From ce604e602dfdbf1a3ab2e7bbd16299634cdac79e Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Tue, 21 Feb 2023 11:14:09 +0800 Subject: [PATCH] feat: prompt to upgrade plugin when installing existing plugin (halo-dev/console#871) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind feature #### What this PR does / why we need it: 安装已存在插件时,支持提示和升级插件。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3164 #### Screenshots: image #### Special notes for your reviewer: 测试方式: 1. Halo 需要切换到 https://github.com/halo-dev/halo/pull/3350 分支。 2. 在插件为 deployment 模式下启动 Halo。 3. 安装任意一个插件,然后继续上传安装相同插件。 4. 观察是否提示升级此插件。 #### Does this PR introduce a user-facing change? ```release-note Console 端安装已存在插件时,支持提示并升级插件。 ``` --- src/components/upload/UppyUpload.vue | 5 +++ .../plugins/components/PluginUploadModal.vue | 40 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/components/upload/UppyUpload.vue b/src/components/upload/UppyUpload.vue index 756dadb9b..8fb1d1567 100644 --- a/src/components/upload/UppyUpload.vue +++ b/src/components/upload/UppyUpload.vue @@ -36,6 +36,7 @@ const props = withDefaults( const emit = defineEmits<{ (event: "uploaded", response: SuccessResponse): void; + (event: "error", file, response): void; }>(); const uppy = computed(() => { @@ -72,6 +73,10 @@ uppy.value.on("upload-success", (_, response: SuccessResponse) => { emit("uploaded", response); }); +uppy.value.on("upload-error", (file, _, response) => { + emit("error", file, response); +}); + onUnmounted(() => { uppy.value.close({ reason: "unmount" }); }); diff --git a/src/modules/system/plugins/components/PluginUploadModal.vue b/src/modules/system/plugins/components/PluginUploadModal.vue index 63fe9794e..f8ef69d41 100644 --- a/src/modules/system/plugins/components/PluginUploadModal.vue +++ b/src/modules/system/plugins/components/PluginUploadModal.vue @@ -1,10 +1,11 @@