Files
platforms/frontend/platform_admin/scripts/check-resource-search.mjs
czl231 a37b147f5f 修复:工作人员列表切换后自动加载数据
监听工作人员类型变化,切换安装、配送和运维菜单时自动重置搜索及页码并重新查询;补充资源、搜索和人员关联回归检查,同时更新中文需求说明与操作日志。
2026-08-11 22:38:20 +08:00

42 lines
2.1 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.1.0
*/
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const listPage = readFileSync(
resolve(root, 'src/views/shared/CrudListPage.vue'),
'utf8',
);
const searchState = readFileSync(
resolve(root, 'src/views/shared/use-resource-list-search.ts'),
'utf8',
);
const resources = readFileSync(resolve(root, 'src/api/resources.ts'), 'utf8');
const expectations = [
[listPage, 'v-if="searchEnabled"', '不支持搜索时隐藏表单'],
[listPage, ':placeholder="searchPlaceholder"', '动态显示可搜索字段'],
[listPage, 'const keyword = requestKeyword();', '只发送受支持的关键字'],
[searchState, 'definition.value.searchFields', '读取后端搜索契约'],
[searchState, 'resourceListDisplayFields', '搜索字段与实际列表列求交集'],
[searchState, 'if (searchEnabled.value || !route.query.keyword) return;', '清理不支持页面的陈旧关键字'],
[searchState, 'if (route.query.keyword || route.query.page) await syncQuery();', '切换列表时清理陈旧关键字和页码'],
[searchState, '`可搜索:${searchableFields.value', '明确列出可搜索中文字段'],
[resources, 'searchFields: resourceSearchFields(name)', '资源定义消费后端搜索契约'],
[resources, "resourceSearchEnumOptions('staff_account', 'role_code')", '工作人员中文角色与搜索契约同源'],
[resources, "resourceSearchEnumOptions('gasorder_basic', 'creator_type')", '订单创建方中文枚举与搜索契约同源'],
];
for (const [content, fragment, description] of expectations) {
if (!content.includes(fragment)) throw new Error(`资源搜索检查失败:${description}`);
}
if (listPage.includes('关键字段模糊搜索')) {
throw new Error('仍存在未说明具体字段的旧搜索提示');
}
console.log('资源搜索检查通过动态提示、隐藏逻辑、URL 清理和中文枚举均已覆盖');