mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-24 11:31:44 +08:00
♻️ 优化插件中心功能
This commit is contained in:
@@ -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,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user