From 5dbb9e353c4f1ea532b9e445c523abc39cb9509d Mon Sep 17 00:00:00 2001 From: CareyWong Date: Thu, 27 Feb 2020 16:44:28 +0800 Subject: [PATCH] Add short url support --- README.md | 6 ++++++ src/views/Subconverter.vue | 11 ++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 20d7792..b9a5962 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,18 @@ ## Table of Contents +- [Update](#Update) - [Requirements](#Requirements) - [Install](#install) - [Usage](#usage) - [Contributing](#contributing) - [License](#license) +## Update +- 20200227 + - 提供了短链接服务,可用于缩短生成的订阅 url,请和谐使用。 + > 注:需要后端支持。自行搭建服务,请参考 [bitly](https://github.com/CareyWang/bitly) 并修改 Subconverter.vue 中 **shortUrlBackend** 配置项。 + ## Requirements 你需要安装 [Node](https://nodejs.org/zh-cn/) 与 [Yarn](https://legacy.yarnpkg.com/en/docs/install) 来安装依赖与打包发布。你可以通过以下命令查看是否安装成功。 注:以下步骤为 Ubuntu 下相应命令,其他系统请自行修改。为了方便后来人解决问题,有问题请发 issue。 diff --git a/src/views/Subconverter.vue b/src/views/Subconverter.vue index 271ae69..9dd4294 100644 --- a/src/views/Subconverter.vue +++ b/src/views/Subconverter.vue @@ -209,7 +209,7 @@ const remoteConfigSample = "https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/example_external_config.ini"; const gayhubRelease = "https://github.com/tindy2013/subconverter/releases"; const defaultBackend = "https://api.wcc.best/sub?"; -const shortUrlBackend = ""; +const shortUrlBackend = "https://api.wcc.best/short"; const configUploadBackend = "https://api.wcc.best/config/upload"; const tgBotLink = "https://t.me/CareyWong_bot"; @@ -482,11 +482,6 @@ export default { this.$message.success("定制订阅已复制到剪贴板"); }, makeShortUrl() { - if (shortUrlBackend === "") { - this.$message.warning("短链接服务后端自定义正在咕……"); - return false; - } - if (this.customSubUrl === "") { this.$message.warning("请先生成订阅链接,再获取对应短链接"); return false; @@ -495,9 +490,7 @@ export default { this.loading = true; this.$axios - .get( - shortUrlBackend + "?longUrl=" + encodeURIComponent(this.customSubUrl) - ) + .get(shortUrlBackend + "?longUrl=" + btoa(this.customSubUrl)) .then(res => { if (res.data.Code === 1 && res.data.ShortUrl !== "") { this.$copyText(res.data.ShortUrl);