From 4cfc22753be83e5a88c32ca1adf68df8faad52c9 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Mon, 4 Dec 2023 16:08:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orion-ops-ui/src/assets/style/global.less | 7 ++++- .../host-group/host-group-tree-selector.vue | 16 ++++++---- .../asset/host-group/host-group-tree.vue | 2 +- .../host-identity/host-identity-selector.vue | 14 +++++++-- .../asset/host-key/host-key-selector.vue | 14 +++++++-- .../meta/tag/tag-multi-selector.vue | 29 +++++++++++-------- .../system/dict-key/dict-key-selector.vue | 15 ++++++---- .../menu/selector/menu-tree-selector.vue | 16 ++++++++-- .../components/user/role/role-selector.vue | 14 ++++++--- .../components/user/user/user-selector.vue | 16 ++++++---- .../src/views/asset/host-key/index.vue | 12 ++------ .../components/config/host-config-drawer.vue | 11 +++---- .../components/config/ssh/ssh-config-form.vue | 2 +- .../src/views/asset/host-list/index.vue | 1 - .../role/components/role-menu-grant-modal.vue | 4 +-- .../user-grant-roles-form-modal.vue | 22 +++++--------- 16 files changed, 119 insertions(+), 76 deletions(-) diff --git a/orion-ops-ui/src/assets/style/global.less b/orion-ops-ui/src/assets/style/global.less index d8e5457e..ba877e75 100644 --- a/orion-ops-ui/src/assets/style/global.less +++ b/orion-ops-ui/src/assets/style/global.less @@ -69,6 +69,10 @@ body { } // -- arco +.arco-menu-inner::-webkit-scrollbar { + display: none; +} + .arco-table-td-content { color: rgba(var(--gray-9), .95); font-size: 13px; @@ -119,7 +123,8 @@ body { margin: 0; } } -.arco-scrollbar-track-direction-horizontal{ + +.arco-scrollbar-track-direction-horizontal { height: 9px; .arco-scrollbar-thumb-bar { diff --git a/orion-ops-ui/src/components/asset/host-group/host-group-tree-selector.vue b/orion-ops-ui/src/components/asset/host-group/host-group-tree-selector.vue index 3b48995d..3e47b059 100644 --- a/orion-ops-ui/src/components/asset/host-group/host-group-tree-selector.vue +++ b/orion-ops-ui/src/components/asset/host-group/host-group-tree-selector.vue @@ -2,6 +2,7 @@ @@ -19,7 +20,7 @@ import type { PropType } from 'vue'; import { computed, onBeforeMount, ref } from 'vue'; import { useCacheStore } from '@/store'; - import { getHostGroupTree } from '@/api/asset/host-group'; + import useLoading from '@/hooks/loading'; const props = defineProps({ modelValue: Array as PropType>, @@ -27,6 +28,7 @@ const emits = defineEmits(['update:modelValue']); + const { loading, setLoading } = useLoading(); const cacheStore = useCacheStore(); const value = computed>({ @@ -44,10 +46,14 @@ const treeData = ref>([]); // 初始化选项 - onBeforeMount(() => { - cacheStore.loadHostGroups().then(s => { - treeData.value = s; - }); + onBeforeMount(async () => { + setLoading(true); + try { + treeData.value = await cacheStore.loadHostGroups(); + } catch (e) { + } finally { + setLoading(false); + } }); diff --git a/orion-ops-ui/src/components/asset/host-group/host-group-tree.vue b/orion-ops-ui/src/components/asset/host-group/host-group-tree.vue index bca9d667..9a92134e 100644 --- a/orion-ops-ui/src/components/asset/host-group/host-group-tree.vue +++ b/orion-ops-ui/src/components/asset/host-group/host-group-tree.vue @@ -92,7 +92,7 @@ import { computed, nextTick, onMounted, ref } from 'vue'; import { createGroupGroupPrefix, rootId } from './types/const'; import { findNode, findParentNode, moveNode } from '@/utils/tree'; - import { createHostGroup, deleteHostGroup, getHostGroupTree, updateHostGroupName, moveHostGroup } from '@/api/asset/host-group'; + import { createHostGroup, deleteHostGroup, updateHostGroupName, moveHostGroup } from '@/api/asset/host-group'; import { isString } from '@/utils/is'; import { useCacheStore } from '@/store'; 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 index e1dd2832..cdce3f89 100644 --- 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 @@ -1,6 +1,7 @@ @@ -15,6 +16,7 @@ import type { SelectOptionData } from '@arco-design/web-vue'; import { computed, onBeforeMount, ref } from 'vue'; import { useCacheStore } from '@/store'; + import useLoading from '@/hooks/loading'; const props = defineProps({ modelValue: Number, @@ -22,6 +24,7 @@ const emits = defineEmits(['update:modelValue']); + const { loading, setLoading } = useLoading(); const cacheStore = useCacheStore(); const value = computed({ @@ -39,15 +42,20 @@ const optionData = ref>([]); // 初始化选项 - onBeforeMount(() => { - cacheStore.loadHostIdentities().then(hostIdentities => { + onBeforeMount(async () => { + setLoading(true); + try { + const hostIdentities = await cacheStore.loadHostIdentities(); optionData.value = hostIdentities.map(s => { return { label: `${s.name} (${s.username})`, value: s.id, }; }); - }); + } catch (e) { + } finally { + setLoading(false); + } }); diff --git a/orion-ops-ui/src/components/asset/host-key/host-key-selector.vue b/orion-ops-ui/src/components/asset/host-key/host-key-selector.vue index 3d6ac95d..b6e3d86d 100644 --- a/orion-ops-ui/src/components/asset/host-key/host-key-selector.vue +++ b/orion-ops-ui/src/components/asset/host-key/host-key-selector.vue @@ -1,6 +1,7 @@ @@ -15,6 +16,7 @@ import type { SelectOptionData } from '@arco-design/web-vue'; import { computed, onBeforeMount, ref } from 'vue'; import { useCacheStore } from '@/store'; + import useLoading from '@/hooks/loading'; const props = defineProps({ modelValue: Number, @@ -22,6 +24,7 @@ const emits = defineEmits(['update:modelValue']); + const { loading, setLoading } = useLoading(); const cacheStore = useCacheStore(); const value = computed({ @@ -39,15 +42,20 @@ const optionData = ref>([]); // 初始化选项 - onBeforeMount(() => { - cacheStore.loadHostKeys().then(hostKeys => { + onBeforeMount(async () => { + setLoading(true); + try { + const hostKeys = await cacheStore.loadHostKeys(); optionData.value = hostKeys.map(s => { return { label: s.name, value: s.id, }; }); - }); + } catch (e) { + } finally { + setLoading(false); + } }); diff --git a/orion-ops-ui/src/components/meta/tag/tag-multi-selector.vue b/orion-ops-ui/src/components/meta/tag/tag-multi-selector.vue index 160435e4..081e43ff 100644 --- a/orion-ops-ui/src/components/meta/tag/tag-multi-selector.vue +++ b/orion-ops-ui/src/components/meta/tag/tag-multi-selector.vue @@ -51,18 +51,6 @@ }); const optionData = ref([]); - // 初始化选项 - onBeforeMount(() => { - cacheStore.loadTags(props.type as string).then((tags) => { - optionData.value = tags.map(s => { - return { - label: s.name, - value: s.id, - }; - }); - }); - }); - // 检查是否可以创建tag const checkCreateTag = async (tags: Array) => { if (!tags.length) { @@ -112,6 +100,23 @@ return id; }; + // 初始化选项 + onBeforeMount(async () => { + setLoading(true); + try { + const tags = await cacheStore.loadTags(props.type as string); + optionData.value = tags.map(s => { + return { + label: s.name, + value: s.id, + }; + }); + } catch (e) { + } finally { + setLoading(false); + } + }); +