admin_new/src/router/index.ts

319 lines
17 KiB
TypeScript

import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
/**
* 路由结构
* - /login 公开
* - / + /dashboard 实际页面
* - /inquiry 询价列表
* - /inquiry/:id 询价详情
* - /:module/:action 通配占位
* - /:pathMatch(.*)* 兜底跳首页
*
* W5.x.x+4: 50 个 P3 路由统一改用 MockTableView + configKey
* - 字段定义 / mock 数据集中在 mockTableConfigs.ts
* - 端点可用时自动透传真数据, 不可用时降级 mock
* - 一个 view 组件 50 路由复用
*/
const routes: RouteRecordRaw[] = [
{
path: '/login',
name: 'Login',
component: () => import('@/modules/auth/LoginView.vue'),
meta: { title: '登录', public: true }
},
// W3.x C P0.1: 数据统计首页
{
path: '/',
name: 'Statistics',
component: () => import('@/modules/statistics/StatisticsView.vue'),
meta: { title: '数据统计', icon: 'DataAnalysis' }
},
{
path: '/dashboard',
redirect: '/'
},
{
path: '/statistics/index',
name: 'StatisticsIndex',
component: () => import('@/modules/statistics/StatisticsView.vue'),
meta: { title: '数据统计', icon: 'DataAnalysis' }
},
{
path: '/inquiry',
name: 'InquiryList',
component: () => import('@/modules/inquiry/InquiryListView.vue'),
meta: { title: '询价管理' }
},
{
path: '/inquiry/:id',
name: 'InquiryDetail',
component: () => import('@/modules/inquiry/InquiryDetailView.vue'),
meta: { title: '询价详情' }
},
{ path: '/order/group-supplier', redirect: '/order/groupsupplierorder' },
{ path: '/order/group-service', redirect: '/order/groupserviceorder' },
{
path: '/supplier/inquiry/inquiry',
redirect: '/inquiry'
},
{
path: '/supplier/inquiry',
redirect: '/inquiry'
},
{
path: '/user/user',
name: 'UserUserList',
component: () => import('@/modules/user/UserListView.vue'),
meta: { title: '用户列表' }
},
// W3.2 订单管理
{
path: '/order',
name: 'OrderList',
component: () => import('@/modules/order/OrderListView.vue'),
meta: { title: '订单管理' }
},
{
path: '/order/:id',
name: 'OrderDetail',
component: () => import('@/modules/order/OrderDetailView.vue'),
meta: { title: '订单详情' }
},
// W4.19 业务模块
{
path: '/user/enterprise',
name: 'UserEnterpriseList',
component: () => import('@/modules/user/EnterpriseListView.vue'),
meta: { title: '企业管理' }
},
{
path: '/user/enterprise/detail/:id',
name: 'EnterpriseDetail',
component: () => import('@/modules/user/enterprise/EnterpriseDetailView.vue'),
meta: { title: '企业详情' }
},
{
path: '/user/enterprise/merchant/register',
name: 'MerchantRegisterList',
component: () => import('@/modules/user/merchant/MerchantRegisterListView.vue'),
meta: { title: '企业登记管理' }
},
{
path: '/user/finance',
name: 'UserFinanceList',
component: () => import('@/modules/user/FinanceListView.vue'),
meta: { title: '财务管理' }
},
{
path: '/supplier/activity',
name: 'SupplierActivityList',
component: () => import('@/modules/supplier/ActivityListView.vue'),
meta: { title: '营销活动' }
},
// W4.1 集成管理
{
path: '/openapi/app',
name: 'OpenAppList',
component: () => import('@/modules/openapi/OpenAppListView.vue'),
meta: { title: '应用列表' }
},
{
path: '/openapi/company',
name: 'OpenCompanyAccount',
component: () => import('@/modules/openapi/CompanyAccountListView.vue'),
meta: { title: '公司账号管理' }
},
{
path: '/openapi/audit-log',
name: 'OpenAuditLog',
component: () => import('@/modules/openapi/AuditLogListView.vue'),
meta: { title: '审计日志' }
},
// W3.x C P0.5+ 真实接入: 数据统计/资讯/帮助/操作指南/区域/单位/商品/店铺
{
path: '/other/operateguide',
name: 'OtherOperateguide',
component: () => import('@/modules/other/operateguide/OperateguideListView.vue'),
meta: { title: '操作指南' }
},
{
path: '/api/lunbo',
name: 'ApiLunbo',
component: () => import('@/modules/api/lunbo/LunboListView.vue'),
meta: { title: '轮播管理' }
},
{
path: '/api/help',
name: 'ApiHelp',
component: () => import('@/modules/api/help/HelpListView.vue'),
meta: { title: '帮助中心' }
},
{
path: '/api/feedback',
name: 'ApiFeedback',
component: () => import('@/modules/api/feedback/FeedbackListView.vue'),
meta: { title: '意见反馈' }
},
{
path: '/other/goodunit',
name: 'OtherGoodunit',
component: () => import('@/modules/other/goodunit/GoodunitListView.vue'),
meta: { title: '商品单位' }
},
{
path: '/other/label',
name: 'OtherLabel',
component: () => import('@/modules/other/label/LabelListView.vue'),
meta: { title: '标签管理' }
},
{
path: '/sys/region',
name: 'SysRegion',
component: () => import('@/modules/sys/region/RegionListView.vue'),
meta: { title: '行政区域' }
},
{
path: '/supplier/good',
name: 'SupplierGood',
component: () => import('@/modules/supplier/good/GoodListView.vue'),
meta: { title: '商品管理' }
},
{
path: '/supplier/servicegood',
component: () => import('@/modules/supplier/servicegood/ServiceGoodListView.vue'),
meta: { title: '服务商品' }
},
{
// W3.x C P2 + W17.3.7: 商品店铺后端未实现, redirect 到 supplier/good 实物商品页
path: '/product/shop',
redirect: '/supplier/good'
},
{
path: '/message/feedback',
redirect: '/api/feedback'
},
{
path: '/other/category',
redirect: '/other/category/good'
},
{
path: '/other/categoryGood',
redirect: '/other/category/good'
},
// ============ W5.x.x+4: 50 个 P3 路由 - MockTableView 集中配置 ============
// 4 个 message
{ path: '/message/sms', component: () => import('@/modules/message/sms/SmsListView.vue'), meta: { title: '短信配置' } },
{ path: '/message/sms-log', component: () => import('@/modules/message/smslog/SmsLogListView.vue'), meta: { title: '短信日志' } },
{ path: '/message/mail-template', component: () => import('@/modules/message/mailtemplate/MailTemplateListView.vue'), meta: { title: '邮件模板' } },
{ path: '/message/mail-log', component: () => import('@/modules/message/maillog/MailLogListView.vue'), meta: { title: '邮件日志' } },
// 4 个运营中心 (P1: mock -> 真 view, /sys/operation/pageList type 区分)
{ path: '/sys/operation', component: () => import('@/modules/sys/operation/OperationListView.vue'), props: () => ({ type: 1 }), meta: { title: '全国运营中心' } },
{ path: '/sys/operation/province', component: () => import('@/modules/sys/operation/OperationListView.vue'), props: () => ({ type: 2 }), meta: { title: '省级运营中心' } },
{ path: '/sys/operation/county', component: () => import('@/modules/sys/operation/OperationListView.vue'), props: () => ({ type: 3 }), meta: { title: '县级运营中心' } },
{ path: '/sys/operation/association', component: () => import('@/modules/sys/operation/OperationListView.vue'), props: () => ({ type: 4 }), meta: { title: '行业协会运营' } },
// 3 个资讯类 (P1: information -> 真 view, industry/categoryZX 404 保留 mock)
{ path: '/other/information', component: () => import('@/modules/other/information/InformationListView.vue'), meta: { title: '资讯列表' } },
{ path: '/other/industry', component: () => import('@/modules/other/category/CategoryDeepListView.vue'), props: { type: 1, title: '行业管理' }, meta: { title: '行业' } },
{ path: '/other/category/zx', component: () => import('@/modules/other/category/CategoryDeepListView.vue'), props: { type: 3, title: '资讯分类' }, meta: { title: '资讯分类' } },
// devtools 5 个
{ path: '/devtools/baseclass', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'devtools-baseclass' }), meta: { title: '基类配置' } },
{ path: '/devtools/datasource', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'devtools-datasource' }), meta: { title: '数据源配置' } },
{ path: '/devtools/fieldtype', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'devtools-fieldtype' }), meta: { title: '字段配置' } },
{ path: '/devtools/param', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'devtools-param' }), meta: { title: '参数配置(开发)' } },
{ path: '/devtools/template', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'devtools-template' }), meta: { title: '模板配置' } },
// job 1 个
{ path: '/job/schedule', component: () => import('@/modules/sys/ScheduleListView.vue'), meta: { title: '定时任务' } },
// order 9 个
{ path: '/order/ordergood', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '商品订单' } },
{ path: '/order/serviceorder', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '服务订单' } },
{ path: '/order/groupsupplierorder', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '商品拼团订单' } },
{ path: '/order/groupserviceorder', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '服务拼团订单' } },
{ path: '/order/ordergood/commission', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '实物订单分佣统计' } },
{ path: '/order/serviceorder/commission', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '服务订单分佣统计' } },
{ path: '/order/ordergood/after', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '商品售后订单' } },
{ path: '/order/serviceorder/after', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '服务售后订单' } },
{ path: '/order/orderserviceafter', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '服务售后订单' } },
{ path: '/order/base-price-analysis', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '基础价格分析表' } },
// W15 新增 - 订单售后 + 退款 + 付款回调 (前端 max-effort mock, 老 vue 同字段)
{ path: '/order/orderpay', component: () => import('@/modules/order/payment/PaymentCallbackListView.vue'), meta: { title: '订单支付回调' } },
{ path: '/order/refund', component: () => import('@/modules/order/refund/RefundProcessListView.vue'), meta: { title: '订单退款管理' } },
{ path: '/order/aftersale', component: () => import('@/modules/order/aftersale/AftersaleListView.vue'), meta: { title: '售后订单' } },
// other 7 个
{ path: '/other/brand', component: () => import('@/modules/other/supplierBrand/SupplierBrandListView.vue'), meta: { title: '品牌管理' } },
// W18 真 view 切换 (原 MockTableView -> 真页面)
{ path: '/other/category/good', component: () => import('@/modules/other/categoryGood/CategoryGoodListView.vue'), meta: { title: '平台分类' } },
{ path: '/other/help', component: () => import('@/modules/other/help/HelpListView.vue'), meta: { title: '帮助中心' } },
{ path: '/other/guide', component: () => import('@/modules/other/operateguide/OperateguideListView.vue'), meta: { title: '内容列表' } },
{ path: '/other/textconfig', component: () => import('@/modules/other/textconfig/TextconfigListView.vue'), meta: { title: '常量配置' } },
{ path: '/other/groupbuy', component: () => import('@/modules/other/groupbuy/GroupbuyListView.vue'), meta: { title: '拼团活动' } },
{ path: '/other/seckill', component: () => import('@/modules/other/seckill/SeckillListView.vue'), meta: { title: '秒杀活动' } },
// 价格公式变量
{ path: '/supplier/priceFormulaVariable', component: () => import('@/modules/supplier/priceformula/PriceFormulaVariableListView.vue'), meta: { title: '价格公式变量' } },
// supplier 2 个
{ path: '/supplier/coupon', component: () => import('@/modules/supplier/coupon/CouponListView.vue'), meta: { title: '优惠券' } }, // W7: 独立 view, 走 /supplier/coupon/page 真 API
{ path: '/supplier/promoter', component: () => import('@/modules/supplier/promoter/PromoterListView.vue'), meta: { title: '推广员管理' } },
{ path: '/supplier/historylog', component: () => import('@/modules/supplier/historylog/HistorylogListView.vue'), meta: { title: '浏览足迹' } },
{ path: '/supplier/ordercomment', component: () => import('@/modules/supplier/ordercomment/OrderCommentListView.vue'), meta: { title: '订单评价' } },
{ path: '/supplier/logistics', component: () => import('@/modules/supplier/logistics/LogisticsListView.vue'), meta: { title: '物流方案' } },
{ path: '/supplier/coupon-scope', component: () => import('@/modules/supplier/couponscope/CouponScopeListView.vue'), meta: { title: '优惠券适用范围' } },
// sys 11 个
{ path: '/sys/dict', component: () => import('@/modules/sys/DictTypeListView.vue'), meta: { title: '字典类型' } },
{ path: '/sys/log/login', component: () => import('@/modules/sys/LogLoginView.vue'), meta: { title: '登录日志' } },
{ path: '/sys/log/operation', component: () => import('@/modules/sys/LogOperationView.vue'), meta: { title: '操作日志' } },
{ path: '/sys/log/error', component: () => import('@/modules/sys/LogErrorView.vue'), meta: { title: '异常日志' } },
{ path: '/sys/notice', component: () => import('@/modules/sys/NoticeListView.vue'), meta: { title: '通知公告' } },
{ path: '/sys/params', component: () => import('@/modules/sys/ParamsListView.vue'), meta: { title: '参数配置' } },
{ path: '/sys/notice-user', component: () => import('@/modules/sys/noticeuser/NoticeUserListView.vue'), meta: { title: '用户通知' } },
{ path: '/sys/userManagement', redirect: '/sys/operation', meta: { title: '全国运营中心' } },
// W18 后台用户管理 5 个 (老 vue sys/user 模块, 真 view 已存在)
{ path: '/sys/user', component: () => import('@/modules/sys/UserListView.vue'), meta: { title: '用户管理' } },
{ path: '/sys/role', component: () => import('@/modules/sys/RoleListView.vue'), meta: { title: '角色管理' } },
{ path: '/sys/post', component: () => import('@/modules/sys/PostListView.vue'), meta: { title: '岗位管理' } },
{ path: '/sys/dept', component: () => import('@/modules/sys/DeptListView.vue'), meta: { title: '部门管理' } },
{ path: '/sys/menu', component: () => import('@/modules/sys/MenuListView.vue'), meta: { title: '菜单管理' } },
// user 9 个
{ path: '/user/enterprise/level', component: () => import('@/modules/user/enterpriselevel/EnterpriselevelListView.vue'), meta: { title: '企业等级管理' } },
{ path: '/user/enterprise/rating', component: () => import('@/modules/user/enterpriserating/EnterpriseratingListView.vue'), meta: { title: '供应商评级' } },
{ path: '/user/enterprise/score', component: () => import('@/modules/user/enterprisescore/EnterprisescoreListView.vue'), meta: { title: '供应商评分' } },
{ path: '/user/finance/recharge', component: () => import('@/modules/user/finance/AccountTransactionListView.vue'), props: () => ({ type: 1 }), meta: { title: '充值管理' } },
{ path: '/user/finance/recharge-tx', component: () => import('@/modules/user/finance/AccountTransactionListView.vue'), props: () => ({ type: 2 }), meta: { title: '提现管理' } },
{ path: '/user/finance/revenue', component: () => import('@/modules/user/finance/AccountTransactionListView.vue'), props: () => ({ type: 3 }), meta: { title: '分账记录管理' } },
{ path: '/user/finance/transaction', component: () => import('@/modules/user/finance/AccountTransactionListView.vue'), meta: { title: '交易流水' } },
{ path: '/user/message', component: () => import('@/modules/user/message/MessageListView.vue'), meta: { title: '系统消息' } },
{ path: '/user/message/handel', component: () => import('@/modules/user/message/MessageListView.vue'), props: { status: 0 }, meta: { title: '待处理消息' } },
// W3.1 通用通配占位
{
path: '/:module/:action?',
name: 'Placeholder',
component: () => import('@/modules/placeholder/PlaceholderView.vue'),
meta: { title: '即将上线' }
},
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
redirect: '/'
}
]
const router = createRouter({
history: createWebHistory('/admin/'),
routes
})
// 路由守卫
router.beforeEach((to, from, next) => {
const isPublic = to.meta?.public === true
const token = localStorage.getItem('access_token')
if (!isPublic && !token) {
next({ name: 'Login', query: { redirect: to.fullPath } })
} else {
next()
}
})
export default router