mirror of https://github.com/halo-dev/halo-admin
refactor: plugin enable/disable api
Signed-off-by: Ryan Wang <i@ryanc.cc>pull/588/head
parent
d15c1636bd
commit
70f7b522f1
|
@ -14,7 +14,7 @@ import type { Plugin } from "@/types/extension";
|
|||
import { axiosInstance } from "@halo-dev/admin-shared";
|
||||
|
||||
const pluginActiveId = ref("detail");
|
||||
const plugin = ref<Plugin>();
|
||||
const plugin = ref<Plugin>({} 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue