Giter VIP home page Giter VIP logo

url-shortener-cfworker's Introduction

使用Cloudflare Worker创建的URL缩短器|支持自定义首页|支持Menu Short|支持短网址、文本、网页分享

首页

后台

后台

常量设置

const admin_path = '/admin_err24d' // 访问地址,如果需要公开访问,把`/admin_err24d`设置成`/`即可
const api_path = '/vcfgbn_api'  //Short Menu第三方访问api,建议设置复杂
const url_key = 'longUrl'  //原始长链接
const url_name = 'shortCode' // 自定义后缀  
const short_url_key = 'shorturl';   //完整缩短后链接,'shorturl'是为了兼容Short Menu

网址响应

{
 "longUrl":"https://abc.com",
 "shortCode":"dfcw",
 "type":"link",
 "shorturl":"https://url.com/dfcw"
}

文本响应

{
 "longUrl":"这是测试文本",
 "shortCode":"dfce",
 "type":"text",
 "shorturl":"https://url.com/dfce"
}

自定义首页index.js

const statichtml = "https://raw.githubusercontent.com/bituplink/OneHtmlNav/master/goodweb.html"

修改上方网址为自己喜欢的网址,只支持单html,建议css和js和script集成进html里


去Workers KV中创建一个命名空间

去Workers KV中创建一个命名空间

去Worker的设置选选项卡中绑定KV 命名空间

绑定KV Namespace 1

绑定KV Namespace 2

其中变量名称填写shortlink, KV 命名空间填写你刚刚创建的命名空间

绑定kv

复制本项目中的index.js的代码到Cloudflare Worker

点击保存并部署


Short Menu设置截图

Upic设置

短链接来自于@xyTom@code-scan

自定义首页来自@bituplink

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.