mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-04-23 06:09:33 +08:00
适配QX TF 390+特性
This commit is contained in:
parent
77ec9c6953
commit
ea7f208882
@ -94,6 +94,18 @@ $app.route("/api/storage")
|
||||
.get(exportData)
|
||||
.post(importData);
|
||||
|
||||
$app.get("/api/env", async (req, res) => {
|
||||
const {isNode, isQX, isLoon, isSurge} = ENV();
|
||||
let backend = "Node";
|
||||
if (isNode) backend = "Node";
|
||||
if (isQX) backend = "QX";
|
||||
if (isLoon) backend = "Loon";
|
||||
if (isSurge) backend = "Surge";
|
||||
res.json({
|
||||
backend
|
||||
});
|
||||
});
|
||||
|
||||
$app.all("/", async (req, res) => {
|
||||
res.send("Hello from Sub-Store! Made with ❤️ by Peng-YM.");
|
||||
});
|
||||
|
2
backend/sub-store.min.js
vendored
2
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
11
config/QX.conf
Normal file
11
config/QX.conf
Normal file
@ -0,0 +1,11 @@
|
||||
# QX TF最新版本(build 390+)配置,请复制到配置的指定位置使用
|
||||
[rewrite_local]
|
||||
^https?:\/\/sub\.store url script-analyze-echo-response https://raw.githubusercontent.com/Peng-YM/Sub-Store/master/backend/sub-store.min.js
|
||||
|
||||
[mitm]
|
||||
# 添加一个sub.store域名
|
||||
hostname=sub.store
|
||||
simple_cert_hostname=sub.store
|
||||
|
||||
[http_backend]
|
||||
https://raw.githubusercontent.com/Peng-YM/Sub-Store/master/backend/sub-store.min.js, tag=Sub-Store, path=/, enabled=true, img-url=https://raw.githubusercontent.com/58xinian/icon/master/Sub-Store1.png
|
@ -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':
|
||||
|
Loading…
x
Reference in New Issue
Block a user