-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileLoader.js
37 lines (33 loc) · 1.11 KB
/
fileLoader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = src;
script.onload = () => resolve(src);
script.onerror = () => reject(new Error(`腳本加載失敗: ${src}`));
document.body.appendChild(script);
});
}
const scripts = [
'./dist/lib/bundle.js',
'./dist/components/app.js',
'./dist/components/fileReaders/fileInputs.js',
'./dist/components/fileReaders/xlsx2ppt.js',
'./dist/components/actionButtons/dailySummary.js',
'./dist/components/actionButtons/exportToExcel.js',
'./dist/components/actionButtons/generateReport.js',
'./dist/components/actionButtons/reset.js',
'./dist/components/actionButtons/toggleWidth.js',
'./dist/components/searchBox.js',
];
async function loadAllScripts(scriptArray) {
try {
for (const script of scriptArray) {
await loadScript(script);
console.log(`加載: ${script}`);
}
console.log('全部加載完畢');
} catch (error) {
console.error(error);
}
}
loadAllScripts(scripts);