fix(route): 路由分离

This commit is contained in:
BTMuli
2023-03-29 21:01:22 +08:00
parent 6cc20242ee
commit e53114cb91
4 changed files with 88 additions and 66 deletions

View File

@@ -0,0 +1,49 @@
/**
* @file router modules main.ts
* @description 主路由模块
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha
*/
// 信息展示
import Home from "../../pages/Home.vue";
import News from "../../pages/News.vue";
import GCG from "../../pages/GCG.vue";
// 数据交互
import Achievements from "../../pages/Achievements.vue";
// 应用配置相关
import Config from "../../pages/Config.vue";
const mainRoutes = [
{
path: "/",
name: "首页",
component: Home,
},
{
path: "/achievements",
name: "成就",
component: Achievements,
},
{
path: "/config",
name: "设置",
component: Config,
},
{
path: "/GCG",
name: "卡牌",
component: GCG,
},
{
path: "/home",
redirect: "/",
},
{
path: "/news",
name: "咨讯",
component: News,
},
];
export default mainRoutes;

24
src/router/modules/sub.ts Normal file
View File

@@ -0,0 +1,24 @@
/**
* @file router modules sub.ts
* @description 子路由模块,用于二级窗口
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha
*/
// 帖子相关
import TPost from "../../views/t-post.vue";
import TPostJson from "../../views/t-post-json.vue";
const subRoutes = [
{
path: "/post_detail/:post_id",
name: "帖子详情",
component: TPost,
},
{
path: "/post_detail_json/:post_id",
name: "帖子详情JSON",
component: TPostJson,
},
];
export default subRoutes;

View File

@@ -1,69 +1,16 @@
// 信息展示
import GCG from "../pages/GCG.vue";
import Home from "../pages/Home.vue";
import News from "../pages/News.vue";
// 数据交互
import Achievements from "../pages/Achievements.vue";
import TPost from "../views/t-post.vue";
// 应用配置相关
import Config from "../pages/Config.vue";
/**
* @file router routes.ts
* @description 路由配置
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha
*/
const routes = [
{
path: "/",
name: "首页",
component: Home,
meta: {
isMain: true,
},
},
{
path: "/achievements",
name: "成就",
component: Achievements,
meta: {
isMain: true,
},
},
{
path: "/config",
name: "设置",
component: Config,
meta: {
isMain: true,
},
},
{
path: "/GCG",
name: "卡牌",
component: GCG,
meta: {
isMain: true,
},
},
{
path: "/home",
redirect: "/",
meta: {
isMain: true,
},
},
{
path: "/news",
name: "咨讯",
component: News,
meta: {
isMain: true,
},
},
{
path: "/post_detail/:post_id",
name: "帖子详情",
component: TPost,
meta: {
isMain: false,
},
},
];
// 主路由
import mainRoutes from "./modules/main";
// 子路由
import subRoutes from "./modules/sub";
// 合并路由
const routes = [...mainRoutes, ...subRoutes];
export default routes;

View File

@@ -0,0 +1,2 @@
<template></template>
<script lang="ts"></script>