🔨 优化异常处理逻辑.

This commit is contained in:
lijiahangmax
2025-12-04 15:31:11 +08:00
parent 14dc8e0407
commit d1cb056adf
26 changed files with 18 additions and 67 deletions

View File

@@ -175,7 +175,6 @@
// 无数据
Message.warning('当前条件未查询到数据');
}
} catch (e) {
} finally {
setLoading(false);
}
@@ -195,7 +194,6 @@
Message.success(`已成功清理 ${data} 条数据`);
emits('clear');
handleClose();
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -104,8 +104,6 @@
emits('handled', { ...formModel.value });
handleClose();
return true;
} catch (e) {
return false;
} finally {
setLoading(false);
}

View File

@@ -302,7 +302,6 @@
props.tableData.filter(s => idList.includes(s.id)).forEach(s => {
s.falseAlarm = FalseAlarm.TRUE;
});
} catch (e) {
} finally {
emits('setLoading', false);
}
@@ -324,7 +323,6 @@
selectedKeys.value = [];
// 重新加载
emits('query');
} catch (e) {
} finally {
emits('setLoading', false);
}

View File

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

View File

@@ -116,7 +116,6 @@
setLoading(true);
const { data } = await getAlarmPolicy(id);
formModel.value = assignOmitRecord(data);
} catch (e) {
} finally {
setLoading(false);
}
@@ -151,8 +150,6 @@
}
// 清空
handlerClear();
} catch (e) {
return false;
} finally {
setLoading(false);
}

View File

@@ -188,7 +188,6 @@
Message.success('删除成功');
// 重新加载
reload();
} catch (e) {
} finally {
setLoading(false);
}
@@ -211,7 +210,6 @@
pagination.total = data.total;
pagination.current = request.page;
pagination.pageSize = request.limit;
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -397,8 +397,6 @@
}
handleClose();
return true;
} catch (e) {
return false;
} finally {
setLoading(false);
}

View File

@@ -185,7 +185,6 @@
Message.success('删除成功');
// 重新加载
reload();
} catch (e) {
} finally {
setLoading(false);
}
@@ -217,7 +216,6 @@
ruleSwitch: checked
});
record.ruleSwitch = checked;
} catch (e) {
} finally {
setLoading(false);
}
@@ -237,28 +235,25 @@
setLoading(true);
const { data } = await getAlarmRuleList(policyId.value, measurement.value);
tableRenderData.value = data;
} catch (e) {
} finally {
setLoading(false);
}
};
onMounted(() => {
try {
// 解析参数
const route = useRoute();
policyId.value = Number.parseInt(route.query.id as string);
policyName.value = route.query.name as string;
// 重新加载数据
reload();
} catch (e) {
}
// 解析参数
const route = useRoute();
policyId.value = Number.parseInt(route.query.id as string);
policyName.value = route.query.name as string;
// 重新加载数据
reload();
});
</script>
<style lang="less" scoped>
@measurement-card-width: 120px;
.container-content {
display: flex;
}

View File

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

View File

@@ -178,7 +178,6 @@
Message.success('删除成功');
// 重新加载
reload();
} catch (e) {
} finally {
setLoading(false);
}
@@ -201,7 +200,6 @@
pagination.total = data.total;
pagination.current = request.page;
pagination.pageSize = request.limit;
} catch (e) {
} finally {
setLoading(false);
}

View File

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

View File

@@ -457,7 +457,6 @@
try {
renderLoading.value = true;
await reload();
} catch (e) {
} finally {
renderLoading.value = false;
}

View File

@@ -160,10 +160,7 @@
}
// 顺序刷新
for (const chunk of chunks) {
try {
await Promise.all(chunk.map(s => s.refresh()));
} catch (e) {
}
await Promise.all(chunk.map(s => s?.refresh?.()));
}
};

View File

@@ -220,6 +220,9 @@
});
series.value = data;
} catch (e) {
console.error('load metrics error', e);
series.value = [];
return e;
} finally {
setLoading(false);
}

View File

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

View File

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

View File

@@ -487,7 +487,6 @@
await updateMonitorHostAlarmSwitch({ idList, alarmSwitch });
rows.forEach(s => s.alarmSwitch = alarmSwitch);
Message.success(`已${label}`);
} catch (e) {
} finally {
setLoading(false);
}
@@ -505,7 +504,6 @@
pagination.current = request.page;
pagination.pageSize = request.limit;
selectedKeys.value = [];
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -73,8 +73,6 @@
// 清空
handlerClear();
return true;
} catch (e) {
return false;
} finally {
setLoading(false);
}

View File

