update at 2026-02-10 14:10:20
This commit is contained in:
@@ -9,6 +9,7 @@ const SERVER_CONFIG = {
|
||||
apiPrefix: '/api',
|
||||
fontsManifestPath: '/miniprogram/assets/fonts.json',
|
||||
defaultConfigPath: '/miniprogram/assets/default.json',
|
||||
routeConfigPath: '/miniprogram/assets/route-config.json',
|
||||
}
|
||||
|
||||
function buildOrigin() {
|
||||
@@ -33,16 +34,29 @@ function normalizePath(path, fallback) {
|
||||
return value.startsWith('/') ? value : `/${value}`
|
||||
}
|
||||
|
||||
function buildRuntimeConfig() {
|
||||
const origin = buildOrigin()
|
||||
function normalizeBaseUrl(baseUrl) {
|
||||
const value = String(baseUrl || '').trim()
|
||||
if (!value) {
|
||||
return buildOrigin()
|
||||
}
|
||||
|
||||
const withProtocol = /^https?:\/\//i.test(value) ? value : `https://${value}`
|
||||
return withProtocol.replace(/\/+$/, '')
|
||||
}
|
||||
|
||||
function buildRuntimeConfig(options = {}) {
|
||||
const origin = normalizeBaseUrl(options.baseUrl)
|
||||
const apiPrefix = normalizePath(SERVER_CONFIG.apiPrefix, '/api').replace(/\/$/, '')
|
||||
const fontsManifestPath = normalizePath(SERVER_CONFIG.fontsManifestPath, '/miniprogram/assets/fonts.json')
|
||||
const defaultConfigPath = normalizePath(SERVER_CONFIG.defaultConfigPath, '/miniprogram/assets/default.json')
|
||||
const routeConfigPath = normalizePath(SERVER_CONFIG.routeConfigPath, '/miniprogram/assets/route-config.json')
|
||||
|
||||
return {
|
||||
activeServerKey: String(options.activeServerKey || '').trim(),
|
||||
fontsBaseUrl: origin,
|
||||
fontsManifestUrl: `${origin}${fontsManifestPath}`,
|
||||
defaultConfigUrl: `${origin}${defaultConfigPath}`,
|
||||
routeConfigUrl: `${origin}${routeConfigPath}`,
|
||||
svgRenderApiUrl: `${origin}${apiPrefix}/render-svg`,
|
||||
pngRenderApiUrl: `${origin}${apiPrefix}/render-png`,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user