75 lines
2.2 KiB
JavaScript
75 lines
2.2 KiB
JavaScript
|
|
/**
|
|||
|
|
* 功能:静态检查三套管理后台的账户角色中文展示与无效头像摘要规则。
|
|||
|
|
* 版本: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)), '..');
|
|||
|
|
const frontendRoot = resolve(appRoot, '..');
|
|||
|
|
|
|||
|
|
function source(path) {
|
|||
|
|
return readFileSync(resolve(frontendRoot, path), 'utf8');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function expectIncludes(content, marker, message) {
|
|||
|
|
if (!content.includes(marker)) throw new Error(`账户角色检查失败:${message}`);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const platformResources = source('platform_admin/src/api/resources.ts');
|
|||
|
|
const platformPage = source(
|
|||
|
|
'platform_admin/src/views/resource/ResourceRecordPage.vue',
|
|||
|
|
);
|
|||
|
|
const platformSummary = source(
|
|||
|
|
'platform_admin/src/views/resource/ResourceAccountSummary.vue',
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
expectIncludes(
|
|||
|
|
platformResources,
|
|||
|
|
"fixedAdminRole('气站管理员')",
|
|||
|
|
'平台总后台缺少气站管理员中文映射',
|
|||
|
|
);
|
|||
|
|
expectIncludes(
|
|||
|
|
platformResources,
|
|||
|
|
"fixedAdminRole('配送点管理员')",
|
|||
|
|
'平台总后台缺少配送点管理员中文映射',
|
|||
|
|
);
|
|||
|
|
expectIncludes(
|
|||
|
|
platformResources,
|
|||
|
|
"define('delivery_account', '配送点账户'",
|
|||
|
|
'配送点账户名称未统一',
|
|||
|
|
);
|
|||
|
|
expectIncludes(
|
|||
|
|
platformPage,
|
|||
|
|
"mode.value !== 'create' || hasAvatarField.value",
|
|||
|
|
'无头像能力的新建账户页仍可能显示无效占位摘要',
|
|||
|
|
);
|
|||
|
|
expectIncludes(
|
|||
|
|
platformSummary,
|
|||
|
|
'v-if="avatarEnabled" class="avatar-column"',
|
|||
|
|
'无头像能力的账户仍可能显示装饰头像',
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
for (const app of ['gas_admin', 'delivery_admin']) {
|
|||
|
|
const resources = source(`${app}/src/api/resources.ts`);
|
|||
|
|
const listPage = source(`${app}/src/views/shared/CrudListPage.vue`);
|
|||
|
|
expectIncludes(
|
|||
|
|
resources,
|
|||
|
|
"fixedAdminRole('配送点管理员')",
|
|||
|
|
`${app} 缺少配送点管理员中文映射`,
|
|||
|
|
);
|
|||
|
|
expectIncludes(
|
|||
|
|
listPage,
|
|||
|
|
"'/gas_account': { admin: '气站管理员' }",
|
|||
|
|
`${app} 缺少气站管理员显示规则`,
|
|||
|
|
);
|
|||
|
|
expectIncludes(
|
|||
|
|
listPage,
|
|||
|
|
"'/delivery_account': { admin: '配送点管理员' }",
|
|||
|
|
`${app} 缺少配送点管理员显示规则`,
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
console.log('账户角色检查通过:三套后台中文角色、未知角色和头像摘要规则均已覆盖。');
|