mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-15 04:18:20 +00:00
33 lines
843 B
TypeScript
33 lines
843 B
TypeScript
async function loadRuntimeConfig() {
|
|
await new Promise<void>((resolve, reject) => {
|
|
const script = document.createElement('script')
|
|
script.src = '/runtime-config.js'
|
|
script.async = false
|
|
script.onload = () => resolve()
|
|
script.onerror = () => reject(new Error('Failed to load runtime config'))
|
|
document.head.appendChild(script)
|
|
})
|
|
}
|
|
|
|
function ensureRuntimeConfigFallback() {
|
|
window.__SKILLHUB_RUNTIME_CONFIG__ ??= {
|
|
apiBaseUrl: '',
|
|
appBaseUrl: '',
|
|
authDirectEnabled: 'false',
|
|
authDirectProvider: '',
|
|
authSessionBootstrapEnabled: 'false',
|
|
authSessionBootstrapProvider: '',
|
|
authSessionBootstrapAuto: 'false',
|
|
}
|
|
}
|
|
|
|
void (async () => {
|
|
try {
|
|
await loadRuntimeConfig()
|
|
} catch (error) {
|
|
console.error(error)
|
|
ensureRuntimeConfigFallback()
|
|
}
|
|
|
|
await import('./main')
|
|
})()
|