mirror of https://github.com/halo-dev/halo
refactor: improve plugin upgrade related code to resolve performance issue (#4410)
#### What type of PR is this? /area console /kind improvement /milestone 2.9.x #### What this PR does / why we need it: 优化插件升级相关代码,解决插件管理列表的潜在性能问题。 #### Which issue(s) this PR fixes: Fixes #4409 #### Special notes for your reviewer: 需要测试插件安装和升级功能 #### Does this PR introduce a user-facing change? ```release-note 优化 Console 端插件管理列表的性能 ```pull/4462/head
parent
b437756157
commit
6326ec1d86
|
@ -27,7 +27,13 @@ const { t } = useI18n();
|
||||||
|
|
||||||
const { currentUserHasPermission } = usePermission();
|
const { currentUserHasPermission } = usePermission();
|
||||||
|
|
||||||
const pluginInstall = ref(false);
|
const pluginUploadModal = ref(false);
|
||||||
|
const pluginToUpgrade = ref<Plugin>();
|
||||||
|
|
||||||
|
function handleOpenUploadModal(plugin?: Plugin) {
|
||||||
|
pluginToUpgrade.value = plugin;
|
||||||
|
pluginUploadModal.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
const keyword = ref("");
|
const keyword = ref("");
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
|
@ -99,7 +105,7 @@ onMounted(() => {
|
||||||
confirmText: t("core.common.buttons.download"),
|
confirmText: t("core.common.buttons.download"),
|
||||||
cancelText: t("core.common.buttons.cancel"),
|
cancelText: t("core.common.buttons.cancel"),
|
||||||
onConfirm() {
|
onConfirm() {
|
||||||
pluginInstall.value = true;
|
handleOpenUploadModal();
|
||||||
},
|
},
|
||||||
onCancel() {
|
onCancel() {
|
||||||
routeRemoteDownloadUrl.value = null;
|
routeRemoteDownloadUrl.value = null;
|
||||||
|
@ -111,7 +117,8 @@ onMounted(() => {
|
||||||
<template>
|
<template>
|
||||||
<PluginUploadModal
|
<PluginUploadModal
|
||||||
v-if="currentUserHasPermission(['system:plugins:manage'])"
|
v-if="currentUserHasPermission(['system:plugins:manage'])"
|
||||||
v-model:visible="pluginInstall"
|
v-model:visible="pluginUploadModal"
|
||||||
|
:upgrade-plugin="pluginToUpgrade"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<VPageHeader :title="$t('core.plugin.title')">
|
<VPageHeader :title="$t('core.plugin.title')">
|
||||||
|
@ -122,7 +129,7 @@ onMounted(() => {
|
||||||
<VButton
|
<VButton
|
||||||
v-permission="['system:plugins:manage']"
|
v-permission="['system:plugins:manage']"
|
||||||
type="secondary"
|
type="secondary"
|
||||||
@click="pluginInstall = true"
|
@click="handleOpenUploadModal()"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<IconAddCircle class="h-full w-full" />
|
<IconAddCircle class="h-full w-full" />
|
||||||
|
@ -219,7 +226,7 @@ onMounted(() => {
|
||||||
<VButton
|
<VButton
|
||||||
v-permission="['system:plugins:manage']"
|
v-permission="['system:plugins:manage']"
|
||||||
type="secondary"
|
type="secondary"
|
||||||
@click="pluginInstall = true"
|
@click="handleOpenUploadModal"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<IconAddCircle class="h-full w-full" />
|
<IconAddCircle class="h-full w-full" />
|
||||||
|
@ -237,7 +244,10 @@ onMounted(() => {
|
||||||
role="list"
|
role="list"
|
||||||
>
|
>
|
||||||
<li v-for="plugin in data" :key="plugin.metadata.name">
|
<li v-for="plugin in data" :key="plugin.metadata.name">
|
||||||
<PluginListItem :plugin="plugin" />
|
<PluginListItem
|
||||||
|
:plugin="plugin"
|
||||||
|
@open-upgrade-modal="handleOpenUploadModal"
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</Transition>
|
</Transition>
|
||||||
|
|
|
@ -11,8 +11,7 @@ import {
|
||||||
VDropdown,
|
VDropdown,
|
||||||
VDropdownDivider,
|
VDropdownDivider,
|
||||||
} from "@halo-dev/components";
|
} from "@halo-dev/components";
|
||||||
import PluginUploadModal from "./PluginUploadModal.vue";
|
import { toRefs } from "vue";
|
||||||
import { ref, toRefs } from "vue";
|
|
||||||
import { usePluginLifeCycle } from "../composables/use-plugin";
|
import { usePluginLifeCycle } from "../composables/use-plugin";
|
||||||
import type { Plugin } from "@halo-dev/api-client";
|
import type { Plugin } from "@halo-dev/api-client";
|
||||||
import { formatDatetime } from "@/utils/date";
|
import { formatDatetime } from "@/utils/date";
|
||||||
|
@ -32,9 +31,11 @@ const props = withDefaults(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const { plugin } = toRefs(props);
|
const emit = defineEmits<{
|
||||||
|
(event: "open-upgrade-modal", plugin?: Plugin): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
const upgradeModal = ref(false);
|
const { plugin } = toRefs(props);
|
||||||
|
|
||||||
const { getFailedMessage, changeStatus, uninstall } =
|
const { getFailedMessage, changeStatus, uninstall } =
|
||||||
usePluginLifeCycle(plugin);
|
usePluginLifeCycle(plugin);
|
||||||
|
@ -65,7 +66,6 @@ const handleResetSettingConfig = async () => {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<PluginUploadModal v-model:visible="upgradeModal" :upgrade-plugin="plugin" />
|
|
||||||
<VEntity>
|
<VEntity>
|
||||||
<template #start>
|
<template #start>
|
||||||
<VEntityField>
|
<VEntityField>
|
||||||
|
@ -145,7 +145,7 @@ const handleResetSettingConfig = async () => {
|
||||||
>
|
>
|
||||||
{{ $t("core.common.buttons.detail") }}
|
{{ $t("core.common.buttons.detail") }}
|
||||||
</VDropdownItem>
|
</VDropdownItem>
|
||||||
<VDropdownItem @click="upgradeModal = true">
|
<VDropdownItem @click="emit('open-upgrade-modal', plugin)">
|
||||||
{{ $t("core.common.buttons.upgrade") }}
|
{{ $t("core.common.buttons.upgrade") }}
|
||||||
</VDropdownItem>
|
</VDropdownItem>
|
||||||
<VDropdownDivider />
|
<VDropdownDivider />
|
||||||
|
|
Loading…
Reference in New Issue