Files
tkPage/src/views/nav.vue

88 lines
2.5 KiB
Vue
Raw Normal View History

2025-07-01 21:02:39 +08:00
<template>
2026-01-19 20:20:55 +08:00
<div class="nav-container bg-background-light dark:bg-background-dark text-slate-800 dark:text-slate-200 subtle-grid shadow-2xl overflow-hidden" :style="containerStyle">
2026-01-16 19:00:07 +08:00
<div class="flex h-full overflow-hidden">
<Sidebar class="flex-none h-full" @activeIndex="activeIndexFn" />
<main class="flex-1 overflow-y-auto p-4 relative flex flex-col h-full bg-[#f3f5f9]">
<div v-show="activeIndexA == 1" class="h-full">
<workbenches />
</div>
<div v-show="activeIndexA == 2" class="h-full">
<hostsList />
</div>
<!-- Decorative blobs -->
<!-- <div class="absolute -top-24 -right-24 w-64 h-64 bg-primary/5 rounded-full blur-3xl pointer-events-none"></div> -->
<!-- <div class="absolute -bottom-24 -left-24 w-64 h-64 bg-secondary/5 rounded-full blur-3xl pointer-events-none"></div> -->
<!-- <div class="absolute bottom-2 right-4 text-xs text-slate-400">{{ version }}</div> -->
</main>
2025-07-01 21:02:39 +08:00
</div>
</div>
</template>
<script setup>
import Sidebar from '../components/Sidebar.vue';
import hostsList from '@/views/hosts/hostsList.vue'
import workbenches from '@/views/hosts/workbenches.vue'
2026-01-19 20:20:55 +08:00
import { ref, computed, onMounted, onUnmounted } from 'vue'
// 设计稿尺寸
const DESIGN_WIDTH = 1600
const DESIGN_HEIGHT = 900
2025-07-01 21:02:39 +08:00
let activeIndexA = ref(1)
2026-01-16 19:00:07 +08:00
const version = ref('v0.1.0')
2025-07-01 21:02:39 +08:00
2026-01-19 20:20:55 +08:00
// 缩放比例
const zoomRatio = ref(1)
// 计算缩放比例
const calcZoom = () => {
const windowWidth = window.innerWidth
const windowHeight = window.innerHeight
// 根据宽高比例计算缩放值,取较小值保证完整显示
const widthRatio = windowWidth / DESIGN_WIDTH
const heightRatio = windowHeight / DESIGN_HEIGHT
zoomRatio.value = Math.min(widthRatio, heightRatio)
}
// 容器样式
const containerStyle = computed(() => ({
width: `${DESIGN_WIDTH}px`,
height: `${DESIGN_HEIGHT}px`,
zoom: zoomRatio.value
}))
2025-07-01 21:02:39 +08:00
function activeIndexFn(data) {
activeIndexA.value = data
console.log(data)
}
2026-01-19 20:20:55 +08:00
onMounted(() => {
calcZoom()
window.addEventListener('resize', calcZoom)
})
onUnmounted(() => {
window.removeEventListener('resize', calcZoom)
})
2025-07-01 21:02:39 +08:00
</script>
2026-01-16 19:00:07 +08:00
<style>
/* Global resets if needed, but Tailwind handles most */
body {
2025-07-01 21:02:39 +08:00
margin: 0;
padding: 0;
2026-01-16 19:00:07 +08:00
background-color: #f3f5f9; /* Match background */
2025-07-01 21:02:39 +08:00
display: flex;
2026-01-16 19:00:07 +08:00
justify-content: center;
2025-07-01 21:02:39 +08:00
align-items: center;
2026-01-16 19:00:07 +08:00
min-height: 100vh;
2026-01-19 20:20:55 +08:00
overflow: hidden;
}
.nav-container {
transform-origin: center center;
2025-07-01 21:02:39 +08:00
}
</style>