Merge pull request #76 from rubickCenter/pre-release

 支持开发者刷新插件
This commit is contained in:
木偶 2021-12-27 11:55:28 +08:00 committed by GitHub
commit 91ce71f139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 54 additions and 6 deletions

View File

@ -10,4 +10,7 @@ window.market = {
deletePlugin(plugin) {
return remote.getGlobal("LOCAL_PLUGINS").deletePlugin(plugin);
},
}
refreshPlugin(plugin) {
return remote.getGlobal("LOCAL_PLUGINS").refreshPlugin(plugin);
},
};

View File

@ -14,6 +14,7 @@
<a-form-item :wrapper-col="{ span: 14, offset: 4 }">
<a-button :loading="loading" type="primary" @click="onSubmit">安装</a-button>
<a-button @click="refresh" style="margin-left: 10px;">刷新插件</a-button>
</a-form-item>
</a-form>
</div>
@ -50,6 +51,15 @@ const downloadPlugin = async (pluginName) => {
loading.value = false;
};
const refresh = () => {
formRef.value.validate().then(() => {
window.market.refreshPlugin({
name: formState.name,
});
message.success(`${formState.name}刷新成功!`);
});
};
const labelCol = { span: 4 };
const wrapperCol = { span: 14 };
</script>

View File

@ -1,6 +1,6 @@
{
"name": "rubick",
"version": "2.0.1-beta.8",
"version": "2.0.1-beta.9",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",

View File

@ -1 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>feature</title><link href="css/app.f8214d90.css" rel="preload" as="style"><link href="js/app.9afe693f.js" rel="preload" as="script"><link href="js/chunk-vendors.ebb3d342.js" rel="preload" as="script"><link href="css/app.f8214d90.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but feature doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.ebb3d342.js"></script><script src="js/app.9afe693f.js"></script></body></html>
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>feature</title><link href="css/app.f8214d90.css" rel="preload" as="style"><link href="js/app.c69aa8d8.js" rel="preload" as="script"><link href="js/chunk-vendors.ebb3d342.js" rel="preload" as="script"><link href="css/app.f8214d90.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but feature doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.ebb3d342.js"></script><script src="js/app.c69aa8d8.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -10,4 +10,7 @@ window.market = {
deletePlugin(plugin) {
return remote.getGlobal("LOCAL_PLUGINS").deletePlugin(plugin);
},
refreshPlugin(plugin) {
return remote.getGlobal("LOCAL_PLUGINS").refreshPlugin(plugin);
},
}

View File

@ -32,6 +32,38 @@ global.LOCAL_PLUGINS = {
global.LOCAL_PLUGINS.addPlugin(plugin);
return global.LOCAL_PLUGINS.PLUGINS;
},
refreshPlugin(plugin) {
// 获取 dev 插件信息
const pluginPath = path.resolve(
baseDir,
"node_modules",
plugin.name
);
const pluginInfo = JSON.parse(
fs.readFileSync(path.join(pluginPath, "./package.json"), "utf8")
);
plugin = {
...plugin,
...pluginInfo,
};
// 刷新
let currentPlugins = global.LOCAL_PLUGINS.getLocalPlugins();
currentPlugins = currentPlugins.map((p) => {
if (p.name === plugin.name) {
return plugin;
}
return p;
});
// 存入
global.LOCAL_PLUGINS.PLUGINS = currentPlugins;
fs.writeFileSync(
configPath,
JSON.stringify(currentPlugins)
);
return global.LOCAL_PLUGINS.PLUGINS;
},
getLocalPlugins() {
try {
if (!global.LOCAL_PLUGINS.PLUGINS.length) {