support Vercel

This commit is contained in:
Stille 2022-08-16 16:37:51 +08:00
parent 26a9d9f11a
commit 22c8085030
8 changed files with 25 additions and 97 deletions

3
.env Normal file
View File

@ -0,0 +1,3 @@
VUE_APP_SITE_NAME = 'subweb'
VUE_APP_API_URL = 'https://sub.ops.ci'
VUE_APP_SHORT_URL = 'https://s.ops.ci'

View File

@ -1,57 +1,10 @@
# subweb
## 简介
subweb 是基于 subconverter 订阅转换的前端项目,方便用户快速生成各平台的订阅链接.
# subweb for Vercel
## Vercel 快速部署
为方便 docker 用户方便挂载或环境变量部署,默认`main`分支不支持`Vercel`,需要`fork`仓库少许设置才能部署至`Vercel`.
1. fork 本仓库, 注意**取消**勾选`Copy the main branch only`
2. Vercel 中创建项目使用`subweb`首次部署.
3. 部署完毕后,在`Vercel`项目 - Settings - Git - Production Branch 设置为`vercel`.
4. 修改环境变量 - Settings - Environment Variables 中修改环境变量,具体参考仓库中`.env`文件.
5. Vercel 部署如需修改导航栏信息,需自行修改`src/layouts/components/header/navBarItem.js`文件.
> *subweb 是我个人入门 vuejs 学习时简单做的一个案例,使用还算方便,开源出来,欢迎各路大佬贡献维护.*
*GitHub [stilleshan/subweb](https://github.com/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)
*`前后端示例,可以直接使用.`*
## 部署
### docker 本地版
*适用于本机快速部署使用*
```shell
docker run -d --name subweb --restart always \
-p 18080:80 \
stilleshan/subweb
```
访问 `http://127.0.0.1:18080`
### docker 自定义版 + 短链接版
自定义版可以挂载配置文件来修改`API 地址`,`短链接地址`,`站点名称`,`导航链接`.
参考以下命令,修改本地挂载路径,启动容器后会生成`config.js`配置文件,更改后刷新生效.
```shell
docker run -d --name subweb --restart always \
-p 18080:80 \
-v /PATH/subweb/public/conf:/usr/share/nginx/html/conf \
stilleshan/subweb
```
同时也可以不挂载目录,直接通过`-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 + myurls 合并进阶版
详情查看 [stilleshan/sub](https://github.com/stilleshan/dockerfiles/tree/main/sub)
## 链接
- [stilleshan/sub](https://github.com/stilleshan/dockerfiles/tree/main/sub)
- [stilleshan/subweb](https://github.com/stilleshan/subweb)
- [stilleshan/subconverter](https://github.com/stilleshan/subconverter)
**其他更多信息请查看`main`分支**

View File

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

View File

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

View File

@ -14,7 +14,7 @@
</template>
<script>
// import { navBarItem } from './navBarItem';
import { navBarItem } from './navBarItem';
export default {
name: 'NavBar',
data() {
@ -24,8 +24,8 @@ export default {
};
},
created() {
this.navBarItem = window.config.menuItem;
this.siteName = window.config.siteName;
this.navBarItem = navBarItem;
this.siteName = process.env.VUE_APP_SITE_NAME;
},
};
</script>

View File

@ -18,7 +18,7 @@
</template>
<script>
// import { navBarItem } from './navBarItem';
import { navBarItem } from './navBarItem';
export default {
name: 'NavBarMobile',
data() {
@ -27,7 +27,7 @@ export default {
};
},
created() {
this.navBarItem = window.config.menuItem;
this.navBarItem = navBarItem;
document.addEventListener('click', (e) => {
if (this.$refs.showPanel) {
let isSelf = this.$refs.showPanel.contains(e.target);

View File

@ -3,20 +3,15 @@ export const navBarItem = [
title: '首页',
link: '/',
target: '',
class: '',
style: '',
id: '',
depth: 'link depth-0',
indent: 'indent-0',
},
{
title: '短链接',
link: 'https://s.ops.ci',
target: '_blank',
},
{
title: 'GitHub',
link: 'https://github.com/stilleshan/subweb',
target: '_blank',
class: '',
style: '',
id: '',
depth: 'link depth-0',
indent: 'indent-0',
},
];

View File

@ -187,13 +187,13 @@ export default {
urls: [],
returnUrl: '',
returnShortUrl: '',
apiUrl: window.config.apiUrl,
shortUrl: window.config.shortUrl,
apiUrl: process.env.VUE_APP_API_URL,
shortUrl: process.env.VUE_APP_SHORT_URL,
manualApiUrl: '',
isShowManualApiUrl: false,
api: 'default',
apis: [
{ value: 'default', text: window.config.apiUrl },
{ value: 'default', text: process.env.VUE_APP_API_URL },
{ value: 'manual', text: '自定义后端 API 地址' },
],
inputs: {