Files
Alfred Tang a79ff81be0 fix: resolve chat messages not loading due to Nuxt auto-import bug and WCDB timeout
- Move frontend/utils/ to frontend/lib/ to avoid Nuxt unimport scanner
  incorrectly extracting function parameter names (value, fallback) as
  module-level exports, which injected phantom imports that broke all
  client-side JavaScript execution
- Update all import paths across 13 files from ~/utils/ to ~/lib/
- Add timeout (5s) and negative cache (60s TTL) to WCDB realtime
  ensure_connected() to prevent open_account() from hanging indefinitely
  when the WeChat database is locked
- Reorder selectContact() to fire loadMessages() before navigateTo() so
  the message fetch starts before route navigation triggers Suspense
- Add watch: false to SSR useAsyncData calls to prevent unnecessary
  re-fetching on client-side route changes
2026-03-14 17:17:10 +08:00

36 lines
858 B
JavaScript

export const API_BASE_OVERRIDE_KEY = 'ui.apiBaseOverride'
export const readApiBaseOverride = () => {
if (!process.client) return ''
try {
const raw = localStorage.getItem(API_BASE_OVERRIDE_KEY)
return String(raw || '').trim()
} catch {
return ''
}
}
export const writeApiBaseOverride = (value) => {
if (!process.client) return
try {
const v = String(value || '').trim()
if (!v) localStorage.removeItem(API_BASE_OVERRIDE_KEY)
else localStorage.setItem(API_BASE_OVERRIDE_KEY, v)
} catch {}
}
export const normalizeApiBase = (value) => {
const raw = String(value || '').trim()
if (!raw) return '/api'
let v = raw.replace(/\/$/, '')
// If a full origin is provided, auto-append `/api` when missing.
if (/^https?:\/\//i.test(v) && !/\/api$/i.test(v)) {
v = `${v}/api`
}
return v.replace(/\/$/, '')
}