Skip to content

Commit

Permalink
fix(webui): fix client css not properly loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 15, 2024
1 parent 06b153d commit e045a98
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/client/client/plugins/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ function jsLoader(ctx: Context, exports: {}) {
}

function cssLoader(ctx: Context, link: HTMLLinkElement) {
ctx.effect(() => {
document.head.appendChild(link)
return () => document.head.removeChild(link)
document.head.appendChild(link)
ctx.on('dispose', () => {
document.head.removeChild(link)
})
return new Promise((resolve, reject) => {
link.onload = resolve
link.onerror = reject
})
}

Expand All @@ -45,10 +49,6 @@ const loaders: Dict<LoaderFactory> = {
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = url
await new Promise((resolve, reject) => {
link.onload = resolve
link.onerror = reject
})
return ctx.plugin(cssLoader, link)
},
async [``](ctx, url) {
Expand Down Expand Up @@ -126,6 +126,7 @@ export default class LoaderService extends Service {
} catch (e) {
console.error(e)
}
return
}
}))
task.then(() => this.entries[key].done.value = true)
Expand Down

0 comments on commit e045a98

Please sign in to comment.