mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: speed up page load
This commit is contained in:
15 files changed
+80
-106
No files matched your search
+4
-12
@@ -1,6 +1,4 @@
|
||||
import { $ } from '@hydrooj/ui-default';
|
||||
|
||||
const { AutoloadPage } = window.Hydro;
|
||||
import { $, addPage, AutoloadPage } from '@hydrooj/ui-default';
|
||||
|
||||
let loaded = false;
|
||||
async function load() {
|
||||
@@ -64,18 +62,12 @@ const loader = (mode) => async (element) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getEles = (types) => {
|
||||
const eles = [];
|
||||
for (const type of types) eles.push(...$(`div[data-${type}]`).get());
|
||||
return eles;
|
||||
};
|
||||
const getEles = (types: string[]) => types.flatMap((type) => $(`div[data-${type}]`).get());
|
||||
|
||||
const page = new AutoloadPage('onlyoffice', async () => {
|
||||
addPage(new AutoloadPage('onlyoffice', async () => {
|
||||
const all = getEles(['doc', 'docx', 'cell', 'xls', 'xlsx', 'slide', 'ppt', 'pptx']);
|
||||
if (all.length) await load();
|
||||
getEles(['doc', 'docx']).forEach(loader('word'));
|
||||
getEles(['cell', 'xls', 'xlsx']).forEach(loader('cell'));
|
||||
getEles(['slide', 'ppt', 'pptx']).forEach(loader('slide'));
|
||||
});
|
||||
|
||||
window.Hydro.extraPages.push(page);
|
||||
}));
|
||||
Reference in new issue
Block a user