♻️ 优化插件中心功能

This commit is contained in:
muwoo 2022-01-17 20:32:08 +08:00
parent 240175c571
commit 751c73b3a6
10 changed files with 48 additions and 21 deletions

View File

@ -53,6 +53,21 @@ export default createStore({
totalPlugins,
});
},
startUnDownload({ commit, state }, name) {
const localPlugins = (window as any).market.getLocalPlugins();
localPlugins.forEach(
(origin: { isdwonload?: any; name?: any; isloading: boolean }) => {
if (origin.name === name) {
origin.isloading = true;
}
}
);
commit("commonUpdate", {
localPlugins,
});
},
successDownload({ commit, state }, name) {
const totalPlugins = JSON.parse(JSON.stringify(state.totalPlugins));
totalPlugins.forEach(
@ -70,10 +85,20 @@ export default createStore({
localPlugins,
});
},
updateLocalPlugin({ commit }) {
async updateLocalPlugin({ commit }) {
const localPlugins = (window as any).market.getLocalPlugins();
const totalPlugins = await request.getTotalPlugins();
totalPlugins.forEach(
(origin: { isdwonload?: any; name?: any; isloading: boolean }) => {
origin.isdwonload = isDownload(origin, localPlugins);
origin.isloading = false;
}
);
commit("commonUpdate", {
localPlugins,
totalPlugins,
});
},
},

View File

@ -40,8 +40,11 @@
type="danger"
size="small"
shape="round"
:loading="pluginDetail.isloading"
@click="deletePlugin(pluginDetail)"
>移除</a-button
>
移除
</a-button
>
</div>
</div>
@ -56,17 +59,11 @@
<div>{{ item.explain }}</div>
<a-tag
:key="cmd"
@click="
openPlugin({
cmd,
plugin: pluginDetail,
feature: item,
router: $router,
})
"
v-for="cmd in item.cmds"
@close="removeFeature(cmd)"
:color="!cmd.label && '#87d068'"
>
{{ cmd }}
{{ cmd.label || cmd }}
</a-tag>
</div>
</div>
@ -101,6 +98,7 @@ const localPlugins = computed(() =>
)
);
const updateLocalPlugin = () => store.dispatch("updateLocalPlugin");
const startUnDownload = (name) => store.dispatch("startUnDownload", name);
const currentSelect = ref([0]);
@ -124,6 +122,7 @@ const readme = computed(() => {
});
const deletePlugin = async (plugin) => {
startUnDownload(plugin.name);
await window.market.deletePlugin(plugin);
updateLocalPlugin();
};

View File

@ -57,9 +57,9 @@
<div class="desc">
{{ detail.description }}
</div>
<a-button shape="round" type="primary">
<a-button v-if="!detail.isdwonload" @click.stop="downloadPlugin(detail)" shape="round" type="primary" :loading="detail.isloading">
<template #icon>
<CloudDownloadOutlined />
<CloudDownloadOutlined v-show="!detail.isloading && !detail.isdwonload" />
</template>
获取
</a-button>

View File

@ -1,6 +1,6 @@
{
"name": "rubick",
"version": "2.0.1-beta.17",
"version": "2.0.1-beta.18",
"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.6418a244.js" rel="preload" as="script"><link href="js/chunk-vendors.335eb4e0.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.335eb4e0.js"></script><script src="js/app.6418a244.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.1b7d9360.js" rel="preload" as="script"><link href="js/chunk-vendors.335eb4e0.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.335eb4e0.js"></script><script src="js/app.1b7d9360.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

@ -185,9 +185,12 @@ export const API: any = {
removeFeature({ data }, window) {
API.currentPlugin = {
...API.currentPlugin,
features: API.currentPlugin.features.filter(
(feature) => feature.code !== data.code
),
features: API.currentPlugin.features.filter((feature) => {
if (data.code.type) {
return feature.code.type !== data.code.type;
}
return feature.code !== data.code;
}),
};
window.webContents.executeJavaScript(
`window.updatePlugin(${JSON.stringify({