ui: pageLoader: support moduleName

This commit is contained in:
undefined committed 2022-03-15 13:59:16 +08:00
1 parent 0569a98739
commit ab3cad57b8
6 files changed
+56 -33

No files matched your search

+13 -4
View File
@@ -50,10 +50,19 @@ async function load() {
...buildSequence(includedPages, 'after'),
...buildSequence(currentPage, 'after'),
];
const loadPage = (depth: number, type: 'before' | 'after') => async (name: string) => {
if (depth > 32) {
console.error('loadPage depth', depth);
return;
}
for (const { func } of buildSequence(pageLoader.getPage(name), type)) {
await func(name, loadPage(depth + 1, type));
}
};
for (const { page, func, type } of loadSequence) {
const ts = new Date().getTime();
const ts = Date.now();
try {
await func(currentPageName);
await func(currentPageName, loadPage(1, type));
} catch (e) {
Notification.warn(`Failed to call '${type}Loading' of ${page.name}`);
console.error(`Failed to call '${type}Loading' of ${page.name}\n${e.stack}`);
@@ -61,7 +70,7 @@ async function load() {
if (process.env.NODE_ENV !== 'production') {
console.time(`${page.name}: ${type}Loading`);
}
const time = new Date().getTime() - ts;
const time = Date.now() - ts;
if ((process.env.NODE_ENV !== 'production' && time > 16) || time > 256) {
console.log(`${page.name}: ${type}Loading took ${time}ms`);
}
@@ -71,7 +80,7 @@ async function load() {
$element: $(section),
}));
$('.page-loader').hide();
console.log('done! %d ms', new Date().getTime() - start.getTime());
console.log('done! %d ms', Date.now() - start.getTime());
for (const { $element, shouldDelay } of sections) {
$element.addClass('visible');
if (shouldDelay) await delay(50);