fix(emergency): 解决消息解析异常问题
- 添加了对消息数据的类型检查 - 添加了JSON解析的异常捕获处理 - 防止非字符串数据导致的解析错误 - 确保消息处理的健壮性
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user