diff --git a/orion-ops-ui/src/api/asset/host-identity.ts b/orion-ops-ui/src/api/asset/host-identity.ts index 54055a75..0822a42b 100644 --- a/orion-ops-ui/src/api/asset/host-identity.ts +++ b/orion-ops-ui/src/api/asset/host-identity.ts @@ -1,5 +1,4 @@ import axios from 'axios'; -import qs from 'query-string'; import { DataGrid, Pagination } from '@/types/global'; /** @@ -71,7 +70,7 @@ export function getHostIdentity(id: number) { * 查询主机身份 */ export function getHostIdentityList() { - return axios.post>('/asset/host-identity/list'); + return axios.get>('/asset/host-identity/list'); } /** diff --git a/orion-ops-ui/src/api/asset/host-key.ts b/orion-ops-ui/src/api/asset/host-key.ts index 88ee9ad2..41e1a625 100644 --- a/orion-ops-ui/src/api/asset/host-key.ts +++ b/orion-ops-ui/src/api/asset/host-key.ts @@ -67,7 +67,7 @@ export function getHostKey(id: number) { * 查询主机秘钥 */ export function getHostKeyList() { - return axios.post>('/asset/host-key/list'); + return axios.get>('/asset/host-key/list'); } /** diff --git a/orion-ops-ui/src/components/asset/host-identity/host-identity-selector.vue b/orion-ops-ui/src/components/asset/host-identity/host-identity-selector.vue new file mode 100644 index 00000000..6b9a9273 --- /dev/null +++ b/orion-ops-ui/src/components/asset/host-identity/host-identity-selector.vue @@ -0,0 +1,52 @@ + + + + + + + diff --git a/orion-ops-ui/src/hooks/favorite.ts b/orion-ops-ui/src/hooks/favorite.ts index 3032f5c0..ab10cae9 100644 --- a/orion-ops-ui/src/hooks/favorite.ts +++ b/orion-ops-ui/src/hooks/favorite.ts @@ -17,6 +17,7 @@ export default function useFavorite(type: FavoriteType) { record[cancelField] = true; Message.success('已收藏'); } + } catch (e) { } finally { loading.close(); } diff --git a/orion-ops-ui/src/store/modules/cache/index.ts b/orion-ops-ui/src/store/modules/cache/index.ts index c020dcab..9499e70e 100644 --- a/orion-ops-ui/src/store/modules/cache/index.ts +++ b/orion-ops-ui/src/store/modules/cache/index.ts @@ -1,7 +1,7 @@ import { defineStore } from 'pinia'; import { CacheState } from './types'; -export type CacheType = 'menus' | 'roles' | 'tags' | 'hostKeys' +export type CacheType = 'menus' | 'roles' | 'tags' | 'hostKeys' | 'hostIdentities' const useCacheStore = defineStore('cache', { state: (): CacheState => ({ @@ -9,6 +9,7 @@ const useCacheStore = defineStore('cache', { roles: [], tags: [], hostKeys: [], + hostIdentities: [], }), getters: {}, diff --git a/orion-ops-ui/src/store/modules/cache/types.ts b/orion-ops-ui/src/store/modules/cache/types.ts index b3b5b85e..76cd7dd3 100644 --- a/orion-ops-ui/src/store/modules/cache/types.ts +++ b/orion-ops-ui/src/store/modules/cache/types.ts @@ -2,12 +2,14 @@ import { MenuQueryResponse } from '@/api/system/menu'; import { RoleQueryResponse } from '@/api/user/role'; import { TagQueryResponse } from '@/api/meta/tag'; import { HostKeyQueryResponse } from '@/api/asset/host-key'; +import { HostIdentityQueryResponse } from '@/api/asset/host-identity'; export interface CacheState { menus: MenuQueryResponse[]; roles: RoleQueryResponse[]; tags: TagQueryResponse[]; hostKeys: HostKeyQueryResponse[]; + hostIdentities: HostIdentityQueryResponse[]; [key: string]: unknown; } diff --git a/orion-ops-ui/src/store/modules/user/index.ts b/orion-ops-ui/src/store/modules/user/index.ts index 589a8f3c..a50d09d7 100644 --- a/orion-ops-ui/src/store/modules/user/index.ts +++ b/orion-ops-ui/src/store/modules/user/index.ts @@ -70,6 +70,7 @@ const useUserStore = defineStore('user', { async logout() { try { await userLogout(); + } catch (e) { } finally { // 登出回调 this.logoutCallBack(); diff --git a/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue index b262ed65..6883f7a4 100644 --- a/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue +++ b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue @@ -109,7 +109,9 @@ // 渲染表单 const renderForm = (record: any) => { Object.keys(formModel).forEach(k => { - formModel[k] = record[k]; + if (record.hasOwnProperty(k)) { + formModel[k] = record[k]; + } }); }; diff --git a/orion-ops-ui/src/views/asset/host-identity/components/host-identity-table.vue b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-table.vue index 061331d4..eec2f990 100644 --- a/orion-ops-ui/src/views/asset/host-identity/components/host-identity-table.vue +++ b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-table.vue @@ -156,6 +156,7 @@ Message.success('删除成功'); // 重新加载数据 await fetchTableData(); + } catch (e) { } finally { setLoading(false); } @@ -184,6 +185,7 @@ pagination.total = data.total; pagination.current = request.page; pagination.pageSize = request.limit; + } catch (e) { } finally { setLoading(false); } @@ -197,8 +199,11 @@ // 获取主机秘钥列表 const fetchHostKeyList = async () => { - const { data } = await getHostKeyList(); - cacheStore.set('hostKeys', data); + try { + const { data } = await getHostKeyList(); + cacheStore.set('hostKeys', data); + } catch (e) { + } }; fetchHostKeyList(); diff --git a/orion-ops-ui/src/views/asset/host-key/components/host-key-form-drawer.vue b/orion-ops-ui/src/views/asset/host-key/components/host-key-form-drawer.vue index 3853a723..688eaf0c 100644 --- a/orion-ops-ui/src/views/asset/host-key/components/host-key-form-drawer.vue +++ b/orion-ops-ui/src/views/asset/host-key/components/host-key-form-drawer.vue @@ -163,7 +163,9 @@ // 渲染表单 const renderForm = (record: any) => { Object.keys(formModel).forEach(k => { - formModel[k] = record[k]; + if (record.hasOwnProperty(k)) { + formModel[k] = record[k]; + } }); }; diff --git a/orion-ops-ui/src/views/asset/host-key/components/host-key-table.vue b/orion-ops-ui/src/views/asset/host-key/components/host-key-table.vue index ec1b6cb7..e322eae8 100644 --- a/orion-ops-ui/src/views/asset/host-key/components/host-key-table.vue +++ b/orion-ops-ui/src/views/asset/host-key/components/host-key-table.vue @@ -124,6 +124,7 @@ Message.success('删除成功'); // 重新加载数据 await fetchTableData(); + } catch (e) { } finally { setLoading(false); } @@ -152,6 +153,7 @@ pagination.total = data.total; pagination.current = request.page; pagination.pageSize = request.limit; + } catch (e) { } finally { setLoading(false); } diff --git a/orion-ops-ui/src/views/asset/host/components/host-config-drawer.vue b/orion-ops-ui/src/views/asset/host/components/host-config-drawer.vue index d4138562..a2e0946f 100644 --- a/orion-ops-ui/src/views/asset/host/components/host-config-drawer.vue +++ b/orion-ops-ui/src/views/asset/host/components/host-config-drawer.vue @@ -35,9 +35,13 @@ import { Message } from '@arco-design/web-vue'; import { getHostConfigAll } from '@/api/asset/host'; import HostConfigSshForm from './host-config-ssh-form.vue'; + import { useCacheStore } from '@/store'; + import { getHostKeyList } from '@/api/asset/host-key'; + import { getHostIdentityList } from '@/api/asset/host-identity'; const { visible, setVisible } = useVisible(); const { loading, setLoading } = useLoading(); + const cacheStore = useCacheStore(); const record = ref(); const config = ref>({}); @@ -61,23 +65,34 @@ } }; - const handleOk = () => { - console.log('ok'); - setLoading(true); - setTimeout(() => { - setVisible(false); - setLoading(false); - }, 1000); - }; - + // 关闭 const handleCancel = () => { - console.log('cancel'); setLoading(false); setVisible(false); }; defineExpose({ open }); + // 加载主机秘钥 + const fetchHostKeys = async () => { + try { + const { data } = await getHostKeyList(); + cacheStore.set('hostKeys', data); + } catch (e) { + } + }; + fetchHostKeys(); + + // 加载主机身份 + const fetchHostIdentities = async () => { + try { + const { data } = await getHostIdentityList(); + cacheStore.set('hostIdentities', data); + } catch (e) { + } + }; + fetchHostIdentities(); + diff --git a/orion-ops-ui/src/views/asset/host/components/host-form-modal.vue b/orion-ops-ui/src/views/asset/host/components/host-form-modal.vue index b999d35b..46fe08e6 100644 --- a/orion-ops-ui/src/views/asset/host/components/host-form-modal.vue +++ b/orion-ops-ui/src/views/asset/host/components/host-form-modal.vue @@ -101,7 +101,9 @@ // 渲染表单 const renderForm = (record: any) => { Object.keys(formModel).forEach(k => { - formModel[k] = record[k]; + if (record.hasOwnProperty(k)) { + formModel[k] = record[k]; + } }); }; diff --git a/orion-ops-ui/src/views/asset/host/components/host-table.vue b/orion-ops-ui/src/views/asset/host/components/host-table.vue index cbde33b6..55e72d6b 100644 --- a/orion-ops-ui/src/views/asset/host/components/host-table.vue +++ b/orion-ops-ui/src/views/asset/host/components/host-table.vue @@ -197,6 +197,7 @@ Message.success('删除成功'); // 重新加载数据 await fetchTableData(); + } catch (e) { } finally { setLoading(false); } @@ -225,6 +226,7 @@ pagination.total = data.total; pagination.current = request.page; pagination.pageSize = request.limit; + } catch (e) { } finally { setLoading(false); } diff --git a/orion-ops-ui/src/views/asset/host/index.vue b/orion-ops-ui/src/views/asset/host/index.vue index 1cdcbe5d..e55ca64b 100644 --- a/orion-ops-ui/src/views/asset/host/index.vue +++ b/orion-ops-ui/src/views/asset/host/index.vue @@ -35,6 +35,8 @@ onUnmounted(() => { const cacheStore = useCacheStore(); cacheStore.set('tags', []); + cacheStore.set('hostKeys', []); + cacheStore.set('hostIdentities', []); }); diff --git a/orion-ops-ui/src/views/asset/host/types/host-config.rules.ts b/orion-ops-ui/src/views/asset/host/types/host-config.rules.ts new file mode 100644 index 00000000..83c0f3f5 --- /dev/null +++ b/orion-ops-ui/src/views/asset/host/types/host-config.rules.ts @@ -0,0 +1,71 @@ +import { FieldRule } from '@arco-design/web-vue'; + +export const port = [{ + required: true, + message: '请输入SSH端口' +}, { + type: 'number', + min: 1, + max: 65535, + message: '输入的端口不合法' +}] as FieldRule[]; + +export const authType = [{ + required: true, + message: '请选择认证方式' +}] as FieldRule[]; + +export const keyId = [{ + required: true, + message: '请选择主机秘钥' +}] as FieldRule[]; + +export const identityId = [{ + required: true, + message: '请选择主机身份' +}] as FieldRule[]; + +export const connectTimeout = [{ + required: true, + message: '请输入连接超时时间' +}, { + type: 'number', + min: 0, + max: 100000, + message: '连接超时时间需要在 0 - 100000 之间' +}] as FieldRule[]; + +export const charset = [{ + required: true, + message: '请输入SSH输出编码' +}, { + maxLength: 12, + message: 'SSH输出编码长度不能超过12位' +}] as FieldRule[]; + +export const fileNameCharset = [{ + required: true, + message: '请输入文件名称编码' +}, { + maxLength: 12, + message: '文件名称编码长度不能超过12位' +}] as FieldRule[]; + +export const fileContentCharset = [{ + required: true, + message: '请输入SSH输出编码' +}, { + maxLength: 12, + message: '文件内容编码长度不能超过12位' +}] as FieldRule[]; + +export const sshRules = { + port, + authType, + keyId, + identityId, + connectTimeout, + charset, + fileNameCharset, + fileContentCharset, +} as Record; diff --git a/orion-ops-ui/src/views/asset/host/types/host-config.types.ts b/orion-ops-ui/src/views/asset/host/types/host-config.types.ts new file mode 100644 index 00000000..9f43f8a1 --- /dev/null +++ b/orion-ops-ui/src/views/asset/host/types/host-config.types.ts @@ -0,0 +1,33 @@ +/** + * 验证方式 + */ +export const AuthTypeEnum = { + PASSWORD: { + value: 'PASSWORD', + label: '密码验证', + }, + KEY: { + value: 'KEY', + label: '秘钥验证', + }, + IDENTITY: { + value: 'IDENTITY', + label: '身份验证', + }, +}; + +/** + * 主机 SSH 配置 + */ +export interface HostSshConfig { + port?: number; + username?: string; + password?: string; + authType?: string; + identityId?: number; + keyId?: number; + connectTimeout?: number; + charset?: string; + fileNameCharset?: string; + fileContentCharset?: string; +} diff --git a/orion-ops-ui/src/views/system/menu/components/menu-form-modal.vue b/orion-ops-ui/src/views/system/menu/components/menu-form-modal.vue index 9cb9ce2a..14240041 100644 --- a/orion-ops-ui/src/views/system/menu/components/menu-form-modal.vue +++ b/orion-ops-ui/src/views/system/menu/components/menu-form-modal.vue @@ -186,7 +186,9 @@ // 渲染表单 const renderForm = (record: any) => { Object.keys(formModel).forEach(k => { - formModel[k] = record[k]; + if (record.hasOwnProperty(k)) { + formModel[k] = record[k]; + } }); }; diff --git a/orion-ops-ui/src/views/system/menu/components/menu-table.vue b/orion-ops-ui/src/views/system/menu/components/menu-table.vue index 92e7654e..fd3c0d6b 100644 --- a/orion-ops-ui/src/views/system/menu/components/menu-table.vue +++ b/orion-ops-ui/src/views/system/menu/components/menu-table.vue @@ -235,6 +235,7 @@ } } Message.success('删除成功'); + } catch (e) { } finally { setFetchLoading(false); } @@ -261,6 +262,7 @@ const { data } = await getMenuList(formModel); tableRenderData.value = data as MenuQueryResponse[]; cacheStore.set('menus', tableRenderData.value); + } catch (e) { } finally { setFetchLoading(false); } @@ -284,6 +286,7 @@ setFetchLoading(true); await initCache(); Message.success('刷新成功'); + } catch (e) { } finally { setFetchLoading(false); } diff --git a/orion-ops-ui/src/views/user/role/components/role-form-modal.vue b/orion-ops-ui/src/views/user/role/components/role-form-modal.vue index d724f847..5290d0b0 100644 --- a/orion-ops-ui/src/views/user/role/components/role-form-modal.vue +++ b/orion-ops-ui/src/views/user/role/components/role-form-modal.vue @@ -85,7 +85,9 @@ // 渲染表单 const renderForm = (record: any) => { Object.keys(formModel).forEach(k => { - formModel[k] = record[k]; + if (record.hasOwnProperty(k)) { + formModel[k] = record[k]; + } }); }; diff --git a/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue b/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue index 1f26469d..4049682a 100644 --- a/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue +++ b/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue @@ -79,6 +79,7 @@ // 获取角色菜单 const { data: roleMenuIdList } = await getRoleMenuId(record.id); tree.value.init(roleMenuIdList); + } catch (e) { } finally { setLoading(false); } diff --git a/orion-ops-ui/src/views/user/role/components/role-table.vue b/orion-ops-ui/src/views/user/role/components/role-table.vue index d5b239e7..d5da29dd 100644 --- a/orion-ops-ui/src/views/user/role/components/role-table.vue +++ b/orion-ops-ui/src/views/user/role/components/role-table.vue @@ -159,6 +159,7 @@ Message.success(`${toggleStatus.label}成功`); // 修改行状态 record.status = toggleStatus.value; + } catch (e) { } finally { setLoading(false); } @@ -173,6 +174,7 @@ Message.success('删除成功'); // 重新加载数据 await fetchTableData(); + } catch (e) { } finally { setLoading(false); } @@ -201,6 +203,7 @@ pagination.total = data.total; pagination.current = request.page; pagination.pageSize = request.limit; + } catch (e) { } finally { setLoading(false); } diff --git a/orion-ops-ui/src/views/user/user/components/user-form-modal.vue b/orion-ops-ui/src/views/user/user/components/user-form-modal.vue index 5adaf55b..c5cf45c0 100644 --- a/orion-ops-ui/src/views/user/user/components/user-form-modal.vue +++ b/orion-ops-ui/src/views/user/user/components/user-form-modal.vue @@ -103,7 +103,9 @@ // 渲染表单 const renderForm = (record: any) => { Object.keys(formModel).forEach(k => { - formModel[k] = record[k]; + if (record.hasOwnProperty(k)) { + formModel[k] = record[k]; + } }); }; diff --git a/orion-ops-ui/src/views/user/user/components/user-grant-roles-form-modal.vue b/orion-ops-ui/src/views/user/user/components/user-grant-roles-form-modal.vue index 08b8f325..68dd1f4f 100644 --- a/orion-ops-ui/src/views/user/user/components/user-grant-roles-form-modal.vue +++ b/orion-ops-ui/src/views/user/user/components/user-grant-roles-form-modal.vue @@ -81,7 +81,9 @@ // 渲染表单 const renderForm = (record: any) => { Object.keys(formModel).forEach(k => { - formModel[k] = record[k]; + if (record.hasOwnProperty(k)) { + formModel[k] = record[k]; + } }); }; @@ -97,6 +99,7 @@ // 加载用户角色 const { data: roleIdList } = await getUserRoleIdList(formModel.id); formModel.roleIdList = roleIdList; + } catch (e) { } finally { setRoleLoading(false); } diff --git a/orion-ops-ui/src/views/user/user/components/user-reset-password-form-modal.vue b/orion-ops-ui/src/views/user/user/components/user-reset-password-form-modal.vue index ec02713d..e0e743b4 100644 --- a/orion-ops-ui/src/views/user/user/components/user-reset-password-form-modal.vue +++ b/orion-ops-ui/src/views/user/user/components/user-reset-password-form-modal.vue @@ -75,7 +75,9 @@ // 渲染表单 const renderForm = (record: any) => { Object.keys(formModel).forEach(k => { - formModel[k] = record[k]; + if (record.hasOwnProperty(k)) { + formModel[k] = record[k]; + } }); }; diff --git a/orion-ops-ui/src/views/user/user/components/user-table.vue b/orion-ops-ui/src/views/user/user/components/user-table.vue index ef79b882..435454ec 100644 --- a/orion-ops-ui/src/views/user/user/components/user-table.vue +++ b/orion-ops-ui/src/views/user/user/components/user-table.vue @@ -187,6 +187,7 @@ Message.success('删除成功'); // 重新加载数据 await fetchTableData(); + } catch (e) { } finally { setLoading(false); } @@ -206,6 +207,7 @@ }); Message.success(`${newStatus.label}成功`); record.status = newStatus.value; + } catch (e) { } finally { setLoading(false); } @@ -234,6 +236,7 @@ pagination.total = data.total; pagination.current = request.page; pagination.pageSize = request.limit; + } catch (e) { } finally { setLoading(false); }