refactor: extract image form to standalone page and implement tags view store

- Created ImageForm.vue as standalone page for add/edit image functionality
- Removed dialog-based image form from VmImages.vue
- Implemented tagsViewStore for global tab state management
- Added automatic tab closing on form cancel/back
- Fixed data persistence issue when switching between image edits
- Removed quick actions section from ImageForm
- Updated router configuration for new image form route
This commit is contained in:
2025-11-28 14:15:29 +08:00
parent 067e0539ba
commit f7c3be1d30
45 changed files with 8776 additions and 6881 deletions
+200 -193
View File
@@ -1,17 +1,5 @@
<template>
<div class="all-sites-container">
<!-- 页面头部 -->
<div class="page-header">
<div class="left">
<h2 class="title">所有站点</h2>
<el-tag type="info" effect="plain" class="count-tag"> {{ pagination.total }} 个站点</el-tag>
</div>
<div class="actions">
<el-button type="primary" @click="handleRefresh" :icon="Refresh" class="action-btn">刷新</el-button>
<!-- <el-button type="success" @click="handleExport" :icon="Download" class="action-btn">导出数据</el-button> -->
</div>
</div>
<!-- 统计卡片 -->
<div class="stats-panel">
<div class="stat-card total-card">
@@ -44,102 +32,115 @@
</div>
</div>
<!-- 搜索和筛选 -->
<el-card class="filter-container" shadow="never">
<el-form :inline="true" :model="queryParams" class="search-form">
<el-form-item label="搜索容器">
<el-input v-model="queryParams.domain" placeholder="请输入容器id或服务器id" clearable />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery" :icon="Search">查询</el-button>
<el-button @click="resetQuery" :icon="Delete">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="main-container" shadow="never">
<!-- 搜索和筛选 -->
<div class="filter-section">
<div class="filter-content">
<el-form :inline="true" :model="queryParams" class="search-form">
<el-form-item label="搜索容器">
<el-input v-model="queryParams.domain" placeholder="请输入容器id或服务器id" clearable />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">
<el-icon><Search /></el-icon>查询
</el-button>
<el-button @click="resetQuery">
<el-icon><Delete /></el-icon>重置
</el-button>
</el-form-item>
</el-form>
<div class="action-bar">
<el-button type="primary" @click="handleRefresh">
<el-icon><Refresh /></el-icon>刷新
</el-button>
</div>
</div>
</div>
<!-- 站点列表 -->
<el-card class="table-container" shadow="never">
<el-table
v-loading="loading"
:data="siteList"
@selection-change="handleSelectionChange"
style="width: 100%"
border
stripe
>
<el-table-column type="selection" width="55" />
<el-table-column prop="container_id" label="容器ID" width="280" show-overflow-tooltip />
<el-table-column prop="url" label="访问地址" min-width="200" show-overflow-tooltip>
<template #default="{ row }">
<el-link :href="row.url" target="_blank" type="primary" v-if="row.url">
{{ row.url }}
</el-link>
<span v-else class="text-muted">无访问地址</span>
</template>
</el-table-column>
<el-table-column label="连接类型" width="120" align="center">
<template #default="{ row }">
<el-tag :type="getConnectTypeColor(row.connect_type)" size="small">
{{ getConnectTypeText(row.connect_type) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="连接状态" width="100" align="center">
<template #default="{ row }">
<el-tag
:type="getConnectionStatusType(row.connect)"
effect="plain"
size="small"
>
{{ getConnectionStatusText(row.connect) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="违规状态" width="100" align="center">
<template #default="{ row }">
<el-tag
:type="row.is_violation ? 'danger' : 'success'"
effect="plain"
size="small"
>
{{ row.is_violation ? '违规' : '正常' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="180" />
<el-table-column label="操作" fixed="right" align="center">
<template #default="{ row }">
<div class="action-buttons">
<!-- 站点列表 -->
<div class="table-section">
<el-table
v-loading="loading"
:data="siteList"
@selection-change="handleSelectionChange"
style="width: 100%"
:header-cell-style="{ background: '#fafafa', color: '#333', fontWeight: 600 }"
>
<el-table-column type="selection" width="55" />
<el-table-column prop="container_id" label="容器ID" width="280" show-overflow-tooltip />
<el-table-column prop="url" label="访问地址" min-width="200" show-overflow-tooltip>
<template #default="{ row }">
<el-link :href="row.url" target="_blank" type="primary" v-if="row.url">
{{ row.url }}
</el-link>
<span v-else class="text-muted">无访问地址</span>
</template>
</el-table-column>
<el-table-column label="连接类型" width="120" align="center">
<template #default="{ row }">
<el-tag :type="getConnectTypeColor(row.connect_type)" size="small">
{{ getConnectTypeText(row.connect_type) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="连接状态" width="100" align="center">
<template #default="{ row }">
<el-tag
:type="getConnectionStatusType(row.connect)"
effect="plain"
size="small"
>
{{ getConnectionStatusText(row.connect) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="违规状态" width="100" align="center">
<template #default="{ row }">
<el-tag
:type="row.is_violation ? 'danger' : 'success'"
effect="plain"
size="small"
>
{{ row.is_violation ? '违规' : '正常' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="180" />
<el-table-column label="操作" fixed="right" align="center" width="180">
<template #default="{ row }">
<el-tooltip content="重新检查" placement="top">
<el-button type="warning" :icon="Refresh" circle size="small" @click="handleRecheck(row)" />
<el-button type="warning" link @click="handleRecheck(row)">
<el-icon><Refresh /></el-icon>检查
</el-button>
</el-tooltip>
<el-tooltip content="标记违规" placement="top" v-if="row.status !== 'violation'">
<el-button type="danger" :icon="Warning" circle size="small" @click="handleMarkViolation(row)" />
<el-button type="danger" link @click="handleMarkViolation(row)">
<el-icon><Warning /></el-icon>违规
</el-button>
</el-tooltip>
<el-tooltip content="标记正常" placement="top" v-if="row.status === 'violation'">
<el-button type="success" :icon="CircleCheck" circle size="small" @click="handleMarkNormal(row)" />
<el-button type="success" link @click="handleMarkNormal(row)">
<el-icon><CircleCheck /></el-icon>正常
</el-button>
</el-tooltip>
</div>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
v-model:current-page="queryParams.pageNum"
v-model:page-size="queryParams.pageSize"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
background
class="pagination"
/>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
v-model:current-page="queryParams.pageNum"
v-model:page-size="queryParams.pageSize"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
background
class="pagination"
/>
</div>
</el-card>
</div>
</template>
@@ -650,42 +651,7 @@ onMounted(() => {
<style scoped>
.all-sites-container {
padding: 20px;
min-height: calc(100vh - 120px);
background-color: #f5f7fa;
}
/* 页面标题样式 */
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
padding-bottom: 16px;
border-bottom: 1px solid #ebeef5;
}
.page-header .left {
display: flex;
align-items: center;
gap: 12px;
}
.page-header .title {
margin: 0;
font-size: 24px;
font-weight: 600;
color: #303133;
}
.count-tag {
font-size: 13px;
}
.page-header .actions {
display: flex;
gap: 12px;
align-items: center;
padding: 0;
}
/* 统计卡片 */
@@ -698,18 +664,18 @@ onMounted(() => {
.stat-card {
background: white;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
border-radius: 4px;
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
padding: 20px;
display: flex;
align-items: center;
transition: all 0.3s;
border: 1px solid #ebeef5;
border: 1px solid #e1e8ed;
}
.stat-card:hover {
transform: translateY(-3px);
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
.stat-icon {
@@ -753,88 +719,129 @@ onMounted(() => {
font-weight: 600;
margin-bottom: 4px;
line-height: 1.1;
color: #303133;
}
.stat-label {
font-size: 14px;
color: #606266;
color: #909399;
}
/* 筛选容器 */
.filter-container {
margin-bottom: 20px;
.main-container {
border: 1px solid #e1e8ed;
background: #ffffff;
}
.filter-section {
padding: 0;
border-bottom: 1px solid #e1e8ed;
background: #fafbfc;
}
.filter-content {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 20px;
gap: 20px;
flex-wrap: wrap;
}
.search-form {
margin: 0;
flex: 1;
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.search-form :deep(.el-form-item) {
margin-bottom: 0;
margin-right: 12px;
}
/* 表格容器 */
.table-container {
margin-bottom: 20px;
}
.action-buttons {
.action-bar {
display: flex;
justify-content: center;
gap: 8px;
gap: 12px;
flex-shrink: 0;
}
.table-section {
padding: 0;
}
/* 分页 */
.pagination {
margin-top: 15px;
display: flex;
justify-content: flex-end;
}
/* 站点详情 */
.site-detail {
padding: 10px 0;
}
.detail-section {
margin-top: 20px;
}
.detail-section h4 {
margin-bottom: 12px;
color: #303133;
font-weight: 600;
}
/* 对话框底部 */
.dialog-footer {
display: flex;
padding: 16px 20px;
border-top: 1px solid #e1e8ed;
background: #fafbfc;
justify-content: flex-end;
}
/* 表格样式优化 */
:deep(.el-table) {
border: none;
color: #2c3e50;
}
:deep(.el-table__header) {
background: #f8f9fa;
}
:deep(.el-table th) {
background: #f8f9fa !important;
border-bottom: 2px solid #e1e8ed;
color: #2c3e50;
font-weight: 600;
font-size: 13px;
}
:deep(.el-table td) {
border-bottom: 1px solid #f0f2f5;
color: #34495e;
}
:deep(.el-table tr:hover > td) {
background-color: #f8f9fa !important;
}
:deep(.el-card__body) {
padding: 0;
}
/* 响应式设计 */
@media screen and (max-width: 1200px) {
@media screen and (max-width: 992px) {
.stats-panel {
grid-template-columns: repeat(2, 1fr);
}
.stat-card:last-child {
grid-column: span 2;
}
}
@media screen and (max-width: 768px) {
.page-header {
flex-direction: column;
align-items: flex-start;
gap: 16px;
}
.page-header .actions {
width: 100%;
flex-wrap: wrap;
}
.stats-panel {
grid-template-columns: 1fr;
}
}
/* 自定义样式 */
.text-muted {
color: #909399;
font-style: italic;
.stat-card:last-child {
grid-column: auto;
}
.filter-content {
flex-direction: column;
align-items: stretch;
}
.search-form {
width: 100%;
}
.action-bar {
width: 100%;
justify-content: flex-start;
}
}
</style>