feat: 标准资源使用独立页面并优化详情布局
This commit is contained in:
@@ -1,21 +1,36 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
/**
|
||||
* 功能:校验平台总后台资源定义、页面路由与后端资源契约保持一致。
|
||||
* 版本: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 source = readFileSync(resolve(root, 'src/api/resources.ts'), 'utf8');
|
||||
const routes = readFileSync(resolve(root, 'src/router/routes/modules/platform.ts'), 'utf8');
|
||||
const routeFiles = ['platform.ts', 'finance-route.ts'];
|
||||
const routes = routeFiles
|
||||
.map((name) =>
|
||||
readFileSync(resolve(root, 'src/router/routes/modules', name), 'utf8'),
|
||||
)
|
||||
.join('\n');
|
||||
const contract = JSON.parse(
|
||||
readFileSync(resolve(root, 'src/contracts/platform-resources.json'), 'utf8'),
|
||||
);
|
||||
const backend = new Map(contract.resources.map((item) => [item.name, item]));
|
||||
const frontendDefinitions = [
|
||||
...source.matchAll(/define\('([^']+)',\s*'[^']+',\s*'([^']+)'/g),
|
||||
...source.matchAll(
|
||||
/define\(\s*'([^']+)'\s*,\s*'[^']+'\s*,\s*'([^']+)'/g,
|
||||
),
|
||||
].map((match) => ({ name: match[1], mode: match[2] }));
|
||||
const frontendNames = frontendDefinitions.map((item) => item.name);
|
||||
const embeddedResources = new Set([
|
||||
'wallet_basic', 'wallet_bank', 'payment_order', 'wallet_record',
|
||||
'payment_refund', 'wallet_apply_cash',
|
||||
'wallet_basic',
|
||||
'wallet_bank',
|
||||
'payment_order',
|
||||
'wallet_record',
|
||||
'payment_refund',
|
||||
'wallet_apply_cash',
|
||||
]);
|
||||
|
||||
for (const name of frontendNames) {
|
||||
@@ -38,11 +53,23 @@ for (const item of contract.resources) {
|
||||
}
|
||||
|
||||
const forbidden = [
|
||||
'/platform/platform_', '/gas/gas_', '/delivery/delivery_', '/staff/',
|
||||
'/user/', '/ec/ec_', '/finance/fin_', '/wallet/wallet',
|
||||
'delivery_task', 'delivery_track', 'delivery_track_point',
|
||||
'dev_device_binding', 'dev_smart_cylinder_valve', 'dev_telemetry',
|
||||
'wallet_ledger', 'wallet_recharge', 'wallet_withdrawal',
|
||||
'/platform/platform_',
|
||||
'/gas/gas_',
|
||||
'/delivery/delivery_',
|
||||
'/staff/',
|
||||
'/user/',
|
||||
'/ec/ec_',
|
||||
'/finance/fin_',
|
||||
'/wallet/wallet',
|
||||
'delivery_task',
|
||||
'delivery_track',
|
||||
'delivery_track_point',
|
||||
'dev_device_binding',
|
||||
'dev_smart_cylinder_valve',
|
||||
'dev_telemetry',
|
||||
'wallet_ledger',
|
||||
'wallet_recharge',
|
||||
'wallet_withdrawal',
|
||||
];
|
||||
for (const value of forbidden) {
|
||||
if (source.includes(value) || routes.includes(value))
|
||||
|
||||
Reference in New Issue
Block a user