fix(components): 菜单管理调整
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user