feat: reoede web to tailwindcss
This commit is contained in:
+68
-47
@@ -1,68 +1,89 @@
|
||||
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
|
||||
import LoginInex from '../views/home/login.vue'
|
||||
// import LoginInex from '../components/Login.vue'
|
||||
import { CONSTANT } from '../constant'
|
||||
|
||||
const router = createRouter({
|
||||
// history: createWebHistory(import.meta.env.BASE_URL),
|
||||
history: createWebHashHistory(),
|
||||
// 使用 HTML5 History 模式,确保 URL 变化反映在浏览器地址栏中
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: LoginInex
|
||||
component:() => import('../components/Login.vue')
|
||||
},
|
||||
{
|
||||
path: '/statistic',
|
||||
name: 'statistic',
|
||||
alias: '/',
|
||||
component: () => import('../views/tabsTools/statistic/statistic.vue')
|
||||
},
|
||||
{
|
||||
path: '/sendways',
|
||||
name: 'sendWays',
|
||||
component: () => import('../views/tabsTools/sendWays/sendWays.vue')
|
||||
},
|
||||
{
|
||||
path: '/sendtasks',
|
||||
name: 'sendtasks',
|
||||
component: () => import('../views/tabsTools/sendTasks/sendTasks.vue')
|
||||
},
|
||||
{
|
||||
path: '/cronmessages',
|
||||
name: 'cronmessages',
|
||||
component: () => import('../views/tabsTools/cronMessage/cronMessage.vue')
|
||||
},
|
||||
{
|
||||
path: '/sendlogs',
|
||||
name: 'sendlogs',
|
||||
component: () => import('../views/tabsTools/sendLogs/sendLogs.vue')
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
name: 'settings',
|
||||
component: () => import('../views/tabsTools/settings/settings.vue')
|
||||
},
|
||||
{
|
||||
path: '/hostedMessage',
|
||||
name: 'hostedmessage',
|
||||
component: () => import('../views/tabsTools/hostedMessage/hostedMessage.vue')
|
||||
},
|
||||
{
|
||||
path: '/:catchAll(.*)',
|
||||
name: '404',
|
||||
component: () => import('../views/404.vue')
|
||||
path: '/',
|
||||
name: 'index',
|
||||
component: () => import('../components/Index.vue'),
|
||||
children: [
|
||||
{
|
||||
// 默认子路由,显示 Dashboard
|
||||
path: '',
|
||||
name: 'dashboard',
|
||||
component: () => import('../components/pages/dashboard/Dashboard.vue')
|
||||
},
|
||||
{
|
||||
path: 'sendlogs',
|
||||
name: 'sendlogs',
|
||||
component: () => import('../components/pages/sendLogs/SendLogs.vue')
|
||||
},
|
||||
{
|
||||
path: 'hostedmessage',
|
||||
name: 'hostedmessage',
|
||||
component: () => import('../components/pages/hostedMessage/HostedMessage.vue')
|
||||
},
|
||||
{
|
||||
path: 'settings',
|
||||
name: 'settings',
|
||||
component: () => import('../components/pages/settings/Settings.vue')
|
||||
},
|
||||
{
|
||||
path: 'sendways',
|
||||
name: 'sendways',
|
||||
component: () => import('../components/pages/sendWays/SendWays.vue')
|
||||
},
|
||||
{
|
||||
path: 'sendtasks',
|
||||
name: 'sendtasks',
|
||||
component: () => import('../components/pages/sendTasks/SendTasks.vue')
|
||||
},
|
||||
{
|
||||
path: 'cronmessages',
|
||||
name: 'cronmessages',
|
||||
component: () => import('../components/pages/cronMessages/CronMessages.vue')
|
||||
}
|
||||
]
|
||||
},
|
||||
// {
|
||||
// path: '/settings',
|
||||
// name: 'settings',
|
||||
// component: () => import('../views/tabsTools/settings/settings.vue')
|
||||
// },
|
||||
// {
|
||||
// path: '/hostedMessage',
|
||||
// name: 'hostedmessage',
|
||||
// component: () => import('../views/tabsTools/hostedMessage/hostedMessage.vue')
|
||||
// },
|
||||
// {
|
||||
// path: '/:catchAll(.*)',
|
||||
// name: '404',
|
||||
// component: () => import('../views/404.vue')
|
||||
// },
|
||||
]
|
||||
})
|
||||
|
||||
// 登录失效重定向到登录页面
|
||||
router.beforeEach((to, from, next) => {
|
||||
const isAuthenticated = Boolean(localStorage.getItem(CONSTANT.STORE_TOKEN_NAME));
|
||||
const token = localStorage.getItem(CONSTANT.STORE_TOKEN_NAME);
|
||||
const isAuthenticated = Boolean(token && token.trim() !== '');
|
||||
|
||||
|
||||
if (!isAuthenticated && to.path !== '/login') {
|
||||
|
||||
next('/login');
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 100);
|
||||
} else if (isAuthenticated && to.path === '/login') {
|
||||
|
||||
next('/');
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user