@@ -1,4 +1,4 @@
import type { MonitorHostQueryResponse, } from '@/api/monitor/monitor-host';
import type { MonitorHostQueryResponse } from '@/api/monitor/monitor-host';
import { getMonitorHostMetrics, updateMonitorHostAlarmSwitch } from '@/api/monitor/monitor-host';
import type { HostAgentLogResponse } from '@/api/asset/host-agent';
import { getAgentInstallLogStatus, getHostAgentStatus, installHostAgent, updateAgentInstallStatus } from '@/api/asset/host-agent';
@@ -69,13 +69,11 @@ export default function useMonitorHostList(options: UseMonitorHostListOptions) {
Message.success('开始安装');
// 重新加载
reload();
} catch (e) {
} finally {
setLoading(false);
}
}
});
} catch (e) {
} finally {
setLoading(false);
}
@@ -99,7 +97,6 @@ export default function useMonitorHostList(options: UseMonitorHostListOptions) {
});
log.status = AgentLogStatus.SUCCESS;
Message.success('状态已修正');
} catch (e) {
} finally {
setLoading(false);
}
@@ -126,7 +123,6 @@ export default function useMonitorHostList(options: UseMonitorHostListOptions) {
});
record.alarmSwitch = newSwitch;
Message.success(`${dict.label}`);
} catch (e) {
} finally {
setLoading(false);
}
@@ -178,6 +174,7 @@ export default function useMonitorHostList(options: UseMonitorHostListOptions) {
});
});
} catch (e) {
// ignored
}
}
};
@@ -199,6 +196,7 @@ export default function useMonitorHostList(options: UseMonitorHostListOptions) {
});
});
} catch (e) {
// ignored
}
}
};

View File

@@ -74,7 +74,6 @@
try {
const { data } = await getSystemAppInfo();
app.value = data;
} catch (e) {
} finally {
setLoading(false);
}
@@ -86,6 +85,7 @@
const { data } = await getAppLatestRelease();
repo.value = data;
} catch (e) {
// ignored
}
});

View File

@@ -121,7 +121,6 @@
settings: setting.value
});
Message.success('修改成功');
} catch (e) {
} finally {
setLoading(false);
}
@@ -137,7 +136,6 @@
'auto-clear.exec-log.keep-days': toAnonymousNumber(data['auto-clear.exec-log.keep-days']),
'auto-clear.terminal-log.keep-days': toAnonymousNumber(data['auto-clear.terminal-log.keep-days']),
};
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -84,7 +84,6 @@
settings: { ...setting.value }
});
Message.success('修改成功');
} catch (e) {
} finally {
setLoading(false);
}
@@ -97,7 +96,6 @@
const { data } = await generatorKeypair();
setting.value['encrypt.public-key'] = data.publicKey;
setting.value['encrypt.private-key'] = data.privateKey;
} catch (e) {
} finally {
setLoading(false);
}
@@ -111,7 +109,6 @@
setting.value = {
...data
};
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -126,7 +126,6 @@
settings: setting.value
});
Message.success('修改成功');
} catch (e) {
} finally {
setLoading(false);
}
@@ -143,7 +142,6 @@
'log.tracker-load-interval': toAnonymousNumber(data['log.tracker-load-interval']),
'log.tracker-load-lines': toAnonymousNumber(data['log.tracker-load-lines']),
};
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -181,7 +181,7 @@
<script lang="ts">
export default {
name: 'loginSetting',
name: 'loginSetting'
};
</script>
@@ -213,7 +213,6 @@
settings: setting.value
});
Message.success('修改成功');
} catch (e) {
} finally {
setLoading(false);
}
@@ -233,7 +232,6 @@
'login.login-failed-lock-time': toAnonymousNumber(data['login.login-failed-lock-time']),
'login.login-failed-send-threshold': toAnonymousNumber(data['login.login-failed-send-threshold']),
};
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -100,7 +100,6 @@
settings: setting.value,
});
Message.success('修改成功');
} catch (e) {
} finally {
setLoading(false);
}
@@ -115,7 +114,6 @@
...data,
'sftp.preview-size': toAnonymousNumber(data['sftp.preview-size']),
};
} catch (e) {
} finally {
setLoading(false);
}

View File

@@ -91,11 +91,8 @@
// 加载用户主题
onMounted(async () => {
try {
const { data } = await getPreference<Record<string, any>>('TERMINAL', [TerminalPreferenceItem.SSH_THEME]);
currentThemeName.value = data[TerminalPreferenceItem.SSH_THEME]?.name;
} catch (e) {
}
const { data } = await getPreference<Record<string, any>>('TERMINAL', [TerminalPreferenceItem.SSH_THEME]);
currentThemeName.value = data[TerminalPreferenceItem.SSH_THEME]?.name;
});
// 加载主题列表
@@ -110,7 +107,6 @@
result.push(subArray);
}
themes.value = result;
} catch (e) {
} finally {
setLoading(false);
}