From 61a2db936dcbc3d5aebe8ff850bcaab76e3b3785 Mon Sep 17 00:00:00 2001 From: zhangwencui <1064582902@qq.com> Date: 星期一, 15 六月 2026 11:09:18 +0800 Subject: [PATCH] 合并恢复 --- debug-uniapp-white-screen.md | 81 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 81 insertions(+), 0 deletions(-) diff --git a/debug-uniapp-white-screen.md b/debug-uniapp-white-screen.md new file mode 100644 index 0000000..ad27ada --- /dev/null +++ b/debug-uniapp-white-screen.md @@ -0,0 +1,81 @@ +# Debug Session: uniapp-white-screen + +**Status:** [OPEN] +**Created:** 2026-05-28 + +## Problem Description + +UniApp 鐪熸満杩愯鎶ラ敊鐧藉睆锛� +``` +reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack -> + at s (app-service.js:15:401) + at (app-service.js:942:153013) + at (app-service.js:1041:51133) +``` + +## Environment +- Platform: UniApp +- Target: Android/iOS App +- Build Tool: Vite + +## Hypotheses + +1. **H1: SCSS/棰勫鐞嗗櫒閰嶇疆闂** - `modern-compiler` API 涓嶅吋瀹圭湡鏈虹幆澧� + - Status: Tested, changed to `legacy`, issue persists + +2. **H2: JavaScript 璇硶鍏煎鎬ч棶棰�** - 浣跨敤浜嗙湡鏈� JavaScriptCore 涓嶆敮鎸佺殑 ES6+ 璇硶 + - Observation Points: 妫�鏌ュ彲閫夐摼鎿嶄綔绗� `?.`銆佺┖鍊煎悎骞� `??`銆丅igInt 绛� + +3. **H3: 鏌愪釜椤甸潰鎴栫粍浠跺瓨鍦ㄨ娉曢敊璇�** - 鐗瑰畾鏂囦欢鐨勮娉曢敊璇鑷存暣涓簲鐢ㄦ棤娉曞惎鍔� + - Observation Points: 妫�鏌ユ渶杩戜慨鏀圭殑鏂囦欢锛岀壒鍒槸 works.vue + +4. **H4: 渚濊禆鍖呯増鏈笉鍏煎** - 鏌愪簺 npm 鍖呬娇鐢ㄤ簡涓嶅吋瀹圭湡鏈虹殑璇硶 + - Observation Points: 妫�鏌� package.json 涓殑渚濊禆鐗堟湰 + +5. **H5: 鏋勫缓浜х墿鎹熷潖鎴栫紦瀛橀棶棰�** - 闇�瑕佹竻闄ょ紦瀛橀噸鏂版瀯寤� + - Observation Points: 妫�鏌� dist 鐩綍鍜屾瀯寤烘棩蹇� + +## Evidence Log + +### Step 1: Initial Analysis +- File works.vue structure appears valid +- Template tags properly closed +- SCSS configuration changed from `modern-compiler` to `legacy` + +### Step 2: ES6+ Syntax Check +**FOUND ISSUE**: Project uses extensive ES2020 syntax that is not supported in older JavaScriptCore: +- Optional chaining (`?.`) - found 100+ occurrences +- Nullish coalescing (`??`) - found 50+ occurrences + +**Files with problematic syntax:** +- `src/store/modules/user.ts` +- `src/utils/versionUpgrade.js` +- `src/pages/sales/salesQuotation/*.vue` +- `src/pages/productionManagement/**/*.vue` +- `src/pages/oa/_utils/*.js` +- Many more... + +### Step 3: Fix Applied +Updated `vite.config.js` to set build target to ES2015 to ensure proper transpilation of ES2020 syntax. + +### Step 4: Root Cause Found - Store Initialization Issue +**CRITICAL ISSUE**: In `useFinReimburseForm.js`, `useUserStore()` was called at module level (line 37), which causes Pinia store initialization before Vue app context is ready. + +**This is the main cause of `createInstanceContext failed` error!** + +### Step 5: Fix Applied +- Modified `useFinReimburseForm.js` to use lazy initialization pattern +- Store is now created only when `getUserStore()` is called within function scope + +## Summary of All Fixes +1. 鉁� vite.config.js - SCSS api changed to `legacy` +2. 鉁� vite.config.js - Build target set to `es2015` +3. 鉁� App.vue - Changed `<div>` to `<view>` +4. 鉁� user.ts - Fixed optional chaining syntax +5. 鉁� versionUpgrade.js - Fixed optional chaining and nullish coalescing syntax +6. 鉁� useFinReimburseForm.js - Fixed store initialization timing + +## Next Steps +1. Clear build cache: `rd /s /q dist` +2. Rebuild and test on real device +3. If still failing, check for other module-level store calls -- Gitblit v1.9.3