From 75455b006c4b2a9ec7d5ba2ecefaf450691be617 Mon Sep 17 00:00:00 2001
From: t8y2 <1156263951@qq.com>
Date: Thu, 29 May 2025 11:09:12 +0800
Subject: [PATCH 1/2] feat(theme): global search button toggle
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在主题设置中添加全局搜索按钮的显示控制选项
- 更新多语言文件,添加全局搜索按钮显示控制的翻译
- 修改全局头部组件,根据主题设置决定是否显示全局搜索按钮
- 在主题抽屉中添加全局搜索按钮显示控制的开关
---
src/layouts/modules/global-header/index.vue | 2 +-
src/layouts/modules/theme-drawer/modules/page-fun.vue | 3 +++
src/locales/langs/en-us.ts | 3 +++
src/locales/langs/zh-cn.ts | 3 +++
src/theme/settings.ts | 3 +++
src/typings/app.d.ts | 7 +++++++
6 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/layouts/modules/global-header/index.vue b/src/layouts/modules/global-header/index.vue
index 592048db..d1e680a7 100644
--- a/src/layouts/modules/global-header/index.vue
+++ b/src/layouts/modules/global-header/index.vue
@@ -38,7 +38,7 @@ const { isFullscreen, toggle } = useFullscreen();
-
+
themeStore.layout.scrollMode === 'wra
+
+
+
diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts
index c3ae71c7..ef8baf32 100644
--- a/src/locales/langs/en-us.ts
+++ b/src/locales/langs/en-us.ts
@@ -112,6 +112,9 @@ const local: App.I18n.Schema = {
},
multilingual: {
visible: 'Display multilingual button'
+ },
+ globalSearch: {
+ visible: 'Display GlobalSearch button'
}
},
tab: {
diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts
index 32c14ceb..c21d7a63 100644
--- a/src/locales/langs/zh-cn.ts
+++ b/src/locales/langs/zh-cn.ts
@@ -112,6 +112,9 @@ const local: App.I18n.Schema = {
},
multilingual: {
visible: '显示多语言按钮'
+ },
+ globalSearch: {
+ visible: '显示全局搜索按钮'
}
},
tab: {
diff --git a/src/theme/settings.ts b/src/theme/settings.ts
index 4cfa185f..63c2cb25 100644
--- a/src/theme/settings.ts
+++ b/src/theme/settings.ts
@@ -30,6 +30,9 @@ export const themeSettings: App.Theme.ThemeSetting = {
},
multilingual: {
visible: true
+ },
+ globalSearch: {
+ visible: true
}
},
tab: {
diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts
index 73cd76f1..7f9c30c2 100644
--- a/src/typings/app.d.ts
+++ b/src/typings/app.d.ts
@@ -58,6 +58,10 @@ declare namespace App {
/** Whether to show the multilingual */
visible: boolean;
};
+ globalSearch: {
+ /** Whether to show the GlobalSearch */
+ visible: boolean;
+ };
};
/** Tab */
tab: {
@@ -377,6 +381,9 @@ declare namespace App {
multilingual: {
visible: string;
};
+ globalSearch: {
+ visible: string;
+ };
};
tab: {
visible: string;
From 222187d3b036ead467e5f18f2829d43476e8e99a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=81=95=E7=91=9E=E7=8E=9B=E7=9A=84=E7=9A=87=E5=B8=9D?=
<2075125282@qq.com>
Date: Sat, 31 May 2025 02:21:40 +0800
Subject: [PATCH 2/2] optimize(hooks): update detection function to cover the
exceptions that occur when the request fails.
---
src/plugins/app.ts | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/plugins/app.ts b/src/plugins/app.ts
index 1a0d8999..4943341f 100644
--- a/src/plugins/app.ts
+++ b/src/plugins/app.ts
@@ -25,8 +25,8 @@ export function setupAppVersionNotification() {
const buildTime = await getHtmlBuildTime();
- // If build time hasn't changed, no update is needed
- if (buildTime === BUILD_TIME) {
+ // If failed to get build time or build time hasn't changed, no update is needed.
+ if (!buildTime || buildTime === BUILD_TIME) {
return;
}
@@ -88,16 +88,22 @@ export function setupAppVersionNotification() {
}
}
-async function getHtmlBuildTime() {
+async function getHtmlBuildTime(): Promise {
const baseUrl = import.meta.env.VITE_BASE_URL || '/';
- const res = await fetch(`${baseUrl}index.html?time=${Date.now()}`);
+ try {
+ const res = await fetch(`${baseUrl}index.html?time=${Date.now()}`);
- const html = await res.text();
+ if (!res.ok) {
+ console.error('getHtmlBuildTime error:', res.status, res.statusText);
+ return null;
+ }
- const match = html.match(//);
-
- const buildTime = match?.[1] || '';
-
- return buildTime;
+ const html = await res.text();
+ const match = html.match(//);
+ return match?.[1] || null;
+ } catch (error) {
+ console.error('getHtmlBuildTime error:', error);
+ return null;
+ }
}