2023-09-11 16:33:57 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="layout-container">
|
2023-09-28 01:30:25 +08:00
|
|
|
<!-- 列表-表格 -->
|
|
|
|
|
<host-table v-if="renderTable"
|
|
|
|
|
ref="table"
|
2023-09-14 16:18:41 +08:00
|
|
|
@openAdd="() => modal.openAdd()"
|
2023-09-20 10:40:59 +08:00
|
|
|
@openUpdate="(e) => modal.openUpdate(e)"
|
|
|
|
|
@openUpdateConfig="(e) => config.open(e)" />
|
2023-09-28 01:30:25 +08:00
|
|
|
<!-- 列表-卡片 -->
|
|
|
|
|
<host-card-list v-else
|
2023-10-02 22:56:43 +08:00
|
|
|
ref="card" />
|
|
|
|
|
<!-- @openAdd="() => modal.openAdd()"-->
|
|
|
|
|
<!-- @openUpdate="(e) => modal.openUpdate(e)"-->
|
|
|
|
|
<!-- @openUpdateConfig="(e) => config.open(e)" />-->
|
2023-09-11 16:33:57 +08:00
|
|
|
<!-- 添加修改模态框 -->
|
|
|
|
|
<host-form-modal ref="modal"
|
2023-09-14 16:18:41 +08:00
|
|
|
@added="() => table.addedCallback()"
|
|
|
|
|
@updated="() => table.updatedCallback()" />
|
2023-09-20 10:40:59 +08:00
|
|
|
<!-- 配置面板 -->
|
|
|
|
|
<host-config-drawer ref="config" />
|
2023-09-11 16:33:57 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
export default {
|
|
|
|
|
name: 'assetHost'
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-09-28 01:30:25 +08:00
|
|
|
import { computed, onUnmounted, ref } from 'vue';
|
|
|
|
|
import { useAppStore, useCacheStore } from '@/store';
|
2023-09-11 16:33:57 +08:00
|
|
|
import HostTable from './components/host-table.vue';
|
2023-09-28 01:30:25 +08:00
|
|
|
import HostCardList from '@/views/asset/host/components/host-card-list.vue';
|
2023-09-11 16:33:57 +08:00
|
|
|
import HostFormModal from './components/host-form-modal.vue';
|
2023-09-20 10:40:59 +08:00
|
|
|
import HostConfigDrawer from '@/views/asset/host/components/host-config-drawer.vue';
|
2023-09-11 16:33:57 +08:00
|
|
|
|
|
|
|
|
const table = ref();
|
2023-09-28 01:30:25 +08:00
|
|
|
const card = ref();
|
2023-09-11 16:33:57 +08:00
|
|
|
const modal = ref();
|
2023-09-20 10:40:59 +08:00
|
|
|
const config = ref();
|
2023-09-28 01:30:25 +08:00
|
|
|
const appStore = useAppStore();
|
|
|
|
|
|
|
|
|
|
// FIXME 临时
|
|
|
|
|
const renderTable = computed(() => appStore.hostView === 'card');
|
2023-09-11 16:33:57 +08:00
|
|
|
|
2023-09-14 16:18:41 +08:00
|
|
|
// 卸载时清除 tags cache
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
const cacheStore = useCacheStore();
|
|
|
|
|
cacheStore.set('tags', []);
|
2023-09-22 11:50:56 +08:00
|
|
|
cacheStore.set('hostKeys', []);
|
|
|
|
|
cacheStore.set('hostIdentities', []);
|
2023-09-14 16:18:41 +08:00
|
|
|
});
|
|
|
|
|
|
2023-09-11 16:33:57 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|