muwoo b7d8932291
Update index.ts
ref: 调整插件市场的数据源
2024-09-29 09:55:37 +08:00

100 lines
2.6 KiB
TypeScript

import axios from 'axios';
let baseURL = 'https://gitcode.net/rubickcenter/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({
timeout: 4000,
baseURL:
baseURL || 'https://gitee.com/monkeyWang/rubickdatabase/raw/master',
});
export default {
async getTotalPlugins() {
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() {
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() {
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() {
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;
},
async getPluginDetail(url: string) {
const res = await instance.get(url);
return res.data;
},
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() {
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;
},
async getImageDetail() {
let targetPath = 'plugins/image.json';
if (access_token) {
targetPath = `${encodeURIComponent(
targetPath
)}/raw?access_token=${access_token}&ref=master`;
}
const res = await instance.get(targetPath);
return res.data;
},
};