🔨 优化异常处理逻辑.

This commit is contained in:
lijiahangmax
2025-12-01 09:59:48 +08:00
parent 0ece84bdf1
commit c6b248ab6f
26 changed files with 21 additions and 46 deletions

View File

@@ -58,15 +58,13 @@
// 修改配置 // 修改配置
appStore.updateSettings({ [key]: value }); appStore.updateSettings({ [key]: value });
// 同步偏好 // 同步偏好
try {
await updatePreference({ await updatePreference({
type: 'SYSTEM', type: 'SYSTEM',
item: key, item: key,
value value
}); });
} catch (e) {
}
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@@ -48,7 +48,6 @@
setLoading(true); setLoading(true);
try { try {
treeData.value = await cacheStore.loadHostGroupTree(); treeData.value = await cacheStore.loadHostGroupTree();
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -163,7 +163,6 @@
} }
} }
} }
} catch (e) {
} finally { } finally {
emits('setLoading', false); emits('setLoading', false);
} }
@@ -300,7 +299,6 @@
}); });
// 移动分组 // 移动分组
moveNode(treeData.value, dragNode, dropNode, dropPosition); moveNode(treeData.value, dragNode, dropNode, dropPosition);
} catch (e) {
} finally { } finally {
emits('setLoading', false); emits('setLoading', false);
} }
@@ -312,7 +310,6 @@
emits('setLoading', true); emits('setLoading', true);
const groups = await cacheStore.loadHostGroupTree(force); const groups = await cacheStore.loadHostGroupTree(force);
treeData.value = groups || []; treeData.value = groups || [];
} catch (e) {
} finally { } finally {
emits('setLoading', false); emits('setLoading', false);
} }

View File

@@ -75,7 +75,6 @@
username: s.username, username: s.username,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -57,7 +57,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -160,7 +160,6 @@
hosts.value = data; hosts.value = data;
// 设置主机搜索选项 // 设置主机搜索选项
filterOptions.value = getAuthorizedHostOptions(data.hostList); filterOptions.value = getAuthorizedHostOptions(data.hostList);
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -62,7 +62,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -67,7 +67,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -284,6 +284,7 @@ export default class LogAppender implements ILogAppender {
this.client.close(); this.client.close();
} }
} catch (e) { } catch (e) {
// ignored
} }
} }

View File

@@ -139,7 +139,6 @@
pagination.total = data.total; pagination.total = data.total;
pagination.current = request.page; pagination.current = request.page;
pagination.pageSize = request.limit; pagination.pageSize = request.limit;
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -66,7 +66,6 @@
setVisible(false); setVisible(false);
Message.error('cron 表达式错误'); Message.error('cron 表达式错误');
} }
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -125,7 +125,6 @@
Message.success('回滚成功'); Message.success('回滚成功');
emits('updated'); emits('updated');
handleClear(); handleClear();
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }
@@ -144,7 +143,6 @@
pagination.total = data.total; pagination.total = data.total;
pagination.current = request.page; pagination.current = request.page;
pagination.pageSize = request.limit; pagination.pageSize = request.limit;
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -126,7 +126,6 @@
} }
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -43,7 +43,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -48,7 +48,6 @@
value: s.agentKey, value: s.agentKey,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -37,7 +37,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -70,7 +70,6 @@
origin: s origin: s
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -78,7 +78,6 @@
title: '根目录', title: '根目录',
children: render([...menus]) children: render([...menus])
}]; }];
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -96,10 +96,16 @@
const reloadAllMessage = async () => { const reloadAllMessage = async () => {
hasMore.value = true; hasMore.value = true;
messageList.value = []; messageList.value = [];
try {
await Promise.all([
// 查询数量 // 查询数量
queryMessageCount(); queryMessageCount(),
// 加载列表 // 加载列表
await loadMessage(); loadMessage()
]);
} catch (e) {
console.error('load message error', e);
}
}; };
// 获取数量 // 获取数量
@@ -108,7 +114,6 @@
try { try {
const { data } = await getSystemMessageCount(queryUnread.value); const { data } = await getSystemMessageCount(queryUnread.value);
classifyCount.value = data; classifyCount.value = data;
} catch (ex) {
} finally { } finally {
setFetchLoading(false); setFetchLoading(false);
} }
@@ -135,17 +140,16 @@
limit: messageLimit, limit: messageLimit,
classify: currentClassify.value, classify: currentClassify.value,
queryUnread: queryUnread.value, queryUnread: queryUnread.value,
maxId, maxId
}); });
data.forEach(s => { data.forEach(s => {
messageList.value.push({ messageList.value.push({
...s, ...s,
content: clearHtmlTag(s.content), content: clearHtmlTag(s.content),
contentHtml: replaceHtmlTag(s.content), contentHtml: replaceHtmlTag(s.content)
}); });
}); });
hasMore.value = data.length === messageLimit; hasMore.value = data.length === messageLimit;
} catch (ex) {
} finally { } finally {
setFetchLoading(false); setFetchLoading(false);
} }
@@ -159,7 +163,6 @@
await updateSystemMessageReadAll(currentClassify.value); await updateSystemMessageReadAll(currentClassify.value);
// 修改状态 // 修改状态
messageList.value.forEach(s => s.status = MessageStatus.READ); messageList.value.forEach(s => s.status = MessageStatus.READ);
} catch (ex) {
} finally { } finally {
setMessageLoading(false); setMessageLoading(false);
} }
@@ -171,7 +174,6 @@
try { try {
// 清理消息 // 清理消息
await clearSystemMessage(currentClassify.value); await clearSystemMessage(currentClassify.value);
} catch (ex) {
} finally { } finally {
setMessageLoading(false); setMessageLoading(false);
} }
@@ -204,7 +206,6 @@
// 移除 // 移除
const index = messageList.value.findIndex(s => s.id === message.id); const index = messageList.value.findIndex(s => s.id === message.id);
messageList.value.splice(index, 1); messageList.value.splice(index, 1);
} catch (ex) {
} finally { } finally {
setMessageLoading(false); setMessageLoading(false);
} }
@@ -237,7 +238,7 @@
onUnmounted(() => { onUnmounted(() => {
localStorage.setItem(MESSAGE_CONFIG_KEY, JSON.stringify({ localStorage.setItem(MESSAGE_CONFIG_KEY, JSON.stringify({
currentClassify: currentClassify.value, currentClassify: currentClassify.value,
queryUnread: queryUnread.value, queryUnread: queryUnread.value
})); }));
}); });

View File

@@ -45,7 +45,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -94,7 +94,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -94,7 +94,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -65,7 +65,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -64,7 +64,6 @@
value: s.id, value: s.id,
}; };
}); });
} catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -127,8 +127,6 @@
// 清空 // 清空
handlerClear(); handlerClear();
emits('updated'); emits('updated');
} catch (e) {
return false;
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -180,6 +180,7 @@ export default class TerminalSessionManager implements ITerminalSessionManager {
// 移除 resize 事件 // 移除 resize 事件
removeEventListen(window, 'resize', this.dispatchFitFn); removeEventListen(window, 'resize', this.dispatchFitFn);
} catch (e) { } catch (e) {
// ignored
} }
} }