支持内网部署配置能力

This commit is contained in:
muwoo
2022-01-10 19:13:26 +08:00
parent 58aabb9f1e
commit 371565744e
7 changed files with 180 additions and 58 deletions

View File

@@ -1,30 +1,53 @@
import axios from "axios";
let baseURL = "https://gitee.com/monkeyWang/rubick-database/raw/master";
let access_token = "";
try {
const dbdata = window.rubick.db.get("rubick-localhost-config");
baseURL = dbdata.data.database;
access_token = dbdata.data.access_token;
} catch (e) {
// ignore
}
const instance = axios.create({
baseURL: baseURL || "https://gitee.com/monkeyWang/rubick-database/raw/master",
});
export default {
async getTotalPlugins() {
const res = await axios.get(
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/total-plugins.json"
);
let targetPath = "plugins/total-plugins.json";
if (access_token) {
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
}
const res = await instance.get(targetPath);
return res.data;
},
async getFinderDetail() {
const res = await axios.get(
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/finder.json"
);
let targetPath = "plugins/finder.json";
if (access_token) {
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
}
const res = await instance.get(targetPath);
return res.data;
},
async getSystemDetail() {
const res = await axios.get(
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/system.json"
);
let targetPath = "/plugins/system.json";
if (access_token) {
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
}
const res = await instance.get(targetPath);
return res.data;
},
async getWorkerDetail() {
const res = await axios.get(
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/worker.json"
);
let targetPath = "/plugins/worker.json";
if (access_token) {
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
}
const res = await instance.get(targetPath);
return res.data;
},
@@ -33,16 +56,20 @@ export default {
return res.data;
},
async getSearchDetail(url: string) {
const res = await axios.get(
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/search.json"
);
async getSearchDetail() {
let targetPath = "/plugins/search.json";
if (access_token) {
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
}
const res = await instance.get(targetPath);
return res.data;
},
async getDevDetail(url: string) {
const res = await axios.get(
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/dev.json"
);
async getDevDetail() {
let targetPath = "/plugins/dev.json";
if (access_token) {
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
}
const res = await instance.get(targetPath);
return res.data;
},
};