Files
lucia-frontend/src/router/index.js
2024-02-01 12:33:11 +08:00

123 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { createRouter, createWebHistory, createWebHashHistory } from "vue-router";
import AuthContainer from '@/views/AuthContainer.vue';
import MainContainer from '@/views/MainContainer.vue';
import Login from '@/views/Login/index.vue';
import Files from '@/views/Files/index.vue';
import Upload from '@/views/Upload/index.vue';
import Map from '@/views/Discover/Map/index.vue';
import Conformance from '@/views/Discover/Conformance/index.vue';
import Performance from '@/views/Discover/Performance/index.vue';
import MemberArea from '@/views/MemberArea/index.vue';
import NotFound404 from '@/views/NotFound404.vue';
const routes = [
{
path: '/', // 預設進入路由
redirect: '/files', //重定向
},
{
path: '/',
name: "AuthContainer",
component: AuthContainer,
children: [
{
path: "/login",
name: "Login",
component: Login,
},
]
},
{
path: "/",
name: "MainContainer",
component: MainContainer,
meta: {
title: "MainContainer",
requiresAuth: true
},
children: [
{
path: "/member-area",
name: "MemberArea",
component: MemberArea,
},
{
path: "/files",
name: "Files",
component: Files,
},
{
path: "/upload", // router.push({ replace: true }) 路徑不添進歷史紀錄
name: "Upload",
component: Upload
},
{
path: "/discover",
name: "Discover",
children: [
{
path: "/discover/map/:type/:fileId",
name: "Map",
component: Map,
},
{
path: "/discover/conformance/:type/:fileId",
name: "Conformance",
component: Conformance,
},
{
// type: rule(名稱待討論)
// checkType: log | filter
path: "/:type/:checkType/:checkId/map/:checkFileId",
name: "CheckMap",
component: Map,
props: true,
},
{
path: "/:type/:checkType/:checkId/conformance/:checkFileId",
name: "CheckConformance",
component: Conformance,
props: true,
},
// {
// path: "/discover/performance/:type/:fileId",
// name: "Performance",
// component: Performance,
// }
]
},
]
},
{
path: "/:pathMatch(.*)*",
name: "NotFound404",
component: NotFound404,
},
{
path: "/discover/performance",
name: "Performance",
component: Performance,
}
];
const base_url = import.meta.env.BASE_URL;
const router = createRouter({
history: createWebHistory(base_url), //(/)
// history: createWebHashHistory(base_url), // (/#)
routes
});
// 全域性路由守衛
// router.beforeEach((to, from) => {
// // to: Route: 即將要進入的目標 路由物件
// // from: Route: 當前導航正要離開的路由
// let isRemoveCookie = document.cookie.split(';').some(c => c.trim().startsWith('expires=Thu, 01 Jan 1970 00:00:00 UTC;')); // 是否登入,有到期日表示已登出。
// // 當路由到 login 時有登入要跳轉至home
// if (to.name === 'Login') {
// if (isRemoveCookie) router.push({ name: 'Files' });
// }
// });
export default router;