| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- import type { App } from "vue";
- import { createRouter, createWebHashHistory, type RouteRecordRaw } from "vue-router";
- export const Layout = () => import("@/layouts/index.vue");
- /**
- * 静态路由
- */
- export const constantRoutes: RouteRecordRaw[] = [
- {
- path: "/redirect",
- meta: { hidden: true },
- component: Layout,
- children: [
- {
- path: "/redirect/:path(.*)",
- component: () => import("@/views/redirect/index.vue"),
- },
- ],
- },
- {
- path: "/login",
- name: "Login",
- meta: { hidden: true },
- component: () => import("@/views/module_system/auth/index.vue"),
- },
- {
- path: "/enterprise/select",
- name: "EnterpriseSelect",
- meta: { hidden: true, title: "选择企业" },
- component: () => import("@/views/enterprise/select.vue"),
- },
- {
- path: "/401",
- name: "401",
- meta: { hidden: true, title: "401" },
- component: () => import("@/views/error/401.vue"),
- },
- {
- // 顾客页(收款链接 `/#/checkout/<token>` 的落点)—— **免登录**,所以必须放在
- // `constantRoutes` 里:动态路由要先生成权限表,而打开链接的人没有登录态。
- //
- // ★ `name` 是**对外承诺**,不是本地标签:免登录放行判据读的就是它
- // (`plugins/permission.ts` 的 `PUBLIC_ROUTE_NAMES`)。改名要把两边一起改,
- // 否则顾客页会静默变回「跳登录页」—— 页面本身没有任何报错。
- // ★ 路径形状由后端决定:`LsyCheckoutLinkService#buildUrl` 拼的是
- // `<base>/#/checkout/<token>`(hash 路由,`createWebHashHistory`),
- // 所以这里带不带前导 `/` 都一样,但**必须**是 `checkout/:token` 两段。
- path: "/checkout/:token",
- name: "Checkout",
- meta: { hidden: true, title: "收款" },
- component: () => import("@/views/checkout/index.vue"),
- },
- {
- // 汇安融顾客页(收款链接 `/#/checkout/alipay/<token>` 的落点)—— 免登录,同上一段。
- // ★ 为什么是**三段**路径而乐收赢是两段:`HarCheckoutLinkService#buildUrl` 的
- // PATH_PREFIX 是 `/#/checkout/alipay/`,`alipay` 是路径里的**字面段**,不是参数。
- // 若按乐收赢写成 `checkout/:token`,`alipay` 会被当成 token ⇒ 顾客页拿着 "alipay"
- // 去查链接,一律「链接无效」。
- // (路径段 2026-10-09 由 `har` 改来 —— 这串出现在顾客眼前,不带上游品牌;
- // 与后端 PATH_PREFIX 必须**同名**改,改单边就是整页 404。)
- path: "/checkout/alipay/:token",
- name: "HarCheckout",
- meta: { hidden: true, title: "收款" },
- component: () => import("@/views/checkout/har/index.vue"),
- },
- {
- path: "/404",
- name: "404",
- meta: { hidden: true, title: "404" },
- component: () => import("@/views/error/404.vue"),
- },
- {
- path: "/500",
- name: "500",
- meta: { hidden: true, title: "500" },
- component: () => import("@/views/error/500.vue"),
- },
- {
- path: "/",
- name: "/",
- redirect: "/home",
- component: Layout,
- children: [
- {
- path: "home",
- component: () => import("@/views/dashboard/tenant.vue"),
- // 用于 keep-alive 功能,需要与 SFC 中自动推导或显式声明的组件名称一致
- // 参考文档: https://cn.vuejs.org/guide/built-ins/keep-alive.html#include-exclude
- name: "Home",
- meta: {
- title: "首页",
- icon: "homepage",
- affix: true,
- keepAlive: true,
- },
- },
- {
- path: "profile",
- name: "Profile",
- meta: { title: "个人中心", icon: "user", hidden: true },
- component: () => import("@/views/current/profile.vue"),
- },
- ],
- },
- // 通配 404 必须置于静态路由最后,否则会抢先匹配 /、/home 等
- {
- path: "/:pathMatch(.*)*",
- component: () => import("@/views/error/404.vue"),
- meta: { hidden: true, title: "404" },
- },
- ];
- /**
- * 创建路由
- */
- const router = createRouter({
- history: createWebHashHistory(),
- routes: constantRoutes,
- // 刷新时,滚动条位置还原
- scrollBehavior: () => ({ left: 0, top: 0 }),
- });
- // 全局注册 router
- // 为了捕获并处理全局错误,在注册路由时添加错误处理
- export function setupRouter(app: App<Element>) {
- app.use(router);
- }
- export default router;
|