diff --git a/src/modules/system/plugins/PluginDetail.vue b/src/modules/system/plugins/PluginDetail.vue index f573f6d6..2aadac6a 100644 --- a/src/modules/system/plugins/PluginDetail.vue +++ b/src/modules/system/plugins/PluginDetail.vue @@ -14,7 +14,7 @@ import type { Plugin } from "@/types/extension"; import { axiosInstance } from "@halo-dev/admin-shared"; const pluginActiveId = ref("detail"); -const plugin = ref(); +const plugin = ref({} as Plugin); const { params } = useRoute(); @@ -30,17 +30,15 @@ const handleFetchPlugin = async () => { }; const isStarted = computed(() => { - return ( - plugin.value?.status?.phase === "STARTED" && plugin.value?.spec.enabled - ); + return plugin.value.status?.phase === "STARTED" && plugin.value.spec.enabled; }); const handleChangePluginStatus = async () => { try { + plugin.value.spec.enabled = !plugin.value.spec.enabled; await axiosInstance.put( - `/apis/plugin.halo.run/v1alpha1/plugins/${plugin.value?.metadata.name}/${ - isStarted.value ? "stop" : "startup" - }` + `/apis/plugin.halo.run/v1alpha1/plugins/${plugin.value.metadata.name}`, + plugin.value ); } catch (e) { console.error(e); diff --git a/src/modules/system/plugins/PluginList.vue b/src/modules/system/plugins/PluginList.vue index 079a2dda..501585d8 100644 --- a/src/modules/system/plugins/PluginList.vue +++ b/src/modules/system/plugins/PluginList.vue @@ -45,10 +45,10 @@ const handleFetchPlugins = async () => { const handleChangePluginStatus = async (plugin: Plugin) => { try { + plugin.spec.enabled = !plugin.spec.enabled; await axiosInstance.put( - `/apis/plugin.halo.run/v1alpha1/plugins/${plugin.metadata.name}/${ - isStarted(plugin) ? "stop" : "startup" - }` + `/apis/plugin.halo.run/v1alpha1/plugins/${plugin.metadata.name}`, + plugin ); } catch (e) { console.error(e);