mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-16 23:54:19 +08:00
🐛 fix #210
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { createStore } from "vuex";
|
||||
import request from "@/assets/request";
|
||||
import { createStore } from 'vuex';
|
||||
import request from '@/assets/request';
|
||||
|
||||
const isDownload = (item: Market.Plugin, targets: any[]) => {
|
||||
let isDownload = false;
|
||||
@@ -29,74 +29,84 @@ export default createStore({
|
||||
const totalPlugins = await request.getTotalPlugins();
|
||||
const localPlugins = window.market.getLocalPlugins();
|
||||
|
||||
totalPlugins.forEach(
|
||||
(origin: Market.Plugin) => {
|
||||
origin.isdownload = isDownload(origin, localPlugins);
|
||||
origin.isloading = false;
|
||||
}
|
||||
);
|
||||
commit("commonUpdate", {
|
||||
totalPlugins.forEach((origin: Market.Plugin) => {
|
||||
origin.isdownload = isDownload(origin, localPlugins);
|
||||
origin.isloading = false;
|
||||
});
|
||||
// 修复卸载失败,一直转圈的问题。
|
||||
localPlugins.forEach((origin: Market.Plugin) => {
|
||||
origin.isloading = false;
|
||||
});
|
||||
|
||||
commit('commonUpdate', {
|
||||
localPlugins,
|
||||
totalPlugins,
|
||||
});
|
||||
},
|
||||
startDownload({ commit, state }, name) {
|
||||
const totalPlugins = JSON.parse(JSON.stringify(state.totalPlugins));
|
||||
totalPlugins.forEach(
|
||||
(origin: Market.Plugin) => {
|
||||
if (origin.name === name) {
|
||||
origin.isloading = true;
|
||||
}
|
||||
totalPlugins.forEach((origin: Market.Plugin) => {
|
||||
if (origin.name === name) {
|
||||
origin.isloading = true;
|
||||
}
|
||||
);
|
||||
commit("commonUpdate", {
|
||||
});
|
||||
commit('commonUpdate', {
|
||||
totalPlugins,
|
||||
});
|
||||
},
|
||||
|
||||
startUnDownload({ commit, state }, name) {
|
||||
const localPlugins = window.market.getLocalPlugins();
|
||||
localPlugins.forEach(
|
||||
(origin: Market.Plugin) => {
|
||||
if (origin.name === name) {
|
||||
origin.isloading = true;
|
||||
}
|
||||
localPlugins.forEach((origin: Market.Plugin) => {
|
||||
if (origin.name === name) {
|
||||
origin.isloading = true;
|
||||
}
|
||||
);
|
||||
commit("commonUpdate", {
|
||||
});
|
||||
commit('commonUpdate', {
|
||||
localPlugins,
|
||||
});
|
||||
},
|
||||
|
||||
errorUnDownload({ commit, state }, name) {
|
||||
const localPlugins = window.market.getLocalPlugins();
|
||||
// 修复卸载失败,一直转圈的问题。
|
||||
localPlugins.forEach((origin: Market.Plugin) => {
|
||||
if (origin.name === name) {
|
||||
origin.isloading = false;
|
||||
}
|
||||
});
|
||||
|
||||
commit('commonUpdate', {
|
||||
localPlugins,
|
||||
});
|
||||
},
|
||||
|
||||
successDownload({ commit, state }, name) {
|
||||
const totalPlugins = JSON.parse(JSON.stringify(state.totalPlugins));
|
||||
totalPlugins.forEach(
|
||||
(origin: Market.Plugin) => {
|
||||
if (origin.name === name) {
|
||||
origin.isloading = false;
|
||||
origin.isdownload = true;
|
||||
}
|
||||
totalPlugins.forEach((origin: Market.Plugin) => {
|
||||
if (origin.name === name) {
|
||||
origin.isloading = false;
|
||||
origin.isdownload = true;
|
||||
}
|
||||
);
|
||||
});
|
||||
const localPlugins = window.market.getLocalPlugins();
|
||||
|
||||
commit("commonUpdate", {
|
||||
commit('commonUpdate', {
|
||||
totalPlugins,
|
||||
localPlugins,
|
||||
});
|
||||
},
|
||||
|
||||
async updateLocalPlugin({ commit }) {
|
||||
const localPlugins = window.market.getLocalPlugins();
|
||||
const totalPlugins = await request.getTotalPlugins();
|
||||
|
||||
totalPlugins.forEach(
|
||||
(origin: Market.Plugin) => {
|
||||
origin.isdownload = isDownload(origin, localPlugins);
|
||||
origin.isloading = false;
|
||||
}
|
||||
);
|
||||
totalPlugins.forEach((origin: Market.Plugin) => {
|
||||
origin.isdownload = isDownload(origin, localPlugins);
|
||||
origin.isloading = false;
|
||||
});
|
||||
|
||||
commit("commonUpdate", {
|
||||
commit('commonUpdate', {
|
||||
localPlugins,
|
||||
totalPlugins,
|
||||
});
|
||||
|
||||
@@ -115,6 +115,7 @@ import { computed, ref, toRaw } from 'vue';
|
||||
import path from 'path';
|
||||
import MarkdownIt from 'markdown-it';
|
||||
import { PlusCircleOutlined, MinusCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
|
||||
@@ -133,6 +134,7 @@ const localPlugins = computed(() =>
|
||||
);
|
||||
const updateLocalPlugin = () => store.dispatch('updateLocalPlugin');
|
||||
const startUnDownload = (name) => store.dispatch('startUnDownload', name);
|
||||
const errorUnDownload = (name) => store.dispatch('errorUnDownload', name);
|
||||
|
||||
const currentSelect = ref([0]);
|
||||
|
||||
@@ -146,7 +148,7 @@ const superPanelPlugins = ref(
|
||||
_id: 'super-panel-plugins',
|
||||
}
|
||||
);
|
||||
console.log(toRaw(superPanelPlugins.value.data));
|
||||
|
||||
const addCmdToSuperPanel = ({ cmd, code }) => {
|
||||
const plugin = {
|
||||
...toRaw(pluginDetail.value),
|
||||
@@ -216,8 +218,13 @@ const readme = computed(() => {
|
||||
|
||||
const deletePlugin = async (plugin) => {
|
||||
startUnDownload(plugin.name);
|
||||
const timer = setTimeout(() => {
|
||||
errorUnDownload(plugin.name);
|
||||
message.error('卸载超时,请重试!');
|
||||
}, 20000);
|
||||
await window.market.deletePlugin(plugin);
|
||||
updateLocalPlugin();
|
||||
clearTimeout(timer);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user