update subweb

This commit is contained in:
Stille 2022-07-11 16:22:45 +08:00
parent 2da0d0ad0a
commit 5326269875
11 changed files with 102 additions and 93 deletions

View File

@ -1,2 +0,0 @@
NODE_ENV = 'development'
VUE_APP_BASE_API_URL = 'http://127.0.0.1:25500'

View File

@ -1,2 +0,0 @@
NODE_ENV = 'production'
VUE_APP_BASE_API_URL = 'http://127.0.0.1:25500'

View File

@ -8,5 +8,6 @@ RUN npm run build
FROM nginx:1.16-alpine FROM nginx:1.16-alpine
COPY --from=build /app/dist /usr/share/nginx/html COPY --from=build /app/dist /usr/share/nginx/html
COPY . /app
EXPOSE 80 EXPOSE 80
CMD [ "nginx", "-g", "daemon off;" ] CMD [ "sh", "-c", "/app/start.sh" ]

View File

@ -1,8 +1,4 @@
# subweb # subweb
GitHub [stilleshan/dockerfiles](https://github.com/stilleshan/dockerfiles)
Docker [stilleshan/subweb](https://hub.docker.com/r/stilleshan/subweb)
> *docker image support for X86 and ARM*
## 简介 ## 简介
subweb 是基于 subconverter 订阅转换的前端项目,方便用户快速生成各平台的订阅链接. subweb 是基于 subconverter 订阅转换的前端项目,方便用户快速生成各平台的订阅链接.
@ -10,6 +6,7 @@ subweb 是基于 subconverter 订阅转换的前端项目,方便用户快速生
*GitHub [stilleshan/subweb](https://github.com/stilleshan/subweb) *GitHub [stilleshan/subweb](https://github.com/stilleshan/subweb)
Docker [stilleshan/subweb](https://hub.docker.com/r/stilleshan/subweb)* Docker [stilleshan/subweb](https://hub.docker.com/r/stilleshan/subweb)*
> *docker image support for X86 and ARM*
## 示例 ## 示例
[https://sub.ops.ci](https://sub.ops.ci) [https://sub.ops.ci](https://sub.ops.ci)
@ -17,27 +14,39 @@ Docker [stilleshan/subweb](https://hub.docker.com/r/stilleshan/subweb)*
## 部署 ## 部署
### docker 本地版 ### docker 本地版
*适用于本机部署使用* *适用于本机快速部署使用*
```shell ```shell
docker run -d --name subweb --restart always -p 18080:80 stilleshan/subweb docker run -d --name subweb --restart always \
-p 18080:80 \
stilleshan/subweb
``` ```
访问 `http://127.0.0.1:18080` 访问 `http://127.0.0.1:18080`
### docker 在线版 (自定义后端 API) ### docker 自定义版
*适用于服务器部署,配合域名反代使用* 自定义版可以挂载配置文件来修改`API 地址`,`站点名称`,`导航链接`.
参考以下命令,修改本地挂载路径,启动容器后会生成`config.js`配置文件,更改后刷新生效.
**修改自定义 subconverter API 地址需要自行编译构建镜像. **
```shell ```shell
git clone https://github.com/stilleshan/subweb docker run -d --name subweb --restart always \
cd subweb -p 18080:80 \
# 修改 .env.productionn 中 VUE_APP_BASE_API_URL 为你 subconverter 后端 API 地址. -v /PATH/subweb/conf:/usr/share/nginx/html/conf \
docker build -t subweb . stilleshan/subweb
# 构建镜像
docker run -d --name subweb --restart always -p 18080:80 subweb
# 启动容器
``` ```
同时也可以不挂载目录,直接通过`-e`环境变量来修改`API 地址`和`站点名称`,但是无法修改`导航链接`.
```shell
docker run -d --name subweb --restart always \
-p 18080:80 \
-e SITE_NAME=subweb \
-e API_URL=https://sub.ops.ci \
stilleshan/subweb
```
访问 `http://127.0.0.1:18080`
> *推荐使用 nginx 反向代理部署*
## 链接 ## 链接
- [GitHub - stilleshan/subweb](https://github.com/stilleshan/subweb) - [GitHub - stilleshan/subweb](https://github.com/stilleshan/subweb)
- [GitHub - stilleshan/subconverter](https://github.com/stilleshan/subconverter) - [GitHub - stilleshan/subconverter](https://github.com/stilleshan/subconverter)

View File

@ -0,0 +1,16 @@
window.config = {
siteName: 'Subconverter Web',
apiUrl: 'http://127.0.0.1:25500',
menuItem: [
{
title: '首页',
link: '/',
target: '',
},
{
title: 'GitHub',
link: 'https://github.com/stilleshan/subweb',
target: '_blank',
},
],
};

View File

@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<script type="text/javascript" src="<%= BASE_URL %>conf/config.js"></script>
</head> </head>
<body> <body>
<noscript> <noscript>

View File

@ -1,12 +1,12 @@
<template> <template>
<header id="header" class="reveal"> <header id="header" class="reveal">
<h1><a href="/">Subconverter Web</a></h1> <h1>
<a href="/">{{ siteName }}</a>
</h1>
<nav id="nav" ref="navBar"> <nav id="nav" ref="navBar">
<ul> <ul>
<li v-for="i in navBarItem" :key="i" :class="i.style"> <li v-for="i in navBarItem" :key="i">
<a :href="i.link" :class="i.class" :target="i.target">{{ <a :href="i.link" :target="i.target">{{ i.title }}</a>
i.title
}}</a>
</li> </li>
</ul> </ul>
</nav> </nav>
@ -14,16 +14,18 @@
</template> </template>
<script> <script>
import { navBarItem } from './navBarItem'; // import { navBarItem } from './navBarItem';
export default { export default {
name: 'NavBar', name: 'NavBar',
data() { data() {
return { return {
navBarItem: [], navBarItem: [],
siteName: '',
}; };
}, },
created() { created() {
this.navBarItem = navBarItem; this.navBarItem = window.config.menuItem;
this.siteName = window.config.siteName;
}, },
}; };
</script> </script>

View File

@ -8,9 +8,9 @@
:key="i" :key="i"
:href="i.link" :href="i.link"
:target="i.target" :target="i.target"
:class="i.depth" class="link depth-0"
style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0)"
><span :class="i.indent"></span>{{ i.title }}</a ><span class="indent-0"></span>{{ i.title }}</a
> >
</nav> </nav>
</div> </div>
@ -18,7 +18,7 @@
</template> </template>
<script> <script>
import { navBarItem } from './navBarItem'; // import { navBarItem } from './navBarItem';
export default { export default {
name: 'NavBarMobile', name: 'NavBarMobile',
data() { data() {
@ -27,7 +27,7 @@ export default {
}; };
}, },
created() { created() {
this.navBarItem = navBarItem; this.navBarItem = window.config.menuItem;
document.addEventListener('click', (e) => { document.addEventListener('click', (e) => {
if (this.$refs.showPanel) { if (this.$refs.showPanel) {
let isSelf = this.$refs.showPanel.contains(e.target); let isSelf = this.$refs.showPanel.contains(e.target);

View File

@ -2,29 +2,14 @@
<div class="box"> <div class="box">
<form method="post" action="#"> <form method="post" action="#">
<div class="row gtr-uniform gtr-50"> <div class="row gtr-uniform gtr-50">
<span v-for="(item, index) in inputs" :key="item" class="col-12 row"> <div class="col-12">
<div <textarea
class="col-10 col-10-mobilep" id="message"
style="text-align: center; padding-top: 10px" v-model.trim="inputs.inputValue"
> :placeholder="inputs.placeholder"
<input rows="3"
type="text" ></textarea>
v-model.trim="item.inputValue" </div>
:placeholder="item.placeholder"
/>
</div>
<div
class="col-2 col-2-mobilep"
style="text-align: center; padding-top: 10px"
>
<input
type="button"
:value="item.buttonValue"
:class="item.buttonClass"
@click="addLinks(index)"
/>
</div>
</span>
<div <div
class="col-4 col-4-mobilep list" class="col-4 col-4-mobilep list"
style="text-align: center; padding-top: 20px" style="text-align: center; padding-top: 20px"
@ -108,7 +93,7 @@
> >
<ul class="actions"> <ul class="actions">
<li> <li>
<input type="button" value="生成链接" @click="checkAll()" /> <input type="button" value="订阅转换" @click="checkAll()" />
</li> </li>
<!-- <li><input type="reset" value="重置内容" class="alt" /></li> --> <!-- <li><input type="reset" value="重置内容" class="alt" /></li> -->
<li> <li>
@ -125,9 +110,7 @@
<input <input
type="text" type="text"
readOnly="true" readOnly="true"
:placeholder=" placeholder="点击订阅转换获取链接"
this.apiUrl + '/sub?target=' + this.targetType + '&url='
"
v-model.trim="returnUrl" v-model.trim="returnUrl"
/> />
</div> </div>
@ -172,22 +155,20 @@ export default {
isShowMoreConfig: false, isShowMoreConfig: false,
urls: [], urls: [],
returnUrl: '', returnUrl: '',
apiUrl: process.env.VUE_APP_BASE_API_URL, apiUrl: window.config.apiUrl,
manualApiUrl: '', manualApiUrl: '',
isManualApi: true, isManualApi: true,
api: 'default', api: 'default',
apis: [ apis: [
{ value: 'default', text: process.env.VUE_APP_BASE_API_URL }, { value: 'default', text: window.config.apiUrl },
{ value: 'manual', text: '自定义后端 API 地址' }, { value: 'manual', text: '自定义后端 API 地址' },
], ],
inputs: [ inputs: {
{ buttonClass: '',
buttonClass: '', inputValue: '',
buttonValue: '添加', placeholder:
inputValue: '', '多订阅链接或节点请确保每行一条\n支持手动使用"|"分割多链接或节点',
placeholder: '订阅地址', },
},
],
targetType: 'clash', targetType: 'clash',
targetTypes: [ targetTypes: [
{ value: 'clash', text: 'Clash' }, { value: 'clash', text: 'Clash' },
@ -223,17 +204,6 @@ export default {
resetDialog() { resetDialog() {
this.dialogVisible = false; this.dialogVisible = false;
}, },
addLinks(index) {
if (index == 0) {
this.inputs.push({
buttonClass: 'alt',
buttonValue: '移除',
placeholder: '订阅地址',
});
} else {
this.inputs.splice(index, 1);
}
},
selectApi(event) { selectApi(event) {
if (event.target.value == 'manual') { if (event.target.value == 'manual') {
this.isManualApi = false; this.isManualApi = false;
@ -245,18 +215,13 @@ export default {
this.targetType = event.target.value; this.targetType = event.target.value;
}, },
checkUrls() { checkUrls() {
this.urls = []; if (this.inputs.inputValue == '') {
for (const i in this.inputs) { this.dialogMessage = '请填写正确的订阅地址';
if (utils.regexCheck(this.inputs[i].inputValue)) { this.dialogVisible = true;
this.urls.push(this.inputs[i].inputValue); return false;
if (Number(i) + 1 == this.inputs.length) { } else {
return true; this.urls = this.inputs.inputValue;
} return true;
} else {
this.dialogMessage = '请填写正确的订阅地址';
this.dialogVisible = true;
return false;
}
} }
}, },
checkApi() { checkApi() {

View File

@ -5,7 +5,8 @@ const getSubLink = function (
isShowMoreConfig, isShowMoreConfig,
moreConfig moreConfig
) { ) {
let link = links.join('|'); let linkLst = links.split('\n');
let link = linkLst.join('|');
let finalUrl = let finalUrl =
apiUrl + '/sub?target=' + targetType + '&url=' + encodeURIComponent(link); apiUrl + '/sub?target=' + targetType + '&url=' + encodeURIComponent(link);
if (isShowMoreConfig) { if (isShowMoreConfig) {

18
subweb/start.sh Executable file
View File

@ -0,0 +1,18 @@
#/bin/sh
if [ ! -f /usr/share/nginx/html/conf/config.js ]; then
cp /app/public/conf/config.js /usr/share/nginx/html/conf
fi
if [ $API_URL ]; then
echo "当前 API 地址为: $API_URL"
sed -i "s#http://127.0.0.1:25500#$API_URL#g" /usr/share/nginx/html/conf/config.js
else
echo "当前为默认本地 API 地址: http://127.0.0.1:25500"
echo "如需修改请在容器启动时使用 -e API_URL='https://sub.ops.ci' 传递环境变量"
fi
if [ $SITE_NAME ]; then
sed -i "s#Subconverter Web#$SITE_NAME#g" /usr/share/nginx/html/conf/config.js
fi
nginx -g "daemon off;"