diff --git a/console/src/modules/interface/themes/ThemeSetting.vue b/console/src/modules/interface/themes/ThemeSetting.vue
index 4226d72d6..699c3142a 100644
--- a/console/src/modules/interface/themes/ThemeSetting.vue
+++ b/console/src/modules/interface/themes/ThemeSetting.vue
@@ -1,6 +1,6 @@
diff --git a/console/src/modules/interface/themes/layouts/ThemeLayout.vue b/console/src/modules/interface/themes/layouts/ThemeLayout.vue
index 5d86c4b6c..bc5b083d4 100644
--- a/console/src/modules/interface/themes/layouts/ThemeLayout.vue
+++ b/console/src/modules/interface/themes/layouts/ThemeLayout.vue
@@ -1,7 +1,7 @@
@@ -232,7 +230,10 @@ onMounted(() => {
>
-
+
diff --git a/console/src/modules/system/plugins/PluginSetting.vue b/console/src/modules/system/plugins/PluginSetting.vue
index 15b13ee78..d24ebfa45 100644
--- a/console/src/modules/system/plugins/PluginSetting.vue
+++ b/console/src/modules/system/plugins/PluginSetting.vue
@@ -1,6 +1,6 @@
// core libs
-import { nextTick, onMounted, provide, ref, watch } from "vue";
+import { nextTick, provide, ref, computed, watch } from "vue";
import { RouterView, useRoute, useRouter } from "vue-router";
import { apiClient } from "@/utils/api-client";
@@ -22,6 +22,7 @@ import type { Ref } from "vue";
import type { Plugin, Setting, SettingForm } from "@halo-dev/api-client";
import { usePermission } from "@/utils/permission";
import { useI18n } from "vue-i18n";
+import { useQuery } from "@tanstack/vue-query";
const { currentUserHasPermission } = usePermission();
const { t } = useI18n();
@@ -48,33 +49,68 @@ const initialTabs: PluginTab[] = [
const route = useRoute();
const router = useRouter();
-const plugin = ref();
-const setting = ref();
const tabs = ref(cloneDeep(initialTabs));
-const activeTab = ref();
+const activeTab = ref(tabs.value[0].id);
-provide[>("plugin", plugin);
provide][>("activeTab", activeTab);
-const handleFetchPlugin = async () => {
- try {
- const response =
+const { data: plugin } = useQuery({
+ queryKey: ["plugin", route.params.name],
+ queryFn: async () => {
+ const { data } =
await apiClient.extension.plugin.getpluginHaloRunV1alpha1Plugin({
name: route.params.name as string,
});
- plugin.value = response.data;
- } catch (e) {
- console.error(e);
- }
-};
+ return data;
+ },
+ refetchOnWindowFocus: false,
+});
-const handleFetchSettings = async () => {
- if (!plugin.value || !plugin.value.spec.settingName) return;
- const { data } = await apiClient.plugin.fetchPluginSetting({
- name: plugin.value?.metadata.name,
- });
- setting.value = data;
-};
+provide][>("plugin", plugin);
+
+const { data: setting } = useQuery({
+ queryKey: ["plugin-setting", plugin],
+ queryFn: async () => {
+ const { data } = await apiClient.plugin.fetchPluginSetting({
+ name: plugin.value?.metadata.name as string,
+ });
+ return data;
+ },
+ refetchOnWindowFocus: false,
+ enabled: computed(() => {
+ return (
+ !!plugin.value &&
+ !!plugin.value.spec.settingName &&
+ currentUserHasPermission(["system:plugins:manage"])
+ );
+ }),
+ async onSuccess(data) {
+ if (data) {
+ const { forms } = data.spec;
+ tabs.value = [
+ ...tabs.value,
+ ...forms.map((item: SettingForm) => {
+ return {
+ id: item.group,
+ label: item.label || "",
+ route: {
+ name: "PluginSetting",
+ params: {
+ group: item.group,
+ },
+ },
+ };
+ }),
+ ] as PluginTab[];
+ }
+
+ await nextTick();
+
+ handleTriggerTabChange();
+ },
+});
+
+provide][>("setting", setting);
const handleTabChange = (id: string) => {
const tab = tabs.value.find((item) => item.id === id);
@@ -103,42 +139,6 @@ const handleTriggerTabChange = () => {
activeTab.value = tab ? tab.id : tabs.value[0].id;
};
-onMounted(async () => {
- await handleFetchPlugin();
-
- if (!currentUserHasPermission(["system:plugins:manage"])) {
- handleTriggerTabChange();
- return;
- }
-
- await handleFetchSettings();
-
- tabs.value = cloneDeep(initialTabs);
-
- if (setting.value) {
- const { forms } = setting.value.spec;
- tabs.value = [
- ...tabs.value,
- ...forms.map((item: SettingForm) => {
- return {
- id: item.group,
- label: item.label || "",
- route: {
- name: "PluginSetting",
- params: {
- group: item.group,
- },
- },
- };
- }),
- ] as PluginTab[];
- }
-
- await nextTick();
-
- handleTriggerTabChange();
-});
-
watch([() => route.name, () => route.params], () => {
handleTriggerTabChange();
});
diff --git a/console/src/modules/system/users/UserList.vue b/console/src/modules/system/users/UserList.vue
index aaba5fc78..ad331c9ae 100644
--- a/console/src/modules/system/users/UserList.vue
+++ b/console/src/modules/system/users/UserList.vue
@@ -22,7 +22,6 @@ import {
VEmpty,
VDropdown,
VDropdownItem,
- VDropdownDivider,
} from "@halo-dev/components";
import UserEditingModal from "./components/UserEditingModal.vue";
import UserPasswordChangeModal from "./components/UserPasswordChangeModal.vue";
]