mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-01 03:13:15 +08:00
支持Clash YAML输入
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<v-navigation-drawer
|
||||
app
|
||||
fixed
|
||||
|
||||
3
web/src/config.js
Normal file
3
web/src/config.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const DEBUG = true;
|
||||
|
||||
export const BACKEND_BASE = DEBUG ? `http://127.0.0.1:3000` : `http://sub.store`;
|
||||
@@ -52,9 +52,13 @@ const store = new Vuex.Store({
|
||||
});
|
||||
},
|
||||
// update subscriptions
|
||||
async UPDATE_SUBSCRIPTION({commit}, {name, sub}) {
|
||||
async UPDATE_SUBSCRIPTION({commit, dispatch}, {name, sub}) {
|
||||
axios.patch(`/sub/${name}`, sub).then(() => {
|
||||
commit("FETCH_SUBSCRIPTIONS");
|
||||
dispatch("FETCH_SUBSCRIPTIONS");
|
||||
dispatch("FETCH_COLLECTIONS");
|
||||
commit("SET_SUCCESS_MESSAGE", `成功更新订阅${sub.name || name}`);
|
||||
}).catch(err => {
|
||||
commit("SET_ERROR_MESSAGE", err);
|
||||
});
|
||||
},
|
||||
// new subscription
|
||||
@@ -62,8 +66,14 @@ const store = new Vuex.Store({
|
||||
|
||||
},
|
||||
// delete subscription
|
||||
async DELETE_SUBSCRIPTION() {
|
||||
|
||||
async DELETE_SUBSCRIPTION({commit, dispatch}, name) {
|
||||
axios.delete(`/sub/${name}`).then(() => {
|
||||
dispatch("FETCH_SUBSCRIPTIONS");
|
||||
dispatch("FETCH_COLLECTIONS");
|
||||
commit("SET_SUCCESS_MESSAGE", `成功删除订阅${name}`);
|
||||
}).catch(err => {
|
||||
commit("SET_ERROR_MESSAGE", err);
|
||||
})
|
||||
},
|
||||
// update collection
|
||||
async UPDATE_COLLECTION() {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Axios from 'axios';
|
||||
import {BACKEND_BASE} from "@/config";
|
||||
|
||||
export const axios = Axios.create({
|
||||
// baseURL: 'http://sub.store/api',
|
||||
baseURL: 'http://127.0.0.1:3000/api',
|
||||
baseURL: `${BACKEND_BASE}/api`,
|
||||
timeout: 1000
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<template>
|
||||
<v-container></v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "PopUpProxyList"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
40
web/src/views/ProxyList.vue
Normal file
40
web/src/views/ProxyList.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<v-list>
|
||||
<v-list-item v-for="proxy in proxies" :key="proxy.name">
|
||||
<v-list-item-content>
|
||||
<v-list-item-title v-text="proxy.name" class="wrap-text"></v-list-item-title>
|
||||
<v-list-item-subtitle v-text="getType(proxy.type)"></v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
<v-list-item-action>
|
||||
<v-btn icon>
|
||||
<v-icon color="grey lighten-1">mdi-information</v-icon>
|
||||
</v-btn>
|
||||
</v-list-item-action>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "ProxyList",
|
||||
props: ['proxies'],
|
||||
methods: {
|
||||
getType(type) {
|
||||
switch (type) {
|
||||
case 'ss':
|
||||
return 'shadowsocks'
|
||||
case 'ssr':
|
||||
return 'shadowsocksr'
|
||||
default:
|
||||
return type
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.wrap-text {
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
@@ -8,9 +8,8 @@
|
||||
:key="sub.name"
|
||||
@click="preview(sub)"
|
||||
>
|
||||
<v-list-item-avatar>
|
||||
<v-img
|
||||
src="https://avatars2.githubusercontent.com/u/21050064?s=460&u=40a74913dd0a3d00670d05148c3a08c787470021&v=4"></v-img>
|
||||
<v-list-item-avatar dark>
|
||||
<v-icon>mdi-cloud</v-icon>
|
||||
</v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title v-text="sub.name" class="font-weight-medium"></v-list-item-title>
|
||||
@@ -47,12 +46,11 @@
|
||||
<v-list-item
|
||||
v-for="collection in collections"
|
||||
:key="collection.name"
|
||||
@click="preview(collection)"
|
||||
@click="preview(collection, type='collection')"
|
||||
dense
|
||||
>
|
||||
<v-list-item-avatar>
|
||||
<v-img
|
||||
src="https://avatars2.githubusercontent.com/u/21050064?s=460&u=40a74913dd0a3d00670d05148c3a08c787470021&v=4"></v-img>
|
||||
<v-list-item-avatar dark>
|
||||
<v-icon>mdi-cloud</v-icon>
|
||||
</v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title v-text="collection.name" class="font-weight-medium"></v-list-item-title>
|
||||
@@ -97,6 +95,7 @@
|
||||
</v-list>
|
||||
<v-fab-transition>
|
||||
<v-speed-dial
|
||||
v-if="!showProxyList"
|
||||
v-model="opened"
|
||||
direction="top"
|
||||
right
|
||||
@@ -122,14 +121,37 @@
|
||||
</v-btn>
|
||||
</v-speed-dial>
|
||||
</v-fab-transition>
|
||||
<v-dialog fullscreen hide-overlay transition="dialog-bottom-transition" v-model="showProxyList">
|
||||
<v-card>
|
||||
<v-toolbar dark color="primary">
|
||||
<v-icon>mdi-cloud</v-icon>
|
||||
<v-spacer></v-spacer>
|
||||
<v-toolbar-title>节点列表</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
<v-toolbar-items>
|
||||
<v-btn icon @click="showProxyList = false">
|
||||
<v-icon>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-toolbar-items>
|
||||
</v-toolbar>
|
||||
<proxy-list :proxies="proxies"></proxy-list>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ProxyList from "@/views/ProxyList";
|
||||
import {BACKEND_BASE} from "@/config";
|
||||
import {axios} from "@/utils";
|
||||
|
||||
export default {
|
||||
components: {ProxyList},
|
||||
data: () => {
|
||||
return {
|
||||
opened: false,
|
||||
showProxyList: false,
|
||||
proxies: [],
|
||||
editMenu: [
|
||||
{
|
||||
title: "复制",
|
||||
@@ -163,13 +185,14 @@ export default {
|
||||
console.log(`${action} --> ${sub.name}`);
|
||||
switch (action) {
|
||||
case 'COPY':
|
||||
this.$clipboard(`http://127.0.0.1:3000/download/${sub.name}`);
|
||||
this.$clipboard(`${BACKEND_BASE}/download/${sub.name}`);
|
||||
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
|
||||
break
|
||||
case 'EDIT':
|
||||
this.$router.push(`/sub-edit/${sub.name}`);
|
||||
break
|
||||
case 'DELETE':
|
||||
this.$store.dispatch("DELETE_SUBSCRIPTION", sub.name);
|
||||
break
|
||||
}
|
||||
},
|
||||
@@ -177,17 +200,30 @@ export default {
|
||||
console.log(`${action} --> ${collection.name}`);
|
||||
switch (action) {
|
||||
case 'COPY':
|
||||
this.$clipboard(`http://127.0.0.1:3000/download/collection/${collection.name}`);
|
||||
this.$clipboard(`${BACKEND_BASE}/download/collection/${collection.name}`);
|
||||
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
|
||||
break
|
||||
case 'EDIT':
|
||||
break
|
||||
case 'DELETE':
|
||||
this.$store.dispatch("DELETE_COLLECTION", collection.name);
|
||||
break
|
||||
}
|
||||
},
|
||||
preview(item) {
|
||||
console.log(`PREVIEW: ${item.name}`);
|
||||
preview(item, type = 'sub') {
|
||||
let url;
|
||||
if (type === 'sub') {
|
||||
url = `${BACKEND_BASE}/download/${item.name}`
|
||||
} else {
|
||||
url = `${BACKEND_BASE}/download/collection/${item.name}`
|
||||
}
|
||||
axios.get(url).then(resp => {
|
||||
const {data} = resp;
|
||||
this.proxies = data.split("\n").map(p => JSON.parse(p));
|
||||
this.showProxyList = true;
|
||||
}).catch(err => {
|
||||
this.$store.commit("SET_ERROR_MESSAGE", err);
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user