Files
orion-visor/orion-ops-ui/src/views/asset/host-identity/index.vue

76 lines
2.2 KiB
Vue
Raw Normal View History

2023-09-20 12:13:02 +08:00
<template>
2023-12-04 14:35:18 +08:00
<div class="layout-container">
2023-10-08 01:05:52 +08:00
<!-- 列表-表格 -->
<host-identity-table v-if="renderTable"
ref="table"
2023-09-21 13:50:42 +08:00
@openAdd="() => modal.openAdd()"
2023-09-21 16:06:09 +08:00
@openUpdate="(e) => modal.openUpdate(e)"
@openKeyView="(e) => keyDrawer.openView(e) " />
2023-10-08 01:05:52 +08:00
<!-- 列表-卡片 -->
<host-identity-card-list v-else
ref="card"
@openAdd="() => modal.openAdd()"
@openUpdate="(e) => modal.openUpdate(e)"
@openKeyView="(e) => keyDrawer.openView(e) " />
2023-09-20 12:13:02 +08:00
<!-- 添加修改模态框 -->
2023-09-21 13:50:42 +08:00
<host-identity-form-modal ref="modal"
2023-10-08 01:05:52 +08:00
@added="modalAddCallback"
@updated="modalUpdateCallback" />
2023-12-04 14:35:18 +08:00
<!-- 主机秘钥抽屉 -->
2023-09-21 16:06:09 +08:00
<host-key-form-drawer ref="keyDrawer" />
2023-09-20 12:13:02 +08:00
</div>
</template>
<script lang="ts">
export default {
2023-09-21 13:50:42 +08:00
name: 'assetHostIdentity'
2023-09-20 12:13:02 +08:00
};
</script>
<script lang="ts" setup>
2023-12-04 14:35:18 +08:00
import { ref, computed, onUnmounted } from 'vue';
import { useAppStore, useCacheStore } from '@/store';
2023-10-08 01:05:52 +08:00
import HostIdentityCardList from './components/host-identity-card-list.vue';
2023-09-20 12:13:02 +08:00
import HostIdentityTable from './components/host-identity-table.vue';
2023-09-21 13:50:42 +08:00
import HostIdentityFormModal from './components/host-identity-form-modal.vue';
2023-09-21 16:06:09 +08:00
import HostKeyFormDrawer from '../host-key/components/host-key-form-drawer.vue';
2023-09-20 17:13:38 +08:00
2023-09-20 12:13:02 +08:00
const table = ref();
2023-10-08 01:05:52 +08:00
const card = ref();
2023-09-21 13:50:42 +08:00
const modal = ref();
2023-09-21 16:06:09 +08:00
const keyDrawer = ref();
2023-10-08 01:05:52 +08:00
const appStore = useAppStore();
const cacheStore = useCacheStore();
const renderTable = computed(() => appStore.hostIdentityView === 'table');
// 添加回调
const modalAddCallback = () => {
if (renderTable.value) {
table.value.addedCallback();
} else {
card.value.addedCallback();
}
};
// 修改回调
const modalUpdateCallback = () => {
if (renderTable.value) {
table.value.updatedCallback();
} else {
card.value.updatedCallback();
}
};
// 卸载时清除 cache
2023-09-21 13:50:42 +08:00
onUnmounted(() => {
const cacheStore = useCacheStore();
cacheStore.reset('hostKeys');
2023-09-21 13:50:42 +08:00
});
2023-09-20 12:13:02 +08:00
</script>
<style lang="less" scoped>
</style>