mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-05 08:05:56 +00:00
Publish page dropdowns (namespace/visibility) failed to open on older Chromium because Vite 6 defaults build target to chrome87 and some bundled deps call runtime APIs absent in Chrome 83 (replaceAll, .at, hasOwn). Lower esbuild/vite target to chrome83, add browserslist, drop ??= in bootstrap, and inject runtime polyfills before main loads.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
/**
|
|
* Bootstraps runtime configuration before the React bundle mounts.
|
|
*
|
|
* Deployments inject `/runtime-config.js` at startup, and this file guarantees the app sees either
|
|
* that config or a safe fallback object before importing the main entry.
|
|
*/
|
|
import './legacy-polyfills'
|
|
async function loadRuntimeConfig() {
|
|
await new Promise<void>((resolve, reject) => {
|
|
const script = document.createElement('script')
|
|
script.src = new URL('../runtime-config.js', import.meta.url).toString()
|
|
script.async = false
|
|
script.onload = () => resolve()
|
|
script.onerror = () => reject(new Error('Failed to load runtime config'))
|
|
document.head.appendChild(script)
|
|
})
|
|
}
|
|
|
|
function ensureRuntimeConfigFallback() {
|
|
if (!window.__SKILLHUB_RUNTIME_CONFIG__) {
|
|
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')
|
|
})()
|