mirror of https://github.com/stilleshan/subweb.git
update to support short url
This commit is contained in:
parent
884e1036c8
commit
758e4621ce
10
README.md
10
README.md
|
@ -23,8 +23,8 @@ docker run -d --name subweb --restart always \
|
|||
|
||||
访问 `http://127.0.0.1:18080`
|
||||
|
||||
### docker 自定义版
|
||||
自定义版可以挂载配置文件来修改`API 地址`,`站点名称`,`导航链接`.
|
||||
### docker 自定义版 + 短链接版
|
||||
自定义版可以挂载配置文件来修改`API 地址`,`短链接地址`,`站点名称`,`导航链接`.
|
||||
参考以下命令,修改本地挂载路径,启动容器后会生成`config.js`配置文件,更改后刷新生效.
|
||||
|
||||
```shell
|
||||
|
@ -34,19 +34,21 @@ docker run -d --name subweb --restart always \
|
|||
stilleshan/subweb
|
||||
```
|
||||
|
||||
同时也可以不挂载目录,直接通过`-e`环境变量来修改`API 地址`和`站点名称`,但是无法修改`导航链接`.
|
||||
同时也可以不挂载目录,直接通过`-e`环境变量来修改`API 地址`,`短链接地址`和`站点名称`,但是无法修改`导航链接`.
|
||||
`注意:以下域名请严格填写 http/https 协议,结尾不要 /`
|
||||
```shell
|
||||
docker run -d --name subweb --restart always \
|
||||
-p 18080:80 \
|
||||
-e SITE_NAME=subweb \
|
||||
-e API_URL=https://sub.ops.ci \
|
||||
-e SHORT_URL=https://s.ops.ci \
|
||||
stilleshan/subweb
|
||||
```
|
||||
|
||||
访问 `http://127.0.0.1:18080`
|
||||
> *推荐使用 nginx 反向代理部署*
|
||||
|
||||
### subweb + subconverter 合并进阶版
|
||||
### subweb + subconverter + myurls 合并进阶版
|
||||
详情查看 [stilleshan/sub](https://github.com/stilleshan/dockerfiles/tree/main/sub)
|
||||
|
||||
## 链接
|
||||
|
|
|
@ -2654,6 +2654,11 @@
|
|||
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz",
|
||||
"integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg=="
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"at-least-node": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/at-least-node/-/at-least-node-1.0.0.tgz",
|
||||
|
@ -2674,6 +2679,15 @@
|
|||
"postcss-value-parser": "^4.2.0"
|
||||
}
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.27.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
|
||||
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.14.9",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"babel-loader": {
|
||||
"version": "8.2.5",
|
||||
"resolved": "https://registry.npmmirror.com/babel-loader/-/babel-loader-8.2.5.tgz",
|
||||
|
@ -3142,6 +3156,14 @@
|
|||
"integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==",
|
||||
"dev": true
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmmirror.com/commander/-/commander-2.20.3.tgz",
|
||||
|
@ -3691,6 +3713,11 @@
|
|||
"object-keys": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
|
||||
},
|
||||
"depd": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz",
|
||||
|
@ -4595,8 +4622,17 @@
|
|||
"follow-redirects": {
|
||||
"version": "1.15.1",
|
||||
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.1.tgz",
|
||||
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA=="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"forwarded": {
|
||||
"version": "0.2.0",
|
||||
|
@ -5699,14 +5735,12 @@
|
|||
"mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mime-db": "1.52.0"
|
||||
}
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2",
|
||||
"core-js": "^3.8.3",
|
||||
"element-plus": "^2.1.4",
|
||||
"mitt": "^3.0.0",
|
||||
"vue": "^3.2.13",
|
||||
"vue-router": "^4.0.3",
|
||||
"element-plus": "^2.1.4"
|
||||
"vue-router": "^4.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.16",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
window.config = {
|
||||
siteName: 'Subconverter Web',
|
||||
apiUrl: 'http://127.0.0.1:25500',
|
||||
shortUrl: 'https://s.ops.ci',
|
||||
menuItem: [
|
||||
{
|
||||
title: '首页',
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export function request(config) {
|
||||
const instance = axios.create({
|
||||
timeout: 5000,
|
||||
});
|
||||
|
||||
return instance(config);
|
||||
}
|
|
@ -120,7 +120,29 @@
|
|||
>
|
||||
<ul class="actions">
|
||||
<li>
|
||||
<input type="button" value="复制" @click="toCopy()" />
|
||||
<input
|
||||
type="button"
|
||||
value="复制"
|
||||
@click="toCopy(this.returnUrl, '订阅链接')"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-10" style="text-align: center; padding-top: 20px">
|
||||
<input
|
||||
type="text"
|
||||
readOnly="true"
|
||||
placeholder="点击生成短链接"
|
||||
v-model.trim="returnShortUrl"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="col-2 col-2-mobilep"
|
||||
style="text-align: center; padding-top: 20px"
|
||||
>
|
||||
<ul class="actions">
|
||||
<li>
|
||||
<input type="button" value="短链" @click="getShortUrl()" />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -135,6 +157,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { request } from 'network';
|
||||
import utils from './utils.js';
|
||||
import DialogLayOut from 'components/common/dialog/DialogLayOut.vue';
|
||||
export default {
|
||||
|
@ -165,7 +188,9 @@ export default {
|
|||
isShowMoreConfig: false,
|
||||
urls: [],
|
||||
returnUrl: '',
|
||||
returnShortUrl: '',
|
||||
apiUrl: window.config.apiUrl,
|
||||
shortUrl: window.config.shortUrl,
|
||||
manualApiUrl: '',
|
||||
isManualApi: true,
|
||||
api: 'default',
|
||||
|
@ -268,20 +293,20 @@ export default {
|
|||
this.getFinalUrl();
|
||||
}
|
||||
},
|
||||
toCopy() {
|
||||
if (!this.returnUrl) {
|
||||
toCopy(url, title) {
|
||||
if (!url) {
|
||||
this.dialogMessage = '内容为空,请先订阅转换.';
|
||||
this.dialogVisible = true;
|
||||
} else {
|
||||
var copyInput = document.createElement('input');
|
||||
copyInput.setAttribute('value', this.returnUrl);
|
||||
copyInput.setAttribute('value', url);
|
||||
document.body.appendChild(copyInput);
|
||||
copyInput.select();
|
||||
try {
|
||||
var copyed = document.execCommand('copy');
|
||||
if (copyed) {
|
||||
document.body.removeChild(copyInput);
|
||||
this.dialogMessage = '复制成功';
|
||||
this.dialogMessage = title + '复制成功';
|
||||
this.dialogVisible = true;
|
||||
}
|
||||
} catch {
|
||||
|
@ -290,6 +315,33 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
getShortUrl() {
|
||||
if (this.returnUrl == '') {
|
||||
this.dialogMessage = '内容为空,请先订阅转换.';
|
||||
this.dialogVisible = true;
|
||||
} else {
|
||||
let data = new FormData();
|
||||
data.append('longUrl', btoa(this.returnUrl));
|
||||
request({
|
||||
method: 'post',
|
||||
url: this.shortUrl + '/short',
|
||||
header: {
|
||||
'Content-Type': 'application/form-data; charset=utf-8',
|
||||
},
|
||||
data: data,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.Code === 1 && res.data.ShortUrl !== '') {
|
||||
this.returnShortUrl = res.data.ShortUrl;
|
||||
this.toCopy(res.data.ShortUrl, '短链接');
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.dialogMessage = '短链接生成失败';
|
||||
this.dialogVisible = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
5
start.sh
5
start.sh
|
@ -11,6 +11,11 @@ else
|
|||
echo "如需修改请在容器启动时使用 -e API_URL='https://sub.ops.ci' 传递环境变量"
|
||||
fi
|
||||
|
||||
if [ $SHORT_URL ]; then
|
||||
echo "当前短链接地址为: $API_URL"
|
||||
sed -i "s#https://s.ops.ci#$SHORT_URL#g" /usr/share/nginx/html/conf/config.js
|
||||
fi
|
||||
|
||||
if [ $SITE_NAME ]; then
|
||||
sed -i "s#Subconverter Web#$SITE_NAME#g" /usr/share/nginx/html/conf/config.js
|
||||
fi
|
||||
|
|
|
@ -9,6 +9,7 @@ module.exports = defineConfig({
|
|||
assets: '@/assets',
|
||||
components: '@/components',
|
||||
views: '@/views',
|
||||
network: '@/network',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue