All checks were successful
continuous-integration/drone/push Build is passing
- 新增告警模块 (alerts): 告警规则配置与触发 - 新增成本管理模块 (cost): 成本统计与分析 - 新增配额模块 (quota): 配额管理与限制 - 新增微信模块 (wechat): 微信相关功能接口 - 新增缓存服务 (cache): Redis 缓存封装 - 新增请求日志中间件 (request_logger) - 新增异常处理和链路追踪中间件 - 更新 dashboard 前端展示 - 更新 SDK stats_client 功能
105 lines
2.8 KiB
JavaScript
105 lines
2.8 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
|
|
const routes = [
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
component: () => import('@/views/login/index.vue'),
|
|
meta: { title: '登录', public: true }
|
|
},
|
|
{
|
|
path: '/error',
|
|
name: 'Error',
|
|
component: () => import('@/views/error/index.vue'),
|
|
meta: { title: '出错了', public: true }
|
|
},
|
|
{
|
|
path: '/',
|
|
component: () => import('@/components/Layout.vue'),
|
|
redirect: '/dashboard',
|
|
children: [
|
|
{
|
|
path: 'dashboard',
|
|
name: 'Dashboard',
|
|
component: () => import('@/views/dashboard/index.vue'),
|
|
meta: { title: '仪表盘', icon: 'Odometer' }
|
|
},
|
|
{
|
|
path: 'tenants',
|
|
name: 'Tenants',
|
|
component: () => import('@/views/tenants/index.vue'),
|
|
meta: { title: '租户管理', icon: 'OfficeBuilding' }
|
|
},
|
|
{
|
|
path: 'tenants/:id',
|
|
name: 'TenantDetail',
|
|
component: () => import('@/views/tenants/detail.vue'),
|
|
meta: { title: '租户详情', hidden: true }
|
|
},
|
|
{
|
|
path: 'apps',
|
|
name: 'Apps',
|
|
component: () => import('@/views/apps/index.vue'),
|
|
meta: { title: '应用管理', icon: 'Grid' }
|
|
},
|
|
{
|
|
path: 'tenant-wechat-apps',
|
|
name: 'TenantWechatApps',
|
|
component: () => import('@/views/tenant-wechat-apps/index.vue'),
|
|
meta: { title: '企微应用', icon: 'ChatDotRound' }
|
|
},
|
|
{
|
|
path: 'app-config',
|
|
name: 'AppConfig',
|
|
component: () => import('@/views/app-config/index.vue'),
|
|
meta: { title: '租户应用配置', icon: 'Setting' }
|
|
},
|
|
{
|
|
path: 'stats',
|
|
name: 'Stats',
|
|
component: () => import('@/views/stats/index.vue'),
|
|
meta: { title: '统计分析', icon: 'TrendCharts' }
|
|
},
|
|
{
|
|
path: 'logs',
|
|
name: 'Logs',
|
|
component: () => import('@/views/logs/index.vue'),
|
|
meta: { title: '日志查看', icon: 'Document' }
|
|
},
|
|
{
|
|
path: 'users',
|
|
name: 'Users',
|
|
component: () => import('@/views/users/index.vue'),
|
|
meta: { title: '用户管理', icon: 'User', role: 'admin' }
|
|
}
|
|
]
|
|
}
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes
|
|
})
|
|
|
|
// 路由守卫
|
|
router.beforeEach((to, from, next) => {
|
|
// 设置页面标题
|
|
document.title = to.meta.title ? `${to.meta.title} - 平台管理` : '平台管理'
|
|
|
|
// 检查登录状态
|
|
const authStore = useAuthStore()
|
|
|
|
if (to.meta.public) {
|
|
next()
|
|
} else if (!authStore.isLoggedIn) {
|
|
next('/login')
|
|
} else if (to.meta.role && authStore.user?.role !== to.meta.role) {
|
|
next('/dashboard')
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|