Skip to content

Commit

Permalink
chore: rm china mirror redirect (#12968)
Browse files Browse the repository at this point in the history
chore: rm redirect
  • Loading branch information
0song committed Jun 2, 2023
1 parent 8fd857a commit 0a6e403
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions docs/.vitepress/vitepress/components/vp-app.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import { ElMessageBox } from 'element-plus'
// import { ElMessageBox } from 'element-plus'
import nprogress from 'nprogress'
import dayjs from 'dayjs'
import { isClient, useEventListener, useStorage, useToggle } from '@vueuse/core'
// import dayjs from 'dayjs'
import { isClient, useEventListener, useToggle } from '@vueuse/core'
import { useSidebar } from '../composables/sidebar'
import { useToggleWidgets } from '../composables/toggle-widgets'
import { useLang } from '../composables/lang'
// import { useLang } from '../composables/lang'
import { breakpoints } from '../constant'
import VPOverlay from './vp-overlay.vue'
import VPSkipLink from './vp-skip-link.vue'
Expand All @@ -16,16 +16,16 @@ import VPSidebar from './vp-sidebar.vue'
import VPContent from './vp-content.vue'
import VPSponsors from './vp-sponsors.vue'
const USER_PREFER_GITHUB_PAGE = 'USER_PREFER_GITHUB_PAGE'
// const USER_PREFER_GITHUB_PAGE = 'USER_PREFER_GITHUB_PAGE'
const [isSidebarOpen, toggleSidebar] = useToggle(false)
const { hasSidebar } = useSidebar()
const lang = useLang()
// const lang = useLang()
const mirrorUrl = 'element-plus.gitee.io'
const isMirrorUrl = () => {
if (!isClient) return
return window.location.hostname === mirrorUrl
}
// const mirrorUrl = 'element-plus.gitee.io'
// const isMirrorUrl = () => {
// if (!isClient) return
// return window.location.hostname === mirrorUrl
// }
useToggleWidgets(isSidebarOpen, () => {
if (!isClient) return
Expand All @@ -42,7 +42,7 @@ useEventListener('keydown', (e) => {
}
})
const userPrefer = useStorage<boolean | string>(USER_PREFER_GITHUB_PAGE, null)
// const userPrefer = useStorage<boolean | string>(USER_PREFER_GITHUB_PAGE, null)
onMounted(async () => {
if (!isClient) return
Expand Down Expand Up @@ -75,36 +75,36 @@ onMounted(async () => {
{ capture: true }
)
if (lang.value === 'zh-CN') {
if (isMirrorUrl()) return
// if (lang.value === 'zh-CN') {
// if (isMirrorUrl()) return
if (userPrefer.value) {
// no alert in the next 90 days
if (
dayjs
.unix(Number(userPrefer.value))
.add(90, 'day')
.diff(dayjs(), 'day', true) > 0
)
return
}
try {
await ElMessageBox.confirm(
'建议大陆用户访问部署在国内的站点,是否跳转?',
'提示',
{
confirmButtonText: '跳转',
cancelButtonText: '取消',
}
)
const toLang = '/zh-CN/'
location.href = `https://element-plus.gitee.io${toLang}${location.pathname.slice(
toLang.length
)}`
} catch {
userPrefer.value = String(dayjs().unix())
}
}
// if (userPrefer.value) {
// // no alert in the next 90 days
// if (
// dayjs
// .unix(Number(userPrefer.value))
// .add(90, 'day')
// .diff(dayjs(), 'day', true) > 0
// )
// return
// }
// try {
// await ElMessageBox.confirm(
// '建议大陆用户访问部署在国内的站点,是否跳转?',
// '提示',
// {
// confirmButtonText: '跳转',
// cancelButtonText: '取消',
// }
// )
// const toLang = '/zh-CN/'
// location.href = `https://element-plus.gitee.io${toLang}${location.pathname.slice(
// toLang.length
// )}`
// } catch {
// userPrefer.value = String(dayjs().unix())
// }
// }
// unregister sw
navigator?.serviceWorker?.getRegistrations().then((registrations) => {
for (const registration of registrations) {
Expand Down

0 comments on commit 0a6e403

Please sign in to comment.