perf: automatically close the installation modal after installing the theme (#3777)

#### What type of PR is this?

/kind improvement
/area console
/milestone 2.5.x

#### What this PR does / why we need it:

优化安装主题和升级主题的流程,支持在升级或者安装之后自动关闭弹框以及刷新数据。

#### Special notes for your reviewer:

测试方式:

1. 测试升级或者安装新主题之后是否关闭弹框以及是否有提示即可。

#### Does this PR introduce a user-facing change?

```release-note
优化 Console 端安装和升级主题的流程,支持自动关闭安装弹框和显示反馈提示
```
pull/3772/head^2
Ryan Wang 2023-04-19 10:21:05 +08:00 committed by GitHub
parent 01f66cb3b6
commit 0fb3496aed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 11 deletions

View File

@ -613,9 +613,6 @@ core:
message: There are currently no installed themes, you can try refreshing or installing a new theme. message: There are currently no installed themes, you can try refreshing or installing a new theme.
not_installed_empty: not_installed_empty:
title: There are no themes currently not installed. title: There are no themes currently not installed.
operations:
install:
toast_success: Installation successful
preview_model: preview_model:
title: "Preview theme: {display_name}" title: "Preview theme: {display_name}"
actions: actions:
@ -1126,6 +1123,7 @@ core:
active_success: Activated successfully active_success: Activated successfully
inactive_success: Deactivated successfully inactive_success: Deactivated successfully
upgrade_success: Upgraded successfully upgrade_success: Upgraded successfully
install_success: Installed successfully
download_success: Downloaded successfully download_success: Downloaded successfully
copy_success: Copied successfully copy_success: Copied successfully
operation_failed: Failed to operate operation_failed: Failed to operate

View File

@ -613,9 +613,6 @@ core:
message: 当前没有已安装的主题,你可以尝试刷新或者安装新主题 message: 当前没有已安装的主题,你可以尝试刷新或者安装新主题
not_installed_empty: not_installed_empty:
title: 当前没有未安装的主题 title: 当前没有未安装的主题
operations:
install:
toast_success: 安装成功
preview_model: preview_model:
title: 预览主题:{display_name} title: 预览主题:{display_name}
actions: actions:
@ -1126,6 +1123,7 @@ core:
active_success: 启用成功 active_success: 启用成功
inactive_success: 停用成功 inactive_success: 停用成功
upgrade_success: 升级成功 upgrade_success: 升级成功
install_success: 安装成功
download_success: 下载成功 download_success: 下载成功
copy_success: 复制成功 copy_success: 复制成功
operation_failed: 操作失败 operation_failed: 操作失败

View File

@ -613,9 +613,6 @@ core:
message: 當前沒有已安裝的主題,你可以嘗試刷新或者安裝新主題 message: 當前沒有已安裝的主題,你可以嘗試刷新或者安裝新主題
not_installed_empty: not_installed_empty:
title: 當前沒有未安裝的主題 title: 當前沒有未安裝的主題
operations:
install:
toast_success: 安裝成功
preview_model: preview_model:
title: 預覽主題:{display_name} title: 預覽主題:{display_name}
actions: actions:
@ -1126,6 +1123,7 @@ core:
active_success: 啟用成功 active_success: 啟用成功
inactive_success: 停用成功 inactive_success: 停用成功
upgrade_success: 升級成功 upgrade_success: 升級成功
install_success: 安裝成功
download_success: 下載成功 download_success: 下載成功
copy_success: 複製成功 copy_success: 複製成功
operation_failed: 操作失敗 operation_failed: 操作失敗

View File

@ -97,7 +97,7 @@ const handleCreateTheme = async (theme: Theme) => {
activeTab.value = "installed"; activeTab.value = "installed";
Toast.success(t("core.theme.list_modal.operations.install.toast_success")); Toast.success(t("core.common.toast.install_success"));
} catch (error) { } catch (error) {
console.error("Failed to create theme", error); console.error("Failed to create theme", error);
} finally { } finally {

View File

@ -1,11 +1,15 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VModal } from "@halo-dev/components"; import { Toast, VModal } from "@halo-dev/components";
import UppyUpload from "@/components/upload/UppyUpload.vue"; import UppyUpload from "@/components/upload/UppyUpload.vue";
import { computed, ref, watch } from "vue"; import { computed, ref, watch } from "vue";
import type { Theme } from "@halo-dev/api-client"; import type { Theme } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useQueryClient } from "@tanstack/vue-query";
import { useThemeStore } from "@/stores/theme";
const { t } = useI18n(); const { t } = useI18n();
const queryClient = useQueryClient();
const themeStore = useThemeStore();
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -60,6 +64,21 @@ watch(
} }
} }
); );
const onUploaded = () => {
Toast.success(
t(
props.upgradeTheme
? "core.common.toast.upgrade_success"
: "core.common.toast.install_success"
)
);
queryClient.invalidateQueries({ queryKey: ["themes"] });
themeStore.fetchActivatedTheme();
handleVisibleChange(false);
};
</script> </script>
<template> <template>
<VModal <VModal
@ -76,6 +95,7 @@ watch(
}" }"
:endpoint="endpoint" :endpoint="endpoint"
auto-proceed auto-proceed
@uploaded="onUploaded"
/> />
</VModal> </VModal>
</template> </template>