From ad9b0dfb2157892649808e2cdd82afe10b9e66da Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sun, 16 Jul 2023 23:34:17 +0800 Subject: [PATCH] fix: system settings and plugin settings panels cannot be displayed (#4222) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area console /kind bug /milestone 2.8.x #### What this PR does / why we need it: 修复系统设置面板和插件设置面板无法正常显示的问题,此问题由 https://github.com/halo-dev/halo/pull/4102 中升级了 `@vueuse/router` 导致。 #### Which issue(s) this PR fixes: Fixes #4221 #### Special notes for your reviewer: 需要测试: 1. 测试系统设置能否正常工作。 2. 测试插件的设置能否正常工作。 #### Does this PR introduce a user-facing change? ```release-note None ``` --- .../modules/system/plugins/PluginDetail.vue | 6 ++---- .../modules/system/plugins/tabs/Setting.vue | 4 +--- .../modules/system/settings/SystemSettings.vue | 18 ++---------------- .../modules/system/settings/tabs/Setting.vue | 3 +-- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/console/src/modules/system/plugins/PluginDetail.vue b/console/src/modules/system/plugins/PluginDetail.vue index 32cc66f59..148f5659b 100644 --- a/console/src/modules/system/plugins/PluginDetail.vue +++ b/console/src/modules/system/plugins/PluginDetail.vue @@ -37,11 +37,9 @@ const initialTabs = ref([ const route = useRoute(); const tabs = ref(cloneDeep(initialTabs.value)); -const activeTab = useRouteQuery("tab", tabs.value[0].id, { - mode: "push", -}); +const activeTab = useRouteQuery("tab", tabs.value[0].id); -provide>("activeTab", activeTab); +provide>("activeTab", activeTab); const { data: plugin } = useQuery({ queryKey: ["plugin", route.params.name], diff --git a/console/src/modules/system/plugins/tabs/Setting.vue b/console/src/modules/system/plugins/tabs/Setting.vue index 2e20deb7d..ad8228a92 100644 --- a/console/src/modules/system/plugins/tabs/Setting.vue +++ b/console/src/modules/system/plugins/tabs/Setting.vue @@ -11,7 +11,6 @@ import { Toast, VButton } from "@halo-dev/components"; // types import type { ConfigMap, Plugin, Setting } from "@halo-dev/api-client"; -import { useRouteQuery } from "@vueuse/router"; import { useI18n } from "vue-i18n"; import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { toRaw } from "vue"; @@ -19,8 +18,7 @@ import { toRaw } from "vue"; const { t } = useI18n(); const queryClient = useQueryClient(); -const group = useRouteQuery("tab", undefined, { mode: "push" }); - +const group = inject>("activeTab", ref("basic")); const plugin = inject>("plugin"); const setting = inject>("setting", ref()); const saving = ref(false); diff --git a/console/src/modules/system/settings/SystemSettings.vue b/console/src/modules/system/settings/SystemSettings.vue index bf6bfd414..91e3486a0 100644 --- a/console/src/modules/system/settings/SystemSettings.vue +++ b/console/src/modules/system/settings/SystemSettings.vue @@ -18,11 +18,8 @@ import type { Component } from "vue"; import { markRaw } from "vue"; import SettingTab from "./tabs/Setting.vue"; import { useRouteQuery } from "@vueuse/router"; -import { watch } from "vue"; -import { useRouter } from "vue-router"; const { t } = useI18n(); -const router = useRouter(); interface Tab { id: string; @@ -38,7 +35,8 @@ const tabs = ref([ }, ]); -const activeTab = useRouteQuery("tab", undefined, { mode: "push" }); +const activeTab = useRouteQuery("tab", "basic"); +provide>("activeTab", activeTab); const { data: setting } = useQuery({ queryKey: ["system-setting"], @@ -66,18 +64,6 @@ const { data: setting } = useQuery({ }, }); -watch( - () => activeTab.value, - (value) => { - if (!value) { - router.replace({ - name: "SystemSetting", - query: { tab: tabs.value[0].id }, - }); - } - } -); - provide>("setting", setting);