fix(components): 菜单管理调整

This commit is contained in:
2026-03-27 14:03:42 +08:00
parent 120a5b4dfd
commit ca3d697941
9 changed files with 11075 additions and 103 deletions

View File

@@ -2,12 +2,11 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { setupElegantRouter } from '../build/plugins/router.ts';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootDir = path.resolve(__dirname, '..');
const currentFilePath = fileURLToPath(import.meta.url);
const currentDirPath = path.dirname(currentFilePath);
const rootDir = path.resolve(currentDirPath, '..');
const generatedFiles = [
path.resolve(rootDir, 'src/router/elegant/imports.ts'),
@@ -36,17 +35,25 @@ function isGenerated(before, after) {
async function waitForGeneration(beforeMtimes, timeoutMs = 10000) {
const startTime = Date.now();
while (Date.now() - startTime < timeoutMs) {
async function poll() {
const afterMtimes = await getGeneratedFileMtimes();
if (isGenerated(beforeMtimes, afterMtimes)) {
return;
}
await new Promise(resolve => setTimeout(resolve, 100));
if (Date.now() - startTime >= timeoutMs) {
throw new Error('Timed out while waiting for elegant-router generated files.');
}
await new Promise(resolve => {
setTimeout(resolve, 100);
});
await poll();
}
throw new Error('Timed out while waiting for elegant-router generated files.');
await poll();
}
process.chdir(rootDir);