fix(docs): reduce welcome screen delay and add localStorage check

This commit is contained in:
sanbuphy
2026-03-16 14:42:42 +08:00
parent ec95e132f4
commit c99264cb02
2 changed files with 19 additions and 2 deletions
+18 -1
View File
@@ -6,6 +6,8 @@ layout: home
import { onMounted } from 'vue'
import { withBase } from 'vitepress'
const WELCOME_SEEN_KEY = 'easy-vibe-welcome-seen'
onMounted(() => {
// 语言映射:浏览器语言代码 -> 网站路径
const langMap = {
@@ -44,8 +46,23 @@ onMounted(() => {
targetLang = '/zh-cn/'
}
const targetPath = withBase(targetLang)
let hasSeenWelcome = false
try {
hasSeenWelcome = window.localStorage.getItem(WELCOME_SEEN_KEY) === '1'
} catch {
hasSeenWelcome = false
}
if (!hasSeenWelcome) {
window.location.replace(
withBase(`/welcome/?next=${encodeURIComponent(targetPath)}`)
)
return
}
// 立即跳转,不显示任何内容
// 使用 withBase 自动处理 base 路径(根据 config.mjs 中的配置)
window.location.replace(withBase(targetLang))
window.location.replace(targetPath)
})
</script>