Files
bid-doctor/apps/web/src/router.ts
YANG JIANKUAN dd8c04001d
Some checks failed
ci / server (push) Has been cancelled
ci / web (push) Has been cancelled
ci / contract (push) Has been cancelled
feat(m6): 额度流水、套餐开通、数据删除、运营后台(M6 剩下的 P0)
决策 M6-1–M6-10(docs/architecture/m6-plan.md、docs/decisions.md)。

用户端:
- 额度与套餐页:本期额度、按功能分布、扣点规则、流水(逐条余额、关联项目和任务、导出 CSV)
- 开通 / 续费申请(对公转账,运营确认到账后开通),80% / 100% 提醒
- 专业版到期:整个账号只读、额度清零,到期前 30 / 7 / 0 天提醒(worker 每小时 billing_tick)
- 删除项目(彻底删除、销毁数据密钥),注销账号(企业名称 + 短信验证码)
- 通知铃铛、账号页

运营后台:
- 独立进程 bid-doctor ops(/ops/v1)和 apps/admin;用户名 + 密码 + TOTP + IP 白名单
- 开通申请(到账 / 开通 / 退回 / 发票)、企业查询和调额度、误报 / 漏报、失败任务、审计;不看业务内容
- 左侧菜单(标准 logo、可展开收起的分组、图标、待办数、环境标签)
- 运营人员角色只留结构:ops_admin.role、权限点、每个接口的检查点、菜单按权限过滤

数据库:迁移 0010(排队的订阅、申请单号、通知类型、billing_due)、0011(bd_ops 权限)、0012(运营角色)。
另修:取消解析 / 检查接口报 500;uuid7 进程内单调;data_key 销毁后不再新建;审计 None 存 SQL NULL。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:06:06 +08:00

89 lines
3.2 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 { ApiError } from "@bid-doctor/api-client";
import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";
import AppShell from "@/components/AppShell.vue";
import { runtimeConfig } from "@/lib/config";
import { qk } from "@/lib/keys";
import { fetchMe } from "@/lib/queries";
import { queryClient } from "@/lib/queryClient";
declare module "vue-router" {
interface RouteMeta {
/** 不需要登录 */
public?: boolean;
}
}
export const router = createRouter({
// 路由基础路径可配置;桌面外壳用 hash 模式(架构 §5.2 第 6 条)
history: runtimeConfig.routerMode === "hash" ? createWebHashHistory() : createWebHistory(runtimeConfig.routerBase),
routes: [
{ path: "/login", name: "login", component: () => import("@/pages/LoginPage.vue"), meta: { public: true } },
{
path: "/",
component: AppShell,
children: [
{ path: "", name: "workbench", component: () => import("@/pages/WorkbenchPage.vue") },
{ path: "projects/new", name: "project-new", component: () => import("@/pages/ProjectNewPage.vue") },
{ path: "qualifications", name: "qualifications", component: () => import("@/pages/QualificationsPage.vue") },
{ path: "quota", name: "quota", component: () => import("@/pages/QuotaPage.vue") },
{ path: "account", name: "account", component: () => import("@/pages/AccountPage.vue") },
{
path: "projects/:projectId/parse/:jobId",
name: "parse",
component: () => import("@/pages/ParsePage.vue"),
props: true,
},
{
path: "projects/:projectId",
name: "overview",
component: () => import("@/pages/OverviewPage.vue"),
props: true,
},
{
path: "projects/:projectId/lots",
name: "lots",
component: () => import("@/pages/LotsPage.vue"),
props: true,
},
{
path: "projects/:projectId/checklist",
name: "checklist",
component: () => import("@/pages/ChecklistPage.vue"),
props: true,
},
{
path: "projects/:projectId/check",
name: "bid-check",
component: () => import("@/pages/BidCheckPage.vue"),
props: true,
},
{
path: "projects/:projectId/report",
name: "report",
component: () => import("@/pages/ReportPage.vue"),
props: true,
},
{
path: "projects/:projectId/results/:runId",
name: "results",
component: () => import("@/pages/ResultsPage.vue"),
props: true,
},
],
},
{ path: "/:pathMatch(.*)*", redirect: "/" },
],
});
router.beforeEach(async (to) => {
if (to.meta.public) return true;
try {
await queryClient.fetchQuery({ queryKey: qk.me, queryFn: fetchMe, staleTime: 60_000 });
return true;
} catch (e) {
// 被其他设备挤下线(session_revoked)、过期(session_expired)时,登录页说明原因
const reason = e instanceof ApiError && e.code !== "unauthenticated" ? { reason: e.code } : {};
return { name: "login", query: { ...(to.fullPath === "/" ? {} : { redirect: to.fullPath }), ...reason } };
}
});