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:
32
src/router/index.js
Normal file
32
src/router/index.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// 路由表由模块注册表动态生成 -- 新增模块自动产生路由,无需手改。
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import modules from '../modules/index.js'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
redirect: modules.length ? `/${modules[0].id}` : '/404'
|
||||
},
|
||||
// 每个模块一条路由,组件懒加载
|
||||
...modules.map((m) => ({
|
||||
path: `/${m.id}`,
|
||||
name: m.id,
|
||||
component: m.component,
|
||||
meta: { moduleId: m.id }
|
||||
})),
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'not-found',
|
||||
redirect: '/'
|
||||
}
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
scrollBehavior() {
|
||||
return { top: 0 }
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user