front/src/router/index.ts
zzh a8d71d821d
All checks were successful
Build and Deploy Front / deploy (push) Successful in 11m54s
refine: 工作台与订单列表密度/工具栏选中态、筛选芯片与分页弱化
合并管理端工作台抬头与泳道卡片,订单列表统一紧凑工具栏(情境主按钮+更多)、吸顶与选中展开,并补可清除筛选芯片。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-27 12:49:53 +08:00

626 lines
18 KiB
TypeScript
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 } from 'vue-router';
import NProgress from 'nprogress'; // progress bar
import 'nprogress/nprogress.css';
import { isLogin } from '@/utils/auth';
import { appRoutes } from './routes';
import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './routes/base';
import createRouteGuard from './guard';
NProgress.configure({
showSpinner: false,
speed: 280,
minimum: 0.12,
trickleSpeed: 160,
}); // NProgress Configuration
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/',
name: 'siteRoot',
component: () => import('@/views/site/index.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
},
},
{
path: '/login',
name: 'login',
component: () => import('@/views/login/index.vue'),
meta: {
requiresAuth: false,
loginPortal: 'customer',
noAffix: true,
hideInMenu: true,
},
},
{
path: '/admin',
name: 'adminLogin',
component: () => import('@/views/login/index.vue'),
meta: {
requiresAuth: false,
loginPortal: 'admin',
noAffix: true,
hideInMenu: true,
},
},
{
path: '/agent',
name: 'agentLogin',
component: () => import('@/views/login/index.vue'),
meta: {
requiresAuth: false,
loginPortal: 'agent',
noAffix: true,
hideInMenu: true,
},
},
// 门户:与客户同 DEFAULT_LAYOUT 壳;子路由用绝对 path,父级不占 /agent,以免抢走登录页
{
path: '/agent-portal',
name: 'AgentPortal',
component: () => import('@/layout/default-layout.vue'),
redirect: '/agent/workplace',
meta: {
requiresAuth: true,
hideInMenu: true,
agentPortalOnly: true,
},
children: [
{
path: '/agent/workplace',
name: 'AgentPortalWorkplace',
component: () => import('@/views/agent/workplace/index.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
agentPortalOnly: true,
},
},
{
path: '/agent/invite',
name: 'AgentPortalInvite',
component: () => import('@/views/agent/invite/index.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
agentPortalOnly: true,
},
},
{
path: '/agent/customers',
name: 'AgentPortalCustomers',
component: () => import('@/views/agent/customers/index.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
agentPortalOnly: true,
},
},
{
path: '/agent/orders',
name: 'AgentPortalOrders',
component: () => import('@/views/order/myOrders/index.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
agentPortalOnly: true,
},
},
{
path: '/agent/commission',
name: 'AgentPortalCommission',
component: () => import('@/views/agent/commission/index.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
agentPortalOnly: true,
},
},
{
path: '/agent/priceCheck',
name: 'AgentPortalPriceCheck',
component: () => import('@/views/order/priceCheck/index.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
agentPortalOnly: true,
},
},
{
path: '/agent/placeOrder',
name: 'AgentPortalPlaceOrder',
component: () => import('@/views/order/placeOrder/index.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
agentPortalOnly: true,
},
},
],
},
{
path: '/track/query',
name: 'H5TrackQuery',
component: () => import('@/views/h5/track-query/index.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
},
},
// 登录独立壳:不挂 customer-center layout,避免同步拉下单树导致首屏慢/闪乱
{
path: '/h5/login',
name: 'H5Login',
component: () => import('@/views/h5/customer-center/login/index.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
noAffix: true,
customerPortalOnly: true,
locale: 'h5.login.title',
},
},
// 管理端 H5:须注册在客户 /h5 之前,避免被客户中心 catch-all 吞掉
{
path: '/h5/admin/login',
name: 'H5AdminLogin',
component: () => import('@/views/h5/admin-center/login/index.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
noAffix: true,
adminPortalOnly: true,
locale: 'h5Admin.login.title',
},
},
{
path: '/h5/admin',
name: 'H5AdminCenter',
component: () => import('@/views/h5/admin-center/layout.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
adminPortalOnly: true,
},
children: [
{
path: '',
name: 'H5AdminCenterIndex',
redirect: () => {
const token =
localStorage.getItem('rbac_access_token') ||
localStorage.getItem('token');
return token ? '/h5/admin/workplace' : '/h5/admin/login';
},
},
{
path: 'workplace',
name: 'H5AdminWorkplace',
component: () => import('@/views/h5/admin-center/workplace/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.tab.workplace',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'eddie',
name: 'H5AdminEddie',
component: () => import('@/views/h5/admin-center/eddie/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.tab.eddie',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'monitor',
redirect: '/h5/admin/eddie',
},
{
path: 'orders',
name: 'H5AdminOrders',
component: () => import('@/views/h5/admin-center/orders/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.tab.orders',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'orders/:id',
name: 'H5AdminOrderDetail',
component: () => import('@/views/h5/admin-center/orders/detail.vue'),
meta: {
requiresAuth: true,
locale: 'h5.orders.detail.title',
h5HideTabBar: true,
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'me',
name: 'H5AdminMe',
component: () => import('@/views/h5/admin-center/me/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.tab.me',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'recharge',
name: 'H5AdminRecharge',
component: () => import('@/views/h5/admin-center/recharge/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.recharge.title',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'approval',
name: 'H5AdminApproval',
component: () => import('@/views/h5/admin-center/approval/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.approval.title',
h5HideHeader: true,
h5HideTabBar: true,
adminPortalOnly: true,
},
},
{
path: 'customers',
name: 'H5AdminCustomers',
component: () => import('@/views/h5/admin-center/customers/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.customers.title',
h5HideHeader: true,
h5HideTabBar: true,
adminPortalOnly: true,
},
},
{
path: 'ops/parcel-arrival',
name: 'H5AdminOpsParcelArrival',
component: () => import('@/views/h5/admin-center/ops/parcel-arrival.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.ops.parcelArrival',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'ops/inbound',
name: 'H5AdminOpsInbound',
component: () => import('@/views/h5/admin-center/ops/inbound.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.ops.inbound',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'ops/putaway',
name: 'H5AdminOpsPutaway',
component: () => import('@/views/h5/admin-center/ops/putaway.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.ops.putaway',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'ops/relocate',
name: 'H5AdminOpsRelocate',
component: () => import('@/views/h5/admin-center/ops/relocate.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.ops.relocate',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'ops/outbound',
name: 'H5AdminOpsOutbound',
component: () => import('@/views/h5/admin-center/ops/outbound.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.ops.outbound',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'ops/fulfill-pack',
name: 'H5AdminOpsFulfillPack',
component: () => import('@/views/h5/admin-center/ops/fulfill-pack.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.ops.fulfillPack',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'ops/bag-pack',
name: 'H5AdminOpsBagPack',
component: () => import('@/views/h5/admin-center/ops/bag-pack.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.ops.bagPack',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: 'ops/master-board',
name: 'H5AdminOpsMasterBoard',
component: () => import('@/views/h5/admin-center/ops/master-board.vue'),
meta: {
requiresAuth: true,
locale: 'h5Admin.ops.masterBoard',
h5HideHeader: true,
adminPortalOnly: true,
},
},
{
path: ':pathMatch(.*)*',
name: 'H5AdminCenterFallback',
redirect: () => {
const token =
localStorage.getItem('rbac_access_token') ||
localStorage.getItem('token');
return token ? '/h5/admin/workplace' : '/h5/admin/login';
},
},
],
},
{
path: '/h5',
name: 'H5CustomerCenter',
component: () => import('@/views/h5/customer-center/layout.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
customerPortalOnly: true,
},
children: [
{
path: '',
name: 'H5CustomerCenterIndex',
redirect: () => (isLogin() ? '/h5/orders' : '/h5/price'),
},
{
path: 'assistant',
name: 'H5Assistant',
component: () => import('@/views/h5/customer-center/assistant/index.vue'),
meta: {
requiresAuth: true,
h5GuestOk: true,
locale: 'h5.tab.assistant',
h5HideHeader: true,
},
},
{
path: 'price',
name: 'H5Price',
component: () => import('@/views/h5/customer-center/price/index.vue'),
meta: {
requiresAuth: true,
h5GuestOk: true,
locale: 'h5.tab.price',
h5HideHeader: true,
},
},
{
path: 'orders',
name: 'H5Orders',
component: () => import('@/views/h5/customer-center/orders/index.vue'),
meta: {
requiresAuth: true,
h5GuestOk: true,
locale: 'h5.tab.orders',
h5HideHeader: true,
},
},
{
path: 'orders/:id',
name: 'H5OrderDetail',
component: () => import('@/views/h5/customer-center/orders/detail.vue'),
meta: {
requiresAuth: true,
locale: 'h5.orders.detail.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
{
path: 'me',
name: 'H5Me',
component: () => import('@/views/h5/customer-center/me/index.vue'),
meta: {
requiresAuth: true,
h5GuestOk: true,
locale: 'h5.tab.me',
h5HideHeader: true,
},
},
{
path: 'storeOrders',
name: 'H5StoreOrders',
component: () => import('@/views/h5/customer-center/store-orders/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5.storeOrders.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
{
path: 'storeOrders/:id',
name: 'H5StoreOrderDetail',
component: () => import('@/views/h5/customer-center/store-orders/detail.vue'),
meta: {
requiresAuth: true,
locale: 'h5.storeOrders.detail.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
{
path: 'recharge',
name: 'H5Recharge',
component: () => import('@/views/h5/customer-center/recharge/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5.recharge.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
{
path: 'invoice',
name: 'H5Invoice',
component: () => import('@/views/h5/customer-center/invoice/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5.invoice.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
{
path: 'place-order',
name: 'H5PlaceOrder',
component: () => import('@/views/h5/customer-center/place-order/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5.placeOrder.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
{
path: 'coupons',
name: 'H5Coupons',
component: () => import('@/views/h5/customer-center/coupons/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5.coupons.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
{
path: 'invite',
name: 'H5Invite',
component: () => import('@/views/h5/customer-center/invite/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5.invite.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
{
path: 'commission',
name: 'H5Commission',
component: () => import('@/views/h5/customer-center/commission/index.vue'),
meta: {
requiresAuth: true,
locale: 'h5.commission.title',
h5HideTabBar: true,
h5HideHeader: true,
},
},
// 未知 /h5/* 回落客户中心,避免空白页
{
path: ':pathMatch(.*)*',
name: 'H5CustomerCenterFallback',
redirect: () => {
const token =
localStorage.getItem('rbac_access_token') ||
localStorage.getItem('token');
return token ? '/h5/orders' : '/h5/price';
},
},
],
},
{
path: '/wechat/register',
name: 'WechatRegister',
component: () => import('@/views/wechat/register/index.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
},
},
{
path: '/register',
name: 'CustomerRegister',
component: () => import('@/views/register/index.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
},
},
{
path: '/wechat/bind',
name: 'WechatBind',
component: () => import('@/views/wechat/bind/index.vue'),
meta: {
requiresAuth: false,
hideInMenu: true,
},
},
{
path: '/oauth/platform-store/:platform',
name: 'PlatformStoreOAuthCallback',
component: () => import('@/views/order/platformStore/oauthCallback.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
},
},
{
path: '/Plugin/AddPackage',
name: 'PluginAddPackage',
component: () => import('@/views/plugin/AddPackage.vue'),
meta: {
requiresAuth: true,
hideInMenu: true,
},
},
...appRoutes,
REDIRECT_MAIN,
NOT_FOUND_ROUTE,
],
// 多页签 keep-alive:禁止切页强制滚顶,避免主区「抖一下」
scrollBehavior(to) {
if (to.hash) return false;
return false;
},
});
createRouteGuard(router);
export default router;