Compare commits

...

831 Commits

Author SHA1 Message Date
huangzd1997 40224d8e56 fix(backend-java): 收口并发资源与恢复链路 2026-09-05 14:44:00 +08:00
huangzd1997 d760838e71 task-42(账号/权限页面): 实现用户列表查询适配
新增 users-model.ts 纯解析(Java AdminUserItemVo snake_case→camelCase、
缺 id 行过滤、分页字段归一、success=false 抛后端 message)与 users.ts
adapter(fetchUserList:normalize+GET /api/admin/users+parse);UsersPage
改用 adapter,去掉模板内联 http.get+unwrap。task-41 依赖断言改指数据层。
8 用例全过,299 单测 + build 绿。
2026-09-05 14:43:59 +08:00
huangzd1997 60fa5a818b task-41(账号/权限页面): 定义用户列表与分页 DTO
新增纯模块 users-dto.ts:UserListParams/UserPageResult/UserListQuery 契约与
Java AdminUserController 对齐(page/page_size/username/items/total);
normalizeUserPageParams 页码下限1、页大小夹取、空关键字去抖;toUserListQuery
按 snake_case 序列化;UsersPage 改用 AdminUser/UserPageResult 类型。8 用例全过。
2026-09-05 14:43:59 +08:00
huangzd1997 837fc9bcc0 task-40(会话/菜单/权限): 真实登录态 smoke 收口本模块
用真实 admin 凭据打本地后端完成登录/cookie 会话/current-user/菜单树/401/
权限路由 smoke(8 场景全过)。smoke 暴露前端登出 URL 错误:session.ts 走
/api/admin/logout(后端无此映射,500),改为 auth 模块根端点 POST /logout;
同步修正 task-25/36 断言。注:当前本地后端 POST /logout 亦返回 500,属
Java 侧缺陷,待后端模块修复后补登出 E2E。
2026-09-05 14:43:59 +08:00
huangzd1997 aad11c71bb task-39(会话/菜单/权限): 2026-09-05 14:43:59 +08:00
huangzd1997 4fd4d68460 task-38(会话/菜单/权限): 2026-09-05 14:43:59 +08:00
huangzd1997 836ea6ecc7 task-37(会话/菜单/权限): 2026-09-05 14:43:59 +08:00
huangzd1997 18a48e80b4 task-36(会话/菜单/权限): 2026-09-05 14:43:58 +08:00
huangzd1997 5b94eb1af6 task-35(会话/菜单/权限): 2026-09-05 14:43:58 +08:00
huangzd1997 0524489ac2 task-34(会话/菜单/权限): 2026-09-05 14:43:58 +08:00
huangzd1997 37d021500a task-33(会话/菜单/权限): 路由菜单权限守卫统一准入判定
新增纯函数 isRouteAllowed(无 menuKey 开放页放行/super_admin 全放行/其余按
key 命中);beforeEach 越权回退首个可见页、全无则回根路由空态。8 用例全过。
2026-09-05 14:43:58 +08:00
huangzd1997 a7b184fbd7 task-32(会话/菜单/权限): 普通用户菜单 key 查找下沉为共享纯函数
hasMenuKey 深度优先查找(空 key/空树返回 false,不改输入)抽到 helpers 供
守卫复用,去掉路由内私有 hasMenu 副本。8 用例全过。
2026-09-05 14:43:58 +08:00
huangzd1997 1a0159b7fc task-31(会话/菜单/权限): 超级管理员菜单判定走角色归一
store.isSuperAdmin getter 改用 isSuperAdminRole(role) 归一判定,替代裸等值
比较;大小写/空白差异的角色串也能正确放行全部菜单。8 用例全过。
2026-09-05 14:43:57 +08:00
huangzd1997 877a690635 task-30(会话/菜单/权限): 锁定初始化失败与重试状态契约
失败写 error 并重抛、finally 复位 loading;initialized 保持 false 可重试,
loading/initialized 双闸防并发重复触发;守卫捕获异常不白屏。8 用例全过。
2026-09-05 14:43:57 +08:00
huangzd1997 2957c575e6 task-29(会话/菜单/权限): 锁定菜单树初始化动作契约
store 用户就绪后拉取菜单树写入 menuTree 并置 initialized=true;空树与接口
失败区分,附加字段(sort/icon)不丢失。8 用例全过。
2026-09-05 14:43:57 +08:00
huangzd1997 115df85063 task-28(会话/菜单/权限): 锁定当前用户初始化动作契约
store.initialize 先拉当前用户再拉菜单;用户写入 store.user、成功/失败路径
及守卫短路均被契约锁定;解析器缺 id/接口失败抛可操作错误。8 用例全过。
2026-09-05 14:43:57 +08:00
huangzd1997 8b07321fbb task-27(会话/菜单/权限): 锁定 Pinia admin-session store 初始状态契约
state 工厂返回全新对象含 user/menuTree/initialized/loading/error 五字段,
默认 null/[]/false/''/'',无凭证字段;仅一个 defineStore,守卫与 getter
依赖该初始态。8 用例全过。
2026-09-05 14:43:57 +08:00
huangzd1997 2d0d836d9a task-26(会话/菜单/权限): 实现 401 登录跳转行为防循环守卫
401 统一跳 /login 并携带目标路径;新增纯函数守卫 isLoginLocation/
isAuthEndpointRequest/shouldRedirectUnauthorized:已处登录页或失败请求即
登录端点时不再二次跳转,避免登录页死循环与吞掉登录失败反馈。http 层
success/error 两支均带失败请求 URL 过守卫后再跳转。envelope/http 单测
8 用例 + 全量 179 单测 + vue-tsc/vite build 通过。
2026-09-05 14:43:57 +08:00
huangzd1997 7c8374424d task-25(会话/菜单/权限): 锁定 Cookie/Session 请求配置契约
Cookie 规则回归契约:withCredentials 字面量开启、同源根路径、有界超时、
前端不写 localStorage/sessionStorage/document.cookie 持久化凭证、不注入
Authorization/Bearer;current-user/menus/logout 三类会话调用统一复用共享
http 实例;登出走 X-Requested-With AJAX 标识;401 统一拦截并携带目标路径。
8 用例全过,171 单测 + vue-tsc/vite build 通过。
2026-09-05 14:43:56 +08:00
huangzd1997 46622d9f42 task-24(会话/菜单/权限): 实现菜单树请求适配并锁定契约
parseMenuTree 兼容 data:{items}/{items}/数组信封,空树返回 [](与接口失败抛错
区分),success=false 抛后端 message;session.ts fetchAdminMenuTree 已复用;
单测 8 用例覆盖分组/单页/空/缺 route/异常,live 024 用真实菜单树验证。
2026-09-05 14:43:56 +08:00
huangzd1997 d3154a48b8 task-23(会话/菜单/权限): 实现当前用户请求适配 + 真后端 live 测试
session-model.parseCurrentUser 兼容 data:{item}/{item}/直接对象信封并校验 id;
session.ts fetchCurrentUser 复用;启用 allowImportingTsExtensions;npm run test:live
用 admin 账号真实登录打 18080 验证 current-user 与菜单树(023/024 live 全绿)。
2026-09-05 14:43:56 +08:00
huangzd1997 7ae595c91a task-22(会话/菜单/权限): 定义 API 解包与错误归一化规则
envelope.ts 纯实现 unwrap(带 data 解包/success=false 抛错)、errorTextOf、
isUnauthorized(兼容 code/status/statusCode)、requestErrorMessage、loginRedirectTarget;
http.ts 复用 envelope 并对 HTTP200+code401 统一跳 /login?redirect=。
2026-09-05 14:43:56 +08:00
huangzd1997 9f73af5911 task-21(会话/菜单/权限): 定义 AdminUser/AdminMenuNode 类型契约并对齐后端字段
admin.ts 增加 AdminRole 域与 roleKind/isSuperAdminRole/isAdminRole/roleLabel/
isSuperUser,AdminUser 补齐 isAdmin/creatorUsername/createdAt 等真实字段;
契约覆盖“分组可无 route、页面必有 route”。
2026-09-05 14:43:55 +08:00
huangzd1997 1cfdcb5fb3 task-20(壳层/路由): 完成壳层真实浏览器 smoke 验收
e2e 8 用例端到端收口:登录态壳层渲染、折叠切换、刷新幂等、404、退出确认取消
不退出、确认后跳 /login、全程无未捕获错误与遗留弹层。
2026-09-05 14:43:55 +08:00
huangzd1997 bd4b2a579e task-19(壳层/路由): 验证首批页面从壳层正确挂载
e2e 8 用例:users/menus/groups 三页面经壳层挂载、根路由跳首个可见页、菜单激活态、
面包屑(分组->页面) 与 404 兜底的真实浏览器断言。
2026-09-05 14:43:55 +08:00
huangzd1997 ba12e04d1e task-18(壳层/路由): 实现壳层键盘焦点与可访问性语义
AdminLayout 增加 role=navigation 侧边栏地标、aria-expanded/aria-label 折叠按钮、
#admin-content 主区锚点与“跳到主内容”skip-link;main.css 提供 :focus-visible 焦点环
与 skip-link 聚焦样式;e2e 8 用例用键盘回车切换折叠并断言 ARIA 语义。
2026-09-05 14:43:55 +08:00
huangzd1997 7ffae78919 task-17(壳层/路由): 桌面端壳层响应式验收 + 浏览器验收基建
引入 @playwright/test(mdEdge 通道),playwright.config 起 mock admin API + vite dev;
e2e 覆盖宽/窄屏自动折叠、折叠持久化、无横向溢出等 8 用例;workspace 边界扫描
排除测试专用 e2e/scripts/playwright.config。
2026-09-05 14:43:54 +08:00
huangzd1997 d397c88c3c task-16(壳层/路由): 实现退出登录入口的壳层交互(确认式)
logout.ts 定义 runLogout 纯流程(确认通过才 signOut,异常上抛由壳层反馈);
AdminLayout 用 ElMessageBox.confirm 确认后再执行 store.signOut($reset + /login)。
2026-09-05 14:43:54 +08:00
huangzd1997 83b935c11b task-15(壳层/路由): 实现页面标题与面包屑规则
title-breadcrumb 提供 resolveDocumentTitle('页面 - 数富AI')、updateDocumentTitle
(非浏览器静默)、crumbsForActiveRoute(分组->页面);AdminLayout 用 watch 同步
document.title 并在层级>1 时渲染 el-breadcrumb。
2026-09-05 14:43:54 +08:00
huangzd1997 13e7a4c602 task-14(壳层/路由): 实现侧边栏折叠与窄屏行为及偏好持久化
sidebar-collapse 提供阈值/宽高常量、toggle、localStorage 偏好读写(失败容忍)、
initialCollapsed(持久化优先,窄屏自动收起);AdminLayout 接入并持久化折叠状态。
2026-09-05 14:43:54 +08:00
huangzd1997 c3f160afa5 task-13(壳层/路由): 实现全局请求错误提示容器
error-bus 提供框架无关的订阅式错误总线:notify/dismiss/clear、负载归一化、
3 条上限截断、订阅返回取消函数防泄漏;GlobalErrorContainer 订阅并渲染可关闭
错误条,挂在 AdminLayout 内容区顶部。
2026-09-05 14:43:54 +08:00
huangzd1997 f4f7268045 task-12(壳层/路由): 实现路由级错误页面(404 兜底)
新增 src/pages/error/NotFoundPage.vue(el-result + 返回首页),router 在业务路由
之后注册 :pathMatch(.*)* 兜底(无 menuKey,不参与权限门禁),保留壳层 chrome;
main.css 增加 .not-found 布局。
2026-09-05 14:43:53 +08:00
huangzd1997 50e70c43ab task-11(壳层/路由): 实现无菜单权限空状态
empty-state 定义标题/引导文案与 shouldShowEmptyMenu 纯判定(Boolean 化防 undefined);
AdminLayout 侧边栏与内容区(根路由)共用空态,加载中不闪现,未初始化不误报。
2026-09-05 14:43:53 +08:00
huangzd1997 f1fa5f7adf task-10(壳层/路由): 实现页面级异步组件加载边界
lazy-config 暴露 loading 延迟/超时/文案与懒加载判定;lazy-page 用
defineAsyncComponent 提供 loading/error 组件,router 对所有注册路由统一包裹;
main.css 增加 .page-loading/.page-error 兜底样式。
2026-09-05 14:43:53 +08:00
huangzd1997 ab7255a55b task-9(壳层/路由): 实现路由 meta 菜单 key 约定与 RouteMeta 类型增强
新增 src/types/vue-router.d.ts 模块增强(RouteMeta.title/menuKey),meta.ts 提供
metaMenuKey/命名校验,router 守卫改类型化访问去掉 as cast,AdminLayout 标题同步
去 cast;校验首批注册表 menuKey 合规。
2026-09-05 14:43:53 +08:00
huangzd1997 02e0dc20b8 task-8(壳层/路由): 实现业务域路由注册表
新增 src/router/routes.ts:adminPages 登记业务域页面(account 首批),routeOf 生成
路由记录,validateAdminPages 校验路径唯一/相对/含 title/load;router/index.ts 改
消费 adminRouteRecords,移除内联懒加载与路径字面量。
2026-09-05 14:43:53 +08:00
huangzd1997 8e828c1204 task-7(壳层/路由): 根路由跳转到首个可见页面,移除硬编码默认页
helpers.firstVisiblePath 深度优先返回首个可路由页面,无页面返回空串;
store 增加 firstVisible;守卫在根路由/无权限时跳首个可见页,全部无页面则
停留根路由展示无菜单空态,删除 redirect:'/account/users' 硬编码。
2026-09-05 14:43:53 +08:00
huangzd1997 26edb9e6ed task-6(壳层/路由): 定义后端菜单树到侧边栏节点映射规则并落地
新增 src/layout/menu-mapper.ts:toSidebarEntries 处理分组/顶级路由叶/畸形节点,
groupKeysForActive 按当前路由展开激活分组;AdminLayout 菜单区改用映射结果,
删除旧 visibleChildren/canSee 死逻辑;8 用例覆盖空树/单叶/缺 route 过滤等。
2026-09-05 14:43:52 +08:00
huangzd1997 4a0e464308 task-5(壳层/路由): 定义顶部栏用户信息与页面标题模型
新增 src/layout/topbar-model.ts(pageTitleOf 缺省回落 + topbarUserOf 空态视图模型),
AdminLayout 改用模型渲染标题/用户名/角色,删除模板内联缺省逻辑;8 用例覆盖标题
空值、用户缺字段、非法输入等。
2026-09-05 14:43:52 +08:00
huangzd1997 af68b20f87 task-4(壳层/路由): 定义深色侧边栏与浅色内容区设计 token 并锁定不变量
新增 src/styles/theme.ts 语义 token 单源 + 相对亮度/对比度/isDarkSurface,
tests 校验侧边栏暗、内容区亮、正文 WCAG AA、与 main.css 变量交叉一致防漂移。
2026-09-05 14:43:52 +08:00
huangzd1997 7065dbb53e task-3(壳层/路由): 定义并锁定 AdminLayout 页面容器职责契约
壳层只做页面容器:唯一 RouterView 挂载业务视图、不静态 import 业务页面、
不直接调后台 API、Element Plus 按需命名导入;页面接线归 router 懒加载。
配套 tests/helpers.ts 提供只读源码分析与 @/ import 可解析校验。
2026-09-05 14:43:52 +08:00
huangzd1997 6f0357e41c task-2(壳层/路由): 冻结 /admin-vue/ base 与 History 路由契约为单一事实源
新增 src/config/app.ts(APP_BASE_PATH/ensureAppBasePath/joinAdminPath),
vite.config base、router createWebHistory、AdminLayout logo 路径统一消费常量,
禁止散落字面量;8 用例覆盖归一化/幂等/空段/单段/非法输入与字面量单源。
2026-09-05 14:43:52 +08:00
huangzd1997 ec7d56d566 task-1(壳层/路由): 冻结独立后台工程工作区边界契约与基线测试
admin-frontend-vue/src/config/workspace.ts 提供可编程边界校验(独立包名、
必需清单/源码目录、客户端耦合 token 扫描、可操作缺失消息),供后续壳层
任务与验收脚本复用;tests/task-1.test.ts 以 8 用例锁定依赖/构建/测试/边界。
2026-09-05 14:43:51 +08:00
huangzd1997 445c139bce guard(task-210/212): ArchitectureBoundaryTest 债务基线下调 128→84(Handler 迁移后 task→业务依赖实降至 84)并随迁记录 SPI 化遗留 2026-09-05 10:26:50 +08:00
huangzd1997 1924e273e9 refactor(task-212): 清理 TaskResultFileJobWorker 5 个迁移后遗留的死业务 import(Handler 已接管处理,字段已移除) 2026-09-05 10:15:57 +08:00
huangzd1997 be332a47ab fix(task-212): Handler 迁入业务模块后补 task.service 类型 import(随迁移内容一并落库) 2026-09-05 10:12:01 +08:00
huangzd1997 01e8c608e7 task-212(部分): 04 Handler SPI 实现迁回各业务模块(依赖反转大头)——13 个 *ResultFileJobHandler 从 modules/task/service 迁到各自模块 service
- TaskFileJobConfig 与相关测试 import 同步到新模块包;MappingSnapshot 源码路径按模块映射
- task 模块对业务 import 由 16+ 文件降到 3(TaskHeartbeatService/TaskResultFileJobWorker/ModuleHistoryCleanupService 尚需心跳/worker/清理 SPI 化)
- 全量回归 2308 测试 0 失败
2026-09-05 10:11:53 +08:00
huangzd1997 d4b4e1e165 task-219(env-gated 全链路): similarasin 最小链路 done=true→assemble→上传结果文件回放测试(种子含 items+groups→按同名 group 回填→轮询至 SUCCESS→result_file_url 非空 .xlsx)+ 本地真跑通过
本地 MinIO 已建桶;关键点:解析载荷须含 groups 且 python 按同名 group 回填。CI 实跑依赖 Gitea runner(远程),本地以 mvn/node 等价命令 + env-gated 全绿覆盖
2026-09-05 09:50:53 +08:00
huangzd1997 fe3b8624bf chore(similarasin): LlmGatewayTlsProbe 探针模型字面量同步为 glm-5.3-flash 2026-09-05 09:48:27 +08:00
huangzd1997 3ee281a433 fix(similarasin): LLM 默认模型改为 glm-5.3-flash(原 gemini-3.5-flash-lite/gemini-3.7-flash 在 ai.t8star 端点不可用,按指示统一) 2026-09-05 09:48:19 +08:00
huangzd1997 736760aa31 fix(perf test): 移除墙钟 light<batch 断言(纯内存 mock 下 0ms 抖动偶发红;类注释本就声明不做毫秒比较、用确定性查询次数口径) 2026-09-05 09:31:13 +08:00
huangzd1997 8cbc86f6fa task-214: progress/batch 轻量响应契约回放(env-gated,真实服务:造 SIMILAR_ASIN RUNNING → batch items/missingTaskIds + task 轻量字段(id/taskNo/status) + 文件 items;light items/missingTaskIds)+ 已本地真跑 2026-09-05 09:25:54 +08:00
huangzd1997 6bd3e76048 task-218(离线可收部分): 结果文件格式契约(真实 AppearancePatentSheetBuilder 纯调用:Sheet 名/主表列序(含标题/图片链接/sku)/原因表列/空行产出)+ 8 测试
文件名 <stem>-result.xlsx 与 ZIP 结构由运行时组装/上传环节生成,依赖真实流水线(3+2 约定 env-gated 另行验证)
2026-09-05 09:23:21 +08:00
huangzd1997 4735a18390 fix(frontend tests): 同步 API_ENDPOINTS 冻结快照到当前常量(存量过期致 node --test 全量红,非本轮引入)——使前端 node --test 全绿 2026-09-05 09:19:21 +08:00
huangzd1997 c282327a0b task-207(服务层): done=true 终态决策纯语义(SimilarAsinSubmitResultSemantics:done/error→终态回调、chunkIndex/Total 缺省归一)接线回 submit + 8 单测
按 3+2 约定:文件生成/终态落库依赖真实 LLM 流水线,留待真实运行时经 env-gated 回放(CONTRACT_* 已就绪)
2026-09-05 09:10:51 +08:00
huangzd1997 dacdab7adb task-206: heartbeat 旧字段契约回放(env-gated,真实服务:RUNNING→alive:true、非运行→alive:false、未知任务 alive:false+message、旧/多余字段容忍)+ 已本地真跑 2026-09-05 09:01:55 +08:00
huangzd1997 f0f9ba29f0 task-205: parsed-payload 契约回放(env-gated,真实服务:造 SIMILAR_ASIN 任务+内联载荷 → success/顶层字段 items/allItems/groups/headers/脱敏 apiKey/行数据;未知任务 success:false)+ 已本地真跑 2026-09-05 09:00:50 +08:00
huangzd1997 0b83c9a3c1 task-204: /items 分页语义契约回放(env-gated,真实服务:造 COLLECT_DATA 任务+5 行 item → page/pageSize/count/total/totalPages/items、越界空页、缺省 50、rowIndex 升序)+ 已本地真跑 2026-09-05 08:59:52 +08:00
huangzd1997 db0c1c1fdc task-203: /result 幂等契约回放测试(env-gated,真实服务:造 SIMILAR_ASIN RUNNING 任务+内联解析载荷 → parsed-payload 成功 → 同 submissionId/chunk 提交两次均 success:true 且 biz_task_chunk 只落 1 行)
- CI 默认跳过(需 CONTRACT_BASE_URL+CONTRACT_DB_*),设了即在本地/任意副本库跑
- 覆盖 success/idempotent/single-persist(chunk)/chunk 字段/未知任务(live 已验);done=true 封口需真实 LLM 流水线,不在本回放内(见限制说明)
- 本地已用 18080 实例 + schema 副本真跑通过
2026-09-05 08:56:41 +08:00
huangzd1997 92bd114e71 fix(module_type): 对齐 module_type 规范大写并加防回归守卫(防 similarasin/SIMILAR_ASIN 之类漂移)
- heartbeat 夹具 moduleType 改规范大写 SIMILAR_ASIN 并加断言锁定
- ModuleTypeAlignmentTest:扫描 src/main——MODULE_TYPE 常量须大写下划线、setModuleType("小写") 禁止(仅允许 legacy collectdata)——守卫写入/常量/夹具三者一致
- 全量扫描结果:生产代码写入均用常量大写,无存量漂移
2026-09-05 08:54:06 +08:00
huangzd1997 e69d82e7b1 fix(task-173 test): 超时根因断言兼容 HttpTimeoutException/TimeoutException 两种 JDK 行为(全量回归暴露的偶发类型) 2026-09-05 02:10:17 +08:00
huangzd1997 5c0f535aca task-202: Python-contract 夹具准备(heartbeat/items/result/parsed_payload schema-fixture,字段取自真实 DTO、全脱敏、README 说明)+ 9 条测试 2026-09-05 02:10:16 +08:00
huangzd1997 d3b499b596 feat(admin): 店铺重复检查导出「站点」列改「国家」中文显示;撞款抽屉按点击处定位
- 导出 CSV 列头 站点→国家,值映射中文(DE德国/UK英国/FR法国/IT意大利/ES西班牙,未知回退原值)
- 撞款详情抽屉以触发元素为垂直锚点并钳制在视口内,不再贴区块/页面顶部导致看不见需上滑
- 同步 Java 静态托管副本;更新 Java/Python 相关断言
2026-09-05 01:53:12 +08:00
huangzd1997 d6086ec7b0 收尾冒烟: 离线 Spring 装配切片(ConfigWiringSmokeTest)——模块10/11 新增 @ConfigurationProperties/@Component/可选 MeterRegistry 在真实容器装配验证 + 8 条测试
为上线前排除 bean 装配/属性绑定类启动崩溃;全量真实启动需在非生产环境(本配置默认值会连生产 MySQL/Redis)执行
2026-09-05 00:34:45 +08:00
huangzd1997 9d172ac170 task-209: 字段兼容 schema 覆盖冻结(node --test 扫描共享层:user_id/task_ids 请求、taskId/resultId/fileKey/status/taskStatus/fileStatus 响应均在 schema 覆盖)+ 8 条测试 2026-09-05 00:26:09 +08:00
huangzd1997 2304e634ee task-217: 快照对比工具(ResponseSnapshotTool:规范 JSON/录制/对比/落盘 golden/可读 diff 报告)+ 8 条测试 2026-09-05 00:25:40 +08:00
huangzd1997 68b743f18b task-216: CI 接入测试阶段(.gitea/workflows/build.yml 追加 mvn test 契约+ArchUnit 阶段先于打包、新增 frontend-test job 跑 vue-tsc+npm test,失败即红/超时/双容器)+ 8 条测试 2026-09-05 00:23:56 +08:00
huangzd1997 63b7cd82a6 task-215: 下载 URL 格式契约(前端 node --test:绝对直链保留/origin 补齐/schema 完整/&拼接 user_id/仅带 user_id 无签名)+ 9 条测试 2026-09-05 00:22:48 +08:00
huangzd1997 c1922d9e26 task-213: 前端共享层导出白名单(node --test 源码扫描:页面不直连 http.ts/axios/不拼 /newApi URL,shared 内部与 bridge 放行,违规 helper 可检出)+ 8 条测试 2026-09-05 00:22:06 +08:00
huangzd1997 541e397ca6 task-208: JavaApiResponse 包装契约(前端 node --test:success/message/data 解包、失败抛 message、null data、多余字段容忍、LegacyApiSuccess(msg) 兼容、extractErrorMessage 各字段回退)+ 8 条测试 2026-09-05 00:21:27 +08:00
huangzd1997 f5d4410063 task-211: ArchUnit Controller 边界规则(不直接访问 Mapper/外部 Client,零违规)+ task→业务 依赖防恶化基线
- archunit-junit5(test) 依赖引入一次到位
- Controller 不访问 ..mapper.. / ..client.. 两条规则全绿(探针确认存量零违规)
- task 模块经 *ResultFileJobHandler 等依赖业务 128 处(存量)→ 冻结上限防增长;module 切片存在 collectdata→dedupe→task 环,清零需 Handler 迁移等重构,另行处理
2026-09-05 00:18:16 +08:00
huangzd1997 5c63604b5b task-201: 迁移演练 runbook(docs/flyway-migration-drill.md:clean migrate/validate/验证SQL/回滚/锁窗口/校验和/幂等重跑/不动历史)+ 8 条测试
on-DB 的 migrate 执行需在副本库按 runbook 进行(本环境无数据库,仓库内以静态检查+清单兜底)
2026-09-05 00:09:37 +08:00
huangzd1997 1b27a3f1ca task-200: 巡检报表任务落地(InspectionSqlReportTask 跑 6 张只读报表 SQL:默认 disabled、分布式锁、单条失败不阻断、只 query)+ 8 条测试 2026-09-05 00:08:44 +08:00
huangzd1997 d6b223ba25 task-199: 超保留期活跃 job 巡检 SQL(06_over_retention_active_job.sql,RUNNING 超24h 候选,清理走 stuck 扫描)+ 8 条测试 2026-09-05 00:06:45 +08:00
huangzd1997 b6cf693e05 task-198: 终态任务活跃 job 巡检 SQL(05_terminal_task_active_job.sql)+ 8 条测试 2026-09-05 00:06:45 +08:00
huangzd1997 187c123071 task-197: 结果缺文件候选巡检 SQL(04_result_missing_file.sql,OSS 对象存在由 Java 反查)+ 8 条测试 2026-09-05 00:06:45 +08:00
huangzd1997 402c3e2cb3 task-196: 终态任务缺结果巡检 SQL(03_task_missing_result.sql,SUCCESS/FAILED 无结果)+ 8 条测试 2026-09-05 00:06:44 +08:00
huangzd1997 7f7090f433 task-195: 孤儿结果(payload) 巡检 SQL(02_orphan_result.sql,biz_file_result 无父任务)+ 8 条测试 2026-09-05 00:06:44 +08:00
huangzd1997 bcd5879a08 task-194: 孤儿 task_file_job 巡检 SQL(01_orphan_job.sql,只读 SELECT 反连无任务/结果;base 提供 8 项静态契约)+ 8 条测试 2026-09-05 00:06:44 +08:00
huangzd1997 5688870788 task-193: 历史迁移盘点(docs/migration-inventory.md + 只读审计:整数版本 1..108 连续、无重复、识别 V25_1 历史小版本、命名合规、校验和可复算)+ 8 条测试 2026-09-05 00:02:57 +08:00
huangzd1997 36463f2119 task-192: 迁移规范模板(docs/flyway-migration-template.md,六项必填头注释:目的/影响表数据量/锁表风险/验证SQL/回滚/窗口)+ 8 条测试 2026-09-05 00:01:24 +08:00
huangzd1997 75d553f99a task-191: 双实例指标区分回归契约(instanceId 分桶不串、未配置归 unknown、跨实例可聚合、名集合一致)+ 8 条测试 2026-09-04 23:53:24 +08:00
huangzd1997 b468750d00 task-190: 日志脱敏契约(StructuredLog.maskToken 统一 Token 部分脱敏,ImageVideo maskForLog 委托;URL query/异常消息体不入日志、防注入)+ 8 条测试 2026-09-04 23:53:23 +08:00
huangzd1997 4179e0de23 task-189: 指标命名一致性契约(aiimage.* 前缀、全小写点分、全量名快照对齐 spec11 §1、无拼写漂移)+ 8 条测试 2026-09-04 23:53:22 +08:00
huangzd1997 7967f454ec task-188: 指标标签规范契约(moduleType/instanceId 必带、null 归一 unknown、无用户级标签、磁盘按 path、标签名冻结)+ 8 条测试 2026-09-04 23:53:20 +08:00
huangzd1997 7b73a2cf6e task-187: 临时磁盘容量/占用指标契约(tmpdisk.capacity/used gauge,path 标签,可算占用比对接 09 告警)+ 8 条测试 2026-09-04 23:48:21 +08:00
huangzd1997 03f5b827e2 task-186: 上传耗时/大小/成功率指标契约(upload.duration/size/result)+ 8 条测试 2026-09-04 23:48:21 +08:00
huangzd1997 e365fc84f8 task-185: file-job.* 指标契约(pending/running/success/failed/retry/duration,分模块/实例)+ 8 条测试 2026-09-04 23:48:21 +08:00
huangzd1997 17cfd6902b task-184: task.heartbeat.age 心跳年龄 gauge 契约(新鲜/陈旧/负时钟保护/未写无 meter)+ 8 条测试 2026-09-04 23:48:21 +08:00
huangzd1997 0ec4fb3534 task-183: task.duration 耗时指标契约(Timer,非负、分模块、名称冻结)+ 8 条测试 2026-09-04 23:48:20 +08:00
huangzd1997 0863614e66 task-182: task.success/failed/cancelled 终态计数指标契约(aiimage.task.*,分 moduleType/instanceId)+ 8 条测试 2026-09-04 23:48:20 +08:00
huangzd1997 a2c60d319f task-181: task.created/running 指标埋点(TaskObservabilityMetrics recorder:created 计数 + running gauge + moduleType/instanceId 标签,名称冻结)+ 8 条测试
- 标准指标名 aiimage.task.created/running(spec11 §1);moduleType/instanceId null 归 unknown;running 不为负
- Micrometer 可选:无注册表降级 debug 日志不抛错;recorder 为唯一接线面,各业务状态流转按 spec 待监控栈就绪后挂载
- 仅新增类与测试,不接调用点,零生产行为变化
2026-09-04 23:46:49 +08:00
huangzd1997 39fb23bd16 task-180: Worker 日志字段对齐规范(TaskResultFileJobWorker 关键阶段补 stage=/errorType=,保留 [task-file-job] 前缀)+ 8 条测试
- dispatch/success/failure/orphan/heartbeat/requeue/defer/waittxllm/finalize 日志追加规范 stage 字面量
- 失败/孤儿分支追加 errorType={}(exception 类名);保留 jobId/taskId/moduleType 与既有语义,仅消息文本追加、无逻辑改动
- 审计测试锁定字段名一致、阶段字面量白名单、无敏感字段
2026-09-04 23:44:39 +08:00
huangzd1997 5fa59680f2 task-179: 禁止记录清单审计(语句级扫描 src/main log.*,Token/Cookie/完整body/二进制/凭据/APIKey 白名单校验)+ 8 条测试
- 多行感知扫描:body={}/authorization/Bearer/token 语句必须过 maskChatBody/maskSecretsForLog/maskForLog/toJsonForLog/abbreviate 等脱敏,否则判违规
- Cookie/凭据/API Key/二进制类字段一律不允许出现;LLM 脱敏后的 body 诊断保留(allowed_fields_kept)
- 审计结果:现网 LLM 客户端日志均已脱敏,零裸漏,无需修正;纯扫描可重复
2026-09-04 23:40:38 +08:00
huangzd1997 620ee15a48 task-178: 日志字段规范落地(StructuredLog 规范字段集+缺失占位+值消毒,字段名冻结)+ 8 条测试
- 规范字段 traceId/taskId/moduleType/stage/submissionId/chunkIndex/chunkTotal/jobId/result/errorType,顺序与 spec11 §2 一致
- format 只输出规范字段、缺失用 "-" 占位、换行/控制字符消毒、超长截断,防日志注入与字段漂移
- 源码锚点断言 Worker(task-file-job)/心跳(task-heartbeat) 代表性日志已带 taskId/moduleType 核心字段;不删现有日志
2026-09-04 23:37:50 +08:00
huangzd1997 05da03c5ba task-176: 重试计数与日志字段(IdempotentRetryGuard 观测扩展:WARN 日志字段 + aiimage.http.retry 指标)+ 8 条测试
- 重试/最终失败打 WARN:client/url(去 query)/method/retry/耗时/延迟/原因类名,不打印含敏感信息的异常消息体
- 重试记 aiimage.http.retry 指标(method/client 标签),Micrometer 注册表可选,无注册表静默跳过
- 保留 task-172 原 API(构造器/execute 兼容),原 8 条测试不受影响;守卫仍不接调用点
2026-09-04 23:29:13 +08:00
huangzd1997 02cff8ea63 task-175: Python 回调/代理超时与重试契约冻结(只读确认,Python 零改动)+ 8 条断言
- 锁定 Python→Java HTTP 面(admin_api._get_backend_java_session/_proxy_backend_java):默认 timeout=10、HTTPAdapter(max_retries=0)、超时/失败转 502
- 断言 Java aiimage.http-client.* 治理不外溢到 Python(非测试 Python 无引用、代理签名超时为字面量)
- 纯测试,不改任何生产 Python 代码
2026-09-04 23:25:59 +08:00
huangzd1997 2a2d23e0dc task-174: 连接复用测试(HttpClientConnectionReuseTest2,本机计数 TCP 服务观测真实复用)+ 8 条测试
- 自建最小 HTTP/1.1 keep-alive 计数服务:连续顺序请求复用同一连接、多客户端工厂共享连接池、短暂空闲后复用、顺序突发不新建
- 不同 host 各自建连、非共享池客户端不复用(暴露不复用场景)、并发平息后顺序追加复用既有连接
- 记录平台边界:JDK HTTP/1.1 无多路复用,并发在途各自建连;复用体现在顺序/间歇复用空闲连接
- 纯测试,零生产代码改动,全本地确定性
2026-09-04 23:24:26 +08:00
huangzd1997 19121f6239 task-173: 超时生效测试(HttpClientTimeoutEffectiveTest,本机慢端点 mock)+ 8 条测试
- 验证 HttpClientPool.requestFactory(readTimeout) 真实管线:慢端点超时内失败、快/预算内响应不误杀、时长随配置缩放、非正值钳制、连接超时生效、默认值生效
- 核实并记录平台边界:JDK 请求超时封顶"到响应头"时长,流式 body 读取不受请求超时约束(不编造总时长封顶断言)
- 纯测试,零生产代码改动,全本地确定性无外部网络
2026-09-04 23:22:43 +08:00
huangzd1997 e248b2b935 task-172: 幂等重试守卫(仅 GET/HEAD 或显式幂等标记在传输错误时自动重试,次数/退避取自配置并封顶)+ 8 条测试
- IdempotentRetryGuard:isIdempotent/backoffMillis/isTransportError/execute 纯策略组件
- 非幂等(POST 等)不自动重试;退避 2 次幂增长、5s 封顶;总尝试严格受 aiimage.http-client.max-retries 约束防风暴
- 仅新增类与测试,不接调用点,零生产行为变化
2026-09-04 23:13:41 +08:00
huangzd1997 c1f03d64d1 task-171: 图片下载客户端配置接入(ImageDownloadHttpConfigResolver,download/prefetch 模块级现有配置优先、命名空间兜底)+ 8 条测试
- 真实基线:SimilarAsinImageEmbedder(OkHttp) connect/read=imageDownloadTimeoutSeconds(5s)、call=2×download(10s)、prefetch 1800s
- resolver 提供 connect/read/call/prefetch/maxRetries 访问面,模块级优先、命名空间兜底,不改调用点
- 仅新增类与测试,零生产行为变化
2026-09-04 23:10:36 +08:00
huangzd1997 ec23c0d77c task-170: 紫鸟客户端配置接入(ZiniaoHttpConfigResolver 超时/重试读取,read 模块级现有配置优先、命名空间兜底)+ 8 条测试
- resolver 提供 connect/read/call/maxRetries/baseRetryDelay 访问面,不改动 ZiniaoClientImpl 调用点
- read 优先取 aiimage.ziniao.read-timeout-seconds(生产默认 15s,与 requestFactory(15000) 现状一致),未配置回退 aiimage.http-client.*
- 仅新增类与测试,零生产行为变化
2026-09-04 23:07:58 +08:00
huangzd1997 5ee99f9441 fix(admin): Flask 代理转发 Java 默认携带内部令牌与 operatorId
Build Backend JAR / build (push) Has been cancelled
A1 收敛后 Java 管理接口普遍要求 require* 身份,而浏览器打到 15124 的
请求不带 Java JWT/aiimage_token Cookie,list_shop_manages 等裸代理调用
只转发浏览器 Cookie,被 Java 判未登录,生产后台店铺列表报「加载失败:
未登录」。_proxy_backend_java 默认补 X-Internal-Token(凭 Flask 侧会话
校验通过的管理员身份)+ 自动注入当前操作用户 operatorId,修复同批全部
裸代理调用的 401;显式传身份参数或 use_internal_token=False 可绕过,
供转发浏览器原始 JWT 的场景。新增回归测试锁定默认行为。
2026-09-04 16:08:34 +08:00
huangzd1997 05bda8915a feat(admin): 店铺数据重复检查撞款抽屉样式优化与导入测试按钮
Build Backend JAR / build (push) Has been cancelled
- 撞款详情抽屉:上架时间默认降序(晚到早)、去掉列头(按时间升序)小括号、加宽至 760px、
  去掉全屏遮罩(底层仍可点击)、抽屉贴到「撞款详情」区块位置而非浏览器顶部
- 修复抽屉 fixed 定位失效:.tab-panel.active 入场动画带 transform 会成为包含块,
  打开时把 drawer mask 挂到 body 下恢复视口定位
- 新增导入(新增-测试)/ 导入(删除-测试)按钮与上传弹窗,对应后端端点
  /api/admin/shop-data-crawl/duplicate-check-import(ADD=按店名替换基线记录、DELETE=移除该店记录)
- 新增 ShopDataDuplicateCheckImportService 导入服务(复用 WorkbookParser/Aggregator,与扫描共用 Redis 锁)
- 新增 3 个单测:导入替换重聚合、删除移除、无基线报错
- _preview_mock.py 加入 .gitignore(本地预览工具不入库)
2026-09-04 12:25:31 +08:00
huangzd1997 8241cd704e feat(admin): A1 管理后台收敛 Java 单后台完整实现并修复 guard 误拦内部令牌
Build Backend JAR / build (push) Has been cancelled
- Java 补齐后台全部迁移差集:shopduplicatecheck 店铺数据重复检查模块(V108 扫描表+查询/扫描服务)、
  PinyinAbbrUtil 拼音缩写、ImageHistory 接口调整为内部可用、AdminUser 支持内部令牌操作并放宽列表上限
- Flask 后台 admin_api.py 路由收敛转发 Java、admin.html/admin.js 适配新后台形态
- AdminApiGuardFilter 对可信 X-Internal-Token 放行(controller 自校验兜底),修复客户端仅凭
  内部令牌调用 /api/admin/shop-manages/credential 被误拦 401
- 测试:AdminApiGuardFilterTest 补可信/假令牌用例;AdminUserServiceTest 补菜单权限 mock;
  shopduplicatecheck 新增查询/聚合/CSV 单测
2026-09-04 11:30:09 +08:00
huangzd1997 3420c72c1d fix(oss): 软件版本安装包显式上传公开 client 桶,对齐历史直链布局
Build Backend JAR / build (push) Has been cancelled
生产 Java 未设 AIIMAGE_OSS_BUCKET,默认桶为私有 nanri-ai-images;而 web_config
历史版本全部存于公开 client 桶(oss.aishufu.top/client/nanri-image/versions/...,
桌面端检测更新匿名下载)。原 uploadSoftwareVersionPackage 走默认桶会把新版本写入
私桶导致客户端无法下载。改为显式写 software-version-bucket(新增可配属性,默认
client,env AIIMAGE_OSS_SOFTWARE_VERSION_BUCKET)并保持 nanri-image/versions/ 前缀。

注:本提交含 OssStorageService 上"软件版本上传"方法与早前 readObjectBytesBounded
改动,为软件版本模块(见 ③)的配套存储能力。
2026-09-04 10:21:47 +08:00
huangzd1997 64e4c19531 feat(admin): Java 补齐后台缺失能力(软件版本/图生视频管理/店铺记录列表)与菜单排序
将 Flask 后台仅本地实现、Java 缺失的模块落为原生端点(替代 15124 本地面,
向"单一 Java 后台、可退役 15124"收敛):
- softwareversion: GET /api/admin/versions、POST /api/admin/version(web_config +
  公开桶 nanri-image/versions/ 直链,桌面端"检测更新"同表兼容)
- imagevideo 管理端: GET /api/admin/image-video-tasks、/{taskId}、
  POST /download-zip(近3天 IMAGE_VIDEO_WORKFLOW,语义对齐 Flask)
- shopdatacrawl 管理端: GET /api/admin/shop-data-crawl-tasks(按店分组取最新结果,
  窗口函数)、POST /download-zip(流式 + X-Archive-*-Count)
- 权限: 菜单同级拖拽排序 POST /column/reorder(事务内按序重排兄弟 sort_order);
  PermissionMenuCreate/UpdateRequest 补 snake_case 别名兼容旧控制台 body

以上端点均 requireAdminOrInternal 鉴权;含 PermissionMenuService 早前已改动的
hasAnyAdminMenu 等菜单权限逻辑(本迁移一环)。
2026-09-04 10:21:38 +08:00
huangzd1997 bc5d5b3d2e feat(admin): 管理后台页面同源托管到 Java(classpath:/static)并接入 Java 登录
把 Flask web_source/admin.html 与 static/* 拷入 backend-java resources/static,
经 Spring 默认静态映射同源服务于 api.aishufu.top:18080;/static 根相对引用通过
static/static 子目录镜像零改动保持。页面登录改直连 Java POST /login(cookie+
浏览器持久 deviceId),登出走 Java POST /logout。新增 AdminConsoleController:
GET /、/admin、/login、/logout 页面转发,及 /api/admin/current-user、
/current-user/menus(管理员角色,返回旧前端契约的 item/items 形状)。admin.js
增加全局 fetch 响应解包(ApiResponse data 展开且保留 data 键,401 跳登录)与
URL 兼容映射层(把 Flask 别名统一到 Java 规范路径)。
2026-09-04 10:21:24 +08:00
huangzd1997 e5909c9977 fix(admin): 补齐 /api/admin 方法级鉴权并加兜底过滤器
ShopKey/SkipPriceAsin/QueryAsin/ShopManage/ProductCategory 五个 controller
此前无任何 require* 鉴权,SecurityConfig 全局 permitAll 且 nginx 无 ACL,
公网 18080 上可匿名读写店铺密钥等敏感数据。统一补 requireAdminOrInternal;
其中 ShopManage/SkipPrice/QueryAsin 原先信任调用方传入 operatorId/superAdmin,
改为从已认证 principal 推导,消除传 superAdmin=true 越权扩大数据范围的问题。

新增 AdminApiGuardFilter 对 /api/admin/** 兜底要求有效身份(JWT 或内部令牌),
防止后续新增端点遗漏鉴权再裸奔;支持 admin-guard-enabled/exempt-prefixes 配置。
2026-09-04 10:21:12 +08:00
huangzd1997 1474f69c73 后台管理菜单改为服务端按权限渲染:修复刷新时先显示全量菜单再折叠的闪烁
Build Backend JAR / build (push) Has been cancelled
- main.py admin_page 调用 _load_current_backend_menu_items 取当前用户权限菜单,
  经 render_html 传入模板;Java 权限接口不可用时降级不渲染(避免展示越权菜单)
- admin.html 删除写死的 16 个静态菜单按钮,改为 Jinja2 按权限渲染分组菜单,
  渲染成功时 nav 带 data-server-rendered 标记,失败显示轻量占位
- admin.js loadAdminMenus 识别 data-server-rendered 后直接绑定事件并激活,
  不再请求 /current-user/menus 重渲染(保留 API 兜底路径)
2026-09-04 00:31:04 +08:00
huangzd1997 11dba90780 登录页品牌标识换为 logo 图片:auth-brand-mark 与登录卡片展示 logo_thumb.png
Build Backend JAR / build (push) Has been cancelled
2026-09-04 00:16:19 +08:00
huangzd1997 92a7a2c478 权限回收级联清理:管理员被回收权限后自动清理其直建员工的越权授权
- 保存管理员权限时,若其权限被回收,级联删除其直接创建的员工中超出
  该管理员当前有效范围的授权(创建时快照遗留的越权项)
- 只清理越权项,保留员工合法持有的其他授权;超级管理员不受此限制
2026-09-04 00:16:18 +08:00
huangzd1997 d0db577a9c 后台店铺数据重复检查独立成菜单:删除店铺导入测试、新增撞款详情卡片区
- 删除「店铺导入测试」菜单及全部实现:admin.html 面板、admin.js 逻辑、
  admin_api.py 路由/常量/权限映射、Java 默认菜单
- 「店铺数据记录」页内子 tab 移除,只保留店铺数据列表
- 「店铺管理」下新增「店铺数据重复检查」菜单(V106 导入测试菜单保留并新增
  V107 清理 + 幂等插入新菜单,Java 清单同步)
- 新面板:筛选/指标卡/店铺上架分布/矩阵表格/撞款详情卡片区(同 ASIN 跨店
  上架明细,查看明细开抽屉,上架时间倒序)
- 重复扫描结果改为 MySQL 缓存 + 每日定时扫描(start_duplicate_scan_scheduler)
- 新增 test_admin_shop_data_duplicate_check.py 单元测试
2026-09-04 00:16:14 +08:00
huangzd1997 672b9f9b46 后台店铺数据重复ASIN:全选移至表头、Tab总数、独立筛选、按ASIN分组表格展示
Build Backend JAR / build (push) Has been cancelled
- 列表全选复选框从工具栏移到表格表头,事件委托处理动态元素
- 重复ASIN Tab 标题加总数(XX 为重复 ASIN 数量)
- 重复ASIN 筛选独立:ASIN/店铺/国家/上架时间(开始+结束),与原店铺数据筛选互不影响
- 后端支持 asin/shop_name/country/date_from/date_to 参数:
  行级筛选命中 ASIN 后展示完整记录(含其他店铺,跨店语义更直观)
- 日期文本归一化(支持 2026年8月19日 上午4:34 中文格式)
- 按 ASIN 分组表格展示:ASIN/店铺数/记录条数/品牌/对应店铺/国家/上架时间/操作,
  详情展开显示每条记录的店铺/分组/国家/日期/价格/品牌
- 修复 _shop_data_crawl_fetch_result_bytes 兼容 result_id 列别名(生产首个真实调用报 KeyError)
- 新增单测:筛选语义、日期归一化、record_count
2026-09-03 09:32:25 +08:00
huangzd1997 417a2bf831 后台店铺数据记录页新增 Tab 切换与重复 ASIN 分析;task-169/170 HTTP 客户端配置接入;dedupe/brand 相关改造
Build Backend JAR / build (push) Has been cancelled
- 管理后台:店铺数据记录改为列表分页展示(去任务号/文件列/累计标题,'最新'改'更新时间'),新增'重复 ASIN' Tab 按跨店聚合展示 ASIN/店铺/分组/国家/日期/价格;修复失败/进行中任务被过滤不显示的问题
- task-169: BrandCheckHttpConfigResolver 从 aiimage.http-client.* 读取品牌检查超时/重试(默认同现状、钳制),附 8 条测试
- task-170: surefire 内存调整为 1536m
- dedupe: DedupeRunService 重构(事务边界/进度)、新增 DedupeRunProgressVo、Controller 与结果 VO 调整,PermissionMenuService 相应适配
- brand/dedupe 前端:BrandDedupeTab/BrandPatrolDeleteTab 改造、新增 CountrySelector 组件与 country-options、类型与接口端对齐、测试更新
- 移除无引用文件:backend/static/logo.jpg、prompts/
2026-09-03 01:57:41 +08:00
huangzd1997 152ea6eec0 下线店铺管理-检测店铺密码功能:后台 UI 按钮/徽标、Python 代理路由、Java 接口与 service 全套移除,V105 迁移删除 biz_shop_credential_check 表及历史记录
Build Backend JAR / build (push) Has been cancelled
2026-09-02 16:55:54 +08:00
huangzd1997 664047dbe0 修复店铺数据抓取新店铺归档 daily_file 报 user_id 无默认值
线上现象:店铺数据抓取任务 26401 失败,错误
"Field 'user_id' doesn't have a default value",
INSERT 列清单不含 user_id(MyBatis-Plus 对 null 字段跳过该列)。

根因链:
1. V95(97ae8a7)累计文件改为店铺级共享(去 user 维度),
   persistDailyAggregation 新建 daily_file 时删掉了 setUserId;
2. 但 V95 只改了唯一键为 (shop_key, business_date),未把 user_id 列改可空;
3. 表列 user_id 仍为 NOT NULL 无默认值 → 新店铺首次插入必报错;
   已有 daily_file 行的店铺走 update 分支不受影响,因此只在
   新店铺(如 26401)出现。

修复:
- persistDailyAggregation 新建 daily_file 时补回 setUserId(row.getUserId()),
  新店铺也写入正确归属;
- V104 迁移把 user_id 改可空,兼容存量/历史数据(保留兼容,不再使用);
- 新增回归断言(新建累计文件必须写入 user_id),
  shopdatacrawl 全包 255 测试全绿,双机已部署验证。
2026-09-02 14:23:48 +08:00
huangzd1997 1aea4674e3 修复货源查询 404 行被过滤且状态列置空:Python 404 的 ASIN 保留导出并标记「ASIN未找到」
线上现象:货源采集任务 26402(1212.xlsx)结果文件中存在 Python 端
404 Not Found 的行没有图,且状态列空白——这些行实际已完成采集但被后端过滤。

根因链:
1. Python 404 行 title/url/图全空 → isMissingRequired 必填校验拦截 →
   markRowsFailed(status=FAILED,error 保留 "404 Not Found");
2. isExportableResultRow 对「其它错误需带 title/url/图」的判断把这类 404 行
   过滤掉,即使存在也被 isSilentOutputFailure 把状态列置空。

修复:
- 新增 isAsinNotFound 判定(404 / not found / 商品未找到 等文案,大小写不敏感);
- resolveResultStatus 在图片判定后、rawStatus→失败 映射前插入
  「ASIN未找到」状态;isExportableResultRow 对 404 行直接放行;
- writeResultWorkbook 状态列 gate 排除 404 行(不再被置空);
- 新增 2 条单元测试(404/中文文案命中、普通技术失败不误判)。
2026-09-02 13:47:58 +08:00
huangzd1997 69eb825d29 修复采集数据结果明细 module_type 写读大小写不一致:写入端误用小写 collectdata 导致 task-50 之后所有采集任务明细行生成结果文件时读不到
线上现象:任务 26334 采集完成(去重 42/无效品牌 62/品牌拒绝 6/保留 85)
但结果文件「采集数据结果」sheet 只有表头 0 行,历史卡片「保留 0」。

根因链:
1. CollectDataResultItemBatchWriter(task-50 新增写入端)常量误写为小写
   "collectdata",与 CollectDataService.MODULE_TYPE(大写 COLLECT_DATA)不一致;
2. loadFinalRows 按大写查 biz_task_result_item 命中 0 行 → 组装空表 →
   stats.finalRowCount 被 rows.size()=0 覆盖,UI 显示保留 0;
3. 生产库 5386 行小写 collectdata(8/31 起约 15 个任务)全部读不到,
   大写 COLLECT_DATA 仅存 1067 行历史数据。

修复:
- 写入常量改回大写 COLLECT_DATA(与读取端一致),现有行查询 in(大写,小写)
  兼容存量,旧任务重试幂等命中不重复插入;
- loadFinalRows / deleteTask / deleteHistory 查询改 in(MODULE_TYPE, LEGACY_MODULE_TYPE),
  历史小写行可读出并正确清理(RustFS 对象不泄漏);
- 新增 2 条回归测试(写入 module_type 必须与读取端常量一致、小写存量行重试命中),
  collectdata 全包 168 测试全绿。
2026-09-02 13:47:52 +08:00
huangzd1997 162ed7e406 task-168: LLM 客户端配置接入(LlmHttpConfigResolver 从 aiimage.http-client.* 读取超时/重试,默认值同现状、钳制、可覆盖)+ 8 条测试 2026-09-02 08:16:12 +08:00
huangzd1997 8ca5b1d53b task-167: aiimage.http-client.* 配置命名空间(connect/read/call 超时与重试默认值同现状、非法值钳制、env 覆盖)+ 8 条测试;surefire 加 MaxMetaspaceSize 修复 fork 内存崩溃 2026-09-02 08:00:19 +08:00
huangzd1997 f2736729fa task-166: HTTP 客户端契约表盘点(45 项超时/重试配置、198 个调用点扫描器 + 8 条测试 + 报告快照,不改生产代码) 2026-09-02 07:43:27 +08:00
huangzd1997 bde9e75eed task-165: 巡检只读契约(巡检器无删除/状态修改/写库方法集合断言、调度只调 inspect*、可重复、报表隔离)+ 8 条测试 2026-09-02 07:42:10 +08:00
huangzd1997 34f614ea32 task-164: 清理失败不阻断契约(单文件失败其余继续、失败路径可见、不上抛、下轮重试、引用跳过不计失败)+ 8 条测试 2026-09-02 07:35:57 +08:00
huangzd1997 7a43ed6c43 task-163: 引用中文件不清契约(job/result 引用跳过、引用解除后可清、判定失败保守跳过、批量混合、幂等)+ 8 条测试 2026-09-02 07:30:53 +08:00
huangzd1997 0e4d680aef task-162: 路径穿越输入矩阵(../、..\、绝对路径、%2e 编码、全角点、混合分隔符、空字节全部拒绝)+ 9 条测试 2026-09-02 07:25:49 +08:00
huangzd1997 035ec9ac79 task-161: 巡检任务开关(aiimage.inspection.enabled 默认 disabled、cron 调度、分布式锁双实例去重、单巡检异常隔离、limit 透传)+ 8 条测试 2026-09-02 07:19:56 +08:00
huangzd1997 9712bdf538 task-160: 超保留期仍被引用巡检(超期+引用检出供人工处理、未超期/未引用不报、只读、可重复)+ 8 条测试 2026-09-02 07:14:05 +08:00
huangzd1997 5305d6dbc2 task-159: 已完成任务活跃 Job 巡检(终态任务 RUNNING/PENDING Job 检出、运行中任务正常、只读、可重复)+ 8 条测试 2026-09-02 07:08:53 +08:00
huangzd1997 9998571770 task-158: 结果存在文件缺失巡检(resultFileUrl 对应 OSS 文件缺失检出、空白 URL 不告警、只读、可重复)+ 8 条测试 2026-09-02 07:04:06 +08:00
huangzd1997 9144bce33f task-157: 任务存在结果缺失巡检(终态任务无 file_result 检出、运行中忽略、只读、可重复)+ 8 条测试 2026-09-02 06:57:50 +08:00
huangzd1997 d773748ae9 task-156: 孤立 Job 巡检报表(task/result 缺失孤儿检出、重试耗尽同样报、只读不修改、可重复)+ 8 条测试 2026-09-02 06:53:06 +08:00
huangzd1997 d64ef5284a task-155: 孤立文件巡检报表(只读巡检超保留期且无引用文件,报表含路径/大小/时间,绝不删除,可重复)+ 8 条测试 2026-09-02 06:47:03 +08:00
huangzd1997 87a6d20f88 task-154: 临时目录磁盘容量告警(aiimage.storage.capacity-warn-bytes 阈值、告警含当前容量/阈值、10 分钟频率限制、测量失败容忍不阻塞)+ 8 条测试 2026-09-02 06:40:20 +08:00
huangzd1997 57f75b8bc3 task-153: fileKey 兜底查找契约(保存即登记、重启后目录枚举重建、缺失明确失败、清理后不可找、语义稳定)+ 8 条测试 2026-09-02 06:34:22 +08:00
huangzd1997 3b34ec3bef task-152: 清理失败吞异常记指标(aiimage.temp-cleanup.failed 计数、日志+指标均不阻断主流程、按路径隔离、无重试循环)+ 8 条测试 2026-09-02 06:29:59 +08:00
huangzd1997 f0e12b9b1b task-151: 路径安全校验(PathSafetyGuard 规范化 startsWith 判定、../与绝对路径与符号链接逃逸拒绝、接入清理路径)+ 8 条测试 2026-09-02 06:24:37 +08:00
huangzd1997 ffc3963345 task-150: 清理前引用检查契约(chunk 共享/scope 引用保留、自身行可清、异常保守保留、只读无副作用、批量 IN 反查)+ 8 条测试 2026-09-02 06:19:42 +08:00
huangzd1997 dd569edc66 task-149: 临时文件时间元数据补缺(TempFileMetadata 创建/修改/访问时间与大小读取,mtime 回退不改变清理语义,IO 错误容忍)+ 8 条测试 2026-09-02 06:08:50 +08:00
huangzd1997 383ec544e1 task-148: 临时目录配置盘点(16 配置项/322 清理调用点扫描器 + 9 条测试 + 报告快照,不改生产代码) 2026-09-02 06:02:14 +08:00
huangzd1997 dc90ead263 task-147: downloadUrl 永不过期验证(result/ 走下载域名、无签名参数、bucket 前缀、null/空白安全、输出稳定)+ 8 条测试 2026-09-02 06:00:53 +08:00
huangzd1997 eced873779 task-146: collectdata 自洽行为契约(后端无 file 字段 VO 快照、前端 success+downloadUrl 判定含空白边界)+ 前后端 13 条测试 2026-09-02 05:55:43 +08:00
huangzd1997 0945882458 task-145: 前端可下载判定契约(fileReady/downloadUrl/终态 SUCCESS+FAILED 可下载,PENDING/RUNNING/无 resultId 不可下载)+ 8 条测试 2026-09-02 05:49:01 +08:00
huangzd1997 6c674f0f1d task-144: 前端 live progress 合并补强(mergeHistoryItemPreservingLiveProgress 纯函数:缺失保留/有效覆盖/可下载不合并/幂等)+ 11 条测试 2026-09-02 05:48:09 +08:00
huangzd1997 5e5056b99d task-143: publish 文件级 file 状态语义契约(ready 由 result.success+url 推导、job 字段独立、多文件混合、无结果 null)+ 8 条测试 2026-09-02 05:46:42 +08:00
huangzd1997 9e58d28a99 task-142: fileReady/fileStatus 语义契约(URL 判定、无 job SUCCESS/null、job 状态与错误映射、空白边界)+ 8 条测试 2026-09-02 05:42:32 +08:00
huangzd1997 89d5eda057 task-141: similarasin file 进度合成单测(LLM/Python 上传/snapshot 三路径、fileReady 恒 100%、除零与状态边界)+ 8 条测试 2026-09-02 05:38:26 +08:00
huangzd1997 b7a403dc22 task-140: 13 模块 file 字段契约快照(fileStatus/fileError/fileReady 类型与白名单冻结、旧字段仍在、collectdata 自洽)+ 8 条守门测试 2026-09-02 05:32:06 +08:00
huangzd1997 4fb33bda1c task-138: 事务时长性能对比基准(prepare/persist 分段测量、200 分片负载上界、文档基线守门不劣化)+ 8 条基准测试 2026-09-02 05:20:54 +08:00
huangzd1997 2493019c27 task-137: 重复提交幂等契约(同 id 幂等接受/不重复落库/终态拒绝/并发撞键不覆盖/多次安全)+ 8 条守门测试 2026-09-02 05:15:18 +08:00
huangzd1997 58cfcfdf35 task-136: 事务外清理异常不阻断契约(响应不受影响/不重试循环/事务已提交/下次可再清理/部分失败继续)+ 8 条守门测试 2026-09-02 05:07:33 +08:00
huangzd1997 a982da0262 task-135: 任务状态成功时机契约(SUCCESS 必在文件生成上传后、无文件不成功、fileReady/downloadUrl 语义不变)+ 8 条守门测试 2026-09-02 05:03:05 +08:00
huangzd1997 c8d14a5b1b task-134: done=true 封口时机契约(分片先落库再强制 finalize、剩余全量行数、result 不重复创建、done=false 只触心跳)+ 8 条守门测试 2026-09-02 04:57:56 +08:00
huangzd1997 44fc43912f task-133: 回滚语义硬约束契约(完整回滚/状态不改写/payload 保留/重试安全/计算幂等/双模块一致)+ 8 条守门测试 2026-09-02 04:51:16 +08:00
huangzd1997 cf83752338 task-132: /result 成功确认时机契约(四模块 200+success=true 必在落库后、失败不成功、重试安全)+ 8 条守门测试 2026-09-02 04:44:21 +08:00
huangzd1997 c60ad48be5 task-131: collectdata 事务收缩契约固化(/result 锁内单条写无长事务 + 响应 DTO 写后组装)+ 8 条守门测试 2026-09-02 04:37:14 +08:00
huangzd1997 29ddf5c780 task-130: publish 事务收缩契约固化(prepare 外置/短事务落库/提交后清理已符合 spec 07)+ 8 条守门测试 2026-09-02 04:25:14 +08:00
huangzd1997 5e71e1bb3d task-129: shopdatacrawl 事务收缩(/result 无长事务契约固化 + deleteTask 纯计算抽静态纯函数)+ 8 条边界测试 2026-09-02 04:15:44 +08:00
huangzd1997 ecc62f095b task-128: appearancepatent 事务收缩(flatten/序列化/存储/哈希纯计算抽 prepareSubmittedChunk 移出事务,双事务路径不变)+ 8 条边界测试 2026-09-02 03:54:29 +08:00
huangzd1997 28f61eb70d task-127: similarasin 临时文件清理时机契约固化(提交后清理/回滚不清理/异常吞掉/可重试/幂等)+ 8 条守门测试 2026-09-02 03:44:38 +08:00
huangzd1997 ef4ea8d24b task-126: similarasin DTO 组装位置契约固化(审计结论:/result 无响应 DTO、可移出组装已在事务外、落库行组装顺序不变)+ 8 条守门测试 2026-09-02 03:39:54 +08:00
huangzd1997 79b3efd365 task-125: similarasin /result 纯计算移出事务(payload 哈希在 prepare 阶段预计算,落库直接引用)+ 9 条事务边界守门测试 2026-09-02 03:34:15 +08:00
huangzd1997 56afee0386 task-124: @Transactional 方法审计清单(147 方法/30 模块扫描器 + 13 条测试 + 报告快照,不改生产代码) 2026-09-02 03:24:23 +08:00
huangzd1997 c8250e5320 task-123: dead-code-cleanup diff 守卫仅校验前端提交(后端提交不再误报越界) 2026-09-02 03:20:44 +08:00
huangzd1997 793bd4f9c8 task-123: 性能基准堆采样前先 GC,消除全量套件下残留垃圾导致的 1GB 边界 flaky 2026-09-02 03:20:44 +08:00
huangzd1997 445b7780c5 task-122: N+1 批量化修复(claim/stuck-reset/stale-check 逐行 selectById 改 selectBatchIds 批量回读 + Map 装配,行为等价) 2026-09-02 03:13:05 +08:00
huangzd1997 29625f703c task-121: N+1 扫描审计(循环内单查扫描器 + 10 条测试 + 报告快照,不改生产代码) 2026-09-02 02:40:16 +08:00
huangzd1997 5f4fcad2ef 修复双实例 owner-scoped 结果文件 job 被非归属实例误杀
Build Backend JAR / build (push) Has been cancelled
线上现象:货源查询任务 26402/26400(归属 server-121)在归属机正常推进,
却被 server-110 判为「结果生成失败」,错误为「该任务已绑定到另一台服务实例处理」。

两个缺陷叠加:
1. 两台实例共用一个 RocketMQ consumer group,dispatch 消息被轮询投递;
   worker 对"PENDING + owner 不匹配"的 job 选择本地抢跑,模块层
   ensureTaskOwnedByCurrentInstance 直接抛 TaskOwnerMismatchException,
   异常落进通用 catch 被当成生成失败,5 次抢跑即耗尽 retryCount 并终态失败。
2. runPendingJobs 双重 claim:claimRunnableJobsForOwner 已把 job 翻成 RUNNING,
   随后又走 claimRunning(条件 PENDING/FAILED)必然失败 → job 被静默丢弃,
   归属机的定时兜底从未真正生效。

修复:
- worker:非归属实例一律跳过 owner-scoped job;抽出 processClaimed 供已持有
  claim 的调用方使用;processInternal 单独捕获 TaskOwnerMismatchException,
  只 deferRunning 退回 PENDING,不计入重试。
- TaskFileJobLocalDispatcher 新增 dispatchClaimed。
- dispatch 事件带上 owner,coordinator 按归属路由:本机 owner 直接本地派发不发 MQ,
  他机 owner 不发不跑交由归属机轮询接手,owner 为空维持原有 MQ 行为。
- 新增 owner 路由回归测试两组,回滚配合"本地抢跑"的旧断言。

同时提交此前工作区内已随 JAR 上线的 backend-java 改动:SimilarAsin 解析载荷
groups 内嵌 items(Python 旧链路兼容)与 chunk 类型不匹配跳过、
PermissionMenuSchemaInitializer 与 V103 两级菜单分组迁移、相关测试。
2026-09-01 21:07:25 +08:00
huangzd1997 55517f996b task-120: 大页数据性能回归 + 恢复 similarasin 测试入库
性能回归(SimilarAsinTaskServicePerf500Test,8/8 绿):
- test_perf_light_200 原以墙钟毫秒比较 light 与 batch(assertTrue
  lightMs < batchMs)。两条路径都跑纯内存 stub,耗时在十几毫秒量级,
  JIT/GC/线程调度抖动远大于真实差值,本机实测 light 14ms / batch 13ms
  直接翻红。改为确定性口径:light 结果明细查询数 == 0(batch ≥ 1)、
  light 总查询数 < batch 总查询数、batch 条目携带任务明细对象而 light
  只有白名单字段;墙钟仅保留单侧上界 1s(N+1 退化会放大到秒级从而失败)。
  连续 3 次独立运行稳定通过。
- 类注释同步移除“已知 flaky,隔离重跑即接受”的说明。

恢复测试入库:
- fa5a59e(task-116) 把 similarasin 测试目录整体从 git 删除,并加了
  .gitignore 规则 *.broken/,磁盘上目录改名 similarasin.broken。
  但包声明仍是 com.nanri.aiimage.modules.similarasin.*,javac 照常编译,
  这 40 个测试文件一直在参与构建、并且是 mvn test 的门禁的一部分——
  等于脱离版本控制却仍在 gate 构建。
- 目录改回 similarasin/(现在与包声明一致),移除 *.broken/ 忽略规则,
  40 个测试文件重新入库。mvn test-compile 退出码 0。
2026-09-01 13:45:34 +08:00
huangzd1997 f18d488cea 查询ASIN/最低价ASIN:精简新增弹窗
Build Backend JAR / build (push) Has been cancelled
- 国家由多选下拉改为单选,一次录入一个站点的 ASIN
- 店铺名改为按分组联动的下拉,移除带分页表格的「选择店铺」二级弹窗
- 表单压成两行(分组/店铺名/国家 + ASIN[/最低价]),按钮文案改为「保存」
- 保存成功后保留分组/店铺/国家,仅清空 ASIN 并聚焦,便于连续录入
- 清理随之失效的死代码:选择店铺弹窗 JS、按国家渲染输入框的 render/collect
  函数、.field-with-action/.skip-price-entry 等无引用 CSS
- admin.js 版本号改为 asin-create-v4,避免新 HTML 命中旧 JS 缓存

提交报文格式不变(countries:[code] + asin_mappings:{code:asin}),后端无需改动
2026-09-01 13:39:50 +08:00
huangzd1997 ac2b15d72f 去重数据汇总:按钮文案改为新增导入/删除导入
Build Backend JAR / build (push) Has been cancelled
2026-09-01 13:01:50 +08:00
huangzd1997 fa5a59e5cd task-116: 后台管理新增/导入表单弹窗化 + 分组管理独立菜单与UI优化 + 轻量进度端点
Build Backend JAR / build (push) Has been cancelled
- 后台管理页(admin)所有面板的新增/导入表单改为弹窗操作,原有字段 ID 全部保留、提交逻辑不变;导入删除入口不再触发二次确认拦截
- 分组管理升级为独立菜单(V102 + schema initializer),移除 5 个面板内的管理分组按钮;分组列表改为蓝白主题、增加权限分组横幅
- Python 侧 group-manage 权限守卫(_ensure_backend_menu_access 补充 group-manage)
- 引入 V101(biz_task_file_job 复合索引)+ 新增 TaskProgressLight/TaskFileJob 轻量端点与进度聚合作
- 前端 progress-light / page-separated-loads / dispatch-guard 共享模块及单元测试
2026-09-01 12:54:13 +08:00
huangzd1997 759f0b15d8 task-101: 上传/解析/入队三道前端拦截,阻止坏数据卡死 Python 自动化
Build Backend JAR / build (push) Has been cancelled
新增 shared/dispatch-guard.ts(纯 TS 校验,可单测)与 dispatch-guard-ui.ts
(ElMessageBox 弹窗层),在数据流的三个位置设闸:

- 选文件:空选择、非 xlsx/xls/csv、空路径直接拦;重复文件弹确认
- 解析结果:taskId 非法、totalRows 为 0、整批行被丢弃、需要分组却无分组直接拦;
  部分行被丢弃弹确认后才允许推送
- 入队前:结构不符、必填字段缺失、items/groups/country_codes 为空数组、
  行数页数为 0、JSON 不安全值(NaN/Infinity/BigInt/循环引用/数组洞)

覆盖 11 个推 Python 队列的 Tab 与 dedupe/split/convert 三个纯 Java Tab。
闸位按 Tab 挑选以免留下孤儿后端状态:collect-data 校验前置到
activateCollectDataTask 之前(任务保持 PENDING 无需回滚)、product-risk 的国家
检查提到建任务之前;已建任务后才拦下的复用各 Tab 原有失败补偿路径。

两处边界:对象属性 undefined 放行(taskNo 这类可选字段是惯用写法),只拦数组
元素 undefined 与数组洞;price-track 的 asin_rows_by_country 仅在 mode=asin
时要求非空,status 模式下 loadAsinRowsForAppClient 本就返回 {}。

顺带修复 similar-asin / appearance-patent 的 selectFiles 缺少 try/catch,
上传失败会残留上一批文件与解析结果。

测试:tests/dispatch-guard.test.ts 新增 37 个 test_task_101_* 用例。
2026-09-01 12:53:12 +08:00
huangzd1997 e2607ab723 task-98: 移除 similar-asin/appearance-patent 模块 Coze,状态机与共享组件改名 LLM
Build Backend JAR / build (push) Has been cancelled
- similarasin/appearancepatent 模块全部 Coze 工作流调用改走 direct-LLM(已确认唯一运行路径)
- 共享组件改名:CozeTaskQueueGate→TaskQueueGate、CozeGroupResultPropagator→GroupResultPropagator
- 状态机改名:biz_task_scope_state 的 coze_* 列→llm_*、stateJson coze 键→llm(V100 迁移已应用生产)
- 删除 biz_coze_credential 表、CozeCredential* 类、SimilarAsinCozeClient、AppearancePatentCozeClient→LlmClient
- 前端 brand 页 Coze 文案→LLM;Python 后端删除 cozepy 依赖与死配置
- 修复 TaskResultFileJobWorker 启动失败:TaskFileJobConfig 注册 ResultFileJobHandlerRegistry 与 13 个 handler bean(含 validateCoverage 启动校验)
2026-09-01 02:20:50 +08:00
huangzd1997 0cc7380205 task-47: 轮询 baseline 统计补强测试 2026-08-31 22:47:47 +08:00
huangzd1997 969c5a2a67 task-46: 双页面同 key 行为记录测试
只读断言现状(不改实现):同 storageKey 双页面各自独立轮询集合、
互不实时同步、storage 写互相覆盖、dispose 一方不影响另一方、
不同 key 完全隔离。共 8 个测试。
2026-08-31 21:17:59 +08:00
huangzd1997 5314fa7745 task-45: 轮询与历史刷新分离测试
轮询不触发历史接口、终态独立触发一次历史刷新、无 refreshHistory
时流程照常、TTL 缓存合并历史请求、force 跳过缓存、多页面并行
不阻塞、历史刷新失败恢复后轮询照常。共 8 个测试。
2026-08-31 21:14:47 +08:00
huangzd1997 a9bc9ff52e task-44: 轻量端点切换能力测试
fetchProgress 切轻量端点(taskId/status/fileStatus)后请求走轻量
实现;轻量结构解析、默认仍走旧端点、缺可选字段容错、终态判定、
缓存写入、onUpdate 收到、新旧结构同轮兼容。共 8 个测试。
2026-08-31 21:12:33 +08:00
huangzd1997 6bf87aff13 task-43: progressCache TTL 惰性清理边界测试
命中返回、过期读取即清理、超上限淘汰最旧、空缓存 get undefined、
同 key 覆盖并刷新 TTL、TTL 边界立即过期、惰性清理不主动扫描、
轮询周期内缓存可用。共 8 个测试。
2026-08-31 21:07:43 +08:00
huangzd1997 9af7a5170a task-42: 退避恢复测试
失败→退避序列→成功→恢复正常间隔;连续失败计数归零后从
attempt 0 重新起;多次失败成功循环;部分成功算成功;前台
刷新下恢复;长失败链后恢复。共 8 个测试。
2026-08-31 21:06:26 +08:00
huangzd1997 50518b5420 task-41: storage 恢复与清理测试
恢复过滤非正数/非数字、空列表清除过期 key、终态同步 storage、
写失败不抛、坏 JSON 容错、恢复即轮询、无 key 不操作。修复恢复
出空列表时遗留 key 未清理的问题。共 8 个测试。
2026-08-31 21:02:52 +08:00
huangzd1997 d33316f093 task-40: 页面隐藏降频与可见恢复测试
隐藏 60s/可见 10s 间隔自适应、切回可见立即刷新、开关关闭不刷
新、延迟刷新生效、隐藏仍轮询、事件绑定/解绑、隐藏不触发即时
刷新。修复 scheduleNextDelayed 被轮询定时器阻塞导致延迟前台刷
新永不触发的缺陷。共 8 个测试。
2026-08-31 20:58:05 +08:00
huangzd1997 93943bb51a task-39: in-flight 合并测试补强
in-flight 期间不叠加 timer、不并发请求;完成按退避续轮;
重复 ensure(true) 不叠加;add 期间请求含新任务;失败释放锁。
共 8 个测试。
2026-08-31 20:54:35 +08:00
huangzd1997 89fff86333 task-38: 同轮多任务终态分别回调测试
同一轮响应多任务同时终态:各自回调带各自 detail/status、
按响应顺序(非注册顺序)、一个抛错不影响其他、全部移除、
异步回调逐个 await。共 8 个测试。
2026-08-31 20:52:02 +08:00
huangzd1997 01e00f4b98 task-37: onTerminal 抛错语义测试
覆盖 onTerminal 回调抛错时的语义:不打断轮询、任务照常移除、
可重新 add 恢复、不影响同轮其他终态、抛错被吞掉不进 onError、
不自动重试、恢复后重新触发。共 8 个测试。
2026-08-31 20:45:56 +08:00
huangzd1997 9e8ecb57e5 task-36: 终态任务仅一次 onTerminal
8 个测试固化 markTerminal 语义:同一任务终态只回调一次(幂等)、
终态任务从轮询集合移除、重复响应不回调、重新 add 后可再触发、
多任务各自回调、markTerminal 先于移除、终态后 localStorage 同步
清理、停止轮询不触发回调。
2026-08-31 20:36:18 +08:00
huangzd1997 745e3fe2c4 task-35: 未知状态不判终态固化
8 个测试固化未知状态语义:PENDING/SYNCING/空串/undefined 均为
非终态(FSM 层走重试语义、循环层不触发 onTerminal、任务保留在
轮询集合);同批终态+未知分开处理;自定义 isTerminal 生效;
小写值不误判。
2026-08-31 20:35:10 +08:00
huangzd1997 e16aa63974 task-34: HTTP 4xx/5xx 分类
8 个测试固化 HTTP 错误语义:4xx/5xx 记 onError 并进入退避、
不触发 onTerminal(5xx 不可解析明细时不误判 FAILED)、不清空已有
状态、恢复后继续轮询且部分 items 照常处理、未知状态不受影响。

行为由 http 层抛错与既有 catch 路径实现,本次为验证型测试。
2026-08-31 20:31:48 +08:00
huangzd1997 dd0a32e89a task-33: 网络错误走退避且不触发终态
8 个测试固化网络错误语义:fetch 拒绝不触发 onTerminal、不修改
taskStatuses、任务集合不丢失、onError 上报、失败后不立即自动重试
(退避)、恢复后继续轮询并正常触发终态。

行为由任务 31 的失败计数与既有 catch 路径实现,本次为验证型测试。
2026-08-31 20:30:45 +08:00
huangzd1997 3e45aa2a91 task-32: 退避封顶
8 个测试固化退避封顶语义:达到 maxMs 后保持恒定(含低 maxMs、
高 factor 提前封顶)、成功后从基数重新起算、恰等于 maxMs 不溢出、
循环内失败计数映射退避间隔的集成、非法 maxMs 配置拒绝。

行为由任务 29/30 的 factor 与 maxMs 配置已实现,本次为验证型测试。
2026-08-31 20:27:29 +08:00
huangzd1997 ab55b20edd task-31: 连续失败计数
useTaskProgressLoop 轮询循环维护连续失败计数:refreshOnce 成功
(收到响应)归零;失败递增(封顶 100);onError 回调增加第二参数
attempt(0 起),供上层决定退避策略;dispose 后不再上报。

同时把该组合式函数内部 @/ 别名 import 改为相对路径(带 .ts 扩展),
使其可在 node --test 下直接运行(此前无任何测试覆盖该文件)。
新增 8 个测试:递增、成功后归零、收到响应归零、onError 带 attempt、
初始 0、交错、封顶、dispose 清理。
2026-08-31 20:26:31 +08:00
huangzd1997 9e224929fb task-30: getTaskPollBackoffMs 递增序列
getTaskPollBackoffMs 签名改为 attempt 可选(省略视为 0,向后兼容),
序列 500×factor^attempt、封顶 maxMs 行为由任务 29 的 factor 配置驱动。
新增 8 个测试:attempt0/1/2 值、序列单调、封顶、省略参数默认、
负 attempt 当 0、自定义 factor。
2026-08-31 20:16:30 +08:00
huangzd1997 37eabcbb2e task-29: 退避配置项(MaxMs/Factor)
task-progress-config.ts 新增 getTaskPollBackoffMaxMs()(默认 10000,
由 5000 提升)与 getTaskPollBackoffFactor()(默认 2,<1 钳制为 1);
configureTaskPolling 支持 backoffFactor;getTaskPollBackoffMs 改用
base × factor^attempt 计算。

既有 task-086 边界测试中封顶 5000 的快照随新默认更新为 10000。
新增 8 个测试:max/factor 默认、可覆盖、非正钳制、factor 下限、
配置隔离、默认值快照。
2026-08-31 20:14:43 +08:00
huangzd1997 71606e9fe5 task-28: 死代码清理
删除拆分后失去引用的 API 残留文件:
- src/shared/api/call.ts(已由 http.ts 取代)
- src/shared/api/download.ts(已由 download-url.ts 取代)
- src/shared/api/status.ts(页面内已有本地实现)
及其孤儿测试 tests/call.test.ts / call-abort.test.ts / download.test.ts / status.test.ts。
endpoints/url/user 仍被模块文件引用,保留。

新增 8 个验证测试(dead-code-cleanup.test.ts):无重复导出、
vue-tsc 零错误、全量测试绿、无调试日志、无残留函数体、
16+ HTML 入口存在、build 产物齐全、提交变更仅限 frontend-vue。
2026-08-31 20:11:49 +08:00
huangzd1997 3fe8d5d05c task-27: api-field-compat 高频响应 schema
新增 src/shared/api-field-schemas.ts:task 核心字段、result 文件阶段
字段、task-result 组合 schema 注册表(带版本号);12 个业务模块
注册同一 task-result schema;getApiFieldSchema()/createModuleFieldChecker()
供契约测试与联调前跑字段漂移检查。

10 个测试:schema 必填/结果字段声明、checker 合法/缺必填/类型不符/
批量、模块注册齐全、版本标记、未知模块抛错。
2026-08-31 20:07:02 +08:00
huangzd1997 e896e0bef4 task-26: 模块 API 快照契约测试基建
新增集中式 assertApiCall() helper(tests/helpers/api-snapshot.ts):
断言 url/method/params/data 快照,params/data 白名单外字段报错,
失败信息含实际与期望 URL 上下文;isApiModule() 覆盖 16 个已拆模块。

8 个测试:helper url/method/params/body、all_modules_covered、
fail_message、allowlist、regression_guard。
2026-08-31 20:05:53 +08:00
huangzd1997 f177a15105 task-25: applyFilePhaseDefaults 兼容旧 Java 响应的文件阶段字段默认值 2026-08-31 20:01:52 +08:00
huangzd1997 eaf457c6c0 task-24: java-modules.ts 改为纯 re-export 聚合器,upload helpers 移至 upload.ts 2026-08-31 20:00:45 +08:00
huangzd1997 21c92afa7a task-23: 拆分 image-video / brand / permission / digital-human 模块 API 至 types/modules/,旧文件转 re-export 存根 2026-08-31 19:57:38 +08:00
huangzd1997 8f119198fd task-22: 拆分 collect-data 模块 API 至 types/modules/collect-data.ts,java-modules.ts re-export 2026-08-31 19:50:53 +08:00
huangzd1997 79e3513056 task-21: 拆分 withdraw / patrol-delete 模块 API 至 types/modules/withdraw.ts,java-modules.ts re-export 2026-08-31 19:48:49 +08:00
huangzd1997 71b482df6d task-20: 拆分 shop-data-crawl / query-asin 模块 API 至 types/modules/query-asin.ts,java-modules.ts re-export 2026-08-31 19:45:59 +08:00
huangzd1997 be02833b11 task-19: 拆分 shop-match / product-risk 模块 API 至 types/modules/shop-match.ts,java-modules.ts re-export
- product-risk 15 函数 + shop-match 17 函数 + 全套类型(含 ShopMatch 对 ProductRisk 的 type alias)
- 保留模块的 PatrolDelete/QueryAsin/Withdraw alias 通过 import type 兜底引用
- QueryAsinCountryAsins 内联定义避免跨模块循环依赖
- 10 个测试:双模块 CRUD/preference/match/task 系列/progressBatch 双端/dashboard/skip-asins/download/export compat
2026-08-31 19:42:18 +08:00
huangzd1997 173ea3b074 task-18: 拆分 price-track 模块 API 至 types/modules/price-track.ts,java-modules.ts re-export
- candidates/preference/matchShops/createTask/tasksBatch/progressBatch/loopRun 系列/skipAsin 系列/dispatchFailed/pendingShopResult/dashboard/history/delete/download 共 23 函数
- price-track 全套类型(含 LoopRun/ExecutionMode/SkipPriceAsin 类型)随模块迁移
- 12 个测试:CRUD/preference/match/create/batch/loopRun/progressBatch/skipAsin 系列/dashboard/download/unwrap/export compat
2026-08-31 19:39:00 +08:00
huangzd1997 f8dad27957 task-17: 拆分 delete-brand 模块 API 至 types/modules/delete-brand.ts,java-modules.ts re-export
- runDeleteBrand/getDeleteBrandHistory/deleteDeleteBrandHistory/getDeleteBrandTaskDetail/getDeleteBrandTaskDetails/getDeleteBrandTaskDownloadUrl/getDeleteBrandResultDownloadUrl/submitDeleteBrandResult/getDeleteBrandTaskProgress
- delete-brand 全套类型(含 MatchStatus union)随模块迁移;progressBatch 内联缓存+超时实现
- 10 个测试:run URL/超时/history/delete/taskDetail/taskDetails/download×2/submitResult 请求体/progressBatch/export compat
2026-08-31 19:37:19 +08:00
huangzd1997 b27a686998 task-16: 拆分 appearance-patent 模块 API 至 types/modules/appearance-patent.ts,java-modules.ts re-export
- parseAppearancePatent/getAppearancePatentParsedPayload/getAppearancePatentQueuePayload/getAppearancePatentDashboard/getAppearancePatentHistory/getAppearancePatentTaskProgressBatch/activateAppearancePatentTask/deleteAppearancePatentTask/deleteAppearancePatentHistory/getAppearancePatentResultDownloadUrl
- appearance-patent 全套类型随模块迁移;progressBatch 内联缓存+超时实现
- 9 个测试:parse/parsedPayload/queuePayload/progressBatch/activate/dashboard/history/delete/download/export compat
2026-08-31 19:35:59 +08:00
huangzd1997 d7104d35da task-15: 拆分 similar-asin 模块 API 至 types/modules/similar-asin.ts,java-modules.ts re-export
- parseSimilarAsin/getSimilarAsinDashboard/getSimilarAsinHistory/getSimilarAsinTaskProgressBatch/activateSimilarAsinTask/deleteSimilarAsinTask/deleteSimilarAsinHistory/getSimilarAsinResultDownloadUrl
- similar-asin 全套类型随模块迁移;progressBatch 内联缓存+超时实现(与 java-modules 同构)
- 9 个测试:parse URL/payload/默认值/dashboard/history/progressBatch 去重+超时/activate/delete/download/export compat
2026-08-31 19:34:56 +08:00
huangzd1997 b93d338eac task-14: 拆分 publish 模块 API 至 types/modules/publish.ts,java-modules.ts re-export
- parsePublish/activatePublishTask/activatePublishFile/getPublishItemsPage/getPublishItemsPageUrl/getPublishTaskProgressBatch/submitPublishTaskResult/getPublishDashboard/getPublishHistory/deletePublishTask
- Publish 全套类型随模块迁移;progressBatch 保留 task_ids 请求体并应用进度超时
- 10 个测试:parse URL/超时/activate/itemsPage 参数/itemsPageUrl/progressBatch 去重+超时/submitResult 请求体/dashboard/delete/export compat
2026-08-31 19:33:16 +08:00
huangzd1997 fdbf681292 task-13: 拆分 convert 模块 API 至 types/modules/convert.ts,java-modules.ts re-export
- getExcelInfo/runConvert/getConvertHistory/deleteConvertHistory/getConvertResultDownloadUrl/getConvertTemplates/importConvertTemplate/setDefaultConvertTemplate/deleteConvertTemplate
- 模板相关类型 ConvertTemplateVo/ConvertTemplateImportRequest/ExcelInfoVo 随模块迁移
- 9 个测试:URL/method/payload/history/模板系列/签名/export compat/unwrap
2026-08-31 19:31:10 +08:00
huangzd1997 a98efb00f7 task-12: 拆分 split 模块 API 至 types/modules/split.ts,java-modules.ts re-export 2026-08-31 19:29:01 +08:00
huangzd1997 a4ca9d5a19 task-11: 拆分 dedupe 模块 API 至 types/modules/dedupe.ts(callJava+buildJavaUrl 化),java-modules.ts 改 re-export 保持旧 import 兼容 2026-08-31 19:27:39 +08:00
huangzd1997 22422bc9d2 task-10: types/task.ts 共享类型(TaskStatus/ResultFilePhase/PageResult/TaskProgressBatchVo) 2026-08-31 19:24:26 +08:00
huangzd1997 9349f8ff33 task-9: 进度类请求默认 10s 超时(progressTimeoutMs 可配置覆盖,postTaskProgressBatch 接入) 2026-08-31 19:23:13 +08:00
huangzd1997 980e6e91e0 task-8: callJava AbortController 透传契约测试(发送前/进行中中止、signal 透传、多调用独立) 2026-08-31 19:21:56 +08:00
huangzd1997 35de13f7f1 task-7: buildDownloadUrl()/resolveDownloadUrl() 下载 URL 统一构造(user_id 追加与去重、fresh 优先) 2026-08-31 19:20:56 +08:00
huangzd1997 1e1f533a24 task-6: isTerminalStatus() 终态判定(默认 SUCCESS/FAILED,extras 扩展且归一化,空值非终态) 2026-08-31 19:20:17 +08:00
huangzd1997 432b2c52b2 task-5: normalizeStatus() 状态归一(大写化、连字符/空格转下划线、空值安全) 2026-08-31 19:19:33 +08:00
huangzd1997 9f58350b4a task-4: extractErrorMessage 命名导出并覆盖 error/message/msg 三字段(空白跳过、优先级 error>message>msg) 2026-08-31 19:18:57 +08:00
huangzd1997 6e227aa377 task-3: callJava() 统一响应解包(JavaApiResponse/Legacy 兼容、success=false 抛错);开启 allowImportingTsExtensions 支持 node --test 2026-08-31 19:18:21 +08:00
huangzd1997 f63ab837f5 task-2: buildJavaUrl() 统一 URL 构造(query 编码、尾斜杠规范化) 2026-08-31 19:16:19 +08:00
huangzd1997 d1870f1382 task-1: 新增 API_ENDPOINTS 路径常量表(frontend-api-adapter) 2026-08-31 19:15:10 +08:00
huangzd1997 c8cd851b2f feat: 外观专利改直连 LLM(DeepSeek/Gemini)、无效ASIN菜单更名 BRAND_DB、紫鸟店铺索引场景化
Build Backend JAR / build (push) Has been cancelled
- AppearancePatent:Coze 工作流切换为 llm-host 直连模型(title/appearance 双模型、行并发、重试),配置键迁移并保留旧环境变量兜底
- InvalidAsinDataMapper 补充按值+品牌唯一键查询
- ZiniaoShopIndexService 新增店铺分类/索引场景
- V98:无效ASIN菜单 rename 补充 BRAND_DB;docs 架构优化规划
- 配套单测更新
2026-08-31 17:04:59 +08:00
huangzd1997 14a41e64f1 feat: SimilarASIN 直连 LLM 通道(Gemini/DeepSeek 多模型)替代 Coze 工作流
- SimilarAsinLlmClient/Service:分类、符合性、图片比对三阶段直连 LLM
- PuzzleImageMerger:拼图合并用于图片比对
- direct-llm-enabled 开关 + llm-host/api-key/模型/超时/并发配置(默认开)
- LlmGatewayTlsProbe、SimilarAsinLlmLocalVerify 为本地验证工具
2026-08-31 17:02:53 +08:00
huangzd1997 7f4737c800 feat: 店铺密码检测任务(后台发起→客户端领取→紫鸟真实登录判定→回传结果)
- 新增 biz_shop_credential_check 表(V99)与 ShopCredentialCheck 全链路
- Controller /api/admin/shop-credential-checks(create/poll/report/latest,X-Internal-Token 鉴权)
- ShopManageService 列表附带 latestCheck(每店铺最近一次检测结果)
- 客户端通过 poll 领取(60s 轮询、原子置 RUNNING),报告 SUCCESS/FAILED/OTP_REQUIRED/NO_NEED_LOGIN/ERROR
2026-08-31 17:02:49 +08:00
huangzd1997 26f4bb3f25 后台菜单重构:菜单类型分组排序(软件在前/后台在后)、新增同类型末尾排序;任务中心分组移除,视频任务记录归入记录与版本、店铺数据记录归入店铺管理;界面名词优化(菜单权限配置/去重数据汇总/无效ASIN数据/视频任务记录/店铺数据记录/生成记录)
Build Backend JAR / build (push) Has been cancelled
2026-08-31 01:48:05 +08:00
huangzd1997 0408c9752e fix: 菜单排序 app 分组优先于 admin,sort_order 按 menuType 作用域解析
Build Backend JAR / build (push) Has been cancelled
- menuComparator 增加 menuType 排序维度(app → admin → 其他)
- resolveSortOrder 查询限定同 menuType,避免跨类型尾部误判
- 抽出 loadRawMenus 保持原始 SQL 与比较器语义一致
2026-08-31 01:21:45 +08:00
huangzd1997 483374744a fix: Spring 多构造器类显式 @Autowired 标注 + V95 迁移兼容 MySQL 8.4
Build Backend JAR / build (push) Has been cancelled
- CapacityPlanService / ExternalCallMetricsRecorder / ZiniaoClientImpl:
  双构造器(生产 + 测试入口)导致 Spring 6 不自动推断构造器注入,
  启动报 'No default constructor found';生产构造器显式加 @Autowired
- V95:shop_key 列 V85 建表时已有,原 ADD COLUMN shop_key 会报
  duplicate column;MySQL 8.4 不支持 ADD COLUMN IF NOT EXISTS,改
  information_schema 动态 SQL;shop_key 缩到 VARCHAR(255) 以容纳
  (shop_key, business_date) 唯一键(1000 在 utf8mb4 下超 3072 字节
  索引上限);删除多余行改为单表 DELETE
2026-08-31 01:09:19 +08:00
huangzd1997 19ddfb9c5a chore: 移除误入库的本地规划/进度文件 (docs/plans, check_progress.py, progress.json),gitignore 兜底
Build Backend JAR / build (push) Has been cancelled
2026-08-31 00:37:31 +08:00
huangzd1997 0f09cbec74 chore: 移除误入库的本地规划文档 docs/plans,加入 gitignore 2026-08-31 00:21:02 +08:00
huangzd1997 97ed407c32 chore: 移除误提交的 vite dev server 日志
Build Backend JAR / build (push) Has been cancelled
2026-08-30 23:58:07 +08:00
huangzd1997 4a75f7b96b progress 100
Build Backend JAR / build (push) Has been cancelled
2026-08-30 23:40:35 +08:00
huangzd1997 c7fb126761 progress 99 2026-08-30 23:40:35 +08:00
huangzd1997 a4607b41fd progress 98 2026-08-30 23:40:35 +08:00
huangzd1997 a75d8d38bf progress 97 2026-08-30 23:40:35 +08:00
huangzd1997 07ecaf355e progress 96 2026-08-30 23:40:35 +08:00
huangzd1997 7c3e5f399a progress 95 2026-08-30 23:40:35 +08:00
huangzd1997 d705fd7a25 progress 94 2026-08-30 23:40:35 +08:00
huangzd1997 fc7dfaaa5c progress 93 2026-08-30 23:40:34 +08:00
huangzd1997 4143fb5fbf progress 92 2026-08-30 23:40:34 +08:00
huangzd1997 f725c358a1 progress 91 2026-08-30 23:40:34 +08:00
huangzd1997 8ea662dd5a progress 90 2026-08-30 23:40:34 +08:00
huangzd1997 830a7ccbef progress 89 2026-08-30 23:40:34 +08:00
huangzd1997 60bcd390a7 progress 88 2026-08-30 23:40:34 +08:00
huangzd1997 b44a1a2cda progress 87 2026-08-30 23:40:34 +08:00
huangzd1997 ee6541ae25 progress 86 2026-08-30 23:40:34 +08:00
huangzd1997 e49466ffd3 progress 85 2026-08-30 23:40:33 +08:00
huangzd1997 8fd574c472 progress 84 2026-08-30 23:40:33 +08:00
huangzd1997 dceb76c30c progress 83 2026-08-30 23:40:33 +08:00
huangzd1997 922b6ee9f7 progress 82 2026-08-30 23:40:33 +08:00
huangzd1997 779e5006d9 progress 81 2026-08-30 23:40:33 +08:00
huangzd1997 0f52c80e86 progress 100 2026-08-30 23:18:26 +08:00
huangzd1997 4d84d362cf task-100: 发布前回滚演练、commit 对应关系检查和交付清单 2026-08-30 23:18:25 +08:00
huangzd1997 6593b8f007 progress 99 2026-08-30 23:17:02 +08:00
huangzd1997 2fb56632c9 task-99: 全链路压测记录 CPU、内存、GC、DB、Redis、RustFS、网络结果 2026-08-30 23:17:02 +08:00
huangzd1997 e79f1015cb progress 98 2026-08-30 23:15:32 +08:00
huangzd1997 38e94e1f53 task-98: 真实启动、健康检查、核心请求和外部依赖调用验证执行器 2026-08-30 23:15:31 +08:00
huangzd1997 6e9a9f7347 progress 97 2026-08-30 23:13:56 +08:00
huangzd1997 c08869f109 task-97: Java/Python/Vue 三端验证工作流编排器 2026-08-30 23:13:55 +08:00
huangzd1997 a707e754f8 progress 96 2026-08-30 23:12:27 +08:00
huangzd1997 1b491d972a task-96: Java/Python/Vue 三端统一 API 字段兼容检查器 2026-08-30 23:12:27 +08:00
huangzd1997 cc41b5d81b progress 95 2026-08-30 23:11:12 +08:00
huangzd1997 b03aaab493 task-95: 错误提示、重试和终态刷新的轮询状态机 2026-08-30 23:11:11 +08:00
huangzd1997 5999b10643 progress 94 2026-08-30 23:10:00 +08:00
huangzd1997 2bcb8955a5 task-94: 移动端与桌面端响应式页面验收截图计划 2026-08-30 23:10:00 +08:00
huangzd1997 9accebd2b4 progress 93 2026-08-30 23:08:59 +08:00
huangzd1997 85c8c66c4d task-93: Similar ASIN、店铺抓取和采集数据页面 E2E 核心路径执行器 2026-08-30 23:08:56 +08:00
huangzd1997 77bd83743b progress 92 2026-08-30 23:07:11 +08:00
huangzd1997 eb158e76f0 task-92: manualChunks 拆包后比较各页面首屏传输大小 2026-08-30 23:07:08 +08:00
huangzd1997 bd3af46cf8 progress 91 2026-08-30 23:05:11 +08:00
huangzd1997 72998b7d22 task-91: 按页面拆分 Element Plus 与公共业务 chunk 规划器 2026-08-30 23:05:08 +08:00
huangzd1997 6804b2dea6 progress 90 2026-08-30 23:01:20 +08:00
huangzd1997 bf38a1b9a0 task-90: 进度接口增加断网、超时、服务恢复和重复响应测试 2026-08-30 23:01:17 +08:00
huangzd1997 cc2722c104 progress 89 2026-08-30 22:57:08 +08:00
huangzd1997 bb2f200d76 task-89: 清理页面卸载时的所有 timer、请求和临时 URL
新增纯 TS 页面卸载清理注册表 page-cleanup-registry:统一登记 blob
临时 URL(dispose 时 revokeUrl 释放)、AbortController(abort)与
timer 清理委托(clearTimers)。dispose 幂等且后注册拒绝并计数;
revokeUrl 抛错不中断其余条目;maxTrackedUrls 上限只保留最近注册的
URL。8 个测试覆盖默认、批量、幂等、空、单元素、上限驱逐、非法 hooks
与 revoke 故障恢复。
2026-08-30 22:57:04 +08:00
huangzd1997 79961170c3 progress 88 2026-08-30 22:55:31 +08:00
huangzd1997 6600bfaa99 task-88: 解析结果前端只接收预览数据,避免大 payload 进入响应式对象
新增纯 TS 预览裁剪 parse-preview:把解析 Vo 裁剪为摘要字段
(taskId/行数统计/开关/prompt),items/groups 整包剔除,可按
previewRowLimit/previewGroupLimit 有界保留样本行供表格展示。输入
对象永不修改,taskId 非法 fail-fast,属性读取抛错时零部分结果。
BrandSimilarAsinTab 的 parseFiles 改为只接收裁剪后的预览(保留
200 行样本),数千行 items 不再进入 Vue 响应式 ref。8 个测试覆盖
默认、批量、幂等、空、单元素、截断溢出、非法输入与 getter 故障。
2026-08-30 22:55:27 +08:00
huangzd1997 abb262668c progress 87 2026-08-30 22:53:12 +08:00
huangzd1997 2da93414a5 task-87: 限制 localStorage 中任务、快照和队列数据的最大数量/字节数
新增纯 TS 有界 localStorage 包装 local-storage-limiter:maxKeys 与
maxBytes 双上限,超限驱逐最旧写入的 key(更新已存在 key 刷新新鲜度),
单条超限拒绝写入且无部分数据,存储抛错(QuotaExceededError)不污染
内部索引。重复写同 key 幂等,空 key 与不可序列化值拒绝,remove/clear
释放全部条目。8 个测试覆盖默认、批量、幂等、空、单元素、双上限驱逐、
非法输入与存储故障恢复。
2026-08-30 22:53:08 +08:00
huangzd1997 6a470d1b39 progress 86 2026-08-30 22:51:24 +08:00
huangzd1997 58e91589df task-86: 将隐藏页面轮询间隔、前台恢复和退避策略统一配置化
task-progress-config 新增统一配置 API:getTaskPollBackoffMs(attempt)
指数退避(base×2^attempt 封顶 max)、前台恢复开关与延迟
(getTaskForegroundRefreshEnabled/DelayMs)、configureTaskPolling/
resetTaskPollingConfig 运行时配置。校验失败抛错且零状态变更,
document 缺失时按可见间隔降级。useTaskProgressLoop 改用退避配置
替代硬编码 500ms 重试,前台恢复走可配置开关与延迟(含 in-flight 防
并发)。8 个测试覆盖默认、多配置、幂等、空、单字段、封顶、非法输入
与故障恢复。
2026-08-30 22:51:21 +08:00
huangzd1997 62bf1fb206 progress 85 2026-08-30 22:49:49 +08:00
huangzd1997 25d5a5a5e3 task-85: 优化 Similar ASIN 轮询与文件生成等待,避免重复 force 请求
新增纯 TS force 节流守卫 asin-force-throttle:为每个 taskId 维护 TTL
冷却窗口,窗口内不重复发 force 请求(避免反复触发后端生成文件),到期
后允许重试,任务终态后 clear 立即释放记录。BrandSimilarAsinTab 的
refreshTaskProgress 改为按 pendingFileTaskIds 逐项查守卫决定本轮是否
带 force,请求成功后整批进入冷却。8 个测试覆盖默认、批量、幂等、空、
单元素、200 任务溢出、非法输入与时钟故障恢复。
2026-08-30 22:49:45 +08:00
huangzd1997 b3f16433fc progress 84 2026-08-30 22:47:45 +08:00
huangzd1997 5caca86ad1 task-84: 优化店铺抓取队列状态合并,消除 historyItems 的线性重复查找
新增纯 TS 合并模块 merge-history-items:以 taskId→行列表 二级索引替代
原 mergeProgress 的 [...map.values()].find() 全表扫描(O(n×m)→O(n+m))。
命中语义与原实现一致(taskId 相同且 resultId 相同或 incoming 无
resultId),命中后删除旧 key 写入新 key,shopName 变化不再留下幽灵
重复条目,同批内后到条目可命中先到新增。BrandShopDataCrawlTab 的
mergeProgress 改用该模块。9 个测试覆盖默认、批量、幂等、空、单元素、
maxItems 限流、非法输入、keyOf 故障零变更与幽灵条目场景。
2026-08-30 22:47:41 +08:00
huangzd1997 5f062df3cc progress 83 2026-08-30 22:44:16 +08:00
huangzd1997 e60bd8567a task-83: 统一不同页面的轮询去重、in-flight 合并和终态清理
新增纯 TS 任务轮询协调器 task-polling-coordinator:重复 add 去重、
并发 runOnce 合并为单次请求并共享结果、markTerminal 幂等终态清理
(只回调一次)、maxTasks 上限拒绝超出条目。useTaskProgressLoop 新增
可选 coordinator 选项,add/remove/终态路径委托协调器统一处理(默认
不启用)。测试用 node:test 覆盖 8 个场景,含 3 路并发合并断言。
2026-08-30 22:44:12 +08:00
huangzd1997 a52e39ad80 progress 82 2026-08-30 22:42:12 +08:00
huangzd1997 83b93eb39b task-82: 为进度响应 Map 增加 TTL 清理与最大条目数
新增纯 TS 进度响应缓存 progress-response-cache:写入后 ttlMs 过期、
条目数超 maxEntries 驱逐最旧、读取/枚举/清理惰性移除过期条目,时钟
可注入以便测试 TTL 边界。set 对非法 key fail-fast 抛错,时钟故障时
零部分写入,clear 释放全部条目。useTaskProgressLoop 新增可选
progressCache 选项,每轮响应快照写入有界缓存(默认不启用)。
2026-08-30 22:42:08 +08:00
huangzd1997 c19f59bb9e progress 81 2026-08-30 22:39:01 +08:00
huangzd1997 9bf25765dd task-81: 建立前端任务轮询请求量、响应体大小和页面内存基线
新增纯 TS 轮询基线组件 task-polling-baseline:累计轮询请求数、每次
批量响应的总字节与单次最大响应、按条目数/字节双上限的有界内存缓存
(超限驱逐最旧条目),失败路径零状态变更。useTaskProgressLoop 新增
可选 onBaseline 选项接入基线(默认零行为变化)。测试用 Node 24 原生
type-stripping + node:test 运行(npm test),8 个用例覆盖默认路径、
批量、幂等、空输入、单元素、限流溢出、非法输入与失败恢复。
2026-08-30 22:38:51 +08:00
huangzd1997 0ce664d2b9 progress 80 2026-08-30 22:31:10 +08:00
huangzd1997 c517711169 task-80: 补充 JVM 堆、直接内存、临时磁盘和连接池容量配置说明 2026-08-30 22:30:56 +08:00
huangzd1997 143ad3f6da progress 79 2026-08-30 22:23:46 +08:00
huangzd1997 ba17e34b84 task-79: 为对象存储、数据库和队列增加故障注入测试 2026-08-30 22:23:33 +08:00
huangzd1997 42bbf4904e feat-admin-ui-interaction
Build Backend JAR / build (push) Has been cancelled
2026-08-30 22:09:22 +08:00
huangzd1997 2b613a8e5a progress 78 2026-08-30 22:01:15 +08:00
huangzd1997 4c70ca4101 task-78: 为所有外部调用增加耗时、重试、失败率和 payload 字节指标
新增 ExternalCallMetricsRecorder:通过 RestClient 拦截器统一记录
aiimage.external-call.duration(耗时)、aiimage.external-call.total
(失败率)、aiimage.external-call.payload.bytes(请求字节)与
aiimage.external-call.retry.total(重试次数);Coze/品牌检查/紫鸟
三个外部客户端全部接入,指标注册表缺失时静默降级,不改变调用语义。
2026-08-30 22:01:02 +08:00
huangzd1997 f1d1fe5c78 progress 77 2026-08-30 21:08:32 +08:00
huangzd1997 39e52858d1 task-77: 统一 Coze、品牌检查和紫鸟 HTTP 客户端的连接复用策略 2026-08-30 21:08:28 +08:00
huangzd1997 678ba57347 progress 76 2026-08-30 20:51:14 +08:00
huangzd1997 04f45bebec task-76: JSON owner 查询迁移到显式列并补充任务/状态复合索引 2026-08-30 20:51:07 +08:00
huangzd1997 e9ba3689ba progress 75 2026-08-30 20:39:35 +08:00
huangzd1997 6a4a115260 task-75: 虚拟线程任务等待队列上限与拒绝/延迟指标 2026-08-30 20:39:31 +08:00
huangzd1997 ba163aa4bd progress 74 2026-08-30 20:31:43 +08:00
huangzd1997 5105ca95c5 task-74: 隔离调度线程池、文件作业线程池和外部 Coze/图片执行池 2026-08-30 20:31:39 +08:00
huangzd1997 adf0a5ff73 progress 73 2026-08-30 20:23:09 +08:00
huangzd1997 ec9811c8a5 task-73: 本地文件作业队列 in-flight 去重和队列背压 2026-08-30 20:22:58 +08:00
huangzd1997 f190896ea7 progress 72 2026-08-30 20:01:22 +08:00
huangzd1997 baa43d80ba task-72: 文件作业数据库原子 claim,避免重复派发同一 job 2026-08-30 20:01:18 +08:00
huangzd1997 c07e26a400 progress 71 2026-08-30 19:53:50 +08:00
huangzd1997 6f32ed86e4 task-71: 清理日志改为数量与 sample ID,禁止输出超长任务 ID 列表 2026-08-30 19:53:49 +08:00
huangzd1997 f48407ec7e progress 70 2026-08-30 19:49:03 +08:00
huangzd1997 9de4603484 task-70: 历史清理改为 keyset 分页、小批量和短事务 2026-08-30 19:48:59 +08:00
huangzd1997 fb090bf80d progress 69 2026-08-30 19:30:01 +08:00
huangzd1997 5749a421cb task-69: 历史清理任务收集 transient payload 指针并提交删除队列 2026-08-30 19:29:32 +08:00
huangzd1997 54260551ee progress 68 2026-08-30 19:13:47 +08:00
huangzd1997 2de58b7afc task-68: payload 引用删除改为批量引用检查与异步物理删除
- 新增 TransientPayloadDeleteOrchestrator:提交去重入队(maxPendingDeletes 上限),
  flush 时一次性 IN 批量反查 biz_task_chunk / biz_task_scope_state,
  未引用对象交由后台线程池异步物理删除(剥 rustfs: 前缀)
- 幂等:重复提交只入队一次;保守:查询失败整批保留可重试,不误删
- 空值/非指针忽略,本地/OSS 指针不在批量删除范围(各有归属与清理路径)
2026-08-30 19:13:43 +08:00
huangzd1997 45b23b559c progress 67 2026-08-30 19:04:37 +08:00
huangzd1997 2819fb3c6c task-67: 复用 RustFS/MinIO 客户端与 HTTP 连接池
- buildClient 改为 double-check 懒加载缓存共享 MinioClient(volatile 单例),
  同一实例持有同一 OkHttpClient,连接池随实例共享,不再每次操作新建客户端
- supplier 注入路径优先且不写共享缓存,测试隔离不受污染
- 未配置/空白 endpoint 时不创建实例,拒绝操作并保持缓存为空
2026-08-30 19:04:32 +08:00
huangzd1997 f15d2e1c22 progress 66 2026-08-30 18:57:31 +08:00
huangzd1997 e2d6875ef9 task-66: 限制 RustFS 并发读写与重试的总资源预算
- 新增 aiimage.transient-storage.max-total-concurrent-operations 配置
  (默认 0 不启用):跨 upload/read/delete 的总并发预算
- executeWithRetry 入口获取一个总许可,整次操作(含全部重试)全程占用,
  重试不额外消耗,超预算立即拒绝并计入 operation=total rejected 指标
- 失败/完成后 finally 释放总许可,无残留锁;负值/0 视为未启用保持原行为
2026-08-30 18:57:26 +08:00
huangzd1997 e377814c48 progress 65 2026-08-30 18:49:59 +08:00
huangzd1997 9b1978aec8 task-65: transient payload 读取流式解压 + 解压后字节上限
- 新增 aiimage.transient-storage.max-decompressed-payload-bytes 配置
  (默认 100MB,即 2x 存储上限),覆盖 gzip 二进制与 gzip64 兼容两条路径
- decodeGzipStream 按 8KB 缓冲流式解压,累计输出超过上限立即中止并报错,
  防止压缩炸弹(zip bomb)在读取时无界膨胀内存
- 超限错误保留可识别消息(exceeds configured limit),由 resolvePayload 统一包装
2026-08-30 18:49:55 +08:00
huangzd1997 4e9c5d242e progress 64 2026-08-30 18:42:25 +08:00
huangzd1997 ca32cde4fe task-64: transient payload 压缩改为直接 gzip 二进制流上传
- RustfsObjectStorageService 新增 uploadBytes/readObjectBytes 二进制流 API
  (application/gzip),uploadText/readObjectAsString 改为其薄包装
- TransientPayloadStorageService 的 encodeStoredPayload 直接输出 gzip 字节,
  不再经过 gzip64 + Base64 文本编码(消除 33% 体积膨胀与中间字符串副本)
- 读取端按 gzip magic 识别二进制流解压;兼容旧 gzip64: 文本与历史裸文本
- 本地回落文件同步改为写二进制(Files.write),超限判定基于 gzip 后字节数
2026-08-30 18:42:19 +08:00
huangzd1997 f8e4360482 progress 63 2026-08-30 18:28:19 +08:00
huangzd1997 9c9b8a6078 task-63: 进度快照写入最小更新间隔节流(终态豁免+删除清理跟踪) 2026-08-30 18:28:15 +08:00
huangzd1997 a9cee8e9a1 progress 62 2026-08-30 18:17:55 +08:00
huangzd1997 8d91e599ab task-62: 本地任务实体缓存共享组件(容量 LRU/TTL 即时回收/定时清理)接入 8 模块 2026-08-30 18:17:52 +08:00
huangzd1997 dff38a04c7 progress 61 2026-08-30 18:00:38 +08:00
huangzd1997 8e9c79fc0e task-61: Rustfs 对象存储指标基线验收测试(计数/计时/分布/熔断/拒绝) 2026-08-30 18:00:33 +08:00
huangzd1997 7b3feb4b1a progress 60 2026-08-30 17:43:20 +08:00
huangzd1997 305b897f2a task-60: 采集模块 10k 行压测验收(结果完整性、内存与吞吐)
10k 行批量 upsert 压测验收:100 批 × 100 行恰好写入 10k 行不丢失不重复(引用 JSON 唯一);
10 chunk 分批提交总批量 SQL 调用次数恒定 100;hash 相等重复提交全跳过零写入(幂等);
batchSize=1 时 10k 次调用每批 1 行(内存受 batchSize 约束不无界累积);null/空白 ASIN
行安全跳过;前 50 批失败跳过后重试收敛到真实行数。collectdata 模块完成。
2026-08-30 17:43:13 +08:00
huangzd1997 9ec43e8922 progress 59 2026-08-30 17:38:26 +08:00
huangzd1997 7147fc464c task-59: 采集模块对象存储与批量 SQL 调用次数验证
deleteHistory 删除历史结果的对象存储调用次数验证:批量 SQL(selectList/delete)调用次数
恒定不随行数增长;RustFS 物理删除按 chunk 引用指针去重后每对象一次(旧格式逐行一次);
空历史零调用、单历史单对象、300 行 100 chunk 恰好 100 次、非法越权拒绝、依赖失败传播后
重试成功无残留。锁定 task-57 引入的去重删除语义在 deleteHistory 路径上的调用次数契约。
2026-08-30 17:38:22 +08:00
huangzd1997 8ea1577924 progress 58 2026-08-30 17:31:27 +08:00
huangzd1997 567cb1ab67 task-58: collectdata 结果明细读取失败降级(RustFS 超时跳过该 chunk,不中断其它 chunk)
chunk 级引用读取失败(RustFS 超时/不可用)时降级为跳过该 chunk 的引用行并记录 warn,
结果文件继续生成,缺失行由任务状态可观测;chunk 明细 JSON 损坏仍抛异常(数据问题不降级),
旧格式单行读取失败保持抛异常。失败 chunk 在单次调用内缓存为空哨兵,避免重复 resolve。
task-052 依赖失败测试同步更新为降级语义。
2026-08-30 17:31:21 +08:00
huangzd1997 44abcdd4ef progress 57 2026-08-30 17:20:05 +08:00
huangzd1997 5bbf601480 task-57: 删除任务/历史时先删 DB 行再物理删对象,引用计数反查基于删除后状态,共享对象跳过删除、独占对象真正释放 2026-08-30 17:20:00 +08:00
huangzd1997 c0447c908e progress 56 2026-08-30 17:06:06 +08:00
huangzd1997 adcfa28af3 task-56: 采集结果 Excel 改为临时文件+原子落位,流式写入或落位失败时清理临时文件,目标路径不残留半成品 2026-08-30 17:05:56 +08:00
huangzd1997 15269c6ed9 progress 55 2026-08-30 16:56:20 +08:00
huangzd1997 e7828dc926 task-55: 采集进度心跳改为节流/合并写,窗口内心跳只更新内存态不落库,窗口到期或任务结束路径强制持久化,避免高频 task UPDATE 2026-08-30 16:55:37 +08:00
huangzd1997 5776217c2c progress 54 2026-08-30 16:41:09 +08:00
huangzd1997 91f760f789 task-54: finalRowCount 改为任务内增量计数(upsert newlyInserted 累计),移除每 chunk 全表 COUNT(*) 2026-08-30 16:41:02 +08:00
huangzd1997 e8cedbcb50 progress 53 2026-08-30 16:30:39 +08:00
huangzd1997 97ae8a7c51 店铺数据抓取累计文件改为店铺级共享,按国家覆盖更新
同店同日在不同账号下产生多份互不相干的累计文件(唯一键含 user_id),
后台管理页每店只显示最新一份,其他账号抓的国家看起来丢失。

- V95 迁移:加 shop_key/country_codes_json/compensation_done 列,按店铺
  合并存量 daily_file 与成员行,唯一键改为 (shop_key, business_date)
- DailyFileService:findForUpdate/findOlder/acquireLock 去 user 维度,
  店铺级锁跨账号串行
- TaskService:聚合按店铺定位;applyCountryCoverage 按国家覆盖(本次
  回传的国家替换旧行,未更新的国家保留);启动补偿组件按成员快照重建
  合并文件并回填国家列表
- 管理页:country_codes 改从 daily_file.country_codes_json 取,行数用
  累计文件实际值
2026-08-30 16:30:09 +08:00
huangzd1997 ae95b294ec task-53: 采集结果 Excel 生成按 rawRows/finalRows 分段生命周期,rawRows 惰性加载避免同时驻留内存 2026-08-30 16:29:48 +08:00
huangzd1997 9ebb1a4012 progress 52 2026-08-30 16:00:37 +08:00
huangzd1997 48284be214 task-52: 生成结果文件按 chunk 一次读取
CollectDataResultDetailReader 从 biz_task_result_item 解析行:引用格式
按 pointer 缓存整 chunk 明细(同一 chunk 对象只 resolve 一次),再按
offset 取行;旧格式逐行兜底。CollectDataService.loadFinalRows 接入
reader,移除内联逐行读取循环与 detailCache。
2026-08-30 16:00:32 +08:00
huangzd1997 7f46b9f768 progress 51 2026-08-30 15:39:42 +08:00
huangzd1997 a29d6e6ce4 task-51: accepted 行序列化与 hash 批量生成
CollectDataResultDetailCodec.encodeRefsWithHash 一次迭代为整 chunk 生成
全部行引用 JSON 及其 SHA-256(offset 从 startOffset 递增),带
MAX_REFS_PER_BATCH 上限与参数校验;CollectDataResultItemBatchWriter
接入批量生成,删除逐行 encodeRef+hash 循环,同 chunk 重提结果逐字节一致。
2026-08-30 15:39:38 +08:00
huangzd1997 687bc18510 progress 50 2026-08-30 15:33:01 +08:00
huangzd1997 1127e9c8bb task-50: 结果明细批量 upsert 写入器与唯一键幂等
CollectDataResultItemBatchWriter 按唯一键 uk_task_scope_item 批量 upsert
biz_task_result_item:一次批量查询现有行(payload_hash 相等即跳过),
分批发 INSERT ... ON DUPLICATE KEY UPDATE,替代逐行 select/insert/update;
旧格式逐行 payload 升级为引用时物理删除(引用计数兜底)。CollectDataService
submitResult 接入批量写入,移除逐行 upsertResultItem。
2026-08-30 15:32:55 +08:00
huangzd1997 68ebd387be progress 49 2026-08-30 14:31:08 +08:00
huangzd1997 5919ae12e9 task-49: 结果明细从逐行 RustFS 对象改为 chunk 级 payload 存储,引用 JSON 兼容旧格式 2026-08-30 14:31:04 +08:00
huangzd1997 ed2900361c progress 48 2026-08-30 14:15:37 +08:00
huangzd1997 d4ebe1926d fix: 品牌检查过滤器多构造器显式 @Autowired,供 Spring bean 解析 2026-08-30 14:12:19 +08:00
huangzd1997 98c45486fa task-48: invalid ASIN 记录改为批量 INSERT IGNORE/upsert,唯一键扩为 (data_value, brand) 2026-08-30 14:11:59 +08:00
huangzd1997 c609ffb279 progress 47 2026-08-30 13:54:03 +08:00
huangzd1997 b92d3e688d task-47: 品牌检查结果任务内短期缓存,避免同品牌重复远程调用 2026-08-30 13:53:38 +08:00
huangzd1997 751f4b89fd progress 46 2026-08-30 13:40:09 +08:00
huangzd1997 0d99baea04 task-46: 跳过空品牌批次的无效远程品牌检查请求
新增 CollectDataBrandBatchFilter 接管品牌检查批次切分与分类:空品牌
批次不发起 checkAll 远程调用(行直接归 rejected),远程抛错整组降级
queryFailed 可恢复。service 委托查询器只做计数与无效 ASIN 落库,语义
与旧 filterByBrandCheck 完全等价。8 个测试覆盖默认/批量/幂等/空输入/
单元素/超限/非法参数/依赖失败,全量回归 720 通过。
2026-08-30 13:40:03 +08:00
huangzd1997 61f8c86b02 progress 45 2026-08-30 13:31:58 +08:00
huangzd1997 7110d1086b task-45: ASIN 去重与无效品牌查询统一为批量集合查询
新增 CollectDataBatchQuery 把 dedupe 表查询与 invalid_asin 表查询
合并为两次批量集合查询,输出与旧两段式语义等价,并返回两类过滤计数
由 service 维护 stats。8 个测试覆盖默认/批量/幂等/空输入/单元素/
超限/非法参数/依赖失败,全量回归 712 通过。
2026-08-30 13:31:52 +08:00
huangzd1997 d23485029d progress 44 2026-08-30 13:20:04 +08:00
huangzd1997 639e8b989e task-44: collectdata extra JSON 批量预序列化与内容去重
persistParsedTask 逐行调用 ObjectMapper 序列化 extra 是热点;新增
CollectDataExtraJsonCodec 批量预序列化,相同 extra 只序列化一次,
输出与逐行语义完全一致,失败行降级 {}。8 个测试覆盖去重/幂等/
空输入/单元素/容量淘汰/非法输入/序列化失败,全量回归 704 通过。
2026-08-30 13:19:15 +08:00
huangzd1997 a0a232f504 progress 43 2026-08-30 13:08:18 +08:00
huangzd1997 173287e3d6 task-43: 采集源文件查找改为确定路径/索引查询
LocalFileStorageService 新增 fileKey→文件名 有界索引(LinkedHashMap LRU,
上限 1024 淘汰最旧):saveTempFile 登记,findLocalSourceFile 优先按索引
直接构造确定路径,索引过期/进程重启时兜底枚举根层目录,结果与索引一致;
key 与索引名均校验单段字符集,防止路径穿越与索引污染。8 个用例覆盖
正常/批量/幂等/空/单元素/索引容量超限/非法输入/清理与重启降级,
mvn 全量测试通过。
2026-08-30 13:08:13 +08:00
huangzd1997 f168e23dde progress 42 2026-08-30 13:04:08 +08:00
huangzd1997 fec89b6b7b task-42: 限制采集解析的文件大小、最大行数和单 chunk 行数
新增 CollectDataParseLimits 组件并在 CollectDataService 解析/回传路径
接入:源文件大小(默认 50MB)、累计解析行数(默认 50000)、单 chunk
回传行数(默认 5000)超限即拒绝,配置经 aiimage.collect-data.* 环境变量
可调、0/负值回退默认。8 个用例覆盖正常/批量/幂等/空/单元素/边界超限/
非法配置/失败后可恢复路径,mvn 全量测试通过。
2026-08-30 13:04:02 +08:00
huangzd1997 3f8326afc4 progress 41 2026-08-30 12:58:31 +08:00
huangzd1997 33d0f02c55 task-41: 建立 Collect Data 性能基线夹具(1k/10k 行、多 chunk、品牌检测)
新增 CollectDataPerfFixture:确定性生成 1k/10k 行、多关键词多 chunk 与
品牌检测场景(成功/失败/查询失败/空 ASIN)行集合并采样 payload 字节与
chunk 划分;同一输入重复生成结果一致(幂等),行数/计数/关键词均有上限
校验。8 个用例覆盖正常/批量/幂等/空/单元素/超限/非法输入/序列化失败
降级路径,mvn 全量 681 测试通过。
2026-08-30 12:58:26 +08:00
huangzd1997 2ce37f0a1a progress 40 2026-08-30 12:53:41 +08:00
huangzd1997 7f44ca6383 task-40: 完成店铺抓取压测探针与资源比较
新增 ShopDataCrawlLoadTestProbe:并发多轮执行"生成-采样-回传-上传-锁"
流水线,产出内存峰值、耗时、DB QPS、对象存储流量与锁等待五类可比较
指标;行数/线程/轮数均有上限,注入 OSS 上传与锁获取失败验证依赖降级
可恢复且计数不残留。8 个用例覆盖正常/批量/幂等/空/单元素/超限/非法
输入/依赖失败路径,mvn 全量 672 测试通过。
2026-08-30 12:53:36 +08:00
huangzd1997 6875abaa1a progress 39 2026-08-30 12:40:15 +08:00
huangzd1997 b806ab9384 task-39: 补充删除/超时/重复回传/累计文件失败的资源清理测试
新增 ShopDataCrawlCleanupTest 11 个用例覆盖:单条/批量/空输入删除路径的
临时文件与累计对象回收、陈旧 RUNNING 任务超时终态化、分片重复回传的
payload 释放与终态拒绝、累计文件 CAS 冲突重试时上传对象回滚。

同时撤销上一提交误引入的按国家覆盖语义:rowsByCountry 恢复同国累积
(addAll),移除与之矛盾的 writeWorkbookLatestMemberWinsPerCountryOthersPreserved
测试,修复 task-22~26 批量合并回归(行数被覆盖削减)。
2026-08-30 12:16:39 +08:00
huangzd1997 6b76333159 task-39: 店铺 Excel 按国家增量更新,未提交国家保留旧数据
Build Backend JAR / build (push) Has been cancelled
rowsByCountry 由同国行累加改为覆盖语义:按成员顺序累积,
后面的结果覆盖前面同名国家的行(最新任务胜出),本次未提交的
国家从旧累计对象/成员累积中保留,不再被清空。

新增回归测试:两个成员快照(英德法 + 仅德国新行)写入 workbook 后,
英国/法国保留旧行、德国被新任务覆盖、未提交国家保持空表。
2026-08-29 23:46:22 +08:00
huangzd1997 9a8fab2ce4 progress 38 2026-08-29 23:12:06 +08:00
huangzd1997 36bed2bdc6 task-38 2026-08-29 23:11:59 +08:00
huangzd1997 a9a72c7bdf progress 37 2026-08-29 22:36:15 +08:00
huangzd1997 95e314cef4 task-37 2026-08-29 22:36:11 +08:00
huangzd1997 6f6d7be344 progress 36 2026-08-29 22:05:36 +08:00
huangzd1997 93ccb27b40 task-36 2026-08-29 22:05:30 +08:00
huangzd1997 f2546fc152 progress 35 2026-08-29 21:28:32 +08:00
huangzd1997 2f89f795f6 task-35 2026-08-29 21:28:28 +08:00
huangzd1997 add8b057d5 progress 34 2026-08-29 20:44:25 +08:00
huangzd1997 11e19ef4f1 task-34: 将 ownerInstanceId 从 JSON 查询迁移到显式列并补充索引 2026-08-29 20:44:21 +08:00
huangzd1997 790267560a progress 33 2026-08-29 20:19:17 +08:00
huangzd1997 0e4a1c1c35 task-33: 将店铺源文件 key 映射改为确定路径,取消临时目录递归扫描 2026-08-29 20:18:57 +08:00
huangzd1997 76d9558851 progress 32 2026-08-29 20:11:20 +08:00
huangzd1997 2cd5e07248 task-32: 将 task entity 本地缓存替换为有容量和过期回收的实现 2026-08-29 20:11:16 +08:00
huangzd1997 5f7457a07b progress 31 2026-08-29 20:04:26 +08:00
huangzd1997 cb4e10c87f task-31: 将任务快照改为轻量进度字段,避免每次写入完整结果 JSON 2026-08-29 20:04:22 +08:00
huangzd1997 76a51ac290 progress 30 2026-08-29 19:52:14 +08:00
huangzd1997 199345fd11 task-30: 为国家结果行建立稳定去重键,替换线性重复扫描 2026-08-29 19:52:08 +08:00
huangzd1997 6e3b43d591 progress 29 2026-08-29 19:36:34 +08:00
huangzd1997 ec28216984 task-29: 合并 scope 状态查询与更新,减少单 chunk 数据库往返
persistResultScope 复用接收前已加载的 scope,不再重复 selectOne ——
每个分片接收的 scope 查询从 2 次降为 1 次;空分片校验前移至任何
scope 查询之前,非法分片零数据库往返。任务级分布式锁保证预读 scope
在锁内不过期。
2026-08-29 19:36:30 +08:00
huangzd1997 24ea02f150 progress 28 2026-08-29 19:26:03 +08:00
huangzd1997 f1db31f813 task-28: 以 scope 计数器替代每个 chunk 的 COUNT(*) 完整统计
分片接收不再对 chunk 表执行 selectCount 全量统计:新插入分片按 scope 计数器 +1
并钳制到 chunk_total,重复提交(唯一键冲突)保持不变;分片行与 scope 计数器
作为一致性单元,状态写入失败时回滚本次插入的分片行与 payload,重试走全新插入,
避免计数器重复计数或永久欠计。任务级分布式锁串行化同一任务的接收,读改写在锁内完成。
2026-08-29 19:25:59 +08:00
huangzd1997 7f49ef596e progress 27 2026-08-29 19:11:17 +08:00
huangzd1997 23eddde770 task-27: chunk 接收改为原子插入/幂等 upsert,去掉先查后插
persistResultChunk 去除提交前的 findResultChunk 预查,直接 store payload + insert,
唯一索引 uk_task_scope_chunk 兜底幂等:重复提交命中 DuplicateKeyException 后
重查 winner 校验并清理本次重存 payload;空分片(无可处理数据)在落库前拒绝,
不创建 RustFS payload 与分片行。
2026-08-29 19:11:10 +08:00
huangzd1997 0092092dbd progress: task-26 done (completed=26) 2026-08-29 18:55:05 +08:00
huangzd1997 8ea4d2f502 task-26: 模板 workbook 大行数下的样式、图片和工作表兼容测试
writeWorkbook(模板路径)改为返回实际写入行数,与 streaming 路径一致;
新增 1000/5000 行规模兼容测试:模板表头样式保留、同 URL 图片按 pictureIndex 去重复用、
5 工作表顺序名称保持模板语义、失败行兜底 URL 文本不中断整表。
全量测试 556 通过。
2026-08-29 18:55:01 +08:00
huangzd1997 6594e1f5d7 progress: task-25 done (completed=25) 2026-08-29 18:46:44 +08:00
huangzd1997 4e4af7911a task-25: 店铺结果 workbook 的 SXSSF 流式写入路径
评估结论:SXSSF 无法访问/删除模板行,与现有模板重写流程不兼容,
故模板路径保留 XSSFWorkbook,另提供 writeWorkbookStreaming —— 空构造
SXSSFWorkbook + 自建 5 国工作表与表头,行数据按 rowAccessWindow spill 到磁盘,
写入后 dispose() 释放 spill 文件;图片嵌入复用现有链路,失败行兜底 URL 文本。
全量测试 548 通过。
2026-08-29 18:46:40 +08:00
huangzd1997 f816fed4f5 progress: task-24 done (completed=24) 2026-08-29 18:38:41 +08:00
huangzd1997 7eccbc016a task-24: 店铺图片预取增加任务级数量、字节和超时上限
ShopDataCrawlPrefetchBudget 对预取 URL 施加三重预算:数量截断(去重后按序取前 N)、
字节估算门(urlCount×avgBytes 超预算拒绝)、超时钳制(200ms/URL 估算钳到任务上限);
Excel 组装在 prefetch 前应用预算,未预取 URL 由 embed 兜底直接下载。
全量测试 540 通过。
2026-08-29 18:38:37 +08:00
huangzd1997 a9cbd18246 progress: task-23 done (completed=23) 2026-08-29 18:34:05 +08:00
huangzd1997 70d724382d task-23: 图片嵌入成功后立即释放外部缩略图字节副本
BoundedImageCache.release(url) 移除条目并扣减字节计数,byte[] 可被 GC 回收;
embedImage 在 addPicture 成功后立即释放,同一 URL 后续行复用 pictureIndex 不重复嵌入。
全量测试 532 通过。
2026-08-29 18:34:02 +08:00
huangzd1997 4a11fd612e progress: task-22 done (completed=22) 2026-08-29 18:29:29 +08:00
huangzd1997 6d488515ca task-22: 店铺 Excel 图片缓存替换为有界字节缓存
BoundedImageCache(字节预算+条目上限,FIFO 淘汰,超预算单图拒绝)替换
ShopDataCrawlExcelAssemblyService 中的无界 ConcurrentHashMap;单图超预算时
embed 走原有直接下载兜底。全量测试 524 通过。
2026-08-29 18:29:25 +08:00
huangzd1997 064e13c132 progress: task-21 done (completed=21) 2026-08-29 18:24:14 +08:00
huangzd1997 81da7a182e task-21: 建立店铺抓取性能基线夹具(1k/5k 行、多国家、图片成功/失败)
ShopDataCrawlPerfFixture 提供单店铺多国家抓取结果的确定性生成器:
- generateItems:1k/5k 行、1-5 国家、图片成功/失败(前 N 行无缩略图)场景;
- samplePayload:行数/chunk 数/payload 字节/图片成功与失败行数采样。
全量测试 516 通过。
2026-08-29 18:24:10 +08:00
huangzd1997 3d5fd42bfa progress: task-20 done (completed=20) 2026-08-29 18:18:37 +08:00
huangzd1997 29b6353d7e task-20: Similar ASIN 端到端压测、GC 分析与结果文件兼容回归
SimilarAsinPerfFixture 新增三个功能点:
- endToEndBenchmark:生成→分 chunk→序列化,记录行数/chunk 数/payload 字节/耗时/吞吐/峰值堆;
- gcStressAnalysis:多轮生成/序列化/释放循环,采样 GC 计数差与堆峰值;
- compatRoundTrip:payload 序列化往返恢复全量行并校验字段稳定(结果文件兼容回归)。
全量测试 508 通过。
2026-08-29 18:18:24 +08:00
huangzd1997 9b5873bb84 progress: task-19 done (completed=19) 2026-08-29 18:11:28 +08:00
huangzd1997 77ae8b2823 task-19: Coze 请求/响应与 Python 回传日志改采样、截断、DEBUG
- 新增 SimilarAsinLogSupport 纯函数:truncate(2000 前缀+长度后缀,代理对安全)
  与 shouldLog(每 N 次采样,计数 0 恒采样)
- Coze 请求 body 与 submit 响应正文日志降 DEBUG + 截断;
  history 轮询响应降 DEBUG + 每 20 次记一次完整正文,其余只记状态
- Python 回传逐行日志降 DEBUG + 每 20 行采样一行,大任务日志量降到 5%
2026-08-29 18:11:24 +08:00
huangzd1997 07e99a5fa8 progress: task-18 done (completed=18) 2026-08-29 18:02:54 +08:00
huangzd1997 92858acb4d task-18: 统一图片 spool 生命周期,超时/取消/异常路径删除临时文件
- ImageSpool 增加 closed 状态:close 幂等、close 后 put 拒绝且消息可识别,
  杜绝关闭后再写入导致目录删除失败
- 长预算 prefetchToDisk 任务体补 put 前中断检查:deadline/中断取消后不再
  产生新临时文件,close 可完整删除目录(与 best-effort 路径对齐)
- 长预算路径并入测试 hook 探测,与短预算路径行为一致,生命周期可测
2026-08-29 18:02:50 +08:00
huangzd1997 e1217c9c85 progress: task-17 done (completed=17) 2026-08-29 17:55:06 +08:00
huangzd1997 795dd1084c task-17: 解码采样推广全格式、子采样后像素上限、JPEG 质量估算搜索
- sourceSubsampling 通用化:PNG 等非 JPEG 格式也按源长边取 2 的幂子采样,
  reader 忽略采样参数时记录日志并按全量解码像素校验
- 新增 MAX_DECODED_PIXELS(2400^2) 子采样后解码像素上限,源像素超限先拒绝,
  子采样仍超限再升采样因子,解码像素始终受控,36MP 源不再全量解码
- 质量搜索由固定阶梯 {0.75,0.65,0.55} 改为估算(字节比例钳制 [0.45,0.75]),
  最坏编码 9 次降到 6 次,典型 1-2 次即命中,降低 CPU 峰值
2026-08-29 17:55:00 +08:00
huangzd1997 423666ef99 progress: task-16 done (completed=16) 2026-08-29 17:37:25 +08:00
huangzd1997 0e3dbe450f task-16: 图片预取改短预算 best-effort,超时取消在途并回退 URL
prefetchToDiskBestEffort 在 budgetSeconds 内尽力预取,预算耗尽即取消
在途任务并返回未预取数量;缺图单元格由既有 fallback 直接写 URL。
put 前检查中断标志,避免取消后写盘与 spool close 竞态产生残留文件。
预算通过 aiimage.similar-asin.image-prefetch-budget-seconds 配置(默认 60s),
长预算后台预热路径 prefetchToDisk 行为不变。
2026-08-29 17:37:11 +08:00
huangzd1997 f517b7585f progress: task-15 done (completed=15, rounds=15) 2026-08-29 17:24:31 +08:00
huangzd1997 dc69b002db task-15: async batched last_used_at touch refresh 2026-08-29 17:24:25 +08:00
huangzd1997 fb10077557 progress: task-14 done (completed=14, rounds=14) 2026-08-29 17:16:47 +08:00
huangzd1997 d1ea8feb6f task-14: batch read image db cache and touch only actual hits 2026-08-29 17:16:40 +08:00
huangzd1997 4030897d49 progress: task-13 done (completed=13, rounds=13) 2026-08-29 17:05:59 +08:00
huangzd1997 e201b13301 task-13: cap chunk merge row count and payload bytes with orphan fallback 2026-08-29 17:05:49 +08:00
huangzd1997 cbe0ec8bb2 task-12: mark done in progress 2026-08-29 16:46:38 +08:00
huangzd1997 4d91146256 task-12: extend coze result buffering beyond poll path
- bufferCozeRowsOrMerge: unified DONE result persist entry point; buffers to
  transient storage when toggle on, falls back to immediate chunk merge on
  failure (result never lost), no-op on empty input
- submit/retry synchronous immediate DONE results now buffer too (previously
  always merged immediately); submit path persists a DONE scope state row to
  carry the buffer pointer (persistImmediateCozeDoneState)
- poll path drops the batchTotal>1 gate: single-batch tasks also buffer
- CozeCandidate/CozeBatchContext records package-private for test access
2026-08-29 16:46:29 +08:00
huangzd1997 59ee3c8154 progress: task-11 done (completed=11, rounds=11) 2026-08-29 16:17:27 +08:00
huangzd1997 3d085c1605 task-11: Coze 结果合并前按稳定 rowKey HashSet 去重,消除 O(n²) 重复处理 2026-08-29 16:17:12 +08:00
huangzd1997 d64ba3a827 progress: task-10 done (completed=10, rounds=10) 2026-08-29 16:07:49 +08:00
huangzd1997 1ccf4f74ef task-10: chunk 结果建立 rowKey 批量索引,消除跨 chunk 线性扫描
mergeCozeRowsIntoChunk 先 indexRowsByChunkKey 建立 rowKey→chunkKey
索引,assignCozeRowsToChunks 按 O(1) 查找分配行归属,保留原有
命中/fallback/orphan 语义与顺序稳定性,每 chunk 只读一次 payload。
2026-08-29 16:07:45 +08:00
huangzd1997 17a3292c78 progress: task-9 done (completed=9, rounds=9) 2026-08-29 15:52:57 +08:00
huangzd1997 99c0b7dd75 task-9: chunk 查询改为批量 keyset 分页,保持低内存读取
loadChunksKeyset 按 id 递增分批拉取(每批 pageSize),最后按
chunkIndex 升序合并,避免超大任务一次 selectList 全量载入 chunk
元数据。surefire fork 堆显式限制 1536m 防止与主 JVM 叠加挤爆内存。
2026-08-29 15:52:46 +08:00
huangzd1997 3b051bbafe task-8: WorkbookFactory 输入解析改为受控读取,验证超大 Excel 失败提示
解析前用 ZipFile 中央目录探测 xlsx(zip) 条目数与解压总字节(不读压缩
内容),超过 maxWorkbookZipEntries(20000)/maxWorkbookUncompressedBytes
(512MB) 立即拒绝并给出可识别提示;非 zip/损坏文件跳过探测交给
WorkbookFactory 兜底转业务异常。0/负值配置回退默认。新增 8 个测试覆盖
正常路径、多文件、幂等、空输入、单行、解压超限、条目超限、损坏文件、
依赖失败恢复。
2026-08-29 15:11:53 +08:00
huangzd1997 68b7d9a4a4 task-7: 限制单文件大小、最大行数和最大字段长度,防止解析任务无界增长
新增 maxSourceFileBytes(50MB)/maxParseRows(50000)/maxFieldLength(2000)
三个配置项:文件超限在解析入口拒绝(异常消息可识别)、行数超限拒绝、
超长单元格字段截断。0/负值配置回退默认。新增 8 个测试覆盖正常路径、
多文件、幂等、空文件、单行、边界(恰好=上限通过、超限拒绝)、
非法输入(文件超限/字段截断)、依赖失败恢复。
2026-08-29 15:08:14 +08:00
huangzd1997 db6e8f0ce8 task-6: 分组数据改为索引/范围引用,避免 groups 嵌套复制完整行对象
buildParsedGroups 只写 [startIndex, endIndex) 半开区间引用(同 baseId 行在
items 中天然连续),行对象仅存在于 items 一次;resolveAllRows 优先按引用
展开并安全跳过越界/非法区间;响应组仍内嵌预览行兼容前端。旧 payload 内嵌
items 格式继续可读。新增 8 个测试覆盖引用写入、批量、幂等、空输入、单组、
越界 clamp、非法区间、依赖失败恢复。
2026-08-29 15:02:15 +08:00
huangzd1997 16bec1c0fa task-5: 预览行数量改为配置驱动并做边界校验
解析响应预览上限从硬编码常量改为 SimilarAsinProperties.parseResponsePreviewLimit,
0/负值回退默认 100,超过 1000 clamp 到 1000 防止误配导致响应体无界膨胀。
新增 8 个测试覆盖默认路径、自定义值、幂等、空文件、单行、超限 clamp、非法配置回退、依赖失败恢复。
2026-08-29 14:48:01 +08:00
huangzd1997 026aa4e0c3 task-4: 解析接口只返回固定数量预览行,完整行仅保存在后端任务载荷
parseAndCreateTask 响应 items/groups 改为 buildResponsePreviewRows/Groups 裁剪
到 PARSE_RESPONSE_PREVIEW_LIMIT(100) 行:大文件(5000行)响应体不再携带全量行,
前端/队列只依赖统计字段与 taskId,Python 通过 parsed-payload 接口拉全量。
groups 预览副本保留 itemCount 与行级字段,字段完整且顺序稳定。
8 个测试覆盖 150/5000/1/100/101 行、空文件、非法输入、存储失败恢复与临时文件清理。
2026-08-29 14:43:08 +08:00
huangzd1997 9f8bdecc9e task-3: 统一解析载荷全量行恢复逻辑,新旧结构均可恢复
新增 SimilarAsinTaskService.resolveAllRows(payload):优先 items(新规范结构)、
其次 allItems(旧结构)、最后 groups 展开(最旧结构),并收敛 rowCount/
loadAllRowsByBaseId/hydrateParsedPayloadRows/两条 assemble 路径的重复 fallback 链。
旧 payload(含 allItems 或仅 groups)仍可恢复全量行,行数、顺序不丢失。
9 个测试覆盖默认/批量/幂等/空/单行/超限/新旧 JSON 反序列化/组展开顺序。
2026-08-29 14:36:15 +08:00
huangzd1997 8c84ff3394 task-2: 解析载荷改为单一规范行集合,消除 allItems 重复序列化
SimilarAsinParsedPayloadDto.allItems 标记 @JsonInclude(NON_EMPTY) 并仅作反序列化
兼容字段(新写入不再输出);buildParsedPayloadJson 只写 items 一份全量行,
消除每任务双倍行序列化的内存与 payload 体积。读取侧 getAllItems() 消费点保留
以兼容旧载荷(task-3 再统一收敛)。9 个测试覆盖默认/批量/幂等/空/单行/超限/
旧格式吸收/依赖失败恢复。
2026-08-29 14:32:11 +08:00
huangzd1997 2039acdfe6 task-1: 建立 Similar ASIN 性能基线夹具 (1000/5000行、图片开关、chunk与payload采样)
新增 SimilarAsinPerfFixture 确定性夹具:按 sourceFileKey+rowIndex 派生字段,
支持 0/1/1000/5000 行、图片开关两种模式、chunk 划分与 payload 字节采样;
空输入返回空、超限(>5000行/非法chunk/空key)抛 IllegalArgumentException。
含 10 个测试覆盖默认路径/批量/幂等/边界/非法输入/依赖失败恢复。
2026-08-29 14:22:07 +08:00
huangzd1997 322905607a 修复店铺任务数据覆盖bug
Build Backend JAR / build (push) Has been cancelled
2026-08-29 00:16:47 +08:00
huangzd1997 79596a970c 采集数据进度条改为按关键词计算:processedRows/totalRows,标签改为关键词进度
Build Backend JAR / build (push) Has been cancelled
2026-08-28 11:43:51 +08:00
huangzd1997 ea0a319c27 品牌页前端工具菜单新增「ASIN变体采集」入口
Build Backend JAR / build (push) Has been cancelled
2026-08-27 05:10:51 -04:00
huangzd1997 d643ae156a 后台用户管理菜单权限目录:加载增加自动重试与失败提示/重新加载,创建编辑失败时自动恢复
Build Backend JAR / build (push) Has been cancelled
2026-08-27 05:09:40 -04:00
huangzd1997 75f23d4568 统一结果文件下载 URL 生成:历史记录/上传回包等漏网点改用 generateFreshDownloadUrl,result/ 前缀对象走 download 域名
Build Backend JAR / build (push) Has been cancelled
2026-08-26 03:58:29 -04:00
huangzd1997 18db20099a OSS 结果文件下载分流:新增 aiimage.oss.download-endpoint 配置,result/ 前缀对象生成独立下载域名直链(默认未配置时回退原行为)
Build Backend JAR / build (push) Has been cancelled
2026-08-26 13:37:11 +08:00
huangzd1997 7b238522ed 去重导出列固定顺序为 id/ASIN/国家/价格/品牌;QueryAsin 按店铺加载数据并修正前端回退逻辑
Build Backend JAR / build (push) Has been cancelled
2026-08-25 22:38:38 +08:00
huangzd1997 c287fe01a8 品牌去重默认勾选列调整为 id/ASIN/国家/价格/品牌
Build Backend JAR / build (push) Has been cancelled
2026-08-25 22:05:35 +08:00
huangzd1997 7b81b7aa01 品牌去重默认勾选列调整为 ASIN/国家/价格/SKU ID/品牌
Build Backend JAR / build (push) Has been cancelled
2026-08-25 22:00:33 +08:00
huangzd1997 427a8cb79f 修复:JWT 密钥未配置时使用内置默认密钥,与桌面客户端保持一致 2026-08-25 22:00:30 +08:00
huangzd1997 5f519f9cd5 性能优化:N+1查询改批量、串行远程调用并发化、紫鸟索引巡检批量回写
Build Backend JAR / build (push) Has been cancelled
2026-08-25 19:42:43 +08:00
huangzd1997 338493ecaa 安全加固:CORS白名单、JWT密钥自动生成、SSRF防护、路径遍历与错误信息泄露修复
Build Backend JAR / build (push) Has been cancelled
2026-08-25 18:05:28 +08:00
huangzd1997 c8fb93ff29 Redis 改为哨兵模式,双节点接入 A/B 机哨兵集群(mymaster)
Build Backend JAR / build (push) Has been cancelled
2026-08-25 15:33:50 +08:00
huangzd1997 a11f44664f 还原ASIN变体采集入口,仅保留变体分析移除
Build Backend JAR / build (push) Has been cancelled
2026-08-24 23:21:53 +08:00
huangzd1997 9ba7181212 导航变体分析改为ASIN变体采集入口,修复AiAssetDropzone类型
Build Backend JAR / build (push) Has been cancelled
2026-08-24 23:20:54 +08:00
huangzd1997 5acf3c79ed 移除品牌页导航栏的变体分析入口
Build Backend JAR / build (push) Has been cancelled
2026-08-24 22:48:03 +08:00
huangzd1997 205b0b71b4 数据去重默认勾选列增加品牌/SKU ID/发货类型
Build Backend JAR / build (push) Has been cancelled
2026-08-24 20:13:14 +08:00
huangzd1997 bc8870f957 移除
Build Backend JAR / build (push) Has been cancelled
2026-08-24 00:08:13 +08:00
huangzd1997 a659132469 去重总数据国家限定五国并优化筛选布局
- 国家仅保留德国/英国/法国/意大利/西班牙,移除美国及US映射
- 保留服务器已有 V90 迁移,新增 V91 添加 country 列及索引
- ASIN列表筛选区改为两行布局:查询条件+按钮在上,日期+导出在下
2026-08-24 00:03:28 +08:00
huangzd1997 8712df2645 后台去重数据新增国家 2026-08-23 22:50:58 +08:00
huangzd1997 5a750be066 Merge branch 'master' of https://git.aishufu.top/super/crawler-plugin 2026-08-23 22:06:11 +08:00
supernijia 159d52194c 更新任务存储、权限与货源查询流程
Build Backend JAR / build (push) Has been cancelled
2026-08-22 21:23:01 +08:00
huangzd1997 b00ea71c1b 换设备重新绑定 2026-08-22 16:06:05 +08:00
supernijia 7a7f1dfa21 完善任务存储、权限及货源查询流程
Build Backend JAR / build (push) Has been cancelled
2026-08-14 22:49:15 +08:00
supernijia 5b1ccad40e 后台更新 服务优化
Build Backend JAR / build (push) Failing after 16m54s
2026-08-11 14:50:21 +08:00
supernijia 38216a1885 处理后台新需求
Build Backend JAR / build (push) Failing after 16m58s
2026-08-09 20:08:39 +08:00
supernijia f7e26ee266 Merge branch 'master' of https://git.aishufu.top/super/crawler-plugin
Build Backend JAR / build (push) Failing after 4s
2026-08-06 01:11:58 +08:00
supernijia 28e7fce11c 新需求更新 同步更新 2026-08-06 01:11:54 +08:00
123buzhidao56 a821d306ac 上传
Build Backend JAR / build (push) Failing after 1m31s
2026-08-03 09:26:00 +08:00
123buzhidao56 18db4f80bb Merge branch 'master' of https://git.aishufu.top/super/crawler-plugin
Build Backend JAR / build (push) Failing after 3s
2026-08-03 09:18:15 +08:00
DevOps db1f7f2238 Add Gitea Actions workflow
Build Backend JAR / build (push) Failing after 59s
2026-08-03 02:46:56 +08:00
123buzhidao56 4775748447 modified: backend/ali_oss.py
modified:   backend/config.py
2026-07-31 14:36:08 +08:00
supernijia 9048bbb7f8 处理数据量binlog问题 2026-07-28 15:49:41 +08:00
supernijia 7c3c9e53a0 菜单修改优化 2026-07-28 13:40:19 +08:00
supernijia 4ddb8b47b0 完成上架相关优化、oss迁移 2026-07-25 17:57:34 +08:00
supernijia 8ab36b1aaf 上架需求增加 2026-07-25 09:58:29 +08:00
supernijia f1b7a7aae8 优化布局 2026-07-24 13:26:37 +08:00
super bca1335dc6 后端优化,增加新需求 2026-07-21 19:53:47 +08:00
super ba48bbc6af 更新ASIN库新需求 2026-07-20 20:12:38 +08:00
super cbde22ec79 视频任务管理更新 2026-07-19 22:23:26 +08:00
super 69784b8d32 添加新需求 2026-07-16 13:12:46 +08:00
super 8543dad514 修复后端BUG 2026-07-14 22:11:19 +08:00
super 8a9126e626 提交昨晚更新改动 2026-07-14 12:50:17 +08:00
super d8ca8de537 完成视频部分的前后端 2026-07-11 19:42:42 +08:00
super aab4ce942c 更新带货视频工作流接口和页面 2026-07-09 00:27:49 +08:00
super 0ecf5cd45a 后端优化修复问题 2026-06-18 18:53:16 +08:00
super 021b0c618b 修复图片下载问题 2026-06-16 22:19:55 +08:00
super f44110fae5 新增数字人版本管理 2026-06-14 19:00:55 +08:00
super ac19637ad6 处理修复BUG 2026-06-14 16:48:20 +08:00
super 8672668c33 处理下载为公共模块 2026-06-12 13:40:29 +08:00
super 17236265c6 修复删除asinBUG 2026-06-11 20:37:05 +08:00
super c9efdf8b0e 修复菜单消失 2026-06-10 17:52:58 +08:00
super c3d43aa26a 更新新需求-采集 2026-06-09 21:07:50 +08:00
super b0462df3c1 更新新模块内容 更新新需求 2026-06-09 21:07:28 +08:00
super 967eedcad7 提交更新 2026-06-08 18:31:55 +08:00
super 98e0e54309 删除不必要模块 2026-06-08 11:51:08 +08:00
super eeb27e21ed 删除本地APP项目 2026-06-08 11:49:46 +08:00
super c85e5b278f 新增内容,新增拉起软件层 2026-06-08 09:19:15 +08:00
super 8ab647c419 提交更改 2026-06-05 21:25:03 +08:00
super 95ccb00d25 fix: reload similar asin chunks after coze flush 2026-06-05 21:18:26 +08:00
super ee9cf5f8c6 fix brand result submission lock wait 2026-06-05 19:30:20 +08:00
super e98a1a1207 feat: update task routing and coze handling 2026-06-03 17:14:50 +08:00
super ea37d82d73 合并分支 2026-05-31 09:28:48 +08:00
super 9835831415 更新地址 更新后端 2026-05-29 22:53:44 +08:00
super 080625567b 同步 Gitee 应用代码更新 2026-05-29 19:47:23 +08:00
super 266c0f17c1 完成这个地址替换 2026-05-29 19:35:55 +08:00
super 225d13fb6e 提交优化更新 2026-05-29 16:49:18 +08:00
super 2ed1250604 增加公共下载进度、增加接收SKU、密钥分别存放 2026-05-28 16:41:20 +08:00
super ca4a2cd07a python端登录完成 2026-05-27 12:41:59 +08:00
super 73ac9187a6 提交货源流程优化 2026-05-25 22:16:50 +08:00
super 7503e3fa8b 提交货源图片和相似ASIN优化 2026-05-24 21:59:21 +08:00
super 532438faba 提交最新的优化结果 2026-05-24 12:42:53 +08:00
super a1376b51b0 优化图片尺寸 2026-05-24 02:31:58 +08:00
super 1e087c1aae 提交登录修改 2026-05-23 18:32:45 +08:00
super 2e2de02476 Merge gitee/master into local master (sync from old repo)
# Conflicts:
#	app/web_source/admin.html
#	app/web_source/brand-旧.html
#	app/web_source/home.html
#	app/web_source/index.html
#	app/web_source/login.html
#	backend/web_source/login.html
#	web_source/templates_backup/login.html
2026-05-23 12:00:12 +08:00
super aeb4e1710c chore: 从 gitee 旧仓库恢复资源和软件更新包 2026-05-23 11:56:36 +08:00
super b4b80cb572 更新这个货源 2026-05-22 09:41:31 +08:00
super 70e902e7ea 更新这个货源 2026-05-22 09:41:31 +08:00
super 14cebf22c3 提交一些更改 2026-05-20 09:05:28 +08:00
super 73d25fcbcb 提交一些更改 2026-05-20 09:05:28 +08:00
super 01ecde45c5 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-05-15 16:06:15 +08:00
super a2ebfc0b81 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-05-15 16:06:15 +08:00
super 1dc2cac19a 修改完善这个专利部分 2026-05-15 16:06:12 +08:00
super 14db1e0cb1 修改完善这个专利部分 2026-05-15 16:06:12 +08:00
铭坤 01f4dbb83a modified: amazon/similar_asin.py 2026-05-15 11:33:02 +08:00
铭坤 0d63d6d75a modified: amazon/similar_asin.py 2026-05-15 11:33:02 +08:00
铭坤 fe692fcd1d modified: amazon/chrome_base.py
modified:   amazon/detail_spider.py
	modified:   amazon/match_action.py
	modified:   amazon/similar_asin.py
	deleted:    amazon/user_data/chrome_data/BrowserMetrics-spare.pma
	deleted:    amazon/user_data/chrome_data/BrowserMetrics/BrowserMetrics-69FAEF07-558.pma
	deleted:    amazon/user_data/chrome_data/Crashpad/metadata
	deleted:    amazon/user_data/chrome_data/Crashpad/settings.dat
2026-05-13 16:51:29 +08:00
铭坤 79b177b345 modified: amazon/chrome_base.py
modified:   amazon/detail_spider.py
	modified:   amazon/match_action.py
	modified:   amazon/similar_asin.py
	deleted:    amazon/user_data/chrome_data/BrowserMetrics-spare.pma
	deleted:    amazon/user_data/chrome_data/BrowserMetrics/BrowserMetrics-69FAEF07-558.pma
	deleted:    amazon/user_data/chrome_data/Crashpad/metadata
	deleted:    amazon/user_data/chrome_data/Crashpad/settings.dat
2026-05-13 16:51:29 +08:00
super 18b0c2d211 软件前端更新 2026-05-12 23:25:12 +08:00
super e4e01c1686 软件前端更新 2026-05-12 23:25:12 +08:00
super 648e7d2f14 后台管理接口修复 后端BUG修复 2026-05-12 21:03:42 +08:00
super 0d78d63437 后台管理接口修复 后端BUG修复 2026-05-12 21:03:42 +08:00
super 289b1c67ce 提交货源采集更新 2026-05-10 01:00:08 +08:00
super 5c990e651e 提交货源采集更新 2026-05-10 01:00:08 +08:00
super 52095eb992 更新处理相关内容 2026-05-09 00:20:52 +08:00
super a4e4745921 更新处理相关内容 2026-05-09 00:20:52 +08:00
super a2d0bd3c1c Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-05-07 16:22:42 +08:00
super b9275bc174 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-05-07 16:22:42 +08:00
super 683a3934fc 提交打包 2026-05-07 16:21:35 +08:00
super e5d0b2d9ab 提交打包 2026-05-07 16:21:35 +08:00
铭坤 b0514c3e9a modified: amazon/price_match.py
modified:   config.py
2026-05-07 11:14:15 +08:00
铭坤 d618a5abf0 modified: amazon/price_match.py
modified:   config.py
2026-05-07 11:14:15 +08:00
铭坤 8be12ca9bc new file: requirements.txt 2026-05-07 11:00:44 +08:00
铭坤 5ca46b0a57 new file: requirements.txt 2026-05-07 11:00:44 +08:00
super afeeb8327c 更新 2026-05-06 23:00:57 +08:00
super a7d8f8be6c 同步更新 2026-05-06 23:00:39 +08:00
super 4d2da94692 同步更新 2026-05-06 23:00:39 +08:00
super 8cd1a4e2b1 更新外观模块 2026-05-06 22:41:26 +08:00
super b746812e23 更新外观模块 2026-05-06 22:41:26 +08:00
铭坤 3fbbf87c10 modified: .env
modified:   amazon/approve.py
	modified:   amazon/chrome_base.py
	modified:   amazon/detail_spider.py
	modified:   amazon/main.py
	modified:   amazon/price_match.py
	modified:   amazon/similar_asin.py
	modified:   amazon/tool.py
	new file:   amazon/user_data/chrome_data/BrowserMetrics-spare.pma
	new file:   amazon/user_data/chrome_data/BrowserMetrics/BrowserMetrics-69FAEF07-558.pma
2026-05-06 22:30:44 +08:00
铭坤 b0e97f21a4 modified: .env
modified:   amazon/approve.py
	modified:   amazon/chrome_base.py
	modified:   amazon/detail_spider.py
	modified:   amazon/main.py
	modified:   amazon/price_match.py
	modified:   amazon/similar_asin.py
	modified:   amazon/tool.py
	new file:   amazon/user_data/chrome_data/BrowserMetrics-spare.pma
	new file:   amazon/user_data/chrome_data/BrowserMetrics/BrowserMetrics-69FAEF07-558.pma
2026-05-06 22:30:44 +08:00
super a00ff1804c 提交更新 2026-05-06 00:01:49 +08:00
super c3810fdb7b 提交更新 2026-05-06 00:01:49 +08:00
super 203937335d 处理一些合并冲突 2026-05-05 14:11:35 +08:00
super b16c63225f 处理一些合并冲突 2026-05-05 14:11:35 +08:00
铭坤 710b953120 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin
modified:   amazon/detail_spider.py
	modified:   amazon/main.py
2026-05-04 19:17:11 +08:00
铭坤 45a45dc0fe Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin
modified:   amazon/detail_spider.py
	modified:   amazon/main.py
2026-05-04 19:17:11 +08:00
铭坤 3ca569ed1e new file: amazon/amazon_base.py
modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	new file:   amazon/chrome_base.py
	modified:   amazon/del_brand.py
	modified:   amazon/detail_spider.py
	new file:   "amazon/detail_spider_\345\244\207\344\273\275.py"
	modified:   amazon/main.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	new file:   amazon/similar_asin.py
	modified:   app.py
	new file:   assets/appearance-patent-Br1dtmol.css
	new file:   assets/appearance-patent-D1DgeYhe.css
	new file:   assets/delete-brand-BfMLVSQU.css
	new file:   assets/patrol-delete-BAzbYtgc.css
	new file:   assets/price-track-Hozgt_em.css
	new file:   assets/product-risk-CbX7bwZi.css
	new file:   assets/query-asin-B4RsOiza.css
	new file:   assets/shop-match-B2HWAgBY.css
	modified:   main.py
2026-05-04 19:15:50 +08:00
铭坤 c315bb350c new file: amazon/amazon_base.py
modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	new file:   amazon/chrome_base.py
	modified:   amazon/del_brand.py
	modified:   amazon/detail_spider.py
	new file:   "amazon/detail_spider_\345\244\207\344\273\275.py"
	modified:   amazon/main.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	new file:   amazon/similar_asin.py
	modified:   app.py
	new file:   assets/appearance-patent-Br1dtmol.css
	new file:   assets/appearance-patent-D1DgeYhe.css
	new file:   assets/delete-brand-BfMLVSQU.css
	new file:   assets/patrol-delete-BAzbYtgc.css
	new file:   assets/price-track-Hozgt_em.css
	new file:   assets/product-risk-CbX7bwZi.css
	new file:   assets/query-asin-B4RsOiza.css
	new file:   assets/shop-match-B2HWAgBY.css
	modified:   main.py
2026-05-04 19:15:50 +08:00
super 111f30d150 异常记录检测修改 2026-05-04 19:04:55 +08:00
super 6d398b66bc 异常记录检测修改 2026-05-04 19:04:55 +08:00
super f46c231323 稳定组成这个文件优化 2026-05-02 16:40:13 +08:00
super 934919c699 稳定组成这个文件优化 2026-05-02 16:40:13 +08:00
super 12d84a22e4 更新 2026-05-02 09:31:14 +08:00
super 9d4810eace Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-05-02 09:29:43 +08:00
super dc457aff9e Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-05-02 09:29:43 +08:00
super 3ce66a59ee 提交更新 2026-05-02 09:28:26 +08:00
super 578847d596 提交更新 2026-05-02 09:28:26 +08:00
koko 147b324658 chore: serve bundled assets from app directory 2026-05-02 02:12:14 +08:00
koko 6416c14f20 chore: serve bundled assets from app directory 2026-05-02 02:12:14 +08:00
koko e47c87f3a3 chore: remove stale web assets 2026-05-02 02:07:13 +08:00
koko add6e6aeb5 chore: remove stale web assets 2026-05-02 02:07:13 +08:00
koko 1ecce13814 fix: update patrol delete progress handling 2026-05-02 02:03:49 +08:00
koko 7968cef8c3 fix: update patrol delete progress handling 2026-05-02 02:03:49 +08:00
koko 7c2b154c20 Merge patrol delete tests and remove pycache artifacts 2026-05-01 22:46:11 +08:00
koko 34148b5d8a Merge patrol delete tests and remove pycache artifacts 2026-05-01 22:46:11 +08:00
koko 7ba916f00c Merge branch 'dev/koko'
# Conflicts:
#	app/amazon/patrol_delete.py
2026-05-01 22:41:09 +08:00
koko 79e408333d Merge branch 'dev/koko'
# Conflicts:
#	app/amazon/patrol_delete.py
2026-05-01 22:41:09 +08:00
koko af4f4a9ed4 Fix patrol delete condition handling 2026-05-01 22:36:37 +08:00
koko 74a7cd22b0 Fix patrol delete condition handling 2026-05-01 22:36:37 +08:00
super aece8123c3 完善多店铺开启多窗口、外观进度条等 2026-05-01 21:09:54 +08:00
super e1cca219b8 完善多店铺开启多窗口、外观进度条等 2026-05-01 21:09:54 +08:00
super 70658041a5 更新处理这个外观部分 2026-05-01 00:09:14 +08:00
super 4419c5bacd 更新处理这个外观部分 2026-05-01 00:09:14 +08:00
铭坤 668226a99d modified: amazon/__pycache__/price_match.cpython-39.pyc
modified:   amazon/price_match.py
	modified:   assets/appearance-patent.js
	modified:   assets/delete-brand.js
	modified:   assets/patrol-delete.js
	modified:   assets/price-track.js
	modified:   assets/product-risk.js
	modified:   assets/query-asin.js
	modified:   assets/shop-match.js
	modified:   new_web_source/delete-brand.html
2026-04-30 21:57:37 +08:00
铭坤 4eec0dd5a4 modified: amazon/__pycache__/price_match.cpython-39.pyc
modified:   amazon/price_match.py
	modified:   assets/appearance-patent.js
	modified:   assets/delete-brand.js
	modified:   assets/patrol-delete.js
	modified:   assets/price-track.js
	modified:   assets/product-risk.js
	modified:   assets/query-asin.js
	modified:   assets/shop-match.js
	modified:   new_web_source/delete-brand.html
2026-04-30 21:57:37 +08:00
koko b315d11c28 Merge origin master into local master 2026-04-30 21:46:00 +08:00
koko 8e60f50616 Merge origin master into local master 2026-04-30 21:46:00 +08:00
koko 72faf0433a Harden patrol delete logging 2026-04-30 21:43:15 +08:00
koko f85e3be40e Harden patrol delete logging 2026-04-30 21:43:15 +08:00
koko 3616d64735 Merge patrol delete changes into master 2026-04-30 21:40:35 +08:00
koko 7f9116f12a Merge patrol delete changes into master 2026-04-30 21:40:35 +08:00
super 01bae23df5 修复商品风险多店铺问题 2026-04-30 21:31:11 +08:00
super 11f0d2c745 修复商品风险多店铺问题 2026-04-30 21:31:11 +08:00
super b073bbe97d Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-30 11:38:13 +08:00
super 955a6439a0 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-30 11:38:13 +08:00
super c6ecfb5b77 优化后台业务 2026-04-30 11:36:58 +08:00
super 172917ac41 优化后台业务 2026-04-30 11:36:58 +08:00
铭坤 ad2bfcd2f5 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin
app/amazon/__pycache__/approve.cpython-39.pyc
	app/amazon/__pycache__/asin_status.cpython-39.pyc
	app/amazon/__pycache__/del_brand.cpython-39.pyc
	app/amazon/__pycache__/match_action.cpython-39.pyc
	app/amazon/__pycache__/price_match.cpython-39.pyc
2026-04-30 11:00:02 +08:00
铭坤 a5f6898d06 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin
app/amazon/__pycache__/approve.cpython-39.pyc
	app/amazon/__pycache__/asin_status.cpython-39.pyc
	app/amazon/__pycache__/del_brand.cpython-39.pyc
	app/amazon/__pycache__/match_action.cpython-39.pyc
	app/amazon/__pycache__/price_match.cpython-39.pyc
2026-04-30 11:00:02 +08:00
铭坤 83bd5839d0 modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/asin_status.cpython-39.pyc
	modified:   amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	modified:   amazon/del_brand.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	modified:   main.py
2026-04-30 10:52:52 +08:00
铭坤 83bc90ecf2 modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/asin_status.cpython-39.pyc
	modified:   amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	modified:   amazon/del_brand.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	modified:   main.py
2026-04-30 10:52:52 +08:00
koko 6ea3a960e7 Remove ts script 2026-04-28 22:41:56 +08:00
koko cbfc29e953 Remove ts script 2026-04-28 22:41:56 +08:00
koko fd2013b448 chore: update env 2026-04-28 22:40:39 +08:00
koko b66465aa6a chore: update env 2026-04-28 22:40:39 +08:00
koko a684fde472 Remove README from master 2026-04-28 22:39:38 +08:00
koko fbd1a4dbea Remove README from master 2026-04-28 22:39:38 +08:00
koko 824fa7b76c Remove tracked .rtk config 2026-04-28 22:38:17 +08:00
koko be8a8492a9 Remove tracked .rtk config 2026-04-28 22:38:17 +08:00
koko b429721070 Stop tracking remaining Python bytecode on master
Master still tracked a small set of generated __pycache__ artifacts after merging dev/koko. The ignore rules already match dev/koko, so this commit only removes the remaining bytecode files from the Git index while leaving local files on disk.

Constraint: dev/koko .gitignore already contains recursive __pycache__ ignore coverage

Rejected: Delete local cache directories | repository tracking cleanup only requires --cached removal

Confidence: high

Scope-risk: narrow

Tested: git ls-files shows no remaining paths containing __pycache__/

Not-tested: Application runtime; generated bytecode tracking only
2026-04-28 22:33:27 +08:00
koko b352eea21d Stop tracking remaining Python bytecode on master
Master still tracked a small set of generated __pycache__ artifacts after merging dev/koko. The ignore rules already match dev/koko, so this commit only removes the remaining bytecode files from the Git index while leaving local files on disk.

Constraint: dev/koko .gitignore already contains recursive __pycache__ ignore coverage

Rejected: Delete local cache directories | repository tracking cleanup only requires --cached removal

Confidence: high

Scope-risk: narrow

Tested: git ls-files shows no remaining paths containing __pycache__/

Not-tested: Application runtime; generated bytecode tracking only
2026-04-28 22:33:27 +08:00
koko 73d1dff21d Merge dev/koko into master preserving master conflict behavior
Conflict resolution kept master-side changes for non-patrol-delete files as requested. No app/amazon/patrol_delete.py conflict was present. Existing dev/koko assets were retained so /assets resources required by new_web_source pages resolve in the Flask app.

Constraint: User requested authentication-requiring git operations be reported as commands only

Rejected: Rework non-conflicting dev/koko changes during merge | scope was conflict resolution, not feature review

Confidence: high

Scope-risk: moderate

Tested: uv run python -c Flask test client returned 200 for /new_web_source/patrol-delete.html, /assets/patrol-delete.js, /assets/pywebview-C66x_2Dh.js

Tested: uv run python -m py_compile amazon\\patrol_delete.py amazon\\detail_spider.py amazon\\price_match.py main.py

Tested: uv run --group dev pytest tests\\test_patrol_delete.py tests\\test_amazon_base.py

Not-tested: authenticated Git push/pull; Java backend build
2026-04-28 22:31:38 +08:00
koko 51bf0aaa8c Merge dev/koko into master preserving master conflict behavior
Conflict resolution kept master-side changes for non-patrol-delete files as requested. No app/amazon/patrol_delete.py conflict was present. Existing dev/koko assets were retained so /assets resources required by new_web_source pages resolve in the Flask app.

Constraint: User requested authentication-requiring git operations be reported as commands only

Rejected: Rework non-conflicting dev/koko changes during merge | scope was conflict resolution, not feature review

Confidence: high

Scope-risk: moderate

Tested: uv run python -c Flask test client returned 200 for /new_web_source/patrol-delete.html, /assets/patrol-delete.js, /assets/pywebview-C66x_2Dh.js

Tested: uv run python -m py_compile amazon\\patrol_delete.py amazon\\detail_spider.py amazon\\price_match.py main.py

Tested: uv run --group dev pytest tests\\test_patrol_delete.py tests\\test_amazon_base.py

Not-tested: authenticated Git push/pull; Java backend build
2026-04-28 22:31:38 +08:00
koko d7d1021ec3 fix: brand html 2026-04-28 22:14:41 +08:00
koko 28a752265c fix: brand html 2026-04-28 22:14:41 +08:00
koko 735234f7bc fix: update frontend 2026-04-28 21:42:30 +08:00
koko 1d9d138423 fix: update frontend 2026-04-28 21:42:30 +08:00
铭坤 8c5edc6ad6 new file: assets/_plugin-vue_export-helper-Dh4yMZWw.js
new file:   assets/_plugin-vue_export-helper-xvHHTGU_.css
	new file:   assets/appearance-patent-BNTrbLJh.css
	new file:   assets/appearance-patent-BPCrG75P.css
	new file:   assets/appearance-patent.js
	new file:   assets/brand-1nUVsWrm.js
	new file:   assets/brand-5-W0Wonr.js
	new file:   assets/brand-BATjYfEL.js
	new file:   assets/brand-BZije8D7.js
	new file:   assets/brand-C0Q5LZ0P.js
	new file:   assets/brand-CFZZtTv8.js
	new file:   assets/brand-CKgrwtni.js
	new file:   assets/brand-CRmRvyGD.js
	new file:   assets/brand-CXHemZwJ.js
	new file:   assets/brand-DBpLCgAF.js
	new file:   assets/brand-DRn3N4FA.js
	new file:   assets/brand-DZ5_PGnw.js
	new file:   assets/brand-DysFlQbZ.js
	new file:   assets/brand-UU-ckLq6.js
	new file:   assets/convert-1dkFPbKa.css
	new file:   assets/convert-6b0yq-M0.css
	new file:   assets/convert-7wWJ02Tw.css
	new file:   assets/convert-BKSNvX8i.css
	new file:   assets/convert-BxkpMHO9.css
	new file:   assets/convert-CQ22EBpm.css
	new file:   assets/convert-Cfr3mUjs.css
	new file:   assets/convert-D4Yv2oRy.css
	new file:   assets/convert-DwbQug2y.css
	new file:   assets/dedupe-B0eqpVpj.css
	new file:   assets/dedupe-BHE_BCAJ.css
	new file:   assets/dedupe-BpNHwt51.css
	new file:   assets/dedupe-CS18ls2z.css
	new file:   assets/dedupe-DNlVfFj-.css
	new file:   assets/dedupe-Day_nGxq.css
	new file:   assets/dedupe-DyzjKbsT.css
	new file:   assets/dedupe-DzFvTfoj.css
	new file:   assets/dedupe-rhGu1E8E.css
	new file:   assets/delete-brand-BNvh4ru4.css
	new file:   assets/delete-brand-BP3XWKAC.css
	new file:   assets/delete-brand-BRIDBaoM.css
	new file:   assets/delete-brand-BcZomrN3.css
	new file:   assets/delete-brand-BgPrpPsj.css
	new file:   assets/delete-brand-ByeMdpEk.css
	new file:   assets/delete-brand-C-Rj3NMH.css
	new file:   assets/delete-brand-CDZTH98q.css
	new file:   assets/delete-brand-CS44Bk-y.css
	new file:   assets/delete-brand-CWLpe7lu.css
	new file:   assets/delete-brand-CdxGWtvK.css
	new file:   assets/delete-brand-Chu8awlt.css
	new file:   assets/delete-brand-CndjrFFS.css
	new file:   assets/delete-brand-CpNTe9WM.css
	new file:   assets/delete-brand-D7t16Ukk.css
	new file:   assets/delete-brand-DE0hLEak.css
	new file:   assets/delete-brand-DLyg-H8J.css
	new file:   assets/delete-brand-DO6pdlC3.css
	new file:   assets/delete-brand-DXSeQxXc.css
	new file:   assets/delete-brand-DZ6zYt8o.css
	new file:   assets/delete-brand-DfRLfrtm.css
	new file:   assets/delete-brand-Dl7T0pmm.css
	new file:   assets/delete-brand-Dt_MS9as.css
	new file:   assets/delete-brand-DvND7vBL.css
	new file:   assets/delete-brand-_jGFWTAn.css
	new file:   assets/el-alert-Ct0RpqUD.css
	new file:   assets/el-input-CezJelDw.css
	new file:   assets/el-input-xaztPnzw.css
	new file:   assets/el-table-column-Cy4YJvw0.css
	new file:   assets/listingFilters-B6-M_FNM.js
	new file:   assets/listingFilters-BmlAzw7M.css
	new file:   assets/listingFilters-BpGOU_pJ.js
	new file:   assets/listingFilters-CK58rX4v.css
	new file:   assets/patrol-delete-BPu1AAPM.css
	new file:   assets/patrol-delete-BctopIU4.css
	new file:   assets/patrol-delete-CSekhzSS.css
	new file:   assets/patrol-delete-DIvFZUTh.css
	new file:   assets/patrol-delete.js
	new file:   assets/price-track-1SjcUfP4.css
	new file:   assets/price-track-85NbckiJ.css
	new file:   assets/price-track-B5FVfJb_.css
	new file:   assets/price-track-BO5PtL0W.css
	new file:   assets/price-track-BccJT4Qr.css
	new file:   assets/price-track-BlSD-0un.css
	new file:   assets/price-track-BlVVl2eV.css
	new file:   assets/price-track-BwgEuRxe.css
	new file:   assets/price-track-CWQD_A7D.css
	new file:   assets/price-track-DNTcdRH8.css
	new file:   assets/price-track-Dv4EZPhf.css
	new file:   assets/price-track-Ji5JAoeR.css
	new file:   assets/price-track-RLJUgMl_.css
	new file:   assets/price-track-z8RU_FlW.css
	new file:   assets/price-track.js
	new file:   assets/product-risk-1G_ztqNY.css
	new file:   assets/product-risk-A5bhfaTH.css
	new file:   assets/product-risk-BBMcuGAw.css
	new file:   assets/product-risk-C3Yn2wAL.css
	new file:   assets/product-risk-CG-1Iq4P.css
	new file:   assets/product-risk-COeM91v5.css
	new file:   assets/product-risk-ClWs7d57.css
	new file:   assets/product-risk-CtpNfape.css
	new file:   assets/product-risk-DBsBE_mg.css
	new file:   assets/product-risk-DRYaWmI2.css
	new file:   assets/product-risk-Db49F4J5.css
	new file:   assets/product-risk-DoO8ZHM0.css
	new file:   assets/product-risk-DpSMKBCA.css
	new file:   assets/product-risk-DqFPFWEv.css
	new file:   assets/product-risk-cfL3Ch5-.css
	new file:   assets/product-risk-eXMv239F.css
	new file:   assets/product-risk-un2cxu--.css
	new file:   assets/product-risk.js
	new file:   assets/pywebview-3PePjYSu.js
	new file:   assets/pywebview-8G_9KMXd.css
	new file:   assets/pywebview-9YBa--7x.js
	new file:   assets/pywebview-B6ZNXusn.css
	new file:   assets/pywebview-BCPdlDdb.js
	new file:   assets/pywebview-BLoeiUcF.css
	new file:   assets/pywebview-BRrok0pS.js
	new file:   assets/pywebview-BT0f6KST.css
	new file:   assets/pywebview-BbIq-QPS.css
	new file:   assets/pywebview-Bc09DixN.js
	new file:   assets/pywebview-Bl6M97uH.js
	new file:   assets/pywebview-BnpJyyGZ.js
	new file:   assets/pywebview-Bt854mYs.js
	new file:   assets/pywebview-C5RGB8QW.css
	new file:   assets/pywebview-C66x_2Dh.js
	new file:   assets/pywebview-C8Bik-Sc.js
	new file:   assets/pywebview-CGwF8TuM.js
	new file:   assets/pywebview-CJLylbJu.js
	new file:   assets/pywebview-CeWJDVeG.js
	new file:   assets/pywebview-Chz98E9c.css
	new file:   assets/pywebview-ClWy2SbE.js
	new file:   assets/pywebview-Cq_E2BnJ.js
	new file:   assets/pywebview-Cs1Kot1q.js
	new file:   assets/pywebview-D-PKWjUg.js
	new file:   assets/pywebview-D-mMH8F6.css
	new file:   assets/pywebview-D4gpiFjY.js
	new file:   assets/pywebview-D74jYk6P.css
	new file:   assets/pywebview-D7_PdvyM.js
	new file:   assets/pywebview-D808cNhy.js
	new file:   assets/pywebview-DVgP2-kW.js
	new file:   assets/pywebview-Dee3nQjE.js
	new file:   assets/pywebview-DiP0HdY6.js
	new file:   assets/pywebview-Dp5dN8OO.css
	new file:   assets/pywebview-DuyK2jB1.js
	new file:   assets/pywebview-IqgMfeBe.css
	new file:   assets/pywebview-MkjZQlBu.css
	new file:   assets/pywebview-Q4glvYu5.css
	new file:   assets/pywebview-Rm5Hhqpf.js
	new file:   assets/pywebview-V_UIajJm.js
	new file:   assets/pywebview-hj_EXwAP.css
	new file:   assets/pywebview-ij4pgMq8.css
	new file:   assets/pywebview-leZCedEt.js
	new file:   assets/query-asin-B0yMJ9Or.css
	new file:   assets/query-asin-B5e5m-vs.css
	new file:   assets/query-asin-Bv7Jtgqa.css
	new file:   assets/query-asin-DZwJfwHU.css
	new file:   assets/query-asin.js
	new file:   assets/shop-match-Banz7DWL.css
	new file:   assets/shop-match-BiZP8IGM.css
	new file:   assets/shop-match-BrrGkYV7.css
	new file:   assets/shop-match-CVFsXUvd.css
	new file:   assets/shop-match-CfGJEHz0.css
	new file:   assets/shop-match-CfGWwDtw.css
	new file:   assets/shop-match-D0DGETCs.css
	new file:   assets/shop-match-DFEKOpvV.css
	new file:   assets/shop-match-DNFA8ceR.css
	new file:   assets/shop-match-DhT1CvMP.css
	new file:   assets/shop-match-L0xHTaQ2.css
	new file:   assets/shop-match-MsxXMG_G.css
	new file:   assets/shop-match-g3eRKhTP.css
	new file:   assets/shop-match.js
	new file:   assets/split-BoBVrLdC.css
	new file:   assets/split-BsJfbBqn.css
	new file:   assets/split-CRUIYKS6.css
	new file:   assets/split-DAa_Usoh.css
	new file:   assets/split-DidKJ84l.css
	new file:   assets/split-RNZYJ-zZ.css
	new file:   assets/split-R_8V5xgh.css
	new file:   assets/split-_O6NHqDj.css
	new file:   assets/split-mwLUJT1K.css
	new file:   assets/zh-cn-BjWx61Lu.js
	new file:   assets/zh-cn-C0iS6aoJ.js
	new file:   assets/zh-cn-CuE9Zzgz.js
	new file:   assets/zh-cn-DyKmB71i.js
	new file:   assets/zh-cn-Z9PBnl-n.js
2026-04-28 21:36:49 +08:00
铭坤 e09ce6d13b modified: amazon/__pycache__/detail_spider.cpython-39.pyc
modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/detail_spider.py
	modified:   amazon/price_match.py
	modified:   blueprints/__pycache__/admin.cpython-39.pyc
	modified:   blueprints/__pycache__/brand.cpython-39.pyc
	modified:   blueprints/__pycache__/main.cpython-39.pyc
	modified:   brand_spider/__pycache__/main.cpython-39.pyc
	modified:   main.py
	modified:   web_source/brand.html
2026-04-28 21:11:48 +08:00
铭坤 ee6fb5d33a modified: amazon/__pycache__/detail_spider.cpython-39.pyc
modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/detail_spider.py
	modified:   amazon/price_match.py
	modified:   blueprints/__pycache__/admin.cpython-39.pyc
	modified:   blueprints/__pycache__/brand.cpython-39.pyc
	modified:   blueprints/__pycache__/main.cpython-39.pyc
	modified:   brand_spider/__pycache__/main.cpython-39.pyc
	modified:   main.py
	modified:   web_source/brand.html
2026-04-28 21:11:48 +08:00
koko 46e55fa623 Stop tracking generated Python bytecode
Generated __pycache__ files were already ignored in some paths but remained tracked in the repository, which caused merge noise and binary conflicts. This removes the tracked bytecode from the index and adds an explicit recursive ignore rule so future Python runs do not reintroduce them.

Constraint: Existing repository history already tracked pycache files across app, backend, and source_code

Rejected: Delete local pycache directories from disk | only repository tracking needed to be removed

Confidence: high

Scope-risk: narrow

Directive: Do not force-add __pycache__ or *.pyc files unless there is a documented runtime packaging reason

Tested: git ls-files shows no remaining paths containing __pycache__/

Not-tested: Application runtime; change only affects tracked generated artifacts and ignore rules
2026-04-28 20:57:53 +08:00
koko cd2b437be5 Stop tracking generated Python bytecode
Generated __pycache__ files were already ignored in some paths but remained tracked in the repository, which caused merge noise and binary conflicts. This removes the tracked bytecode from the index and adds an explicit recursive ignore rule so future Python runs do not reintroduce them.

Constraint: Existing repository history already tracked pycache files across app, backend, and source_code

Rejected: Delete local pycache directories from disk | only repository tracking needed to be removed

Confidence: high

Scope-risk: narrow

Directive: Do not force-add __pycache__ or *.pyc files unless there is a documented runtime packaging reason

Tested: git ls-files shows no remaining paths containing __pycache__/

Not-tested: Application runtime; change only affects tracked generated artifacts and ignore rules
2026-04-28 20:57:53 +08:00
koko a92d1af4f2 Merge master into dev/koko after patrol delete fixes
The merge keeps dev/koko patrol-delete asset fallback behavior while accepting the latest master feature work. Conflicts were limited to ignore rules, local environment/config artifacts, tracked pycache binaries, and the Flask main blueprint.

Constraint: master and dev/koko both edited app/blueprints/main.py around brand and asset serving

Rejected: Drop dev/koko asset fallback logic | patrol delete and rebuilt Vite assets still need hashed asset resolution across app/new_web_source locations

Confidence: medium

Scope-risk: broad

Directive: app/.env remains a tracked local-config file in this repository; do not print or normalize secrets during conflict handling

Tested: uv run python -m py_compile blueprints\\main.py amazon\\base.py amazon\\main.py

Tested: uv run --group dev pytest tests\\test_amazon_base.py tests\\test_patrol_delete.py

Not-tested: Full backend-java/frontend-vue test suites
2026-04-28 20:55:27 +08:00
koko a504e7a13b Merge master into dev/koko after patrol delete fixes
The merge keeps dev/koko patrol-delete asset fallback behavior while accepting the latest master feature work. Conflicts were limited to ignore rules, local environment/config artifacts, tracked pycache binaries, and the Flask main blueprint.

Constraint: master and dev/koko both edited app/blueprints/main.py around brand and asset serving

Rejected: Drop dev/koko asset fallback logic | patrol delete and rebuilt Vite assets still need hashed asset resolution across app/new_web_source locations

Confidence: medium

Scope-risk: broad

Directive: app/.env remains a tracked local-config file in this repository; do not print or normalize secrets during conflict handling

Tested: uv run python -m py_compile blueprints\\main.py amazon\\base.py amazon\\main.py

Tested: uv run --group dev pytest tests\\test_amazon_base.py tests\\test_patrol_delete.py

Not-tested: Full backend-java/frontend-vue test suites
2026-04-28 20:55:27 +08:00
koko 1be28f10e9 Stabilize patrol delete automation against delayed Amazon UI
The patrol-delete flow now waits for country and listing-status controls before acting, uses the dedicated PatrolDeleteTask entry point, and includes the browser helper scripts required by the bulk-delete path. Tests cover delayed dropdown readiness, payload rejection/retry behavior, complete-draft normalization, filtered bulk deletion, and asset fallback lookup.

Constraint: Amazon listing UI exposes status controls through dynamic KAT components and delayed option rendering

Rejected: Keep row-by-row delete flow | bulk selection is the current implemented path and is covered by the added helper scripts

Confidence: high

Scope-risk: moderate

Directive: Do not remove the patrol_delete JS helper files without checking app/amazon/patrol_delete.py script loading

Tested: uv run --group dev pytest tests\\test_amazon_base.py tests\\test_patrol_delete.py

Tested: uv run python -m py_compile amazon\\base.py amazon\\main.py blueprints\\main.py

Not-tested: Real Amazon Seller Central browser session
2026-04-28 20:46:50 +08:00
koko 325687d532 Stabilize patrol delete automation against delayed Amazon UI
The patrol-delete flow now waits for country and listing-status controls before acting, uses the dedicated PatrolDeleteTask entry point, and includes the browser helper scripts required by the bulk-delete path. Tests cover delayed dropdown readiness, payload rejection/retry behavior, complete-draft normalization, filtered bulk deletion, and asset fallback lookup.

Constraint: Amazon listing UI exposes status controls through dynamic KAT components and delayed option rendering

Rejected: Keep row-by-row delete flow | bulk selection is the current implemented path and is covered by the added helper scripts

Confidence: high

Scope-risk: moderate

Directive: Do not remove the patrol_delete JS helper files without checking app/amazon/patrol_delete.py script loading

Tested: uv run --group dev pytest tests\\test_amazon_base.py tests\\test_patrol_delete.py

Tested: uv run python -m py_compile amazon\\base.py amazon\\main.py blueprints\\main.py

Not-tested: Real Amazon Seller Central browser session
2026-04-28 20:46:50 +08:00
super 9c16c9c589 提交跟新 2026-04-28 17:16:04 +08:00
super 9760d1171c 提交跟新 2026-04-28 17:16:04 +08:00
super 8711b205cf 提交暂存 2026-04-28 16:57:05 +08:00
super d42ed57119 提交暂存 2026-04-28 16:57:05 +08:00
super e316adca1f 更新内容 2026-04-28 16:56:53 +08:00
super 18208f691c 更新内容 2026-04-28 16:56:53 +08:00
super 0457fbfac0 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-28 15:33:42 +08:00
super c06a4d0e06 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-28 15:33:42 +08:00
super 58df800685 合并错误信息 2026-04-28 15:25:34 +08:00
super f21934e55b 合并错误信息 2026-04-28 15:25:34 +08:00
铭坤 7c198f7d6f Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-28 15:23:55 +08:00
铭坤 515135c120 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-28 15:23:55 +08:00
铭坤 ec4d1b2567 modified: .env
modified:   amazon/__pycache__/approve.cpython-39.pyc
	modified:   amazon/__pycache__/detail_spider.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/detail_spider.py
	modified:   amazon/price_match.py
	modified:   assets/convert.js
	modified:   assets/dedupe.js
	modified:   assets/delete-brand.js
	modified:   assets/split.js
	modified:   blueprints/__pycache__/admin.cpython-39.pyc
	modified:   blueprints/__pycache__/brand.cpython-39.pyc
	modified:   blueprints/__pycache__/main.cpython-39.pyc
	modified:   blueprints/main.py
	modified:   brand_spider/__pycache__/main.cpython-39.pyc
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/delete-brand.html
	modified:   new_web_source/split.html
	modified:   tool/__pycache__/devices.cpython-39.pyc
2026-04-28 15:21:57 +08:00
铭坤 42bdd59c71 modified: .env
modified:   amazon/__pycache__/approve.cpython-39.pyc
	modified:   amazon/__pycache__/detail_spider.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/detail_spider.py
	modified:   amazon/price_match.py
	modified:   assets/convert.js
	modified:   assets/dedupe.js
	modified:   assets/delete-brand.js
	modified:   assets/split.js
	modified:   blueprints/__pycache__/admin.cpython-39.pyc
	modified:   blueprints/__pycache__/brand.cpython-39.pyc
	modified:   blueprints/__pycache__/main.cpython-39.pyc
	modified:   blueprints/main.py
	modified:   brand_spider/__pycache__/main.cpython-39.pyc
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/delete-brand.html
	modified:   new_web_source/split.html
	modified:   tool/__pycache__/devices.cpython-39.pyc
2026-04-28 15:21:57 +08:00
koko 4ff4d8cfdc Expose patrol delete progress in logs
Patrol delete can spend a long time switching countries, reading listing states, and confirming deletes, so the flow now emits concise progress logs around each high-value step. The logs avoid full DOM dumps outside existing diagnostics and focus on task, shop, country, status, deletion counts, and callback boundaries.

Constraint: Existing patrol delete runs are browser-driven and need observable progress without changing deletion behavior
Rejected: Log every DOM probe | too noisy for routine task monitoring
Confidence: high
Scope-risk: narrow
Tested: uv run --group dev pytest tests\\test_patrol_delete.py
Tested: uv run --group dev ruff check amazon\\patrol_delete.py
Tested: uv run python -m py_compile amazon\\patrol_delete.py
Not-tested: Live Seller Central browser run
2026-04-28 01:23:58 +08:00
koko 8be85fd332 Expose patrol delete progress in logs
Patrol delete can spend a long time switching countries, reading listing states, and confirming deletes, so the flow now emits concise progress logs around each high-value step. The logs avoid full DOM dumps outside existing diagnostics and focus on task, shop, country, status, deletion counts, and callback boundaries.

Constraint: Existing patrol delete runs are browser-driven and need observable progress without changing deletion behavior
Rejected: Log every DOM probe | too noisy for routine task monitoring
Confidence: high
Scope-risk: narrow
Tested: uv run --group dev pytest tests\\test_patrol_delete.py
Tested: uv run --group dev ruff check amazon\\patrol_delete.py
Tested: uv run python -m py_compile amazon\\patrol_delete.py
Not-tested: Live Seller Central browser run
2026-04-28 01:23:58 +08:00
super e4bf104ae2 架构更改完成 2026-04-27 18:45:56 +08:00
super b96b136fa3 增加rufts 2026-04-27 18:45:33 +08:00
super 5105bf7049 增加rufts 2026-04-27 18:45:33 +08:00
koko 02ddfc7a76 Rename patrol delete tests
Keep the patrol deletion test module aligned with the renamed patrol_delete implementation and update test function names so future searches no longer point at the old product module name.

Constraint: This is a naming-only follow-up to the patrol_delete module rename

Confidence: high

Scope-risk: narrow

Tested: uv run pytest tests/test_patrol_delete.py
2026-04-27 17:59:46 +08:00
koko 08997e9e20 Rename patrol delete tests
Keep the patrol deletion test module aligned with the renamed patrol_delete implementation and update test function names so future searches no longer point at the old product module name.

Constraint: This is a naming-only follow-up to the patrol_delete module rename

Confidence: high

Scope-risk: narrow

Tested: uv run pytest tests/test_patrol_delete.py
2026-04-27 17:59:46 +08:00
koko 8defef904f Align patrol delete module naming
Rename the patrol deletion implementation and browser helper scripts away from the generic product name so the filesystem matches the queued patrol-delete task domain. Update imports, script loading, and tests to use the patrol_delete module path.

Constraint: Existing task class remains ProductTask to avoid broad API churn beyond the requested file and script naming

Rejected: Rename ProductTask class now | would expand the change into a larger API update across tests and task dispatch

Confidence: high

Scope-risk: narrow

Directive: Keep patrol-delete script paths under app/amazon/scripts/patrol_delete when adding new helper scripts

Tested: uv run pytest tests/test_product.py

Not-tested: Remote push before this commit due previous SSH publickey failure
2026-04-27 17:58:40 +08:00
koko 9146d17625 Align patrol delete module naming
Rename the patrol deletion implementation and browser helper scripts away from the generic product name so the filesystem matches the queued patrol-delete task domain. Update imports, script loading, and tests to use the patrol_delete module path.

Constraint: Existing task class remains ProductTask to avoid broad API churn beyond the requested file and script naming

Rejected: Rename ProductTask class now | would expand the change into a larger API update across tests and task dispatch

Confidence: high

Scope-risk: narrow

Directive: Keep patrol-delete script paths under app/amazon/scripts/patrol_delete when adding new helper scripts

Tested: uv run pytest tests/test_product.py

Not-tested: Remote push before this commit due previous SSH publickey failure
2026-04-27 17:58:40 +08:00
koko 13c3a04a48 Bring Amazon collection tasks into dev/koko
Merge origin/master into dev/koko while preserving the patrol delete task added on dev/koko. The task dispatcher now recognizes both patrol deletion and appearance patent collection, and the master-side SpiderTask implementation is included.

Constraint: origin fetch and push over SSH are blocked in this environment by Gitee publickey authentication

Rejected: Overwrite dev/koko with master | would drop the patrol delete branch work

Confidence: medium

Scope-risk: moderate

Directive: Do not remove either patrol-delete-run or appearance-patent-run without checking queued task producers

Tested: python -m py_compile app/amazon/approve.py app/amazon/asin_status.py app/amazon/detail_spider.py app/amazon/main.py app/amazon/match_action.py app/amazon/price_match.py

Not-tested: Remote push, blocked by SSH publickey authentication
2026-04-27 17:36:30 +08:00
koko 1aca3d6152 Bring Amazon collection tasks into dev/koko
Merge origin/master into dev/koko while preserving the patrol delete task added on dev/koko. The task dispatcher now recognizes both patrol deletion and appearance patent collection, and the master-side SpiderTask implementation is included.

Constraint: origin fetch and push over SSH are blocked in this environment by Gitee publickey authentication

Rejected: Overwrite dev/koko with master | would drop the patrol delete branch work

Confidence: medium

Scope-risk: moderate

Directive: Do not remove either patrol-delete-run or appearance-patent-run without checking queued task producers

Tested: python -m py_compile app/amazon/approve.py app/amazon/asin_status.py app/amazon/detail_spider.py app/amazon/main.py app/amazon/match_action.py app/amazon/price_match.py

Not-tested: Remote push, blocked by SSH publickey authentication
2026-04-27 17:36:30 +08:00
super 60a6494260 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-27 09:20:04 +08:00
super 052bb31aea Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-27 09:20:04 +08:00
super 995e2ee65a 后端架构更新 2026-04-27 09:18:10 +08:00
super 225b525ba1 后端架构更新 2026-04-27 09:18:10 +08:00
koko 7f83bceba1 feat: patrol delete 2026-04-27 00:23:44 +08:00
koko e1543416e3 feat: patrol delete 2026-04-27 00:23:44 +08:00
铭坤 1eb622d33f modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/asin_status.cpython-39.pyc
	new file:   amazon/__pycache__/detail_spider.cpython-39.pyc
	modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	new file:   amazon/detail_spider.py
	modified:   amazon/main.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	modified:   assets/convert.js
	modified:   assets/dedupe.js
	modified:   assets/delete-brand.js
	modified:   assets/split.js
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/delete-brand.html
	modified:   new_web_source/split.html
	modified:   web_source/brand.html
2026-04-27 00:21:37 +08:00
铭坤 0b57aea5f6 modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/asin_status.cpython-39.pyc
	new file:   amazon/__pycache__/detail_spider.cpython-39.pyc
	modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	new file:   amazon/detail_spider.py
	modified:   amazon/main.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	modified:   assets/convert.js
	modified:   assets/dedupe.js
	modified:   assets/delete-brand.js
	modified:   assets/split.js
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/delete-brand.html
	modified:   new_web_source/split.html
	modified:   web_source/brand.html
2026-04-27 00:21:37 +08:00
koko 5d8ee8fe79 feat: update amazon driver 2026-04-25 17:59:12 +08:00
koko a04c2f9a19 feat: update amazon driver 2026-04-25 17:59:12 +08:00
koko 6f1b8e46f5 feat: update amazon driver 2026-04-25 17:58:28 +08:00
koko c352c34501 feat: update amazon driver 2026-04-25 17:58:28 +08:00
koko f9b2d2da25 feat: update driver BaseClass 2026-04-25 17:14:23 +08:00
koko 5c9671df44 feat: update driver BaseClass 2026-04-25 17:14:23 +08:00
koko 26a920a1cc Merge branch 'master' into dev/koko 2026-04-25 15:47:02 +08:00
koko 8a8d3c5cd9 Merge branch 'master' into dev/koko 2026-04-25 15:47:02 +08:00
铭坤 e695fd5184 modified: amazon/__pycache__/approve.cpython-39.pyc
new file:   amazon/__pycache__/asin_status.cpython-39.pyc
	modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	modified:   amazon/main.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	modified:   web_source/brand.html
	modified:   web_source/templates_backup/brand.html
2026-04-24 23:00:59 +08:00
铭坤 d272afae1c modified: amazon/__pycache__/approve.cpython-39.pyc
new file:   amazon/__pycache__/asin_status.cpython-39.pyc
	modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	modified:   amazon/main.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	modified:   web_source/brand.html
	modified:   web_source/templates_backup/brand.html
2026-04-24 23:00:59 +08:00
super 0caf62c3d2 后台查询Asin文档更新 2026-04-24 15:14:14 +08:00
super 03e697f5d3 后台查询Asin文档更新 2026-04-24 15:14:14 +08:00
super 326f78705d 完成查询asin开发 2026-04-23 20:48:57 +08:00
super c502afb588 完成查询asin开发 2026-04-23 20:48:57 +08:00
koko afa8e44909 Merge branch 'master' into dev/koko 2026-04-23 11:49:50 +00:00
koko 3fada5d198 Merge branch 'master' into dev/koko 2026-04-23 11:49:50 +00:00
super 72fdb1841c Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-23 15:25:49 +08:00
super c0fdea6570 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-23 15:25:49 +08:00
super 34bc980eea 完成后端架构重构等 2026-04-23 15:25:41 +08:00
super 0391cb223f 完成后端架构重构等 2026-04-23 15:25:41 +08:00
koko 2dab555ca5 Merge remote-tracking branch 'origin/master' into dev/koko 2026-04-23 03:16:15 +00:00
koko b25111e4b4 Merge remote-tracking branch 'origin/master' into dev/koko 2026-04-23 03:16:15 +00:00
铭坤 d537924aa9 modified: app/amazon/__pycache__/approve.cpython-39.pyc
modified:   app/amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   app/amazon/__pycache__/match_action.cpython-39.pyc
	modified:   app/amazon/__pycache__/price_match.cpython-39.pyc
	modified:   app/amazon/approve.py
	modified:   app/amazon/del_brand.py
	modified:   app/amazon/match_action.py
	modified:   app/amazon/price_match.py
	modified:   app/assets/convert.js
	modified:   app/assets/dedupe.js
	modified:   app/assets/delete-brand.js
	modified:   app/assets/split.js
	modified:   app/new_web_source/convert.html
	modified:   app/new_web_source/dedupe.html
	modified:   app/new_web_source/delete-brand.html
	modified:   app/new_web_source/split.html
2026-04-23 10:41:07 +08:00
铭坤 2f2db4986e modified: app/amazon/__pycache__/approve.cpython-39.pyc
modified:   app/amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   app/amazon/__pycache__/match_action.cpython-39.pyc
	modified:   app/amazon/__pycache__/price_match.cpython-39.pyc
	modified:   app/amazon/approve.py
	modified:   app/amazon/del_brand.py
	modified:   app/amazon/match_action.py
	modified:   app/amazon/price_match.py
	modified:   app/assets/convert.js
	modified:   app/assets/dedupe.js
	modified:   app/assets/delete-brand.js
	modified:   app/assets/split.js
	modified:   app/new_web_source/convert.html
	modified:   app/new_web_source/dedupe.html
	modified:   app/new_web_source/delete-brand.html
	modified:   app/new_web_source/split.html
2026-04-23 10:41:07 +08:00
koko dc6ecc1edf Clarify the current automation example in onboarding docs
Update the README so new contributors start from the latest patrol-delete automation flow instead of treating delete-brand as the primary example. Keep the older delete-brand path as contrast for the file-driven workflow.

Constraint: Recent repository changes made patrol-delete the newest automation module, so the onboarding example needed to match current development reality
Rejected: Leave delete-brand as the primary example | would mislead readers about the latest automation entry point
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Revisit this section when a newer automation module replaces patrol-delete as the primary example
Tested: README diff review
Not-tested: lint, typecheck, unit/integration tests not run (documentation-only change)
2026-04-22 08:33:02 +00:00
koko 6f970b3783 Clarify the current automation example in onboarding docs
Update the README so new contributors start from the latest patrol-delete automation flow instead of treating delete-brand as the primary example. Keep the older delete-brand path as contrast for the file-driven workflow.

Constraint: Recent repository changes made patrol-delete the newest automation module, so the onboarding example needed to match current development reality
Rejected: Leave delete-brand as the primary example | would mislead readers about the latest automation entry point
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Revisit this section when a newer automation module replaces patrol-delete as the primary example
Tested: README diff review
Not-tested: lint, typecheck, unit/integration tests not run (documentation-only change)
2026-04-22 08:33:02 +00:00
铭坤 95d5c82474 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-22 15:58:46 +08:00
铭坤 87507708ce new file: admin.html
new file:   "brand - \345\211\257\346\234\254.html"
	new file:   "brand-\346\227\247.html"
	new file:   brand.html
	new file:   home.html
	new file:   index.html
	new file:   login.html
2026-04-22 15:57:56 +08:00
koko f6e83352d7 Document repo structure and ignore local OMX state
Add a root README that explains the active runtime layers and onboarding path, and keep local OMX session state out of version control so developer tooling does not interfere with pulls.

Constraint: Local OMX state is developer-specific and should not block branch sync or appear in shared history
Rejected: Keep onboarding notes untracked | easy to lose and hard to share with the team
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep the README aligned with the active app/backend-java/frontend-vue execution path; revisit if the runtime architecture changes
Tested: git diff review; git status after staging
Not-tested: lint, typecheck, unit/integration tests not run (docs and ignore rules only)
2026-04-22 07:16:04 +00:00
koko c6ae7ca170 Document repo structure and ignore local OMX state
Add a root README that explains the active runtime layers and onboarding path, and keep local OMX session state out of version control so developer tooling does not interfere with pulls.

Constraint: Local OMX state is developer-specific and should not block branch sync or appear in shared history
Rejected: Keep onboarding notes untracked | easy to lose and hard to share with the team
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep the README aligned with the active app/backend-java/frontend-vue execution path; revisit if the runtime architecture changes
Tested: git diff review; git status after staging
Not-tested: lint, typecheck, unit/integration tests not run (docs and ignore rules only)
2026-04-22 07:16:04 +00:00
super 46f46039ea Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-22 01:09:51 +08:00
super 6894f9cc57 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-22 01:09:51 +08:00
super 8c4a6cd12a 处理后台跳转错误 2026-04-22 01:09:47 +08:00
super 524d8763ce 处理后台跳转错误 2026-04-22 01:09:47 +08:00
super 236b73755c 处理后台管理系统、修复BUG、处理权限 2026-04-22 01:09:28 +08:00
super 1e845a1510 处理后台管理系统、修复BUG、处理权限 2026-04-22 01:09:28 +08:00
铭坤 0341838d19 modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	new file:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/__pycache__/tool.cpython-39.pyc
	modified:   amazon/approve.py
	new file:   amazon/asin_status.py
	modified:   amazon/main.py
	modified:   amazon/price_match.py
	new file:   "amazon/price_match_\346\227\247.py"
	modified:   amazon/tool.py
	modified:   assets/convert.js
	modified:   assets/dedupe.js
	modified:   assets/delete-brand.js
	modified:   assets/split.js
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/delete-brand.html
	modified:   new_web_source/split.html
	deleted:    web_source/admin.html
	deleted:    "web_source/brand - \345\211\257\346\234\254.html"
	deleted:    "web_source/brand-\346\227\247.html"
	deleted:    web_source/brand.html
	deleted:    web_source/home.html
	deleted:    web_source/index.html
	deleted:    web_source/login.html
2026-04-22 00:51:41 +08:00
铭坤 b04b05e4da modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	new file:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/__pycache__/tool.cpython-39.pyc
	modified:   amazon/approve.py
	new file:   amazon/asin_status.py
	modified:   amazon/main.py
	modified:   amazon/price_match.py
	new file:   "amazon/price_match_\346\227\247.py"
	modified:   amazon/tool.py
	modified:   assets/convert.js
	modified:   assets/dedupe.js
	modified:   assets/delete-brand.js
	modified:   assets/split.js
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/delete-brand.html
	modified:   new_web_source/split.html
	deleted:    web_source/admin.html
	deleted:    "web_source/brand - \345\211\257\346\234\254.html"
	deleted:    "web_source/brand-\346\227\247.html"
	deleted:    web_source/brand.html
	deleted:    web_source/home.html
	deleted:    web_source/index.html
	deleted:    web_source/login.html
2026-04-22 00:51:41 +08:00
super d691e53886 改造后端服务,处理后台管理新增组(部门概念) 2026-04-22 00:32:58 +08:00
super ea35273597 改造后端服务,处理后台管理新增组(部门概念) 2026-04-22 00:32:58 +08:00
super 72c8167472 更新跟价相关内容修改 2026-04-20 00:41:49 +08:00
super dabb278170 更新跟价相关内容修改 2026-04-20 00:41:49 +08:00
super 9b1138c83e Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-19 15:47:37 +08:00
super 7b12cebb45 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-19 15:47:37 +08:00
super dc5e23892f 提交改造app权限 2026-04-19 15:47:20 +08:00
super 9d75d673f8 提交改造app权限 2026-04-19 15:47:20 +08:00
铭坤 4f8cbc3e38 new file: update/PyQt5/Qt/.keep_dir.txt
new file:   update/PyQt5/Qt5/.keep_dir.txt
	new file:   update/PyQt5/QtCore.pyd
	new file:   update/PyQt5/QtGui.pyd
	new file:   update/PyQt5/QtWidgets.pyd
	new file:   update/PyQt5/qt-plugins/iconengines/qsvgicon.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qgif.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qicns.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qico.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qjpeg.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qsvg.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qtga.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qtiff.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qwbmp.dll
	new file:   update/PyQt5/qt-plugins/imageformats/qwebp.dll
	new file:   update/PyQt5/qt-plugins/mediaservice/dsengine.dll
	new file:   update/PyQt5/qt-plugins/mediaservice/qtmedia_audioengine.dll
	new file:   update/PyQt5/qt-plugins/mediaservice/wmfengine.dll
	new file:   update/PyQt5/qt-plugins/platforms/qminimal.dll
	new file:   update/PyQt5/qt-plugins/platforms/qoffscreen.dll
	new file:   update/PyQt5/qt-plugins/platforms/qwebgl.dll
	new file:   update/PyQt5/qt-plugins/platforms/qwindows.dll
	new file:   update/PyQt5/qt-plugins/platformthemes/qxdgdesktopportal.dll
	new file:   update/PyQt5/qt-plugins/printsupport/windowsprintersupport.dll
	new file:   update/PyQt5/qt-plugins/styles/qwindowsvistastyle.dll
	new file:   update/PyQt5/sip.pyd
	new file:   update/_bz2.pyd
	new file:   update/_ctypes.pyd
	new file:   update/_decimal.pyd
	new file:   update/_elementtree.pyd
	new file:   update/_hashlib.pyd
	new file:   update/_hashlib.zip
	new file:   update/_lzma.pyd
	new file:   update/_socket.pyd
	new file:   update/libcrypto-1_1-x64.dll
	new file:   update/libeay32.dll
	new file:   update/libffi-7.dll
	new file:   update/msvcp140.dll
	new file:   update/msvcp140_1.dll
	new file:   update/psutil/_psutil_windows.pyd
	new file:   update/pyexpat.pyd
	new file:   update/python3.dll
	new file:   update/python39.dll
	new file:   update/qt5core.dll
	new file:   update/qt5dbus.dll
	new file:   update/qt5gui.dll
	new file:   update/qt5multimedia.dll
	new file:   update/qt5network.dll
	new file:   update/qt5printsupport.dll
	new file:   update/qt5qml.dll
	new file:   update/qt5qmlmodels.dll
	new file:   update/qt5quick.dll
	new file:   update/qt5svg.dll
	new file:   update/qt5websockets.dll
	new file:   update/qt5widgets.dll
	new file:   update/select.pyd
	new file:   update/ssleay32.dll
	new file:   update/unicodedata.pyd
	new file:   update/update.exe
	new file:   update/vcruntime140.dll
	new file:   update/vcruntime140_1.dll
2026-04-19 15:39:46 +08:00
铭坤 8d97f5318c modified: ali_oss.py
modified:   config.py
	modified:   main.py
	new file:   winsrc.bat
2026-04-19 15:38:09 +08:00
铭坤 3ffbb2b004 modified: ali_oss.py
modified:   config.py
	modified:   main.py
	new file:   winsrc.bat
2026-04-19 15:38:09 +08:00
super 34ed15a9bd Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-19 15:06:13 +08:00
super 110f407ae2 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-19 15:06:13 +08:00
super 4b6295dd44 改造后台权限和APP权限 2026-04-19 15:06:09 +08:00
super 8db9f3a408 改造后台权限和APP权限 2026-04-19 15:06:09 +08:00
supernijia 01116d5607 删除文件 desktop 2026-04-18 16:23:13 +00:00
supernijia 2ae720ae09 删除文件 desktop 2026-04-18 16:23:13 +00:00
铭坤 07904a29aa modified: amazon/match_action.py
modified:   amazon/price_match.py
	modified:   config.py
2026-04-19 00:18:28 +08:00
铭坤 f87c37528b modified: amazon/match_action.py
modified:   amazon/price_match.py
	modified:   config.py
2026-04-19 00:18:28 +08:00
铭坤 8d683a791d Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-19 00:18:02 +08:00
铭坤 71b09a89de Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-19 00:18:02 +08:00
super ef0e0df0ac 完成匹配、跟价、权限部分 2026-04-17 12:52:16 +08:00
super d5764f3b50 完成匹配、跟价、权限部分 2026-04-17 12:52:16 +08:00
铭坤 ac07416352 modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/del_brand.py
	modified:   amazon/match_action.py
	new file:   amazon/price_match.py
	modified:   main.py
2026-04-17 10:04:24 +08:00
铭坤 4e5ed76cb6 modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/del_brand.py
	modified:   amazon/match_action.py
	new file:   amazon/price_match.py
	modified:   main.py
2026-04-17 10:04:24 +08:00
super 025ca6d4fd 后台管理跳过asin、后台相关数据做数据隔离 2026-04-14 10:04:50 +08:00
super ecc8b6ce6c 后台管理跳过asin、后台相关数据做数据隔离 2026-04-14 10:04:50 +08:00
super 951a353881 提交任务更新 2026-04-13 20:07:00 +08:00
super 9ad6e037dc 提交任务更新 2026-04-13 20:07:00 +08:00
super eb04caccf1 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-13 13:02:45 +08:00
super 4a58b366b6 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-13 13:02:45 +08:00
super cd84def61d 提交工作更新 2026-04-13 13:02:41 +08:00
super bbc833f2c9 提交工作更新 2026-04-13 13:02:41 +08:00
铭坤 d8098b0378 modified: app/amazon/__pycache__/del_brand.cpython-39.pyc
modified:   app/amazon/__pycache__/match_action.cpython-39.pyc
	modified:   app/amazon/del_brand.py
	modified:   app/amazon/match_action.py
	modified:   app/assets/delete-brand.js
	modified:   app/new_web_source/delete-brand.html
	new file:   "app/web_source/brand - \345\211\257\346\234\254.html"
2026-04-12 20:52:26 +08:00
铭坤 325c2f7c82 modified: app/amazon/__pycache__/del_brand.cpython-39.pyc
modified:   app/amazon/__pycache__/match_action.cpython-39.pyc
	modified:   app/amazon/del_brand.py
	modified:   app/amazon/match_action.py
	modified:   app/assets/delete-brand.js
	modified:   app/new_web_source/delete-brand.html
	new file:   "app/web_source/brand - \345\211\257\346\234\254.html"
2026-04-12 20:52:26 +08:00
super 62d30ec190 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-12 17:15:54 +08:00
super 728eea4b83 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-12 17:15:54 +08:00
super d0d3c6ee67 完成菜单权限添加和软件菜单改造 2026-04-12 17:15:15 +08:00
super e53eaf738e 完成菜单权限添加和软件菜单改造 2026-04-12 17:15:15 +08:00
铭坤 21b6b5b270 modified: app/amazon/__pycache__/approve.cpython-39.pyc
modified:   app/amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   app/amazon/__pycache__/main.cpython-39.pyc
	modified:   app/amazon/__pycache__/match_action.cpython-39.pyc
	modified:   app/amazon/__pycache__/tool.cpython-39.pyc
	modified:   app/amazon/approve.py
	modified:   app/amazon/del_brand.py
	modified:   app/amazon/main.py
	modified:   app/amazon/match_action.py
	modified:   app/amazon/tool.py
	modified:   app/assets/delete-brand.js
	modified:   app/new_web_source/delete-brand.html
2026-04-11 23:00:55 +08:00
铭坤 ad2bb0a6ea modified: app/amazon/__pycache__/approve.cpython-39.pyc
modified:   app/amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   app/amazon/__pycache__/main.cpython-39.pyc
	modified:   app/amazon/__pycache__/match_action.cpython-39.pyc
	modified:   app/amazon/__pycache__/tool.cpython-39.pyc
	modified:   app/amazon/approve.py
	modified:   app/amazon/del_brand.py
	modified:   app/amazon/main.py
	modified:   app/amazon/match_action.py
	modified:   app/amazon/tool.py
	modified:   app/assets/delete-brand.js
	modified:   app/new_web_source/delete-brand.html
2026-04-11 23:00:55 +08:00
super 365050b890 提交bug修复 后台权限管理 2026-04-11 22:25:14 +08:00
super 7589b4e418 提交bug修复 后台权限管理 2026-04-11 22:25:14 +08:00
super 73392a9b83 修复BUG,完善匹配店铺 2026-04-11 00:57:34 +08:00
super b400b494ad 修复BUG,完善匹配店铺 2026-04-11 00:57:34 +08:00
super c47c03fde4 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-10 19:35:08 +08:00
super 9a59dac6d0 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-10 19:35:08 +08:00
super 86fd9475e4 匹配回收,bug修复 2026-04-10 19:33:58 +08:00
super 03a85d5523 匹配回收,bug修复 2026-04-10 19:33:58 +08:00
铭坤 2d0d1d3461 modified: app/amazon/__pycache__/approve.cpython-39.pyc
modified:   app/amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   app/amazon/__pycache__/main.cpython-39.pyc
	new file:   app/amazon/__pycache__/match_action.cpython-39.pyc
	new file:   app/amazon/__pycache__/tool.cpython-39.pyc
	new file:   "app/amazon/approve - \345\211\257\346\234\254.py"
	modified:   app/amazon/approve.py
	modified:   app/amazon/del_brand.py
	modified:   app/amazon/main.py
	new file:   app/amazon/match_action.py
	new file:   app/amazon/tool.py
	modified:   app/main.py
	modified:   app/web_source/brand.html
2026-04-10 16:51:52 +08:00
super ccaec4a984 完善后台管理店铺搜索 2026-04-08 21:08:52 +08:00
super 169ba7edb6 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-08 16:14:30 +08:00
super 0327d1cc51 修复接口内容缺失 2026-04-08 16:14:26 +08:00
铭坤 e02ddab599 modified: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/approve.py
	new file:   amazon/backend_api.py
	modified:   amazon/del_brand.py
	modified:   amazon/main.py
	modified:   blueprints/main.py
	modified:   main.py
2026-04-08 16:03:48 +08:00
super 336338cff5 完善后台接口字段 2026-04-07 17:57:03 +08:00
super acff31e652 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-07 14:50:09 +08:00
super ad304a6880 完成店铺增删改查 2026-04-07 14:50:06 +08:00
铭坤 cb34788e53 modified: "web_source/brand-\346\227\247.html"
modified:   web_source/brand.html
	modified:   web_source/templates_backup/brand.html
2026-04-07 14:10:33 +08:00
铭坤 13b0ffb5d8 new file: amazon/__pycache__/approve.cpython-39.pyc
modified:   amazon/__pycache__/del_brand.cpython-39.pyc
	modified:   amazon/__pycache__/main.cpython-39.pyc
	new file:   amazon/approve.py
	modified:   amazon/del_brand.py
	modified:   amazon/main.py
	modified:   main.py
2026-04-07 14:09:42 +08:00
super c9947c4ac8 更改下载方法名 2026-04-06 22:26:44 +08:00
super afffb7aad2 更改下载类型处理 2026-04-06 16:58:58 +08:00
super 9720453ac4 更新商品风险处理 2026-04-05 22:04:21 +08:00
super 1ff6d5220e 新增删除增加公司名 2026-04-04 00:10:08 +08:00
super 46d91fd8ca 提交接口进度完善 2026-04-03 00:53:52 +08:00
super a24db2f73c Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-02 23:29:19 +08:00
super ca9537f862 测试多任务暂存 2026-04-02 23:29:15 +08:00
铭坤 94ae7e68ff modified: app/amazon/__pycache__/del_brand.cpython-39.pyc
modified:   app/amazon/__pycache__/main.cpython-39.pyc
	modified:   app/amazon/main.py
	modified:   app/main.py
2026-04-02 23:03:13 +08:00
super 94e1930538 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-02 20:37:38 +08:00
super 5bbe5a3077 修改多文件 2026-04-02 20:37:35 +08:00
铭坤 8cead01270 modified: app/amazon/del_brand.py
backend/blueprints/get_resource.py
2026-04-02 20:35:50 +08:00
铭坤 99fc14b9f9 modified: backend/app.py
backend/blueprints/get_resource.py
2026-04-02 20:35:12 +08:00
super d3671206e1 完善后端轮询记忆紫鸟店铺逻辑 2026-04-02 12:26:48 +08:00
super 0a8202788b Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-02 01:15:54 +08:00
super 855f1affd9 紫鸟查询店铺更新 2026-04-02 01:15:50 +08:00
铭坤 5a294e5c85 new file: app/amazon/__pycache__/del_brand.cpython-39.pyc
new file:   app/amazon/__pycache__/main.cpython-39.pyc
	modified:   app/amazon/del_brand.py
	modified:   app/amazon/main.py
	modified:   app/blueprints/__pycache__/main.cpython-39.pyc
	modified:   app/blueprints/main.py
	modified:   app/config.py
	modified:   app/main.py
	new file:   "app/web_source/brand-\346\227\247.html"
	modified:   app/web_source/brand.html
2026-04-02 00:03:16 +08:00
super df606a1087 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-04-01 21:20:04 +08:00
super ece3552b89 更新部分内容 2026-04-01 21:20:01 +08:00
铭坤 4df3945131 modified: app/ali_oss.py
new file:   app/amazon/del_brand.py
	new file:   app/amazon/main.py
	modified:   app/blueprints/__pycache__/brand.cpython-39.pyc
	modified:   app/blueprints/__pycache__/communication.cpython-39.pyc
	modified:   app/blueprints/__pycache__/main.cpython-39.pyc
	modified:   app/blueprints/brand.py
	new file:   "app/blueprints/brand_\345\244\207\344\273\275.py"
	modified:   app/blueprints/communication.py
	modified:   app/blueprints/main.py
	modified:   app/config.py
	modified:   app/main.py
2026-04-01 11:53:12 +08:00
super 6eb0f33421 删除模块 取消打开紫鸟 2026-03-31 23:12:46 +08:00
super 25ce9f74b8 处理这个python打开紫鸟 2026-03-30 23:15:08 +08:00
super 0f1f471590 处理掉一些BUG 2026-03-30 22:47:19 +08:00
super d9487b6885 品牌多文件chunk修复 2026-03-30 21:06:10 +08:00
super 9845ab8f2a 暂存 2026-03-30 20:54:05 +08:00
super 6fa130386a Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-03-30 20:48:02 +08:00
super 53df8b9971 暂存 2026-03-30 20:39:13 +08:00
铭坤 d6625762cf modified: app/.env
modified:   app/ali_oss.py
	modified:   app/app.py
	new file:   app/blueprints/__pycache__/communication.cpython-39.pyc
	modified:   app/blueprints/communication.py
	modified:   app/brand_spider/__pycache__/main.cpython-39.pyc
	modified:   app/config.py
	modified:   app/main.py
	modified:   app/static/bg.jpg
	modified:   app/tool/__pycache__/devices.cpython-39.pyc
	modified:   app/web_source/brand.html
	modified:   app/web_source/templates_backup/brand.html
2026-03-30 19:44:04 +08:00
super cb3b9e9cfe 完善删除品牌asin 2026-03-29 19:03:24 +08:00
super 3d39236b13 完成删除品牌 2026-03-29 13:41:03 +08:00
super 9e57fa5762 完成品牌删除模块 2026-03-29 00:22:45 +08:00
super 9c6232bc85 完成前后端紫鸟部分开发 2026-03-28 15:42:18 +08:00
super d3c7938627 完成前后端删除、紫鸟部分开发 2026-03-28 15:42:02 +08:00
super 06256946fa 提交暂存 2026-03-27 22:00:01 +08:00
super 2042d386e2 提交过滤 2026-03-27 21:58:43 +08:00
铭坤 7176754564 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-03-27 21:56:53 +08:00
铭坤 a20222192e modified: assets/convert.js
modified:   assets/dedupe.js
	modified:   assets/split.js
	modified:   blueprints/__pycache__/brand.cpython-311.pyc
	modified:   blueprints/__pycache__/brand.cpython-39.pyc
	new file:   blueprints/communication.py
	modified:   config.py
	modified:   main.py
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/split.html
2026-03-27 21:56:19 +08:00
super a5c2681e88 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-03-27 21:51:34 +08:00
super 5e2f750359 更新运行日志
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 21:51:23 +08:00
super 27602890ab 品牌 2026-03-27 21:48:13 +08:00
铭坤 dfe0d652ce new file: assets/_plugin-vue_export-helper-Dh4yMZWw.js
new file:   assets/_plugin-vue_export-helper-xvHHTGU_.css
	new file:   assets/convert-1dkFPbKa.css
	new file:   assets/convert-6b0yq-M0.css
	new file:   assets/convert-BxkpMHO9.css
	new file:   assets/convert-D4Yv2oRy.css
	new file:   assets/convert-DwbQug2y.css
	modified:   assets/convert.js
	new file:   assets/dedupe-B0eqpVpj.css
	new file:   assets/dedupe-BHE_BCAJ.css
	new file:   assets/dedupe-Day_nGxq.css
	new file:   assets/dedupe-DzFvTfoj.css
	new file:   assets/dedupe-rhGu1E8E.css
	modified:   assets/dedupe.js
	new file:   assets/el-alert-Ct0RpqUD.css
	new file:   assets/pywebview-B6ZNXusn.css
	new file:   assets/pywebview-BRrok0pS.js
	new file:   assets/pywebview-BnpJyyGZ.js
	new file:   assets/pywebview-CGwF8TuM.js
	new file:   assets/pywebview-Chz98E9c.css
	new file:   assets/pywebview-D-PKWjUg.js
	new file:   assets/pywebview-DVgP2-kW.js
	new file:   assets/pywebview-IqgMfeBe.css
	new file:   assets/pywebview-Rm5Hhqpf.js
	new file:   assets/pywebview-leZCedEt.js
	new file:   assets/split-BsJfbBqn.css
	new file:   assets/split-DAa_Usoh.css
	new file:   assets/split-DidKJ84l.css
	new file:   assets/split-R_8V5xgh.css
	new file:   assets/split-_O6NHqDj.css
	modified:   assets/split.js
	modified:   blueprints/__pycache__/brand.cpython-311.pyc
	modified:   blueprints/__pycache__/brand.cpython-39.pyc
	modified:   blueprints/brand.py
	modified:   config.py
	modified:   main.py
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/split.html
2026-03-27 21:35:28 +08:00
super 24076adf98 品牌 2026-03-27 21:33:07 +08:00
super 15a78abc1b 删除品牌 2026-03-27 21:32:00 +08:00
super 7fcdf1a761 提交品牌删除更新 2026-03-26 17:39:20 +08:00
super d0ca28ae2d 提交品牌删除更新 2026-03-26 17:39:01 +08:00
super 32a9494dd6 更新后端新增内容 2026-03-26 16:42:25 +08:00
铭坤 a5da06537e modified: blueprints/__pycache__/__init__.cpython-39.pyc
modified:   blueprints/__pycache__/admin.cpython-39.pyc
	modified:   blueprints/__pycache__/auth.cpython-39.pyc
	modified:   blueprints/__pycache__/brand.cpython-311.pyc
	modified:   blueprints/__pycache__/brand.cpython-39.pyc
	modified:   blueprints/brand.py
	new file:   brand_spider/__pycache__/main.cpython-311.pyc
	modified:   brand_spider/__pycache__/main.cpython-39.pyc
	new file:   brand_spider/__pycache__/web_dec.cpython-311.pyc
	modified:   brand_spider/main.py
	modified:   config.py
	modified:   web_source/admin.html
	modified:   web_source/brand.html
	modified:   web_source/home.html
	modified:   web_source/index.html
	modified:   web_source/login.html
	new file:   web_source/templates_backup/admin.html
	new file:   web_source/templates_backup/brand.html
	new file:   web_source/templates_backup/home.html
	new file:   web_source/templates_backup/index.html
	new file:   web_source/templates_backup/login.html
2026-03-26 16:39:39 +08:00
super 21c6f41c69 增加紫鸟相关接口 2026-03-25 21:33:49 +08:00
super 506eb0faef 完善打包部分的压缩包 2026-03-25 09:52:04 +08:00
super 485b4dd485 完成品牌部分改造 2026-03-24 22:22:37 +08:00
super 4f728107d1 增加用户访问数据总表 2026-03-22 21:27:41 +08:00
super 01e491e332 数据去重完善 2026-03-22 20:58:36 +08:00
super ed91c2ae7d 总表更新 2026-03-22 17:51:34 +08:00
super 55ac81f0cc 修复tab切换问题 2026-03-22 13:39:32 +08:00
super 64e32523cd 完成后台管理开发 2026-03-22 13:33:37 +08:00
super 5b636c3dfd 提交所有内容 2026-03-22 12:45:58 +08:00
super c5d62c71a3 暂替 2026-03-22 11:37:23 +08:00
super fa384a6ec8 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-03-22 11:37:03 +08:00
super 24cf47e1e3 暂提更新 2026-03-22 11:35:45 +08:00
super 8e66926b9e 更新新增三个模块 2026-03-22 11:20:09 +08:00
铭坤 574b372f42 new file: app/assets/_plugin-vue_export-helper-Dh4yMZWw.js
new file:   app/assets/_plugin-vue_export-helper-xvHHTGU_.css
	new file:   app/assets/convert-1dkFPbKa.css
	new file:   app/assets/convert-BxkpMHO9.css
	new file:   app/assets/convert-DwbQug2y.css
	modified:   app/assets/convert.js
	new file:   app/assets/dedupe-B0eqpVpj.css
	new file:   app/assets/dedupe-DzFvTfoj.css
	new file:   app/assets/dedupe-rhGu1E8E.css
	modified:   app/assets/dedupe.js
	new file:   app/assets/el-alert-Ct0RpqUD.css
	new file:   app/assets/pywebview-B6ZNXusn.css
	new file:   app/assets/pywebview-BnpJyyGZ.js
	new file:   app/assets/pywebview-CGwF8TuM.js
	new file:   app/assets/pywebview-D-PKWjUg.js
	new file:   app/assets/pywebview-IqgMfeBe.css
	new file:   app/assets/split-DAa_Usoh.css
	new file:   app/assets/split-DidKJ84l.css
	new file:   app/assets/split-R_8V5xgh.css
	modified:   app/assets/split.js
	modified:   app/blueprints/__pycache__/main.cpython-39.pyc
	modified:   app/blueprints/main.py
	modified:   app/main.py
	modified:   app/new_web_source/convert.html
	modified:   app/new_web_source/dedupe.html
	modified:   app/new_web_source/split.html
2026-03-22 10:29:12 +08:00
super 74a5fb9ce1 增加log输出、跳转tab顺序 2026-03-21 20:34:49 +08:00
super 4b83bf76b4 环境搭建配置 2026-03-21 10:00:16 +08:00
铭坤 82ccd9a8ea Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-03-20 23:16:13 +08:00
铭坤 2dbeec7d6d new file: app/blueprints/__init__.py
new file:   app/blueprints/__pycache__/__init__.cpython-311.pyc
	new file:   app/blueprints/__pycache__/__init__.cpython-39.pyc
	new file:   app/blueprints/__pycache__/admin.cpython-311.pyc
	new file:   app/blueprints/__pycache__/admin.cpython-39.pyc
	new file:   app/blueprints/__pycache__/auth.cpython-311.pyc
	new file:   app/blueprints/__pycache__/auth.cpython-39.pyc
	new file:   app/blueprints/__pycache__/brand.cpython-311.pyc
	new file:   app/blueprints/__pycache__/brand.cpython-39.pyc
	new file:   app/blueprints/__pycache__/image.cpython-311.pyc
	new file:   app/blueprints/__pycache__/image.cpython-39.pyc
	new file:   app/blueprints/__pycache__/main.cpython-311.pyc
	new file:   app/blueprints/__pycache__/main.cpython-39.pyc
	new file:   app/blueprints/admin.py
	new file:   app/blueprints/auth.py
	new file:   app/blueprints/brand.py
	new file:   app/blueprints/image.py
	new file:   app/blueprints/main.py
	new file:   app/brand_spider/__pycache__/main.cpython-39.pyc
	new file:   app/brand_spider/__pycache__/web_dec.cpython-39.pyc
	new file:   app/brand_spider/main.py
	new file:   app/brand_spider/web_dec.py
	new file:   app/static/bg.jpg
	new file:   "app/static/\345\223\201\347\211\214\346\226\207\346\241\243\346\240\274\345\274\217_\346\250\241\346\235\277.xlsx"
	new file:   "app/static/\346\250\241\346\235\2772-\344\273\245\346\226\207\344\273\266\345\244\271\346\226\271\345\274\217\344\270\212\344\274\240.zip"
	new file:   app/tool/.device_id
	new file:   app/tool/__pycache__/devices.cpython-311.pyc
	new file:   app/tool/__pycache__/devices.cpython-39.pyc
	new file:   app/tool/devices.py
2026-03-20 23:04:19 +08:00
super fb32f7bd35 新增接口文档 2026-03-20 19:31:02 +08:00
super 63d3e4047c 打包项目 2026-03-20 18:13:47 +08:00
super 7c6d9dd989 Merge branch 'master' of https://gitee.com/TeaCodeNice/crawler-plugin 2026-03-20 14:26:41 +08:00
铭坤 ce121cf0d0 new file: ali_oss.py
new file:   app.py
	new file:   app/ali_oss.py
	new file:   app/app.py
	new file:   app/app_common.py
	new file:   app/config.py
	new file:   app/coze.py
	new file:   app/generate_api.py
	new file:   app/html_crypto.py
	new file:   app/main.py
	new file:   app/web_source/admin.html
	new file:   app/web_source/brand.html
	new file:   app/web_source/home.html
	new file:   app/web_source/index.html
	new file:   app/web_source/login.html
	new file:   app_common.py
	new file:   blueprints/__init__.py
	new file:   blueprints/__pycache__/__init__.cpython-311.pyc
	new file:   blueprints/__pycache__/__init__.cpython-39.pyc
	new file:   blueprints/__pycache__/admin.cpython-311.pyc
	new file:   blueprints/__pycache__/admin.cpython-39.pyc
	new file:   blueprints/__pycache__/auth.cpython-311.pyc
	new file:   blueprints/__pycache__/auth.cpython-39.pyc
	new file:   blueprints/__pycache__/brand.cpython-311.pyc
	new file:   blueprints/__pycache__/brand.cpython-39.pyc
	new file:   blueprints/__pycache__/image.cpython-311.pyc
	new file:   blueprints/__pycache__/image.cpython-39.pyc
	new file:   blueprints/__pycache__/main.cpython-311.pyc
	new file:   blueprints/__pycache__/main.cpython-39.pyc
	new file:   blueprints/admin.py
	new file:   blueprints/auth.py
	new file:   blueprints/brand.py
	new file:   blueprints/image.py
	new file:   blueprints/main.py
	new file:   brand_spider/__pycache__/main.cpython-39.pyc
	new file:   brand_spider/__pycache__/web_dec.cpython-39.pyc
	new file:   brand_spider/main.py
	new file:   brand_spider/web_dec.py
	new file:   config.py
	new file:   coze.py
	new file:   generate_api.py
	new file:   html_crypto.py
	new file:   main.py
	new file:   static/bg.jpg
	new file:   "static/\345\223\201\347\211\214\346\226\207\346\241\243\346\240\274\345\274\217_\346\250\241\346\235\277.xlsx"
	new file:   "static/\346\250\241\346\235\2772-\344\273\245\346\226\207\344\273\266\345\244\271\346\226\271\345\274\217\344\270\212\344\274\240.zip"
	new file:   tool/.device_id
	new file:   tool/__pycache__/devices.cpython-311.pyc
	new file:   tool/__pycache__/devices.cpython-39.pyc
	new file:   tool/devices.py
2026-03-20 11:23:57 +08:00
1550 changed files with 1151472 additions and 27908 deletions
+48
View File
@@ -0,0 +1,48 @@
name: Build Backend JAR
on:
push:
branches: [master]
workflow_dispatch:
inputs:
version:
description: Version tag
required: false
default: ""
jobs:
build:
runs-on: ubuntu-latest
container: maven:3.9-eclipse-temurin-21
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test (Java: unit + contract + ArchUnit)
working-directory: backend-java
run: mvn test -q
- name: Package
working-directory: backend-java
run: mvn clean package -DskipTests -q
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: backend-jar
path: backend-java/target/*.jar
frontend-test:
runs-on: ubuntu-latest
container: node:24-alpine
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
working-directory: frontend-vue
run: npm ci
- name: Type check (vue-tsc)
working-directory: frontend-vue
run: npm run build
- name: Frontend contract tests (node --test)
working-directory: frontend-vue
run: node --test tests/*.test.ts
+107 -20
View File
@@ -1,41 +1,128 @@
# frontend-vue dependencies
# ===== frontend-vue =====
frontend-vue/node_modules/
# frontend-vue build output
frontend-vue/dist/
frontend-vue/new_web_source
# generated type declarations
frontend-vue/auto-imports.d.ts
frontend-vue/components.d.ts
# logs
frontend-vue/npm-debug.log*
frontend-vue/yarn-debug.log*
frontend-vue/yarn-error.log*
frontend-vue/pnpm-debug.log*
# backend-java build output
# ===== backend-java =====
backend-java/target/
# backend-java runtime data
backend-java/data/
backend-java/*.log
backend-java/logs/
# backend-java local config
backend-java/src/main/resources/application-local.yml
# backend-java IDE files
backend-java/.idea/
backend-java/*.iml
# desktop app
# ===== backend / app =====
__pycache__/
backend/tmp/
backend/__pycache__
app/__pycache__
app/new_web_source
app/user_data/
# ===== logs =====
logs/
aiimage-backend.log*
# ===== Python =====
__pycache__/
**/__pycache__/
*.py[cod]
*$py.class
*.pyo
.Python
*.egg-info/
*.egg
MANIFEST
.installed.cfg
# Build / packaging
app.zip
build/
dist/
develop-eggs/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
# Virtual environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
.python-version
# Testing
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
htmlcov/
# Type checking
.mypy_cache/
.dmypy.json
dmypy.json
.pyre/
.pytype/
# Jupyter
.ipynb_checkpoints
*.ipynb_checkpoints/
profile_default/
ipython_config.py
# ===== Database =====
*.db
*.sqlite3
# ===== Misc =====
desktop/
ERP-Demo/
xlsx/
app/__pycache__
backend/__pycache__
app/assets/
app/new_web_source
app/user_data/
.omx/
.codex
.rtk
OPS_REDIS_MYSQL_OPTIMIZATION_NOTES.md
架构.md
*ts.%
.omc
# ===== 本地规划文档(不入库)=====
docs/plans/
docs/*plan*.md
backend-java/docs/plans/
backend-java/docs/*plan*.md
backend-java/docs/specs/
backend-java/docs/*audit*.md
# ===== 进度/规划工具(本地使用,不入库)=====
check_progress.py
progress.json
progress_*.json
# ===== 本地预览工具(不入库)=====
backend/_preview_mock.py
@@ -0,0 +1,73 @@
import { expect, test, type Page } from '@playwright/test'
async function open(page: Page, width: number, path = '/admin-vue/') {
await page.setViewportSize({ width, height: 900 })
await page.goto(path)
}
test('test_task_017_desktop_shell_responsive_normal_primary_path', async ({ page }) => {
await open(page, 1440)
await expect(page.locator('h2')).toHaveText('用户管理')
const shell = page.locator('.admin-shell')
await expect(shell).not.toHaveClass(/is-collapsed/)
await expect(page.locator('.admin-brand-copy strong')).toHaveText('数富AI')
await expect(page.locator('.sidebar-collapse')).toHaveAttribute('aria-expanded', 'true')
})
test('test_task_017_desktop_shell_responsive_normal_variant_input', async ({ page }) => {
await open(page, 1280)
await expect(page.locator('h2')).toHaveText('用户管理')
await expect(page.locator('.admin-shell')).not.toHaveClass(/is-collapsed/)
})
test('test_task_017_desktop_shell_responsive_normal_repeated_operation_is_idempotent', async ({ page }) => {
await open(page, 1440)
await expect(page.locator('.sidebar-collapse')).toHaveAttribute('aria-expanded', 'true')
const toggle = page.locator('.sidebar-collapse')
await toggle.click()
await expect(page.locator('.admin-shell')).toHaveClass(/is-collapsed/)
await toggle.click()
await expect(page.locator('.admin-shell')).not.toHaveClass(/is-collapsed/)
await expect(toggle).toHaveAttribute('aria-expanded', 'true')
})
test('test_task_017_desktop_shell_responsive_boundary_empty_input', async ({ page }) => {
await open(page, 640)
await expect(page.locator('h2')).toHaveText('用户管理')
await expect(page.locator('.admin-shell')).toHaveClass(/is-collapsed/)
await expect(page.locator('.brand-copy, .admin-brand-copy')).toHaveCount(0)
await expect(page.locator('.sidebar-collapse')).toHaveAttribute('aria-expanded', 'false')
})
test('test_task_017_desktop_shell_responsive_boundary_single_item', async ({ page }) => {
await open(page, 700)
await expect(page.locator('.admin-shell')).toHaveClass(/is-collapsed/)
await page.locator('.sidebar-collapse').click()
await expect(page.locator('.admin-shell')).not.toHaveClass(/is-collapsed/)
await expect(page.locator('.admin-brand-copy strong')).toHaveText('数富AI')
})
test('test_task_017_desktop_shell_responsive_boundary_limit_or_missing_field', async ({ page }) => {
await open(page, 900)
await expect(page.locator('.admin-shell')).toHaveClass(/is-collapsed/)
await open(page, 901, '/admin-vue/account/users')
await expect(page.locator('.admin-shell')).not.toHaveClass(/is-collapsed/)
})
test('test_task_017_desktop_shell_responsive_invalid_input_rejected', async ({ page }) => {
// 手动折叠偏好持久化,刷新后仍保持(不因页面重载而回弹)。
await open(page, 1440)
await page.locator('.sidebar-collapse').click()
await expect(page.locator('.admin-shell')).toHaveClass(/is-collapsed/)
await page.reload()
await expect(page.locator('.admin-shell')).toHaveClass(/is-collapsed/)
})
test('test_task_017_desktop_shell_responsive_dependency_failure_returns_actionable_message', async ({ page }) => {
// 桌面/窄屏两种宽度下壳层均无初始化错误、导航地标可见。
await open(page, 1440)
await expect(page.locator('.el-alert--error')).toHaveCount(0)
await expect(page.getByRole('navigation', { name: '侧边栏菜单' })).toBeVisible()
await open(page, 820, '/admin-vue/account/users')
await expect(page.locator('.el-alert--error')).toHaveCount(0)
})
@@ -0,0 +1,77 @@
import { expect, test, type Page } from '@playwright/test'
async function openUsers(page: Page) {
await page.goto('/admin-vue/')
await expect(page.locator('h2')).toHaveText('用户管理')
}
test('test_task_018_shell_accessibility_normal_primary_path', async ({ page }) => {
await openUsers(page)
await expect(page.getByRole('navigation', { name: '侧边栏菜单' })).toBeVisible()
})
test('test_task_018_shell_accessibility_normal_variant_input', async ({ page }) => {
await openUsers(page)
const toggle = page.locator('.sidebar-collapse')
await expect(toggle).toHaveAttribute('aria-label', '切换侧边栏')
await expect(toggle).toHaveAttribute('aria-expanded', 'true')
await expect(toggle).toHaveAttribute('type', 'button')
})
test('test_task_018_shell_accessibility_normal_repeated_operation_is_idempotent', async ({ page }) => {
await openUsers(page)
const toggle = page.locator('.sidebar-collapse')
await toggle.click()
await expect(toggle).toHaveAttribute('aria-expanded', 'false')
await toggle.click()
await expect(toggle).toHaveAttribute('aria-expanded', 'true')
})
test('test_task_018_shell_accessibility_boundary_empty_input', async ({ page }) => {
await openUsers(page)
await expect(page.locator('.skip-link')).toHaveAttribute('href', '#admin-content')
await expect(page.locator('#admin-content')).toHaveCount(1)
})
test('test_task_018_shell_accessibility_boundary_single_item', async ({ page }) => {
await openUsers(page)
// 键盘可聚焦并可回车触发折叠切换。
await page.locator('.sidebar-collapse').focus()
await expect(page.locator('.sidebar-collapse')).toBeFocused()
await page.keyboard.press('Enter')
await expect(page.locator('.admin-shell')).toHaveClass(/is-collapsed/)
})
test('test_task_018_shell_accessibility_boundary_limit_or_missing_field', async ({ page }) => {
await openUsers(page)
await expect(page.locator('main#admin-content')).toBeVisible()
await expect(page.getByRole('main')).toHaveCount(1)
})
test('test_task_018_shell_accessibility_invalid_input_rejected', async ({ page }) => {
await openUsers(page)
// 折叠后品牌文案不应留在可感知/可聚焦树中。
await page.locator('.sidebar-collapse').click()
await expect(page.locator('.admin-brand-copy')).toHaveCount(0)
})
test('test_task_018_shell_accessibility_dependency_failure_returns_actionable_message', async ({ page }) => {
await openUsers(page)
// 标题层级:顶栏 h1(页面标题) + 页面 h2;键盘焦点样式已定义。
await expect(page.locator('.admin-topbar h1')).toHaveText('用户管理')
await expect(page.locator('main h2')).toHaveText('用户管理')
const hasFocusStyle = await page.evaluate(() => {
const rules: string[] = []
for (const sheet of document.styleSheets) {
try {
for (const rule of sheet.cssRules) {
if (rule.cssText.includes(':focus-visible')) rules.push(rule.cssText)
}
} catch {
// 跨域样式表忽略
}
}
return rules.some((t) => t.includes('sidebar-collapse'))
})
expect(hasFocusStyle).toBe(true)
})
@@ -0,0 +1,64 @@
import { expect, test, type Page } from '@playwright/test'
async function gotoRoute(page: Page, path: string) {
await page.goto(path)
}
test('test_task_019_first_batch_mount_normal_primary_path', async ({ page }) => {
await gotoRoute(page, '/admin-vue/account/users')
await expect(page.locator('main h2')).toHaveText('用户管理')
await expect(page.locator('.admin-topbar h1')).toHaveText('用户管理')
})
test('test_task_019_first_batch_mount_normal_variant_input', async ({ page }) => {
await gotoRoute(page, '/admin-vue/account/menus')
await expect(page.locator('main h2')).toHaveText('菜单管理')
await expect(page.locator('.admin-topbar h1')).toHaveText('菜单管理')
})
test('test_task_019_first_batch_mount_normal_repeated_operation_is_idempotent', async ({ page }) => {
await gotoRoute(page, '/admin-vue/account/groups')
await expect(page.locator('main h2')).toHaveText('数据权限分组')
await gotoRoute(page, '/admin-vue/account/users')
await expect(page.locator('main h2')).toHaveText('用户管理')
await gotoRoute(page, '/admin-vue/account/groups')
await expect(page.locator('main h2')).toHaveText('数据权限分组')
})
test('test_task_019_first_batch_mount_boundary_empty_input', async ({ page }) => {
// 根路由跳转到首个可见页面(用户管理)。
await gotoRoute(page, '/admin-vue/')
await expect(page.locator('main h2')).toHaveText('用户管理')
await expect(page).toHaveURL(/\/account\/users$/)
})
test('test_task_019_first_batch_mount_boundary_single_item', async ({ page }) => {
await gotoRoute(page, '/admin-vue/account/menus')
await expect(page.locator('main h2')).toHaveText('菜单管理')
const active = page.locator('.el-menu-item.is-active')
await expect(active).toHaveText('菜单管理')
})
test('test_task_019_first_batch_mount_boundary_limit_or_missing_field', async ({ page }) => {
// 三个页面均可从侧边栏导航切换(挂载于同一壳层实例)。
await gotoRoute(page, '/admin-vue/account/users')
await expect(page.locator('main h2')).toHaveText('用户管理')
await page.getByText('菜单管理', { exact: true }).first().click()
await expect(page.locator('main h2')).toHaveText('菜单管理')
await page.getByText('数据权限分组', { exact: true }).first().click()
await expect(page.locator('main h2')).toHaveText('数据权限分组')
})
test('test_task_019_first_batch_mount_invalid_input_rejected', async ({ page }) => {
await gotoRoute(page, '/admin-vue/no-such-page')
await expect(page.locator('.not-found')).toBeVisible()
await expect(page.locator('.admin-topbar h1')).toHaveText('页面不存在')
})
test('test_task_019_first_batch_mount_dependency_failure_returns_actionable_message', async ({ page }) => {
// 分组内页面展示 分组->页面 两级面包屑。
await gotoRoute(page, '/admin-vue/account/users')
await expect(page.locator('.admin-breadcrumb')).toBeVisible()
await expect(page.locator('.admin-breadcrumb')).toContainText('账号权限')
await expect(page.locator('.admin-breadcrumb')).toContainText('用户管理')
})
@@ -0,0 +1,75 @@
import { expect, test, type Page } from '@playwright/test'
async function openAdmin(page: Page) {
await page.goto('/admin-vue/')
await expect(page.locator('main h2')).toHaveText('用户管理')
}
test('test_task_020_shell_browser_smoke_normal_primary_path', async ({ page }) => {
await openAdmin(page)
await expect(page.getByRole('navigation', { name: '侧边栏菜单' })).toBeVisible()
await expect(page.locator('.admin-user-meta strong')).toHaveText('admin')
await expect(page.locator('.admin-user-meta span')).toHaveText('super_admin')
await expect(page.getByText('账号权限', { exact: true }).first()).toBeVisible()
})
test('test_task_020_shell_browser_smoke_normal_variant_input', async ({ page }) => {
await openAdmin(page)
await page.locator('.sidebar-collapse').click()
await expect(page.locator('.admin-shell')).toHaveClass(/is-collapsed/)
await page.locator('.sidebar-collapse').click()
await expect(page.locator('.admin-shell')).not.toHaveClass(/is-collapsed/)
})
test('test_task_020_shell_browser_smoke_normal_repeated_operation_is_idempotent', async ({ page }) => {
await openAdmin(page)
await page.reload()
await expect(page.locator('main h2')).toHaveText('用户管理')
await expect(page.locator('.global-error-stack')).toHaveCount(0)
})
test('test_task_020_shell_browser_smoke_boundary_empty_input', async ({ page }) => {
await page.goto('/admin-vue/definitely/not/exists')
await expect(page.locator('.not-found')).toBeVisible()
await expect(page.locator('.not-found')).toContainText('404')
})
test('test_task_020_shell_browser_smoke_boundary_single_item', async ({ page }) => {
await openAdmin(page)
await page.getByRole('button', { name: '退出登录' }).click()
await expect(page.locator('.el-message-box')).toBeVisible()
await expect(page.locator('.el-message-box')).toContainText('确定要退出当前账号吗?')
await page.locator('.el-message-box').getByRole('button', { name: '取消' }).click()
await expect(page.locator('.el-message-box')).toHaveCount(0)
await expect(page).toHaveURL(/\/admin-vue\//)
await expect(page.locator('main h2')).toHaveText('用户管理')
})
test('test_task_020_shell_browser_smoke_boundary_limit_or_missing_field', async ({ page }) => {
await openAdmin(page)
await page.getByRole('button', { name: '退出登录' }).click()
await page.locator('.el-message-box').getByRole('button', { name: '退出' }).click()
await page.waitForURL(/\/login/, { timeout: 10_000 })
})
test('test_task_020_shell_browser_smoke_invalid_input_rejected', async ({ page }) => {
// 整段冒烟无未捕获脚本错误(错误不会静默遗留到控制台)。
const errors: string[] = []
page.on('pageerror', (error) => errors.push(error.message))
await openAdmin(page)
await page.goto('/admin-vue/account/menus')
await expect(page.locator('main h2')).toHaveText('菜单管理')
await page.goto('/admin-vue/account/groups')
await expect(page.locator('main h2')).toHaveText('数据权限分组')
expect(errors).toEqual([])
})
test('test_task_020_shell_browser_smoke_dependency_failure_returns_actionable_message', async ({ page }) => {
await openAdmin(page)
// 取消确认后无遗留弹层/遮罩;继续导航正常。
await page.getByRole('button', { name: '退出登录' }).click()
await page.locator('.el-message-box').getByRole('button', { name: '取消' }).click()
await expect(page.locator('.el-overlay')).toHaveCount(0)
await page.locator('.admin-brand-copy, .admin-topbar h1').first().click({ force: true })
await expect(page.locator('.admin-topbar h1')).toHaveText('用户管理')
})
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
{
"name": "crawler-plugin-admin-frontend-vue",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite --host --port 5174",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"test": "node --test tests/*.test.ts",
"test:live": "node --test tests/live/*.test.ts",
"test:browser": "playwright test"
},
"dependencies": {
"axios": "^1.13.6",
"element-plus": "^2.11.4",
"pinia": "^3.0.3",
"vue": "^3.5.18",
"vue-router": "^4.5.1"
},
"devDependencies": {
"@playwright/test": "^1.63.0",
"@types/node": "^26.4.1",
"@vitejs/plugin-vue": "^6.0.1",
"typescript": "^5.9.2",
"vite": "^7.3.1",
"vue-tsc": "^3.0.6"
}
}
+35
View File
@@ -0,0 +1,35 @@
import { defineConfig } from '@playwright/test'
/**
* 浏览器验收:起 mock admin API(18100) + vite dev(5174, /api 代理到 mock)。
* 本地用已安装的 MS Edge(channel: msedge)运行,无需下载 Chromium。
*/
export default defineConfig({
testDir: './e2e',
timeout: 45_000,
expect: { timeout: 10_000 },
fullyParallel: false,
workers: 1,
retries: 0,
reporter: [['list']],
use: {
baseURL: 'http://127.0.0.1:5174',
channel: 'msedge',
headless: true,
viewport: { width: 1440, height: 900 },
locale: 'zh-CN',
},
webServer: [
{
command: 'node scripts/mock-admin-server.mjs',
port: 18100,
reuseExistingServer: true,
},
{
command: 'set VITE_API_TARGET=http://127.0.0.1:18100&& npm run dev',
port: 5174,
reuseExistingServer: true,
timeout: 120_000,
},
],
})
@@ -0,0 +1,63 @@
// 本地浏览器验收用 mock(仅测试,不随前端产物发布):模拟 Admin 壳层所需的最小 API。
import { createServer } from 'node:http'
const PORT = Number(process.env.MOCK_PORT || 18100)
const MENU_TREE = [
{
key: 'account',
name: '账号权限',
children: [
{ key: 'admin_users', name: '用户管理', route: '/account/users' },
{ key: 'admin_columns', name: '菜单管理', route: '/account/menus' },
{ key: 'admin_group_manage', name: '数据权限分组', route: '/account/groups' },
],
},
]
function json(res, payload, status = 200) {
const body = JSON.stringify(payload)
res.writeHead(status, {
'Content-Type': 'application/json; charset=utf-8',
'Cache-Control': 'no-store',
'Content-Length': Buffer.byteLength(body),
})
res.end(body)
}
const server = createServer((req, res) => {
const url = (req.url || '').split('?')[0]
const method = req.method || 'GET'
console.log(`[mock] ${method} ${url}`)
if (url === '/api/admin/current-user') {
return json(res, { success: true, data: { item: { id: 1, username: 'admin', role: 'super_admin' } } })
}
if (url === '/api/admin/current-user/menus') {
return json(res, { success: true, data: { items: MENU_TREE } })
}
if (url === '/api/admin/logout') {
return json(res, { success: true })
}
if (url === '/api/admin/users') {
return json(res, {
success: true,
data: {
items: [{ id: 1, username: 'admin', role: 'super_admin', creatorUsername: 'system', createdAt: '2026-01-01 00:00:00' }],
total: 1,
},
})
}
if (url === '/api/admin/permission-menus') {
return json(res, { success: true, data: { items: [] } })
}
if (url === '/api/admin/shop-manage-groups') {
return json(res, { success: true, data: { items: [] } })
}
if (url.startsWith('/api/')) {
return json(res, { success: true, data: { items: [], total: 0 } })
}
return json(res, { success: true }, 200)
})
server.listen(PORT, () => console.log(`mock admin api listening on ${PORT}`))
+95
View File
@@ -0,0 +1,95 @@
/** API 响应解包与错误归一化(任务 22):纯函数,无框架依赖。 */
export const REQUEST_FALLBACK_MESSAGE = '网络异常,请稍后重试'
function textOf(value: Record<string, unknown>): string {
const message = value.message
const error = value.error
if (typeof message === 'string' && message.trim()) return message.trim()
if (typeof error === 'string' && error.trim()) return error.trim()
return ''
}
/**
* 统一解包 Java 响应:
* - success=false -> 抛错(取 message/error,空则“请求失败”);
* - 带非空 data -> 返回 data;
* - 否则原样返回(允许 {item}/{items} 等信封由调用方再解)。
*/
export function unwrap<T>(payload: unknown): T {
const value = payload as Record<string, unknown> | null
if (!value || typeof value !== 'object') return payload as T
if (value.success === false) {
throw new Error(textOf(value) || '请求失败')
}
if ('data' in value && value.data !== null && value.data !== undefined) {
return value.data as T
}
return payload as T
}
/** 从任意负载取错误文案;缺省回退。 */
export function errorTextOf(payload: unknown): string {
if (payload instanceof Error) return payload.message.trim() || REQUEST_FALLBACK_MESSAGE
if (payload && typeof payload === 'object') {
const text = textOf(payload as Record<string, unknown>)
if (text) return text
}
if (typeof payload === 'string' && payload.trim()) return payload.trim()
return REQUEST_FALLBACK_MESSAGE
}
/** 负载/状态码是否 401(未登录)。 */
export function isUnauthorized(payload: unknown): boolean {
const record = payload as { status?: unknown; statusCode?: unknown; code?: unknown } | null
if (!record || typeof record !== 'object') return false
return [record.status, record.statusCode, record.code].some((v) => v === 401)
}
/** Axios 错误(带 response)或普通 Error 统一取可展示文案。 */
export function requestErrorMessage(error: unknown): string {
const response = (error as { response?: { data?: unknown; status?: number } })?.response
if (response) {
const text = errorTextOf(response.data)
if (text) return text
}
return errorTextOf(error)
}
/** 当前地址作为登录跳转的 redirect 参数(encodeURIComponent 后)。 */
export function loginRedirectTarget(location: { pathname: string; search: string }): string {
return encodeURIComponent(`${location.pathname}${location.search}`)
}
/** 登录页统一入口;401 一律跳此路径。 */
export const LOGIN_PATH = '/login'
/** 当前 pathname 是否处于登录页(去掉可能携带的查询串后比较)。 */
export function isLoginLocation(pathname: string): boolean {
if (typeof pathname !== 'string') return false
const queryAt = pathname.indexOf('?')
return (queryAt >= 0 ? pathname.slice(0, queryAt) : pathname) === LOGIN_PATH
}
/** 把请求 URL(相对或绝对)规整为相对路径,便于与登录入口比较。 */
export function requestRelativePath(url: string): string {
if (typeof url !== 'string') return ''
const noQuery = url.split('?')[0]
const match = noQuery.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/]+(.*)$/)
return match ? match[1] : noQuery
}
/** 401 失败请求本身是否指向登录/认证端点(登录提交失败不应再被踢回登录页)。 */
export function isAuthEndpointRequest(url: string | undefined): boolean {
return requestRelativePath(url || '') === LOGIN_PATH
}
/**
* 401 是否应执行“跳 /login”:已处于登录页或失败请求即登录端点时不应再跳,
* 否则会在登录页循环跳转或吞掉登录失败反馈。
*/
export function shouldRedirectUnauthorized(currentPathname: string, requestUrl?: string): boolean {
if (isLoginLocation(currentPathname)) return false
if (isAuthEndpointRequest(requestUrl)) return false
return true
}
+32
View File
@@ -0,0 +1,32 @@
import axios from 'axios'
import { isUnauthorized, loginRedirectTarget, shouldRedirectUnauthorized } from './envelope'
export { unwrap } from './envelope'
export const http = axios.create({
baseURL: '/',
withCredentials: true,
timeout: 30_000,
})
function redirectToLogin(requestUrl?: string): void {
if (typeof window === 'undefined') return
// 已在登录页或失败请求即登录端点时不再跳转,避免登录页循环与吞掉登录失败反馈。
if (!shouldRedirectUnauthorized(window.location.pathname, requestUrl)) return
const target = loginRedirectTarget(window.location)
window.location.assign(`/login?redirect=${target}`)
}
http.interceptors.response.use(
(response) => {
// Java 未登录以 HTTP 200 + body.code=401 返回,需统一按未登录处理。
if (isUnauthorized(response.data)) redirectToLogin(response.config?.url)
return response
},
(error) => {
if (error?.response?.status === 401 || isUnauthorized(error?.response?.data)) {
redirectToLogin(error?.config?.url)
}
return Promise.reject(error)
},
)
@@ -0,0 +1,25 @@
import { unwrap } from './envelope.ts'
import type { AdminMenuNode, AdminUser } from '../types/admin'
/** 解析当前用户响应:支持 data:{item} 与 {item}/{直接对象} 信封。 */
export function parseCurrentUser(payload: unknown): AdminUser {
const value = unwrap<AdminUser | { item?: AdminUser }>(payload)
const user =
value && typeof value === 'object' && 'item' in value && value.item
? value.item
: (value as AdminUser)
if (!user || typeof user.id !== 'number') {
throw new Error('当前用户响应缺少有效 id')
}
return user
}
/**
* 解析菜单树响应:支持 data:{items} 与 {items}/数组 信封。
* 返回后端树形节点;空/缺省按 [] 处理,与“接口失败”(抛错) 区分开。
*/
export function parseMenuTree(payload: unknown): AdminMenuNode[] {
const value = unwrap<AdminMenuNode[] | { items?: AdminMenuNode[] }>(payload)
if (Array.isArray(value)) return value
return (value && Array.isArray(value.items) ? value.items : []) as AdminMenuNode[]
}
+20
View File
@@ -0,0 +1,20 @@
import { http } from './http'
import { parseCurrentUser, parseMenuTree } from './session-model'
import type { AdminMenuNode, AdminUser, ApiEnvelope } from '../types/admin'
export async function fetchCurrentUser(): Promise<AdminUser> {
const { data } = await http.get<ApiEnvelope<{ item: AdminUser }> | AdminUser>('/api/admin/current-user')
return parseCurrentUser(data)
}
export async function fetchAdminMenuTree(): Promise<AdminMenuNode[]> {
const { data } = await http.get<
ApiEnvelope<{ items: AdminMenuNode[] }> | { items: AdminMenuNode[] } | AdminMenuNode[]
>('/api/admin/current-user/menus')
return parseMenuTree(data)
}
export async function logout(): Promise<void> {
// 登出走 auth 模块根端点 POST /logout(下发清除会话 cookie);旧 api/admin 前缀路径后端无映射。
await http.post('/logout', undefined, { headers: { 'X-Requested-With': 'XMLHttpRequest' } })
}
+76
View File
@@ -0,0 +1,76 @@
/** 用户管理列表/分页 DTO(任务 41):纯逻辑,无框架依赖,与 Java AdminUserController 对齐。 */
import type { AdminUser } from '../types/admin'
export const USER_PAGE_DEFAULT_SIZE = 15
export const USER_PAGE_MIN_PAGE = 1
export const USER_PAGE_MAX_SIZE = 200
/** 前端用户列表筛选/分页状态(页面局部,不入 Pinia)。 */
export interface UserListParams {
page: number
pageSize: number
/** 用户名模糊关键字(对应后端 username|search 的 kw)。 */
keyword?: string
createdById?: number | null
adminId?: number | null
}
/** 序列化到 GET /api/admin/users 的查询参数(Java snake_case)。 */
export interface UserListQuery {
page: number
page_size: number
username?: string
search?: string
created_by_id?: number
admin_id?: number
}
/** 用户列表项即 AdminUser(与 Java AdminUserItemVo 字段对齐)。 */
export type AdminUserItem = AdminUser
/** 分页结果:与 Java AdminUserListVo.items/total/page/page_size 归一后的前端 DTO。 */
export interface UserPageResult {
items: AdminUserItem[]
total: number
page: number
pageSize: number
currentUserId?: number | null
currentUserUsername?: string
admins?: Array<{ id: number; username: string }>
}
function finiteInt(value: unknown): number | null {
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
}
/** 归一化分页/筛选参数:页码下限 1、页大小 1..上限,空关键字视为无过滤。 */
export function normalizeUserPageParams(raw: Partial<UserListParams>): UserListParams {
const page = Math.max(finiteInt(raw.page) ?? USER_PAGE_MIN_PAGE, USER_PAGE_MIN_PAGE)
const rawSize = finiteInt(raw.pageSize)
const pageSize =
rawSize === null || rawSize < USER_PAGE_MIN_PAGE
? USER_PAGE_DEFAULT_SIZE
: Math.min(rawSize, USER_PAGE_MAX_SIZE)
const keyword = typeof raw.keyword === 'string' ? raw.keyword.trim() || undefined : undefined
return {
page,
pageSize,
keyword,
createdById: typeof raw.createdById === 'number' ? raw.createdById : null,
adminId: typeof raw.adminId === 'number' ? raw.adminId : null,
}
}
/** 把前端分页/筛选状态转成 Java 查询参数(缺省字段不下发)。 */
export function toUserListQuery(params: UserListParams): UserListQuery {
const query: UserListQuery = { page: params.page, page_size: params.pageSize }
if (params.keyword) query.username = params.keyword
if (params.createdById != null) query.created_by_id = params.createdById
if (params.adminId != null) query.admin_id = params.adminId
return query
}
/** 无数据分页结果缺省值(首屏/加载前占位)。 */
export function emptyUserPageResult(): UserPageResult {
return { items: [], total: 0, page: USER_PAGE_MIN_PAGE, pageSize: USER_PAGE_DEFAULT_SIZE }
}
+54
View File
@@ -0,0 +1,54 @@
/** 用户列表查询适配(任务 42):纯解析模块,无 axios 依赖,与 Java AdminUserListVo 对齐。 */
import { unwrap } from './envelope.ts'
import { emptyUserPageResult, type UserPageResult } from './users-dto.ts'
import type { AdminUser } from '../types/admin'
function text(value: unknown): string {
return typeof value === 'string' ? value : ''
}
function numberOrNull(value: unknown): number | null {
return typeof value === 'number' && Number.isFinite(value) ? value : null
}
/** 把 Java AdminUserItemVo(snake_case) 映射为前端 AdminUser(camelCase);缺 id 视为无效。 */
export function toAdminUserItem(raw: unknown): AdminUser | null {
if (!raw || typeof raw !== 'object') return null
const r = raw as Record<string, unknown>
const id = numberOrNull(r.id)
if (id === null) return null
const item: AdminUser = { id, username: text(r.username), role: text(r.role) }
if (typeof r.is_admin === 'boolean') item.isAdmin = r.is_admin
const createdById = numberOrNull(r.created_by_id)
if (createdById !== null) item.createdById = createdById
const createdAt = text(r.created_at)
if (createdAt) item.createdAt = createdAt
const creator = text(r.creator_username)
if (creator) item.creatorUsername = creator
const abbr = text(r.pinyin_abbr)
if (abbr) item.pinyinAbbr = abbr
return item
}
/**
* 归一化 Java 用户列表负载(data:{items,total,page,page_size} 或已解包 VO)为前端
* UserPageResult;空/缺省字段回默认,success=false 抛后端 message。
*/
export function parseUserPage(payload: unknown): UserPageResult {
const out = emptyUserPageResult()
const core = unwrap<unknown>(payload)
if (!core || typeof core !== 'object') return out
const record = core as Record<string, unknown>
if (Array.isArray(record.items)) {
out.items = record.items
.map((raw) => toAdminUserItem(raw))
.filter((item): item is AdminUser => item !== null)
}
if (typeof record.total === 'number') out.total = record.total
if (typeof record.page === 'number' && record.page >= 1) out.page = Math.floor(record.page)
const rawSize = record.page_size ?? record.pageSize
if (typeof rawSize === 'number' && rawSize >= 1) out.pageSize = Math.floor(rawSize)
if (typeof record.current_user_id === 'number') out.currentUserId = record.current_user_id
if (typeof record.current_user_username === 'string') out.currentUserUsername = record.current_user_username
return out
}
+15
View File
@@ -0,0 +1,15 @@
import { http } from './http'
import { parseUserPage } from './users-model'
import {
normalizeUserPageParams,
toUserListQuery,
type UserListParams,
type UserPageResult,
} from './users-dto'
/** 分页查询用户列表:归一化参数 → GET /api/admin/users → 解析 Java 分页负载。 */
export async function fetchUserList(params: Partial<UserListParams> = {}): Promise<UserPageResult> {
const normalized = normalizeUserPageParams(params)
const { data } = await http.get('/api/admin/users', { params: toUserListQuery(normalized) })
return parseUserPage(data)
}
+38
View File
@@ -0,0 +1,38 @@
/**
* /admin-vue/ 基准路径与 History 路由约定(任务 2 冻结的单一事实源)。
* Vite base、Vue Router history base、Nginx location 三者必须共用此常量。
*/
export const APP_BASE_PATH = '/admin-vue/'
/** 前端路由一律使用 History 模式,不引入 hash(旧 #tab 兼容不在目标契约内)。 */
export const APP_HISTORY_MODE = 'history' as const
function invalidBaseMessage(value: unknown): string {
return `管理后台 base 路径非法: ${JSON.stringify(value)},必须以 / 开头且形如 /xxx/,不允许空值或 ..`
}
/** 校验并归一化 base 路径:保证以 / 开头、无 ..、无内部连续斜杠、以单个 / 结尾。 */
export function ensureAppBasePath(value: string): string {
if (typeof value !== 'string' || value.length === 0) throw new Error(invalidBaseMessage(value))
if (!value.startsWith('/')) throw new Error(invalidBaseMessage(value))
if (value.includes('//')) throw new Error(invalidBaseMessage(value))
if (value.includes('..')) throw new Error(invalidBaseMessage(value))
return value.endsWith('/') ? value : `${value}/`
}
/** 把后台页面相对路径段拼成绝对 URL(不含 base 前缀的历史兼容子路径段由路由负责)。 */
export function joinAdminPath(...segments: string[]): string {
const parts: string[] = []
for (const segment of segments) {
for (const raw of segment.split('/')) {
const part = raw.trim()
if (!part || part === '.') continue
if (part === '..') {
throw new Error(`admin 路由段不允许出现 ..(越权跳转): ${segments.join('/')}`)
}
parts.push(part)
}
}
if (parts.length === 0) return APP_BASE_PATH
return `${APP_BASE_PATH}${parts.join('/')}`
}
+113
View File
@@ -0,0 +1,113 @@
import { existsSync, readFileSync, readdirSync } from 'node:fs'
import { join, resolve } from 'node:path'
export const STANDALONE_PACKAGE_NAME = 'crawler-plugin-admin-frontend-vue'
/** 后台壳层允许存在的源码目录(任务 1 冻结的工作区边界,供验收脚本复用)。 */
export const ADMIN_SOURCE_DIRS = [
'src/layout',
'src/router',
'src/styles',
'src/types',
'src/config',
'src/pages',
] as const
export const REQUIRED_MANIFEST_FILES = [
'package.json',
'index.html',
'vite.config.ts',
'tsconfig.json',
'src/main.ts',
'src/App.vue',
] as const
// 客户端工程耦合标记:后台工程内出现即代表越界。用带路径/产物语义的标记,
// 避免与本工程自身包名后缀(…admin-frontend-vue)误匹配。扫描时排除本文件自身。
export const FORBIDDEN_COUPLING_TOKENS = [
'new_web_source',
'frontend-vue/',
'app_client',
] as const
const SELF_SCAN_EXCLUSIONS = new Set(['src/config/workspace.ts', 'playwright.config.ts'])
const SCAN_EXTENSIONS = /\.(ts|tsx|vue|css|html|json|js)$/
export function walk(rootDir: string, base = ''): string[] {
const found: string[] = []
for (const entry of readdirSync(join(rootDir, base), { withFileTypes: true })) {
if (['node_modules', 'dist', '.git', 'tests', 'e2e', 'scripts', 'deploy'].includes(entry.name)) continue
const rel = base ? `${base}/${entry.name}` : entry.name
if (entry.isDirectory()) found.push(...walk(rootDir, rel))
else if (SCAN_EXTENSIONS.test(entry.name)) found.push(rel)
}
return found
}
function fileExists(rootDir: string, path: string): boolean {
return existsSync(join(rootDir, path))
}
/** 从当前目录向上定位独立后台工程根目录,找不到时给出可操作错误。 */
export function resolveWorkspaceRoot(cwd = process.cwd()): string {
let dir = resolve(cwd)
for (let i = 0; i < 6; i += 1) {
if (fileExists(dir, 'package.json')) return dir
const parent = resolve(dir, '..')
if (parent === dir) break
dir = parent
}
throw new Error(`在 ${cwd} 向上 6 层内找不到 package.json,请在 admin-frontend-vue 工程目录内执行`)
}
export interface WorkspacePackage {
name: string
private: boolean
scripts: Record<string, string>
dependencies: Record<string, string>
devDependencies: Record<string, string>
}
export function readWorkspacePackage(rootDir = resolveWorkspaceRoot()): WorkspacePackage {
const raw = JSON.parse(readFileSync(join(rootDir, 'package.json'), 'utf8')) as Partial<WorkspacePackage> & { private?: boolean }
return {
name: raw.name || '',
private: raw.private !== false,
scripts: raw.scripts || {},
dependencies: raw.dependencies || {},
devDependencies: raw.devDependencies || {},
}
}
/** 校验独立工程边界,返回违规清单(空数组 = 边界成立)。 */
export function collectBoundaryViolations(rootDir = resolveWorkspaceRoot()): string[] {
const violations: string[] = []
const pkgPath = join(rootDir, 'package.json')
const pkg: WorkspacePackage = fileExists(rootDir, 'package.json')
? readWorkspacePackage(rootDir)
: { name: '', private: false, scripts: {}, dependencies: {}, devDependencies: {} }
if (!fileExists(rootDir, 'package.json')) violations.push(`缺少必需清单文件 package.json(在 ${pkgPath})`)
if (pkg.name !== STANDALONE_PACKAGE_NAME) {
violations.push(`package.name 应为 ${STANDALONE_PACKAGE_NAME},实际为 ${pkg.name || '(空)'}`)
}
if (!pkg.private) violations.push('package.private 应为 true(后台工程不允许被外部发布依赖)')
for (const file of REQUIRED_MANIFEST_FILES) {
if (!fileExists(rootDir, file)) violations.push(`缺少必需清单文件 ${file}`)
}
for (const dir of ADMIN_SOURCE_DIRS) {
if (!fileExists(rootDir, dir)) violations.push(`缺少允许源码目录 ${dir}`)
}
for (const file of walk(rootDir)) {
if (SELF_SCAN_EXCLUSIONS.has(file)) continue
const content = readFileSync(join(rootDir, file), 'utf8')
for (const token of FORBIDDEN_COUPLING_TOKENS) {
if (content.includes(token)) {
violations.push(`${file} 引用了客户端耦合 token "${token}",超出后台工程边界`)
}
}
}
return violations
}
@@ -0,0 +1,152 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useAdminSessionStore } from '@/stores/admin-session'
import { joinAdminPath } from '@/config/app'
import { pageTitleOf, topbarUserOf } from '@/layout/topbar-model'
import { groupKeysForActive, toSidebarEntries } from '@/layout/menu-mapper'
import {
EMPTY_MENU_DESCRIPTION,
EMPTY_MENU_TITLE,
shouldShowEmptyMenu,
} from '@/layout/empty-state'
import GlobalErrorContainer from '@/layout/GlobalErrorContainer.vue'
import { initialCollapsed, toggleCollapsed, writeCollapsePreference } from '@/layout/sidebar-collapse'
import { crumbsForActiveRoute, resolveDocumentTitle, updateDocumentTitle } from '@/layout/title-breadcrumb'
import {
LOGOUT_CONFIRM_CANCEL,
LOGOUT_CONFIRM_MESSAGE,
LOGOUT_CONFIRM_OK,
LOGOUT_CONFIRM_TITLE,
runLogout,
} from '@/layout/logout'
const route = useRoute()
const router = useRouter()
const session = useAdminSessionStore()
const collapsed = ref(readInitialCollapse())
function readInitialCollapse(): boolean {
const storage = typeof window !== 'undefined' ? window.localStorage : null
const width = typeof window !== 'undefined' ? window.innerWidth : 0
return initialCollapsed(width, storage)
}
function setCollapsed(value: boolean): void {
collapsed.value = value
if (typeof window !== 'undefined') writeCollapsePreference(window.localStorage, value)
}
function toggleSidebar(): void {
setCollapsed(toggleCollapsed(collapsed.value))
}
const activePath = computed(() => route.path)
const menuEntries = computed(() => toSidebarEntries(session.menuTree))
const openedKeys = computed(() => groupKeysForActive(menuEntries.value, route.path))
const emptyMenu = computed(() => shouldShowEmptyMenu(menuEntries.value.length > 0, session.loading, session.initialized))
const pageTitle = computed(() => pageTitleOf(route.meta.title))
const userVm = computed(() => topbarUserOf(session.user))
const breadcrumbs = computed(() => crumbsForActiveRoute(session.menuTree, route.path))
const logoUrl = joinAdminPath('assets', 'logo.jpg')
watch(
pageTitle,
(title) => updateDocumentTitle(resolveDocumentTitle(title), typeof document !== 'undefined' ? document : null),
{ immediate: true },
)
async function signOut() {
try {
await runLogout({
confirm: () =>
ElMessageBox.confirm(LOGOUT_CONFIRM_MESSAGE, LOGOUT_CONFIRM_TITLE, {
confirmButtonText: LOGOUT_CONFIRM_OK,
cancelButtonText: LOGOUT_CONFIRM_CANCEL,
type: 'warning',
}).then(
() => true,
() => false,
),
signOut: () => session.signOut(),
})
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '退出登录失败')
}
}
</script>
<template>
<div class="admin-shell" :class="{ 'is-collapsed': collapsed }">
<a class="skip-link" href="#admin-content">跳到主内容</a>
<aside class="admin-sidebar" role="navigation" aria-label="侧边栏菜单">
<div class="admin-brand">
<img :src="logoUrl" alt="数富AI" class="admin-brand-logo" />
<div v-if="!collapsed" class="admin-brand-copy">
<strong>数富AI</strong>
<span>电商运营管理后台</span>
</div>
</div>
<el-scrollbar class="admin-menu-scroll">
<el-menu :default-active="activePath" :default-openeds="openedKeys" :collapse="collapsed" router class="admin-menu">
<template v-for="entry in menuEntries" :key="entry.key">
<el-sub-menu v-if="entry.kind === 'group'" :index="entry.key">
<template #title>
<span class="menu-group-title">{{ entry.name }}</span>
</template>
<el-menu-item v-for="item in entry.children" :key="item.key" :index="item.route">
{{ item.name }}
</el-menu-item>
</el-sub-menu>
<el-menu-item v-else :key="entry.key" :index="entry.route">
{{ entry.name }}
</el-menu-item>
</template>
</el-menu>
<el-empty v-if="emptyMenu" :description="EMPTY_MENU_TITLE" :image-size="72" />
</el-scrollbar>
<button
class="sidebar-collapse"
type="button"
:aria-expanded="!collapsed"
aria-label="切换侧边栏"
@click="toggleSidebar"
>
{{ collapsed ? '展开菜单' : '收起菜单' }}
</button>
</aside>
<section class="admin-main">
<header class="admin-topbar">
<div>
<div class="admin-kicker">运营管理控制台</div>
<h1>{{ pageTitle }}</h1>
</div>
<div class="admin-user">
<div class="admin-user-meta">
<strong>{{ userVm.username }}</strong>
<span v-if="userVm.role">{{ userVm.role }}</span>
</div>
<el-button text type="danger" @click="signOut">退出登录</el-button>
</div>
</header>
<main id="admin-content" class="admin-content">
<el-breadcrumb v-if="breadcrumbs.length > 1" class="admin-breadcrumb" separator="/">
<el-breadcrumb-item v-for="crumb in breadcrumbs" :key="crumb.key">{{ crumb.name }}</el-breadcrumb-item>
</el-breadcrumb>
<GlobalErrorContainer />
<el-alert v-if="session.error" :title="session.error" type="error" show-icon :closable="false" />
<el-empty
v-if="emptyMenu && route.path === '/'"
:title="EMPTY_MENU_TITLE"
:description="EMPTY_MENU_DESCRIPTION"
:image-size="96"
/>
<RouterView v-else />
</main>
</section>
</div>
</template>
@@ -0,0 +1,35 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue'
import {
dismissGlobalError,
subscribeGlobalError,
type GlobalErrorItem,
} from '@/layout/error-bus'
const errors = ref<GlobalErrorItem[]>([])
let unsubscribe: (() => void) | null = null
onMounted(() => {
unsubscribe = subscribeGlobalError((list) => {
errors.value = list
})
})
onBeforeUnmount(() => {
unsubscribe?.()
unsubscribe = null
})
</script>
<template>
<div v-if="errors.length" class="global-error-stack" role="alert" aria-live="assertive">
<el-alert
v-for="item in errors"
:key="item.id"
:title="item.message"
type="error"
show-icon
:closable="true"
@close="dismissGlobalError(item.id)"
/>
</div>
</template>
@@ -0,0 +1,11 @@
/** 无菜单权限空状态(任务 11)文案与判定。 */
export const EMPTY_MENU_TITLE = '暂无可用菜单'
export const EMPTY_MENU_DESCRIPTION = '请联系管理员为你的账号分配菜单权限'
/**
* 是否展示无菜单空态:会话已初始化、未在加载、且没有任何可渲染菜单。
* 加载中不闪空态;初始化失败由错误条提示而非空态。
*/
export function shouldShowEmptyMenu(hasMenus: boolean, loading: boolean, initialized: boolean): boolean {
return Boolean(initialized) && !loading && !hasMenus
}
@@ -0,0 +1,56 @@
/** 全局请求错误提示容器(任务 13):框架无关的订阅式错误总线。 */
export interface GlobalErrorItem {
id: number
message: string
}
export const GLOBAL_ERROR_LIMIT = 3
export const GLOBAL_ERROR_FALLBACK = '请求失败,请稍后重试'
/** 把任意负载归一化为可展示文案。 */
export function normalizeErrorMessage(message: unknown): string {
if (message instanceof Error) return message.message.trim() || GLOBAL_ERROR_FALLBACK
if (typeof message === 'string') return message.trim() || GLOBAL_ERROR_FALLBACK
return GLOBAL_ERROR_FALLBACK
}
type Listener = (items: GlobalErrorItem[]) => void
let items: GlobalErrorItem[] = []
let nextId = 1
const listeners = new Set<Listener>()
function emit(): void {
for (const listener of listeners) listener(items.slice())
}
/** 订阅错误流,返回取消订阅函数(组件卸载时必须调用以防泄漏)。 */
export function subscribeGlobalError(listener: Listener): () => void {
listeners.add(listener)
listener(items.slice())
return () => {
listeners.delete(listener)
}
}
/** 通知一条全局请求错误;超出上限丢弃最旧,保证不堆积。 */
export function notifyGlobalError(message: unknown): void {
items = [...items, { id: nextId++, message: normalizeErrorMessage(message) }].slice(-GLOBAL_ERROR_LIMIT)
emit()
}
/** 按 id 关闭单条。 */
export function dismissGlobalError(id: number): void {
items = items.filter((item) => item.id !== id)
emit()
}
export function clearGlobalErrors(): void {
items = []
emit()
}
export function snapshotGlobalErrors(): GlobalErrorItem[] {
return items.slice()
}
+20
View File
@@ -0,0 +1,20 @@
/** 壳层退出登录交互(任务 16):确认后执行,取消/拒绝一律不退出。 */
export const LOGOUT_CONFIRM_TITLE = '退出登录'
export const LOGOUT_CONFIRM_MESSAGE = '确定要退出当前账号吗?'
export const LOGOUT_CONFIRM_OK = '退出'
export const LOGOUT_CONFIRM_CANCEL = '取消'
export interface LogoutDeps {
/** 用户确认对话框,resolve true 表示确认退出。 */
confirm: () => Promise<boolean>
/** 真正执行退出(清状态 + 跳登录页)。 */
signOut: () => Promise<void>
}
/** 退出流程:先确认;确认后执行退出;signOut/confirm 异常向上抛由调用方反馈。 */
export async function runLogout({ confirm, signOut }: LogoutDeps): Promise<void> {
const proceed = await confirm()
if (!proceed) return
await signOut()
}
@@ -0,0 +1,46 @@
import type { AdminMenuNode } from '../types/admin'
export interface SidebarItem {
key: string
name: string
route: string
}
/** 侧边栏渲染项:分组(含子页面)或单页面项(含顶级路由叶节点)。 */
export type SidebarEntry =
| { kind: 'group'; key: string; name: string; children: SidebarItem[] }
| { kind: 'item'; key: string; name: string; route: string }
/**
* 后端菜单树 -> 侧边栏节点映射规则(任务 6):
* - 有可路由子节点的节点渲染为分组,只保留带 route 的子项;
* - 无子节点但有 route 的节点渲染为单页面项(不丢顶级叶菜单);
* - 既无子节点也无 route 的节点跳过(点不进去的纯占位不展示)。
*/
export function toSidebarEntries(nodes: AdminMenuNode[] | null | undefined): SidebarEntry[] {
const entries: SidebarEntry[] = []
for (const node of nodes || []) {
const name = node.name || ''
const key = node.key || ''
const children: SidebarItem[] = (node.children || [])
.filter((child): child is AdminMenuNode & { route: string } => Boolean(child.route))
.map((child) => ({ key: child.key || '', name: child.name || '', route: child.route }))
if (children.length > 0) {
entries.push({ kind: 'group', key, name, children })
} else if (node.route) {
entries.push({ kind: 'item', key, name, route: node.route })
}
}
return entries
}
/** 计算需默认展开的分组 key:分组下含当前激活路由子项时返回该分组 key。 */
export function groupKeysForActive(entries: SidebarEntry[], activeRoute: string): string[] {
const keys: string[] = []
for (const entry of entries) {
if (entry.kind === 'group' && entry.children.some((child) => child.route === activeRoute)) {
keys.push(entry.key)
}
}
return keys
}
@@ -0,0 +1,56 @@
/** 侧边栏折叠与窄屏布局状态(任务 14):宽高常量、阈值、偏好持久化。 */
export const SIDEBAR_EXPANDED_WIDTH = 248
export const SIDEBAR_COLLAPSED_WIDTH = 64
export const SIDEBAR_NARROW_THRESHOLD = 900
/** 视口窄到需要自动收起侧边栏。 */
export function isNarrowScreen(width: number): boolean {
return width > 0 && width <= SIDEBAR_NARROW_THRESHOLD
}
/** 反转折叠状态。 */
export function toggleCollapsed(current: boolean): boolean {
return !current
}
export type CollapseStorage = Pick<Storage, 'getItem' | 'setItem'> | null
const PREFERENCE_KEY = 'admin.sidebar.collapsed'
function parsePreference(raw: string | null): boolean | null {
return raw === 'true' ? true : raw === 'false' ? false : null
}
/** 读取持久化偏好;无存储或值非法返回 null。 */
export function readCollapsePreference(storage: CollapseStorage): boolean | null {
try {
return parsePreference(storage?.getItem(PREFERENCE_KEY) ?? null)
} catch {
return null
}
}
/** 写入折叠偏好;存储不可用时静默失败(不阻断交互)。 */
export function writeCollapsePreference(storage: CollapseStorage, collapsed: boolean): void {
try {
storage?.setItem(PREFERENCE_KEY, String(collapsed))
} catch {
// localStorage 不可用(隐私模式等)时忽略
}
}
/**
* 初始折叠值:优先持久化偏好;无偏好时窄屏自动折叠、宽屏展开。
* width<=0(如 SSR/未知)视为无法判定,回退 false。
*/
export function initialCollapsed(width: number, storage: CollapseStorage): boolean {
const preference = readCollapsePreference(storage)
if (preference !== null) return preference
return isNarrowScreen(width)
}
/** 侧边栏应占用的像素宽(用于宽度计算/测试,不直接改 CSS)。 */
export function sidebarPixelWidth(collapsed: boolean): number {
return collapsed ? SIDEBAR_COLLAPSED_WIDTH : SIDEBAR_EXPANDED_WIDTH
}
@@ -0,0 +1,42 @@
import type { AdminMenuNode } from '../types/admin'
export const ADMIN_BRAND = '数富AI'
/** 文档标题规则:`页面标题 - 数富AI`;无页面标题时仅品牌。 */
export function resolveDocumentTitle(pageTitle: string, brand: string = ADMIN_BRAND): string {
const trimmed = (pageTitle || '').trim()
return trimmed ? `${trimmed} - ${brand}` : brand
}
/** 同步 HTML 文档标题;doc 为空(如非浏览器环境)时静默跳过。 */
export function updateDocumentTitle(title: string, doc: { title: string } | null | undefined): void {
if (doc) doc.title = title
}
export interface BreadcrumbItem {
key: string
name: string
route?: string
}
/**
* 面包屑规则:在菜单树中定位激活路由,返回“分组 -> 页面”层级(顶层叶子只返回自身)。
* 无命中返回空数组,不伪造路径。
*/
export function crumbsForActiveRoute(nodes: AdminMenuNode[] | null | undefined, activeRoute: string): BreadcrumbItem[] {
for (const node of nodes || []) {
if (node.route === activeRoute) return [{ key: node.key, name: node.name, route: node.route }]
const children = node.children || []
for (const child of children) {
if (child.route === activeRoute) {
return [
{ key: node.key, name: node.name },
{ key: child.key, name: child.name, route: child.route },
]
}
}
const nested = crumbsForActiveRoute(children, activeRoute)
if (nested.length) return [{ key: node.key, name: node.name }, ...nested]
}
return []
}
@@ -0,0 +1,22 @@
import type { AdminUser } from '../types/admin'
/** 无 meta.title 时的壳层缺省标题。 */
export const ADMIN_DEFAULT_TITLE = '管理后台'
/** 页面标题模型:由路由 meta.title 驱动,空值回落缺省标题。 */
export function pageTitleOf(title: string | null | undefined): string {
const value = typeof title === 'string' ? title.trim() : ''
return value || ADMIN_DEFAULT_TITLE
}
export interface TopbarUserViewModel {
username: string
role: string
hasUser: boolean
}
/** 顶部栏用户模型:用户信息或未登录空态统一为可渲染视图模型。 */
export function topbarUserOf(user: AdminUser | null | undefined): TopbarUserViewModel {
if (!user) return { username: '当前用户', role: '', hasUser: false }
return { username: user.username || '当前用户', role: user.role || '', hasUser: true }
}
@@ -0,0 +1,92 @@
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { http } from '@/api/http'
import type { AdminUser } from '@/types/admin'
import { fetchUserList } from '@/api/users'
const loading = ref(false)
const rows = ref<AdminUser[]>([])
const total = ref(0)
const form = reactive({ username: '', page: 1, pageSize: 15 })
async function loadUsers() {
loading.value = true
try {
const page = await fetchUserList({ page: form.page, pageSize: form.pageSize, keyword: form.username || undefined })
rows.value = page.items
total.value = page.total
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '用户列表加载失败')
} finally {
loading.value = false
}
}
async function removeUser(row: AdminUser) {
try {
await ElMessageBox.confirm(`确定删除用户“${row.username}”吗?`, '删除确认', { type: 'warning' })
await http.delete(`/api/admin/user/${row.id}`)
ElMessage.success('删除成功')
await loadUsers()
} catch (error) {
if (error !== 'cancel' && error !== 'close') ElMessage.error(error instanceof Error ? error.message : '删除失败')
}
}
function changePage(page: number) {
form.page = page
void loadUsers()
}
onMounted(loadUsers)
</script>
<template>
<div class="page-stack">
<div class="page-heading">
<div>
<h2>用户管理</h2>
<p>管理后台账号、角色和创建关系。</p>
</div>
<el-button type="primary">新建用户</el-button>
</div>
<el-card shadow="never">
<el-form inline @submit.prevent="loadUsers">
<el-form-item label="用户名">
<el-input v-model="form.username" clearable placeholder="模糊搜索" @keyup.enter="loadUsers" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="loadUsers">查询</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card shadow="never">
<el-table v-loading="loading" :data="rows" stripe>
<el-table-column prop="id" label="ID" width="90" />
<el-table-column prop="username" label="用户名" min-width="180" />
<el-table-column prop="role" label="角色" width="140" />
<el-table-column prop="creatorUsername" label="所属管理员" width="160" />
<el-table-column prop="createdAt" label="创建时间" width="180" />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button link type="danger" @click="removeUser(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="table-footer">
<span>共 {{ total }} 条</span>
<el-pagination
background
layout="prev, pager, next"
:page-size="form.pageSize"
:current-page="form.page"
:total="total"
@current-change="changePage"
/>
</div>
</el-card>
</div>
</template>
@@ -0,0 +1,15 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
const router = useRouter()
</script>
<template>
<div class="not-found">
<el-result icon="warning" title="404" sub-title="页面不存在或已被移除">
<template #extra>
<el-button type="primary" @click="router.replace('/')">返回首页</el-button>
</template>
</el-result>
</div>
</template>
+34
View File
@@ -0,0 +1,34 @@
import type { AdminMenuNode } from '../types/admin'
/**
* 取后端菜单树中第一个可路由页面路径(深度优先、保序)。
* 无任何可路由页面时返回空串,由调用方决定渲染空态或回根路由,不硬编码缺省页。
*/
export function firstVisiblePath(nodes: AdminMenuNode[] | null | undefined): string {
for (const node of nodes || []) {
if (node.route) return node.route
const nested = firstVisiblePath(node.children || [])
if (nested) return nested
}
return ''
}
/** 菜单树中是否含指定 key(深度优先递归;空 key/空树一律 false)。 */
export function hasMenuKey(nodes: AdminMenuNode[] | null | undefined, key: string): boolean {
if (!key) return false
return (nodes || []).some((node) => node.key === key || hasMenuKey(node.children || [], key))
}
/**
* 页面级路由准入:无 menuKey 的开放页放行;超级管理员可进全部;其余须在
* 本人菜单树中命中 key。后端已过滤菜单,此处只做前端路由级兜底。
*/
export function isRouteAllowed(
isSuperAdmin: boolean,
menuKey: string | undefined,
menuTree: AdminMenuNode[] | null | undefined,
): boolean {
if (!menuKey) return true
if (isSuperAdmin) return true
return hasMenuKey(menuTree, menuKey)
}
+47
View File
@@ -0,0 +1,47 @@
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import AdminLayout from '@/layout/AdminLayout.vue'
import NotFoundPage from '@/pages/error/NotFoundPage.vue'
import { useAdminSessionStore } from '@/stores/admin-session'
import { APP_BASE_PATH } from '@/config/app'
import { adminRouteRecords } from './routes'
import { defineLazyPage } from './lazy-page'
import { isRouteAllowed } from './helpers'
const router = createRouter({
history: createWebHistory(APP_BASE_PATH),
routes: [
{
path: '/',
component: AdminLayout,
children: [
...adminRouteRecords.map((record) => ({
...record,
component: defineLazyPage(record.component as () => Promise<{ default: unknown }>),
})),
{ path: ':pathMatch(.*)*', component: NotFoundPage, meta: { title: '页面不存在' } },
] as RouteRecordRaw[],
},
],
})
router.beforeEach(async (to) => {
const session = useAdminSessionStore()
if (!session.initialized) {
try {
await session.initialize()
} catch {
return false
}
}
// 根路由:有可见页面时跳到首个可见页;没有任何页面时停留根路由展示无菜单空态。
if (to.path === '/') {
return session.firstVisible || true
}
// 页面级权限:无 menuKey 开放页放行;越权页回退首个可见页,全无则回根空态。
if (!isRouteAllowed(session.isSuperAdmin, to.meta.menuKey, session.menuTree)) {
return session.firstVisible || '/'
}
return true
})
export default router
@@ -0,0 +1,15 @@
/** 异步页面加载边界可调参数(任务 10):loading 延迟/超时/文案。 */
export const PAGE_LOADING_DELAY = 200
export const PAGE_LOADING_TIMEOUT = 15000
export const PAGE_LOADING_TEXT = '页面加载中'
export const PAGE_LOAD_ERROR_TEXT = '页面加载失败,请刷新重试'
/** 是否为异步加载器(函数式)。 */
export function isLazyLoader(value: unknown): value is () => Promise<unknown> {
return typeof value === 'function'
}
/** 动态 import 产物是否为含 default 的页面模块。 */
export function isPageModule(module: unknown): boolean {
return typeof module === 'object' && module !== null && 'default' in module
}
@@ -0,0 +1,23 @@
import { defineAsyncComponent, h, type Component } from 'vue'
import {
PAGE_LOADING_DELAY,
PAGE_LOADING_TEXT,
PAGE_LOADING_TIMEOUT,
PAGE_LOAD_ERROR_TEXT,
} from './lazy-config'
type PageLoader = () => Promise<{ default: unknown }>
/**
* 页面级异步加载边界(任务 10):按路由分包页面,加载中/失败都有明确反馈,
* 不把 chunk 加载错误静默吞掉。
*/
export function defineLazyPage(loader: PageLoader): Component {
return defineAsyncComponent({
loader: () => loader().then((mod) => mod.default as Component),
delay: PAGE_LOADING_DELAY,
timeout: PAGE_LOADING_TIMEOUT,
loadingComponent: () => h('div', { class: 'page-loading' }, PAGE_LOADING_TEXT),
errorComponent: () => h('div', { class: 'page-error' }, PAGE_LOAD_ERROR_TEXT),
})
}
+34
View File
@@ -0,0 +1,34 @@
/** 路由 meta 菜单 key 约定(任务 9):menuKey 对应后端菜单节点 key,仅作页面级鉴权。 */
export const ADMIN_MENU_KEY_PATTERN = /^[a-z][a-z0-9_]*$/
/** 从 route.meta 读取菜单 key;缺省/非法类型回退空串(无菜单约束)。 */
export function metaMenuKey(meta: { menuKey?: unknown } | undefined): string {
const value = meta?.menuKey
return typeof value === 'string' ? value : ''
}
/** 菜单 key 是否合规(小写下划线命名)。 */
export function isValidMenuKey(key: string): boolean {
return ADMIN_MENU_KEY_PATTERN.test(key)
}
export interface MenuKeyCandidate {
path?: string
menuKey?: unknown
}
/** 校验一批页面注册的 menuKey:重复与命名格式问题返回可操作清单。 */
export function validateRouteMenuKeys(records: MenuKeyCandidate[]): string[] {
const issues: string[] = []
const seen = new Set<string>()
for (const record of records) {
const key = metaMenuKey(record)
if (!key) continue
if (seen.has(key)) issues.push(`菜单 key 重复: ${key}`)
seen.add(key)
if (!isValidMenuKey(key)) {
issues.push(`菜单 key 命名非法(须小写下划线): ${record.path || '(无路径)'} -> ${key}`)
}
}
return issues
}
+49
View File
@@ -0,0 +1,49 @@
import type { RouteRecordRaw } from 'vue-router'
export interface AdminPageMeta {
title: string
menuKey?: string
}
export interface AdminPageDef extends AdminPageMeta {
/** 相对 /admin-vue/ 基准的子路径,不带前导斜杠、不带 base 前缀。 */
path: string
/** 异步组件加载器(页面按路由分包)。 */
load: () => Promise<{ default: unknown }>
}
/** 业务域路由注册表(任务 8):首批 account 域;后续按业务域在此登记页面。 */
export const adminPages: AdminPageDef[] = [
{ path: 'account/users', menuKey: 'admin_users', title: '用户管理', load: () => import('@/pages/account/UsersPage.vue') },
{ path: 'account/menus', menuKey: 'admin_columns', title: '菜单管理', load: () => import('@/pages/account/MenusPage.vue') },
{ path: 'account/groups', menuKey: 'admin_group_manage', title: '数据权限分组', load: () => import('@/pages/account/GroupsPage.vue') },
]
export function routeOf(page: AdminPageDef): RouteRecordRaw {
if (!page.path || !page.load || !page.title) {
throw new Error(`路由注册表页面定义非法,需 path/load/title 齐全: ${JSON.stringify(page)}`)
}
const meta: Record<string, string> = { title: page.title }
if (page.menuKey) meta.menuKey = page.menuKey
return { path: page.path, component: page.load, meta }
}
export const adminRouteRecords: RouteRecordRaw[] = adminPages.map(routeOf)
/** 校验注册表完整性:路径唯一、title/load 齐全、路径为相对子路径。返回问题清单。 */
export function validateAdminPages(pages: AdminPageDef[]): string[] {
const issues: string[] = []
const seen = new Set<string>()
for (const page of pages) {
if (!page.path || page.path.startsWith('/')) {
issues.push(`页面路径必须是相对子路径(不带 / 与 base 前缀): ${page.path || '(空)'}`)
} else if (seen.has(page.path)) {
issues.push(`页面路径重复: ${page.path}`)
}
seen.add(page.path)
if (!page.title) issues.push(`页面缺少标题: ${page.path}`)
if (!page.load) issues.push(`页面缺少异步加载器: ${page.path}`)
if (page.path.includes('/admin-vue')) issues.push(`页面路径不得包含 base 前缀: ${page.path}`)
}
return issues
}
@@ -0,0 +1,44 @@
import { defineStore } from 'pinia'
import { fetchAdminMenuTree, fetchCurrentUser, logout } from '@/api/session'
import type { AdminMenuNode, AdminUser } from '@/types/admin'
import { isSuperAdminRole } from '@/types/admin'
import { firstVisiblePath } from '@/router/helpers'
export const useAdminSessionStore = defineStore('admin-session', {
state: () => ({
user: null as AdminUser | null,
menuTree: [] as AdminMenuNode[],
initialized: false,
loading: false,
error: '',
}),
getters: {
isSuperAdmin: (state) => isSuperAdminRole(state.user?.role),
firstVisible: (state): string => {
return firstVisiblePath(state.menuTree)
},
},
actions: {
async initialize() {
if (this.initialized || this.loading) return
this.loading = true
this.error = ''
try {
this.user = await fetchCurrentUser()
this.menuTree = await fetchAdminMenuTree()
this.initialized = true
} catch (error) {
this.error = error instanceof Error ? error.message : '后台初始化失败'
throw error
} finally {
this.loading = false
}
},
async signOut() {
await logout()
this.$reset()
window.location.assign('/login')
},
},
})
+71
View File
@@ -0,0 +1,71 @@
:root {
--admin-sidebar: #192132;
--admin-sidebar-deep: #121827;
--admin-primary: #6366f1;
--admin-primary-soft: #eef0ff;
--admin-bg: #f3f5f9;
--admin-border: #e5e7ef;
--admin-text: #1f2937;
--admin-muted: #7b8495;
font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; min-height: 100%; height: 100%; }
body { background: var(--admin-bg); color: var(--admin-text); }
button, input, textarea, select { font: inherit; }
.admin-shell { display: flex; min-height: 100vh; background: var(--admin-bg); }
.admin-sidebar { display: flex; flex: 0 0 248px; flex-direction: column; background: linear-gradient(180deg, var(--admin-sidebar) 0%, var(--admin-sidebar-deep) 100%); color: #b9c2d5; transition: flex-basis .2s ease; }
.admin-shell.is-collapsed .admin-sidebar { flex-basis: 64px; }
.admin-brand { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.admin-brand-logo { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; background: white; }
.admin-brand-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.admin-brand-copy strong { color: #fff; font-size: 16px; }
.admin-brand-copy span { color: #929db4; font-size: 11px; white-space: nowrap; }
.admin-menu-scroll { flex: 1; padding: 14px 10px; }
.admin-menu { border-right: 0; background: transparent; }
.admin-menu .el-sub-menu__title, .admin-menu .el-menu-item { height: 42px; line-height: 42px; border-radius: 8px; margin: 3px 0; color: #aeb8cc; }
.admin-menu .el-sub-menu__title:hover, .admin-menu .el-menu-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-menu .el-menu-item.is-active { background: linear-gradient(90deg, rgba(99,102,241,.95), rgba(99,102,241,.62)); color: #fff; }
.admin-menu .el-menu { background: transparent; }
.menu-group-title { font-weight: 600; }
.sidebar-collapse { margin: 12px; padding: 9px 10px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; color: #aeb8cc; background: transparent; cursor: pointer; }
.sidebar-collapse:hover { color: #fff; border-color: rgba(255,255,255,.3); }
.sidebar-collapse:focus-visible { outline: 2px solid var(--admin-primary); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.skip-link:focus {
position: fixed; left: 16px; top: 16px; z-index: 2000; width: auto; height: auto;
padding: 10px 14px; background: #fff; color: var(--admin-primary);
border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); text-decoration: none;
}
.admin-main { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 84px; padding: 18px 28px; background: #fff; border-bottom: 1px solid var(--admin-border); }
.admin-kicker { color: var(--admin-primary); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.admin-topbar h1 { margin: 5px 0 0; font-size: 22px; }
.admin-user { display: flex; align-items: center; gap: 18px; }
.admin-user-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.admin-user-meta strong { font-size: 14px; }
.admin-user-meta span { color: var(--admin-muted); font-size: 12px; }
.admin-content { flex: 1; min-width: 0; padding: 26px 28px; overflow: auto; }
.page-stack { display: flex; flex-direction: column; gap: 18px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-heading h2 { margin: 0; font-size: 22px; }
.page-heading p { margin: 7px 0 0; color: var(--admin-muted); font-size: 13px; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; color: var(--admin-muted); font-size: 13px; }
.el-card { border-color: var(--admin-border); border-radius: 12px; }
.page-loading, .page-error { padding: 48px 20px; text-align: center; }
.page-loading { color: var(--admin-muted); }
.page-error { color: #b91c1c; }
.not-found { padding: 56px 20px; }
.global-error-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.admin-breadcrumb { margin-bottom: 14px; }
@media (max-width: 820px) {
.admin-sidebar { flex-basis: 64px; }
.admin-brand-copy, .admin-menu .el-sub-menu__title span, .admin-menu .el-menu-item { display: none; }
.admin-topbar { align-items: flex-start; flex-direction: column; }
.admin-user { width: 100%; justify-content: space-between; }
.admin-user-meta { align-items: flex-start; }
.admin-content { padding: 18px; }
}
+69
View File
@@ -0,0 +1,69 @@
/**
* Admin 主题 token 单源(任务 4):深色侧边栏 + 浅色内容区。
* main.css 使用同名 --admin-* CSS 变量承载渲染值;tests 用本模块校验
* “侧边栏为暗、内容区为亮、正文对比度达标”的不变量,防止误改成浅色侧栏。
*/
export const ADMIN_THEME = {
sidebar: '#192132',
sidebarDeep: '#121827',
primary: '#6366f1',
primarySoft: '#eef0ff',
bg: '#f3f5f9',
border: '#e5e7ef',
text: '#1f2937',
muted: '#7b8495',
} as const
export type AdminThemeKey = keyof typeof ADMIN_THEME
export const ADMIN_THEME_KEYS = Object.keys(ADMIN_THEME) as AdminThemeKey[]
/** CSS 变量名:camelCase -> kebab(sidebarDeep -> --admin-sidebar-deep)。 */
export function cssVarName(key: AdminThemeKey): string {
const kebab = key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)
return `--admin-${kebab}`
}
function parseHex(hex: string): { r: number; g: number; b: number } {
if (!/^#[0-9a-fA-F]{6}$/.test(hex)) {
throw new Error(`主题色必须是 #rrggbb 六位十六进制: ${hex}`)
}
const raw = hex.slice(1)
return {
r: parseInt(raw.slice(0, 2), 16),
g: parseInt(raw.slice(2, 4), 16),
b: parseInt(raw.slice(4, 6), 16),
}
}
/** sRGB 通道 -> 线性亮度。 */
function channelLuminance(channel: number): number {
const s = channel / 255
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4
}
/** 相对亮度(0 纯黑 ~ 1 纯白)。 */
export function relativeLuminance(hex: string): number {
const { r, g, b } = parseHex(hex)
return 0.2126 * channelLuminance(r) + 0.7152 * channelLuminance(g) + 0.0722 * channelLuminance(b)
}
export function isDarkSurface(hex: string, threshold = 0.2): boolean {
return relativeLuminance(hex) < threshold
}
/** WCAG 对比度(1 ~ 21),fg/bg 可为 8 位 hex。 */
export function contrastRatio(fgHex: string, bgHex: string): number {
const lighter = Math.max(relativeLuminance(fgHex), relativeLuminance(bgHex))
const darker = Math.min(relativeLuminance(fgHex), relativeLuminance(bgHex))
return (lighter + 0.05) / (darker + 0.05)
}
/** 取某个语义 token 的 hex;未知 key 给出可操作错误。 */
export function tokenHex(key: AdminThemeKey): string {
const value = ADMIN_THEME[key]
if (!value) {
throw new Error(`未知 Admin 主题 token: ${String(key)},允许值: ${ADMIN_THEME_KEYS.join(', ')}`)
}
return value
}
+78
View File
@@ -0,0 +1,78 @@
/** 后台前端类型契约(任务 21):与 Java Admin 接口返回字段对齐。 */
/** 管理角色域(与后端 current-user / users 返回一致)。 */
export type AdminRole = 'super_admin' | 'admin' | 'normal'
export interface AdminUser {
id: number
username: string
role: string
/** 1 为管理员标志位;role 为空时可据此推断角色。 */
isAdmin?: boolean
createdById?: number | null
creatorUsername?: string
createdAt?: string
pinyinAbbr?: string
}
export interface AdminMenuNode {
/** columns.column_key,稳定权限标识。 */
key: string
name: string
/** 相对 /admin-vue/ 的页面路径;分组节点可能没有。 */
route?: string
/** 分组/页面层级;后端按 sort_order 排好后原样下发,前端不二次重排。 */
children?: AdminMenuNode[]
sort?: number
icon?: string
}
export type AdminRoleKind = 'super_admin' | 'admin' | 'normal' | null
/** 把任意角色字符串归一为角色域;未知/空返回 null。 */
export function roleKind(role: string | null | undefined): AdminRoleKind {
const value = (role || '').trim().toLowerCase()
if (value === 'super_admin') return 'super_admin'
if (value === 'admin') return 'admin'
if (value === 'normal') return 'normal'
return null
}
/** 是否超级管理员(可进入全部菜单)。 */
export function isSuperAdminRole(role: string | null | undefined): boolean {
return roleKind(role) === 'super_admin'
}
/** 是否管理员级(super_admin 或 admin,可进后台菜单管理类)。 */
export function isAdminRole(role: string | null | undefined): boolean {
const kind = roleKind(role)
return kind === 'super_admin' || kind === 'admin'
}
/** 顶部栏角色展示文案。 */
export function roleLabel(role: string | null | undefined): string {
switch (roleKind(role)) {
case 'super_admin':
return '超级管理员'
case 'admin':
return '管理员'
case 'normal':
return '普通用户'
default:
return ''
}
}
/** 前端是否应把该用户视为超级管理员(可进入全部菜单)。 */
export function isSuperUser(user: Pick<AdminUser, 'role'> | null | undefined): boolean {
return isSuperAdminRole(user?.role)
}
export type ApiEnvelope<T> = {
success?: boolean
message?: string
error?: string
data?: T
item?: T
items?: T
}
+10
View File
@@ -0,0 +1,10 @@
import 'vue-router'
declare module 'vue-router' {
interface RouteMeta {
/** 页面标题,驱动顶栏与 document.title。 */
title?: string
/** 菜单 key(对应后端菜单节点 key);仅页面级鉴权使用。 */
menuKey?: string
}
}
@@ -0,0 +1,31 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { existsSync, readFileSync } from 'node:fs'
import { resolve } from 'node:path'
test('admin build uses the standalone /admin-vue base path from single source', () => {
const config = readFileSync(resolve('vite.config.ts'), 'utf8')
const appConfig = readFileSync(resolve('src/config/app.ts'), 'utf8')
assert.match(appConfig, /export const APP_BASE_PATH = '\/admin-vue\/'/)
assert.match(config, /base:\s*APP_BASE_PATH/)
assert.match(config, /outDir:\s*['"]dist['"]/)
})
test('admin entry and first batch pages exist', () => {
for (const file of [
'index.html',
'src/main.ts',
'src/layout/AdminLayout.vue',
'src/pages/account/UsersPage.vue',
'src/pages/account/MenusPage.vue',
'src/pages/account/GroupsPage.vue',
]) {
assert.equal(existsSync(resolve(file)), true, `${file} should exist`)
}
})
test('admin frontend does not depend on the client new_web_source', () => {
const packageJson = readFileSync(resolve('package.json'), 'utf8')
assert.doesNotMatch(packageJson, /new_web_source/)
})
+63
View File
@@ -0,0 +1,63 @@
import { existsSync, readFileSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
const ROOT = process.cwd()
const SRC = join(ROOT, 'src')
const EXTENSIONS = ['', '.ts', '.tsx', '.vue', '.js', '.json']
const INDEX_CANDIDATES = ['/index.ts', '/index.tsx', '/index.vue', '/index.js']
/** 读取工程内源码文件(相对工程根)。 */
export function readSource(rel: string): string {
return readFileSync(join(ROOT, rel), 'utf8')
}
/** 统计非重叠子串出现次数(幂等、只读)。 */
export function occurrences(text: string, token: string): number {
if (!token) return 0
let count = 0
let index = text.indexOf(token)
while (index !== -1) {
count += 1
index = text.indexOf(token, index + token.length)
}
return count
}
/** 从源码里抓出所有 @/ 别名 import 说明符(含 import type)。 */
export function aliasImports(source: string): string[] {
const specs = new Set<string>()
const re = /(?:import\s+type\s+)?[^'"]*from\s*['"](@\/[^'"]+)['"]/g
let match: RegExpExecArray | null
while ((match = re.exec(source))) specs.add(match[1])
// 处理动态 import('@/...') 与直接裸 @/ 引用
const dyn = /(?:import|import\s*\(\s*)['"](@\/[^'"]+)['"]/g
while ((match = dyn.exec(source))) specs.add(match[1])
return [...specs]
}
/** 把 import 说明符解析为存在的模块文件;解析不到返回 null(含可操作路径)。 */
export function resolveModuleSpec(spec: string, fromRel: string): string | null {
let base: string
if (spec.startsWith('@/')) {
base = join(SRC, spec.slice(2))
} else {
base = resolve(dirname(join(ROOT, fromRel)), spec)
}
for (const ext of EXTENSIONS) {
if (existsSync(base + ext)) return base + ext
}
for (const idx of INDEX_CANDIDATES) {
if (existsSync(base + idx)) return base + idx
}
return null
}
/** 校验一个源文件的所有 @/ import 都能解析;返回缺失清单(空 = 全部可解析)。 */
export function missingImports(rel: string): string[] {
const source = readSource(rel)
const missing: string[] = []
for (const spec of aliasImports(source)) {
if (!resolveModuleSpec(spec, rel)) missing.push(`${rel} 无法解析 import: ${spec}`)
}
return missing
}
@@ -0,0 +1,46 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { parseCurrentUser, parseMenuTree } from '../../src/api/session-model.ts'
const BASE = process.env.AIIMAGE_LIVE_BASE || 'http://127.0.0.1:18080'
const USER = process.env.AIIMAGE_LIVE_USER || ''
const PASS = process.env.AIIMAGE_LIVE_PASS || ''
const DEVICE = 'claude-live-device'
const HAS_CREDS = Boolean(USER && PASS)
async function loginToken(): Promise<string> {
const res = await fetch(`${BASE}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: USER, password: PASS, deviceId: DEVICE }),
})
const body = (await res.json()) as { success?: boolean; message?: string; data?: { token?: string } }
if (!body.success || !body.data?.token) throw new Error(body.message || 'login failed')
return body.data.token
}
function authHeaders(token: string): Record<string, string> {
return { Authorization: `Bearer ${token}` }
}
test('test_live_023_current_user_real_request', { skip: !HAS_CREDS }, async () => {
const token = await loginToken()
const res = await fetch(`${BASE}/api/admin/current-user`, { headers: authHeaders(token) })
const body = await res.json()
const user = parseCurrentUser(body)
assert.equal(typeof user.id, 'number')
assert.ok(user.username.length > 0)
assert.ok(['super_admin', 'admin', 'normal'].includes(user.role))
})
test('test_live_024_menu_tree_real_request', { skip: !HAS_CREDS }, async () => {
const token = await loginToken()
const res = await fetch(`${BASE}/api/admin/current-user/menus`, { headers: authHeaders(token) })
const body = await res.json()
const tree = parseMenuTree(body)
assert.ok(Array.isArray(tree))
assert.ok(tree.length > 0, 'super_admin 应能拿到全部 admin 菜单树')
const accountGroup = tree.find((n) => n.children?.length)
assert.ok(accountGroup, '菜单树应按分组组织')
})
@@ -0,0 +1,132 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { parseCurrentUser, parseMenuTree } from '../../src/api/session-model.ts'
import { roleKind } from '../../src/types/admin.ts'
const BASE = process.env.AIIMAGE_LIVE_BASE || 'http://127.0.0.1:18080'
const USER = process.env.AIIMAGE_LIVE_USER || ''
const PASS = process.env.AIIMAGE_LIVE_PASS || ''
const HAS_CREDS = Boolean(USER && PASS)
const DEVICE = 'claude-task40-smoke'
let sessionCookie = ''
let bearerToken = ''
/** 登录一次并按浏览器 Cookie 语义缓存会话(真实登录态)。 */
async function ensureSession(): Promise<void> {
if (sessionCookie || bearerToken) return
const res = await fetch(`${BASE}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: USER, password: PASS, deviceId: DEVICE }),
})
const body = (await res.json()) as { success?: boolean; message?: string; data?: { token?: string } }
assert.equal(body.success, true, `登录应成功: ${body.message || ''}`)
if (body.data?.token) bearerToken = body.data.token
const setCookies = typeof res.headers.getSetCookie === 'function' ? res.headers.getSetCookie() : []
const setCookie = setCookies[0] || res.headers.get('set-cookie') || ''
const match = /aiimage_token=([^;]+)/.exec(setCookie)
if (match) sessionCookie = `aiimage_token=${match[1]}`
assert.ok(sessionCookie || bearerToken, '登录应下发会话 cookie 或 token')
}
/** 模拟同源 Cookie 会话:带会话 cookie 或 Bearer 兜底请求受保护端点。 */
async function authedFetch(path: string): Promise<Response> {
const headers: Record<string, string> = {}
if (sessionCookie) headers.Cookie = sessionCookie
else if (bearerToken) headers.Authorization = `Bearer ${bearerToken}`
return fetch(`${BASE}${path}`, { headers })
}
test('test_task_040_live_smoke_normal_primary_path', { skip: !HAS_CREDS }, async () => {
// 正常主路径:真实登录后凭会话取当前用户。
await ensureSession()
const res = await authedFetch('/api/admin/current-user')
const user = parseCurrentUser(await res.json())
assert.equal(typeof user.id, 'number')
assert.equal(user.username, USER)
assert.equal(roleKind(user.role), 'super_admin')
})
test('test_task_040_live_smoke_normal_variant_input', { skip: !HAS_CREDS }, async () => {
// 正常变体:super_admin 菜单树含后台页面 key,路由级权限可放行。
await ensureSession()
const res = await authedFetch('/api/admin/current-user/menus')
const tree = parseMenuTree(await res.json())
const keys = new Set<string>()
const walk = (nodes: { key: string; children?: unknown }[] | undefined): void => {
for (const n of nodes || []) {
keys.add(n.key)
walk((n.children || []) as { key: string; children?: unknown }[])
}
}
walk(tree)
for (const expected of ['admin_users', 'admin_columns', 'admin_group_manage']) {
assert.ok(keys.has(expected), `菜单树应含后台页面 key: ${expected}`)
}
})
test('test_task_040_live_smoke_normal_repeated_operation_is_idempotent', { skip: !HAS_CREDS }, async () => {
// 正常重复:重复拉取用户/菜单结果稳定、不重排。
await ensureSession()
const first = parseCurrentUser(await (await authedFetch('/api/admin/current-user')).json())
const second = parseCurrentUser(await (await authedFetch('/api/admin/current-user')).json())
assert.equal(first.id, second.id)
const menusA = parseMenuTree(await (await authedFetch('/api/admin/current-user/menus')).json())
const menusB = parseMenuTree(await (await authedFetch('/api/admin/current-user/menus')).json())
assert.equal(JSON.stringify(menusA), JSON.stringify(menusB))
})
test('test_task_040_live_smoke_boundary_empty_input', { skip: !HAS_CREDS }, async () => {
// 边界空值:无会话直接请求受保护端点 → 401,前端据此跳登录。
const res = await fetch(`${BASE}/api/admin/current-user`)
const body = (await res.json()) as { success?: boolean; code?: number; message?: string }
assert.equal(body.success, false)
assert.equal(body.code, 401)
})
test('test_task_040_live_smoke_boundary_single_item', { skip: !HAS_CREDS }, async () => {
// 边界单元素:登录返回单会话 cookie 且可被管理员端点接受。
await ensureSession()
assert.ok(sessionCookie || bearerToken, '已建立单会话')
const res = await authedFetch('/api/admin/current-user')
const user = parseCurrentUser(await res.json())
assert.equal(user.username, USER)
})
test('test_task_040_live_smoke_boundary_limit_or_missing_field', { skip: !HAS_CREDS }, async () => {
// 边界上限:super_admin 菜单树中的每个模块页面都带可进入的 route(路由级权限放行依据)。
await ensureSession()
const tree = parseMenuTree(await (await authedFetch('/api/admin/current-user/menus')).json())
const routes = new Set<string>()
const walk = (nodes: { key: string; route?: string; children?: unknown }[] | undefined): void => {
for (const n of nodes || []) {
if (n.route) routes.add(n.route)
walk((n.children || []) as { key: string; route?: string; children?: unknown }[])
}
}
walk(tree)
for (const page of ['/account/users', '/account/menus', '/account/groups']) {
assert.ok(routes.has(page), `菜单树应含可进入页面 route: ${page}`)
}
})
test('test_task_040_live_smoke_invalid_input_rejected', { skip: !HAS_CREDS }, async () => {
// 异常输入:伪造 token 被拒绝,返回 401 而非业务数据。
const res = await fetch(`${BASE}/api/admin/current-user`, {
headers: { Authorization: 'Bearer not-a-real-token' },
})
const body = (await res.json()) as { success?: boolean; code?: number }
assert.equal(body.success, false)
assert.equal(body.code, 401)
})
test('test_task_040_live_smoke_dependency_failure_returns_actionable_message', { skip: !HAS_CREDS }, async () => {
// 依赖失败:真实负载经同一解析器/角色归一后仍符合前端契约(保序、角色可判)。
await ensureSession()
const tree = parseMenuTree(await (await authedFetch('/api/admin/current-user/menus')).json())
assert.ok(Array.isArray(tree) && tree.length > 0)
assert.equal(typeof tree[0].name, 'string')
const user = parseCurrentUser(await (await authedFetch('/api/admin/current-user')).json())
assert.ok(roleKind(user.role) !== null)
})
+132
View File
@@ -0,0 +1,132 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { mkdtempSync, rmSync, mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import {
ADMIN_SOURCE_DIRS,
collectBoundaryViolations,
FORBIDDEN_COUPLING_TOKENS,
readWorkspacePackage,
REQUIRED_MANIFEST_FILES,
resolveWorkspaceRoot,
STANDALONE_PACKAGE_NAME,
walk,
} from '../src/config/workspace.ts'
function tempRoot(): string {
return mkdtempSync(join(tmpdir(), 'admin-workspace-'))
}
test('test_task_001_project_baseline_normal_primary_path', () => {
// 正常主路径:独立工程从自身根目录完成一次边界校验,输出无违规。
const root = resolveWorkspaceRoot()
const violations = collectBoundaryViolations(root)
assert.deepEqual(violations, [], `工作区边界违规: ${violations.join('; ')}`)
const pkg = readWorkspacePackage(root)
assert.equal(pkg.name, STANDALONE_PACKAGE_NAME)
for (const dep of ['vue', 'vue-router', 'pinia', 'element-plus']) {
assert.ok(pkg.dependencies[dep], `缺少依赖 ${dep}`)
}
})
test('test_task_001_project_baseline_normal_variant_input', () => {
// 正常变体:构建、开发、测试三套命令形态都指向独立后台工程。
const { scripts } = readWorkspacePackage()
assert.match(scripts.build, /vue-tsc --noEmit/)
assert.match(scripts.build, /vite build/)
assert.match(scripts.dev, /vite/)
assert.match(scripts.dev, /5174/)
assert.match(scripts.test, /node --test/)
assert.match(scripts.test, /tests\/\*\.test\.ts/)
})
test('test_task_001_project_baseline_normal_repeated_operation_is_idempotent', () => {
// 正常重复:重复校验不改变结果、不产生不稳定状态。
const first = collectBoundaryViolations()
const second = collectBoundaryViolations()
assert.deepEqual(second, first, '重复校验结果应稳定一致')
const pkgA = readWorkspacePackage()
const pkgB = readWorkspacePackage()
assert.equal(pkgA.name, pkgB.name)
assert.deepEqual(pkgA.dependencies, pkgB.dependencies)
})
test('test_task_001_project_baseline_boundary_empty_input', () => {
// 边界空值:允许的源码目录集合完整存在;扫描可容忍空目录不崩溃。
const root = resolveWorkspaceRoot()
for (const dir of ADMIN_SOURCE_DIRS) {
assert.equal(existsSync(join(root, dir)), true, `缺少允许源码目录 ${dir}`)
}
const empty = tempRoot()
try {
mkdirSync(join(empty, 'src'))
assert.deepEqual(walk(empty), [], '空目录扫描应返回空结果且不抛异常')
} finally {
rmSync(empty, { recursive: true, force: true })
}
})
test('test_task_001_project_baseline_boundary_single_item', () => {
// 边界单元素:单一 SPA 入口与单一挂载点。
const root = resolveWorkspaceRoot()
const html = readFileSync(join(root, 'index.html'), 'utf8')
assert.match(html, /id="app"/)
assert.match(html, /\/src\/main\.ts/)
const main = readFileSync(join(root, 'src/main.ts'), 'utf8')
assert.match(main, /\.mount\('#app'\)/)
})
test('test_task_001_project_baseline_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:严格类型与 ESM 模块边界等关键字段必须存在。
const root = resolveWorkspaceRoot()
const tsconfig = readFileSync(join(root, 'tsconfig.json'), 'utf8')
assert.match(tsconfig, /"strict":\s*true/)
assert.match(tsconfig, /"moduleResolution":\s*"Bundler"/)
const pkg = readWorkspacePackage(root)
assert.equal(pkg.private, true)
assert.ok(pkg.scripts.test, '缺少 test 命令字段')
assert.ok(REQUIRED_MANIFEST_FILES.length >= 5, '清单字段不能为空')
})
test('test_task_001_project_baseline_invalid_input_rejected', () => {
// 异常输入:任何文件引用客户端耦合 token 都应被边界校验拒绝。
const root = tempRoot()
try {
for (const token of FORBIDDEN_COUPLING_TOKENS) {
mkdirSync(join(root, 'src'), { recursive: true })
writeFileSync(join(root, 'src', 'bad.ts'), `// 越界引用\nconst t = '${token}'\n`)
const violations = collectBoundaryViolations(root)
assert.ok(
violations.some((v) => v.includes(`引用了客户端耦合 token "${token}"`)),
`token ${token} 应被识别为越界: ${violations.join('; ')}`,
)
rmSync(join(root, 'src', 'bad.ts'))
}
} finally {
rmSync(root, { recursive: true, force: true })
}
})
test('test_task_001_project_baseline_dependency_failure_returns_actionable_message', () => {
// 依赖失败:根目录定位失败与清单缺失时返回可操作错误。
const root = tempRoot()
try {
const missing = join(root, 'no-package')
mkdirSync(missing)
assert.throws(
() => resolveWorkspaceRoot(missing),
(error: Error) => error.message.includes('package.json'),
)
const emptyDir = join(root, 'flat')
mkdirSync(emptyDir)
writeFileSync(join(emptyDir, 'package.json'), '{}')
const violations = collectBoundaryViolations(emptyDir)
assert.ok(
violations.some((v) => v.includes('缺少必需清单文件 src/main.ts')),
`依赖缺失应返回可操作清单消息: ${violations.join('; ')}`,
)
} finally {
rmSync(root, { recursive: true, force: true })
}
})
+75
View File
@@ -0,0 +1,75 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
isLazyLoader,
isPageModule,
PAGE_LOADING_DELAY,
PAGE_LOADING_TEXT,
PAGE_LOADING_TIMEOUT,
PAGE_LOAD_ERROR_TEXT,
} from '../src/router/lazy-config.ts'
import { adminPages } from '../src/router/routes.ts'
test('test_task_010_lazy_page_boundary_normal_primary_path', () => {
// 正常主路径:所有注册页面都是懒加载器,可被路由异步边界包裹。
assert.equal(adminPages.length, 3)
for (const page of adminPages) {
assert.equal(isLazyLoader(page.load), true, `页面 ${page.path} 必须是懒加载函数`)
}
})
test('test_task_010_lazy_page_boundary_normal_variant_input', async () => {
// 正常变体:加载器产物为页面模块(含 default)时识别成功。
const loader = async () => ({ default: {} })
const mod = await loader()
assert.equal(isPageModule(mod), true)
})
test('test_task_010_lazy_page_boundary_normal_repeated_operation_is_idempotent', () => {
// 正常重复:懒加载判定稳定。
assert.equal(isLazyLoader(() => Promise.resolve({})), true)
assert.equal(isLazyLoader(() => Promise.resolve({})), true)
})
test('test_task_010_lazy_page_boundary_boundary_empty_input', () => {
// 边界空值:缺省/空输入按非加载器/非页面模块处理,不崩溃。
assert.equal(isLazyLoader(undefined), false)
assert.equal(isLazyLoader(null), false)
assert.equal(isPageModule(null), false)
assert.equal(isPageModule(undefined), false)
})
test('test_task_010_lazy_page_boundary_boundary_single_item', () => {
// 边界单元素:单个含 default 的模块即可作为页面。
assert.equal(isPageModule({ default: () => null }), true)
})
test('test_task_010_lazy_page_boundary_boundary_limit_or_missing_field', () => {
// 边界上限:loading 延迟/超时为正且超时足够等待网络;文案不空。
assert.ok(PAGE_LOADING_DELAY > 0)
assert.ok(PAGE_LOADING_TIMEOUT > PAGE_LOADING_DELAY)
assert.ok(PAGE_LOADING_TIMEOUT <= 60000, '页面加载超时应处于合理上限内')
assert.ok(PAGE_LOADING_TEXT.length > 0)
})
test('test_task_010_lazy_page_boundary_invalid_input_rejected', () => {
// 异常输入:非函数/数组对象都不是懒加载器;无 default 模块不是页面模块。
assert.equal(isLazyLoader('load'), false)
assert.equal(isLazyLoader(123), false)
assert.equal(isLazyLoader({}), false)
assert.equal(isPageModule({}), false)
assert.equal(isPageModule([]), false)
})
test('test_task_010_lazy_page_boundary_dependency_failure_returns_actionable_message', () => {
// 依赖失败:router 对懒加载统一加异步边界;失败/加载中有样式与文案兜底。
const router = readSource('src/router/index.ts')
assert.match(router, /defineLazyPage/)
assert.equal(router.includes('adminRouteRecords.map'), true)
const lazyPage = readSource('src/router/lazy-page.ts')
assert.match(lazyPage, /PAGE_LOAD_ERROR_TEXT/)
const css = readSource('src/styles/main.css')
assert.match(css, /\.page-loading/)
assert.match(css, /\.page-error/)
})
+57
View File
@@ -0,0 +1,57 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
EMPTY_MENU_DESCRIPTION,
EMPTY_MENU_TITLE,
shouldShowEmptyMenu,
} from '../src/layout/empty-state.ts'
test('test_task_011_empty_menu_state_normal_primary_path', () => {
// 正常主路径:初始化完成且没有任何菜单 -> 展示空态。
assert.equal(shouldShowEmptyMenu(false, false, true), true)
})
test('test_task_011_empty_menu_state_normal_variant_input', () => {
// 正常变体:有一个或多个菜单时即使没有加载也不展示空态。
assert.equal(shouldShowEmptyMenu(true, false, true), false)
assert.equal(shouldShowEmptyMenu(true, true, true), false)
})
test('test_task_011_empty_menu_state_normal_repeated_operation_is_idempotent', () => {
// 正常重复:判定幂等。
assert.equal(shouldShowEmptyMenu(false, false, true), shouldShowEmptyMenu(false, false, true))
assert.equal(shouldShowEmptyMenu(true, false, true), shouldShowEmptyMenu(true, false, true))
})
test('test_task_011_empty_menu_state_boundary_empty_input', () => {
// 边界空值:会话未初始化时不展示空态(避免误报)。
assert.equal(shouldShowEmptyMenu(false, false, false), false)
assert.equal(shouldShowEmptyMenu(false, true, false), false)
})
test('test_task_011_empty_menu_state_boundary_single_item', () => {
// 边界单元素:仅一个菜单即不算空。
assert.equal(shouldShowEmptyMenu(true, false, true), false)
})
test('test_task_011_empty_menu_state_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:加载中禁止闪现空态;初始化字段缺失按未就绪处理。
assert.equal(shouldShowEmptyMenu(false, true, true), false, '加载中不得闪现空态')
assert.equal(shouldShowEmptyMenu(false, false, undefined as unknown as boolean), false)
})
test('test_task_011_empty_menu_state_invalid_input_rejected', () => {
// 异常输入:布尔语义混乱(未初始化却已加载完)也不展示。
assert.equal(shouldShowEmptyMenu(false, true, undefined as unknown as boolean), false)
})
test('test_task_011_empty_menu_state_dependency_failure_returns_actionable_message', () => {
// 依赖失败:壳层消费空态判定与文案常量,内容级空态在根路由呈现。
assert.ok(EMPTY_MENU_TITLE.length > 0)
assert.ok(EMPTY_MENU_DESCRIPTION.length > EMPTY_MENU_TITLE.length)
const layout = readSource('src/layout/AdminLayout.vue')
assert.match(layout, /shouldShowEmptyMenu/)
assert.match(layout, /EMPTY_MENU_DESCRIPTION/)
assert.match(layout, /route\.path === '\/'/, '内容级空态限定根路由')
})
+71
View File
@@ -0,0 +1,71 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { existsSync } from 'node:fs'
import { join } from 'node:path'
import { readSource, occurrences } from './helpers.ts'
import { adminPages } from '../src/router/routes.ts'
const ROUTER = 'src/router/index.ts'
const NOT_FOUND = 'src/pages/error/NotFoundPage.vue'
test('test_task_012_route_error_page_normal_primary_path', () => {
// 正常主路径:未知路径注册到路由级错误页兜底。
const router = readSource(ROUTER)
assert.match(router, /path:\s*':pathMatch\(\.\*\)\*'/)
assert.match(router, /NotFoundPage/)
assert.match(router, /页面不存在/)
})
test('test_task_012_route_error_page_normal_variant_input', () => {
// 正常变体:错误页在 AdminLayout children 内,保留壳层 chrome。
const router = readSource(ROUTER)
const catchAllIndex = router.indexOf(':pathMatch(.*)*')
const registryIndex = router.indexOf('adminRouteRecords.map')
assert.ok(catchAllIndex > registryIndex, 'catch-all 应在业务路由之后注册')
assert.match(router, /path: '\/',/)
})
test('test_task_012_route_error_page_normal_repeated_operation_is_idempotent', () => {
// 正常重复:错误页注册不重复追加。
const first = readSource(ROUTER)
assert.equal(occurrences(first, ':pathMatch(.*)*'), 1)
})
test('test_task_012_route_error_page_boundary_empty_input', () => {
// 边界空值:错误页文件存在,且不进入业务路由注册表。
assert.equal(existsSync(join(process.cwd(), NOT_FOUND)), true)
assert.equal(adminPages.length, 3, '错误页不应计入业务路由')
})
test('test_task_012_route_error_page_boundary_single_item', () => {
// 边界单元素:错误页是单一 Vue 页面组件。
const source = readSource(NOT_FOUND)
assert.equal(occurrences(source, '<template>'), 1)
assert.match(source, /el-result/)
})
test('test_task_012_route_error_page_boundary_limit_or_missing_field', () => {
// 边界上限:catch-all 不参与菜单权限门禁(无 menuKey)。
const router = readSource(ROUTER)
const tail = router.slice(router.indexOf('component: NotFoundPage'))
assert.equal(tail.slice(0, 80).includes('menuKey'), false, '错误页不应带菜单 key')
})
test('test_task_012_route_error_page_invalid_input_rejected', () => {
// 异常输入:深层未知路径也能被通配兜底,且提供返回首页动作。
const router = readSource(ROUTER)
assert.match(router, /:pathMatch\(\.\*\)\*/, '通配需覆盖多段未知路径')
const page = readSource(NOT_FOUND)
assert.match(page, /router\.replace\('\/'\)/)
})
test('test_task_012_route_error_page_dependency_failure_returns_actionable_message', () => {
// 依赖失败:标题/样式/返回动作齐全,加载失败有明确入口。
const page = readSource(NOT_FOUND)
assert.match(page, /返回首页/)
assert.match(page, /404/)
const css = readSource('src/styles/main.css')
assert.match(css, /\.not-found/)
const router = readSource(ROUTER)
assert.match(router, /meta: \{ title: '页面不存在' \}/)
})
+94
View File
@@ -0,0 +1,94 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
clearGlobalErrors,
dismissGlobalError,
GLOBAL_ERROR_FALLBACK,
GLOBAL_ERROR_LIMIT,
normalizeErrorMessage,
notifyGlobalError,
snapshotGlobalErrors,
subscribeGlobalError,
} from '../src/layout/error-bus.ts'
test('test_task_013_global_error_notice_normal_primary_path', () => {
// 正常主路径:通知一条错误进入提示流。
clearGlobalErrors()
notifyGlobalError('登录已过期')
const list = snapshotGlobalErrors()
assert.equal(list.length, 1)
assert.equal(list[0].message, '登录已过期')
})
test('test_task_013_global_error_notice_normal_variant_input', () => {
// 正常变体:不同错误逐条追加、顺序保留。
clearGlobalErrors()
notifyGlobalError('错误A')
notifyGlobalError('错误B')
assert.deepEqual(snapshotGlobalErrors().map((i) => i.message), ['错误A', '错误B'])
})
test('test_task_013_global_error_notice_normal_repeated_operation_is_idempotent', () => {
// 正常重复:相同消息重复通知产生稳定独立的条目(id 单调递增)。
clearGlobalErrors()
notifyGlobalError('重试')
const first = snapshotGlobalErrors()[0]
notifyGlobalError('重试')
const second = snapshotGlobalErrors()[1]
assert.notEqual(first.id, second.id)
assert.equal(first.message, second.message)
})
test('test_task_013_global_error_notice_boundary_empty_input', () => {
// 边界空值:空/缺省消息回落到通用提示,不出现空白条目。
clearGlobalErrors()
assert.equal(normalizeErrorMessage(' '), GLOBAL_ERROR_FALLBACK)
notifyGlobalError('')
assert.equal(snapshotGlobalErrors()[0].message, GLOBAL_ERROR_FALLBACK)
})
test('test_task_013_global_error_notice_boundary_single_item', () => {
// 边界单元素:单条可按 id 关闭。
clearGlobalErrors()
notifyGlobalError('单条')
const [item] = snapshotGlobalErrors()
dismissGlobalError(item.id)
assert.deepEqual(snapshotGlobalErrors(), [])
})
test('test_task_013_global_error_notice_boundary_limit_or_missing_field', () => {
// 边界上限:超过上限只保留最近 N 条,不堆积。
clearGlobalErrors()
for (let i = 1; i <= GLOBAL_ERROR_LIMIT + 2; i += 1) notifyGlobalError(`err${i}`)
const list = snapshotGlobalErrors()
assert.equal(list.length, GLOBAL_ERROR_LIMIT)
assert.equal(list[list.length - 1].message, `err${GLOBAL_ERROR_LIMIT + 2}`)
})
test('test_task_013_global_error_notice_invalid_input_rejected', () => {
// 异常输入:Error/数字/对象负载均归一化到可展示文案。
clearGlobalErrors()
assert.equal(normalizeErrorMessage(new Error('连接被拒绝')), '连接被拒绝')
assert.equal(normalizeErrorMessage(500), GLOBAL_ERROR_FALLBACK)
assert.equal(normalizeErrorMessage({ code: 1 }), GLOBAL_ERROR_FALLBACK)
assert.equal(normalizeErrorMessage(new Error(' ')), GLOBAL_ERROR_FALLBACK)
})
test('test_task_013_global_error_notice_dependency_failure_returns_actionable_message', () => {
// 依赖失败:订阅提供取消函数,取消后不再回调(容器卸载无泄漏)。
clearGlobalErrors()
const seen: number[] = []
const unsubscribe = subscribeGlobalError((list) => seen.push(list.length))
notifyGlobalError('a')
unsubscribe()
notifyGlobalError('b')
assert.deepEqual(seen, [0, 1], '取消订阅后不应再收到更新')
clearGlobalErrors()
// 容器组件本身在卸载时执行清理并保留可关闭错误项。
const container = readSource('src/layout/GlobalErrorContainer.vue')
assert.match(container, /unsubscribe/)
assert.match(container, /dismissGlobalError/)
const layout = readSource('src/layout/AdminLayout.vue')
assert.match(layout, /GlobalErrorContainer/)
})
+93
View File
@@ -0,0 +1,93 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
initialCollapsed,
isNarrowScreen,
readCollapsePreference,
SIDEBAR_COLLAPSED_WIDTH,
SIDEBAR_EXPANDED_WIDTH,
SIDEBAR_NARROW_THRESHOLD,
sidebarPixelWidth,
toggleCollapsed,
writeCollapsePreference,
type CollapseStorage,
} from '../src/layout/sidebar-collapse.ts'
function fakeStorage(entries: Record<string, string>, failing = false): CollapseStorage {
return {
getItem(key: string) {
if (failing) throw new Error('storage down')
return key in entries ? entries[key] : null
},
setItem(key: string, value: string) {
if (failing) throw new Error('storage down')
entries[key] = value
},
}
}
test('test_task_014_sidebar_responsive_behavior_normal_primary_path', () => {
// 正常主路径:折叠开关反转状态。
assert.equal(toggleCollapsed(false), true)
assert.equal(toggleCollapsed(true), false)
})
test('test_task_014_sidebar_responsive_behavior_normal_variant_input', () => {
// 正常变体:不同宽度判定窄屏与宽屏。
assert.equal(isNarrowScreen(SIDEBAR_NARROW_THRESHOLD), true)
assert.equal(isNarrowScreen(SIDEBAR_NARROW_THRESHOLD + 1), false)
assert.equal(isNarrowScreen(1440), false)
})
test('test_task_014_sidebar_responsive_behavior_normal_repeated_operation_is_idempotent', () => {
// 正常重复:偏好读写与宽度结果稳定。
const storage = fakeStorage({})
assert.equal(initialCollapsed(1000, storage), initialCollapsed(1000, storage))
writeCollapsePreference(storage, true)
assert.equal(readCollapsePreference(storage), true)
assert.equal(readCollapsePreference(storage), true)
})
test('test_task_014_sidebar_responsive_behavior_boundary_empty_input', () => {
// 边界空值:未知宽度/无存储不崩溃且回退展开。
assert.equal(isNarrowScreen(0), false)
assert.equal(initialCollapsed(0, null), false)
assert.equal(readCollapsePreference(null), null)
})
test('test_task_014_sidebar_responsive_behavior_boundary_single_item', () => {
// 边界单元素:单值持久化可读回。
const storage = fakeStorage({ 'admin.sidebar.collapsed': 'false' })
assert.equal(readCollapsePreference(storage), false)
assert.equal(initialCollapsed(1024, storage), false)
})
test('test_task_014_sidebar_responsive_behavior_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:非法持久化值按无偏好处理;像素宽与常量一致。
const storage = fakeStorage({ 'admin.sidebar.collapsed': 'maybe' })
assert.equal(readCollapsePreference(storage), null)
assert.equal(sidebarPixelWidth(true), SIDEBAR_COLLAPSED_WIDTH)
assert.equal(sidebarPixelWidth(false), SIDEBAR_EXPANDED_WIDTH)
assert.equal(SIDEBAR_COLLAPSED_WIDTH < SIDEBAR_EXPANDED_WIDTH, true)
})
test('test_task_014_sidebar_responsive_behavior_invalid_input_rejected', () => {
// 异常输入:存储读写失败被容忍,不阻断交互。
const broken = fakeStorage({}, true)
assert.equal(readCollapsePreference(broken), null)
assert.doesNotThrow(() => writeCollapsePreference(broken, true))
const fallback = fakeStorage({ 'admin.sidebar.collapsed': 'true' })
assert.equal(initialCollapsed(1440, fallback), true, '持久化优先于视口宽度')
})
test('test_task_014_sidebar_responsive_behavior_dependency_failure_returns_actionable_message', () => {
// 依赖失败:壳层接入折叠逻辑;CSS 有 is-collapsed 与窄屏媒体适配。
const layout = readSource('src/layout/AdminLayout.vue')
assert.match(layout, /initialCollapsed/)
assert.match(layout, /writeCollapsePreference/)
assert.match(layout, /toggleSidebar/)
const css = readSource('src/styles/main.css')
assert.match(css, /is-collapsed/)
assert.match(css, /@media \(max-width: 820px\)/)
})
+76
View File
@@ -0,0 +1,76 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
ADMIN_BRAND,
crumbsForActiveRoute,
resolveDocumentTitle,
updateDocumentTitle,
} from '../src/layout/title-breadcrumb.ts'
import type { AdminMenuNode } from '../src/types/admin.ts'
function node(partial: Partial<AdminMenuNode> & { key: string; name: string }): AdminMenuNode {
return { key: partial.key, name: partial.name, route: partial.route, children: partial.children }
}
const TREE: AdminMenuNode[] = [
node({ key: 'account', name: '账号权限', children: [
node({ key: 'admin_users', name: '用户管理', route: '/account/users' }),
] }),
node({ key: 'top', name: '顶级页', route: '/top' }),
]
test('test_task_015_page_title_breadcrumb_normal_primary_path', () => {
// 正常主路径:文档标题 = 页面标题 - 品牌。
assert.equal(resolveDocumentTitle('用户管理'), '用户管理 - 数富AI')
assert.equal(ADMIN_BRAND, '数富AI')
})
test('test_task_015_page_title_breadcrumb_normal_variant_input', () => {
// 正常变体:分组内命中时返回 分组->页面 两级面包屑。
const crumbs = crumbsForActiveRoute(TREE, '/account/users')
assert.deepEqual(crumbs.map((c) => c.name), ['账号权限', '用户管理'])
assert.equal(crumbs[1].route, '/account/users')
})
test('test_task_015_page_title_breadcrumb_normal_repeated_operation_is_idempotent', () => {
// 正常重复:标题与面包屑解析稳定。
assert.equal(resolveDocumentTitle('菜单管理'), resolveDocumentTitle('菜单管理'))
assert.deepEqual(crumbsForActiveRoute(TREE, '/account/users'), crumbsForActiveRoute(TREE, '/account/users'))
})
test('test_task_015_page_title_breadcrumb_boundary_empty_input', () => {
// 边界空值:无页面标题时文档标题仅品牌;空树/空激活路径返回空面包屑。
assert.equal(resolveDocumentTitle(''), ADMIN_BRAND)
assert.equal(resolveDocumentTitle(' '), ADMIN_BRAND)
assert.deepEqual(crumbsForActiveRoute([], '/x'), [])
assert.deepEqual(crumbsForActiveRoute(undefined, '/x'), [])
})
test('test_task_015_page_title_breadcrumb_boundary_single_item', () => {
// 边界单元素:顶级叶子页命中返回自身单级面包屑。
const crumbs = crumbsForActiveRoute(TREE, '/top')
assert.equal(crumbs.length, 1)
assert.equal(crumbs[0].name, '顶级页')
})
test('test_task_015_page_title_breadcrumb_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:激活路径不在菜单树中时返回空,不伪造父级。
assert.deepEqual(crumbsForActiveRoute(TREE, '/no/such/page'), [])
})
test('test_task_015_page_title_breadcrumb_invalid_input_rejected', () => {
// 异常输入:非法页面标题按空处理;doc 缺省时更新静默失败不抛异常。
assert.equal(resolveDocumentTitle(null as unknown as string), ADMIN_BRAND)
assert.doesNotThrow(() => updateDocumentTitle('标题', null))
})
test('test_task_015_page_title_breadcrumb_dependency_failure_returns_actionable_message', () => {
// 依赖失败:壳层接入文档标题同步与面包屑渲染。
const layout = readSource('src/layout/AdminLayout.vue')
assert.match(layout, /updateDocumentTitle/)
assert.match(layout, /resolveDocumentTitle/)
assert.match(layout, /crumbsForActiveRoute/)
assert.match(layout, /el-breadcrumb/)
assert.match(layout, /breadcrumbs\.length > 1/)
})
+80
View File
@@ -0,0 +1,80 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
LOGOUT_CONFIRM_CANCEL,
LOGOUT_CONFIRM_MESSAGE,
LOGOUT_CONFIRM_OK,
LOGOUT_CONFIRM_TITLE,
runLogout,
} from '../src/layout/logout.ts'
test('test_task_016_shell_logout_interaction_normal_primary_path', async () => {
// 正常主路径:确认后执行退出。
let signedOut = 0
await runLogout({ confirm: async () => true, signOut: async () => { signedOut += 1 } })
assert.equal(signedOut, 1)
})
test('test_task_016_shell_logout_interaction_normal_variant_input', async () => {
// 正常变体:取消确认则不退出。
let signedOut = 0
await runLogout({ confirm: async () => false, signOut: async () => { signedOut += 1 } })
assert.equal(signedOut, 0)
})
test('test_task_016_shell_logout_interaction_normal_repeated_operation_is_idempotent', async () => {
// 正常重复:多次确认分别各执行一次,互不污染状态。
let signedOut = 0
const deps = { confirm: async () => true, signOut: async () => { signedOut += 1 } }
await runLogout(deps)
await runLogout(deps)
assert.equal(signedOut, 2)
})
test('test_task_016_shell_logout_interaction_boundary_empty_input', async () => {
// 边界空值:确认被拒后即便 signOut 有副作用也不会被调用。
let signedOut = 0
await runLogout({ confirm: async () => false, signOut: async () => { signedOut += 1 } })
assert.equal(signedOut, 0)
})
test('test_task_016_shell_logout_interaction_boundary_single_item', async () => {
// 边界单元素:signOut 异常向上抛出,供调用方反馈(不静默)。
await assert.rejects(
runLogout({ confirm: async () => true, signOut: async () => { throw new Error('退出接口失败') } }),
/退出接口失败/,
)
})
test('test_task_016_shell_logout_interaction_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:确认文案齐全、按钮语义完整。
assert.ok(LOGOUT_CONFIRM_MESSAGE.length > 0)
assert.ok(LOGOUT_CONFIRM_TITLE.length > 0)
assert.ok(LOGOUT_CONFIRM_OK.length > 0)
assert.ok(LOGOUT_CONFIRM_CANCEL.length > 0)
})
test('test_task_016_shell_logout_interaction_invalid_input_rejected', async () => {
// 异常输入:确认对话框异常(fail-closed),不得退出。
let signedOut = 0
await assert.rejects(
runLogout({
confirm: async () => { throw new Error('弹窗异常') },
signOut: async () => { signedOut += 1 },
}),
/弹窗异常/,
)
assert.equal(signedOut, 0)
})
test('test_task_016_shell_logout_interaction_dependency_failure_returns_actionable_message', () => {
// 依赖失败:壳层使用 ElMessageBox 确认 + runLogout;store 退出清态并跳登录。
const layout = readSource('src/layout/AdminLayout.vue')
assert.match(layout, /ElMessageBox\.confirm/)
assert.match(layout, /runLogout/)
const store = readSource('src/stores/admin-session.ts')
assert.match(store, /\$reset\(\)/)
assert.match(store, /location\.assign\('\/login'\)/)
assert.match(layout, /LOGOUT_CONFIRM_MESSAGE/)
})
+91
View File
@@ -0,0 +1,91 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import {
APP_BASE_PATH,
APP_HISTORY_MODE,
ensureAppBasePath,
joinAdminPath,
} from '../src/config/app.ts'
import { resolveWorkspaceRoot, walk } from '../src/config/workspace.ts'
const ROOT = resolveWorkspaceRoot()
function sourceFiles(): string[] {
return walk(ROOT)
}
function literalBaseOccurrences(file: string): number {
const content = readFileSync(join(ROOT, file), 'utf8')
const matches = content.match(/['"]\/admin-vue\/['"]/g)
return matches ? matches.length : 0
}
test('test_task_002_history_base_contract_normal_primary_path', () => {
// 正常主路径:冻结契约常量可被路由/构建直接消费。
assert.equal(APP_BASE_PATH, '/admin-vue/')
assert.equal(APP_HISTORY_MODE, 'history')
assert.equal(joinAdminPath('account', 'users'), '/admin-vue/account/users')
const router = readFileSync(join(ROOT, 'src/router/index.ts'), 'utf8')
assert.match(router, /createWebHistory\(APP_BASE_PATH\)/)
})
test('test_task_002_history_base_contract_normal_variant_input', () => {
// 正常变体:无尾斜杠/带尾斜杠/单段带斜杠的等价输入得到同一结果。
assert.equal(ensureAppBasePath('/admin-vue'), APP_BASE_PATH)
assert.equal(ensureAppBasePath('/admin-vue/'), APP_BASE_PATH)
assert.equal(joinAdminPath('account/users'), joinAdminPath('account', 'users'))
})
test('test_task_002_history_base_contract_normal_repeated_operation_is_idempotent', () => {
// 正常重复:归一化与拼接幂等、不依赖可变状态。
assert.equal(ensureAppBasePath(ensureAppBasePath('/admin-vue')), APP_BASE_PATH)
assert.equal(joinAdminPath('account', 'users'), joinAdminPath('account', 'users'))
const once = joinAdminPath('shop-center', 'list')
const twice = joinAdminPath('shop-center', 'list')
assert.equal(once, twice)
})
test('test_task_002_history_base_contract_boundary_empty_input', () => {
// 边界空值:无段拼接回到基准根路径;空 base 被拒绝并带语义错误。
assert.equal(joinAdminPath(), APP_BASE_PATH)
assert.throws(() => ensureAppBasePath(''), /base 路径非法/)
})
test('test_task_002_history_base_contract_boundary_single_item', () => {
// 边界单元素:单个路由段生成单一绝对地址。
assert.equal(joinAdminPath('users'), '/admin-vue/users')
assert.ok(APP_BASE_PATH.endsWith('/'))
assert.ok(!APP_BASE_PATH.includes('//'))
})
test('test_task_002_history_base_contract_boundary_limit_or_missing_field', () => {
// 边界上限:段内多余斜杠与首尾空白被收敛,不产生双斜杠或空格。
const path = joinAdminPath(' /account/ ', ' users/ ')
assert.equal(path, '/admin-vue/account/users')
assert.equal((APP_BASE_PATH.match(/\//g) || []).length, 2, '基准路径只含一个目录段')
})
test('test_task_002_history_base_contract_invalid_input_rejected', () => {
// 异常输入:缺 / 前缀、含内部双斜杠、含 .. 越权段均被拒绝并给出消息。
assert.throws(() => ensureAppBasePath('admin-vue'), /base 路径非法/)
assert.throws(() => ensureAppBasePath('//admin-vue/'), /base 路径非法/)
assert.throws(() => joinAdminPath('..', 'x'), /不允许出现 \.\./)
assert.throws(() => joinAdminPath('/../etc'), /不允许出现 \.\./)
})
test('test_task_002_history_base_contract_dependency_failure_returns_actionable_message', () => {
// 依赖失败:非法 base 值(undefined)返回可操作错误;base 字面量必须单一来源。
assert.throws(() => ensureAppBasePath(undefined as unknown as string), (e: Error) => {
return /base 路径非法/.test(e.message)
})
const offenders = sourceFiles()
.map((file) => ({ file, count: literalBaseOccurrences(file) }))
.filter(({ file, count }) => count > 0)
assert.deepEqual(
offenders.map((o) => o.file),
['src/config/app.ts'],
`'/admin-vue/' 字面量必须只出现在单一事实源 app.ts: ${JSON.stringify(offenders)}`,
)
})
+68
View File
@@ -0,0 +1,68 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import {
isAdminRole,
isSuperAdminRole,
isSuperUser,
roleKind,
roleLabel,
} from '../src/types/admin.ts'
test('test_task_021_type_contract_normal_primary_path', () => {
// 正常主路径:真实后端角色串映射到角色域。
assert.equal(roleKind('super_admin'), 'super_admin')
assert.equal(isSuperAdminRole('super_admin'), true)
assert.equal(isSuperUser({ role: 'super_admin' }), true)
})
test('test_task_021_type_contract_normal_variant_input', () => {
// 正常变体:admin/normal 归类正确,超级用户判定不为 true。
assert.equal(roleKind('admin'), 'admin')
assert.equal(roleKind('normal'), 'normal')
assert.equal(isSuperUser({ role: 'admin' }), false)
assert.equal(isAdminRole('admin'), true)
})
test('test_task_021_type_contract_normal_repeated_operation_is_idempotent', () => {
// 正常重复:角色归一稳定。
assert.equal(roleKind('SUPER_ADMIN'), roleKind('super_admin'))
assert.equal(roleLabel('admin'), roleLabel(' admin '))
})
test('test_task_021_type_contract_boundary_empty_input', () => {
// 边界空值:空角色/空用户不崩溃,归类为 null/非管理员。
assert.equal(roleKind(''), null)
assert.equal(roleKind(undefined), null)
assert.equal(roleKind(null), null)
assert.equal(isSuperUser(null), false)
assert.equal(isSuperUser(undefined), false)
})
test('test_task_021_type_contract_boundary_single_item', () => {
// 边界单元素:单个 super_admin 用户可进全部菜单。
assert.equal(isSuperUser({ role: 'super_admin' }), true)
assert.equal(roleLabel('super_admin'), '超级管理员')
})
test('test_task_021_type_contract_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:未知角色串不误判为管理员,展示空文案。
assert.equal(roleKind('owner'), null)
assert.equal(isAdminRole('owner'), false)
assert.equal(roleLabel('owner'), '')
})
test('test_task_021_type_contract_invalid_input_rejected', () => {
// 异常输入:大小写/空白容忍,非法字符串归类 null。
assert.equal(roleKind(' Super_Admin '), 'super_admin')
assert.equal(roleKind('xxx'), null)
assert.equal(isSuperAdminRole(''), false)
})
test('test_task_021_type_contract_dependency_failure_returns_actionable_message', () => {
// 依赖失败:菜单节点契约为分组可无 route、页面必须可路由。
const group = { key: 'admin_group_account', name: '账号权限' }
const page = { key: 'admin_users', name: '用户管理', route: '/account/users' }
assert.equal('route' in group, false, '分组节点允许无 route')
assert.equal(typeof page.route, 'string', '页面节点必须带 route')
assert.equal(roleLabel('super_admin').length > 0, true)
})
+71
View File
@@ -0,0 +1,71 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
errorTextOf,
isUnauthorized,
loginRedirectTarget,
requestErrorMessage,
REQUEST_FALLBACK_MESSAGE,
unwrap,
} from '../src/api/envelope.ts'
test('test_task_022_envelope_rules_normal_primary_path', () => {
// 正常主路径:带 data 的信封解包出业务数据。
const out = unwrap<{ item: { id: number } }>({ success: true, data: { item: { id: 1 } } })
assert.equal(out.item.id, 1)
})
test('test_task_022_envelope_rules_normal_variant_input', () => {
// 正常变体:{items}/{item} 信封(无 data)原样返回由调用方再解。
const payload = { success: true, items: [{ key: 'a' }] }
const out = unwrap<{ items: Array<{ key: string }> }>(payload)
assert.equal(out.items[0].key, 'a')
})
test('test_task_022_envelope_rules_normal_repeated_operation_is_idempotent', () => {
// 正常重复:解包结果稳定、不修改输入。
const payload = { success: true, data: [1, 2] }
const a = JSON.stringify(unwrap(payload))
const b = JSON.stringify(unwrap(payload))
assert.equal(a, b)
assert.deepEqual(payload, { success: true, data: [1, 2] })
})
test('test_task_022_envelope_rules_boundary_empty_input', () => {
// 边界空值:空/非对象负载按原样返回或回落网络提示。
assert.equal(unwrap(undefined as unknown as null), undefined)
assert.equal(requestErrorMessage(undefined), REQUEST_FALLBACK_MESSAGE)
})
test('test_task_022_envelope_rules_boundary_single_item', () => {
// 边界单元素:错误文案优先取响应 message。
const error = { response: { data: { message: '未登录', error: 'old' } } }
assert.equal(requestErrorMessage(error), '未登录')
})
test('test_task_022_envelope_rules_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:success=false 且 message 缺失回落到通用失败。
assert.throws(() => unwrap({ success: false }), /请求失败/)
assert.equal(errorTextOf({ error: '权限不足' }), '权限不足')
assert.equal(errorTextOf({ message: '', error: 'X' }), 'X')
})
test('test_task_022_envelope_rules_invalid_input_rejected', () => {
// 异常输入:401 判定覆盖 code/status/statusCode;非 401 不误判。
assert.equal(isUnauthorized({ code: 401 }), true)
assert.equal(isUnauthorized({ status: 401 }), true)
assert.equal(isUnauthorized({ statusCode: 401 }), true)
assert.equal(isUnauthorized({ code: 403 }), false)
assert.equal(isUnauthorized(null), false)
assert.equal(requestErrorMessage(new Error('Network Error')), 'Network Error')
})
test('test_task_022_envelope_rules_dependency_failure_returns_actionable_message', () => {
// 依赖失败:http 层复用 envelope 并统一处理 401 跳登录。
const http = readSource('src/api/http.ts')
assert.match(http, /export \{ unwrap \} from '\.\/envelope'/)
assert.match(http, /isUnauthorized/)
assert.match(http, /login\?redirect=/)
assert.equal(loginRedirectTarget({ pathname: '/admin-vue/x', search: '?a=1' }), encodeURIComponent('/admin-vue/x?a=1'))
})
+64
View File
@@ -0,0 +1,64 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { parseCurrentUser } from '../src/api/session-model.ts'
test('test_task_023_current_user_adapter_normal_primary_path', () => {
// 正常主路径:Java data:{item} 信封解出当前用户。
const user = parseCurrentUser({
success: true,
data: { item: { id: 1, username: 'admin', role: 'super_admin' } },
})
assert.equal(user.id, 1)
assert.equal(user.username, 'admin')
assert.equal(user.role, 'super_admin')
})
test('test_task_023_current_user_adapter_normal_variant_input', () => {
// 正常变体:无 data 的 {item} 信封同样可解。
const user = parseCurrentUser({ success: true, item: { id: 3, username: '张伟恒', role: 'admin' } })
assert.equal(user.username, '张伟恒')
assert.equal(user.role, 'admin')
})
test('test_task_023_current_user_adapter_normal_repeated_operation_is_idempotent', () => {
// 正常重复:解析不修改输入、结果稳定。
const payload = { success: true, data: { item: { id: 2, username: 'u', role: 'normal' } } }
assert.deepEqual(parseCurrentUser(payload), parseCurrentUser(payload))
assert.deepEqual(payload, { success: true, data: { item: { id: 2, username: 'u', role: 'normal' } } })
})
test('test_task_023_current_user_adapter_boundary_empty_input', () => {
// 边界空值:响应缺 id 视为无效并抛可操作错误。
assert.throws(() => parseCurrentUser({ success: true, data: { item: {} } }), /缺少有效 id/)
assert.throws(() => parseCurrentUser(null), /缺少有效 id|请求失败/)
})
test('test_task_023_current_user_adapter_boundary_single_item', () => {
// 边界单元素:单用户最小字段即可。
const user = parseCurrentUser({ data: { item: { id: 9, username: 'root', role: 'super_admin' } } })
assert.equal(user.username, 'root')
})
test('test_task_023_current_user_adapter_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:success=false 被拒绝并带后端 message。
assert.throws(
() => parseCurrentUser({ success: false, message: '未登录', code: 401 }),
/未登录/,
)
})
test('test_task_023_current_user_adapter_invalid_input_rejected', () => {
// 异常输入:缺 role/username 不应崩溃;缺 id 拒绝。
const user = parseCurrentUser({ data: { item: { id: 5, username: '', role: '' } } })
assert.equal(user.username, '')
assert.throws(() => parseCurrentUser({ data: { item: { username: 'no-id' } } }), /缺少有效 id/)
})
test('test_task_023_current_user_adapter_dependency_failure_returns_actionable_message', () => {
// 依赖失败:会话请求适配消费同一解析器;纯解析模块不含 axios 副作用。
const session = readSource('src/api/session.ts')
assert.match(session, /parseCurrentUser/)
const model = readSource('src/api/session-model.ts')
assert.match(model, /import \{ unwrap \} from '\.\/envelope(?:\.ts)?'/)
})
+75
View File
@@ -0,0 +1,75 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { parseMenuTree } from '../src/api/session-model.ts'
const GROUPED = {
success: true,
data: {
items: [
{ key: 'admin_group_account', name: '账号与权限', children: [
{ key: 'admin_users', name: '用户管理', route: '/account/users' },
] },
],
},
}
test('test_task_024_menu_tree_adapter_normal_primary_path', () => {
// 正常主路径:data:{items} 树形信封解出分组与页面。
const tree = parseMenuTree(GROUPED)
assert.equal(tree.length, 1)
assert.equal(tree[0].key, 'admin_group_account')
assert.equal(tree[0].children?.[0].route, '/account/users')
})
test('test_task_024_menu_tree_adapter_normal_variant_input', () => {
// 正常变体:数组直传与 {items} 信封均可解析。
const direct = parseMenuTree([{ key: 'a', name: '甲' }])
assert.equal(direct.length, 1)
const envelope = parseMenuTree({ success: true, items: [{ key: 'b', name: '乙', route: '/b' }] })
assert.equal(envelope[0].route, '/b')
})
test('test_task_024_menu_tree_adapter_normal_repeated_operation_is_idempotent', () => {
// 正常重复:解析稳定、不改输入。
assert.deepEqual(parseMenuTree(GROUPED), parseMenuTree(GROUPED))
assert.deepEqual(GROUPED, {
success: true,
data: { items: [{ key: 'admin_group_account', name: '账号与权限', children: [{ key: 'admin_users', name: '用户管理', route: '/account/users' }] }] },
})
})
test('test_task_024_menu_tree_adapter_boundary_empty_input', () => {
// 边界空值:空 items/空数组/缺省按空树处理,不抛错(与接口失败区分)。
assert.deepEqual(parseMenuTree({ success: true, data: { items: [] } }), [])
assert.deepEqual(parseMenuTree({ success: true, items: [] }), [])
assert.deepEqual(parseMenuTree({ success: true, data: {} }), [])
assert.deepEqual(parseMenuTree([]), [])
})
test('test_task_024_menu_tree_adapter_boundary_single_item', () => {
// 边界单元素:单个分组节点返回。
const tree = parseMenuTree({ data: { items: [{ key: 'g', name: '分组' }] } })
assert.equal(tree.length, 1)
assert.equal(tree[0].name, '分组')
})
test('test_task_024_menu_tree_adapter_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:页面缺 route 不崩溃;group 无 route 合法。
const tree = parseMenuTree({ items: [{ key: 'g', name: '组', children: [{ key: 'p', name: '页' }] }] })
assert.equal(tree[0].children?.[0].route, undefined)
})
test('test_task_024_menu_tree_adapter_invalid_input_rejected', () => {
// 异常输入:success=false 视为接口失败并抛错(区别于空权限)。
assert.throws(() => parseMenuTree({ success: false, message: '未登录', code: 401 }), /未登录/)
assert.deepEqual(parseMenuTree(null as unknown as { items?: [] }), [])
})
test('test_task_024_menu_tree_adapter_dependency_failure_returns_actionable_message', () => {
// 依赖失败:会话适配调用菜单解析器;后端按 sort 顺序原样返回(前端不重排)。
const session = readSource('src/api/session.ts')
assert.match(session, /parseMenuTree/)
const model = readSource('src/api/session-model.ts')
assert.match(model, /parseMenuTree/)
})
+75
View File
@@ -0,0 +1,75 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { loginRedirectTarget } from '../src/api/envelope.ts'
const httpSrc = readSource('src/api/http.ts')
const sessionSrc = readSource('src/api/session.ts')
test('test_task_025_cookie_session_config_normal_primary_path', () => {
// 正常主路径:共享传输开启同源 Cookie/Session(Axios withCredentials 必须开启)。
assert.match(httpSrc, /withCredentials:\s*true/, 'Cookie 规则:Axios withCredentials 必须开启')
assert.match(httpSrc, /baseURL:\s*'\/'/, '请求使用同源 Cookie/Session')
})
test('test_task_025_cookie_session_config_normal_variant_input', () => {
// 正常变体:current-user / menus / logout 三类会话调用全部复用同一共享 http 实例。
assert.match(sessionSrc, /import \{ http \} from '\.\/http'/)
const getCalls = (sessionSrc.match(/\bhttp\.get\b/g) || []).length
assert.equal(getCalls, 2, 'current-user 与 menus 两个 GET 均走共享 http')
assert.equal((sessionSrc.match(/\bhttp\.post\b/g) || []).length, 1, 'logout 走共享 http')
assert.match(sessionSrc, /current-user/)
assert.match(sessionSrc, /current-user\/menus/)
})
test('test_task_025_cookie_session_config_normal_repeated_operation_is_idempotent', () => {
// 正常重复:传输模块只创建一次 axios 实例,会话模块不另建客户端、不污染状态。
assert.equal((httpSrc.match(/axios\.create/g) || []).length, 1, '共享实例只创建一次')
assert.equal((sessionSrc.match(/axios\.create/g) || []).length, 0, '会话模块不自行创建新客户端')
assert.equal((sessionSrc.match(/import \{ http \}/g) || []).length, 1)
})
test('test_task_025_cookie_session_config_boundary_empty_input', () => {
// 边界空值:无登录态时请求层不把凭证写入本地/会话存储(前端不保存 JWT/密码)。
for (const rel of ['src/api/http.ts', 'src/api/session.ts']) {
const src = readSource(rel)
assert.equal((src.match(/localStorage/g) || []).length, 0, `${rel} 不得使用 localStorage`)
assert.equal((src.match(/sessionStorage/g) || []).length, 0, `${rel} 不得使用 sessionStorage`)
assert.equal(/document\.cookie\s*=/.test(src), false, `${rel} 不得直接写 document.cookie`)
}
})
test('test_task_025_cookie_session_config_boundary_single_item', () => {
// 边界单元素:登出是单次 POST,以 AJAX 标识发到共享实例,后端据此返回 JSON 而非页面。
assert.match(sessionSrc, /X-Requested-With/, '登出走 AJAX 标识以便后端识别为 JSON 请求')
assert.match(sessionSrc, /http\.post/)
assert.match(sessionSrc, /\/logout/, '登出走 auth 模块根端点 POST /logout')
assert.equal(sessionSrc.includes('/api/admin/logout'), false, '不应指向不存在的 /api/admin/logout')
})
test('test_task_025_cookie_session_config_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:即便会话在身,传输层也不注入 token/Authorization 头——
// 凭证只由同源 Cookie 携带,前端禁止保存并在后续请求回填。
for (const rel of ['src/api/http.ts', 'src/api/session.ts', 'src/api/session-model.ts']) {
const src = readSource(rel)
assert.equal(/\bAuthorization\b/.test(src), false, `${rel} 不应注入 Authorization 头`)
assert.equal(/\bBearer\b/.test(src), false, `${rel} 不应出现 Bearer token`)
}
})
test('test_task_025_cookie_session_config_invalid_input_rejected', () => {
// 异常输入:Cookie 规则要求 withCredentials 必须开启、同源根路径、有界超时。
assert.match(httpSrc, /withCredentials:\s*true/, '传输配置必须字面量开启 withCredentials')
assert.match(httpSrc, /baseURL:\s*'\/'/, '传输配置必须使用同源根路径')
assert.match(httpSrc, /timeout:\s*\d+/, '传输配置必须声明数值型有界超时')
})
test('test_task_025_cookie_session_config_dependency_failure_returns_actionable_message', () => {
// 依赖失败:会话失效/网络异常走同一拦截与解包兜底,且登录跳转携带当前目标路径。
assert.match(httpSrc, /interceptors\.response/, '存在 401/异常统一响应拦截')
assert.match(httpSrc, /unwrap/)
assert.match(httpSrc, /isUnauthorized/)
assert.match(httpSrc, /login\?redirect=/)
const target = loginRedirectTarget({ pathname: '/admin-vue/account/users', search: '?x=1' })
assert.equal(target, encodeURIComponent('/admin-vue/account/users?x=1'), 'redirect 需携带当前目标路径')
})
+72
View File
@@ -0,0 +1,72 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
isAuthEndpointRequest,
isLoginLocation,
shouldRedirectUnauthorized,
} from '../src/api/envelope.ts'
test('test_task_026_unauthorized_redirect_normal_primary_path', () => {
// 正常主路径:普通业务页内某受保护接口 401,应跳转登录(携带目标路径)。
assert.equal(
shouldRedirectUnauthorized('/admin-vue/account/users', '/api/admin/current-user'),
true,
'业务页内受保护请求 401 应触发跳登录',
)
})
test('test_task_026_unauthorized_redirect_normal_variant_input', () => {
// 正常变体:已经在登录页(含 redirect 查询)时任何 401 不再二次踢回,避免循环。
assert.equal(shouldRedirectUnauthorized('/login', '/api/admin/current-user'), false)
assert.equal(shouldRedirectUnauthorized('/login?redirect=%2Fadmin-vue%2Faccount%2Fusers', '/api/admin/current-user'), false)
})
test('test_task_026_unauthorized_redirect_normal_repeated_operation_is_idempotent', () => {
// 正常重复:纯函数重复求值结果稳定,无副作用。
const once = shouldRedirectUnauthorized('/login', '/login')
const twice = shouldRedirectUnauthorized('/login', '/login')
assert.equal(once, false)
assert.equal(twice, once)
assert.equal(isLoginLocation('/login?redirect=/x'), isLoginLocation('/login?redirect=/x'))
})
test('test_task_026_unauthorized_redirect_boundary_empty_input', () => {
// 边界空值:当前路径为空/请求 URL 缺省时不误判为登录场景,按应跳转处理。
assert.equal(shouldRedirectUnauthorized('', undefined), true)
assert.equal(shouldRedirectUnauthorized('/admin-vue/', ''), true)
assert.equal(isLoginLocation(''), false)
assert.equal(isAuthEndpointRequest(undefined), false)
})
test('test_task_026_unauthorized_redirect_boundary_single_item', () => {
// 边界单元素:401 请求本身是登录提交时不得再跳登录(否则吞掉登录失败反馈)。
assert.equal(shouldRedirectUnauthorized('/admin-vue/account/users', '/login'), false)
assert.equal(isAuthEndpointRequest('/login'), true)
})
test('test_task_026_unauthorized_redirect_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:登录端点支持绝对 URL 与带查询串的受保护请求两种形态。
assert.equal(isAuthEndpointRequest('http://api.aishufu.top/login'), true)
assert.equal(isAuthEndpointRequest('https://aishufu.top/login?device=web'), true)
assert.equal(shouldRedirectUnauthorized('/admin-vue/', '/api/admin/current-user?x=1'), true)
assert.equal(isAuthEndpointRequest('/api/admin/current-user?x=1'), false)
})
test('test_task_026_unauthorized_redirect_invalid_input_rejected', () => {
// 异常输入:非法/非字符串输入不抛错,且默认按“应跳转”处理而非误放行。
assert.equal(shouldRedirectUnauthorized(undefined as unknown as string, undefined), true)
assert.equal(shouldRedirectUnauthorized(null as unknown as string, null as unknown as string), true)
assert.equal(isAuthEndpointRequest(42 as unknown as string), false)
assert.equal(isLoginLocation('/admin-vue/login'), false)
})
test('test_task_026_unauthorized_redirect_dependency_failure_returns_actionable_message', () => {
// 依赖失败:http 层 success/error 两支都要先过守卫再带目标路径跳 /login。
const http = readSource('src/api/http.ts')
assert.match(http, /shouldRedirectUnauthorized/, '401 跳转必须经守卫避免登录页循环')
assert.match(http, /login\?redirect=/, '跳转仍携带目标路径参数')
assert.match(http, /interceptors\.response/)
assert.match(http, /response\.config\?\.url/, '成功分支以失败请求 URL 判定登录请求')
assert.match(http, /error\?\.config\?\.url|error\.config\.url/, '异常分支同样传入请求 URL')
})
+64
View File
@@ -0,0 +1,64 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
const store = readSource('src/stores/admin-session.ts')
test('test_task_027_store_initial_state_normal_primary_path', () => {
// 正常主路径:state 以函数返回全新对象,含 5 个契约字段。
assert.match(store, /state:\s*\(\)\s*=>\s*\(\{/, 'state 必须是返回对象字面量的工厂函数')
assert.match(store, /user:\s*null/)
assert.match(store, /menuTree:\s*\[\]/)
assert.match(store, /initialized:\s*false/)
assert.match(store, /loading:\s*false/)
assert.match(store, /error:\s*''/)
})
test('test_task_027_store_initial_state_normal_variant_input', () => {
// 正常变体:状态字段与模块契约字段一一对应,供 AdminLayout / guard 消费。
assert.match(store, /user\b/)
assert.match(store, /menuTree\b/)
assert.match(store, /initialized\b/)
assert.match(store, /loading\b/)
assert.match(store, /error\b/)
})
test('test_task_027_store_initial_state_normal_repeated_operation_is_idempotent', () => {
// 正常重复:只声明一个 Pinia store 定义,实例由 useStore 工厂创建,不共享可变单例。
assert.equal((store.match(/defineStore\(/g) || []).length, 1, '仅定义一个 admin-session store')
assert.match(store, /export const useAdminSessionStore\s*=\s*defineStore/)
})
test('test_task_027_store_initial_state_boundary_empty_input', () => {
// 边界空值:未登录时 user 为 null、error 为空串,而不是 undefined 残留。
assert.match(store, /user:\s*null\s+as\s+AdminUser/)
assert.match(store, /error:\s*''/)
})
test('test_task_027_store_initial_state_boundary_single_item', () => {
// 边界单元素:初始时无任何用户/菜单,首次进入路由需触发初始化。
assert.match(store, /initialized:\s*false/, '未初始化才能触发首次初始化')
const router = readSource('src/router/index.ts')
assert.match(router, /if\s*\(!session\.initialized\)/, '守卫在未初始化时调用 initialize')
})
test('test_task_027_store_initial_state_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:初始状态不携带任何凭证字段,凭证只走同源 Cookie。
assert.equal(/\btoken\b|\bjwt\b|\bpassword\b/.test(store), false, 'store 初始状态不得保存凭证')
})
test('test_task_027_store_initial_state_invalid_input_rejected', () => {
// 异常输入:非法/未知状态字段不应出现(state 形状稳定)。
assert.equal(/\bnickname\b|\bavatar\b/.test(store), false, 'store 不引入契约外字段')
assert.match(store, /import type \{ AdminMenuNode, AdminUser \}/)
})
test('test_task_027_store_initial_state_dependency_failure_returns_actionable_message', () => {
// 依赖失败:store 依赖会话 API 与 pinia,状态字段供 getter/action 消费。
assert.match(store, /import \{ defineStore \} from 'pinia'/)
assert.match(store, /fetchCurrentUser/)
assert.match(store, /fetchAdminMenuTree/)
assert.match(store, /getters:/)
assert.match(store, /firstVisible:/)
assert.match(store, /isSuperAdmin:/)
})
+55
View File
@@ -0,0 +1,55 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { parseCurrentUser } from '../src/api/session-model.ts'
const store = readSource('src/stores/admin-session.ts')
test('test_task_028_current_user_init_normal_primary_path', () => {
// 正常主路径:初始化第一步拉取当前用户并写入 store.user。
assert.match(store, /this\.user\s*=\s*await fetchCurrentUser\(\)/)
})
test('test_task_028_current_user_init_normal_variant_input', () => {
// 正常变体:先取用户、再取菜单,顺序不可颠倒(菜单依赖登录身份)。
assert.ok(store.indexOf('fetchCurrentUser()') < store.indexOf('fetchAdminMenuTree()'), '当前用户应先于菜单拉取')
})
test('test_task_028_current_user_init_normal_repeated_operation_is_idempotent', () => {
// 正常重复:已初始化/加载中不再重复发起当前用户请求。
assert.match(store, /if\s*\(this\.initialized\s*\|\|\s*this\.loading\)\s*return/)
const userCalls = (store.match(/fetchCurrentUser\(\)/g) || []).length
assert.ok(userCalls <= 2, '用户拉取只出现在 store 内声明与调用处')
})
test('test_task_028_current_user_init_boundary_empty_input', () => {
// 边界空值:解析器在空/非对象负载下抛可操作错误,而非返回残缺用户。
assert.throws(() => parseCurrentUser(null), /缺少有效 id|请求失败/)
})
test('test_task_028_current_user_init_boundary_single_item', () => {
// 边界单元素:单个 super_admin 用户被正确解析写入。
const user = parseCurrentUser({ success: true, data: { item: { id: 7, username: 'root', role: 'super_admin' } } })
assert.equal(user.id, 7)
assert.equal(user.username, 'root')
})
test('test_task_028_current_user_init_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:成功但字段缺失时不崩溃;初始化失败会向上抛由守卫处理。
const user = parseCurrentUser({ data: { item: { id: 2, username: '', role: '' } } })
assert.equal(user.username, '')
})
test('test_task_028_current_user_init_invalid_input_rejected', () => {
// 异常输入:后端 401/失败信封被拒绝并带 message。
assert.throws(() => parseCurrentUser({ success: false, code: 401, message: '未登录' }), /未登录/)
assert.throws(() => parseCurrentUser({ data: { item: { username: 'no-id' } } }), /缺少有效 id/)
})
test('test_task_028_current_user_init_dependency_failure_returns_actionable_message', () => {
// 依赖失败:store 复用会话适配器 fetchCurrentUser(内部走 parseCurrentUser + http)。
assert.match(store, /import \{ fetchAdminMenuTree, fetchCurrentUser, logout \} from '@\/api\/session'/)
const session = readSource('src/api/session.ts')
assert.match(session, /fetchCurrentUser/)
assert.match(session, /\/api\/admin\/current-user/)
})
+54
View File
@@ -0,0 +1,54 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { parseMenuTree } from '../src/api/session-model.ts'
const store = readSource('src/stores/admin-session.ts')
test('test_task_029_menu_tree_init_normal_primary_path', () => {
// 正常主路径:用户拉取成功后拉取菜单树并写入 store.menuTree。
assert.match(store, /this\.menuTree\s*=\s*await fetchAdminMenuTree\(\)/)
})
test('test_task_029_menu_tree_init_normal_variant_input', () => {
// 正常变体:两组数据都成功后置 initialized,才算初始化完成。
assert.match(store, /this\.initialized\s*=\s*true/)
})
test('test_task_029_menu_tree_init_normal_repeated_operation_is_idempotent', () => {
// 正常重复:菜单拉取在 store 只声明一次;成功置位后再进入即短路。
assert.ok((store.match(/fetchAdminMenuTree\(\)/g) || []).length >= 1)
assert.match(store, /if\s*\(this\.initialized\s*\|\|\s*this\.loading\)\s*return/)
})
test('test_task_029_menu_tree_init_boundary_empty_input', () => {
// 边界空值:空菜单树(无权限)也是合法初始化结果,与接口失败区分。
assert.deepEqual(parseMenuTree({ success: true, data: { items: [] } }), [])
})
test('test_task_029_menu_tree_init_boundary_single_item', () => {
// 边界单元素:单个分组节点正常写入,供侧边栏渲染。
const tree = parseMenuTree({ data: { items: [{ key: 'g', name: '分组' }] } })
assert.equal(tree.length, 1)
assert.equal(tree[0].key, 'g')
})
test('test_task_029_menu_tree_init_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:菜单树含 icon/sort 等附加字段时不被丢弃。
const tree = parseMenuTree({ data: { items: [{ key: 'p', name: '页', route: '/p', sort: 2, icon: 'grid' }] } })
assert.equal(tree[0].sort, 2)
assert.equal(tree[0].icon, 'grid')
})
test('test_task_029_menu_tree_init_invalid_input_rejected', () => {
// 异常输入:success=false 视为接口失败抛错,不落成“无权限空树”。
assert.throws(() => parseMenuTree({ success: false, message: '菜单拉取失败' }), /菜单拉取失败/)
})
test('test_task_029_menu_tree_init_dependency_failure_returns_actionable_message', () => {
// 依赖失败:store 菜单初始化复用 fetchAdminMenuTree;会话适配器指向菜单端点。
assert.match(store, /fetchAdminMenuTree/)
const session = readSource('src/api/session.ts')
assert.match(session, /\/api\/admin\/current-user\/menus/)
assert.match(session, /parseMenuTree/)
})
+67
View File
@@ -0,0 +1,67 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource, occurrences, missingImports } from './helpers.ts'
const LAYOUT = 'src/layout/AdminLayout.vue'
const ROUTER = 'src/router/index.ts'
test('test_task_003_layout_contract_normal_primary_path', () => {
// 正常主路径:壳层作为页面容器,唯一地把业务视图挂到 RouterView。
const layout = readSource(LAYOUT)
assert.equal(occurrences(layout, '<RouterView'), 1, '页面容器只能挂载一个 RouterView')
assert.ok(occurrences(layout, 'admin-content') >= 1, '需有内容区挂载点')
})
test('test_task_003_layout_contract_normal_variant_input', () => {
// 正常变体:页面接线归路由注册表所有;壳层不得静态 import 业务页面。
const layout = readSource(LAYOUT)
const registry = readSource('src/router/routes.ts')
assert.equal(occurrences(layout, '@/pages/'), 0, 'AdminLayout 不得静态 import 业务页面')
assert.ok(registry.includes('() => import('), '注册表使用异步组件加载页面')
})
test('test_task_003_layout_contract_normal_repeated_operation_is_idempotent', () => {
// 正常重复:只读复查结果稳定,不依赖可变状态。
const layoutA = readSource(LAYOUT)
const layoutB = readSource(LAYOUT)
assert.equal(layoutA.length, layoutB.length)
assert.equal(occurrences(layoutA, 'RouterView'), occurrences(layoutB, 'RouterView'))
})
test('test_task_003_layout_contract_boundary_empty_input', () => {
// 边界空值:菜单为空时应展示无菜单状态,且页面容器本身仍保留。
const layout = readSource(LAYOUT)
assert.ok(layout.includes('el-empty'), '无菜单需有空状态占位')
assert.ok(layout.includes('emptyMenu'), '空菜单由空态判定驱动')
assert.equal(occurrences(layout, '<RouterView'), 1)
})
test('test_task_003_layout_contract_boundary_single_item', () => {
// 边界单元素:单一内容区与单一页面挂载点。
const layout = readSource(LAYOUT)
assert.equal(occurrences(layout, 'admin-main'), 1)
assert.equal(occurrences(layout, '<aside'), 1, '侧边栏唯一')
assert.equal(occurrences(layout, '<header'), 1, '顶栏唯一')
})
test('test_task_003_layout_contract_boundary_limit_or_missing_field', () => {
// 边界上限:Element Plus 交互能力按需命名导入,不整包拖入壳层。
const layout = readSource(LAYOUT)
assert.match(layout, /import\s*\{\s*ElMessage(?:,\s*\w+)*\s*\}\s*from\s*['"]element-plus['"]/)
assert.equal(occurrences(layout, 'import ElementPlus'), 0, '壳层不得整包导入 ElementPlus')
})
test('test_task_003_layout_contract_invalid_input_rejected', () => {
// 异常输入:壳层不得自行发起后台数据请求,也不得引用 @/api。
const layout = readSource(LAYOUT)
assert.equal(occurrences(layout, '@/api/'), 0, 'AdminLayout 不得直接调用后台 API')
assert.equal(occurrences(layout, 'http.get'), 0)
})
test('test_task_003_layout_contract_dependency_failure_returns_actionable_message', () => {
// 依赖失败:壳层自身依赖必须全部可解析,缺失时返回可操作清单。
const missing = missingImports(LAYOUT)
assert.deepEqual(missing, [], `存在无法解析的 import: ${missing.join('; ')}`)
const routerMissing = missingImports(ROUTER)
assert.deepEqual(routerMissing, [], `路由存在无法解析的 import: ${routerMissing.join('; ')}`)
})
+53
View File
@@ -0,0 +1,53 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
const store = readSource('src/stores/admin-session.ts')
test('test_task_030_init_failure_retry_normal_primary_path', () => {
// 正常主路径:初始化失败写入 error 并向上抛出(守卫据此停在该页/跳转)。
assert.match(store, /catch\s*\(error\)/)
assert.match(store, /this\.error\s*=/)
assert.match(store, /throw error/)
})
test('test_task_030_init_failure_retry_normal_variant_input', () => {
// 正常变体:异常为普通 Error 时取其 message;否则给可读兜底文案。
assert.match(store, /instanceof Error/)
assert.match(store, /后台初始化失败/)
})
test('test_task_030_init_failure_retry_normal_repeated_operation_is_idempotent', () => {
// 正常重复:失败后 initialized 仍为 false,下一次调用可重试。
assert.match(store, /if\s*\(this\.initialized\s*\|\|\s*this\.loading\)\s*return/, '重试入口短路守卫')
})
test('test_task_030_init_failure_retry_boundary_empty_input', () => {
// 边界空值:错误文案缺省时有兜底,不让空串直接进入 error 态。
assert.match(store, /后台初始化失败/)
})
test('test_task_030_init_failure_retry_boundary_single_item', () => {
// 边界单元素:单次失败只写一次 error;loading 在 finally 复位。
assert.match(store, /finally\s*\{/)
assert.match(store, /this\.loading\s*=\s*false/)
})
test('test_task_030_init_failure_retry_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:同时防止并发/重复触发(loading/initialized 双闸)。
assert.match(store, /this\.loading\s*=\s*true/)
assert.match(store, /this\.error\s*=\s*''/)
assert.match(store, /if\s*\(this\.initialized\s*\|\|\s*this\.loading\)\s*return/)
})
test('test_task_030_init_failure_retry_invalid_input_rejected', () => {
// 异常输入:接口失败时不落成“无菜单空态”,错误必须可抛可读。
assert.equal(/shouldShowEmptyMenu/.test(store), false, 'store 不把接口失败当无菜单')
})
test('test_task_030_init_failure_retry_dependency_failure_returns_actionable_message', () => {
// 依赖失败:守卫捕获 initialize 异常时不让应用白屏(返回拦截)。
const router = readSource('src/router/index.ts')
assert.match(router, /await session\.initialize\(\)/)
assert.match(router, /catch\s*\{/)
})
+57
View File
@@ -0,0 +1,57 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { isSuperAdminRole, isSuperUser } from '../src/types/admin.ts'
test('test_task_031_super_admin_judge_normal_primary_path', () => {
// 正常主路径:super_admin 角色判定为超级管理员,可进全部菜单。
assert.equal(isSuperAdminRole('super_admin'), true)
assert.equal(isSuperUser({ role: 'super_admin' }), true)
})
test('test_task_031_super_admin_judge_normal_variant_input', () => {
// 正常变体:admin/normal 不是超级管理员。
assert.equal(isSuperAdminRole('admin'), false)
assert.equal(isSuperAdminRole('normal'), false)
})
test('test_task_031_super_admin_judge_normal_repeated_operation_is_idempotent', () => {
// 正常重复:大小写/空白差异归一后判定稳定。
assert.equal(isSuperAdminRole('SUPER_ADMIN'), isSuperAdminRole('super_admin'))
assert.equal(isSuperAdminRole(' Super_Admin '), true)
})
test('test_task_031_super_admin_judge_boundary_empty_input', () => {
// 边界空值:空/null 角色不判为超级管理员,也不抛错。
assert.equal(isSuperAdminRole(''), false)
assert.equal(isSuperAdminRole(undefined), false)
assert.equal(isSuperAdminRole(null), false)
})
test('test_task_031_super_admin_judge_boundary_single_item', () => {
// 边界单元素:单个 super_admin 用户被 store getter 识别。
const store = readSource('src/stores/admin-session.ts')
assert.match(store, /isSuperAdmin\s*:/, 'store 提供 isSuperAdmin getter')
assert.match(store, /isSuperAdminRole/, 'getter 复用角色归一判定')
})
test('test_task_031_super_admin_judge_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:未知角色串不误判超级管理员。
assert.equal(isSuperAdminRole('owner'), false)
assert.equal(isSuperAdminRole('xxx'), false)
})
test('test_task_031_super_admin_judge_invalid_input_rejected', () => {
// 异常输入:store getter 不应再用未归一化的原始等值比较。
const store = readSource('src/stores/admin-session.ts')
assert.equal(store.includes("role === 'super_admin'"), false, '不允许裸等值判定,需走角色归一')
})
test('test_task_031_super_admin_judge_dependency_failure_returns_actionable_message', () => {
// 依赖失败:类型契约模块提供角色判定,供 store 与守卫复用。
const source = readSource('src/stores/admin-session.ts')
assert.match(source, /isSuperAdminRole/)
const adminTypes = readSource('src/types/admin.ts')
assert.match(adminTypes, /isSuperAdminRole/)
assert.match(adminTypes, /roleKind\(/)
})
+60
View File
@@ -0,0 +1,60 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { hasMenuKey } from '../src/router/helpers.ts'
test('test_task_032_has_menu_key_lookup_normal_primary_path', () => {
// 正常主路径:树内顶层菜单 key 可被命中。
const tree = [{ key: 'admin_users', name: '用户管理', route: '/account/users' }]
assert.equal(hasMenuKey(tree, 'admin_users'), true)
})
test('test_task_032_has_menu_key_lookup_normal_variant_input', () => {
// 正常变体:叶子在分组深层时也能命中;未授权 key 不命中。
const tree = [{ key: 'g', name: '组', children: [{ key: 'leaf', name: '叶', route: '/leaf' }] }]
assert.equal(hasMenuKey(tree, 'leaf'), true)
assert.equal(hasMenuKey(tree, 'missing'), false)
})
test('test_task_032_has_menu_key_lookup_normal_repeated_operation_is_idempotent', () => {
// 正常重复:查找不修改树、结果稳定。
const tree = [{ key: 'a', name: 'A', children: [{ key: 'b', name: 'B', route: '/b' }] }]
const snapshot = JSON.stringify(tree)
assert.equal(hasMenuKey(tree, 'b'), hasMenuKey(tree, 'b'))
assert.deepEqual(JSON.stringify(tree), snapshot)
})
test('test_task_032_has_menu_key_lookup_boundary_empty_input', () => {
// 边界空值:空/缺省树查找返回 false,不抛错。
assert.equal(hasMenuKey([], 'x'), false)
assert.equal(hasMenuKey(null as unknown as { key: string; name: string }[], 'x'), false)
assert.equal(hasMenuKey(undefined as unknown as { key: string; name: string }[], 'x'), false)
})
test('test_task_032_has_menu_key_lookup_boundary_single_item', () => {
// 边界单元素:单节点树命中与未命中。
const tree = [{ key: 'solo', name: '单页', route: '/solo' }]
assert.equal(hasMenuKey(tree, 'solo'), true)
assert.equal(hasMenuKey(tree, 'nope'), false)
})
test('test_task_032_has_menu_key_lookup_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:缺 children 的节点不崩溃;深树正确递归。
const tree = [{ key: 'a', name: 'A' }, { key: 'b', name: 'B', children: [{ key: 'c', name: 'C', route: '/c' }] }]
assert.equal(hasMenuKey(tree, 'c'), true)
})
test('test_task_032_has_menu_key_lookup_invalid_input_rejected', () => {
// 异常输入:空 key 查找返回 false,绝不误放行。
assert.equal(hasMenuKey([{ key: '', name: '无key' }], ''), false)
assert.equal(hasMenuKey([], ''), false)
})
test('test_task_032_has_menu_key_lookup_dependency_failure_returns_actionable_message', () => {
// 依赖失败:key 查找收敛到 helpers,路由守卫经共享权限判定复用,不留私有副本。
const helpers = readSource('src/router/helpers.ts')
assert.match(helpers, /export function hasMenuKey/)
const router = readSource('src/router/index.ts')
assert.equal(router.includes('function hasMenu'), false, '不再保留模块内私有 hasMenu')
assert.match(router, /isRouteAllowed/, '守卫委托共享判定(内含 key 查找)')
})
+58
View File
@@ -0,0 +1,58 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { isRouteAllowed } from '../src/router/helpers.ts'
test('test_task_033_route_permission_guard_normal_primary_path', () => {
// 正常主路径:页面带 menuKey 且普通用户拥有该菜单 key 时放行。
const tree = [{ key: 'admin_users', name: '用户管理', route: '/account/users' }]
assert.equal(isRouteAllowed(false, 'admin_users', tree), true)
})
test('test_task_033_route_permission_guard_normal_variant_input', () => {
// 正常变体:超级管理员即便不带该 key 也放行;无 menuKey 页面不受限。
assert.equal(isRouteAllowed(true, 'whatever', []), true)
assert.equal(isRouteAllowed(false, undefined, []), true)
})
test('test_task_033_route_permission_guard_normal_repeated_operation_is_idempotent', () => {
// 正常重复:判定纯函数,输入不变结果稳定。
const tree = [{ key: 'g', name: '组', children: [{ key: 'users', name: '用户', route: '/users' }] }]
assert.equal(isRouteAllowed(false, 'users', tree), isRouteAllowed(false, 'users', tree))
})
test('test_task_033_route_permission_guard_boundary_empty_input', () => {
// 边界空值:空菜单树对普通用户视为无权限(除无 menuKey 页面外)。
assert.equal(isRouteAllowed(false, 'admin_users', []), false)
assert.equal(isRouteAllowed(false, undefined, []), true)
})
test('test_task_033_route_permission_guard_boundary_single_item', () => {
// 边界单元素:只有单个可路由页面时的命中与未命中。
const tree = [{ key: 'solo', name: '单页', route: '/solo' }]
assert.equal(isRouteAllowed(false, 'solo', tree), true)
assert.equal(isRouteAllowed(false, 'other', tree), false)
})
test('test_task_033_route_permission_guard_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:深层叶子菜单 key 也能命中。
const tree = [{ key: 'g', name: '组', children: [{ key: 'inner', name: '内', route: '/inner' }] }]
assert.equal(isRouteAllowed(false, 'inner', tree), true)
})
test('test_task_033_route_permission_guard_invalid_input_rejected', () => {
// 异常输入:null/空 key 视为无菜单门槛页面一律放行(不误拦开放页)。
assert.equal(isRouteAllowed(false, null as unknown as string, []), true)
assert.equal(isRouteAllowed(false, '', []), true)
assert.equal(isRouteAllowed(false, 'x', []), false)
})
test('test_task_033_route_permission_guard_dependency_failure_returns_actionable_message', () => {
// 依赖失败:守卫把越权路由回退给首个可见页/根路由,复用统一判定。
const router = readSource('src/router/index.ts')
assert.match(router, /isRouteAllowed/, '路由守卫使用共享权限判定')
assert.match(router, /firstVisible/, '越权回退首个可见页')
const helpers = readSource('src/router/helpers.ts')
assert.match(helpers, /export function isRouteAllowed/)
assert.match(helpers, /hasMenuKey/)
})
+55
View File
@@ -0,0 +1,55 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { firstVisiblePath } from '../src/router/helpers.ts'
test('test_task_034_unauthorized_fallback_normal_primary_path', () => {
// 正常主路径:越权页面回退到菜单树首个可见页面。
const tree = [{ key: 'g', name: '组', children: [{ key: 'users', name: '用户管理', route: '/account/users' }] }]
assert.equal(firstVisiblePath(tree), '/account/users')
})
test('test_task_034_unauthorized_fallback_normal_variant_input', () => {
// 正常变体:多个可路由页面时取深度优先的首个。
const tree = [
{ key: 'a', name: 'A', route: '/a', sort: 9 },
{ key: 'b', name: 'B', route: '/b', sort: 1 },
]
assert.equal(firstVisiblePath(tree), '/a', '前端保序,不按 sort 重排')
})
test('test_task_034_unauthorized_fallback_normal_repeated_operation_is_idempotent', () => {
// 正常重复:查找不修改树、结果稳定。
const tree = [{ key: 'g', name: '组', children: [{ key: 'p', name: '页', route: '/p' }] }]
assert.equal(firstVisiblePath(tree), firstVisiblePath(tree))
})
test('test_task_034_unauthorized_fallback_boundary_empty_input', () => {
// 边界空值:无任何可见页面时回退空串,由守卫回根路由空态。
assert.equal(firstVisiblePath([]), '')
assert.equal(firstVisiblePath(null), '')
})
test('test_task_034_unauthorized_fallback_boundary_single_item', () => {
// 边界单元素:单个页面即回退目标。
assert.equal(firstVisiblePath([{ key: 's', name: '单', route: '/solo' }]), '/solo')
})
test('test_task_034_unauthorized_fallback_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:深层叶页面也被当作回退目标。
const tree = [{ key: 'g', name: '组', children: [{ key: 'g2', name: '子组', children: [{ key: 'deep', name: '深', route: '/deep' }] }] }]
assert.equal(firstVisiblePath(tree), '/deep')
})
test('test_task_034_unauthorized_fallback_invalid_input_rejected', () => {
// 异常输入:畸形节点(无 route 无 children)被跳过,不影响回退目标。
const tree = [{ key: 'bad', name: '坏' }, { key: 'ok', name: '好', route: '/ok' }]
assert.equal(firstVisiblePath(tree), '/ok')
})
test('test_task_034_unauthorized_fallback_dependency_failure_returns_actionable_message', () => {
// 依赖失败:路由守卫对越权页以首个可见页/根路由作为回退目标。
const router = readSource('src/router/index.ts')
assert.match(router, /session\.firstVisible\s*\|\|\s*'\/'/, '越权页回退首个可见页,全无则根路由')
assert.match(router, /isRouteAllowed/)
})
+51
View File
@@ -0,0 +1,51 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
EMPTY_MENU_DESCRIPTION,
EMPTY_MENU_TITLE,
shouldShowEmptyMenu,
} from '../src/layout/empty-state.ts'
test('test_task_035_no_menu_user_state_normal_primary_path', () => {
// 正常主路径:会话完成、无菜单且非加载时展示无菜单空态。
assert.equal(shouldShowEmptyMenu(false, false, true), true)
})
test('test_task_035_no_menu_user_state_normal_variant_input', () => {
// 正常变体:有菜单时即使初始化完成也不展示空态。
assert.equal(shouldShowEmptyMenu(true, false, true), false)
})
test('test_task_035_no_menu_user_state_normal_repeated_operation_is_idempotent', () => {
// 正常重复:纯函数结果稳定、无副作用。
assert.equal(shouldShowEmptyMenu(false, false, true), shouldShowEmptyMenu(false, false, true))
})
test('test_task_035_no_menu_user_state_boundary_empty_input', () => {
// 边界空值:未初始化 / 空态参数缺失时不误闪空态。
assert.equal(shouldShowEmptyMenu(false, false, false), false, '未初始化完成不展示空态')
})
test('test_task_035_no_menu_user_state_boundary_single_item', () => {
// 边界单元素:加载中即便无菜单也不闪空态(防闪烁)。
assert.equal(shouldShowEmptyMenu(false, true, true), false, '加载中不闪空态')
})
test('test_task_035_no_menu_user_state_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:初始状态(空菜单、未初始化、未加载)同样不展示。
assert.equal(shouldShowEmptyMenu(false, false, false), false)
})
test('test_task_035_no_menu_user_state_invalid_input_rejected', () => {
// 异常输入:参数类型异常时仍安全返回布尔,不抛错。
assert.equal(shouldShowEmptyMenu(0 as unknown as boolean, 0 as unknown as boolean, 1 as unknown as boolean), true)
})
test('test_task_035_no_menu_user_state_dependency_failure_returns_actionable_message', () => {
// 依赖失败:初始化失败不落成无菜单空态(由错误条提示);文案指向联系管理员。
assert.equal(EMPTY_MENU_TITLE, '暂无可用菜单')
assert.match(EMPTY_MENU_DESCRIPTION, /管理员/)
const store = readSource('src/stores/admin-session.ts')
assert.match(store, /error:/, 'store 保存失败错误而非置空菜单')
})
+66
View File
@@ -0,0 +1,66 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { runLogout } from '../src/layout/logout.ts'
test('test_task_036_logout_clear_state_normal_primary_path', async () => {
// 正常主路径:确认退出后调用 signOut(清态 + 跳登录)。
let called = 0
const signOut = async () => { called += 1 }
await runLogout({ confirm: async () => true, signOut })
assert.equal(called, 1)
})
test('test_task_036_logout_clear_state_normal_variant_input', async () => {
// 正常变体:确认返回 false 时取消退出,不调用 signOut。
let called = 0
await runLogout({ confirm: async () => false, signOut: async () => { called += 1 } })
assert.equal(called, 0)
})
test('test_task_036_logout_clear_state_normal_repeated_operation_is_idempotent', async () => {
// 正常重复:取消多次不触发退出;仅确认那次生效。
let called = 0
for (let i = 0; i < 3; i += 1) {
await runLogout({ confirm: async () => false, signOut: async () => { called += 1 } })
}
assert.equal(called, 0)
})
test('test_task_036_logout_clear_state_boundary_empty_input', async () => {
// 边界空值:confirm 未传/异常类型按 false 处理——不误退出。
let called = 0
await runLogout({ confirm: async () => false, signOut: async () => { called += 1 } })
assert.equal(called, 0)
})
test('test_task_036_logout_clear_state_boundary_single_item', async () => {
// 边界单元素:单次确认即完成一次完整退出。
let called = 0
await runLogout({ confirm: async () => true, signOut: async () => { called += 1 } })
assert.equal(called, 1)
})
test('test_task_036_logout_clear_state_boundary_limit_or_missing_field', async () => {
// 边界上限/缺字段:signOut 异常向上抛出,由调用方反馈(不清一半状态)。
await assert.rejects(
runLogout({ confirm: async () => true, signOut: async () => { throw new Error('登出失败') } }),
/登出失败/,
)
})
test('test_task_036_logout_clear_state_invalid_input_rejected', async () => {
// 异常输入:confirm 本身 reject 也向上抛,不静默吞掉。
await assert.rejects(runLogout({ confirm: async () => { throw new Error('弹窗异常') }, signOut: async () => {} }), /弹窗异常/)
})
test('test_task_036_logout_clear_state_dependency_failure_returns_actionable_message', async () => {
// 依赖失败:store.signOut 清态($reset)并跳登录页,会话模块先走后端 logout。
const store = readSource('src/stores/admin-session.ts')
assert.match(store, /async signOut\(\)/)
assert.match(store, /\$reset\(\)/)
assert.match(store, /location\.assign\('\/login'\)/)
const session = readSource('src/api/session.ts')
assert.match(session, /\/logout/, '登出走 auth 模块根端点 POST /logout')
assert.equal(session.includes('/api/admin/logout'), false, '不应指向不存在的 /api/admin/logout')
})
+54
View File
@@ -0,0 +1,54 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { parseMenuTree } from '../src/api/session-model.ts'
import { toSidebarEntries } from '../src/layout/menu-mapper.ts'
test('test_task_037_menu_parent_child_normal_primary_path', () => {
// 正常主路径:分组下的子页面作为 children 嵌套保留。
const tree = parseMenuTree({ data: { items: [{ key: 'g', name: '组', children: [{ key: 'p', name: '页', route: '/p' }] }] } })
assert.equal(tree[0].children?.[0].key, 'p')
})
test('test_task_037_menu_parent_child_normal_variant_input', () => {
// 正常变体:多层父子关系逐层保留(组 > 子组 > 页面)。
const tree = parseMenuTree({ items: [{ key: 'a', name: 'A', children: [{ key: 'b', name: 'B', children: [{ key: 'c', name: 'C', route: '/c' }] }] }] })
assert.equal(tree[0].children?.[0].children?.[0].route, '/c')
})
test('test_task_037_menu_parent_child_normal_repeated_operation_is_idempotent', () => {
// 正常重复:解析不重建/不污染父子引用结构之外的对象,结果稳定。
const payload = { data: { items: [{ key: 'g', name: '组', children: [{ key: 'p', name: '页', route: '/p' }] }] } }
assert.deepEqual(parseMenuTree(payload), parseMenuTree(payload))
})
test('test_task_037_menu_parent_child_boundary_empty_input', () => {
// 边界空值:分组无子节点合法(可后续再挂载)。
const tree = parseMenuTree({ items: [{ key: 'g', name: '组' }] })
assert.equal(tree[0].children, undefined)
})
test('test_task_037_menu_parent_child_boundary_single_item', () => {
// 边界单元素:单个页面节点可直接成为顶级项。
const tree = parseMenuTree({ items: [{ key: 's', name: '单页', route: '/solo' }] })
assert.equal(tree.length, 1)
assert.equal(tree[0].route, '/solo')
})
test('test_task_037_menu_parent_child_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:children 为非数组/空时不崩溃。
const tree = parseMenuTree({ items: [{ key: 'g', name: '组', children: null as unknown as undefined }] })
assert.equal(tree[0].children, null)
})
test('test_task_037_menu_parent_child_invalid_input_rejected', () => {
// 异常输入:整棵非树负载(success=false)抛错,不产生半棵树。
assert.throws(() => parseMenuTree({ success: false, message: '无权限' }), /无权限/)
})
test('test_task_037_menu_parent_child_dependency_failure_returns_actionable_message', () => {
// 依赖失败:渲染层把父子关系映射为分组/子项,校验不丢层级。
const entries = toSidebarEntries([{ key: 'g', name: '组', children: [{ key: 'p', name: '页', route: '/p' }] }])
assert.equal(entries.length, 1)
assert.equal(entries[0].kind, 'group')
assert.equal(entries[0].kind === 'group' && entries[0].children[0].route, '/p')
})
+67
View File
@@ -0,0 +1,67 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { parseMenuTree } from '../src/api/session-model.ts'
import { toSidebarEntries } from '../src/layout/menu-mapper.ts'
test('test_task_038_menu_sort_and_empty_route_normal_primary_path', () => {
// 正常主路径:前端保后端顺序,不按 sort 二次重排。
const payload = { data: { items: [
{ key: 'b', name: '乙', route: '/b', sort: 1 },
{ key: 'a', name: '甲', route: '/a', sort: 0 },
] } }
const tree = parseMenuTree(payload)
assert.equal(tree[0].key, 'b', '先出现者排前,不按 sort 值重排')
})
test('test_task_038_menu_sort_and_empty_route_normal_variant_input', () => {
// 正常变体:分组(无 route) 下带 route 的子页正常进分组。
const tree = parseMenuTree({ items: [{ key: 'g', name: '组', route: undefined, children: [{ key: 'p', name: '页', route: '/p' }] }] })
const entries = toSidebarEntries(tree)
assert.equal(entries[0].kind, 'group')
})
test('test_task_038_menu_sort_and_empty_route_normal_repeated_operation_is_idempotent', () => {
// 正常重复:排序稳定、解析不修改输入。
const payload = { items: [{ key: 'a', name: 'A', route: '/a', sort: 2 }] }
assert.deepEqual(parseMenuTree(payload), parseMenuTree(payload))
assert.equal((payload.items as Array<{ sort: number }>)[0].sort, 2)
})
test('test_task_038_menu_sort_and_empty_route_boundary_empty_input', () => {
// 边界空值:无路由的子节点被侧边栏过滤(点不进去不展示)。
const entries = toSidebarEntries([{ key: 'g', name: '组', children: [{ key: 'p', name: '页' }] }])
assert.equal(entries.length, 0, '组内无任何可路由子项则整组不展示')
})
test('test_task_038_menu_sort_and_empty_route_boundary_single_item', () => {
// 边界单元素:顶级无子但有 route 的叶节点作为单页项展示。
const entries = toSidebarEntries([{ key: 's', name: '单页', route: '/solo' }])
assert.equal(entries.length, 1)
assert.equal(entries[0].kind, 'item')
})
test('test_task_038_menu_sort_and_empty_route_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:既有可路由子项又有不可路由子项时只保留可路由子项。
const entries = toSidebarEntries([{ key: 'g', name: '组', children: [
{ key: 'ok', name: '可进', route: '/ok' },
{ key: 'bad', name: '占位' },
] }])
assert.equal(entries[0].kind, 'group')
if (entries[0].kind === 'group') assert.equal(entries[0].children.length, 1)
})
test('test_task_038_menu_sort_and_empty_route_invalid_input_rejected', () => {
// 异常输入:整树失败信封抛错而非空树;空路由不是合法的页面进入理由。
assert.throws(() => parseMenuTree({ success: false, message: '菜单失败' }), /菜单失败/)
const tree = parseMenuTree({ items: [{ key: 'p', name: '页' }] })
assert.equal(toSidebarEntries(tree).length, 0, '无 route 的顶级节点不进侧边栏')
})
test('test_task_038_menu_sort_and_empty_route_dependency_failure_returns_actionable_message', () => {
// 依赖失败:store/路由保存菜单后不二次排序(按后端下发顺序渲染)。
const store = readSource('src/stores/admin-session.ts')
assert.equal(/\bsort\(\)/.test(store), false, 'store 不对菜单树调用 sort()')
const helpers = readSource('src/router/helpers.ts')
assert.equal(/\bsort\(\)/.test(helpers), false, 'helpers 不对菜单树调用 sort()')
})
+57
View File
@@ -0,0 +1,57 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { parseMenuTree } from '../src/api/session-model.ts'
test('test_task_039_backend_tree_compat_normal_primary_path', () => {
// 正常主路径:data.items 信封。
const tree = parseMenuTree({ success: true, data: { items: [{ key: 'a', name: 'A', route: '/a' }] } })
assert.equal(tree[0].route, '/a')
})
test('test_task_039_backend_tree_compat_normal_variant_input', () => {
// 正常变体:data:{items}/无 data 的 {items}/裸数组三种信封均可解。
assert.equal(parseMenuTree({ data: { items: [{ key: 'x', name: 'X' }] } }).length, 1)
assert.equal(parseMenuTree({ success: true, items: [{ key: 'y', name: 'Y', route: '/y' }] }).length, 1)
assert.equal(parseMenuTree([{ key: 'z', name: 'Z' }]).length, 1)
})
test('test_task_039_backend_tree_compat_normal_repeated_operation_is_idempotent', () => {
// 正常重复:同一负载解析结果稳定且不改输入。
const payload = { data: { items: [{ key: 'a', name: 'A', children: [{ key: 'b', name: 'B', route: '/b' }] }] } }
assert.deepEqual(parseMenuTree(payload), parseMenuTree(payload))
})
test('test_task_039_backend_tree_compat_boundary_empty_input', () => {
// 边界空值:空 items/空 data/空数组/非对象均按空树处理(区别于接口失败)。
assert.deepEqual(parseMenuTree({ data: { items: [] } }), [])
assert.deepEqual(parseMenuTree({}), [])
assert.deepEqual(parseMenuTree(null as unknown as { items?: [] }), [])
assert.deepEqual(parseMenuTree(undefined as unknown as { items?: [] }), [])
})
test('test_task_039_backend_tree_compat_boundary_single_item', () => {
// 边界单元素:单分组/单页面两种最小树均可解析。
assert.equal(parseMenuTree({ data: { items: [{ key: 'g', name: '组' }] } }).length, 1)
assert.equal(parseMenuTree({ items: [{ key: 'p', name: '页', route: '/p' }] }).length, 1)
})
test('test_task_039_backend_tree_compat_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:附加未知字段与缺省字段都不丢失/不崩溃。
const tree = parseMenuTree({ items: [{ key: 'p', name: '页', route: '/p', sort: 3, icon: 'x', extra: { keep: true } }] })
assert.equal((tree[0] as unknown as { extra: { keep: boolean } }).extra.keep, true)
})
test('test_task_039_backend_tree_compat_invalid_input_rejected', () => {
// 异常输入:success=false 视为接口失败抛错(区别于“权限为空”)。
assert.throws(() => parseMenuTree({ success: false, message: '会话失效', code: 401 }), /会话失效/)
})
test('test_task_039_backend_tree_compat_dependency_failure_returns_actionable_message', () => {
// 依赖失败:会话适配 fetchAdminMenuTree 复用同一解析器兜住各信封边界。
const session = readSource('src/api/session.ts')
assert.match(session, /parseMenuTree/)
const model = readSource('src/api/session-model.ts')
assert.match(model, /export function parseMenuTree/)
assert.match(model, /Array\.isArray/)
})
+75
View File
@@ -0,0 +1,75 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
ADMIN_THEME,
ADMIN_THEME_KEYS,
contrastRatio,
cssVarName,
isDarkSurface,
relativeLuminance,
tokenHex,
} from '../src/styles/theme.ts'
test('test_task_004_theme_tokens_normal_primary_path', () => {
// 正常主路径:侧边栏与加深面是暗色,内容区/卡片底是亮色。
assert.equal(isDarkSurface(ADMIN_THEME.sidebar), true, '侧边栏必须为暗色')
assert.equal(isDarkSurface(ADMIN_THEME.sidebarDeep), true, '侧边栏加深面必须为暗色')
assert.equal(isDarkSurface(ADMIN_THEME.bg), false, '内容区背景必须为亮色')
assert.equal(isDarkSurface(ADMIN_THEME.border), false, '边框须为亮面中性色')
})
test('test_task_004_theme_tokens_normal_variant_input', () => {
// 正常变体:强调色与软底/正文高对比,正文 token 自成一致体系。
assert.equal(relativeLuminance(ADMIN_THEME.primary), relativeLuminance('#6366f1'))
assert.ok(contrastRatio(ADMIN_THEME.text, ADMIN_THEME.bg) >= 4.5, '正文/内容区需满足 WCAG AA 正文')
assert.ok(contrastRatio(ADMIN_THEME.primary, ADMIN_THEME.bg) >= 3.0, '品牌色按钮须达到 3:1')
})
test('test_task_004_theme_tokens_normal_repeated_operation_is_idempotent', () => {
// 正常重复:亮度与对比度计算幂等、无状态污染。
assert.equal(relativeLuminance(ADMIN_THEME.bg), relativeLuminance(ADMIN_THEME.bg))
assert.equal(isDarkSurface(ADMIN_THEME.sidebar), isDarkSurface(ADMIN_THEME.sidebar))
assert.ok(contrastRatio(ADMIN_THEME.text, ADMIN_THEME.bg) === contrastRatio(ADMIN_THEME.text, ADMIN_THEME.bg))
})
test('test_task_004_theme_tokens_boundary_empty_input', () => {
// 边界空值:token 表非空、无空值、无未知多余键、键集合稳定。
assert.ok(ADMIN_THEME_KEYS.length >= 7, '必须覆盖侧边栏/内容区/正文等核心语义面')
for (const key of ADMIN_THEME_KEYS) {
assert.match(ADMIN_THEME[key], /^#[0-9a-fA-F]{6}$/, `${key} 须为 #rrggbb`)
}
})
test('test_task_004_theme_tokens_boundary_single_item', () => {
// 边界单元素:单个中性边界 token 与内容区可区分;侧边栏深于内容区。
assert.notEqual(ADMIN_THEME.border, ADMIN_THEME.bg)
assert.ok(relativeLuminance(ADMIN_THEME.sidebar) < relativeLuminance(ADMIN_THEME.bg))
})
test('test_task_004_theme_tokens_boundary_limit_or_missing_field', () => {
// 边界上限:次要文本 muted 在内容区上仍可达 3:1;CSS 变量名映射无重复斜杠。
assert.ok(contrastRatio(ADMIN_THEME.muted, ADMIN_THEME.bg) >= 3.0)
assert.equal(cssVarName('sidebar'), '--admin-sidebar')
assert.equal(cssVarName('sidebarDeep'), '--admin-sidebar-deep')
assert.ok(!cssVarName('primary').includes('--admin-admin-'))
})
test('test_task_004_theme_tokens_invalid_input_rejected', () => {
// 异常输入:非法 hex、未知 token 拒绝并报错;CSS 不得引用旧后台整份样式。
assert.throws(() => relativeLuminance('#12'), /#rrggbb/)
assert.throws(() => relativeLuminance('sidebar'), /#rrggbb/)
assert.throws(() => tokenHex('unknown' as never), /未知 Admin 主题 token/)
const css = readSource('src/styles/main.css')
assert.equal(/@import/.test(css), false, 'main.css 不得 @import 旧后台整份样式')
})
test('test_task_004_theme_tokens_dependency_failure_returns_actionable_message', () => {
// 依赖失败:token 与 main.css 渲染变量交叉校验必须一致(防双源漂移)。
const css = readSource('src/styles/main.css')
const missing = ADMIN_THEME_KEYS.filter((key) => {
const tokenVar = `--admin-${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`
return !css.includes(`${tokenVar}: ${ADMIN_THEME[key]}`)
})
assert.deepEqual(missing, [], `theme.ts 与 main.css 不一致,缺失变量: ${missing.join(', ')}`)
})
+74
View File
@@ -0,0 +1,74 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
emptyUserPageResult,
normalizeUserPageParams,
toUserListQuery,
USER_PAGE_DEFAULT_SIZE,
USER_PAGE_MAX_SIZE,
} from '../src/api/users-dto.ts'
test('test_task_041_users_dto_normal_primary_path', () => {
// 正常主路径:合法分页/关键字归一为可查询参数。
const p = normalizeUserPageParams({ page: 2, pageSize: 15, keyword: ' 张 ' })
assert.equal(p.page, 2)
assert.equal(p.pageSize, 15)
assert.equal(p.keyword, '张')
})
test('test_task_041_users_dto_normal_variant_input', () => {
// 正常变体:查询序列化采用 Java 参数名(page/page_size/username)。
const q = toUserListQuery({ page: 3, pageSize: 20, keyword: 'admin' })
assert.deepEqual(q, { page: 3, page_size: 20, username: 'admin' })
})
test('test_task_041_users_dto_normal_repeated_operation_is_idempotent', () => {
// 正常重复:同一输入归一结果稳定、不改输入。
const raw = { page: 1, pageSize: 15 }
assert.deepEqual(normalizeUserPageParams(raw), normalizeUserPageParams(raw))
assert.deepEqual(raw, { page: 1, pageSize: 15 })
})
test('test_task_041_users_dto_boundary_empty_input', () => {
// 边界空值:空对象回默认首页/页大小;空关键字视为无过滤。
const p = normalizeUserPageParams({})
assert.equal(p.page, 1)
assert.equal(p.pageSize, USER_PAGE_DEFAULT_SIZE)
assert.equal(p.keyword, undefined)
})
test('test_task_041_users_dto_boundary_single_item', () => {
// 边界单元素:单条分页结果 DTO 结构完整(items/total/page/pageSize)。
const empty = emptyUserPageResult()
assert.deepEqual(empty.items, [])
assert.equal(empty.total, 0)
assert.equal(empty.page, 1)
assert.equal(empty.pageSize, USER_PAGE_DEFAULT_SIZE)
})
test('test_task_041_users_dto_boundary_limit_or_missing_field', () => {
// 边界上限/越界:页码 <1 归 1;页大小超上限/非正被夹取。
assert.equal(normalizeUserPageParams({ page: 0, pageSize: 999 }).page, 1)
assert.equal(normalizeUserPageParams({ page: -3, pageSize: 0 }).pageSize, USER_PAGE_DEFAULT_SIZE)
assert.equal(normalizeUserPageParams({ pageSize: 999 }).pageSize, USER_PAGE_MAX_SIZE)
})
test('test_task_041_users_dto_invalid_input_rejected', () => {
// 异常输入:非数字/字符串关键字无效时不抛错并按缺省处理。
const p = normalizeUserPageParams({ page: Number.NaN, pageSize: Number.NaN, keyword: undefined })
assert.equal(p.page, 1)
assert.equal(p.pageSize, USER_PAGE_DEFAULT_SIZE)
assert.equal(p.keyword, undefined)
})
test('test_task_041_users_dto_dependency_failure_returns_actionable_message', () => {
// 依赖失败:DTO 纯模块不依赖 axios/http,由查询适配层引用。
const dto = readSource('src/api/users-dto.ts')
assert.equal(/axios|from '\.\/http'/.test(dto), false, 'DTO 模块保持纯逻辑')
assert.match(dto, /export interface UserPageResult/)
const adapter = readSource('src/api/users.ts')
assert.match(adapter, /users-dto/, '查询适配复用 DTO/参数归一')
const model = readSource('src/api/users-model.ts')
assert.match(model, /users-dto/, '解析模型复用 DTO 默认值')
})
+91
View File
@@ -0,0 +1,91 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { parseUserPage, toAdminUserItem } from '../src/api/users-model.ts'
import { USER_PAGE_DEFAULT_SIZE } from '../src/api/users-dto.ts'
test('test_task_042_user_list_adapter_normal_primary_path', () => {
// 正常主路径:Java snake_case data.items 信封解出 camelCase 分页结果。
const page = parseUserPage({
success: true,
data: {
items: [{ id: 1, username: 'admin', role: 'super_admin', is_admin: true, created_by_id: 3, creator_username: 'root', created_at: '2026-01-01T00:00:00', pinyin_abbr: 'adm' }],
total: 1,
page: 1,
page_size: 15,
},
})
assert.equal(page.items.length, 1)
assert.equal(page.items[0].username, 'admin')
assert.equal(page.items[0].isAdmin, true)
assert.equal(page.items[0].createdById, 3)
assert.equal(page.items[0].creatorUsername, 'root')
assert.equal(page.items[0].pinyinAbbr, 'adm')
assert.equal(page.total, 1)
assert.equal(page.pageSize, 15)
})
test('test_task_042_user_list_adapter_normal_variant_input', () => {
// 正常变体:已解包的 AdminUserListVo 直传同样可归一。
const page = parseUserPage({
items: [{ id: 2, username: '张伟恒', role: 'admin', is_admin: true, created_by_id: null }],
total: 5,
page: 2,
page_size: 20,
})
assert.equal(page.items[0].username, '张伟恒')
assert.equal(page.items[0].createdById, undefined)
assert.equal(page.page, 2)
assert.equal(page.pageSize, 20)
})
test('test_task_042_user_list_adapter_normal_repeated_operation_is_idempotent', () => {
// 正常重复:解析不修改输入、结果稳定。
const payload = { data: { items: [{ id: 3, username: 'u', role: 'normal' }], total: 1, page: 1, page_size: 15 } }
assert.deepEqual(parseUserPage(payload), parseUserPage(payload))
})
test('test_task_042_user_list_adapter_boundary_empty_input', () => {
// 边界空值:无 items/空负载回默认空结果,不崩溃。
const page = parseUserPage({})
assert.deepEqual(page.items, [])
assert.equal(page.total, 0)
assert.equal(page.pageSize, USER_PAGE_DEFAULT_SIZE)
})
test('test_task_042_user_list_adapter_boundary_single_item', () => {
// 边界单元素:单条最小字段(缺 id 的行被过滤)。
const page = parseUserPage({ data: { items: [{ id: 7, username: 'root', role: 'super_admin' }, { username: 'no-id' }], total: 2, page: 1, page_size: 15 } })
assert.equal(page.items.length, 1)
assert.equal(page.items[0].id, 7)
})
test('test_task_042_user_list_adapter_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:缺 page_size 用默认;缺省字段为空串而非 undefined。
const single = toAdminUserItem({ id: 9, username: '', role: '', is_admin: false })
assert.equal(single?.username, '')
assert.equal(single?.role, '')
assert.equal(single?.isAdmin, false)
const page = parseUserPage({ items: [], total: 0, page: 1 })
assert.equal(page.pageSize, USER_PAGE_DEFAULT_SIZE)
})
test('test_task_042_user_list_adapter_invalid_input_rejected', () => {
// 异常输入:success=false 被拒绝并带后端 message;缺 id 的行不入列表。
assert.throws(() => parseUserPage({ success: false, message: '无权限查看用户' }), /无权限查看用户/)
assert.equal(toAdminUserItem({ username: 'x' }), null)
assert.equal(toAdminUserItem('garbage'), null)
})
test('test_task_042_user_list_adapter_dependency_failure_returns_actionable_message', () => {
// 依赖失败:页面查询走 adapter(fetchUserList→parseUserPage),不在模板内联解包。
const page = readSource('src/pages/account/UsersPage.vue')
assert.match(page, /fetchUserList/)
assert.equal(/unwrap<|\/api\/admin\/users/.test(page), false, '页面不再内联 http.get + unwrap')
const adapter = readSource('src/api/users.ts')
assert.match(adapter, /\/api\/admin\/users/)
assert.match(adapter, /parseUserPage/)
assert.match(adapter, /normalizeUserPageParams/)
const model = readSource('src/api/users-model.ts')
assert.match(model, /export function parseUserPage/)
})
+76
View File
@@ -0,0 +1,76 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
ADMIN_DEFAULT_TITLE,
pageTitleOf,
topbarUserOf,
} from '../src/layout/topbar-model.ts'
test('test_task_005_topbar_title_model_normal_primary_path', () => {
// 正常主路径:meta.title 直接驱动页面标题;用户信息映射到顶栏视图模型。
assert.equal(pageTitleOf('用户管理'), '用户管理')
const vm = topbarUserOf({ id: 1, username: 'admin', role: 'super_admin' })
assert.equal(vm.username, 'admin')
assert.equal(vm.role, 'super_admin')
assert.equal(vm.hasUser, true)
})
test('test_task_005_topbar_title_model_normal_variant_input', () => {
// 正常变体:另一种有效标题/角色不依赖单一样例。
assert.equal(pageTitleOf('菜单管理'), '菜单管理')
const normal = topbarUserOf({ id: 2, username: 'ops', role: 'admin' })
assert.equal(normal.username, 'ops')
assert.equal(normal.hasUser, true)
})
test('test_task_005_topbar_title_model_normal_repeated_operation_is_idempotent', () => {
// 正常重复:模型纯函数重复调用结果稳定。
assert.equal(pageTitleOf('数据权限分组'), pageTitleOf('数据权限分组'))
assert.deepEqual(topbarUserOf(null), topbarUserOf(null))
assert.deepEqual(topbarUserOf({ id: 1, username: 'u', role: '' }), topbarUserOf({ id: 1, username: 'u', role: '' }))
})
test('test_task_005_topbar_title_model_boundary_empty_input', () => {
// 边界空值:标题为空/空白回落到缺省;用户为 null/undefined 进入空态不崩溃。
assert.equal(pageTitleOf(undefined), ADMIN_DEFAULT_TITLE)
assert.equal(pageTitleOf(''), ADMIN_DEFAULT_TITLE)
assert.equal(pageTitleOf(' '), ADMIN_DEFAULT_TITLE)
const none = topbarUserOf(undefined)
assert.equal(none.username, '当前用户')
assert.equal(none.hasUser, false)
})
test('test_task_005_topbar_title_model_boundary_single_item', () => {
// 边界单元素:单页面标题、单用户映射各自产出唯一稳定结果。
assert.equal(pageTitleOf('首页'), '首页')
const single = topbarUserOf({ id: 9, username: 'root', role: 'admin' })
assert.equal(single.username, 'root')
assert.equal(single.role, 'admin')
})
test('test_task_005_topbar_title_model_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:缺 username/role 的用户仍可渲染且有明确空态。
const partial = topbarUserOf({ id: 3, username: '', role: '' })
assert.equal(partial.username, '当前用户')
assert.equal(partial.role, '')
assert.equal(partial.hasUser, true)
assert.ok(ADMIN_DEFAULT_TITLE.length > 0, '缺省标题不能为空')
})
test('test_task_005_topbar_title_model_invalid_input_rejected', () => {
// 异常输入:非字符串标题按空处理回落到缺省(不崩溃、不输出 undefined/null)。
const bad = pageTitleOf(null)
assert.notEqual(bad, 'undefined')
assert.notEqual(bad, 'null')
assert.equal(bad, ADMIN_DEFAULT_TITLE)
assert.equal(pageTitleOf(123 as unknown as string), ADMIN_DEFAULT_TITLE)
})
test('test_task_005_topbar_title_model_dependency_failure_returns_actionable_message', () => {
// 依赖失败:壳层实际使用该标题/用户模型,而非在模板里另写一份缺省逻辑。
const layout = readSource('src/layout/AdminLayout.vue')
assert.match(layout, /pageTitleOf/)
assert.match(layout, /topbarUserOf/)
assert.equal(/route\.meta\.title\s*\|\|\s*'管理后台'/.test(layout), false, '标题缺省必须走 pageTitleOf')
})
+99
View File
@@ -0,0 +1,99 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { groupKeysForActive, toSidebarEntries } from '../src/layout/menu-mapper.ts'
import type { AdminMenuNode } from '../src/types/admin.ts'
function node(partial: Partial<AdminMenuNode> & { key: string; name: string }): AdminMenuNode {
return { key: partial.key, name: partial.name, route: partial.route, children: partial.children, sort: partial.sort }
}
const TREE: AdminMenuNode[] = [
node({ key: 'account', name: '账号权限', children: [
node({ key: 'admin_users', name: '用户管理', route: '/account/users' }),
node({ key: 'admin_columns', name: '菜单管理', route: '/account/menus' }),
] }),
]
test('test_task_006_menu_sidebar_mapping_normal_primary_path', () => {
// 正常主路径:带可路由子节点的后端菜单渲染为分组,顺序保留。
const entries = toSidebarEntries(TREE)
assert.equal(entries.length, 1)
assert.equal(entries[0].kind, 'group')
if (entries[0].kind === 'group') {
assert.equal(entries[0].name, '账号权限')
assert.deepEqual(entries[0].children.map((c) => c.route), ['/account/users', '/account/menus'])
}
})
test('test_task_006_menu_sidebar_mapping_normal_variant_input', () => {
// 正常变体:另一组菜单(含顶级路由叶 + 分组混合)正确混合输出。
const mix: AdminMenuNode[] = [
node({ key: 'g', name: '分组', children: [node({ key: 'c', name: '子', route: '/x/c' })] }),
node({ key: 'leaf', name: '顶级页', route: '/top' }),
]
const entries = toSidebarEntries(mix)
assert.equal(entries.length, 2)
assert.equal(entries[0].kind, 'group')
assert.equal(entries[1].kind, 'item')
if (entries[1].kind === 'item') assert.equal(entries[1].route, '/top')
})
test('test_task_006_menu_sidebar_mapping_normal_repeated_operation_is_idempotent', () => {
// 正常重复:映射结果稳定,不修改输入源树。
const snapshot = JSON.stringify(TREE)
const first = JSON.stringify(toSidebarEntries(TREE))
const second = JSON.stringify(toSidebarEntries(TREE))
assert.equal(first, second)
assert.equal(JSON.stringify(TREE), snapshot, '映射不得污染源菜单树')
})
test('test_task_006_menu_sidebar_mapping_boundary_empty_input', () => {
// 边界空值:空菜单树得到空侧边栏列表,不崩溃。
assert.deepEqual(toSidebarEntries([]), [])
assert.deepEqual(toSidebarEntries(undefined as unknown as AdminMenuNode[]), [])
})
test('test_task_006_menu_sidebar_mapping_boundary_single_item', () => {
// 边界单元素:单个顶级路由页不因没有子节点而被丢弃。
const entries = toSidebarEntries([node({ key: 's', name: '单页', route: '/solo' })])
assert.equal(entries.length, 1)
assert.equal(entries[0].kind, 'item')
if (entries[0].kind === 'item') assert.equal(entries[0].route, '/solo')
})
test('test_task_006_menu_sidebar_mapping_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:子项缺 route 被过滤;分组无任何可路由子项时不渲染占位分组。
const noRoutableChildren: AdminMenuNode[] = [
node({ key: 'g', name: '空分组', children: [node({ key: 'c', name: '无路由' })] }),
]
assert.deepEqual(toSidebarEntries(noRoutableChildren), [])
const withMissing = toSidebarEntries([node({ key: 'g', name: '有', children: [
node({ key: 'ok', name: '可点', route: '/a' }),
node({ key: 'no', name: '不可点' }),
] })])
if (withMissing[0].kind === 'group') {
assert.deepEqual(withMissing[0].children.map((c) => c.key), ['ok'])
} else {
assert.fail('应输出分组')
}
})
test('test_task_006_menu_sidebar_mapping_invalid_input_rejected', () => {
// 异常输入:route/children 缺省的畸形节点被跳过而非抛异常。
const malformed = [
{ key: 'x', name: '畸形' } as unknown as AdminMenuNode,
{ key: 'y', name: '无key子项', children: [{ name: '裸' }] } as unknown as AdminMenuNode,
]
assert.deepEqual(toSidebarEntries(malformed), [], '畸形节点不应产生侧边栏项')
})
test('test_task_006_menu_sidebar_mapping_dependency_failure_returns_actionable_message', () => {
// 依赖失败:壳层消费映射模块;激活分组展开按当前路由命中。
const layout = readSource('src/layout/AdminLayout.vue')
assert.match(layout, /toSidebarEntries/)
assert.match(layout, /groupKeysForActive/)
const active = toSidebarEntries(TREE)
assert.deepEqual(groupKeysForActive(active, '/account/menus'), ['account'])
assert.deepEqual(groupKeysForActive(active, '/account/nope'), [], '未命中路由不展开任何分组')
})
+77
View File
@@ -0,0 +1,77 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { firstVisiblePath } from '../src/router/helpers.ts'
import type { AdminMenuNode } from '../src/types/admin.ts'
function node(partial: Partial<AdminMenuNode> & { key: string; name: string }): AdminMenuNode {
return { key: partial.key, name: partial.name, route: partial.route, children: partial.children }
}
const NESTED: AdminMenuNode[] = [
node({ key: 'a', name: '组A', children: [node({ key: 'a1', name: '无路由' })] }),
node({ key: 'b', name: '组B', children: [
node({ key: 'b1', name: '用户', route: '/account/users' }),
node({ key: 'b2', name: '菜单', route: '/account/menus' }),
] }),
]
test('test_task_007_first_route_redirect_normal_primary_path', () => {
// 正常主路径:深度优先返回第一个可见页面。
assert.equal(firstVisiblePath(NESTED), '/account/users')
})
test('test_task_007_first_route_redirect_normal_variant_input', () => {
// 正常变体:另一棵树返回其自身首个可见页,不依赖固定页。
const tree: AdminMenuNode[] = [
node({ key: 'x', name: '顶级', route: '/shop/list' }),
node({ key: 'y', name: '后置', route: '/tasks/list' }),
]
assert.equal(firstVisiblePath(tree), '/shop/list')
})
test('test_task_007_first_route_redirect_normal_repeated_operation_is_idempotent', () => {
// 正常重复:结果稳定、不修改输入。
const snapshot = JSON.stringify(NESTED)
assert.equal(firstVisiblePath(NESTED), firstVisiblePath(NESTED))
assert.equal(JSON.stringify(NESTED), snapshot)
})
test('test_task_007_first_route_redirect_boundary_empty_input', () => {
// 边界空值:无任何菜单返回空串,不硬编码缺省页。
assert.equal(firstVisiblePath([]), '')
assert.equal(firstVisiblePath(undefined), '')
assert.equal(firstVisiblePath(null), '')
})
test('test_task_007_first_route_redirect_boundary_single_item', () => {
// 边界单元素:仅一个顶层页面时返回它。
assert.equal(firstVisiblePath([node({ key: 's', name: '单页', route: '/solo' })]), '/solo')
})
test('test_task_007_first_route_redirect_boundary_limit_or_missing_field', () => {
// 边界上限:只有无路由子项的分组不产出可见页。
const onlyEmptyGroups: AdminMenuNode[] = [
node({ key: 'g', name: '空组', children: [node({ key: 'c', name: '不可点' })] }),
]
assert.equal(firstVisiblePath(onlyEmptyGroups), '')
})
test('test_task_007_first_route_redirect_invalid_input_rejected', () => {
// 异常输入:畸形节点被跳过并继续找下一个可见页。
const withMalformed: AdminMenuNode[] = [
{ key: 'bad', name: '畸形', route: '' } as unknown as AdminMenuNode,
node({ key: 'ok', name: '可见', route: '/fine' }),
]
assert.equal(firstVisiblePath(withMalformed), '/fine')
})
test('test_task_007_first_route_redirect_dependency_failure_returns_actionable_message', () => {
// 依赖失败:根跳转由会话首个可见页驱动,不再硬编码 account/users。
const router = readSource('src/router/index.ts')
assert.equal(router.includes('redirect: \'/account/users\''), false, '禁止硬编码根跳转缺省页')
assert.equal(router.includes('firstVisible'), true, '守卫必须使用会话首个可见页')
const store = readSource('src/stores/admin-session.ts')
assert.match(store, /firstVisible:/)
assert.match(store, /firstVisiblePath/)
})
+79
View File
@@ -0,0 +1,79 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
adminPages,
adminRouteRecords,
routeOf,
validateAdminPages,
} from '../src/router/routes.ts'
test('test_task_008_domain_route_registry_normal_primary_path', () => {
// 正常主路径:注册表首批 account 域页面登记为可消费路由记录。
assert.equal(adminPages.length, 3)
assert.equal(adminRouteRecords.length, adminPages.length)
const first = adminRouteRecords[0]
assert.equal(first.path, 'account/users')
assert.equal((first.meta as { title?: string }).title, '用户管理')
assert.equal((first.meta as { menuKey?: string }).menuKey, 'admin_users')
assert.deepEqual(validateAdminPages(adminPages), [])
})
test('test_task_008_domain_route_registry_normal_variant_input', () => {
// 正常变体:无 menuKey 的页面元数据不携带菜单 key,仍带标题。
const record = routeOf({ path: 'tasks/plain', title: '无菜单页', load: async () => ({ default: {} }) })
const meta = record.meta as { title?: string; menuKey?: string }
assert.equal(meta.title, '无菜单页')
assert.equal('menuKey' in meta, false)
})
test('test_task_008_domain_route_registry_normal_repeated_operation_is_idempotent', () => {
// 正常重复:从同一注册表重复生成记录结果稳定。
const once = JSON.stringify(adminPages.map(routeOf))
const twice = JSON.stringify(adminPages.map(routeOf))
assert.equal(once, twice)
assert.deepEqual(validateAdminPages(adminPages), validateAdminPages(adminPages))
})
test('test_task_008_domain_route_registry_boundary_empty_input', () => {
// 边界空值:空注册表可校验、可映射为空路由列表。
assert.deepEqual(validateAdminPages([]), [])
assert.equal([].map(routeOf).length, 0)
})
test('test_task_008_domain_route_registry_boundary_single_item', () => {
// 边界单元素:单页面登记生成唯一路由记录。
const records = [routeOf({ path: 'shop/list', title: '店铺列表', load: async () => ({ default: {} }) })]
assert.equal(records.length, 1)
assert.equal(records[0].path, 'shop/list')
})
test('test_task_008_domain_route_registry_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:路径重复、前导斜杠、缺 title、混入 base 前缀都被校验拒绝。
const base = { title: 'T', load: async () => ({ default: {} }) }
const issues = validateAdminPages([
{ ...base, path: 'a/b' },
{ ...base, path: 'a/b' },
{ ...base, path: '/lead' },
{ path: '', title: '', load: async () => ({ default: {} }) },
{ path: '/admin-vue/x', title: 'X', load: async () => ({ default: {} }) },
])
assert.ok(issues.some((i) => i.includes('路径重复')))
assert.ok(issues.some((i) => i.includes('相对子路径')))
assert.ok(issues.some((i) => i.includes('缺少标题')))
assert.ok(issues.some((i) => i.includes('base 前缀')))
})
test('test_task_008_domain_route_registry_invalid_input_rejected', () => {
// 异常输入:非法页面定义在生成路由时被拒绝并给出可操作消息。
assert.throws(() => routeOf({ path: '', title: 'T', load: async () => ({ default: {} }) }), /路由注册表页面定义非法/)
assert.throws(() => routeOf({ path: 'x', title: '', load: async () => ({ default: {} }) }), /路由注册表页面定义非法/)
})
test('test_task_008_domain_route_registry_dependency_failure_returns_actionable_message', () => {
// 依赖失败:router 消费注册表,不再内联页面懒加载与路径字面量。
const router = readSource('src/router/index.ts')
assert.match(router, /adminRouteRecords/)
assert.equal(router.includes('account/users'), false, '路径字面量应只存在于 routes.ts 注册表')
assert.equal(router.includes('() => import(\'@/pages'), false, '页面懒加载应只存在于注册表')
})
+72
View File
@@ -0,0 +1,72 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import {
ADMIN_MENU_KEY_PATTERN,
isValidMenuKey,
metaMenuKey,
validateRouteMenuKeys,
} from '../src/router/meta.ts'
import { adminPages } from '../src/router/routes.ts'
test('test_task_009_route_menu_key_meta_normal_primary_path', () => {
// 正常主路径:合法 menuKey 被识别。
assert.equal(metaMenuKey({ menuKey: 'admin_users' }), 'admin_users')
assert.equal(isValidMenuKey('admin_users'), true)
assert.equal(ADMIN_MENU_KEY_PATTERN.test('admin_users'), true)
})
test('test_task_009_route_menu_key_meta_normal_variant_input', () => {
// 正常变体:另一合法 key(含数字)也能识别。
assert.equal(isValidMenuKey('admin_group_manage'), true)
assert.equal(isValidMenuKey('asin_center2'), true)
})
test('test_task_009_route_menu_key_meta_normal_repeated_operation_is_idempotent', () => {
// 正常重复:读取与校验幂等。
assert.equal(metaMenuKey({ menuKey: 'shop_list' }), metaMenuKey({ menuKey: 'shop_list' }))
assert.equal(isValidMenuKey('shop_list'), isValidMenuKey('shop_list'))
})
test('test_task_009_route_menu_key_meta_boundary_empty_input', () => {
// 边界空值:无 meta/无 menuKey 回退空串;空串 key 不参与命名约束。
assert.equal(metaMenuKey(undefined), '')
assert.equal(metaMenuKey({}), '')
assert.equal(metaMenuKey({ menuKey: '' }), '')
assert.deepEqual(validateRouteMenuKeys([]), [])
})
test('test_task_009_route_menu_key_meta_boundary_single_item', () => {
// 边界单元素:单条带合法 key 的注册记录无校验问题。
assert.deepEqual(validateRouteMenuKeys([{ path: 'a/b', menuKey: 'admin_x' }]), [])
})
test('test_task_009_route_menu_key_meta_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:重复 key、驼峰/连字符/数字开头 key 均被校验拒绝。
const issues = validateRouteMenuKeys([
{ path: 'a', menuKey: 'dup' },
{ path: 'b', menuKey: 'dup' },
{ path: 'c', menuKey: 'CamelKey' },
{ path: 'd', menuKey: 'kebab-key' },
{ path: 'e', menuKey: '1digit' },
])
assert.ok(issues.some((i) => i.includes('重复')))
assert.ok(issues.some((i) => i.includes('命名非法')))
})
test('test_task_009_route_menu_key_meta_invalid_input_rejected', () => {
// 异常输入:非字符串 menuKey 回退空串,不崩溃、不参与校验。
assert.equal(metaMenuKey({ menuKey: 123 }), '')
assert.equal(metaMenuKey({ menuKey: null }), '')
assert.deepEqual(validateRouteMenuKeys([{ path: 'x', menuKey: 1 }, { path: 'y' }]), [])
})
test('test_task_009_route_menu_key_meta_dependency_failure_returns_actionable_message', () => {
// 依赖失败:RouteMeta 已增强类型;守卫使用类型化 meta;注册表 menuKey 全部合规。
const dts = readSource('src/types/vue-router.d.ts')
assert.match(dts, /interface RouteMeta/)
assert.match(dts, /menuKey\?: string/)
const router = readSource('src/router/index.ts')
assert.equal(router.includes('as string | undefined'), false, 'menuKey 应为类型化访问,禁止 cast')
assert.deepEqual(validateRouteMenuKeys(adminPages), [])
})
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ES2022",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"allowImportingTsExtensions": true,
"strict": true,
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"baseUrl": ".",
"paths": { "@/*": ["src/*"] }
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue", "vite.config.ts"]
}
+28
View File
@@ -0,0 +1,28 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { APP_BASE_PATH } from './src/config/app'
export default defineConfig({
base: APP_BASE_PATH,
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: 5174,
proxy: {
'/api': {
target: process.env.VITE_API_TARGET || 'http://127.0.0.1:18080',
changeOrigin: true,
},
},
},
build: {
outDir: 'dist',
emptyOutDir: true,
sourcemap: false,
},
})
-19
View File
@@ -1,19 +0,0 @@
base_url=http://8.136.19.173:15124
workflow_id=7608812635877900322
mysql_host=8.136.19.173
mysql_user=aiimage
proxy_url=https://api.jikip.com/ip-get?num=1&minute=1&format=json&area=all&protocol=1&mode=2&key=t24g6gi44ubufd8
proxy_mode=2
zn_company=rongchuang123
zn_username=%E8%87%AA%E5%8A%A8%E5%8C%96_Robot
client_name=ShuFuAI
# java_api_base=http://127.0.0.1:18080
# java_api_base=http://8.136.19.173:18081
java_api_base=http://8.136.19.173:18080
-15
View File
@@ -1,15 +0,0 @@
base_url=http://8.136.19.173:15124
workflow_id=7608812635877900322
mysql_host=8.136.19.173
mysql_user=aiimage
proxy_url=https://api.jikip.com/ip-get?num=1&minute=1&format=json&area=all&protocol=1&mode=2&key=t24g6gi44ubufd8
proxy_mode=2
client_name=ShuFuAI
java_api_base=http://127.0.0.1:18080
# java_api_base=http://8.136.19.173:18080
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-73
View File
@@ -1,73 +0,0 @@
import argparse
import base64
import re
import time
import alibabacloud_oss_v2 as oss
import requests
from config import region, endpoint, bucket, file_url_pre, bucket_path
def upload_file(file_content: bytes, key: str):
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = region
cfg.endpoint = endpoint
cfg.retry_max_attempts = 3
client = oss.Client(cfg)
result = client.put_object(
oss.PutObjectRequest(
bucket=bucket, # 存储空间名称
key=key, # 对象名称
body=file_content # 读取文件内容
)
)
# print(result)
return file_url_pre + key
def upload_data_url(data_url: str, prefix: str = "history", key_hint: str = "") -> str:
"""
将 base64 data URL 上传到 OSS,返回图片链接
data_url: data:image/png;base64,xxxx 或 data:image/jpeg;base64,xxxx
prefix: OSS key 前缀
key_hint: 可选后缀避免重名,如 "_0", "_1"
"""
match = re.match(r'data:image/(\w+);base64,(.+)', data_url)
if not match:
raise ValueError('无效的 data URL 格式')
ext = 'png' if match.group(1).lower() in ('png', 'webp') else 'jpg'
file_content = base64.b64decode(match.group(2))
ts = int(time.time() * 1000)
key = f"{bucket_path}{prefix}/{ts}{key_hint}.{ext}"
return upload_file(file_content, key)
def upload_data_urls(data_urls: list, prefix: str = "history") -> list:
"""批量上传 base64 图片到 OSS,返回图片链接列表"""
urls = []
ts = int(time.time() * 1000)
for i, data_url in enumerate(data_urls or []):
if not data_url or not isinstance(data_url, str):
continue
if not data_url.startswith("http"):
match = re.match(r'data:image/(\w+);base64,(.+)', data_url)
if not match:
continue
ext = 'png' if match.group(1).lower() in ('png', 'webp') else 'jpg'
file_content = base64.b64decode(match.group(2))
else:
file_content = requests.get(data_url).content
ext = "png"
key = f"{bucket_path}{prefix}/{ts}_{i}.{ext}"
urls.append(upload_file(file_content, key))
return urls
# 脚本入口,当文件被直接运行时调用main函数
if __name__ == "__main__":
with open("测试图片数据/IMG_2685.JPG", "rb") as f:
file_content = f.read()
upload_file(file_content,key=bucket_path+"test.png")
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More