@@ -80,7 +80,7 @@ onMounted(() => {
-
+
diff --git a/src/modules/interface/themes/components/ThemeListModal.vue b/src/modules/interface/themes/components/ThemeListModal.vue
index 4423f6c45..ab797f0fe 100644
--- a/src/modules/interface/themes/components/ThemeListModal.vue
+++ b/src/modules/interface/themes/components/ThemeListModal.vue
@@ -11,11 +11,11 @@ import {
VTag,
} from "@halo-dev/components";
import ThemeInstallModal from "./ThemeInstallModal.vue";
-import { onMounted, ref } from "vue";
+import { ref, watch } from "vue";
import type { Theme } from "@halo-dev/api-client";
import { apiClient } from "@halo-dev/admin-shared";
-withDefaults(
+const props = withDefaults(
defineProps<{
visible: boolean;
selectedTheme: Theme | null;
@@ -32,6 +32,7 @@ const emit = defineEmits<{
(event: "update:visible", visible: boolean): void;
(event: "close"): void;
(event: "update:selectedTheme", theme: Theme | null): void;
+ (event: "select", theme: Theme | null): void;
}>();
const themes = ref([]);
@@ -71,7 +72,7 @@ const handleUninstall = async (theme: Theme) => {
});
};
-const handleVisibleChange = (visible: boolean) => {
+const onVisibleChange = (visible: boolean) => {
emit("update:visible", visible);
if (!visible) {
emit("close");
@@ -80,10 +81,18 @@ const handleVisibleChange = (visible: boolean) => {
const handleSelectTheme = (theme: Theme) => {
emit("update:selectedTheme", theme);
- handleVisibleChange(false);
+ emit("select", theme);
+ onVisibleChange(false);
};
-onMounted(handleFetchThemes);
+watch(
+ () => props.visible,
+ (visible) => {
+ if (visible) {
+ handleFetchThemes();
+ }
+ }
+);
defineExpose({
handleFetchThemes,
@@ -95,7 +104,7 @@ defineExpose({
:visible="visible"
:width="888"
title="已安装的主题"
- @update:visible="handleVisibleChange"
+ @update:visible="onVisibleChange"
>
安装主题
- 关闭
+ 关闭
diff --git a/src/modules/interface/themes/composables/use-theme.ts b/src/modules/interface/themes/composables/use-theme.ts
index 3bb89a31a..b0c4ad057 100644
--- a/src/modules/interface/themes/composables/use-theme.ts
+++ b/src/modules/interface/themes/composables/use-theme.ts
@@ -6,17 +6,19 @@ import { useDialog } from "@halo-dev/components";
interface useThemeLifeCycleReturn {
loading: Ref
;
- activatedTheme: Ref;
+ activatedTheme: Ref;
isActivated: ComputedRef;
handleActiveTheme: () => void;
}
-export function useThemeLifeCycle(theme: Ref): useThemeLifeCycleReturn {
- const activatedTheme = ref({} as Theme);
+export function useThemeLifeCycle(
+ theme: Ref
+): useThemeLifeCycleReturn {
+ const activatedTheme = ref();
const loading = ref(false);
const isActivated = computed(() => {
- return activatedTheme.value?.metadata?.name === theme.value?.metadata?.name;
+ return activatedTheme.value?.metadata.name === theme.value?.metadata.name;
});
const dialog = useDialog();
@@ -54,7 +56,7 @@ export function useThemeLifeCycle(theme: Ref): useThemeLifeCycleReturn {
const handleActiveTheme = async () => {
dialog.info({
title: "是否确认启用当前主题",
- description: theme.value.spec.displayName,
+ description: theme.value?.spec.displayName,
onConfirm: async () => {
try {
const { data: systemConfigMap } =
@@ -66,7 +68,7 @@ export function useThemeLifeCycle(theme: Ref): useThemeLifeCycleReturn {
const themeConfigToUpdate = JSON.parse(
systemConfigMap.data?.theme || "{}"
);
- themeConfigToUpdate.active = theme.value?.metadata?.name;
+ themeConfigToUpdate.active = theme.value?.metadata.name;
systemConfigMap.data["theme"] = JSON.stringify(themeConfigToUpdate);
await apiClient.extension.configMap.updatev1alpha1ConfigMap({
diff --git a/src/modules/interface/themes/layouts/ThemeLayout.vue b/src/modules/interface/themes/layouts/ThemeLayout.vue
index 0eba8f37b..73d97685f 100644
--- a/src/modules/interface/themes/layouts/ThemeLayout.vue
+++ b/src/modules/interface/themes/layouts/ThemeLayout.vue
@@ -1,7 +1,7 @@
@@ -139,7 +141,7 @@ watch(
v-model:selected-theme="selectedTheme"
v-model:visible="themesModal"
/>
-
+
@@ -171,11 +173,7 @@ watch(
@@ -205,7 +203,18 @@ watch(
-
+
+
+
+
+
+
+ 加载中...
+
+
+
+
+
diff --git a/src/modules/system/plugins/components/PluginListItem.vue b/src/modules/system/plugins/components/PluginListItem.vue
index d1ae9197f..6b67b5424 100644
--- a/src/modules/system/plugins/components/PluginListItem.vue
+++ b/src/modules/system/plugins/components/PluginListItem.vue
@@ -76,7 +76,7 @@ const { isStarted, changeStatus, uninstall } = usePluginLifeCycle(plugin);