mirror of https://github.com/alibaba/ice.git
25 lines
696 B
Plaintext
25 lines
696 B
Plaintext
<% if(appWorkerPath) {-%>import '<%- appWorkerPath %>';<% } -%>
|
|
<% if(!!loaders && !!dataLoader && useAppWorker) {-%>
|
|
import dataloaderConfig from './dataloader-config';
|
|
|
|
addEventListener('beforepageload', async (pageInfos = {}) => {
|
|
const {
|
|
key,
|
|
} = pageInfos.detail || {};
|
|
const config = dataloaderConfig[key];
|
|
if (config) {
|
|
if (typeof config === 'function') {
|
|
const res = await config();
|
|
pha.postMessage(res, '0');
|
|
} else if (Array.isArray(config)) {
|
|
config.forEach(async (item, index) => {
|
|
if (typeof item === 'function') {
|
|
const res = await item();
|
|
pha.postMessage(res, `$index}`);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
<% } -%>
|