Files
platforms/frontend/platform_admin/scripts/check-user-address-relation-display.mjs
2026-08-11 21:33:20 +08:00

32 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 功能:静态检查用户地址列表的账户名称展示、标识降级与复制入口。
* 版本v1.0.0
*/
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
function source(path) {
return readFileSync(resolve(appRoot, path), 'utf8');
}
function expectIncludes(content, marker, message) {
if (!content.includes(marker)) throw new Error(`用户地址展示检查失败:${message}`);
}
const resources = source('src/api/resources.ts');
const listPage = source('src/views/shared/CrudListPage.vue');
const relationName = source('src/views/shared/RelationNameText.vue');
const fieldDisplay = source('src/views/shared/resource-list-field-display.ts');
expectIncludes(resources, "listLabel: '用户账户'", '列表列名未改为用户账户');
expectIncludes(resources, 'listRelationNameOnly: true', '用户地址未启用账户名称展示');
expectIncludes(listPage, '<RelationNameText', '列表未使用账户名称组件');
expectIncludes(fieldDisplay, 'return match ? optionLabel(match) : identity;', '关系名称缺失时未降级显示标识');
expectIncludes(relationName, '用户唯一标识:${identity}', '缺少完整标识悬停提示');
expectIncludes(relationName, '@click.stop="copyIdentity"', '缺少标识复制入口');
console.log('用户地址展示检查通过:账户名称、标识降级、悬停与复制入口均已覆盖。');