import assert from 'node:assert/strict' import test from 'node:test' import { existsSync, readFileSync } from 'node:fs' import { join } from 'node:path' /** * 2026-11-22 京东工具台密钥设置入口(用户拍板「这边也要加密钥设置」)的源码绊线。 * * 三件钉: * 1. 三个京东页(工具台/采集/上架)头部 .top-right 都挂 BrandApiSecretSettingsButton * (variant=topbar、show-proxy=false——京东特性没有代理消费方,面板代理区不许出现); * 2. 按钮组件把 showProxy 透传给面板、副标题随代理区开关派生、默认仍 true(亚马逊侧零变化); * 3. 面板本体与 setup 强制门不在本文件射程(不动)。 */ const ROOT = process.cwd() function read(relativePath: string, what: string): string { const path = join(ROOT, relativePath) assert.ok(existsSync(path), `${what} 尚未落地:${path}`) return readFileSync(path, 'utf8') } const JD_PAGES = [ ['src/pages/jd/JdConsolePage.vue', '京东工具台首页'], ['src/pages/jd/JdCollectTab.vue', '京东采集页'], ['src/pages/jd/JdPublishTab.vue', '京东上架页'], ] as const const ENTRY_LINE = '' test('三个京东页头部都挂密钥设置入口(variant=topbar、show-proxy=false)', () => { for (const [file, what] of JD_PAGES) { const src = read(file, what) assert.ok(src.includes(ENTRY_LINE), `${what}(${file})头部没有密钥设置入口:${ENTRY_LINE}`) assert.ok( /import BrandApiSecretSettingsButton from '@\/pages\/brand\/components\/BrandApiSecretSettingsButton\.vue'/.test(src), `${what}(${file})没有 import BrandApiSecretSettingsButton`, ) // 入口必须画在 .top-right(铃铛与用户名之间),不得挪去别处 assert.ok( /
\s*\s*]*\/>\s*/.test(src), `${what}(${file})的密钥设置入口不在 top-right(NotificationBell 与用户名之间)`, ) } }) test('按钮组件把 showProxy 透传给面板,副标题随代理区开关派生,默认 true(亚马逊侧零变化)', () => { const src = read('src/pages/brand/components/BrandApiSecretSettingsButton.vue', '密钥设置按钮') assert.ok( //.test(src), '按钮组件没有把 showProxy 透传给面板:京东入口传 false 也只会照常显示代理区', ) assert.ok(/showProxy\?: boolean/.test(src), '按钮组件没有 showProxy prop') assert.ok( /props\.showProxy\s*\?/.test(src), '副标题没有按 showProxy 派生:隐藏代理时不得再提「代理设置保存在当前客户端」', ) assert.ok(/showProxy: true,/.test(src), 'showProxy 默认值必须是 true(亚马逊侧现有调用零变化)') })