From 371565744e4f8434299f12123b7a1b74f0df24ec Mon Sep 17 00:00:00 2001
From: muwoo <2424880409@qq.com>
Date: Mon, 10 Jan 2022 19:13:26 +0800
Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=94=AF=E6=8C=81=E5=86=85?=
=?UTF-8?q?=E7=BD=91=E9=83=A8=E7=BD=B2=E9=85=8D=E7=BD=AE=E8=83=BD=E5=8A=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
feature/src/assets/request/index.ts | 67 ++++++++++++------
feature/src/views/settings/index.vue | 41 +++--------
feature/src/views/settings/localhost.vue | 90 ++++++++++++++++++++++++
package.json | 2 +-
src/common/utils/localPlugin.ts | 21 +++++-
src/core/plugin-handler/index.ts | 15 +++-
src/main/common/api.ts | 2 +-
7 files changed, 180 insertions(+), 58 deletions(-)
create mode 100644 feature/src/views/settings/localhost.vue
diff --git a/feature/src/assets/request/index.ts b/feature/src/assets/request/index.ts
index e003247..fa61b9e 100644
--- a/feature/src/assets/request/index.ts
+++ b/feature/src/assets/request/index.ts
@@ -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;
},
};
diff --git a/feature/src/views/settings/index.vue b/feature/src/views/settings/index.vue
index 46bfd3b..201a59c 100644
--- a/feature/src/views/settings/index.vue
+++ b/feature/src/views/settings/index.vue
@@ -14,6 +14,12 @@
全局快捷键
+