Skip to content

Commit 303c42b

Browse files
committedJan 4, 2025
feat: 优化 RemoteComp 组件的动态 CSS 更新逻辑,增强条件判断以支持不同情况
1 parent 1ace1ba commit 303c42b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed
 

‎src/components/RemoteComp.vue

+6-8
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,12 @@ async function updateRemote() {
104104
throw new Error('Remote content is empty')
105105
}
106106
const vueObj = await compileVue(props.name, remoteContent, props?.rendererOptions?.sfcOptions || {})
107-
if (vueObj.css) {
108-
if (generator.value) {
109-
updateDynamicCss(`${vueObj.css}\n${(await compileCss({ code: remoteContent, unoGenerator: generator.value }))?.output?.css}`)
110-
}
111-
else {
112-
updateDynamicCss(vueObj.css)
113-
}
114-
}
107+
if (generator.value && vueObj.css)
108+
updateDynamicCss(`${vueObj.css}\n${(await compileCss({ code: remoteContent, unoGenerator: generator.value }))?.output?.css}`, `${props.name}-css`)
109+
else if (vueObj.css)
110+
updateDynamicCss(vueObj.css, `${props.name}-css`)
111+
else if (generator.value)
112+
updateDynamicCss(`${(await compileCss({ code: remoteContent, unoGenerator: generator.value }))?.output?.css}`, `${props.name}-css`)
115113
renderedComp.value = getAsyncComponent(async () => (await evalJs(vueObj.js!, '')()), remoteLoading, remoteError)
116114
status.value = remoteStatus.Loaded
117115
}

0 commit comments

Comments
 (0)