fix: 修复小程序编译兼容性问题

- 修改 tsconfig.json target 为 ES2019
- 修改 vite.config.ts 添加 build.target 和 esbuild.target 为 es2015
- 重写 currency.ts getCurrencySymbol 函数,避免使用可选链和空值合并操作符
This commit is contained in:
claw_bot 2026-03-24 06:06:24 +00:00
parent fa2fa98985
commit 365c461ea4
3 changed files with 17 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ESNext", "target": "ES2019",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"module": "ESNext", "module": "ESNext",
"moduleResolution": "bundler", "moduleResolution": "bundler",
@ -9,10 +9,9 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"esModuleInterop": true, "esModuleInterop": true,
"lib": ["ESNext", "DOM"], "lib": ["ES2019", "DOM"],
"skipLibCheck": true, "skipLibCheck": true,
"noEmit": true, "noEmit": true,
"ignoreDeprecations": "6.0",
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["./*"], "@/*": ["./*"],

View File

@ -21,7 +21,9 @@ const CURRENCY_SYMBOLS: Record<string, string> = {
* @returns * @returns
*/ */
export function getCurrencySymbol(currency?: string): string { export function getCurrencySymbol(currency?: string): string {
return CURRENCY_SYMBOLS[currency?.toUpperCase() ?? 'CNY'] || '¥'; // 兼容小程序:避免使用 ?. 和 ??
const code = currency ? currency.toUpperCase() : 'CNY';
return CURRENCY_SYMBOLS[code] || '¥';
} }
/** /**

View File

@ -10,5 +10,17 @@ export default defineConfig({
'@/utils': '/home/node/.openclaw/workspace/AssetManager/AssetManager.UniApp/utils', '@/utils': '/home/node/.openclaw/workspace/AssetManager/AssetManager.UniApp/utils',
'@/types': '/home/node/.openclaw/workspace/AssetManager/AssetManager.UniApp/types' '@/types': '/home/node/.openclaw/workspace/AssetManager/AssetManager.UniApp/types'
} }
},
build: {
// 小程序兼容性:转译 ES2019+ 语法
target: 'es2015',
minify: 'terser',
terserOptions: {
ecma: 2015
}
},
esbuild: {
// 确保可选链和空值合并被转译
target: 'es2015'
} }
}) })