2023-11-10 19:02:38 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="index-container" v-if="render">
|
|
|
|
|
<host-group-view />
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
export default {
|
|
|
|
|
name: 'assetHostGroup'
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { Message } from '@arco-design/web-vue';
|
|
|
|
|
|
|
|
|
|
import { computed, ref, onBeforeMount, onUnmounted } from 'vue';
|
|
|
|
|
import { useAppStore, useCacheStore, useDictStore } from '@/store';
|
|
|
|
|
import HostGroupView from './components/host-group-view.vue';
|
2023-11-14 15:05:47 +08:00
|
|
|
import { getHostList } from '@/api/asset/host';
|
2023-11-10 19:02:38 +08:00
|
|
|
|
|
|
|
|
const render = ref(false);
|
|
|
|
|
const cacheStore = useCacheStore();
|
|
|
|
|
|
2023-11-14 15:05:47 +08:00
|
|
|
// 加载主机列表
|
|
|
|
|
const loadHostList = async () => {
|
2023-11-10 19:02:38 +08:00
|
|
|
try {
|
2023-11-14 15:05:47 +08:00
|
|
|
const { data } = await getHostList();
|
2023-11-10 19:02:38 +08:00
|
|
|
// 设置到缓存
|
2023-11-14 15:05:47 +08:00
|
|
|
cacheStore.set('hosts', data);
|
|
|
|
|
} catch (e) {
|
2023-11-10 19:02:38 +08:00
|
|
|
Message.error('tag加载失败');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onBeforeMount(async () => {
|
|
|
|
|
// 加载主机列表
|
2023-11-14 15:05:47 +08:00
|
|
|
await loadHostList();
|
2023-11-10 19:02:38 +08:00
|
|
|
render.value = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 卸载时清除 cache
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
cacheStore.reset('user', 'roles', 'hosts');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.index-container {
|
|
|
|
|
position: relative;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
padding: 16px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|