From 9fb5927d79e212ebead4397e67dcf7e49fab9872 Mon Sep 17 00:00:00 2001 From: 0song <82012629+0song@users.noreply.github.com> Date: Thu, 28 Apr 2022 12:48:41 +0800 Subject: [PATCH] chore: disable pwa on mirror site (#7413) * chore: disable pwa on mirror site * chore: disable pwa on mirror site --- docs/.vitepress/vitepress/components/vp-app.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/.vitepress/vitepress/components/vp-app.vue b/docs/.vitepress/vitepress/components/vp-app.vue index fc6afaaa01..e85ca28c06 100644 --- a/docs/.vitepress/vitepress/components/vp-app.vue +++ b/docs/.vitepress/vitepress/components/vp-app.vue @@ -17,11 +17,16 @@ import VPSponsors from './vp-sponsors.vue' import VPReloadPrompt from './vp-reload-prompt.vue' const USER_PREFER_GITHUB_PAGE = 'USER_PREFER_GITHUB_PAGE' - const [isSidebarOpen, toggleSidebar] = useToggle(false) const { hasSidebar } = useSidebar() const lang = useLang() +const mirrorUrl = 'element-plus.gitee.io' +const isMirrorUrl = () => { + if (!isClient) return + return window.location.hostname === mirrorUrl +} + useToggleWidgets(isSidebarOpen, () => { if (!isClient) return if (window.outerWidth >= breakpoints.lg) { @@ -63,7 +68,7 @@ onMounted(async () => { ) if (lang.value === 'zh-CN') { - if (location.host === 'element-plus.gitee.io') return + if (isMirrorUrl()) return if (userPrefer.value) { // no alert in the next 90 days @@ -130,7 +135,7 @@ onMounted(async () => { - +