diff --git a/src/layouts/modules/global-header/index.vue b/src/layouts/modules/global-header/index.vue index 1428030a..85995c26 100644 --- a/src/layouts/modules/global-header/index.vue +++ b/src/layouts/modules/global-header/index.vue @@ -45,7 +45,7 @@ const tenantId = ref(authStore.userInfo?.user?.tenantId || '0
- + themeStore.layout.scrollMode === 'wra + + + diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index fb320195..c884a79a 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -135,6 +135,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 0317dc95..0ab6341e 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -135,6 +135,9 @@ const local: App.I18n.Schema = { }, multilingual: { visible: '显示多语言按钮' + }, + globalSearch: { + visible: '显示全局搜索按钮' } }, tab: { 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; + } } diff --git a/src/theme/settings.ts b/src/theme/settings.ts index 5d521d52..bb8b9bb9 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 a2a49d53..29415bb3 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: { @@ -415,6 +419,9 @@ declare namespace App { multilingual: { visible: string; }; + globalSearch: { + visible: string; + }; }; tab: { visible: string;