仰望星辰工作室

miaopanel

miaopanel/ web/src/views/Docker.vue 25.5 KB · 776 行 原始文件
1<script setup lang="ts">
2import { computed, inject, onMounted, ref } from 'vue'
3import { api } from '../api'
4import { navigate } from '../router'
5import type {
6 DockerContainer,
7 DockerImage,
8 DockerNetwork,
9 DockerOverview,
10 DockerPort,
11 DockerStatus,
12 DockerVolume,
13} from '../types'
14import DockerCreateModal from '../components/docker/DockerCreateModal.vue'
15import ContainerLogsModal from '../components/docker/ContainerLogsModal.vue'
16import BindDomainModal from '../components/docker/BindDomainModal.vue'
17import ConfirmDialog from '../components/ConfirmDialog.vue'
18
19defineOptions({ name: 'DockerView' })
20
21const notify = inject<(text: string, kind?: 'ok' | 'error') => void>('notify')!
22
23type Tab = 'containers' | 'images' | 'networks' | 'volumes'
24
25const status = ref<DockerStatus | null>(null)
26const overview = ref<DockerOverview | null>(null)
27const containers = ref<DockerContainer[]>([])
28const images = ref<DockerImage[]>([])
29const networks = ref<DockerNetwork[]>([])
30const volumes = ref<DockerVolume[]>([])
31
32const tab = ref<Tab>('containers')
33const stateFilter = ref('all')
34const search = ref('')
35const loading = ref(true)
36const refreshing = ref(false)
37const busy = ref('')
38const starting = ref(false)
39
40const createOpen = ref(false)
41const logsTarget = ref<DockerContainer | null>(null)
42const bindTarget = ref<DockerContainer | null>(null)
43const deleteTarget = ref<DockerContainer | null>(null)
44
45const mirrorOpen = ref(false)
46const mirrorText = ref('')
47const mirrorBusy = ref(false)
48
49const pullRef = ref('')
50const networkName = ref('')
51const networkDriver = ref('bridge')
52const volumeName = ref('')
53
54const filtered = computed(() => {
55 const q = search.value.trim().toLowerCase()
56 return containers.value.filter((c) => {
57 if (stateFilter.value === 'running' && c.state !== 'running') return false
58 if (stateFilter.value === 'stopped' && c.state === 'running') return false
59 if (!q) return true
60 return c.name.toLowerCase().includes(q) || c.image.toLowerCase().includes(q)
61 })
62})
63
64const deleteOptions = computed(() => {
65 if (!deleteTarget.value || deleteTarget.value.bindings.length === 0) return []
66 return [
67 {
68 value: 'keep',
69 label: '仅删除容器',
70 description: '域名绑定站点会保留,但访问会返回 502,需要手动到网站页删除。',
71 },
72 {
73 value: 'remove',
74 label: '同时删除绑定站点',
75 description: `将删除 ${deleteTarget.value.domains.join('、')},反代配置与站点一并移除。`,
76 danger: true,
77 },
78 ]
79})
80
81function stateText(c: DockerContainer): string {
82 if (c.state === 'running') return '运行中'
83 if (c.state === 'paused') return '已暂停'
84 if (c.state === 'restarting') return '重启中'
85 return '已停止'
86}
87
88function stateClass(c: DockerContainer): string {
89 if (c.state === 'running') return 'ok'
90 if (c.state === 'paused' || c.state === 'restarting') return 'warn'
91 return 'off'
92}
93
94function publishedPorts(c: DockerContainer): DockerPort[] {
95 return c.ports.filter((p) => p.published && p.host_port > 0)
96}
97
98function createdText(raw: string): string {
99 if (!raw) return '—'
100 const d = new Date(raw)
101 return Number.isNaN(d.getTime()) ? raw : d.toLocaleString()
102}
103
104async function loadStatus() {
105 loading.value = true
106 try {
107 status.value = await api.get<DockerStatus>('api/v1/docker/status')
108 if (status.value.running) {
109 await loadAll()
110 }
111 } catch (e) {
112 notify((e as Error).message, 'error')
113 } finally {
114 loading.value = false
115 }
116}
117
118async function loadAll() {
119 refreshing.value = true
120 try {
121 const [ov, cs, im, ne, vo] = await Promise.all([
122 api.get<DockerOverview>('api/v1/docker/overview'),
123 api.get<{ containers: DockerContainer[] }>('api/v1/docker/containers'),
124 api.get<{ images: DockerImage[] }>('api/v1/docker/images'),
125 api.get<{ networks: DockerNetwork[] }>('api/v1/docker/networks'),
126 api.get<{ volumes: DockerVolume[] }>('api/v1/docker/volumes'),
127 ])
128 overview.value = ov
129 containers.value = cs.containers ?? []
130 images.value = im.images ?? []
131 networks.value = ne.networks ?? []
132 volumes.value = vo.volumes ?? []
133 } catch (e) {
134 notify((e as Error).message, 'error')
135 } finally {
136 refreshing.value = false
137 }
138}
139
140async function refreshContainers() {
141 try {
142 const [ov, cs] = await Promise.all([
143 api.get<DockerOverview>('api/v1/docker/overview'),
144 api.get<{ containers: DockerContainer[] }>('api/v1/docker/containers'),
145 ])
146 overview.value = ov
147 containers.value = cs.containers ?? []
148 } catch (e) {
149 notify((e as Error).message, 'error')
150 }
151}
152
153async function startDocker() {
154 starting.value = true
155 try {
156 status.value = await api.post<DockerStatus>('api/v1/docker/start')
157 await loadAll()
158 notify('Docker 服务已启动')
159 } catch (e) {
160 notify((e as Error).message, 'error')
161 } finally {
162 starting.value = false
163 }
164}
165
166async function action(c: DockerContainer, act: 'start' | 'stop' | 'restart') {
167 if (busy.value) return
168 busy.value = c.id
169 try {
170 await api.post(`api/v1/docker/containers/${encodeURIComponent(c.id)}/action`, { action: act })
171 await refreshContainers()
172 notify(`${c.name} ${act === 'start' ? '已启动' : act === 'stop' ? '已停止' : '已重启'}`)
173 } catch (e) {
174 notify((e as Error).message, 'error')
175 } finally {
176 busy.value = ''
177 }
178}
179
180function askDelete(c: DockerContainer) {
181 if (busy.value) return
182 deleteTarget.value = c
183}
184
185async function confirmDelete(payload: { option: string }) {
186 const target = deleteTarget.value
187 deleteTarget.value = null
188 if (!target) return
189 busy.value = target.id
190 try {
191 const removeBindings = payload.option === 'remove' ? '1' : '0'
192 await api.del(
193 `api/v1/docker/containers/${encodeURIComponent(target.id)}?force=1&remove_bindings=${removeBindings}`,
194 )
195 await refreshContainers()
196 notify(`容器 ${target.name} 已删除`)
197 } catch (e) {
198 notify((e as Error).message, 'error')
199 } finally {
200 busy.value = ''
201 }
202}
203
204async function onCreated() {
205 await Promise.all([refreshContainers(), loadImages(), loadOverview()])
206}
207
208async function loadImages() {
209 try {
210 images.value = (await api.get<{ images: DockerImage[] }>('api/v1/docker/images')).images ?? []
211 } catch (e) {
212 notify((e as Error).message, 'error')
213 }
214}
215
216async function loadOverview() {
217 try {
218 overview.value = await api.get<DockerOverview>('api/v1/docker/overview')
219 } catch {
220 /* keep the previous counters */
221 }
222}
223
224async function pullImage() {
225 const refName = pullRef.value.trim()
226 if (!refName || busy.value) return
227 busy.value = 'pull'
228 try {
229 const res = await api.post<{ image: string; output: string }>('api/v1/docker/images/pull', {
230 image: refName,
231 })
232 notify(`镜像 ${res.image} 拉取完成`)
233 pullRef.value = ''
234 await Promise.all([loadImages(), loadOverview()])
235 } catch (e) {
236 notify((e as Error).message, 'error')
237 } finally {
238 busy.value = ''
239 }
240}
241
242async function deleteImage(img: DockerImage) {
243 if (!window.confirm(`删除镜像 ${img.repository}:${img.tag}?仍被容器使用时会失败。`)) return
244 busy.value = `image-${img.id}`
245 try {
246 await api.del(`api/v1/docker/images/${encodeURIComponent(img.id)}`)
247 await Promise.all([loadImages(), loadOverview()])
248 notify('镜像已删除')
249 } catch (e) {
250 notify((e as Error).message, 'error')
251 } finally {
252 busy.value = ''
253 }
254}
255
256async function loadNetworks() {
257 try {
258 networks.value = (await api.get<{ networks: DockerNetwork[] }>('api/v1/docker/networks')).networks ?? []
259 } catch (e) {
260 notify((e as Error).message, 'error')
261 }
262}
263
264async function createNetwork() {
265 const name = networkName.value.trim()
266 if (!name || busy.value) return
267 busy.value = 'network'
268 try {
269 await api.post('api/v1/docker/networks', { name, driver: networkDriver.value })
270 networkName.value = ''
271 await Promise.all([loadNetworks(), loadOverview()])
272 notify('网络已创建')
273 } catch (e) {
274 notify((e as Error).message, 'error')
275 } finally {
276 busy.value = ''
277 }
278}
279
280async function deleteNetwork(n: DockerNetwork) {
281 if (!window.confirm(`删除网络 ${n.name}?仍被容器使用时会失败。`)) return
282 busy.value = `network-${n.name}`
283 try {
284 await api.del(`api/v1/docker/networks/${encodeURIComponent(n.name)}`)
285 await Promise.all([loadNetworks(), loadOverview()])
286 notify('网络已删除')
287 } catch (e) {
288 notify((e as Error).message, 'error')
289 } finally {
290 busy.value = ''
291 }
292}
293
294async function loadVolumes() {
295 try {
296 volumes.value = (await api.get<{ volumes: DockerVolume[] }>('api/v1/docker/volumes')).volumes ?? []
297 } catch (e) {
298 notify((e as Error).message, 'error')
299 }
300}
301
302async function createVolume() {
303 const name = volumeName.value.trim()
304 if (!name || busy.value) return
305 busy.value = 'volume'
306 try {
307 await api.post('api/v1/docker/volumes', { name })
308 volumeName.value = ''
309 await Promise.all([loadVolumes(), loadOverview()])
310 notify('存储卷已创建')
311 } catch (e) {
312 notify((e as Error).message, 'error')
313 } finally {
314 busy.value = ''
315 }
316}
317
318async function deleteVolume(v: DockerVolume) {
319 if (!window.confirm(`删除存储卷 ${v.name}?卷内数据会丢失。`)) return
320 busy.value = `volume-${v.name}`
321 try {
322 await api.del(`api/v1/docker/volumes/${encodeURIComponent(v.name)}`)
323 await Promise.all([loadVolumes(), loadOverview()])
324 notify('存储卷已删除')
325 } catch (e) {
326 notify((e as Error).message, 'error')
327 } finally {
328 busy.value = ''
329 }
330}
331
332function openMirrors() {
333 mirrorText.value = (status.value?.mirrors ?? []).join('\n')
334 mirrorOpen.value = true
335}
336
337async function saveMirrors() {
338 if (mirrorBusy.value) return
339 mirrorBusy.value = true
340 try {
341 const list = mirrorText.value
342 .split('\n')
343 .map((v) => v.trim())
344 .filter(Boolean)
345 status.value = await api.put<DockerStatus>('api/v1/docker/mirrors', { mirrors: list })
346 mirrorOpen.value = false
347 notify('镜像加速配置已保存,Docker 已重启')
348 } catch (e) {
349 notify((e as Error).message, 'error')
350 } finally {
351 mirrorBusy.value = false
352 }
353}
354
355onMounted(loadStatus)
356</script>
357
358<template>
359 <div class="card">
360 <div class="row" style="align-items: flex-start">
361 <div>
362 <h2>Docker</h2>
363 <p class="hint">容器、镜像、网络与存储卷管理;绑定域名的容器流量会经过 nginx 与 WAF。</p>
364 </div>
365 <div class="spacer"></div>
366 <span v-if="status" class="badge" :class="status.running ? 'ok' : status.installed ? 'warn' : 'off'">
367 {{ status.running ? '运行中' : status.installed ? '未运行' : '未安装' }}
368 </span>
369 <button class="btn btn-ghost btn-sm" :disabled="refreshing || !status?.running" @click="loadAll">
370 <span v-if="refreshing" class="spin"></span>
371 刷新
372 </button>
373 <button v-if="status?.running" class="btn btn-ghost btn-sm" @click="openMirrors">镜像加速</button>
374 </div>
375
376 <div v-if="loading" class="row" style="padding: 24px 0">
377 <span class="spin"></span><span class="muted">正在检测 Docker…</span>
378 </div>
379
380 <div v-else-if="status && !status.supported" class="alert danger">
381 {{ status.message || 'Docker 管理仅支持 Linux 服务器。' }}
382 </div>
383
384 <div v-else-if="status && !status.installed" class="docker-empty">
385 <h3>还没有安装 Docker</h3>
386 <p class="hint">
387 前往应用商店安装 Docker。组件会使用阿里云 Docker CE 镜像源,并自动写入国内镜像加速与日志轮转配置。
388 </p>
389 <button class="btn btn-primary" @click="navigate('apps')">去应用商店安装</button>
390 </div>
391
392 <div v-else-if="status && !status.running" class="docker-empty">
393 <h3>Docker 已安装,但守护进程未运行</h3>
394 <p class="hint">{{ status.message || '请启动 Docker 服务后再管理容器。' }}</p>
395 <button class="btn btn-primary" :disabled="starting" @click="startDocker">
396 <span v-if="starting" class="spin"></span>
397 {{ starting ? '正在启动…' : '启动 Docker' }}
398 </button>
399 </div>
400
401 <template v-else-if="status">
402 <div v-if="!status.nginx_ready" class="alert" style="margin-top: 12px">
403 nginx 尚未安装或不可用,容器可以正常运行,但暂时无法绑定域名。
404 <button class="btn btn-ghost btn-sm" style="margin-left: 8px" @click="navigate('apps')">
405 去安装 nginx
406 </button>
407 </div>
408
409 <div class="grid cols-3" style="margin-top: 14px">
410 <div class="card stat">
411 <span class="label">容器数量</span>
412 <span class="value">{{ overview?.containers.total ?? 0 }}</span>
413 <span class="meta">运行 {{ overview?.containers.running ?? 0 }} 个 · 占用 {{ overview?.containers.size || '—' }}</span>
414 </div>
415 <div class="card stat">
416 <span class="label">镜像数量</span>
417 <span class="value">{{ overview?.images.total ?? 0 }}</span>
418 <span class="meta">占用 {{ overview?.images.size || '—' }}</span>
419 </div>
420 <div class="card stat">
421 <span class="label">网络数量</span>
422 <span class="value">{{ overview?.networks.total ?? 0 }}</span>
423 <span class="meta">已创建的网络</span>
424 </div>
425 <div class="card stat">
426 <span class="label">存储卷数量</span>
427 <span class="value">{{ overview?.volumes.total ?? 0 }}</span>
428 <span class="meta">占用 {{ overview?.volumes.size || '—' }}</span>
429 </div>
430 <div class="card stat">
431 <span class="label">域名绑定</span>
432 <span class="value">{{ overview?.bindings ?? 0 }}</span>
433 <span class="meta">通过 nginx 反代暴露的容器端口</span>
434 </div>
435 <div class="card stat">
436 <span class="label">版本</span>
437 <span class="value" style="font-size: 18px">{{ status.version || '—' }}</span>
438 <span class="meta">Compose {{ status.compose_version || '—' }}</span>
439 </div>
440 </div>
441
442 <div class="tabs" style="margin-top: 16px">
443 <button class="tab" :class="{ active: tab === 'containers' }" @click="tab = 'containers'">容器</button>
444 <button class="tab" :class="{ active: tab === 'images' }" @click="tab = 'images'">镜像</button>
445 <button class="tab" :class="{ active: tab === 'networks' }" @click="tab = 'networks'">网络</button>
446 <button class="tab" :class="{ active: tab === 'volumes' }" @click="tab = 'volumes'">存储卷</button>
447 </div>
448
449 <div v-if="tab === 'containers'" class="tab-panel">
450 <div class="row docker-toolbar">
451 <select v-model="stateFilter" class="select" style="width: 130px">
452 <option value="all">全部状态</option>
453 <option value="running">运行中</option>
454 <option value="stopped">已停止</option>
455 </select>
456 <input v-model="search" class="input" style="max-width: 260px" placeholder="搜索容器名称或镜像" />
457 <div class="spacer"></div>
458 <button class="btn btn-primary btn-sm" @click="createOpen = true">新建容器</button>
459 </div>
460
461 <div v-if="filtered.length === 0" class="docker-empty small">
462 <p class="hint">没有匹配的容器。点击「新建容器」粘贴 docker run 或 compose 即可创建。</p>
463 </div>
464
465 <div v-else class="docker-grid">
466 <div v-for="c in filtered" :key="c.id" class="docker-card">
467 <div class="docker-card-head">
468 <div class="docker-name">
469 <b>{{ c.name }}</b>
470 <span class="mono">{{ c.short_id }}</span>
471 </div>
472 <span class="badge" :class="stateClass(c)">{{ stateText(c) }}</span>
473 </div>
474 <div class="docker-image mono">{{ c.image }}</div>
475 <div class="docker-ports">
476 <span v-for="p in publishedPorts(c)" :key="p.host_port + p.protocol" class="port-chip mono">
477 :{{ p.host_port }} → {{ p.container_port }}/{{ p.protocol }}
478 </span>
479 <span v-if="publishedPorts(c).length === 0" class="hint">没有发布端口</span>
480 </div>
481 <div v-if="c.domains.length" class="docker-domains">
482 <span v-for="d in c.domains" :key="d" class="domain-chip">{{ d }}</span>
483 </div>
484 <div class="hint docker-created">{{ createdText(c.created_at) }}</div>
485 <div class="docker-actions">
486 <button
487 v-if="c.state !== 'running'"
488 class="btn btn-sm btn-primary"
489 :disabled="busy === c.id"
490 @click="action(c, 'start')"
491 >
492 启动
493 </button>
494 <button
495 v-else
496 class="btn btn-sm btn-ghost"
497 :disabled="busy === c.id"
498 @click="action(c, 'stop')"
499 >
500 停止
501 </button>
502 <button class="btn btn-sm btn-ghost" :disabled="busy === c.id" @click="action(c, 'restart')">
503 重启
504 </button>
505 <button class="btn btn-sm btn-ghost" @click="logsTarget = c">日志</button>
506 <button class="btn btn-sm btn-ghost" @click="bindTarget = c">绑定域名</button>
507 <button class="btn btn-sm btn-danger" :disabled="busy === c.id" @click="askDelete(c)">
508 删除
509 </button>
510 </div>
511 </div>
512 </div>
513 </div>
514
515 <div v-else-if="tab === 'images'" class="tab-panel">
516 <div class="row docker-toolbar">
517 <input v-model="pullRef" class="input mono" style="max-width: 300px" placeholder="镜像名,例如 nginx:latest" />
518 <button class="btn btn-primary btn-sm" :disabled="busy === 'pull'" @click="pullImage">
519 <span v-if="busy === 'pull'" class="spin"></span>
520 {{ busy === 'pull' ? '拉取中…' : '拉取镜像' }}
521 </button>
522 <div class="spacer"></div>
523 <button class="btn btn-ghost btn-sm" @click="loadImages">刷新</button>
524 </div>
525 <div class="table-wrap">
526 <table class="table">
527 <thead>
528 <tr><th>镜像</th><th>ID</th><th>大小</th><th>创建时间</th><th></th></tr>
529 </thead>
530 <tbody>
531 <tr v-for="img in images" :key="img.id">
532 <td class="mono">{{ img.repository }}:{{ img.tag }}</td>
533 <td class="mono">{{ img.id.slice(0, 19) }}</td>
534 <td>{{ img.size }}</td>
535 <td class="muted">{{ createdText(img.created_at) }}</td>
536 <td class="right">
537 <button class="btn btn-ghost btn-sm" :disabled="busy === 'image-' + img.id" @click="deleteImage(img)">
538 删除
539 </button>
540 </td>
541 </tr>
542 <tr v-if="images.length === 0">
543 <td colspan="5" class="hint">还没有镜像,先拉取一个。</td>
544 </tr>
545 </tbody>
546 </table>
547 </div>
548 </div>
549
550 <div v-else-if="tab === 'networks'" class="tab-panel">
551 <div class="row docker-toolbar">
552 <input v-model="networkName" class="input mono" style="max-width: 220px" placeholder="网络名称" />
553 <select v-model="networkDriver" class="select" style="width: 120px">
554 <option value="bridge">bridge</option>
555 <option value="overlay">overlay</option>
556 </select>
557 <button class="btn btn-primary btn-sm" :disabled="busy === 'network'" @click="createNetwork">
558 <span v-if="busy === 'network'" class="spin"></span>
559 创建网络
560 </button>
561 <div class="spacer"></div>
562 <button class="btn btn-ghost btn-sm" @click="loadNetworks">刷新</button>
563 </div>
564 <div class="table-wrap">
565 <table class="table">
566 <thead>
567 <tr><th>名称</th><th>驱动</th><th>范围</th><th>ID</th><th></th></tr>
568 </thead>
569 <tbody>
570 <tr v-for="n in networks" :key="n.id">
571 <td class="mono">{{ n.name }}</td>
572 <td>{{ n.driver }}</td>
573 <td>{{ n.scope }}</td>
574 <td class="mono muted">{{ n.id.slice(0, 12) }}</td>
575 <td class="right">
576 <button
577 v-if="!['bridge', 'host', 'none'].includes(n.name)"
578 class="btn btn-ghost btn-sm"
579 :disabled="busy === 'network-' + n.name"
580 @click="deleteNetwork(n)"
581 >
582 删除
583 </button>
584 <span v-else class="hint">内置</span>
585 </td>
586 </tr>
587 </tbody>
588 </table>
589 </div>
590 </div>
591
592 <div v-else class="tab-panel">
593 <div class="row docker-toolbar">
594 <input v-model="volumeName" class="input mono" style="max-width: 240px" placeholder="存储卷名称" />
595 <button class="btn btn-primary btn-sm" :disabled="busy === 'volume'" @click="createVolume">
596 <span v-if="busy === 'volume'" class="spin"></span>
597 创建存储卷
598 </button>
599 <div class="spacer"></div>
600 <button class="btn btn-ghost btn-sm" @click="loadVolumes">刷新</button>
601 </div>
602 <div class="table-wrap">
603 <table class="table">
604 <thead>
605 <tr><th>名称</th><th>驱动</th><th>挂载点</th><th></th></tr>
606 </thead>
607 <tbody>
608 <tr v-for="v in volumes" :key="v.name">
609 <td class="mono">{{ v.name }}</td>
610 <td>{{ v.driver }}</td>
611 <td class="mono muted">{{ v.mountpoint || '—' }}</td>
612 <td class="right">
613 <button class="btn btn-ghost btn-sm" :disabled="busy === 'volume-' + v.name" @click="deleteVolume(v)">
614 删除
615 </button>
616 </td>
617 </tr>
618 <tr v-if="volumes.length === 0">
619 <td colspan="4" class="hint">还没有存储卷。</td>
620 </tr>
621 </tbody>
622 </table>
623 </div>
624 </div>
625 </template>
626 </div>
627
628 <DockerCreateModal v-if="createOpen" @close="createOpen = false" @created="onCreated" />
629 <ContainerLogsModal v-if="logsTarget" :container="logsTarget" @close="logsTarget = null" />
630 <BindDomainModal
631 v-if="bindTarget"
632 :container="bindTarget"
633 :nginx-ready="status?.nginx_ready ?? false"
634 @close="bindTarget = null"
635 @changed="refreshContainers"
636 />
637
638 <ConfirmDialog
639 v-if="deleteTarget"
640 title="删除容器"
641 :message="`确定删除容器 ${deleteTarget.name}?该操作会强制停止并移除容器。`"
642 confirm-text="删除"
643 danger
644 :options="deleteOptions"
645 @close="deleteTarget = null"
646 @confirm="confirmDelete"
647 />
648
649 <div v-if="mirrorOpen" class="overlay" @click.self="mirrorOpen = false">
650 <div class="modal" style="width: min(560px, 100%)">
651 <div class="modal-head">
652 <h3>镜像加速</h3>
653 <button class="icon-btn" title="关闭" @click="mirrorOpen = false">×</button>
654 </div>
655 <p class="hint">
656 每行一个 registry mirror,例如阿里云个人加速地址
657 <code>https://&lt;你的ID&gt;.mirror.aliyuncs.com</code>。保存会写入
658 <code>/etc/docker/daemon.json</code> 并重启 Docker;live-restore 会尽量保持运行中容器不中断。
659 </p>
660 <textarea v-model="mirrorText" class="textarea mono" rows="6" placeholder="https://docker.m.daocloud.io"></textarea>
661 <div class="modal-foot">
662 <div class="spacer"></div>
663 <button class="btn btn-ghost" :disabled="mirrorBusy" @click="mirrorOpen = false">取消</button>
664 <button class="btn btn-primary" :disabled="mirrorBusy" @click="saveMirrors">
665 <span v-if="mirrorBusy" class="spin"></span>
666 保存并重启
667 </button>
668 </div>
669 </div>
670 </div>
671</template>
672
673<style scoped>
674.docker-empty {
675 padding: 48px 0;
676 text-align: center;
677}
678.docker-empty.small {
679 padding: 24px 0;
680}
681.docker-empty h3 {
682 margin: 0 0 8px;
683}
684.docker-empty .hint {
685 max-width: 560px;
686 margin: 0 auto 16px;
687}
688.docker-toolbar {
689 display: flex;
690 align-items: center;
691 gap: 8px;
692 flex-wrap: wrap;
693 margin-bottom: 12px;
694}
695.tab-panel {
696 padding-top: 6px;
697}
698.docker-grid {
699 display: grid;
700 grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
701 gap: 12px;
702}
703.docker-card {
704 border: 1px solid var(--line);
705 border-radius: 14px;
706 background: #fbfefd;
707 padding: 14px;
708 display: flex;
709 flex-direction: column;
710 gap: 8px;
711}
712.docker-card-head {
713 display: flex;
714 align-items: flex-start;
715 gap: 8px;
716}
717.docker-name {
718 min-width: 0;
719 flex: 1;
720 display: flex;
721 flex-direction: column;
722}
723.docker-name b {
724 font-size: 14px;
725 overflow: hidden;
726 text-overflow: ellipsis;
727 white-space: nowrap;
728}
729.docker-name span {
730 font-size: 11px;
731 color: var(--muted);
732}
733.docker-image {
734 font-size: 12px;
735 color: #31575f;
736 overflow: hidden;
737 text-overflow: ellipsis;
738 white-space: nowrap;
739}
740.docker-ports,
741.docker-domains {
742 display: flex;
743 flex-wrap: wrap;
744 gap: 6px;
745}
746.port-chip,
747.domain-chip {
748 padding: 2px 8px;
749 border-radius: 999px;
750 font-size: 11px;
751 background: rgba(52, 211, 153, 0.1);
752 color: #276c5c;
753}
754.domain-chip {
755 background: rgba(14, 165, 233, 0.1);
756 color: #0369a1;
757}
758.docker-created {
759 font-size: 11px;
760}
761.docker-actions {
762 display: flex;
763 flex-wrap: wrap;
764 gap: 6px;
765 margin-top: auto;
766 padding-top: 6px;
767 border-top: 1px dashed var(--line);
768}
769.badge.warn {
770 color: #b45309;
771 background: rgba(245, 158, 11, 0.12);
772}
773.right {
774 text-align: right;
775}
776</style>