问题: 路由 /supplier/coupon 共用了 configKey=other-textconfig, 导致点击优惠券打开的是常量配置页 (W5.x.x+4 阶段误用) 改动: - 新增 src/modules/supplier/coupon/CouponListView.vue (233 行) - 沿用老 vue supplier/coupon.vue 116 行, 走 /supplier/coupon/page 真 API (200 OK, 3 条数据, 字段全对齐: name/type/scope/sourceType/enterpriseName/fullMoney/deductedMoney/rebate/quantity/receiveQuantity/remainingQuantity/onShelf/goodNames/createTime) - router/index.ts 行 237 改用独立 view - mockTableConfigs.ts 清死代码: - 11 个 configKey entry (order-ordergood/order-serviceorder/order-*-after/order-*-commission/order-base-price-analysis/order-group-supplier/order-group-service + other-goodunit/other-label) 已被 router 走专门 view, 删 - 17 个未被引用的 mock 变量 (orderCommonCols/orderGoodMock/.../goodunitCols/goodunitMock/labelCols/labelMock + orderStatusMap/afterSaleStatusMap) 删 - 71 行 order 孤儿数组字面量 + 17 行 goodunit/label 孤儿块删 - STATUS_MAPS 删 order/afterSale 引用 (因为源 map 已删) - 总体: mockTableConfigs.ts 928 行 → 797 行 (-131 行, -14%) 验收: 13/13 URL 200 (admin + 11 旧 + 1 新 coupon); CouponListView-*.js 已编译进 dist build: gzip 375KB 无回退, MockTableView bundle 49.88KB → 41.65KB (-17%)
290 lines
15 KiB
TypeScript
290 lines
15 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/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: '服务商品' }
|
|
},
|
|
{
|
|
path: '/product/shop',
|
|
name: 'ProductShop',
|
|
component: () => import('@/modules/product/shop/ShopListView.vue'),
|
|
meta: { title: '店铺管理' }
|
|
},
|
|
{
|
|
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/generic/MockTableView.vue'), props: () => ({ configKey: 'message-sms' }), meta: { title: '短信配置' } },
|
|
{ path: '/message/sms-log', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'message-sms-log' }), meta: { title: '短信日志' } },
|
|
{ path: '/message/mail-template', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'message-mail-template' }), meta: { title: '邮件模板' } },
|
|
{ path: '/message/mail-log', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'message-mail-log' }), meta: { title: '邮件日志' } },
|
|
// 4 个运营中心
|
|
{ path: '/sys/operation', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-operation-country' }), meta: { title: '全国运营中心' } },
|
|
{ path: '/sys/operation/province', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-operation-province' }), meta: { title: '省级运营中心' } },
|
|
{ path: '/sys/operation/county', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-operation-county' }), meta: { title: '县级运营中心' } },
|
|
{ path: '/sys/operation/association', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-operation-association' }), meta: { title: '行业协会运营' } },
|
|
// 3 个资讯类
|
|
{ path: '/other/information', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-information' }), meta: { title: '资讯列表' } },
|
|
{ path: '/other/industry', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-industry' }), meta: { title: '行业' } },
|
|
{ path: '/other/category/zx', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-category-zx' }), 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/generic/MockTableView.vue'), props: () => ({ configKey: 'job-schedule' }), 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/orderserviceafter', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '服务售后订单' } },
|
|
{ path: '/order/base-price-analysis', component: () => import('@/modules/order/OrderListView.vue'), meta: { title: '基础价格分析表' } },
|
|
// other 7 个
|
|
{ path: '/other/brand', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-brand' }), meta: { title: '品牌管理' } },
|
|
{ path: '/other/category/good', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-category-good' }), meta: { title: '平台分类' } },
|
|
{ path: '/other/help', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-help' }), meta: { title: '帮助中心' } },
|
|
{ path: '/other/guide', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-guide' }), meta: { title: '内容列表' } },
|
|
{ path: '/other/textconfig', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-textconfig' }), meta: { title: '常量配置' } },
|
|
{ path: '/other/groupbuy', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-groupbuy' }), meta: { title: '拼团活动' } },
|
|
{ path: '/other/seckill', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'other-seckill' }), 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/generic/MockTableView.vue'), props: () => ({ configKey: 'supplier-promoter' }), meta: { title: '推广返佣' } },
|
|
// sys 11 个
|
|
{ path: '/sys/dict', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-dict' }), meta: { title: '字典类型' } },
|
|
{ path: '/sys/log/login', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-log-login' }), meta: { title: '登录日志' } },
|
|
{ path: '/sys/log/operation', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-log-operation' }), meta: { title: '操作日志' } },
|
|
{ path: '/sys/log/error', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-log-error' }), meta: { title: '异常日志' } },
|
|
{ path: '/sys/notice', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-notice' }), meta: { title: '通知公告' } },
|
|
{ path: '/sys/params', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-params' }), meta: { title: '参数配置' } },
|
|
{ path: '/sys/notice-user', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-notice-user' }), meta: { title: '用户通知' } },
|
|
{ path: '/sys/userManagement', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'sys-userManagement' }), meta: { title: '全国运营中心' } },
|
|
// user 9 个
|
|
{ path: '/user/enterprise/level', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-enterprise-level' }), meta: { title: '企业等级管理' } },
|
|
{ path: '/user/enterprise/rating', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-enterprise-rating' }), meta: { title: '评级' } },
|
|
{ path: '/user/enterprise/score', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-enterprise-score' }), meta: { title: '评分' } },
|
|
{ path: '/user/finance/recharge', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-finance-recharge' }), meta: { title: '充值管理' } },
|
|
{ path: '/user/finance/recharge-tx', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-finance-recharge-tx' }), meta: { title: '提现管理' } },
|
|
{ path: '/user/finance/revenue', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-finance-revenue' }), meta: { title: '分账记录管理' } },
|
|
{ path: '/user/finance/transaction', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-finance-transaction' }), meta: { title: '交易流水' } },
|
|
{ path: '/user/message', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-message' }), meta: { title: '系统消息' } },
|
|
{ path: '/user/message/handel', component: () => import('@/modules/generic/MockTableView.vue'), props: () => ({ configKey: 'user-message-handel' }), 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
|