仰望星辰工作室

better-staridc-MNBT

better-staridc-MNBT/ templates/tdesign/spa/src/docker/views/VolumeView.vue 2.7 KB · 114 行 原始文件
Z zfhsh first commit 2 个月前
1<template>
2 <div class="dk-volume">
3 <t-card>
4 <template #header>
5 <div class="dk-card-hd">
6 <h3>存储卷</h3>
7 <t-button theme="default" variant="outline" size="small" @click="load">
8 <i class="mdi mdi-refresh"></i> 刷新
9 </t-button>
10 </div>
11 </template>
12
13 <t-table
14 row-key="name"
15 :data="rows"
16 :columns="columns"
17 :loading="loading"
18 table-layout="auto"
19 stripe
20 bordered
21 >
22 <template #name="{ row }">
23 <span class="dk-mono">{{ row.Name || row.name || '-' }}</span>
24 </template>
25 <template #driver="{ row }">
26 {{ row.Driver || row.driver || '-' }}
27 </template>
28 <template #mountpoint="{ row }">
29 <span class="dk-mono dk-path">{{ row.Mountpoint || row.mountpoint || '-' }}</span>
30 </template>
31 <template #created="{ row }">
32 <span class="dk-mono">{{ row.CreatedAt || row.created_at || '-' }}</span>
33 </template>
34 <template #empty>
35 <div class="dk-empty">
36 <i class="mdi mdi-database"></i>
37 <p>暂无存储卷</p>
38 </div>
39 </template>
40 </t-table>
41 </t-card>
42 </div>
43</template>
44
45<script setup>
46import { ref, onMounted } from 'vue'
47import { listVolume } from '@/docker/api/docker'
48
49const loading = ref(false)
50const rows = ref([])
51
52const columns = [
53 { colKey: 'name', title: '名称', minWidth: 200 },
54 { colKey: 'driver', title: '驱动', width: 120 },
55 { colKey: 'mountpoint', title: '挂载点', minWidth: 280 },
56 { colKey: 'created', title: '创建时间', minWidth: 180 },
57]
58
59async function load() {
60 loading.value = true
61 const r = await listVolume()
62 loading.value = false
63 if (r.ok && r.data) {
64 const btResp = r.data.data || r.data
65 const list = btResp.data || btResp || []
66 rows.value = Array.isArray(list) ? list : []
67 }
68}
69
70onMounted(load)
71</script>
72
73<style scoped>
74.dk-card-hd {
75 display: flex;
76 align-items: center;
77 justify-content: space-between;
78 width: 100%;
79}
80.dk-card-hd h3 {
81 margin: 0;
82 font-size: 16px;
83 font-weight: 600;
84}
85.dk-mono {
86 font-family: Consolas, Monaco, monospace;
87 font-size: 12.5px;
88}
89.dk-path {
90 font-size: 11.5px;
91 word-break: break-all;
92}
93.dk-empty {
94 text-align: center;
95 padding: 40px 20px;
96 color: var(--td-text-color-secondary, #6b7280);
97}
98.dk-empty i {
99 font-size: 36px;
100 opacity: 0.5;
101 display: block;
102 margin-bottom: 8px;
103}
104.dk-empty p {
105 margin: 0;
106 font-size: 13px;
107}
108
109/* ========== 移动端 ========== */
110@media (max-width: 768px) {
111 .dk-card-hd { flex-direction: column; gap: 10px; align-items: flex-start; }
112 .dk-volume :deep(.t-table) { font-size: 12px; }
113}
114</style>