feat: init mainPage portfolio site
Vue 3 模块化作品集主页,浅色极简风格,中英双语懒加载 i18n。 - 模块注册表(import.meta.glob)约定式收集项目模块,新增页签无需改导航/路由 - i18n: 中文同步注入主 chunk,英文动态 import() 拆独立 chunk,仅切换时下载 - 第一个页签 mobile-game: 展示 448/449 移动游戏毕设(概览/截图轮播/版本时间线/团队/排行榜/ML视频) - 排行榜复用 /449/449rest.php,失败优雅降级 - 构建: vite outDir=/root/html,emptyOutDir=false,产物用 mainPage/ 命名空间 - 样式: CSS 变量令牌,无 UI 框架运行时依赖
This commit is contained in:
21
src/composables/useI18nLazy.js
Normal file
21
src/composables/useI18nLazy.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ref } from 'vue'
|
||||
import { loadLocaleAsync } from '../i18n/index.js'
|
||||
|
||||
const current = ref('zh-CN')
|
||||
const switching = ref(false)
|
||||
|
||||
// 语言懒加载切换逻辑
|
||||
export function useI18nLazy() {
|
||||
async function switchLocale(locale) {
|
||||
if (switching.value || current.value === locale) return
|
||||
switching.value = true
|
||||
try {
|
||||
await loadLocaleAsync(locale)
|
||||
current.value = locale
|
||||
} finally {
|
||||
switching.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return { current, switching, switchLocale }
|
||||
}
|
||||
Reference in New Issue
Block a user