mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-22 20:32:42 +08:00
✨ 支持内网部署配置能力
This commit is contained in:
parent
58aabb9f1e
commit
371565744e
@ -1,30 +1,53 @@
|
|||||||
import axios from "axios";
|
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 {
|
export default {
|
||||||
async getTotalPlugins() {
|
async getTotalPlugins() {
|
||||||
const res = await axios.get(
|
let targetPath = "plugins/total-plugins.json";
|
||||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/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;
|
return res.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
async getFinderDetail() {
|
async getFinderDetail() {
|
||||||
const res = await axios.get(
|
let targetPath = "plugins/finder.json";
|
||||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/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;
|
return res.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
async getSystemDetail() {
|
async getSystemDetail() {
|
||||||
const res = await axios.get(
|
let targetPath = "/plugins/system.json";
|
||||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/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;
|
return res.data;
|
||||||
},
|
},
|
||||||
async getWorkerDetail() {
|
async getWorkerDetail() {
|
||||||
const res = await axios.get(
|
let targetPath = "/plugins/worker.json";
|
||||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/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;
|
return res.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -33,16 +56,20 @@ export default {
|
|||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
async getSearchDetail(url: string) {
|
async getSearchDetail() {
|
||||||
const res = await axios.get(
|
let targetPath = "/plugins/search.json";
|
||||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/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;
|
return res.data;
|
||||||
},
|
},
|
||||||
async getDevDetail(url: string) {
|
async getDevDetail() {
|
||||||
const res = await axios.get(
|
let targetPath = "/plugins/dev.json";
|
||||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/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;
|
return res.data;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,12 @@
|
|||||||
</template>
|
</template>
|
||||||
全局快捷键
|
全局快捷键
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
|
<a-menu-item key="localhost">
|
||||||
|
<template #icon>
|
||||||
|
<DatabaseOutlined />
|
||||||
|
</template>
|
||||||
|
内网部署配置
|
||||||
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
</div>
|
</div>
|
||||||
<div class="settings-detail">
|
<div class="settings-detail">
|
||||||
@ -32,26 +38,6 @@
|
|||||||
{{ shortCut.showAndHidden }}
|
{{ shortCut.showAndHidden }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="settings-item-li">-->
|
|
||||||
<!-- <div class="label">插件分离快捷键</div>-->
|
|
||||||
<!-- <div-->
|
|
||||||
<!-- class="value"-->
|
|
||||||
<!-- tabIndex="-1"-->
|
|
||||||
<!-- @keyup="(e) => changeShortCut(e, 'separate')"-->
|
|
||||||
<!-- >-->
|
|
||||||
<!-- {{ shortCut.separate }}-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="settings-item-li">-->
|
|
||||||
<!-- <div class="label">返回主界面</div>-->
|
|
||||||
<!-- <div-->
|
|
||||||
<!-- class="value"-->
|
|
||||||
<!-- tabIndex="-1"-->
|
|
||||||
<!-- @keyup="(e) => changeShortCut(e, 'quit')"-->
|
|
||||||
<!-- >-->
|
|
||||||
<!-- {{ shortCut.quit }}-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
<div class="title">通用</div>
|
<div class="title">通用</div>
|
||||||
@ -80,17 +66,6 @@
|
|||||||
></a-switch>
|
></a-switch>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="setting-item">-->
|
|
||||||
<!-- <div class="title">本地搜索启动</div>-->
|
|
||||||
<!-- <div class="settings-item-li">-->
|
|
||||||
<!-- <div class="label">搜索启动应用&文件</div>-->
|
|
||||||
<!-- <a-switch-->
|
|
||||||
<!-- v-model:checked="local.search"-->
|
|
||||||
<!-- checked-children="开"-->
|
|
||||||
<!-- un-checked-children="关"-->
|
|
||||||
<!-- ></a-switch>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="currentSelect[0] === 'global'">
|
<div v-if="currentSelect[0] === 'global'">
|
||||||
<a-collapse>
|
<a-collapse>
|
||||||
@ -147,15 +122,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div @click="addConfig" class="add-global">+ 新增全局快捷功能</div>
|
<div @click="addConfig" class="add-global">+ 新增全局快捷功能</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Localhost v-if="currentSelect[0] === 'localhost'" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ToolOutlined, LaptopOutlined } from "@ant-design/icons-vue";
|
import { ToolOutlined, LaptopOutlined, DatabaseOutlined } from "@ant-design/icons-vue";
|
||||||
import debounce from "lodash.debounce";
|
import debounce from "lodash.debounce";
|
||||||
import { ref, reactive, watch, toRefs, toRaw } from "vue";
|
import { ref, reactive, watch, toRefs, toRaw } from "vue";
|
||||||
import keycodes from "./keycode";
|
import keycodes from "./keycode";
|
||||||
|
import Localhost from "./localhost.vue";
|
||||||
|
|
||||||
const { remote, ipcRenderer } = window.require("electron");
|
const { remote, ipcRenderer } = window.require("electron");
|
||||||
|
|
||||||
|
90
feature/src/views/settings/localhost.vue
Normal file
90
feature/src/views/settings/localhost.vue
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<template>
|
||||||
|
<a-alert
|
||||||
|
message="把插件发布到公网 npm 如果不符合您的公司安全要求,rubick 支持内网私有源和私有插件库,如果您需要内网部署使用,可以自行配置以下规则。"
|
||||||
|
type="warning"
|
||||||
|
style="margin-bottom: 20px"
|
||||||
|
/>
|
||||||
|
<a-form
|
||||||
|
name="custom-validation"
|
||||||
|
ref="formRef"
|
||||||
|
:model="formState"
|
||||||
|
:rules="rules"
|
||||||
|
v-bind="layout"
|
||||||
|
>
|
||||||
|
<a-form-item has-feedback label="npm 源" name="register">
|
||||||
|
<a-input
|
||||||
|
placeholder="https://registry.npm.taobao.org"
|
||||||
|
v-model:value="formState.register"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item has-feedback label="database url" name="database">
|
||||||
|
<a-input
|
||||||
|
placeholder="https://gitee.com/monkeyWang/rubick-database/raw/master"
|
||||||
|
v-model:value="formState.database"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item has-feedback label="access_token" name="access_token">
|
||||||
|
<a-input
|
||||||
|
placeholder="内网gitlab仓库必填"
|
||||||
|
v-model:value="formState.access_token"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :wrapper-col="{ span: 18, offset: 6 }">
|
||||||
|
<a-button @click="submit" type="primary">确定</a-button>
|
||||||
|
<a-button style="margin-left: 10px" @click="resetForm">恢复默认</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, toRaw } from "vue";
|
||||||
|
import { message } from "ant-design-vue";
|
||||||
|
|
||||||
|
let _rev: any;
|
||||||
|
|
||||||
|
let defaultConfig = {
|
||||||
|
register: "https://registry.npm.taobao.org",
|
||||||
|
database: "https://gitee.com/monkeyWang/rubick-database/raw/master",
|
||||||
|
access_token: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const dbdata = window.rubick.db.get("rubick-localhost-config");
|
||||||
|
defaultConfig = dbdata.data;
|
||||||
|
_rev = dbdata._rev;
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
const formState = ref(JSON.parse(JSON.stringify(defaultConfig)));
|
||||||
|
|
||||||
|
const rules = {
|
||||||
|
register: [{ required: true, trigger: "change" }],
|
||||||
|
database: [{ required: true, trigger: "change" }],
|
||||||
|
};
|
||||||
|
const layout = {
|
||||||
|
labelCol: { span: 6 },
|
||||||
|
wrapperCol: { span: 18 },
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
formState.value = {
|
||||||
|
register: "https://registry.npm.taobao.org",
|
||||||
|
database: "https://gitee.com/monkeyWang/rubick-database/raw/master",
|
||||||
|
access_token: "",
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const submit = () => {
|
||||||
|
const changeData: any = {
|
||||||
|
_id: "rubick-localhost-config",
|
||||||
|
data: toRaw(formState.value),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_rev) {
|
||||||
|
changeData._rev = _rev;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.rubick.db.put(changeData);
|
||||||
|
message.success("设置成功!重启插件市场后生效!");
|
||||||
|
};
|
||||||
|
</script>
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rubick",
|
"name": "rubick",
|
||||||
"version": "2.0.1-beta.12",
|
"version": "2.0.1-beta.13",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
|
@ -3,12 +3,27 @@ import fs from "fs";
|
|||||||
import getLocalDataFile from "./getLocalDataFile";
|
import getLocalDataFile from "./getLocalDataFile";
|
||||||
import { PluginHandler } from "@/core";
|
import { PluginHandler } from "@/core";
|
||||||
import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/main";
|
import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/main";
|
||||||
|
import { API } from "@/main/common/api";
|
||||||
|
|
||||||
const configPath = path.join(getLocalDataFile(), "./rubick-local-plugin.json");
|
const configPath = path.join(getLocalDataFile(), "./rubick-local-plugin.json");
|
||||||
|
|
||||||
const pluginInstance = new PluginHandler({
|
let registry;
|
||||||
|
let pluginInstance;
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
registry = (await API.dbGet({ data: { id: "rubick-localhost-config" } })).data.register;
|
||||||
|
console.log(registry);
|
||||||
|
pluginInstance = new PluginHandler({
|
||||||
baseDir,
|
baseDir,
|
||||||
});
|
registry,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
pluginInstance = new PluginHandler({
|
||||||
|
baseDir,
|
||||||
|
registry,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
global.LOCAL_PLUGINS = {
|
global.LOCAL_PLUGINS = {
|
||||||
PLUGINS: [],
|
PLUGINS: [],
|
||||||
|
@ -9,6 +9,7 @@ import got from "got";
|
|||||||
import fixPath from "fix-path";
|
import fixPath from "fix-path";
|
||||||
|
|
||||||
import spawn from "cross-spawn";
|
import spawn from "cross-spawn";
|
||||||
|
import { ipcRenderer } from "electron";
|
||||||
|
|
||||||
fixPath();
|
fixPath();
|
||||||
|
|
||||||
@ -37,7 +38,19 @@ class AdapterHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.baseDir = options.baseDir;
|
this.baseDir = options.baseDir;
|
||||||
this.registry = options.registry || "https://registry.npm.taobao.org";
|
|
||||||
|
let register = options.registry || "https://registry.npm.taobao.org";
|
||||||
|
|
||||||
|
try {
|
||||||
|
const dbdata = ipcRenderer.sendSync("msg-trigger", {
|
||||||
|
type: "dbGet",
|
||||||
|
data: { id: "rubick-localhost-config" },
|
||||||
|
});
|
||||||
|
register = dbdata.data.register;
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
this.registry = register || "https://registry.npm.taobao.org";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ const dbInstance = new LocalDb(app.getPath("userData"));
|
|||||||
|
|
||||||
dbInstance.init();
|
dbInstance.init();
|
||||||
|
|
||||||
const API: any = {
|
export const API: any = {
|
||||||
currentPlugin: null,
|
currentPlugin: null,
|
||||||
DBKEY: "RUBICK_DB_DEFAULT",
|
DBKEY: "RUBICK_DB_DEFAULT",
|
||||||
getCurrentWindow: (window, e) => {
|
getCurrentWindow: (window, e) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user