mirror of https://github.com/halo-dev/halo-admin
perf: open confirm dialog when changing plugin status
Signed-off-by: Ryan Wang <i@ryanc.cc>pull/588/head
parent
ce17c6eff9
commit
352f7a3acc
|
@ -16,10 +16,10 @@
|
||||||
"typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false && pnpm run typecheck:packages",
|
"typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false && pnpm run typecheck:packages",
|
||||||
"lint": "eslint ./src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore && pnpm run lint:packages",
|
"lint": "eslint ./src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore && pnpm run lint:packages",
|
||||||
"prettier": "prettier --write './src/**/*.{vue,js,jsx,ts,tsx,css,scss,json,yml,yaml,html}' && pnpm run prettier:packages",
|
"prettier": "prettier --write './src/**/*.{vue,js,jsx,ts,tsx,css,scss,json,yml,yaml,html}' && pnpm run prettier:packages",
|
||||||
"typecheck:packages": "pnpm --filter './packages/**' run typecheck",
|
"typecheck:packages": "pnpm --parallel --filter './packages/**' run typecheck",
|
||||||
"lint:packages": "pnpm --filter './packages/**' lint",
|
"lint:packages": "pnpm --parallel --filter './packages/**' lint",
|
||||||
"prettier:packages": "pnpm --filter './packages/**' prettier",
|
"prettier:packages": "pnpm --parallel --filter './packages/**' prettier",
|
||||||
"test:unit:packages": "pnpm --filter './packages/**' run test:unit"
|
"test:unit:packages": "pnpm --parallel --filter './packages/**' run test:unit"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {
|
import {
|
||||||
|
useDialog,
|
||||||
VButton,
|
VButton,
|
||||||
VCard,
|
VCard,
|
||||||
VPageHeader,
|
VPageHeader,
|
||||||
|
@ -9,14 +10,16 @@ import {
|
||||||
VTag,
|
VTag,
|
||||||
} from "@halo-dev/components";
|
} from "@halo-dev/components";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import { computed, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
import type { Plugin } from "@/types/extension";
|
import type { Plugin } from "@/types/extension";
|
||||||
import { axiosInstance } from "@halo-dev/admin-shared";
|
import { axiosInstance } from "@halo-dev/admin-shared";
|
||||||
|
import cloneDeep from "lodash.clonedeep";
|
||||||
|
|
||||||
const pluginActiveId = ref("detail");
|
const pluginActiveId = ref("detail");
|
||||||
const plugin = ref<Plugin>({} as Plugin);
|
const plugin = ref<Plugin>({} as Plugin);
|
||||||
|
|
||||||
const { params } = useRoute();
|
const { params } = useRoute();
|
||||||
|
const dialog = useDialog();
|
||||||
|
|
||||||
const handleFetchPlugin = async () => {
|
const handleFetchPlugin = async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -34,20 +37,27 @@ const isStarted = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleChangePluginStatus = async () => {
|
const handleChangePluginStatus = async () => {
|
||||||
try {
|
const pluginToUpdate = cloneDeep(plugin.value);
|
||||||
plugin.value.spec.enabled = !plugin.value.spec.enabled;
|
|
||||||
await axiosInstance.put(
|
dialog.info({
|
||||||
`/apis/plugin.halo.run/v1alpha1/plugins/${plugin.value.metadata.name}`,
|
title: `确定要${plugin.value.spec.enabled ? "停止" : "启动"}该插件吗?`,
|
||||||
plugin.value
|
onConfirm: async () => {
|
||||||
);
|
try {
|
||||||
} catch (e) {
|
pluginToUpdate.spec.enabled = !pluginToUpdate.spec.enabled;
|
||||||
console.error(e);
|
await axiosInstance.put(
|
||||||
} finally {
|
`/apis/plugin.halo.run/v1alpha1/plugins/${plugin.value.metadata.name}`,
|
||||||
window.location.reload();
|
pluginToUpdate
|
||||||
}
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
} finally {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleFetchPlugin();
|
onMounted(handleFetchPlugin);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -308,5 +318,3 @@ handleFetchPlugin();
|
||||||
</VCard>
|
</VCard>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
|
|
Loading…
Reference in New Issue