🔨 优化安装逻辑.

This commit is contained in:
lijiahangmax
2025-12-19 00:32:53 +08:00
parent 58a1a7abd4
commit 1e74659f15
7 changed files with 27 additions and 14 deletions

View File

@@ -50,7 +50,7 @@ export interface HostAgentInstallStatusUpdateRequest {
* 安装主机探针
*/
export function installHostAgent(request: HostInstallAgentRequest) {
return axios.post('/asset/host-agent/install', request);
return axios.post<Record<string, number>>('/asset/host-agent/install', request);
}
/**

View File

@@ -405,7 +405,6 @@
} = useMonitorHostList({
hosts: renderList,
setLoading,
reload,
});
// 重置条件

View File

@@ -456,7 +456,6 @@
} = useMonitorHostList({
hosts: tableRenderData,
setLoading,
reload,
});
// 获取行样式

View File

@@ -16,8 +16,6 @@ export interface UseMonitorHostListOptions {
hosts: Ref<Array<MonitorHostQueryResponse>>;
// 设置加载中
setLoading: (loading: boolean) => void;
// 重新加载
reload: () => void;
}
// 使用监控主机列表
@@ -29,7 +27,7 @@ export default function useMonitorHostList(options: UseMonitorHostListOptions) {
const router = useRouter();
const { toggleDict } = useDictStore();
const { hosts, setLoading, reload } = options;
const { hosts, setLoading } = options;
// 打开详情
const openDetail = (hostId: number, name: string) => {
@@ -65,10 +63,18 @@ export default function useMonitorHostList(options: UseMonitorHostListOptions) {
onOk: async () => {
try {
// 调用安装
await installHostAgent({ idList: hostIdList });
const { data } = await installHostAgent({ idList: hostIdList });
Message.success('开始安装');
// 重新加载
reload();
// 设置状态
installHosts.forEach(host => {
const installId = data[host.agentKey];
if (installId) {
host.installLog = {
id: installId,
eventStatus: AgentLogStatus.WAIT,
} as any;
}
});
} finally {
setLoading(false);
}