diff --git a/fastapp/src/App.vue b/fastapp/src/App.vue
index 27a3c9b5..75823435 100644
--- a/fastapp/src/App.vue
+++ b/fastapp/src/App.vue
@@ -6,12 +6,18 @@ import { useThemeStore } from "@/store";
const themeStore = useThemeStore();
onLaunch(() => {
- // 初始化主题
- themeStore.initTheme();
+ // 延迟初始化主题,确保DOM完全加载
+ setTimeout(() => {
+ themeStore.initTheme();
+ }, 50);
});
onShow(() => {
console.log("App Show");
+ // 在应用显示时也尝试初始化主题,处理可能的初始化失败
+ setTimeout(() => {
+ themeStore.initTheme();
+ }, 10);
});
onHide(() => {
diff --git a/fastapp/src/store/modules/theme.store.ts b/fastapp/src/store/modules/theme.store.ts
index f70383c5..3c5b518e 100644
--- a/fastapp/src/store/modules/theme.store.ts
+++ b/fastapp/src/store/modules/theme.store.ts
@@ -105,7 +105,8 @@ export const useThemeStore = defineStore("appTheme", () => {
// 更新CSS变量
const updateCSSVariables = () => {
- if (typeof document !== 'undefined') {
+ // 确保在客户端环境且DOM已准备好
+ if (typeof window !== 'undefined' && typeof document !== 'undefined' && document.documentElement) {
const root = document.documentElement;
const isDark = theme.value === 'dark';
@@ -166,13 +167,18 @@ export const useThemeStore = defineStore("appTheme", () => {
// 更新主题变量
updateThemeVars();
- // 更新CSS变量
- updateCSSVariables();
-
- // 设置导航栏颜色
+ // 延迟更新CSS变量,确保DOM已准备好
nextTick(() => {
+ updateCSSVariables();
setNavigationBarColor();
});
+
+ // 为了兼容性,在更长的延迟后再次尝试
+ if (typeof window !== 'undefined') {
+ setTimeout(() => {
+ updateCSSVariables();
+ }, 100);
+ }
};
// 监听主题变化,自动更新CSS变量
diff --git a/frontend/.env.development b/frontend/.env.development
index 2679b89c..8f00cbd2 100644
--- a/frontend/.env.development
+++ b/frontend/.env.development
@@ -6,8 +6,9 @@ VITE_APP_TITLE=fastapiadmin
# 网络请求公用地址
-VITE_API_BASE_URL=http://127.0.0.1:8001
-# VITE_API_BASE_URL=https://service.fastapiadmin.com
+# VITE_API_BASE_URL=http://127.0.0.1:8001
+VITE_API_BASE_URL=https://service.fastapiadmin.com
+
# 代理前缀
VITE_APP_BASE_API=/api/v1
diff --git a/frontend/src/layouts/components/TagsView/index.vue b/frontend/src/layouts/components/TagsView/index.vue
index c4c06ca6..d1865f5c 100644
--- a/frontend/src/layouts/components/TagsView/index.vue
+++ b/frontend/src/layouts/components/TagsView/index.vue
@@ -400,13 +400,13 @@ const refreshSelectedTag = (tag: TagView | null) => {
* 关闭标签
*/
const closeSelectedTag = (tag: TagView | null) => {
- // 总是使用当前路由对应的标签
- const currentTag = routePathMap.value.get(route.path);
- if (!currentTag) return;
+ // 如果传入了具体的标签,使用传入的标签;否则使用当前路由对应的标签
+ const targetTag = tag || routePathMap.value.get(route.path);
+ if (!targetTag) return;
- tagsViewStore.delView(currentTag).then((result: any) => {
- if (tagsViewStore.isActive(currentTag)) {
- tagsViewStore.toLastView(result.visitedViews, currentTag);
+ tagsViewStore.delView(targetTag).then((result: any) => {
+ if (tagsViewStore.isActive(targetTag)) {
+ tagsViewStore.toLastView(result.visitedViews, targetTag);
}
// 关闭标签后重置滚动状态,以便下次可以重新判断是否需要滚动
nextTick(() => {
diff --git a/frontend/src/views/monitor/job/index.vue b/frontend/src/views/monitor/job/index.vue
index b415d54a..c7adec6e 100644
--- a/frontend/src/views/monitor/job/index.vue
+++ b/frontend/src/views/monitor/job/index.vue
@@ -566,9 +566,10 @@
+
-
+