feat: make asset support es module

This commit is contained in:
rainke 2023-10-16 16:59:03 +08:00 committed by 刘菊萍(絮黎)
parent 7677ad0166
commit d56ed6bff1
2 changed files with 4 additions and 2 deletions

View File

@ -56,12 +56,13 @@ export function createSimulator(
}
const id = asset.id ? ` data-id="${asset.id}"` : '';
const lv = asset.level || level || AssetLevel.Environment;
const scriptType = asset.scriptType ? ` type="${asset.scriptType}"` : '';
if (asset.type === AssetType.JSUrl) {
scripts[lv].push(
`<script src="${asset.content}"${id}></script>`,
`<script src="${asset.content}"${id}${scriptType}></script>`,
);
} else if (asset.type === AssetType.JSText) {
scripts[lv].push(`<script${id}>${asset.content}</script>`);
scripts[lv].push(`<script${id}${scriptType}>${asset.content}</script>`);
} else if (asset.type === AssetType.CSSUrl) {
styles[lv].push(
`<link rel="stylesheet" href="${asset.content}"${id} />`,

View File

@ -38,6 +38,7 @@ export interface AssetItem {
device?: string;
level?: AssetLevel;
id?: string;
scriptType?: string;
}
export type AssetList = Array<Asset | undefined | null>;