mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
适配QX TF 390+特性
This commit is contained in:
@@ -40,6 +40,9 @@ function initStore(store) {
|
||||
store.dispatch("FETCH_COLLECTIONS").catch(() => {
|
||||
showError(`无法拉取组合订阅列表!`);
|
||||
});
|
||||
store.dispatch("FETCH_ENV").catch(() => {
|
||||
showError(`无法获取当前运行环境!`);
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
@@ -15,13 +15,14 @@ const store = new Vuex.Store({
|
||||
|
||||
subscriptions: {},
|
||||
collections: {},
|
||||
env: {},
|
||||
|
||||
settings: {}
|
||||
},
|
||||
|
||||
mutations: {
|
||||
COPY(state, text) {
|
||||
state.clipboard = text;
|
||||
state.clipboard = text;
|
||||
},
|
||||
// UI
|
||||
SET_NAV_TITLE(state, title) {
|
||||
@@ -56,6 +57,12 @@ const store = new Vuex.Store({
|
||||
state.collections = data;
|
||||
});
|
||||
},
|
||||
// fetch env
|
||||
async FETCH_ENV({state}) {
|
||||
return axios.get("/env").then(resp => {
|
||||
state.env = resp.data;
|
||||
})
|
||||
},
|
||||
// update subscriptions
|
||||
async UPDATE_SUBSCRIPTION({dispatch}, {name, sub}) {
|
||||
return axios.patch(`/sub/${name}`, sub).then(() => {
|
||||
|
||||
@@ -184,11 +184,23 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
subscriptions: function () {
|
||||
subscriptionBaseURL() {
|
||||
const backend = this.$store.state.env.backend;
|
||||
switch (backend) {
|
||||
case "QX":
|
||||
return "http://127.0.0.1:9999";
|
||||
case "Node":
|
||||
case "Surge":
|
||||
case "Loon":
|
||||
default:
|
||||
return BACKEND_BASE;
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
const subs = this.$store.state.subscriptions;
|
||||
return Object.keys(subs).map(k => subs[k]);
|
||||
},
|
||||
collections: function () {
|
||||
collections() {
|
||||
const cols = this.$store.state.collections;
|
||||
return Object.keys(cols).map(k => cols[k]);
|
||||
}
|
||||
@@ -199,7 +211,7 @@ export default {
|
||||
console.log(`${action} --> ${sub.name}`);
|
||||
switch (action) {
|
||||
case 'COPY':
|
||||
this.$clipboard(`${BACKEND_BASE}/download/${sub.name}`);
|
||||
this.$clipboard(`${this.subscriptionBaseURL}/download/${sub.name}`);
|
||||
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
|
||||
break
|
||||
case 'EDIT':
|
||||
@@ -214,7 +226,7 @@ export default {
|
||||
console.log(`${action} --> ${collection.name}`);
|
||||
switch (action) {
|
||||
case 'COPY':
|
||||
this.$clipboard(`${BACKEND_BASE}/download/collection/${collection.name}`);
|
||||
this.$clipboard(`${this.subscriptionBaseURL}/download/collection/${collection.name}`);
|
||||
this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
|
||||
break
|
||||
case 'EDIT':
|
||||
|
||||
Reference in New Issue
Block a user