mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
chore: 🚀 配置域名迁移提示
This commit is contained in:
parent
3f9887c426
commit
b06703d706
@ -20,7 +20,7 @@ import CustomFooter from './components/CustomFooter.vue'
|
||||
import SvgImage from './components/SvgImage.vue'
|
||||
import HomeStar from './components/HomeStar.vue'
|
||||
import ExternalLink from './components/ExternalLink.vue'
|
||||
import ElementPlus from 'element-plus'
|
||||
import ElementPlus, { ElMessageBox } from 'element-plus'
|
||||
import 'element-plus/dist/index.css'
|
||||
|
||||
// 声明百度统计全局变量
|
||||
@ -46,8 +46,41 @@ export default {
|
||||
app.component('ExternalLink',ExternalLink)
|
||||
app.use(ElementPlus)
|
||||
|
||||
// 百度统计路由监听
|
||||
// 站点迁移检测
|
||||
if (typeof window !== 'undefined') {
|
||||
// 检测是否为旧域名,只在页面首次加载时检测
|
||||
const checkSiteMigration = async () => {
|
||||
if (window.location.hostname === 'wot-design-uni.pages.dev') {
|
||||
try {
|
||||
// 使用 Element Plus 的 MessageBox 弹出确认对话框
|
||||
await ElMessageBox.confirm(
|
||||
'站点已迁移至新域名,为了获得更好的访问体验,建议您跳转到新站点。',
|
||||
'站点迁移通知',
|
||||
{
|
||||
confirmButtonText: '立即跳转',
|
||||
cancelButtonText: '稍后再说',
|
||||
type: 'warning',
|
||||
center: true
|
||||
}
|
||||
)
|
||||
// 用户点击确认后跳转
|
||||
// 保持当前路径,只替换域名
|
||||
const newUrl = `https://wot-ui.cn${window.location.pathname}${window.location.search}${window.location.hash}`
|
||||
window.location.href = newUrl
|
||||
} catch {
|
||||
// 用户点击取消或关闭对话框,不做任何操作
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载完成后检测
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', checkSiteMigration)
|
||||
} else {
|
||||
checkSiteMigration()
|
||||
}
|
||||
|
||||
// 百度统计路由监听
|
||||
// 确保百度统计已加载
|
||||
const trackPageView = (path: string) => {
|
||||
if (window._hmt) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user