feat: 插件删除功能

This commit is contained in:
Junyan Qin
2024-11-09 23:25:26 +08:00
parent 601fa0ac7f
commit 15482e398b
6 changed files with 39 additions and 7 deletions

View File

@@ -59,7 +59,7 @@ const props = defineProps({
},
});
const emit = defineEmits(['toggle', 'update', 'uninstall']);
const emit = defineEmits(['toggle', 'update', 'remove']);
const openGithubSource = () => {
window.open(props.plugin.source, '_blank');
@@ -73,8 +73,8 @@ const updatePlugin = () => {
emit('update', props.plugin);
}
const uninstallPlugin = () => {
emit('uninstall', props.plugin);
const removePlugin = () => {
emit('remove', props.plugin);
}
const menuItems = [
@@ -96,7 +96,7 @@ const menuItems = [
{
title: '删除',
condition: (plugin) => true,
action: uninstallPlugin
action: removePlugin
}
]
</script>

View File

@@ -80,7 +80,7 @@
</v-card>
<div class="plugins-container">
<PluginCard class="plugin-card" v-for="plugin in plugins" :key="plugin.name" :plugin="plugin"
@toggle="togglePlugin" @update="updatePlugin" />
@toggle="togglePlugin" @update="updatePlugin" @remove="removePlugin" />
</div>
</template>
@@ -141,6 +141,18 @@ const updatePlugin = (plugin) => {
})
}
const removePlugin = (plugin) => {
proxy.$axios.delete(`/plugins/${plugin.author}/${plugin.name}`).then(res => {
if (res.data.code != 0) {
snackbar.error(res.data.msg)
return
}
snackbar.success(`已添加删除任务 请到任务列表查看进度`)
}).catch(error => {
snackbar.error(error)
})
}
const installPlugin = () => {
if (installDialogSource.value == '' || installDialogSource.value.trim() == '') {