fix(emergency): 解决消息解析异常问题

- 添加了对消息数据的类型检查
- 添加了JSON解析的异常捕获处理
- 防止非字符串数据导致的解析错误
- 确保消息处理的健壮性
This commit is contained in:
2026-04-10 14:43:29 +08:00
parent 7106e99a7b
commit 3da41ae2d3
+7 -1
View File
@@ -172,7 +172,13 @@
loadingVisible.value = false;
};
window.onmessage = async (msg) => {
const result = JSON.parse(msg.data);
if (!msg.data || typeof msg.data !== 'string') return;
let result: any;
try {
result = JSON.parse(msg.data);
} catch (e) {
return;
}
switch (result.code) {
case 'closeLoading':
closeLoading();