ACS
This commit is contained in:
+196
@@ -0,0 +1,196 @@
|
||||
007 Admin UI项目,基于elementplus+vue3+vite+vue-router进行开发的企业级高端后台管理系统UI。
|
||||
|
||||
使用pnpm包管理器。
|
||||
|
||||
组件封装到src/components目录下。
|
||||
路由封装到src/router目录下。
|
||||
api封装到src/api目录下。
|
||||
store封装到src/store目录下。
|
||||
页面封装到src/views目录下。
|
||||
|
||||
当你实现一个通用组件后,应该在compoents.md文件中记录下来,记录组件名称、参数、事件、使用方法。
|
||||
|
||||
请保持整体风格样式统一,也就是说在实现一个页面或者组件之前你需要先阅读其他已经实现的页面。
|
||||
在没有实现具体页面之前禁止注册路由。
|
||||
在需要的情况下你需要注册侧边栏
|
||||
请使用vue3 setup语法糖开发,禁止使用scss。禁止使用ts。
|
||||
|
||||
注册侧边栏在/config/menus.js文件中。
|
||||
|
||||
|
||||
|
||||
## 1. 基础布局规范
|
||||
```css
|
||||
/* 页面容器 */
|
||||
.page-container {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 筛选容器 */
|
||||
.filter-container {
|
||||
margin-bottom: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
/* 搜索表单 */
|
||||
.search-form {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
/* 操作栏 */
|
||||
.action-bar {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* 表格容器 */
|
||||
.table-container {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
```
|
||||
|
||||
## 2. 表格样式规范
|
||||
```css
|
||||
/* 表格基础样式 */
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* 表头样式 */
|
||||
:deep(.el-table th) {
|
||||
background-color: #f8f9fb !important;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
height: 50px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
/* 单元格样式 */
|
||||
:deep(.el-table td) {
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
/* 斑马纹样式 */
|
||||
:deep(.el-table--striped .el-table__body tr.el-table__row--striped td) {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
/* 行悬停效果 */
|
||||
:deep(.el-table__body tr:hover > td) {
|
||||
background-color: #f1f5f9 !important;
|
||||
}
|
||||
|
||||
/* 行过渡动画 */
|
||||
:deep(.el-table__body tr) {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
```
|
||||
|
||||
## 3. 分页样式规范
|
||||
```css
|
||||
/* 分页容器 */
|
||||
.pagination {
|
||||
margin-top: 24px;
|
||||
justify-content: flex-end;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
/* 分页基础样式 */
|
||||
:deep(.el-pagination) {
|
||||
--el-pagination-hover-color: #1f2937;
|
||||
}
|
||||
|
||||
/* 禁用按钮样式 */
|
||||
:deep(.el-pagination button:disabled) {
|
||||
background-color: #f1f5f9;
|
||||
}
|
||||
|
||||
/* 页码样式 */
|
||||
:deep(.el-pagination .el-pager li) {
|
||||
border-radius: 4px;
|
||||
margin: 0 2px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
/* 激活页码样式 */
|
||||
:deep(.el-pagination .el-pager li.active) {
|
||||
background-color: #1f2937;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 页码悬停效果 */
|
||||
:deep(.el-pagination .el-pager li:hover:not(.active)) {
|
||||
background-color: #f1f5f9;
|
||||
}
|
||||
```
|
||||
|
||||
## 4. 对话框样式规范
|
||||
```css
|
||||
/* 对话框底部 */
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 响应式设计规范
|
||||
```css
|
||||
/* 移动端适配 */
|
||||
@media (max-width: 768px) {
|
||||
.el-form-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.action-bar .el-button {
|
||||
width: 100%;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
padding: 8px 0;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 6. 颜色规范
|
||||
- 主色:#1f2937
|
||||
- 背景色:#f8f9fb
|
||||
- 悬停色:#f1f5f9
|
||||
- 文字主色:#1f2937
|
||||
- 文字次色:#64748b
|
||||
|
||||
## 7. 间距规范
|
||||
- 页面内边距:0
|
||||
- 卡片间距:20px
|
||||
- 表单间距:15px
|
||||
- 按钮间距:12px
|
||||
- 表格内边距:8px-12px
|
||||
|
||||
## 8. 圆角规范
|
||||
- 卡片圆角:8px
|
||||
- 按钮圆角:4px
|
||||
- 表格圆角:8px
|
||||
|
||||
## 9. 阴影规范
|
||||
- 卡片阴影:0 2px 12px 0 rgba(0, 0, 0, 0.05)
|
||||
|
||||
## 10. 动画规范
|
||||
- 过渡时间:0.3s
|
||||
- 过渡效果:ease
|
||||
@@ -1,5 +1,81 @@
|
||||
# Vue 3 + Vite + ElementPlus
|
||||
# 007UI 后台管理系统
|
||||
|
||||
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
一个基于Vue 3、Element Plus的现代化后台管理系统模板,采用蓝色扁平化高端设计风格。
|
||||
|
||||
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
|
||||
## 技术栈
|
||||
|
||||
- **前端框架**:Vue 3
|
||||
- **构建工具**:Vite
|
||||
- **UI组件库**:Element Plus
|
||||
- **路由管理**:Vue Router
|
||||
- **HTTP请求**:Axios
|
||||
- **图表库**:ECharts
|
||||
- **实用工具**:VueUse
|
||||
|
||||
## 特性
|
||||
|
||||
- 🎨 精美的蓝色扁平化UI设计风格
|
||||
- 📱 响应式布局,支持多端设备
|
||||
- 🧩 模块化设计,易于扩展
|
||||
- 🔐 内置完整的权限管理系统
|
||||
- 📊 集成数据可视化图表
|
||||
- 📝 丰富的表单组件和数据表格
|
||||
- 🌐 全局状态管理
|
||||
- 🚀 快速的开发体验
|
||||
|
||||
## 快速开始
|
||||
|
||||
确保已安装Node.js和pnpm包管理器。
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone https://github.com/yourusername/007ui.git
|
||||
|
||||
# 进入项目目录
|
||||
cd 007ui
|
||||
|
||||
# 安装依赖
|
||||
pnpm install
|
||||
|
||||
# 启动开发服务器
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
007ui/
|
||||
├── public/ # 静态资源
|
||||
├── src/ # 源代码
|
||||
│ ├── assets/ # 资源文件
|
||||
│ ├── components/ # 公共组件
|
||||
│ │ └── layout/ # 布局组件
|
||||
│ ├── router/ # 路由配置
|
||||
│ ├── utils/ # 工具函数
|
||||
│ ├── views/ # 页面组件
|
||||
│ ├── App.vue # 应用入口组件
|
||||
│ ├── main.js # 应用入口文件
|
||||
│ └── style.css # 全局样式
|
||||
├── .gitignore # Git忽略文件
|
||||
├── index.html # HTML模板
|
||||
├── package.json # 项目配置
|
||||
├── README.md # 项目说明
|
||||
└── vite.config.js # Vite配置
|
||||
```
|
||||
|
||||
## 布局和页面
|
||||
|
||||
- **登录页**:简洁美观的登录界面
|
||||
- **主布局**:包含侧边栏、顶部导航和内容区
|
||||
- **仪表盘**:数据概览和图表展示
|
||||
- **系统管理**:用户、角色、权限管理
|
||||
- **内容管理**:文章、分类、标签管理
|
||||
- **数据统计**:访问统计、性能监控
|
||||
|
||||
## 贡献
|
||||
|
||||
欢迎提交问题和功能请求。对于重大更改,请先开启一个issue讨论您想要的更改。
|
||||
|
||||
## 许可证
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
# 组件文档
|
||||
|
||||
## 图表组件
|
||||
|
||||
### BaseEChart
|
||||
基础图表组件,作为其他图表组件的基础组件。
|
||||
|
||||
#### 属性
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|------|------|------|--------|
|
||||
| options | ECharts 配置项 | Object | - |
|
||||
| width | 图表宽度 | String | '100%' |
|
||||
| height | 图表高度 | String | '350px' |
|
||||
| theme | 图表主题 | String | '' |
|
||||
|
||||
#### 方法
|
||||
| 方法名 | 说明 | 参数 |
|
||||
|--------|------|------|
|
||||
| getChart | 获取 ECharts 实例 | - |
|
||||
| resize | 重置图表大小 | - |
|
||||
|
||||
### LineChart
|
||||
折线图组件
|
||||
|
||||
#### 属性
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|------|------|------|--------|
|
||||
| data | 数据数组 | Array | - |
|
||||
| xAxis | X轴数据 | Array | - |
|
||||
| smooth | 是否平滑曲线 | Boolean | true |
|
||||
| area | 是否显示面积 | Boolean | false |
|
||||
| series | 系列配置 | Array | [] |
|
||||
| title | 图表标题 | String | '' |
|
||||
|
||||
#### 使用示例
|
||||
```vue
|
||||
<line-chart
|
||||
:data="[150, 230, 224, 218, 135, 147, 260]"
|
||||
:xAxis="['周一', '周二', '周三', '周四', '周五', '周六', '周日']"
|
||||
:smooth="true"
|
||||
:area="true"
|
||||
title="销售趋势"
|
||||
/>
|
||||
```
|
||||
|
||||
### BarChart
|
||||
柱状图组件
|
||||
|
||||
#### 属性
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|------|------|------|--------|
|
||||
| data | 数据数组 | Array | - |
|
||||
| xAxis | X轴数据 | Array | - |
|
||||
| showBackground | 是否显示背景 | Boolean | true |
|
||||
| series | 系列配置 | Array | [] |
|
||||
| title | 图表标题 | String | '' |
|
||||
| barWidth | 柱子宽度 | Number | 30 |
|
||||
|
||||
#### 使用示例
|
||||
```vue
|
||||
<bar-chart
|
||||
:data="[320, 332, 301, 334]"
|
||||
:xAxis="['第一季度', '第二季度', '第三季度', '第四季度']"
|
||||
:showBackground="true"
|
||||
title="季度业绩"
|
||||
/>
|
||||
```
|
||||
|
||||
### PieChart
|
||||
饼图组件
|
||||
|
||||
#### 属性
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|------|------|------|--------|
|
||||
| data | 数据数组,格式:[{name: '名称', value: 100}] | Array | - |
|
||||
| ring | 是否显示为环形图 | Boolean | false |
|
||||
| title | 图表标题 | String | '' |
|
||||
| radius | 饼图半径 | String/Array | '70%' |
|
||||
| showLegend | 是否显示图例 | Boolean | true |
|
||||
| legendPosition | 图例位置,可选值:'right'/'bottom' | String | 'right' |
|
||||
|
||||
#### 使用示例
|
||||
```vue
|
||||
<pie-chart
|
||||
:data="[
|
||||
{ value: 1048, name: '线上销售' },
|
||||
{ value: 735, name: '门店销售' },
|
||||
{ value: 580, name: '代理商' },
|
||||
{ value: 484, name: '其他' }
|
||||
]"
|
||||
:ring="false"
|
||||
title="收入来源分布"
|
||||
/>
|
||||
```
|
||||
|
||||
## 使用注意事项
|
||||
|
||||
1. 依赖安装
|
||||
```bash
|
||||
npm install echarts @vueuse/core
|
||||
```
|
||||
|
||||
2. 自适应容器
|
||||
所有图表组件都会自动适应容器大小,确保容器具有明确的宽高。
|
||||
|
||||
3. 主题定制
|
||||
可以通过 BaseEChart 的 theme 属性设置主题,支持 ECharts 内置主题。
|
||||
|
||||
4. 性能优化
|
||||
- 当图表不可见时会自动销毁实例
|
||||
- 使用 v-if 而不是 v-show 来控制图表显示隐藏
|
||||
- 数据量较大时建议使用防抖处理
|
||||
|
||||
5. 示例访问
|
||||
可以通过访问 `/demo/charts` 路由查看完整的图表示例。
|
||||
+6
-4
@@ -1,10 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Vue</title>
|
||||
<meta name="description" content="007UI - 高端蓝色扁平化后台管理系统模板" />
|
||||
<meta name="keywords" content="管理系统,后台,模板,Vue3,ElementPlus" />
|
||||
<title>007UI 后台管理系统</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
+6
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "frontend-starter",
|
||||
"name": "007ui",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -10,9 +10,13 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@vueuse/core": "^13.1.0",
|
||||
"axios": "^1.7.9",
|
||||
"dayjs": "^1.11.13",
|
||||
"echarts": "^5.6.0",
|
||||
"element-plus": "^2.9.1",
|
||||
"pinia": "^3.0.2",
|
||||
"qrcode": "^1.5.4",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
},
|
||||
|
||||
Generated
+370
-10
@@ -11,15 +11,27 @@ importers:
|
||||
'@element-plus/icons-vue':
|
||||
specifier: ^2.3.1
|
||||
version: 2.3.1(vue@3.5.13)
|
||||
'@vueuse/core':
|
||||
specifier: ^13.1.0
|
||||
version: 13.1.0(vue@3.5.13)
|
||||
axios:
|
||||
specifier: ^1.7.9
|
||||
version: 1.7.9
|
||||
dayjs:
|
||||
specifier: ^1.11.13
|
||||
version: 1.11.13
|
||||
echarts:
|
||||
specifier: ^5.6.0
|
||||
version: 5.6.0
|
||||
element-plus:
|
||||
specifier: ^2.9.1
|
||||
version: 2.9.1(vue@3.5.13)
|
||||
pinia:
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.2(vue@3.5.13)
|
||||
qrcode:
|
||||
specifier: ^1.5.4
|
||||
version: 1.5.4
|
||||
vue:
|
||||
specifier: ^3.5.13
|
||||
version: 3.5.13
|
||||
@@ -252,61 +264,51 @@ packages:
|
||||
resolution: {integrity: sha512-Py5vFd5HWYN9zxBv3WMrLAXY3yYJ6Q/aVERoeUFwiDGiMOWsMs7FokXihSOaT/PMWUty/Pj60XDQndK3eAfE6A==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.29.1':
|
||||
resolution: {integrity: sha512-RiWpGgbayf7LUcuSNIbahr0ys2YnEERD4gYdISA06wa0i8RALrnzflh9Wxii7zQJEB2/Eh74dX4y/sHKLWp5uQ==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.29.1':
|
||||
resolution: {integrity: sha512-Z80O+taYxTQITWMjm/YqNoe9d10OX6kDh8X5/rFCMuPqsKsSyDilvfg+vd3iXIqtfmp+cnfL1UrYirkaF8SBZA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.29.1':
|
||||
resolution: {integrity: sha512-fOHRtF9gahwJk3QVp01a/GqS4hBEZCV1oKglVVq13kcK3NeVlS4BwIFzOHDbmKzt3i0OuHG4zfRP0YoG5OF/rA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-loongarch64-gnu@4.29.1':
|
||||
resolution: {integrity: sha512-5a7q3tnlbcg0OodyxcAdrrCxFi0DgXJSoOuidFUzHZ2GixZXQs6Tc3CHmlvqKAmOs5eRde+JJxeIf9DonkmYkw==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-powerpc64le-gnu@4.29.1':
|
||||
resolution: {integrity: sha512-9b4Mg5Yfz6mRnlSPIdROcfw1BU22FQxmfjlp/CShWwO3LilKQuMISMTtAu/bxmmrE6A902W2cZJuzx8+gJ8e9w==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.29.1':
|
||||
resolution: {integrity: sha512-G5pn0NChlbRM8OJWpJFMX4/i8OEU538uiSv0P6roZcbpe/WfhEO+AT8SHVKfp8qhDQzaz7Q+1/ixMy7hBRidnQ==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.29.1':
|
||||
resolution: {integrity: sha512-WM9lIkNdkhVwiArmLxFXpWndFGuOka4oJOZh8EP3Vb8q5lzdSCBuhjavJsw68Q9AKDGeOOIHYzYm4ZFvmWez5g==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.29.1':
|
||||
resolution: {integrity: sha512-87xYCwb0cPGZFoGiErT1eDcssByaLX4fc0z2nRM6eMtV9njAfEE6OW3UniAoDhX4Iq5xQVpE6qO9aJbCFumKYQ==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.29.1':
|
||||
resolution: {integrity: sha512-xufkSNppNOdVRCEC4WKvlR1FBDyqCSCpQeMMgv9ZyXqqtKBfkw1yfGMTUTs9Qsl6WQbJnsGboWCp7pJGkeMhKA==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.29.1':
|
||||
resolution: {integrity: sha512-F2OiJ42m77lSkizZQLuC+jiZ2cgueWQL5YC9tjo3AgaEw+KJmVxHGSyQfDUoYR9cci0lAywv2Clmckzulcq6ig==}
|
||||
@@ -338,6 +340,9 @@ packages:
|
||||
'@types/web-bluetooth@0.0.16':
|
||||
resolution: {integrity: sha512-oh8q2Zc32S6gd/j50GowEjKLoOVOwHP/bWVjKJInBwQqdOYMdPrf1oVlelTlyfFK3CKxL1uahMDAr+vy8T7yMQ==}
|
||||
|
||||
'@types/web-bluetooth@0.0.21':
|
||||
resolution: {integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==}
|
||||
|
||||
'@vitejs/plugin-vue@5.2.1':
|
||||
resolution: {integrity: sha512-cxh314tzaWwOLqVes2gnnCtvBDcM1UMdn+iFR+UjAn411dPT3tOmqrJjbMd7koZpMAmBM/GqeV4n9ge7JSiJJQ==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
@@ -360,6 +365,15 @@ packages:
|
||||
'@vue/devtools-api@6.6.4':
|
||||
resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==}
|
||||
|
||||
'@vue/devtools-api@7.7.2':
|
||||
resolution: {integrity: sha512-1syn558KhyN+chO5SjlZIwJ8bV/bQ1nOVTG66t2RbG66ZGekyiYNmRO7X9BJCXQqPsFHlnksqvPhce2qpzxFnA==}
|
||||
|
||||
'@vue/devtools-kit@7.7.2':
|
||||
resolution: {integrity: sha512-CY0I1JH3Z8PECbn6k3TqM1Bk9ASWxeMtTCvZr7vb+CHi+X/QwQm5F1/fPagraamKMAHVfuuCbdcnNg1A4CYVWQ==}
|
||||
|
||||
'@vue/devtools-shared@7.7.2':
|
||||
resolution: {integrity: sha512-uBFxnp8gwW2vD6FrJB8JZLUzVb6PNRG0B0jBnHsOH8uKyva2qINY8PTF5Te4QlTbMDqU5K6qtJDr6cNsKWhbOA==}
|
||||
|
||||
'@vue/reactivity@3.5.13':
|
||||
resolution: {integrity: sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==}
|
||||
|
||||
@@ -377,15 +391,36 @@ packages:
|
||||
'@vue/shared@3.5.13':
|
||||
resolution: {integrity: sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==}
|
||||
|
||||
'@vueuse/core@13.1.0':
|
||||
resolution: {integrity: sha512-PAauvdRXZvTWXtGLg8cPUFjiZEddTqmogdwYpnn60t08AA5a8Q4hZokBnpTOnVNqySlFlTcRYIC8OqreV4hv3Q==}
|
||||
peerDependencies:
|
||||
vue: ^3.5.0
|
||||
|
||||
'@vueuse/core@9.13.0':
|
||||
resolution: {integrity: sha512-pujnclbeHWxxPRqXWmdkKV5OX4Wk4YeK7wusHqRwU0Q7EFusHoqNA/aPhB6KCh9hEqJkLAJo7bb0Lh9b+OIVzw==}
|
||||
|
||||
'@vueuse/metadata@13.1.0':
|
||||
resolution: {integrity: sha512-+TDd7/a78jale5YbHX9KHW3cEDav1lz1JptwDvep2zSG8XjCsVE+9mHIzjTOaPbHUAk5XiE4jXLz51/tS+aKQw==}
|
||||
|
||||
'@vueuse/metadata@9.13.0':
|
||||
resolution: {integrity: sha512-gdU7TKNAUVlXXLbaF+ZCfte8BjRJQWPCa2J55+7/h+yDtzw3vOoGQDRXzI6pyKyo6bXFT5/QoPE4hAknExjRLQ==}
|
||||
|
||||
'@vueuse/shared@13.1.0':
|
||||
resolution: {integrity: sha512-IVS/qRRjhPTZ6C2/AM3jieqXACGwFZwWTdw5sNTSKk2m/ZpkuuN+ri+WCVUP8TqaKwJYt/KuMwmXspMAw8E6ew==}
|
||||
peerDependencies:
|
||||
vue: ^3.5.0
|
||||
|
||||
'@vueuse/shared@9.13.0':
|
||||
resolution: {integrity: sha512-UrnhU+Cnufu4S6JLCPZnkWh0WwZGUp72ktOF2DFptMlOs3TOdVv8xJN53zhHGARmVOsz5KqOls09+J1NR6sBKw==}
|
||||
|
||||
ansi-regex@5.0.1:
|
||||
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
ansi-styles@4.3.0:
|
||||
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
async-validator@4.2.5:
|
||||
resolution: {integrity: sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==}
|
||||
|
||||
@@ -395,25 +430,59 @@ packages:
|
||||
axios@1.7.9:
|
||||
resolution: {integrity: sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==}
|
||||
|
||||
birpc@0.2.19:
|
||||
resolution: {integrity: sha512-5WeXXAvTmitV1RqJFppT5QtUiz2p1mRSYU000Jkft5ZUCLJIk4uQriYNO50HknxKwM6jd8utNc66K1qGIwwWBQ==}
|
||||
|
||||
camelcase@5.3.1:
|
||||
resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
cliui@6.0.0:
|
||||
resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==}
|
||||
|
||||
color-convert@2.0.1:
|
||||
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||
engines: {node: '>=7.0.0'}
|
||||
|
||||
color-name@1.1.4:
|
||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||
|
||||
combined-stream@1.0.8:
|
||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
copy-anything@3.0.5:
|
||||
resolution: {integrity: sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==}
|
||||
engines: {node: '>=12.13'}
|
||||
|
||||
csstype@3.1.3:
|
||||
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
||||
|
||||
dayjs@1.11.13:
|
||||
resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==}
|
||||
|
||||
decamelize@1.2.0:
|
||||
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
delayed-stream@1.0.0:
|
||||
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
||||
dijkstrajs@1.0.3:
|
||||
resolution: {integrity: sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==}
|
||||
|
||||
echarts@5.6.0:
|
||||
resolution: {integrity: sha512-oTbVTsXfKuEhxftHqL5xprgLoc0k7uScAwtryCgWF6hPYFLRwOUHiFmHGCBKP5NPFNkDVopOieyUqYGH8Fa3kA==}
|
||||
|
||||
element-plus@2.9.1:
|
||||
resolution: {integrity: sha512-9Agqf/jt4Ugk7EZ6C5LME71sgkvauPCsnvJN12Xid2XVobjufxMGpRE4L7pS4luJMOmFAH3J0NgYEGZT5r+NDg==}
|
||||
peerDependencies:
|
||||
vue: ^3.2.0
|
||||
|
||||
emoji-regex@8.0.0:
|
||||
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||
|
||||
entities@4.5.0:
|
||||
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
|
||||
engines: {node: '>=0.12'}
|
||||
@@ -429,6 +498,10 @@ packages:
|
||||
estree-walker@2.0.2:
|
||||
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
||||
|
||||
find-up@4.1.0:
|
||||
resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
follow-redirects@1.15.9:
|
||||
resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==}
|
||||
engines: {node: '>=4.0'}
|
||||
@@ -447,6 +520,25 @@ packages:
|
||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
os: [darwin]
|
||||
|
||||
get-caller-file@2.0.5:
|
||||
resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
|
||||
engines: {node: 6.* || 8.* || >= 10.*}
|
||||
|
||||
hookable@5.5.3:
|
||||
resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==}
|
||||
|
||||
is-fullwidth-code-point@3.0.0:
|
||||
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
is-what@4.1.16:
|
||||
resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==}
|
||||
engines: {node: '>=12.13'}
|
||||
|
||||
locate-path@5.0.0:
|
||||
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
lodash-es@4.17.21:
|
||||
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
|
||||
|
||||
@@ -474,6 +566,9 @@ packages:
|
||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mitt@3.0.1:
|
||||
resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==}
|
||||
|
||||
nanoid@3.3.8:
|
||||
resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==}
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
@@ -482,9 +577,41 @@ packages:
|
||||
normalize-wheel-es@1.2.0:
|
||||
resolution: {integrity: sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw==}
|
||||
|
||||
p-limit@2.3.0:
|
||||
resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
p-locate@4.1.0:
|
||||
resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
p-try@2.2.0:
|
||||
resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
path-exists@4.0.0:
|
||||
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
perfect-debounce@1.0.0:
|
||||
resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==}
|
||||
|
||||
picocolors@1.1.1:
|
||||
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||
|
||||
pinia@3.0.2:
|
||||
resolution: {integrity: sha512-sH2JK3wNY809JOeiiURUR0wehJ9/gd9qFN2Y828jCbxEzKEmEt0pzCXwqiSTfuRsK9vQsOflSdnbdBOGrhtn+g==}
|
||||
peerDependencies:
|
||||
typescript: '>=4.4.4'
|
||||
vue: ^2.7.0 || ^3.5.11
|
||||
peerDependenciesMeta:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
pngjs@5.0.0:
|
||||
resolution: {integrity: sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
postcss@8.4.49:
|
||||
resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==}
|
||||
engines: {node: ^10 || ^12 || >=14}
|
||||
@@ -492,15 +619,52 @@ packages:
|
||||
proxy-from-env@1.1.0:
|
||||
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
|
||||
|
||||
qrcode@1.5.4:
|
||||
resolution: {integrity: sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
hasBin: true
|
||||
|
||||
require-directory@2.1.1:
|
||||
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
require-main-filename@2.0.0:
|
||||
resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==}
|
||||
|
||||
rfdc@1.4.1:
|
||||
resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==}
|
||||
|
||||
rollup@4.29.1:
|
||||
resolution: {integrity: sha512-RaJ45M/kmJUzSWDs1Nnd5DdV4eerC98idtUOVr6FfKcgxqvjwHmxc5upLF9qZU9EpsVzzhleFahrT3shLuJzIw==}
|
||||
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
||||
hasBin: true
|
||||
|
||||
set-blocking@2.0.0:
|
||||
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
|
||||
|
||||
source-map-js@1.2.1:
|
||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
speakingurl@14.0.1:
|
||||
resolution: {integrity: sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
string-width@4.2.3:
|
||||
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
strip-ansi@6.0.1:
|
||||
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
superjson@2.2.2:
|
||||
resolution: {integrity: sha512-5JRxVqC8I8NuOUjzBbvVJAKNM8qoVuH0O77h4WInc/qC2q5IreqKxYwgkga3PfA22OayK2ikceb/B26dztPl+Q==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
tslib@2.3.0:
|
||||
resolution: {integrity: sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==}
|
||||
|
||||
vite@6.0.5:
|
||||
resolution: {integrity: sha512-akD5IAH/ID5imgue2DYhzsEwCi0/4VKY31uhMLEYJwPP4TiUp8pL5PIK+Wo7H8qT8JY9i+pVfPydcFPYD1EL7g==}
|
||||
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
|
||||
@@ -565,6 +729,27 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
which-module@2.0.1:
|
||||
resolution: {integrity: sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==}
|
||||
|
||||
wrap-ansi@6.2.0:
|
||||
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
y18n@4.0.3:
|
||||
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
|
||||
|
||||
yargs-parser@18.1.3:
|
||||
resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
yargs@15.4.1:
|
||||
resolution: {integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
zrender@5.6.1:
|
||||
resolution: {integrity: sha512-OFXkDJKcrlx5su2XbzJvj/34Q3m6PvyCZkVPHGYpcCJ52ek4U/ymZyfuV1nKE23AyBJ51E/6Yr0mhZ7xGTO4ag==}
|
||||
|
||||
snapshots:
|
||||
|
||||
'@babel/helper-string-parser@7.25.9': {}
|
||||
@@ -740,6 +925,8 @@ snapshots:
|
||||
|
||||
'@types/web-bluetooth@0.0.16': {}
|
||||
|
||||
'@types/web-bluetooth@0.0.21': {}
|
||||
|
||||
'@vitejs/plugin-vue@5.2.1(vite@6.0.5)(vue@3.5.13)':
|
||||
dependencies:
|
||||
vite: 6.0.5
|
||||
@@ -777,6 +964,24 @@ snapshots:
|
||||
|
||||
'@vue/devtools-api@6.6.4': {}
|
||||
|
||||
'@vue/devtools-api@7.7.2':
|
||||
dependencies:
|
||||
'@vue/devtools-kit': 7.7.2
|
||||
|
||||
'@vue/devtools-kit@7.7.2':
|
||||
dependencies:
|
||||
'@vue/devtools-shared': 7.7.2
|
||||
birpc: 0.2.19
|
||||
hookable: 5.5.3
|
||||
mitt: 3.0.1
|
||||
perfect-debounce: 1.0.0
|
||||
speakingurl: 14.0.1
|
||||
superjson: 2.2.2
|
||||
|
||||
'@vue/devtools-shared@7.7.2':
|
||||
dependencies:
|
||||
rfdc: 1.4.1
|
||||
|
||||
'@vue/reactivity@3.5.13':
|
||||
dependencies:
|
||||
'@vue/shared': 3.5.13
|
||||
@@ -801,6 +1006,13 @@ snapshots:
|
||||
|
||||
'@vue/shared@3.5.13': {}
|
||||
|
||||
'@vueuse/core@13.1.0(vue@3.5.13)':
|
||||
dependencies:
|
||||
'@types/web-bluetooth': 0.0.21
|
||||
'@vueuse/metadata': 13.1.0
|
||||
'@vueuse/shared': 13.1.0(vue@3.5.13)
|
||||
vue: 3.5.13
|
||||
|
||||
'@vueuse/core@9.13.0(vue@3.5.13)':
|
||||
dependencies:
|
||||
'@types/web-bluetooth': 0.0.16
|
||||
@@ -811,8 +1023,14 @@ snapshots:
|
||||
- '@vue/composition-api'
|
||||
- vue
|
||||
|
||||
'@vueuse/metadata@13.1.0': {}
|
||||
|
||||
'@vueuse/metadata@9.13.0': {}
|
||||
|
||||
'@vueuse/shared@13.1.0(vue@3.5.13)':
|
||||
dependencies:
|
||||
vue: 3.5.13
|
||||
|
||||
'@vueuse/shared@9.13.0(vue@3.5.13)':
|
||||
dependencies:
|
||||
vue-demi: 0.14.10(vue@3.5.13)
|
||||
@@ -820,6 +1038,12 @@ snapshots:
|
||||
- '@vue/composition-api'
|
||||
- vue
|
||||
|
||||
ansi-regex@5.0.1: {}
|
||||
|
||||
ansi-styles@4.3.0:
|
||||
dependencies:
|
||||
color-convert: 2.0.1
|
||||
|
||||
async-validator@4.2.5: {}
|
||||
|
||||
asynckit@0.4.0: {}
|
||||
@@ -832,16 +1056,45 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
|
||||
birpc@0.2.19: {}
|
||||
|
||||
camelcase@5.3.1: {}
|
||||
|
||||
cliui@6.0.0:
|
||||
dependencies:
|
||||
string-width: 4.2.3
|
||||
strip-ansi: 6.0.1
|
||||
wrap-ansi: 6.2.0
|
||||
|
||||
color-convert@2.0.1:
|
||||
dependencies:
|
||||
color-name: 1.1.4
|
||||
|
||||
color-name@1.1.4: {}
|
||||
|
||||
combined-stream@1.0.8:
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
|
||||
copy-anything@3.0.5:
|
||||
dependencies:
|
||||
is-what: 4.1.16
|
||||
|
||||
csstype@3.1.3: {}
|
||||
|
||||
dayjs@1.11.13: {}
|
||||
|
||||
decamelize@1.2.0: {}
|
||||
|
||||
delayed-stream@1.0.0: {}
|
||||
|
||||
dijkstrajs@1.0.3: {}
|
||||
|
||||
echarts@5.6.0:
|
||||
dependencies:
|
||||
tslib: 2.3.0
|
||||
zrender: 5.6.1
|
||||
|
||||
element-plus@2.9.1(vue@3.5.13):
|
||||
dependencies:
|
||||
'@ctrl/tinycolor': 3.6.1
|
||||
@@ -863,6 +1116,8 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- '@vue/composition-api'
|
||||
|
||||
emoji-regex@8.0.0: {}
|
||||
|
||||
entities@4.5.0: {}
|
||||
|
||||
esbuild@0.24.0:
|
||||
@@ -896,6 +1151,11 @@ snapshots:
|
||||
|
||||
estree-walker@2.0.2: {}
|
||||
|
||||
find-up@4.1.0:
|
||||
dependencies:
|
||||
locate-path: 5.0.0
|
||||
path-exists: 4.0.0
|
||||
|
||||
follow-redirects@1.15.9: {}
|
||||
|
||||
form-data@4.0.1:
|
||||
@@ -907,6 +1167,18 @@ snapshots:
|
||||
fsevents@2.3.3:
|
||||
optional: true
|
||||
|
||||
get-caller-file@2.0.5: {}
|
||||
|
||||
hookable@5.5.3: {}
|
||||
|
||||
is-fullwidth-code-point@3.0.0: {}
|
||||
|
||||
is-what@4.1.16: {}
|
||||
|
||||
locate-path@5.0.0:
|
||||
dependencies:
|
||||
p-locate: 4.1.0
|
||||
|
||||
lodash-es@4.17.21: {}
|
||||
|
||||
lodash-unified@1.0.3(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21):
|
||||
@@ -929,12 +1201,35 @@ snapshots:
|
||||
dependencies:
|
||||
mime-db: 1.52.0
|
||||
|
||||
mitt@3.0.1: {}
|
||||
|
||||
nanoid@3.3.8: {}
|
||||
|
||||
normalize-wheel-es@1.2.0: {}
|
||||
|
||||
p-limit@2.3.0:
|
||||
dependencies:
|
||||
p-try: 2.2.0
|
||||
|
||||
p-locate@4.1.0:
|
||||
dependencies:
|
||||
p-limit: 2.3.0
|
||||
|
||||
p-try@2.2.0: {}
|
||||
|
||||
path-exists@4.0.0: {}
|
||||
|
||||
perfect-debounce@1.0.0: {}
|
||||
|
||||
picocolors@1.1.1: {}
|
||||
|
||||
pinia@3.0.2(vue@3.5.13):
|
||||
dependencies:
|
||||
'@vue/devtools-api': 7.7.2
|
||||
vue: 3.5.13
|
||||
|
||||
pngjs@5.0.0: {}
|
||||
|
||||
postcss@8.4.49:
|
||||
dependencies:
|
||||
nanoid: 3.3.8
|
||||
@@ -943,6 +1238,18 @@ snapshots:
|
||||
|
||||
proxy-from-env@1.1.0: {}
|
||||
|
||||
qrcode@1.5.4:
|
||||
dependencies:
|
||||
dijkstrajs: 1.0.3
|
||||
pngjs: 5.0.0
|
||||
yargs: 15.4.1
|
||||
|
||||
require-directory@2.1.1: {}
|
||||
|
||||
require-main-filename@2.0.0: {}
|
||||
|
||||
rfdc@1.4.1: {}
|
||||
|
||||
rollup@4.29.1:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.6
|
||||
@@ -968,8 +1275,28 @@ snapshots:
|
||||
'@rollup/rollup-win32-x64-msvc': 4.29.1
|
||||
fsevents: 2.3.3
|
||||
|
||||
set-blocking@2.0.0: {}
|
||||
|
||||
source-map-js@1.2.1: {}
|
||||
|
||||
speakingurl@14.0.1: {}
|
||||
|
||||
string-width@4.2.3:
|
||||
dependencies:
|
||||
emoji-regex: 8.0.0
|
||||
is-fullwidth-code-point: 3.0.0
|
||||
strip-ansi: 6.0.1
|
||||
|
||||
strip-ansi@6.0.1:
|
||||
dependencies:
|
||||
ansi-regex: 5.0.1
|
||||
|
||||
superjson@2.2.2:
|
||||
dependencies:
|
||||
copy-anything: 3.0.5
|
||||
|
||||
tslib@2.3.0: {}
|
||||
|
||||
vite@6.0.5:
|
||||
dependencies:
|
||||
esbuild: 0.24.0
|
||||
@@ -994,3 +1321,36 @@ snapshots:
|
||||
'@vue/runtime-dom': 3.5.13
|
||||
'@vue/server-renderer': 3.5.13(vue@3.5.13)
|
||||
'@vue/shared': 3.5.13
|
||||
|
||||
which-module@2.0.1: {}
|
||||
|
||||
wrap-ansi@6.2.0:
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
string-width: 4.2.3
|
||||
strip-ansi: 6.0.1
|
||||
|
||||
y18n@4.0.3: {}
|
||||
|
||||
yargs-parser@18.1.3:
|
||||
dependencies:
|
||||
camelcase: 5.3.1
|
||||
decamelize: 1.2.0
|
||||
|
||||
yargs@15.4.1:
|
||||
dependencies:
|
||||
cliui: 6.0.0
|
||||
decamelize: 1.2.0
|
||||
find-up: 4.1.0
|
||||
get-caller-file: 2.0.5
|
||||
require-directory: 2.1.1
|
||||
require-main-filename: 2.0.0
|
||||
set-blocking: 2.0.0
|
||||
string-width: 4.2.3
|
||||
which-module: 2.0.1
|
||||
y18n: 4.0.3
|
||||
yargs-parser: 18.1.3
|
||||
|
||||
zrender@5.6.1:
|
||||
dependencies:
|
||||
tslib: 2.3.0
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="200" height="200" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="100" cy="100" r="90" fill="#1890ff" />
|
||||
<text x="100" y="130" font-family="Arial, sans-serif" font-size="70" font-weight="bold" text-anchor="middle" fill="white">007</text>
|
||||
<text x="100" y="160" font-family="Arial, sans-serif" font-size="30" font-weight="bold" text-anchor="middle" fill="white">UI</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 486 B |
+116
-3
@@ -6,8 +6,121 @@
|
||||
</router-view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'App'
|
||||
<script setup>
|
||||
// 全局设置ElementPlus主题颜色
|
||||
import { useCssVar } from '@vueuse/core'
|
||||
import {useUserStore} from "@/store/userStore.js";
|
||||
import {onMounted} from "vue";
|
||||
import {getUserInfo} from "@/api/login.js";
|
||||
|
||||
const userStore = useUserStore()
|
||||
onMounted(async () => {
|
||||
let resp = await getUserInfo()
|
||||
userStore.setUserInfo(resp.data)
|
||||
console.log(userStore.userInfo)
|
||||
})
|
||||
// 设置主题颜色
|
||||
const primaryColor = '#1890ff'
|
||||
useCssVar('--el-color-primary', document.documentElement).value = primaryColor
|
||||
|
||||
// 生成不同深度的主题色
|
||||
const generateDarkColor = (color, level) => {
|
||||
const values = color.replace('#', '').match(/.{2}/g).map(v => parseInt(v, 16))
|
||||
const [r, g, b] = values.map(v => Math.max(0, Math.floor(v * (1 - level * 0.1))))
|
||||
return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
// 设置不同深度的主题色
|
||||
for (let i = 1; i <= 9; i++) {
|
||||
useCssVar(`--el-color-primary-light-${i}`, document.documentElement).value =
|
||||
i <= 5
|
||||
? `rgba(24, 144, 255, ${1 - i * 0.1})`
|
||||
: '#f0f9ff'
|
||||
|
||||
if (i <= 2) {
|
||||
useCssVar(`--el-color-primary-dark-${i}`, document.documentElement).value =
|
||||
generateDarkColor(primaryColor, i)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 全局样式 */
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
/* 过渡动画 */
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* 滚动条样式 */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #a8a8a8;
|
||||
}
|
||||
|
||||
/* Element Plus样式优化 */
|
||||
.el-button {
|
||||
font-weight: 400;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.el-card {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.el-menu {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.el-dialog {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.el-dialog__header {
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.el-dialog__footer {
|
||||
padding: 10px 20px 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,25 @@
|
||||
import request from "@/utils/request.js";
|
||||
|
||||
// 获取域名白名单列表
|
||||
export function getDomainList(params) {
|
||||
return request.get("/api/v1/admin/server/domain_withe/list",params)
|
||||
}
|
||||
|
||||
// 添加域名白名单
|
||||
export function addDomain(data) {
|
||||
return request.post("/api/v1/admin/server/domain_withe/add",data)
|
||||
}
|
||||
|
||||
// 删除域名白名单
|
||||
export function deleteDomain(id) {
|
||||
return request.post("/api/v1/admin/server/domain_withe/delete",{domain_id: id})
|
||||
}
|
||||
|
||||
// 批量删除域名白名单
|
||||
export async function batchDeleteDomain(ids) {
|
||||
let promises = []
|
||||
for (let id of ids) {
|
||||
promises.push(deleteDomain(id))
|
||||
}
|
||||
return await Promise.all(promises)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import request from "@/utils/request.js";
|
||||
|
||||
|
||||
export const userLogin = (username,password) => {
|
||||
return request.post("/api/v1/user/login",{username,password})
|
||||
}
|
||||
|
||||
export const getUserInfo = () => {
|
||||
return request.get("/api/v1/users/info/info")
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import request from "@/utils/request.js";
|
||||
/**
|
||||
* 获取工单列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
export function getTickerList(count, page, status) {
|
||||
return request.get('/api/v1/admin/work_order/list', { count, page, status })
|
||||
}
|
||||
|
||||
// 待处理
|
||||
export function getPendingTicketList(count, page) {
|
||||
return getTickerList(count,page,0)
|
||||
}
|
||||
|
||||
// 进行中
|
||||
export function getProcessingTicketList(count, page) {
|
||||
return getTickerList(count,page,1)
|
||||
}
|
||||
|
||||
//已回复
|
||||
export function getRepliedTicketList(count, page) {
|
||||
return getTickerList(count,page,2)
|
||||
}
|
||||
|
||||
// 已解决
|
||||
export function getCompletedTicketList(count, page) {
|
||||
return getTickerList(count,page,3)
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
export function getTicketDetail(work_id) {
|
||||
return request.get('/api/v1/admin/work_order/detail', { work_id })
|
||||
}
|
||||
|
||||
// 回复
|
||||
export function replyTicket(work_id, content, files) {
|
||||
return request.post('/api/v1/admin/work_order/reply', { work_id, content, files })
|
||||
}
|
||||
|
||||
// 关闭工单
|
||||
export function closeTicket(work_id) {
|
||||
return request.post('/api/v1/admin/work_order/close', { work_id })
|
||||
}
|
||||
|
||||
export function getFile(file_id) {
|
||||
return request.get('/api/v1/tool/file/down', { file_id })
|
||||
}
|
||||
|
||||
// 获取用户头像
|
||||
export function getUserAvatar(user_id) {
|
||||
// TODO: 实现获取用户头像的逻辑
|
||||
return `https://avatar.example.com/${user_id}`
|
||||
}
|
||||
|
||||
// 获取文件图片
|
||||
export async function getFileImage(file_id) {
|
||||
let resp = await getFile(file_id)
|
||||
console.log(resp.data.content)
|
||||
return resp.data.content
|
||||
}
|
||||
|
||||
// 解析多个文件ID为图片URL数组
|
||||
export async function parseFilesToImages(files) {
|
||||
if (!files || files === '') return []
|
||||
|
||||
const fileIds = files.split(',')
|
||||
return await Promise.all(fileIds.map(async (id) => await getFileImage(id.trim())))
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="252px" height="294px" viewBox="0 0 252 294" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
|
||||
<stop stop-color="#1890FF" offset="0%"></stop>
|
||||
<stop stop-color="#096DD9" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<path d="M0,62.0354 C0,27.7583 27.7584,0 62.0354,0 L189.9646,0 C224.2416,0 252,27.7583 252,62.0354 L252,232.9646 C252,267.2417 224.2416,295 189.9646,295 L62.0354,295 C27.7584,295 0,267.2417 0,232.9646 L0,62.0354 Z" id="path-2"></path>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-3">
|
||||
<stop stop-color="#1890FF" stop-opacity="0.2" offset="0%"></stop>
|
||||
<stop stop-color="#096DD9" stop-opacity="0.1" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="404" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group-3" transform="translate(21.000000, 13.000000)">
|
||||
<path d="M8,33 L8,227 C8,232.5228 12.4771,237 18,237 L191.9646,237 C210.6669,237 226,221.6668 226,202.9646 L226,33 L8,33 Z" id="Rectangle-Copy-14" fill="#F5F7FA" fill-rule="nonzero"></path>
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-2"></use>
|
||||
</mask>
|
||||
<use id="Rectangle" fill="url(#linearGradient-1)" fill-rule="nonzero" opacity="0.7" xlink:href="#path-2"></use>
|
||||
<circle id="Oval" fill="url(#linearGradient-3)" mask="url(#mask-2)" cx="126" cy="147.5" r="90"></circle>
|
||||
<text id="404" font-family="Arial-BoldMT, Arial" font-size="130" font-weight="bold" letter-spacing="-4.33333" fill="#FFFFFF">
|
||||
<tspan x="22" y="183">404</tspan>
|
||||
</text>
|
||||
<path d="M21,244 L21,33 L29,33 L29,244 L21,244 Z" id="Rectangle" fill="#E6F7FF" fill-rule="nonzero"></path>
|
||||
<path d="M198,33 L198,244 L191,244 L191,33 L198,33 Z" id="Rectangle-Copy-13" fill="#E6F7FF" fill-rule="nonzero"></path>
|
||||
<path d="M41,63 L41,56 L212,56 L212,63 L41,63 Z" id="Rectangle-Copy-15" fill="#E6F7FF" fill-rule="nonzero"></path>
|
||||
<path d="M41,222 L41,215 L212,215 L212,222 L41,222 Z" id="Rectangle-Copy-16" fill="#E6F7FF" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="200" height="200" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="100" cy="100" r="90" fill="#1890ff" />
|
||||
<text x="100" y="130" font-family="Arial, sans-serif" font-size="70" font-weight="bold" text-anchor="middle" fill="white">007</text>
|
||||
<text x="100" y="160" font-family="Arial, sans-serif" font-size="30" font-weight="bold" text-anchor="middle" fill="white">UI</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 486 B |
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<BaseEChart :options="chartOptions" v-bind="$attrs" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import BaseEChart from './BaseEChart.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'BarChart'
|
||||
})
|
||||
|
||||
const props = defineProps({
|
||||
// 数据项
|
||||
data: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
// x轴数据
|
||||
xAxis: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
// 是否显示背景
|
||||
showBackground: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 系列配置
|
||||
series: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
// 图表标题
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 柱子宽度
|
||||
barWidth: {
|
||||
type: Number,
|
||||
default: 30
|
||||
}
|
||||
})
|
||||
|
||||
const chartOptions = computed(() => {
|
||||
const series = props.series.length > 0 ? props.series : [{
|
||||
name: '数值',
|
||||
data: props.data,
|
||||
type: 'bar',
|
||||
barWidth: props.barWidth,
|
||||
showBackground: props.showBackground,
|
||||
backgroundStyle: {
|
||||
color: 'rgba(180, 180, 180, 0.1)'
|
||||
},
|
||||
itemStyle: {
|
||||
borderRadius: [4, 4, 0, 0]
|
||||
}
|
||||
}]
|
||||
|
||||
return {
|
||||
title: props.title ? {
|
||||
text: props.title,
|
||||
left: 'center',
|
||||
top: 10
|
||||
} : null,
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow'
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
top: props.title ? '60px' : '40px',
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: props.xAxis,
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#E5E7EB'
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: '#E5E7EB'
|
||||
}
|
||||
},
|
||||
axisLine: {
|
||||
show: false
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
series
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<div ref="chartRef" :style="{ width: width, height: height }" class="chart-container"></div>
|
||||
</template>
|
||||
|
||||
<script setup name="BaseEChart">
|
||||
import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
|
||||
import * as echarts from 'echarts'
|
||||
import { useElementSize, useResizeObserver } from '@vueuse/core'
|
||||
|
||||
defineOptions({
|
||||
name: 'BaseEChart'
|
||||
})
|
||||
|
||||
const props = defineProps({
|
||||
options: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
width: {
|
||||
type: String,
|
||||
default: '100%'
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
default: '350px'
|
||||
},
|
||||
theme: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
const chartRef = ref(null)
|
||||
let chartInstance = null
|
||||
|
||||
// 初始化图表
|
||||
const initChart = () => {
|
||||
if (chartInstance) {
|
||||
chartInstance.dispose()
|
||||
}
|
||||
|
||||
if (!chartRef.value) return
|
||||
|
||||
chartInstance = echarts.init(chartRef.value, props.theme)
|
||||
chartInstance.setOption(props.options)
|
||||
}
|
||||
|
||||
// 监听容器大小变化
|
||||
useResizeObserver(chartRef, () => {
|
||||
if (chartInstance) {
|
||||
chartInstance.resize()
|
||||
}
|
||||
})
|
||||
|
||||
// 监听配置变化
|
||||
watch(
|
||||
() => props.options,
|
||||
(newOptions) => {
|
||||
if (chartInstance) {
|
||||
chartInstance.setOption(newOptions)
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
initChart()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (chartInstance) {
|
||||
chartInstance.dispose()
|
||||
chartInstance = null
|
||||
}
|
||||
})
|
||||
|
||||
// 暴露更新方法
|
||||
defineExpose({
|
||||
getChart: () => chartInstance,
|
||||
resize: () => chartInstance?.resize()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chart-container {
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<BaseEChart :options="chartOptions" v-bind="$attrs" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import BaseEChart from './BaseEChart.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'LineChart'
|
||||
})
|
||||
|
||||
const props = defineProps({
|
||||
// 数据项
|
||||
data: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
// x轴数据
|
||||
xAxis: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
// 是否平滑曲线
|
||||
smooth: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 是否显示面积
|
||||
area: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 系列配置
|
||||
series: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
// 图表标题
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
const chartOptions = computed(() => {
|
||||
const series = props.series.length > 0 ? props.series : [{
|
||||
name: '数值',
|
||||
data: props.data,
|
||||
type: 'line',
|
||||
smooth: props.smooth,
|
||||
areaStyle: props.area ? {} : null,
|
||||
showSymbol: true,
|
||||
symbolSize: 6,
|
||||
lineStyle: {
|
||||
width: 2
|
||||
}
|
||||
}]
|
||||
|
||||
return {
|
||||
title: props.title ? {
|
||||
text: props.title,
|
||||
left: 'center',
|
||||
top: 10
|
||||
} : null,
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'cross'
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
top: props.title ? '60px' : '40px',
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: props.xAxis,
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#E5E7EB'
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: '#E5E7EB'
|
||||
}
|
||||
},
|
||||
axisLine: {
|
||||
show: false
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
series
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<BaseEChart :options="chartOptions" v-bind="$attrs" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import BaseEChart from './BaseEChart.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'PieChart'
|
||||
})
|
||||
|
||||
const props = defineProps({
|
||||
// 数据项 [{name: '名称', value: 100}]
|
||||
data: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
// 是否显示为环形图
|
||||
ring: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 图表标题
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 半径设置
|
||||
radius: {
|
||||
type: [String, Array],
|
||||
default: '70%'
|
||||
},
|
||||
// 是否显示图例
|
||||
showLegend: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 图例位置
|
||||
legendPosition: {
|
||||
type: String,
|
||||
default: 'right' // 'right', 'bottom'
|
||||
}
|
||||
})
|
||||
|
||||
const chartOptions = computed(() => {
|
||||
return {
|
||||
title: props.title ? {
|
||||
text: props.title,
|
||||
left: 'center',
|
||||
top: 10
|
||||
} : null,
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b}: {c} ({d}%)'
|
||||
},
|
||||
legend: props.showLegend ? {
|
||||
orient: props.legendPosition === 'right' ? 'vertical' : 'horizontal',
|
||||
[props.legendPosition]: '5%',
|
||||
top: props.legendPosition === 'right' ? 'middle' : 'bottom',
|
||||
itemWidth: 10,
|
||||
itemHeight: 10,
|
||||
icon: 'circle'
|
||||
} : undefined,
|
||||
series: [
|
||||
{
|
||||
name: props.title || '数据占比',
|
||||
type: 'pie',
|
||||
radius: props.ring ? ['50%', '70%'] : props.radius,
|
||||
avoidLabelOverlap: true,
|
||||
itemStyle: {
|
||||
borderRadius: 4,
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
formatter: '{b}: {d}%'
|
||||
},
|
||||
labelLine: {
|
||||
show: true
|
||||
},
|
||||
data: props.data
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
padding: 16px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,43 +0,0 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps({
|
||||
msg: String,
|
||||
})
|
||||
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>{{ msg }}</h1>
|
||||
|
||||
<div class="card">
|
||||
<button type="button" @click="count++">count is {{ count }}</button>
|
||||
<p>
|
||||
Edit
|
||||
<code>components/HelloWorld.vue</code> to test HMR
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Check out
|
||||
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
||||
>create-vue</a
|
||||
>, the official Vue + Vite starter
|
||||
</p>
|
||||
<p>
|
||||
Learn more about IDE Support for Vue in the
|
||||
<a
|
||||
href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
|
||||
target="_blank"
|
||||
>Vue Docs Scaling up Guide</a
|
||||
>.
|
||||
</p>
|
||||
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<div class="qrcode-container">
|
||||
<canvas ref="qrcodeCanvas"></canvas>
|
||||
<div v-if="!text" class="qrcode-placeholder">请提供文本以生成二维码</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import QRCode from 'qrcode'
|
||||
|
||||
const props = defineProps({
|
||||
text: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: ''
|
||||
},
|
||||
size: {
|
||||
type: Number,
|
||||
default: 128
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
|
||||
const qrcodeCanvas = ref(null)
|
||||
|
||||
const generateQRCode = async () => {
|
||||
if (!props.text || !qrcodeCanvas.value) {
|
||||
// 如果没有文本或者canvas未准备好,则清空canvas
|
||||
const ctx = qrcodeCanvas.value?.getContext('2d');
|
||||
if (ctx) {
|
||||
ctx.clearRect(0, 0, qrcodeCanvas.value.width, qrcodeCanvas.value.height);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const defaultOptions = {
|
||||
width: props.size,
|
||||
height: props.size,
|
||||
margin: 2,
|
||||
color: {
|
||||
dark: '#000000',
|
||||
light: '#ffffff'
|
||||
},
|
||||
errorCorrectionLevel: 'M' // 容错级别 L M Q H
|
||||
};
|
||||
|
||||
const finalOptions = { ...defaultOptions, ...props.options };
|
||||
|
||||
await QRCode.toCanvas(qrcodeCanvas.value, props.text, finalOptions);
|
||||
} catch (err) {
|
||||
console.error('生成二维码失败:', err);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
generateQRCode()
|
||||
})
|
||||
|
||||
watch(() => [props.text, props.size, props.options], () => {
|
||||
generateQRCode()
|
||||
}, { deep: true })
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.qrcode-container {
|
||||
display: inline-flex; /* 使容器适应内容大小 */
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
canvas {
|
||||
display: block; /* 移除canvas默认的底部空间 */
|
||||
}
|
||||
|
||||
.qrcode-placeholder {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<div class="text-truncate" :title="showTooltip ? text : undefined">
|
||||
{{ truncatedText }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'TextTruncate',
|
||||
props: {
|
||||
text: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: ''
|
||||
},
|
||||
maxLength: {
|
||||
type: Number,
|
||||
default: 20
|
||||
},
|
||||
ellipsis: {
|
||||
type: String,
|
||||
default: '...'
|
||||
},
|
||||
showTooltip: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
truncatedText() {
|
||||
if (!this.text || this.text.length <= this.maxLength) {
|
||||
return this.text;
|
||||
}
|
||||
return this.text.slice(0, this.maxLength) + this.ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.text-truncate {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
<template>
|
||||
<div class="admin-layout">
|
||||
<!-- 侧边栏 -->
|
||||
<div class="sidebar">
|
||||
<div class="logo-container">
|
||||
<h1 class="title">零零七云计算后台控制面板</h1>
|
||||
</div>
|
||||
<el-scrollbar>
|
||||
<el-menu
|
||||
:default-active="activeMenu"
|
||||
class="sidebar-menu"
|
||||
background-color="#ffffff"
|
||||
text-color="#333333"
|
||||
active-text-color="#1890ff"
|
||||
:unique-opened="true"
|
||||
router
|
||||
>
|
||||
<sidebar-menu-item v-for="menu in menus" :key="menu.path" :menu="menu" />
|
||||
</el-menu>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
|
||||
<!-- 主区域 -->
|
||||
<div class="main-container">
|
||||
<!-- 顶部导航 -->
|
||||
<div class="navbar">
|
||||
<div class="navbar-left">
|
||||
<breadcrumb />
|
||||
</div>
|
||||
<div class="navbar-right">
|
||||
<div class="navbar-item">
|
||||
<el-tooltip content="全屏" placement="bottom">
|
||||
<el-button type="text" class="header-btn" @click="toggleFullScreen">
|
||||
<el-icon :size="18"><full-screen /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
|
||||
<div class="navbar-item">
|
||||
<el-dropdown trigger="click">
|
||||
<div class="avatar-container">
|
||||
<el-avatar :size="32" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
|
||||
<span class="username">{{ userStore.userInfo.user_name }}</span>
|
||||
<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||
</div>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item @click="router.push('/profile')">
|
||||
<el-icon><user /></el-icon>个人信息
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click="router.push('/change-password')">
|
||||
<el-icon><key /></el-icon>修改密码
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item divided @click="handleLogout">
|
||||
<el-icon><switch-button /></el-icon>退出登录
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 标签页 -->
|
||||
<tags-view />
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<div class="content-container">
|
||||
<el-config-provider :locale="zhCn">
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition name="fade" mode="out-in">
|
||||
<keep-alive>
|
||||
<component :is="Component" />
|
||||
</keep-alive>
|
||||
</transition>
|
||||
</router-view>
|
||||
</el-config-provider>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import SidebarMenuItem from './SidebarMenuItem.vue'
|
||||
import Breadcrumb from './Breadcrumb.vue'
|
||||
import TagsView from './TagsView.vue'
|
||||
import { menus as menuConfig } from '@/config/menus'
|
||||
import {
|
||||
FullScreen,
|
||||
ArrowDown,
|
||||
User,
|
||||
Key,
|
||||
SwitchButton
|
||||
} from '@element-plus/icons-vue'
|
||||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import {useUserStore} from "@/store/userStore.js";
|
||||
|
||||
const userStore = useUserStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
// 侧边栏菜单数据
|
||||
const menus = ref(menuConfig)
|
||||
|
||||
// 获取当前激活的菜单项
|
||||
const activeMenu = computed(() => {
|
||||
return route.path
|
||||
})
|
||||
|
||||
// 切换全屏
|
||||
const toggleFullScreen = () => {
|
||||
if (!document.fullscreenElement) {
|
||||
document.documentElement.requestFullscreen()
|
||||
} else {
|
||||
if (document.exitFullscreen) {
|
||||
document.exitFullscreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
const handleLogout = () => {
|
||||
ElMessageBox.confirm('确定要退出登录吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
localStorage.removeItem('token')
|
||||
router.push('/login')
|
||||
}).catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.admin-layout {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 侧边栏样式 */
|
||||
.sidebar {
|
||||
width: 240px;
|
||||
height: 100%;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
overflow: hidden;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.logo-container {
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 16px;
|
||||
color: #333;
|
||||
background-color: #ffffff;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
border-right: none;
|
||||
height: calc(100vh - 60px);
|
||||
}
|
||||
|
||||
/* 主容器样式 */
|
||||
.main-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #f0f2f5;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 顶部导航栏样式 */
|
||||
.navbar {
|
||||
height: 60px;
|
||||
padding: 0 15px;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.navbar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.navbar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.navbar-item {
|
||||
padding: 0 10px;
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-btn {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.header-btn:hover {
|
||||
background-color: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.avatar-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
padding: 0 12px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.avatar-container:hover {
|
||||
background-color: rgba(0, 0, 0, 0.025);
|
||||
}
|
||||
|
||||
.username {
|
||||
margin: 0 8px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
/* 内容区域样式 */
|
||||
.content-container {
|
||||
flex: 1;
|
||||
padding: 16px;
|
||||
overflow-y: auto;
|
||||
background-color: #f0f2f5;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 过渡动画 */
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
:deep(.el-dropdown-menu__item) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:deep(.el-dropdown-menu__item i) {
|
||||
margin-right: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<el-breadcrumb separator="/">
|
||||
<el-breadcrumb-item v-for="(item, index) in breadcrumbs" :key="index" :to="item.path">
|
||||
<el-icon v-if="item.icon" class="breadcrumb-icon">
|
||||
<component :is="item.icon" />
|
||||
</el-icon>
|
||||
{{ item.title }}
|
||||
</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
HomeFilled,
|
||||
Setting,
|
||||
User,
|
||||
Document,
|
||||
List,
|
||||
PieChart,
|
||||
DataAnalysis,
|
||||
DataBoard
|
||||
} from '@element-plus/icons-vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
// 图标映射
|
||||
const iconMap = {
|
||||
'dashboard': 'DataBoard',
|
||||
'system': 'Setting',
|
||||
'users': 'User',
|
||||
'content': 'Document',
|
||||
'articles': 'Document',
|
||||
'categories': 'List',
|
||||
'tags': 'List',
|
||||
'statistics': 'PieChart',
|
||||
'visits': 'DataAnalysis',
|
||||
'performance': 'DataAnalysis'
|
||||
}
|
||||
|
||||
// 生成面包屑数据
|
||||
const breadcrumbs = computed(() => {
|
||||
// 当前路由的完整路径
|
||||
const currentPath = route.path
|
||||
|
||||
// 按照路径层级生成面包屑
|
||||
const pathSegments = currentPath.split('/').filter(segment => segment !== '')
|
||||
const result = []
|
||||
|
||||
// 添加首页
|
||||
result.push({
|
||||
path: '/dashboard',
|
||||
title: '首页',
|
||||
icon: 'HomeFilled'
|
||||
})
|
||||
|
||||
// 构建剩余的面包屑
|
||||
let currentPathBuilder = ''
|
||||
|
||||
for (let i = 0; i < pathSegments.length; i++) {
|
||||
const segment = pathSegments[i]
|
||||
currentPathBuilder += '/' + segment
|
||||
|
||||
// 查找匹配的路由
|
||||
const matchedRoute = router.getRoutes().find(route => route.path === currentPathBuilder)
|
||||
const segmentIcon = iconMap[segment]
|
||||
|
||||
if (matchedRoute && matchedRoute.meta.title) {
|
||||
result.push({
|
||||
path: currentPathBuilder,
|
||||
title: matchedRoute.meta.title,
|
||||
icon: segmentIcon
|
||||
})
|
||||
} else if (segment) {
|
||||
// 如果没有匹配的路由,但有路径段,也添加到面包屑
|
||||
result.push({
|
||||
path: currentPathBuilder,
|
||||
title: segment.charAt(0).toUpperCase() + segment.slice(1),
|
||||
icon: segmentIcon
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.breadcrumb-icon {
|
||||
margin-right: 6px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
:deep(.el-breadcrumb__item) {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:deep(.el-breadcrumb__inner) {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:deep(.el-breadcrumb__inner a) {
|
||||
color: #606266;
|
||||
font-weight: normal;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
:deep(.el-breadcrumb__inner a:hover) {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
:deep(.el-breadcrumb__separator) {
|
||||
margin: 0 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<el-sub-menu v-if="hasChildren" :index="menu.path">
|
||||
<template #title>
|
||||
<el-icon v-if="menu.icon || menu.meta?.icon">
|
||||
<component :is="menu.icon || menu.meta?.icon" />
|
||||
</el-icon>
|
||||
<span>{{ menu.title || menu.meta?.title }}</span>
|
||||
</template>
|
||||
<sidebar-menu-item
|
||||
v-for="child in menu.children"
|
||||
:key="child.path"
|
||||
:menu="child"
|
||||
/>
|
||||
</el-sub-menu>
|
||||
<el-menu-item v-else :index="menu.path">
|
||||
<el-icon v-if="menu.icon || menu.meta?.icon">
|
||||
<component :is="menu.icon || menu.meta?.icon" />
|
||||
</el-icon>
|
||||
<template #title>{{ menu.title || menu.meta?.title }}</template>
|
||||
</el-menu-item>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import * as ElementPlusIcons from '@element-plus/icons-vue'
|
||||
|
||||
// 接收菜单项属性
|
||||
const props = defineProps({
|
||||
menu: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
// 判断是否有子菜单
|
||||
const hasChildren = computed(() => {
|
||||
return props.menu.children && props.menu.children.length > 0
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-menu-item, :deep(.el-sub-menu__title) {
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
:deep(.el-sub-menu .el-menu-item) {
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
padding-left: 55px !important;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.el-icon {
|
||||
margin-right: 10px;
|
||||
width: 24px;
|
||||
text-align: center;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
/* 激活菜单项特效 */
|
||||
.el-menu-item.is-active {
|
||||
position: relative;
|
||||
background-color: #e6f7ff !important;
|
||||
color: #1890ff !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.el-menu-item.is-active::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 3px;
|
||||
height: 100%;
|
||||
background-color: #1890ff;
|
||||
}
|
||||
|
||||
:deep(.el-sub-menu.is-active > .el-sub-menu__title) {
|
||||
color: #1890ff !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.el-menu-item:hover, :deep(.el-sub-menu__title:hover) {
|
||||
background-color: #f5f7fa !important;
|
||||
}
|
||||
|
||||
/* 修复图标颜色 */
|
||||
.el-menu-item.is-active .el-icon, :deep(.el-sub-menu.is-active > .el-sub-menu__title .el-icon) {
|
||||
color: #1890ff !important;
|
||||
}
|
||||
|
||||
/* 修复箭头颜色 */
|
||||
:deep(.el-sub-menu.is-active > .el-sub-menu__title .el-sub-menu__icon-arrow) {
|
||||
color: #1890ff !important;
|
||||
}
|
||||
|
||||
/* 子菜单样式 */
|
||||
:deep(.el-menu--inline) {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,366 @@
|
||||
<template>
|
||||
<div class="tags-view-container">
|
||||
<div class="tags-view-wrapper">
|
||||
<div class="tags-view-scroll">
|
||||
<router-link
|
||||
v-for="tag in visitedViews"
|
||||
:key="tag.path"
|
||||
:class="isActive(tag) ? 'active-tag' : 'tag'"
|
||||
:to="{ path: tag.path, query: tag.query }"
|
||||
@contextmenu.prevent="openMenu($event, tag)"
|
||||
>
|
||||
<el-icon v-if="tag.meta.icon" class="tag-icon">
|
||||
<component :is="tag.meta.icon" />
|
||||
</el-icon>
|
||||
<span class="tag-title">{{ tag.meta.title }}</span>
|
||||
<el-icon
|
||||
class="tag-close"
|
||||
@click.prevent.stop="closeSelectedTag(tag)"
|
||||
v-if="!isAffix(tag)"
|
||||
>
|
||||
<close />
|
||||
</el-icon>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右键菜单 -->
|
||||
<ul v-show="visible" :style="{left: left+'px', top: top+'px'}" class="contextmenu">
|
||||
<li @click="refreshSelectedTag(selectedTag)">
|
||||
<el-icon><refresh /></el-icon>
|
||||
<span>刷新页面</span>
|
||||
</li>
|
||||
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">
|
||||
<el-icon><close /></el-icon>
|
||||
<span>关闭当前</span>
|
||||
</li>
|
||||
<li @click="closeOthersTags">
|
||||
<el-icon><circle-close /></el-icon>
|
||||
<span>关闭其他</span>
|
||||
</li>
|
||||
<li @click="closeLeftTags">
|
||||
<el-icon><back /></el-icon>
|
||||
<span>关闭左侧</span>
|
||||
</li>
|
||||
<li @click="closeRightTags">
|
||||
<el-icon><right /></el-icon>
|
||||
<span>关闭右侧</span>
|
||||
</li>
|
||||
<li @click="closeAllTags">
|
||||
<el-icon><remove /></el-icon>
|
||||
<span>关闭所有</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { Close, Refresh, CircleClose, Back, Right, Remove } from '@element-plus/icons-vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
// 固定标签
|
||||
const affixTags = ref([])
|
||||
// 访问过的标签
|
||||
const visitedViews = ref([])
|
||||
// 右键菜单
|
||||
const visible = ref(false)
|
||||
const top = ref(0)
|
||||
const left = ref(0)
|
||||
const selectedTag = ref({})
|
||||
|
||||
// 初始化标签
|
||||
const initTags = () => {
|
||||
// 如果当前路由不在访问过的标签中,添加它
|
||||
if (route.name) {
|
||||
addVisitedView(route)
|
||||
}
|
||||
// 添加固定标签(仪表盘)
|
||||
const dashboardRoute = router.getRoutes().find(r => r.name === 'Dashboard')
|
||||
if (dashboardRoute) {
|
||||
affixTags.value.push(dashboardRoute)
|
||||
addVisitedView(dashboardRoute)
|
||||
}
|
||||
}
|
||||
|
||||
// 添加访问过的标签
|
||||
const addVisitedView = (view) => {
|
||||
if (visitedViews.value.some(v => v.path === view.path)) return
|
||||
|
||||
// 过滤404和登录页
|
||||
if (view.name === 'NotFound' || view.name === 'Login') return
|
||||
|
||||
visitedViews.value.push(
|
||||
Object.assign({}, view, {
|
||||
title: view.meta.title || 'unknown'
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
// 刷新选中的标签
|
||||
const refreshSelectedTag = (view) => {
|
||||
// 路由刷新的原理是先获取当前路由的全部信息,然后将路由重定向到一个空白页,
|
||||
// 然后立即再将路由重定向回原路由,实现刷新效果
|
||||
const { fullPath } = view
|
||||
router.replace('/redirect' + fullPath)
|
||||
}
|
||||
|
||||
// 关闭选中的标签
|
||||
const closeSelectedTag = (view) => {
|
||||
// 从访问过的标签中移除
|
||||
const index = visitedViews.value.findIndex(v => v.path === view.path)
|
||||
if (index > -1) {
|
||||
visitedViews.value.splice(index, 1)
|
||||
}
|
||||
|
||||
// 如果关闭的是当前标签,则跳转到下一个标签
|
||||
if (isActive(view)) {
|
||||
toLastView(visitedViews.value, view)
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭其他标签
|
||||
const closeOthersTags = () => {
|
||||
// 保留固定标签和当前选中的标签
|
||||
visitedViews.value = visitedViews.value.filter(v => {
|
||||
return isAffix(v) || v.path === selectedTag.value.path
|
||||
})
|
||||
|
||||
if (!isActive(selectedTag.value)) {
|
||||
router.push(selectedTag.value)
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭左侧标签
|
||||
const closeLeftTags = () => {
|
||||
const selectedIndex = visitedViews.value.findIndex(v => v.path === selectedTag.value.path)
|
||||
if (selectedIndex === -1) return
|
||||
|
||||
// 保留固定标签和右侧标签
|
||||
visitedViews.value = visitedViews.value.filter((v, i) => {
|
||||
return isAffix(v) || i >= selectedIndex
|
||||
})
|
||||
|
||||
if (!isActive(selectedTag.value)) {
|
||||
router.push(selectedTag.value)
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭右侧标签
|
||||
const closeRightTags = () => {
|
||||
const selectedIndex = visitedViews.value.findIndex(v => v.path === selectedTag.value.path)
|
||||
if (selectedIndex === -1) return
|
||||
|
||||
// 保留固定标签和左侧标签
|
||||
visitedViews.value = visitedViews.value.filter((v, i) => {
|
||||
return isAffix(v) || i <= selectedIndex
|
||||
})
|
||||
|
||||
if (!isActive(selectedTag.value)) {
|
||||
router.push(selectedTag.value)
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭所有标签
|
||||
const closeAllTags = () => {
|
||||
// 仅保留固定标签
|
||||
visitedViews.value = visitedViews.value.filter(v => isAffix(v))
|
||||
|
||||
// 跳转到第一个标签或首页
|
||||
toLastView(visitedViews.value)
|
||||
}
|
||||
|
||||
// 跳转到最后一个标签或首页
|
||||
const toLastView = (visitedViews, view) => {
|
||||
const latestView = visitedViews.slice(-1)[0]
|
||||
if (latestView) {
|
||||
router.push(latestView)
|
||||
} else {
|
||||
// 如果没有标签,则跳转到首页
|
||||
if (view && view.name === 'Dashboard') {
|
||||
// 如果当前是首页,则刷新页面
|
||||
router.push('/redirect' + '/dashboard')
|
||||
} else {
|
||||
router.push('/')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否是当前激活的标签
|
||||
const isActive = (tag) => {
|
||||
return tag.path === route.path
|
||||
}
|
||||
|
||||
// 判断是否是固定标签
|
||||
const isAffix = (tag) => {
|
||||
return affixTags.value.some(t => t.path === tag.path)
|
||||
}
|
||||
|
||||
// 打开右键菜单
|
||||
const openMenu = (e, tag) => {
|
||||
const menuMinWidth = 125
|
||||
const offsetLeft = e.clientX
|
||||
const offsetWidth = document.body.clientWidth
|
||||
const maxLeft = offsetWidth - menuMinWidth
|
||||
|
||||
left.value = offsetLeft > maxLeft ? maxLeft : offsetLeft
|
||||
top.value = e.clientY
|
||||
|
||||
visible.value = true
|
||||
selectedTag.value = tag
|
||||
}
|
||||
|
||||
// 关闭右键菜单
|
||||
const closeMenu = () => {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
// 监听路由变化,添加标签
|
||||
watch(route, (newRoute) => {
|
||||
if (newRoute.name) {
|
||||
addVisitedView(newRoute)
|
||||
}
|
||||
})
|
||||
|
||||
// 点击其他区域关闭右键菜单
|
||||
const handleClickOutside = () => {
|
||||
closeMenu()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initTags()
|
||||
document.addEventListener('click', handleClickOutside)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('click', handleClickOutside)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tags-view-container {
|
||||
height: 40px;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.tags-view-wrapper {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 16px;
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tags-view-wrapper::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tags-view-scroll {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.tag, .active-tag {
|
||||
height: 28px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
margin-right: 5px;
|
||||
border-radius: 2px;
|
||||
font-size: 12px;
|
||||
color: #333333;
|
||||
background-color: #f4f4f5;
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||
border: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
.tag:hover {
|
||||
color: #1890ff;
|
||||
background-color: #e6f7ff;
|
||||
border-color: #1890ff;
|
||||
}
|
||||
|
||||
.active-tag {
|
||||
color: #1890ff;
|
||||
background-color: #e6f7ff;
|
||||
border-color: #1890ff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.tag-icon {
|
||||
margin-right: 4px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.tag-title {
|
||||
max-width: 120px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tag-close {
|
||||
margin-left: 5px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.tag:hover .tag-close {
|
||||
color: #666;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.active-tag .tag-close {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.active-tag:hover .tag-close {
|
||||
background-color: rgba(24, 144, 255, 0.1);
|
||||
}
|
||||
|
||||
.contextmenu {
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
background-color: #fff;
|
||||
list-style-type: none;
|
||||
padding: 6px 0;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
font-size: 12px;
|
||||
border: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
.contextmenu li {
|
||||
padding: 8px 16px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.contextmenu li:hover {
|
||||
background-color: #f5f7fa;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.contextmenu li .el-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,49 @@
|
||||
export const menus = [
|
||||
{
|
||||
path: '/dashboard',
|
||||
title: '仪表盘',
|
||||
icon: 'DataBoard'
|
||||
},
|
||||
{
|
||||
path : '/ticket',
|
||||
title: '工单处理',
|
||||
icon: 'DataBoard'
|
||||
|
||||
},
|
||||
{
|
||||
path: '/acs',
|
||||
title: 'ACS管理',
|
||||
icon: 'Monitor',
|
||||
children: [
|
||||
{
|
||||
path: '/acs/messages',
|
||||
title: '消息管理',
|
||||
children: [
|
||||
{ path: '/acs/messages/announcements', title: '官方公告' },
|
||||
{ path: '/acs/messages/policies', title: '官方政策' },
|
||||
{ path: '/acs/messages/news', title: '新闻咨询' }
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/acs/images',
|
||||
title: '镜像管理',
|
||||
children: [
|
||||
{ path: '/acs/images/vm', title: '虚拟机镜像' },
|
||||
{ path: '/acs/images/container', title: '容器镜像' },
|
||||
{ path: '/acs/images/categories', title: '镜像分类' }
|
||||
]
|
||||
},
|
||||
{ path: '/acs/nodes', title: '节点管理' }
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/system',
|
||||
title: '系统管理',
|
||||
icon: 'Setting',
|
||||
children: [
|
||||
// { path: '/system/users', title: '用户管理' },
|
||||
// { path: '/system/operation-log', title: '操作日志' },
|
||||
{ path: '/system/domain-whitelist', title: '域名白名单' }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -2,10 +2,19 @@ import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import ElementPlus from 'element-plus'
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
import 'element-plus/dist/index.css'
|
||||
import './style.css'
|
||||
import {createPinia} from "pinia";
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
// 注册所有图标
|
||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
app.component(key, component)
|
||||
}
|
||||
const pinia = createPinia()
|
||||
app.use(router)
|
||||
app.use(ElementPlus)
|
||||
app.use(pinia)
|
||||
app.mount('#app')
|
||||
+212
-8
@@ -1,20 +1,217 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import Home from '../views/Home.vue'
|
||||
import AdminLayout from '../components/layout/AdminLayout.vue'
|
||||
import OperationLog from '@/views/system/OperationLog.vue'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: Home,
|
||||
redirect: '/dashboard'
|
||||
},
|
||||
{
|
||||
path: '/redirect',
|
||||
component: AdminLayout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: '/redirect/:path(.*)',
|
||||
component: () => import('../views/Redirect.vue'),
|
||||
meta: { title: '重定向' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
component: AdminLayout,
|
||||
children: [
|
||||
{
|
||||
path: 'dashboard',
|
||||
name: 'Dashboard',
|
||||
component: () => import('../views/dashboard/Dashboard.vue'),
|
||||
meta: {
|
||||
title: '仪表盘',
|
||||
icon: 'DataBoard'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'ticket',
|
||||
name: 'Ticket',
|
||||
meta: {
|
||||
title: '工单管理',
|
||||
icon: 'Tickets'
|
||||
},
|
||||
component: () => import('../views/ticket/TicketChat.vue'),
|
||||
},
|
||||
// ACS管理路由
|
||||
{
|
||||
path: 'acs',
|
||||
name: 'ACS',
|
||||
meta: {
|
||||
title: 'ACS管理',
|
||||
icon: 'Monitor'
|
||||
},
|
||||
redirect: '/acs/messages/announcements',
|
||||
children: [
|
||||
// 消息管理路由
|
||||
{
|
||||
path: 'messages',
|
||||
name: 'Messages',
|
||||
meta: {
|
||||
title: '消息管理'
|
||||
},
|
||||
redirect: '/acs/messages/announcements',
|
||||
children: [
|
||||
{
|
||||
path: 'announcements',
|
||||
name: 'Announcements',
|
||||
component: () => import('../views/acs/messages/Announcements.vue'),
|
||||
meta: {
|
||||
title: '官方公告'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'policies',
|
||||
name: 'Policies',
|
||||
component: () => import('../views/acs/messages/Policies.vue'),
|
||||
meta: {
|
||||
title: '官方政策'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'news',
|
||||
name: 'News',
|
||||
component: () => import('../views/acs/messages/News.vue'),
|
||||
meta: {
|
||||
title: '新闻咨询'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// 镜像管理路由
|
||||
{
|
||||
path: 'images',
|
||||
name: 'Images',
|
||||
meta: {
|
||||
title: '镜像管理'
|
||||
},
|
||||
redirect: '/acs/images/vm',
|
||||
children: [
|
||||
{
|
||||
path: 'vm',
|
||||
name: 'VmImages',
|
||||
component: () => import('../views/acs/images/VmImages.vue'),
|
||||
meta: {
|
||||
title: '虚拟机镜像'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'container',
|
||||
name: 'ContainerImages',
|
||||
component: () => import('../views/acs/images/ContainerImages.vue'),
|
||||
meta: {
|
||||
title: '容器镜像'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'categories',
|
||||
name: 'ImageCategories',
|
||||
component: () => import('../views/acs/images/ImageCategories.vue'),
|
||||
meta: {
|
||||
title: '镜像分类'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// 节点管理路由
|
||||
{
|
||||
path: 'nodes',
|
||||
name: 'Nodes',
|
||||
component: () => import('../views/acs/nodes/Nodes.vue'),
|
||||
meta: {
|
||||
title: '节点管理'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'system',
|
||||
name: 'System',
|
||||
meta: {
|
||||
title: '系统管理',
|
||||
icon: 'Setting'
|
||||
},
|
||||
redirect: '/system/users',
|
||||
children: [
|
||||
{
|
||||
path: 'users',
|
||||
name: 'Users',
|
||||
component: () => import('../views/system/Users.vue'),
|
||||
meta: {
|
||||
title: '用户管理'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'operation-log',
|
||||
name: 'OperationLog',
|
||||
component: OperationLog,
|
||||
meta: { title: '操作日志' }
|
||||
},
|
||||
{
|
||||
path: 'domain-whitelist',
|
||||
name: 'DomainWhitelist',
|
||||
component: () => import('../views/system/DomainWhitelist.vue'),
|
||||
meta: { title: '域名白名单' }
|
||||
}
|
||||
]
|
||||
},
|
||||
// 个人中心路由
|
||||
{
|
||||
path: 'profile',
|
||||
name: 'Profile',
|
||||
component: () => import('../views/profile/UserInfo.vue'),
|
||||
meta: {
|
||||
title: '个人信息',
|
||||
hidden: true
|
||||
}
|
||||
},
|
||||
// 修改密码路由
|
||||
{
|
||||
path: 'change-password',
|
||||
name: 'ChangePassword',
|
||||
component: () => import('../views/profile/ChangePassword.vue'),
|
||||
meta: {
|
||||
title: '修改密码',
|
||||
hidden: true
|
||||
}
|
||||
},
|
||||
// 服务器详情页面路由
|
||||
{
|
||||
path: 'servers/server',
|
||||
name: 'ServerDetail',
|
||||
component: () => import('../views/acs/nodes/server.vue'),
|
||||
meta: {
|
||||
title: '服务器详情',
|
||||
hidden: true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// 登录页
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: () => import('../views/Login.vue'),
|
||||
meta: {
|
||||
title: '首页'
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
// 404 页面
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'NotFound',
|
||||
component: () => import('../views/NotFound.vue')
|
||||
component: () => import('../views/NotFound.vue'),
|
||||
meta: {
|
||||
title: '页面不存在'
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -26,12 +223,19 @@ const router = createRouter({
|
||||
// 全局前置守卫
|
||||
router.beforeEach((to, from, next) => {
|
||||
// 设置页面标题
|
||||
document.title = to.meta.title || '默认标题'
|
||||
next()
|
||||
document.title = to.meta.title ? `${to.meta.title} - 007UI管理系统` : '007UI管理系统'
|
||||
|
||||
// 这里可以添加登录验证逻辑
|
||||
const isAuthenticated = localStorage.getItem('token')
|
||||
if (to.path !== '/login' && !isAuthenticated) {
|
||||
next({ path: '/login' })
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
// 全局后置钩子
|
||||
router.afterEach((to, from) => {
|
||||
router.afterEach(() => {
|
||||
window.scrollTo(0, 0)
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {ref} from "vue";
|
||||
|
||||
|
||||
export const useUserStore = defineStore('userStore',() => {
|
||||
|
||||
let userInfo = ref({})
|
||||
|
||||
function setUserInfo(u){
|
||||
userInfo.value = u
|
||||
}
|
||||
|
||||
return {userInfo,setUserInfo}
|
||||
})
|
||||
+135
@@ -1,5 +1,140 @@
|
||||
/* 全局样式 */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* 常用工具类 */
|
||||
.text-primary {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.text-success {
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.text-warning {
|
||||
color: #faad14;
|
||||
}
|
||||
|
||||
.text-danger {
|
||||
color: #f5222d;
|
||||
}
|
||||
|
||||
.text-info {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.text-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-column {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.justify-center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.h-full {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.mb-10 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.mt-10 {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.mr-10 {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.ml-10 {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.p-10 {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.py-10 {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.px-10 {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
/* 响应式工具类 */
|
||||
@media (max-width: 768px) {
|
||||
.hidden-xs {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) and (max-width: 992px) {
|
||||
.hidden-sm {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 992px) and (max-width: 1200px) {
|
||||
.hidden-md {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.hidden-lg {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
|
||||
|
||||
/**获取所有站点 */
|
||||
export const getSiteList = (data) => {
|
||||
return http2.get(`/v1/admin/audit/list?page=${data.page}&count=${data.count}&key=${data.key}`)
|
||||
}
|
||||
/**手动触发站点审计 */
|
||||
export const auditSite = () => {
|
||||
return http2.get(`/v1/admin/audit/start`)
|
||||
}
|
||||
/**删除违规网页审计 */
|
||||
export const delAudit = (data) => {
|
||||
return http2.post(`/v1/admin/audit/delete`,data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**获取违规网页审计列表 */
|
||||
export const getAuditList = (data) => {
|
||||
return http2.get(`/v1/admin/audit/violation_list?page=${data.page}&count=${data.count}&key=${data.key}`)
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取消息列表 */
|
||||
export const getMessageList = (data) => {
|
||||
return http2.get(`/v1/messages/get_message_list?page=${data.page}&count=${data.count}&message_type=${data.message_type}`)
|
||||
}
|
||||
/**获取单条消息 */
|
||||
export const getMessage = (data) => {
|
||||
return http2.get(`/v1/messages/get_message?message_id=${data}`)
|
||||
}
|
||||
/**添加消息 */
|
||||
export const addMessage = (data) => {
|
||||
return http2.post(`/v1/messages/add_message`, data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**删除消息 */
|
||||
export const deleteMessage = (data) => {
|
||||
return http2.post(`/v1/messages/delete_message`, data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**修改消息 */
|
||||
export const editMessage = (data) => {
|
||||
return http2.post(`/v1/messages/update_message`, data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**获取附件列表 */
|
||||
export const getFileList = (data) => {
|
||||
return http2.get(`/v1/attachment/get_attachment_list?page=${data.page}&count=${data.count}&key=${data.key}&user_type=${data.user_type}`)
|
||||
}
|
||||
/**上传附件 */
|
||||
export const uploadFile = (data) => {
|
||||
return http2.post(`/v1/attachment/add_attachment`, data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**删除附件 */
|
||||
export const deleteFile = (data) => {
|
||||
return http2.get(`/v1/attachment/delete_attachment?aid=${data}`)
|
||||
}
|
||||
/**用户获取消息列表 */
|
||||
export const getUserMessageList = (data) => {
|
||||
return http2.get(`/v1/messages/get_message_list?page=${data.page}&count=${data.count}&message_type=${data.message_type}`)
|
||||
}
|
||||
/**用户获取单条消息 */
|
||||
export const getUserMessage = (data) => {
|
||||
return http2.get(`/v1/messages/get_message?message_id=${data}`)
|
||||
}
|
||||
|
||||
/**获取消息详情 */
|
||||
export const getMessageDetail = (data) => {
|
||||
return http2.get(`/v1/messages/get_message?message_id=${data.message_id}`)
|
||||
}
|
||||
/**修改图片大小 */
|
||||
export const compressAndConvertFileToBase64=async(file)=> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function(e) {
|
||||
const img = new Image();
|
||||
img.src = e.target.result;
|
||||
|
||||
img.onload = function() {
|
||||
const canvas = document.createElement('canvas');
|
||||
const MAX_WIDTH = 300; // 压缩的最大宽度
|
||||
const MAX_HEIGHT = 200; // 压缩的最大高度
|
||||
|
||||
let width = img.width;
|
||||
let height = img.height;
|
||||
|
||||
// 计算压缩比例
|
||||
if (width > height) {
|
||||
if (width > MAX_WIDTH) {
|
||||
height *= MAX_WIDTH / width;
|
||||
width = MAX_WIDTH;
|
||||
}
|
||||
} else {
|
||||
if (height > MAX_HEIGHT) {
|
||||
width *= MAX_HEIGHT / height;
|
||||
height = MAX_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(img, 0, 0, width, height);
|
||||
|
||||
// 将canvas内容转换为jpeg并压缩质量
|
||||
const dataUrl = canvas.toDataURL('image/jpeg', 0.8); // 0.8是压缩质量,范围0-1
|
||||
|
||||
resolve(dataUrl);
|
||||
};
|
||||
|
||||
img.onerror = function(error) {
|
||||
reject(error);
|
||||
};
|
||||
};
|
||||
|
||||
reader.onerror = function(error) {
|
||||
reject(error);
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取镜像列表 */
|
||||
export const getMirrorList = data => {
|
||||
return http2.get(`/v1/image/list?server_id=${data}`);
|
||||
};
|
||||
/*用户获取镜像列表 */
|
||||
export const getUserMirrorList = data => {
|
||||
return http2.get(
|
||||
`/v1/image/list?server_id=${data.server_id}&count=${data.count}&page=${data.page}&key=${data.key}`
|
||||
);
|
||||
};
|
||||
/**上传镜像 */
|
||||
export const uploadMirror = data => {
|
||||
return http2.post("/v1/image/pull", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**编辑镜像 */
|
||||
export const editMirror = data => {
|
||||
return http2.post("/v1/image/update", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除镜像 */
|
||||
export const delMirror = data => {
|
||||
return http2.post("/v1/image/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**镜像同步 */
|
||||
export const syncMirror = data => {
|
||||
return http2.get(`/v1/image/sync?server_id=${data}`);
|
||||
};
|
||||
/**重新拉取镜像 */
|
||||
export const pullMirror = data => {
|
||||
return http2.post(`/v1/image/repull`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取镜像信息 */
|
||||
export const Mirrorinfo = data => {
|
||||
const serverType = data.server_type || "dockerContainer"; // 设置默认值
|
||||
return http2.get(
|
||||
`/v1/image/info?image_id=${data.image_id}&server_type=${serverType}`
|
||||
);
|
||||
};
|
||||
|
||||
export const addVirtualMirror = data => {
|
||||
return http2.post("/v1/image/create", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export const getImageTypeList = (server_id) => {
|
||||
return http2.get(`/v1/image/class_list?server_id=${server_id}`);
|
||||
};
|
||||
|
||||
export const createImageType = (server_id,class_name,class_ico) => {
|
||||
return http2.post("/v1/image/class_create", {
|
||||
server_id,
|
||||
class_name,
|
||||
class_ico
|
||||
},{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const updateImageType = (class_id,class_name,class_ico) => {
|
||||
return http2.post("/v1/image/class_update", {
|
||||
class_id,
|
||||
class_name,
|
||||
class_ico
|
||||
},{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取订单列表 */
|
||||
export const getOrderList = (data) => {
|
||||
return http2.get(`/v1/admin/trades/get_trades?page=${data.page}&count=${data.count}&key=${data.key}`)
|
||||
}
|
||||
/**编辑订单 */
|
||||
export const editOrder = (data) => {
|
||||
return http2.post('/v1/admin/trades/update_trades',data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**删除订单 */
|
||||
export const deleteOrder = (data) => {
|
||||
return http2.post('/v1/admin/trades/delete_trade',data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**用户获取订单列表 */
|
||||
export const getUserOrderList = (data) => {
|
||||
return http2.get(`/v1/user/procedure/get_trade_list?page=${data.page}&count=${data.count}&key=${data.key}`)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取用户列表 */
|
||||
export const get_pay_code = data => {
|
||||
return http2.get(
|
||||
`https://yun.tdhly.love/submit.php?pid=2&type=${data.type}&out_trade_no={商户订单号}¬ify_url={服务器异步通知地址}&name={商品名称}&money=${data.money}&sign=9vP6xvcc93YYi9c6F3HiY9HFuyZizIxe&sign_type=MD5`
|
||||
);
|
||||
};
|
||||
// /**email验证码 */
|
||||
// export const ask_update_user_email = data => {
|
||||
// return http2.post("/v1/user/info/ask_update_user_email", data, {
|
||||
// headers: {
|
||||
// "Content-Type": "multipart/form-data"
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
/**获取容器订单金额 */
|
||||
export const procedure_get_price = data => {
|
||||
return http2.post("/v1/user/procedure/get_price", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取虚拟机订单金额 */
|
||||
export const procedure_vir_price = data => {
|
||||
return http2.post("/v1/user/procedure/get_vm_price", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,455 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
|
||||
/** 获取所有服务器 */
|
||||
export const getServer = (page, count, key, type = "dockerContainer") => {
|
||||
return http2.get(
|
||||
`/v1/admin/server/get_server_list?page=${page}&count=${count}&key=${key}&server_type=${type}`
|
||||
);
|
||||
};
|
||||
|
||||
/**新增服务器 */
|
||||
export const addServer = data => {
|
||||
return http2.post("/v1/admin/server/add_server", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**编辑服务器 */
|
||||
export const editServer = data => {
|
||||
return http2.post("/v1/admin/server/update_server", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除服务器 */
|
||||
export const deleteServer = data => {
|
||||
return http2.post("/v1/admin/server/delete_server", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**查询指定服务器 */
|
||||
export const selectServer = data => {
|
||||
return http2.post("/v1/admin/server/select_server", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取服务器套餐列表*/
|
||||
export const getServerPlan = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/container_plan/get_server_plan_list?server_id=${data.server_id}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**获取指定套餐 */
|
||||
export const selectServerPlan = data => {
|
||||
return http2.post("/v1/admin/container_plan/get_server_plan_detail", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改套餐信息 */
|
||||
export const editServerPlan = data => {
|
||||
return http2.post("/v1/admin/container_plan/update_server_plan", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**新增套餐 */
|
||||
export const addServerPlan = data => {
|
||||
return http2.post("/v1/admin/container_plan/add_server_plan", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除套餐 */
|
||||
export const deleteServerPlan = data => {
|
||||
return http2.post("/v1/admin/container_plan/delete_server_plan", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器列表 */
|
||||
export const getContainer = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/container/get_container_list?server_id=${data.server_id}&user_id=${data.user_id}&page=${data.page}&count=${data.count}&key=${data.key}`
|
||||
);
|
||||
};
|
||||
/**获取单个指定容器 */
|
||||
export const getOneContainer = data => {
|
||||
return http2.post("/v1/admin/container/get_container_detail", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**查询指定虚拟机信息(管理员查询) */
|
||||
export const getVmAdminContainer = id => {
|
||||
return http2.get(`/v1/admin/instance/detail/${id}`);
|
||||
};
|
||||
// 暂停容器
|
||||
export const pauseContainer = data => {
|
||||
return http2.post("/v1/admin/container/pause_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 暂停虚拟机
|
||||
export const pauseInstance = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/pause/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**恢复虚拟机 */
|
||||
export const unpauseInstance = (id, data = "") => {
|
||||
return http2.post(`/v1/admin/instance/resume/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 解除暂停
|
||||
export const unpauseContainer = data => {
|
||||
return http2.post("/v1/admin/container/unpause_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器状态 */
|
||||
export const getContainerStatus = data => {
|
||||
return http2.post("/v1/admin/container/get_container_status", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取虚拟机状态 */
|
||||
export const getInstanceStatus = id => {
|
||||
return http2.get(`/v1/admin/instance/get_state/${id}`);
|
||||
};
|
||||
/**查询服务器状态 */
|
||||
export const getServerStatus = id => {
|
||||
return http2.get(`/v1/admin/server/send_server_status?server_id=${id}`);
|
||||
};
|
||||
/**开通容器 */
|
||||
export const openContainer = data => {
|
||||
return http2.post("/v1/admin/container/open_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**开通虚拟机 */
|
||||
export const openInstance = (id, data = "") => {
|
||||
return http2.post(`/v1/admin/instance/approve/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**启动容器 */
|
||||
export const startContainer = data => {
|
||||
return http2.post("/v1/admin/container/start_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**启动虚拟机 */
|
||||
export const startInstance = data => {
|
||||
return http2.get(`/v1/admin/instance/start/${data}`);
|
||||
};
|
||||
/**重装容器 */
|
||||
export const reinstallC = data => {
|
||||
return http2.post("/v1/admin/container/reinstall_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**重装虚拟机 */
|
||||
export const reinstallI = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/reinstall/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取容器日志 */
|
||||
export const getContainerLog = data => {
|
||||
return http2.post(`/v1/admin/container/get_container_log`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取虚拟机操作日志 */
|
||||
export const getInstanceLog = (id, data) => {
|
||||
return http2.get(
|
||||
`/v1/admin/instance/log/${id}?page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
|
||||
/**重启容器 */
|
||||
export const restartContainer = data => {
|
||||
return http2.post("/v1/admin/container/reboot_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**重启虚拟机 */
|
||||
export const restartInstance = data => {
|
||||
return http2.get(`/v1/admin/instance/reboot/${data}`);
|
||||
};
|
||||
|
||||
/**停止容器 */
|
||||
export const stopContainer = data => {
|
||||
return http2.post("/v1/admin/container/stop_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**停止虚拟机 */
|
||||
export const stopInstance = data => {
|
||||
return http2.get(`/v1/admin/instance/stop/${data}`);
|
||||
};
|
||||
|
||||
/**删除容器 */
|
||||
export const deleteContainer = data => {
|
||||
return http2.post("/v1/admin/container/delete_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除虚拟机 */
|
||||
export const deleteInstance = (id, data = "") => {
|
||||
return http2.post(`/v1/admin/instance/delete/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**清除容器流量 */
|
||||
export const clearContainerTraffic = data => {
|
||||
return http2.post("/v1/admin/container/clear_container_traffic", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**连接控制台 */
|
||||
export const connectConsole = data => {
|
||||
return http2.post("/v1/admin/container/get_container_console", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取虚拟机控制台 */
|
||||
export const getInstanceConsole = data => {
|
||||
return http2.get(`/v1/admin/instance/console/${data}`);
|
||||
};
|
||||
/**查询容器所有卷信息 */
|
||||
export const getVolumeList = data => {
|
||||
return http2.get(`/v1/admin/volume/get_volume_list?container_id=${data}`);
|
||||
};
|
||||
/**查询虚拟机所有卷信息 */
|
||||
export const getInstanceVolumeList = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/volume/get_volume_list?instance_id=${data.instance_id}&page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**新增卷 */
|
||||
export const addVolume = data => {
|
||||
return http2.post("/v1/admin/volume/add_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改卷大小 */
|
||||
export const updateVolume = data => {
|
||||
return http2.post("/v1/admin/volume/update_volume_size", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除数据卷 */
|
||||
export const deleteVolume = data => {
|
||||
return http2.post("/v1/admin/volume/delete_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器网络信息 */
|
||||
export const getNetworkList = data => {
|
||||
return http2.get(
|
||||
`/v1/container/proxy/get_container_proxy?container_id=${data}`
|
||||
);
|
||||
};
|
||||
/**获取虚拟机端口列表 */
|
||||
export const getInstancePortList = data => {
|
||||
const params = new URLSearchParams();
|
||||
if (data.page !== undefined) params.append("page", data.page.toString());
|
||||
if (data.count !== undefined) params.append("count", data.count.toString());
|
||||
if (data.internal_port !== undefined)
|
||||
params.append("internal_port", data.internal_port.toString());
|
||||
return http2.get(
|
||||
`/v1/admin/instance_port/list?instance_id=${data.instance_id}&${params.toString()}`
|
||||
);
|
||||
};
|
||||
/**添加容器网络 */
|
||||
export const addNetwork = data => {
|
||||
return http2.post("/v1/container/proxy/add_container_proxy", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**创建端口 */
|
||||
export const addPort = data => {
|
||||
return http2.post("/v1/admin/instance_port/create", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取浮动ip列表 */
|
||||
export const getFloatingIpList = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/floating_ip/get_list?server_id=${data.server_id}&page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**新增浮动ip */
|
||||
export const addFloatingIp = data => {
|
||||
return http2.post("/v1/admin/floating_ip/add", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**批量添加浮动ip */
|
||||
export const addFloatingIpBatch = data => {
|
||||
return http2.post("/v1/admin/floating_ip/add_list", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除浮动ip */
|
||||
export const delFloatingIp = data => {
|
||||
return http2.post("/v1/admin/floating_ip/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取单个用户操作日志 */
|
||||
export const getUserLog = data => {
|
||||
return http2.get(
|
||||
`/v1/user/procedure/get_user_log?user_id=${data.user_id}&page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
|
||||
/**管理员修改头像 */
|
||||
export const editAvatar = data => {
|
||||
return http2.post("/v1/admin/users/upload_user_avatar", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取服务器硬盘信息 */
|
||||
export const getDiskInfo = data => {
|
||||
return http2.get(`/v1/admin/server/get_server_disk?server_id=${data}`);
|
||||
};
|
||||
/**获取服务器实际划分硬盘信息 */
|
||||
export const getRealDisk = data => {
|
||||
return http2.get(`/v1/admin/server/get_server_disk_info?server_id=${data}`);
|
||||
};
|
||||
/**获取服务器流量信息 */
|
||||
export const getTraffic = data => {
|
||||
return http2.get(`/v1/admin/server/get_server_bandwidth?server_id=${data}`);
|
||||
};
|
||||
/**获取版本更新 */
|
||||
export const getVersion = () => {
|
||||
return http2.get(`/v1/admin/version`);
|
||||
};
|
||||
|
||||
// 管理员删除https网络
|
||||
export const AdminDelHttps = data => {
|
||||
return http2.post("/v1/container/proxy/del_https_connet", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 管理员添加https网络
|
||||
export const AdminAddHttps = data => {
|
||||
return http2.post("/v1/container/proxy/add_https_proxy", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取指定端口信息 */
|
||||
export const getPortInfo = data => {
|
||||
return http2.get(`/v1/admin/instance_port/detail?port_id=${data}`);
|
||||
};
|
||||
/**新增卷 */
|
||||
export const addVolumeMount = data => {
|
||||
return http2.post("/v1/admin/volume/add_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**进入救援系统 */
|
||||
export const rescueInstance = id => {
|
||||
return http2.get(`/v1/admin/instance/rescue/enter/${id}`);
|
||||
};
|
||||
|
||||
/**退出救援系统 */
|
||||
export const exitRescueInstance = id => {
|
||||
return http2.get(`/v1/admin/instance/rescue/exit/${id}`);
|
||||
};
|
||||
|
||||
/**修改虚拟机密码 */
|
||||
export const changeInstancePassword = (id, data) => {
|
||||
return http2.post(`/v1/admin/instance/update_password/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改虚拟机密码(用户) */
|
||||
export const changeInstancePasswordUser = (id, data) => {
|
||||
return http2.post(`/v1/user/instance/update_password/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取全局配置 */
|
||||
export const getSetting = () => {
|
||||
return http2.get('/v1/admin/settings/get_settings')
|
||||
}
|
||||
/**变更设置 */
|
||||
export const updateSetting = (data) => {
|
||||
return http2.post('/v1/admin/settings/update_settings', data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**新增设置 */
|
||||
export const addSetting = (data) => {
|
||||
return http2.post('/v1/admin/settings/add_settings', data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**删除设置 */
|
||||
export const deleteSetting = (data) => {
|
||||
return http2.post('/v1/admin/settings/delete_settings', data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**获取单项配置 */
|
||||
export const getOneSetting = (data) => {
|
||||
return http2.get(`/v1/admin/settings/get_setting?name=${data}`)
|
||||
}
|
||||
/**获取多个配置 */
|
||||
export const getSettings = (data) => {
|
||||
// return http2.get(`/v1/admin/settings/get_settings?names=${data}`);
|
||||
const namesParam = data.join(',');
|
||||
// 将处理后的namesParam放入URL中
|
||||
return http2.get(`/v1/admin/settings/get_setting?names=${encodeURIComponent(namesParam)}`);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取用户列表 */
|
||||
export const ask_update_user_email11 = data => {
|
||||
return http2.get(`/v1/user/info/ask_update_user_email?email=${data.email}`);
|
||||
};
|
||||
/**email验证码 */
|
||||
export const ask_update_user_email = data => {
|
||||
return http2.post("/v1/user/info/ask_update_user_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**email修改 */
|
||||
export const update_user_email = data => {
|
||||
return http2.post("/v1/user/info/update_user_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**phone验证码 */
|
||||
export const ask_update_user_phone = data => {
|
||||
return http2.post("/v1/user/info/ask_update_user_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**phone修改 */
|
||||
export const update_user_phone = data => {
|
||||
return http2.post("/v1/user/info/update_user_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**密码修改 */
|
||||
export const update_user_password = data => {
|
||||
return http2.post("/v1/user/info/update_user_password", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,501 @@
|
||||
|
||||
import {http2} from "@/utils/request.js";
|
||||
// import { getUserContainer } from './user';
|
||||
|
||||
// 获取图像验证码
|
||||
export const Captch = data => {
|
||||
return http2.get(`/v1/user/check/get_code_img`);
|
||||
};
|
||||
|
||||
/** 登录 */
|
||||
export const getLogin = data => {
|
||||
return http2.post("/v1/user/login", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// // /** 刷新token */
|
||||
// export const refreshTokenApi = (data?: object) => {
|
||||
// return http.request<RefreshTokenResult>("post", "/refresh-token", { data });
|
||||
// };
|
||||
|
||||
/**获取用户列表 */
|
||||
export const getUserList = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/users/get_user_list?page=${data.page}&count=${data.count}&key=${data.key}`
|
||||
);
|
||||
};
|
||||
/**添加用户 */
|
||||
export const addUser = data => {
|
||||
return http2.post("/v1/admin/users/add_user", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**编辑用户信息 */
|
||||
export const editUser = data => {
|
||||
return http2.post("/v1/admin/users/update_user", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改用户密码 */
|
||||
export const editPassword = data => {
|
||||
return http2.post("/v1/admin/users/update_user_password", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除用户 */
|
||||
export const deleteUser = data => {
|
||||
return http2.post("/v1/admin/users/del_user", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**查询单个用户 */
|
||||
export const userDetail = data => {
|
||||
return http2.post("/v1/admin/users/select_user", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改用户余额 */
|
||||
export const editBalance = data => {
|
||||
return http2.post("/v1/admin/users/update_user_balance", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取用户服务器 */
|
||||
export const getUserServer = (data = {}) => {
|
||||
const serverType = data.server_type || "dockerContainer"; // 设置默认值
|
||||
return http2.get(
|
||||
`/v1/user/procedure/get_server_list?server_type=${serverType}`
|
||||
);
|
||||
};
|
||||
/**用户获取虚拟机列表 */
|
||||
export const getVirtualList = data => {
|
||||
let url = `/v1/user/instance/list?page=${data.page}&count=${data.count}`;
|
||||
if (data.key) {
|
||||
url += `&key=${data.key}`;
|
||||
}
|
||||
if (data.server_id) {
|
||||
url += `&server_id=${data.server_id}`;
|
||||
}
|
||||
return http2.get(url);
|
||||
};
|
||||
/**用户获取服务器套餐 */
|
||||
export const getUserPackage = data => {
|
||||
return http2.get(`/v1/user/procedure/get_server_plan_list?server_id=${data}`);
|
||||
};
|
||||
/**获取用户容器列表 */
|
||||
export const getUserContainer = data => {
|
||||
return http2.get(
|
||||
`/v1/user/container/list?page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**用户按地区获取容器 */
|
||||
export const getUserContainerD = data => {
|
||||
return http2.get(
|
||||
`/v1/user/container/list?page=${data.page}&count=${data.count}&server_id=${data.server_id}`
|
||||
);
|
||||
};
|
||||
/**获取用户操作日志 */
|
||||
export const get_user_log = () => {
|
||||
return http2.get(`/v1/user/procedure/get_user_log`);
|
||||
};
|
||||
/**获取用户自身信息 */
|
||||
export const getUserInfo = () => {
|
||||
return http2.get(`/v1/user/procedure/get_user_info`);
|
||||
};
|
||||
/**获取用户自身信息 */
|
||||
export const getUserInfoV1 = () => {
|
||||
return http2.get(`/v1/user/info/get_user_info`);
|
||||
};
|
||||
/**用户实名 */
|
||||
export const realName = data => {
|
||||
return http2.post("/v1/external/real_name", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**发送手机验证码 */
|
||||
export const sendCode = data => {
|
||||
return http2.post("/v1/external/send_message", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**发送邮箱验证码 */
|
||||
export const sendEmailCode = data => {
|
||||
return http2.post("/v1/external/send_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**用户注册 */
|
||||
export const register = data => {
|
||||
return http2.post("/v1/user/register", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**手机号修改校证码 */
|
||||
export const CodePhone = data => {
|
||||
return http2.post("/v1/user/info/ask_update_user_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改手机号码 */
|
||||
export const SetPhone = data => {
|
||||
return http2.post("/v1/user/info/update_user_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**邮箱修改校证码 */
|
||||
export const CodeEmail = data => {
|
||||
return http2.post("/v1/user/info/ask_update_user_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改邮箱 */
|
||||
export const SetEmail = data => {
|
||||
return http2.post("/v1/user/info/update_user_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**上传头像 */
|
||||
export const uploadAvatar = data => {
|
||||
return http2.post("/v1/user/info/upload_user_avatar", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**手机号忘记密码 */
|
||||
export const forgetphone = data => {
|
||||
return http2.post("/v1/user/info/forget_user_password_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**邮箱忘记密码 */
|
||||
export const forgetemail = data => {
|
||||
return http2.post("/v1/user/info/forget_user_password_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**管理员全局搜索 */
|
||||
export const Find = data => {
|
||||
return http2.post("/v1/admin/search", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 管理员删除容器网络
|
||||
export const delContainer = data => {
|
||||
return http2.post("/v1/user/container/delete_connect", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 删除端口
|
||||
export const delPort = data => {
|
||||
return http2.post("/v1/admin/instance_port/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 自定义容器价格
|
||||
export const Containerpay = data => {
|
||||
return http2.post("/v1/admin/container/update_container_price", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 修改虚拟机续费价格
|
||||
export const Containerpaytime = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/update_price/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 自定义容器到期时间
|
||||
export const Containertime = data => {
|
||||
return http2.post("/v1/admin/container/update_container_expire_time", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 修改虚拟机续到期时间
|
||||
export const Containertimetime = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/update_expire_time/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 修改虚拟机信息
|
||||
export const editContainer = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/update/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/***************************************容器管理 ************************/
|
||||
|
||||
/** 容器操作 */
|
||||
export const startUserContainer = (type, id) => {
|
||||
return http2.post(
|
||||
"/v1/user/container/" + type,
|
||||
{
|
||||
container_id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
/**用户容器退款 */
|
||||
export const backUserContainer = data => {
|
||||
return http2.post("/v1/user/container/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**重装容器 */
|
||||
export const reinContainer = data => {
|
||||
return http2.post("/v1/user/container/reinstall", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**重装虚拟机 */
|
||||
export const reinVmContainer = (id, data) => {
|
||||
return http2.post(`/v1/user/instance/reinstall/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 容器操作 */
|
||||
export const startAdminContainer = (type, id) => {
|
||||
return http2.post(
|
||||
"/v1/admin/container/" + type,
|
||||
{
|
||||
container_id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
/** 容器操作 */
|
||||
export const procedureUpdateContainerRenew = data => {
|
||||
return http2.post("/v1/user/procedure/update_container_renew", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器完整信息 */
|
||||
export const getContainerDetail = id => {
|
||||
return http2.get(`/v1/user/container/detail?container_id=${id}`);
|
||||
};
|
||||
/**获取虚拟机完整信息 */
|
||||
export const getVmContainerDetail = id => {
|
||||
return http2.get(`/v1/user/instance/detail/${id}`);
|
||||
};
|
||||
/**容器操作信息 */
|
||||
export const containerLog = data => {
|
||||
return http2.post("/v1/user/container/logs", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**虚拟机操作日志 */
|
||||
export const vmLog = data => {
|
||||
return http2.get(
|
||||
`/v1/user/instance/log/${data.id}?page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**获取容器状态 */
|
||||
export const getContainerStatus = data => {
|
||||
return http2.post(`/v1/user/container/status`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取虚拟机状态 */
|
||||
export const getVmStatus = id => {
|
||||
return http2.get(`/v1/user/instance/get_state/${id}`);
|
||||
};
|
||||
/**获取容器运行日志 */
|
||||
export const getContainerLog = data => {
|
||||
return http2.post(`/v1/user/container/run_logs`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器购买网络订单 */
|
||||
export const getContainerList = data => {
|
||||
return http2.post(`/v1/user/procedure/add_network`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**计算容器网络价格 */
|
||||
export const getContainerPrice = data => {
|
||||
return http2.post(`/v1/user/procedure/get_price_network`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 启动虚拟机 */
|
||||
export const start_vm = id => {
|
||||
return http2.get(`/v1/user/instance/start/${id}`);
|
||||
};
|
||||
/** 停止虚拟机(关机) */
|
||||
export const stop_vm = id => {
|
||||
return http2.get(`/v1/user/instance/stop/${id}`);
|
||||
};
|
||||
/**重启虚拟机 */
|
||||
export const restart_vm = id => {
|
||||
return http2.get(`/v1/user/instance/reboot/${id}`);
|
||||
};
|
||||
/**获取虚拟机控制台 */
|
||||
export const get_vm_console = id => {
|
||||
return http2.get(`/v1/user/instance/console/${id}`);
|
||||
};
|
||||
/**进入救援系统 */
|
||||
export const rescue_vm = id => {
|
||||
return http2.get(`/v1/user/instance/rescue/enter/${id}`);
|
||||
};
|
||||
/**退出救援系统 */
|
||||
export const unrescue_vm = id => {
|
||||
return http2.get(`/v1/user/instance/rescue/exit/${id}`);
|
||||
};
|
||||
|
||||
// ******************************* new
|
||||
/** 提交充值订单 */
|
||||
export const user_update_container_recharge = data => {
|
||||
return http2.post("/v1/user/procedure/update_container_recharge", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 提交容器订单 */
|
||||
export const user_update_plan_info = data => {
|
||||
return http2.post("/v1/user/procedure/update_plan_info", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 提交虚拟机订单 */
|
||||
export const user_update_vm_info = data => {
|
||||
return http2.post("/v1/user/procedure/create_vm_trade", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取订单简略信息 */
|
||||
export const getOrderDetail = id => {
|
||||
return http2.get(`/v1/user/procedure/get_low_trade_info?trade_id=${id}`);
|
||||
};
|
||||
/**支付请求 */
|
||||
export const pay_request = data => {
|
||||
return http2.post("/v1/external/pay", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**用户删除容器网络 */
|
||||
export const deleteConNet = data => {
|
||||
return http2.post("/v1/user/container/delete_connect", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 添加https
|
||||
export const additionHttp = data => {
|
||||
return http2.post("/v1/user/container/add_https_connet", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 删除https
|
||||
export const DelHttp = data => {
|
||||
return http2.post("/v1/user/container/del_https_connet", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取新增虚拟机端口价格 */
|
||||
export const getVmPortPrice = data => {
|
||||
return http2.post("/v1/user/procedure/get_price_instance_port", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**提交新增虚拟机端口订单 */
|
||||
export const addVmPort = data => {
|
||||
return http2.post("/v1/user/procedure/add_instance_port", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,171 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
|
||||
|
||||
/**获取虚拟机列表 */
|
||||
export const getVirtualList = data => {
|
||||
let url = `/v1/admin/instance/list?page=${data.page}&count=${data.count}`;
|
||||
if (data.key) {
|
||||
url += `&key=${data.key}`;
|
||||
}
|
||||
if (data.user_id) {
|
||||
url += `&user_id=${data.user_id}`;
|
||||
}
|
||||
if (data.server_id) {
|
||||
url += `&server_id=${data.server_id}`;
|
||||
}
|
||||
return http2.get(url);
|
||||
};
|
||||
|
||||
/**新增虚拟机 */
|
||||
export const addVirtual = data => {
|
||||
return http2.post("/v1/admin/instance/create_vm", data);
|
||||
};
|
||||
|
||||
/**迁移数据卷 */
|
||||
export const migrate_disk = data => {
|
||||
return http2.post("/v1/admin/volume/migrate_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取虚拟机访问控制列表 */
|
||||
export const getVirtualAccessList = data => {
|
||||
let url = `/v1/admin/instance/access_control/list?page=${data.page}&count=${data.count}&instance_id=${data.instance_id}`;
|
||||
return http2.get(url);
|
||||
};
|
||||
/**获取虚拟机访问控制列表(用户) */
|
||||
export const getUserAccessList = data => {
|
||||
let url = `/v1/user/instance/access_control/list?page=${data.page}&count=${data.count}&instance_id=${data.instance_id}`;
|
||||
return http2.get(url);
|
||||
};
|
||||
|
||||
/**创建访问控制 */
|
||||
export const createAccessControl = data => {
|
||||
return http2.post("/v1/admin/instance/access_control/create", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**创建访问控制(用户) */
|
||||
export const createUserAccessControl = data => {
|
||||
return http2.post("/v1/user/instance/access_control/create", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除访问控制 */
|
||||
export const deleteAccessControl = data => {
|
||||
return http2.post("/v1/admin/instance/access_control/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除访问控制(用户) */
|
||||
export const deleteUserAccessControl = data => {
|
||||
return http2.post("/v1/user/instance/access_control/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取虚拟机快照列表 */
|
||||
export const getSnapshotList = data => {
|
||||
let url = `/v1/admin/instance/snapshot/list/${data.instance_id}?page=${data.page}&count=${data.count}`;
|
||||
return http2.get(url);
|
||||
};
|
||||
/**获取虚拟机快照列表(用户) */
|
||||
export const getUserSnapshotList = data => {
|
||||
let url = `/v1/user/instance/snapshot/list/${data.instance_id}?page=${data.page}&count=${data.count}`;
|
||||
return http2.get(url);
|
||||
};
|
||||
/**创建虚拟机快照 */
|
||||
export const createSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/snapshot/create/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**创建虚拟机快照(用户) */
|
||||
export const createUserSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/user/instance/snapshot/create/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**删除虚拟机快照 */
|
||||
export const deleteSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/snapshot/delete/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**恢复虚拟机快照 */
|
||||
export const recoverSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/snapshot/restore/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**恢复虚拟机快照(用户) */
|
||||
export const recoverUserSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/user/instance/snapshot/restore/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取实时监控 */
|
||||
export const getVirtualLog = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/instance/run_logs/${data.id}?start_time=${data.start_time}&end_time=${data.end_time}`
|
||||
);
|
||||
};
|
||||
/**获取实时监控(用户) */
|
||||
export const getUserVirtualLog = data => {
|
||||
return http2.get(
|
||||
`/v1/user/instance/run_logs/${data.id}?start_time=${data.start_time}&end_time=${data.end_time}`
|
||||
);
|
||||
};
|
||||
|
||||
/**获取新增虚拟机快照数量价格 */
|
||||
export const getSnapshotPrice = data => {
|
||||
return http2.get(`/v1/user/procedure/get_price_snapshot?num=${data}`);
|
||||
};
|
||||
|
||||
/**提交虚拟机购买快照订单 */
|
||||
export const submitSnapshotOrder = data => {
|
||||
return http2.post("/v1/user/procedure/update_container_snapshot", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 获取购买虚拟机数据卷价格
|
||||
export const getVolumePrice = data => {
|
||||
return http2.post("/v1/user/procedure/get_price_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 提交虚拟机数据卷订单
|
||||
export const submitVolumeOrder = data => {
|
||||
return http2.post("/v1/user/procedure/update_container_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 复制文本到剪贴板
|
||||
* @param {string} text 要复制的文本
|
||||
* @returns {Promise<boolean>} 是否复制成功
|
||||
*/
|
||||
export const copyDomText = (text) => {
|
||||
// 优先使用 navigator.clipboard API (现代浏览器)
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
return navigator.clipboard.writeText(text)
|
||||
.then(() => {
|
||||
return true;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('复制到剪贴板失败:', error);
|
||||
return fallbackCopyTextToClipboard(text);
|
||||
});
|
||||
} else {
|
||||
// 回退方案
|
||||
return fallbackCopyTextToClipboard(text);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 使用传统方法复制文本到剪贴板
|
||||
* @param {string} text 要复制的文本
|
||||
* @returns {boolean} 是否复制成功
|
||||
*/
|
||||
const fallbackCopyTextToClipboard = (text) => {
|
||||
try {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
|
||||
// 避免滚动到底部
|
||||
textArea.style.top = '0';
|
||||
textArea.style.left = '0';
|
||||
textArea.style.position = 'fixed';
|
||||
textArea.style.opacity = '0';
|
||||
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
|
||||
const successful = document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
|
||||
return successful;
|
||||
} catch (err) {
|
||||
console.error('复制到剪贴板失败:', err);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
+73
-7
@@ -1,4 +1,26 @@
|
||||
import axios from 'axios'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import router from '@/router'
|
||||
|
||||
// 基础URL
|
||||
const baseUrl = 'https://apiservertest.s1f.ren'
|
||||
|
||||
// 检查URL是否需要认证
|
||||
const urlNeedAuth = (url) => {
|
||||
// 这里可以添加不需要认证的URL列表
|
||||
const noAuthUrls = ['/v1/user/login', '/v1/user/check/get_code_img', '/v1/user/register']
|
||||
return !noAuthUrls.some(noAuthUrl => url.includes(noAuthUrl))
|
||||
}
|
||||
|
||||
// 检查token是否过期
|
||||
const isTokenExpired = () => {
|
||||
const token = localStorage.getItem('token')
|
||||
if (!token) return true
|
||||
|
||||
// 这里可以添加token过期检查逻辑,如果有JWT可以解析它
|
||||
// 简单实现,仅检查token是否存在
|
||||
return false
|
||||
}
|
||||
|
||||
class Request {
|
||||
constructor(config = {}) {
|
||||
@@ -14,10 +36,10 @@ class Request {
|
||||
(config) => {
|
||||
// 在发送请求之前做些什么
|
||||
// 例如:添加 token
|
||||
// const token = localStorage.getItem('token')
|
||||
// if (token) {
|
||||
// config.headers.Authorization = `Bearer ${token}`
|
||||
// }
|
||||
const token = localStorage.getItem('token')
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
return config
|
||||
},
|
||||
(error) => {
|
||||
@@ -49,7 +71,7 @@ class Request {
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
return Promise.reject(error)
|
||||
return error.response.data
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -82,11 +104,55 @@ class Request {
|
||||
|
||||
// 创建默认实例
|
||||
const request = new Request({
|
||||
baseURL: 'http://localhost:3000',
|
||||
baseURL: baseUrl,
|
||||
timeout: 5000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
|
||||
export const mainUrl = baseUrl + "/acs"
|
||||
|
||||
export const http2 = axios.create({
|
||||
baseURL: baseUrl,
|
||||
timeout: 5000,
|
||||
headers: {},
|
||||
});
|
||||
|
||||
http2.interceptors.request.use(config => {
|
||||
const token = localStorage.getItem('token'); // 假设 token 存储在 localStorage
|
||||
if(urlNeedAuth(config.url) && isTokenExpired()){
|
||||
if (token){
|
||||
localStorage.removeItem('token');
|
||||
ElMessage.warning('登陆过期,请重新登陆')
|
||||
}
|
||||
router.push('/login')
|
||||
return Promise.reject();
|
||||
}
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
|
||||
config.url = '/acs' + config.url
|
||||
return config
|
||||
})
|
||||
|
||||
http2.interceptors.response.use(
|
||||
response => response, // 正常响应时直接返回
|
||||
error => {
|
||||
console.log('出现错误', error.response);
|
||||
if (error.response == undefined) {
|
||||
ElMessage.error("服务器错误,请稍后再试");
|
||||
return Promise.reject(error);
|
||||
}
|
||||
const { status } = error.response;
|
||||
if (status === 401) {
|
||||
localStorage.removeItem('token');
|
||||
ElMessage.warning('登陆过期,请重新登陆')
|
||||
router.push('/login')
|
||||
return Promise.reject();
|
||||
}
|
||||
// 其他错误处理(可选)
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export default request
|
||||
@@ -0,0 +1,409 @@
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<!-- 登录表单区域 -->
|
||||
<div class="login-form-container">
|
||||
<div class="login-content">
|
||||
<div class="login-header">
|
||||
<h1 class="system-name">零零七云计算后台控制面板</h1>
|
||||
</div>
|
||||
<h2 class="welcome-text">欢迎回来</h2>
|
||||
<p class="sub-title">登录您的账户以继续访问</p>
|
||||
|
||||
<el-form
|
||||
ref="loginFormRef"
|
||||
:model="loginForm"
|
||||
:rules="loginRules"
|
||||
class="login-form"
|
||||
>
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
placeholder="请输入用户名"
|
||||
:prefix-icon="User"
|
||||
clearable
|
||||
size="large"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-input
|
||||
v-model="loginForm.password"
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
:prefix-icon="Lock"
|
||||
show-password
|
||||
clearable
|
||||
size="large"
|
||||
@keyup.enter="handleLogin"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<div class="login-options">
|
||||
<el-checkbox v-model="rememberMe">
|
||||
<span class="remember-text">记住我</span>
|
||||
</el-checkbox>
|
||||
<el-button link type="primary" class="forget-btn" @click="forgetPassword">忘记密码?</el-button>
|
||||
</div>
|
||||
|
||||
<el-button
|
||||
type="primary"
|
||||
class="login-button"
|
||||
:loading="loading"
|
||||
@click="handleLogin"
|
||||
>
|
||||
{{ loading ? '登录中...' : '登录' }}
|
||||
</el-button>
|
||||
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="login-footer">
|
||||
<p class="copyright">Copyright © 2025 零零七云计算 All Rights Reserved.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 装饰区域 -->
|
||||
<div class="login-decoration">
|
||||
<div class="decoration-content">
|
||||
<h2 class="slogan">新一代企业级管理系统</h2>
|
||||
<p class="description">基于 Vue3 + Element Plus 的现代化管理系统</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { User, Lock, Monitor, Connection } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {getUserInfo, userLogin} from "@/api/login.js";
|
||||
|
||||
const router = useRouter()
|
||||
const loginFormRef = ref(null)
|
||||
const loading = ref(false)
|
||||
const rememberMe = ref(false)
|
||||
|
||||
const loginForm = reactive({
|
||||
username: '',
|
||||
password: ''
|
||||
})
|
||||
|
||||
const loginRules = {
|
||||
username: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
{ min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
const forgetPassword = () => {
|
||||
ElMessage.warning('请前往官网重置密码!')
|
||||
}
|
||||
const handleLogin = () => {
|
||||
loginFormRef.value?.validate(async valid =>{
|
||||
window.localStorage.removeItem('token')
|
||||
if (valid) {
|
||||
loading.value = true
|
||||
let resp = await userLogin(loginForm.username, loginForm.password)
|
||||
loading.value = false
|
||||
if(resp.code === 200){
|
||||
|
||||
window.localStorage.setItem('token',resp.data.token)
|
||||
let userInfo = await getUserInfo()
|
||||
if(userInfo.data.is_admin){
|
||||
await router.push('/dashboard')
|
||||
} else {
|
||||
ElMessage.warning('你不是管理员,不能登陆到后台控制面板')
|
||||
}
|
||||
}else{
|
||||
ElMessage.error(resp.message)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-container {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.login-form-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 40px;
|
||||
background: #fff;
|
||||
position: relative;
|
||||
max-width: 520px;
|
||||
}
|
||||
|
||||
.login-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
max-width: 360px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
.system-name {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
background: linear-gradient(45deg, #1890ff, #36cfc9);
|
||||
-webkit-background-clip: text;
|
||||
color: transparent;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.welcome-text {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.sub-title {
|
||||
font-size: 16px;
|
||||
color: #6b7280;
|
||||
margin: 0 0 40px 0;
|
||||
}
|
||||
|
||||
.login-form :deep(.el-input) {
|
||||
--el-input-height: 44px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.login-form :deep(.el-input__wrapper) {
|
||||
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.login-form :deep(.el-input__inner) {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.login-options {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 16px 0 24px;
|
||||
}
|
||||
|
||||
.remember-text {
|
||||
color: #4b5563;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.forget-btn {
|
||||
font-size: 14px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.login-button {
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
font-size: 16px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.divider {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 0 0 24px;
|
||||
color: #9ca3af;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.divider::before,
|
||||
.divider::after {
|
||||
content: '';
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
background: #e5e7eb;
|
||||
}
|
||||
|
||||
.divider-text {
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.social-login {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.social-btn {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.social-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.wechat {
|
||||
background: #07c160;
|
||||
border-color: #07c160;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dingtalk {
|
||||
background: #1890ff;
|
||||
border-color: #1890ff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.github {
|
||||
background: #24292e;
|
||||
border-color: #24292e;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.login-footer {
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-size: 14px;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
/* 装饰区域样式 */
|
||||
.login-decoration {
|
||||
flex: 1.5;
|
||||
background: linear-gradient(135deg, #1890ff 0%, #36cfc9 100%);
|
||||
padding: 60px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.login-decoration::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: url('../assets/grid.svg') repeat;
|
||||
opacity: 0.1;
|
||||
}
|
||||
|
||||
.decoration-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-size: 42px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 16px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 18px;
|
||||
opacity: 0.9;
|
||||
margin: 0 0 60px;
|
||||
}
|
||||
|
||||
.feature-list {
|
||||
display: grid;
|
||||
gap: 32px;
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
.feature-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.feature-icon {
|
||||
font-size: 24px;
|
||||
padding: 12px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.feature-info h3 {
|
||||
font-size: 18px;
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
|
||||
.feature-info p {
|
||||
font-size: 14px;
|
||||
opacity: 0.8;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.decoration-footer {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tech-stack {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.tech-icon {
|
||||
height: 32px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.login-decoration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.login-form-container {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.login-form-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.welcome-text {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.sub-title {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+46
-19
@@ -1,34 +1,61 @@
|
||||
<template>
|
||||
<div class="not-found">
|
||||
<h1>404</h1>
|
||||
<p>抱歉,页面不存在</p>
|
||||
<router-link to="/">返回首页</router-link>
|
||||
<div class="not-found-container">
|
||||
<div class="not-found-content">
|
||||
<img src="../assets/404.svg" alt="404" class="not-found-image" />
|
||||
<h1 class="not-found-title">404</h1>
|
||||
<h2 class="not-found-subtitle">抱歉,您访问的页面不存在</h2>
|
||||
<p class="not-found-desc">可能是链接错误或者该页面已被删除</p>
|
||||
<el-button type="primary" @click="backHome">返回首页</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'NotFound'
|
||||
<script setup>
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const backHome = () => {
|
||||
router.push('/dashboard')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.not-found {
|
||||
padding: 40px;
|
||||
.not-found-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
background-color: #f0f2f5;
|
||||
}
|
||||
|
||||
.not-found-content {
|
||||
text-align: center;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
.not-found-image {
|
||||
width: 250px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.not-found-title {
|
||||
font-size: 72px;
|
||||
font-weight: bold;
|
||||
color: #1890ff;
|
||||
margin: 0;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.not-found-subtitle {
|
||||
font-size: 24px;
|
||||
color: #333;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.not-found-desc {
|
||||
font-size: 16px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #42b983;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
margin: 20px 0 30px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onBeforeMount } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
onBeforeMount(() => {
|
||||
const { params, query } = route
|
||||
const { path } = params
|
||||
|
||||
// 将path数组转换为路径字符串
|
||||
const redirectPath = Array.isArray(path) ? '/' + path.join('/') : '/' + path
|
||||
|
||||
router.replace({ path: redirectPath, query })
|
||||
})
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,708 @@
|
||||
<template>
|
||||
<div class="image-categories-container" v-loading="loading">
|
||||
<!-- 页面标题 -->
|
||||
<div class="page-header">
|
||||
<h2>镜像分类管理</h2>
|
||||
<p class="page-description">管理不同服务器下的镜像分类</p>
|
||||
</div>
|
||||
|
||||
<!-- 操作栏 -->
|
||||
<el-card class="search-card">
|
||||
<el-form :inline="true" class="search-form">
|
||||
<el-form-item label="服务器">
|
||||
<el-select
|
||||
v-model="selectedServer"
|
||||
placeholder="请选择服务器"
|
||||
clearable
|
||||
@change="handleServerChange"
|
||||
style="width: 220px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in serverList"
|
||||
:key="item.server_id"
|
||||
:label="item.name"
|
||||
:value="item.server_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类名称">
|
||||
<el-input
|
||||
v-model="searchKey"
|
||||
placeholder="搜索分类名称"
|
||||
clearable
|
||||
@input="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="handleAddCategory"
|
||||
:disabled="!selectedServer"
|
||||
>
|
||||
<el-icon><plus /></el-icon>添加分类
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 表格 -->
|
||||
<el-card class="table-card">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="filteredCategoryList"
|
||||
style="width: 100%"
|
||||
border
|
||||
stripe
|
||||
highlight-current-row
|
||||
>
|
||||
<el-table-column type="index" width="60" align="center" label="序号" />
|
||||
<el-table-column prop="name" label="分类名称" min-width="150" />
|
||||
<el-table-column label="分类图标" align="center" width="100">
|
||||
<template #default="scope">
|
||||
<el-avatar
|
||||
v-if="scope.row.class_ico"
|
||||
:size="40"
|
||||
:src="scope.row.class_ico"
|
||||
fit="cover"
|
||||
/>
|
||||
<el-icon v-else :size="20"><picture /></el-icon>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="所属服务器" min-width="150">
|
||||
<template #default="scope">
|
||||
<el-tag type="info">{{ getServerName(scope.row.server_id) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" min-width="180">
|
||||
<template #default="scope">
|
||||
{{ scope.row.created_at }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="200" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
type="success"
|
||||
link
|
||||
@click="handleEditCategory(scope.row)"
|
||||
>
|
||||
<el-icon><edit /></el-icon>编辑
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页器 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
background
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="totalCount"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 添加/编辑分类对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="isEdit ? '编辑分类' : '添加分类'"
|
||||
width="500px"
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form
|
||||
ref="categoryFormRef"
|
||||
:model="categoryForm"
|
||||
:rules="categoryRules"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="所属服务器" prop="server_id" v-if="!isEdit">
|
||||
<el-select
|
||||
v-model="categoryForm.server_id"
|
||||
placeholder="请选择服务器"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in serverList"
|
||||
:key="item.server_id"
|
||||
:label="item.name"
|
||||
:value="item.server_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类名称" prop="class_name">
|
||||
<el-input v-model="categoryForm.class_name" placeholder="请输入分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类图标" prop="class_icon">
|
||||
<div class="image-icon-upload">
|
||||
<div class="preview-container">
|
||||
<img
|
||||
v-if="categoryForm.class_icon"
|
||||
:src="categoryForm.class_icon"
|
||||
class="preview-icon"
|
||||
/>
|
||||
<div v-else class="empty-preview">
|
||||
<el-icon><picture /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="upload-buttons">
|
||||
<el-button type="primary" @click="$refs.fileInput.click()">选择文件</el-button>
|
||||
<input ref="fileInput" type="file" style="display: none" @change="onFileSelected" />
|
||||
<div class="el-upload__tip" v-if="selectedFileName">
|
||||
已选择: {{ selectedFileName }}
|
||||
</div>
|
||||
<el-button @click="picSwitch = true; getpicList()">从素材库选择</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submitCategoryForm" :loading="submitLoading">
|
||||
确 定
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 素材库对话框 -->
|
||||
<el-dialog v-model="picSwitch" title="素材库" width="70%" :before-close="() => picSwitch = false">
|
||||
<div class="pic-search">
|
||||
<el-input
|
||||
v-model="picPagin.key"
|
||||
placeholder="请输入搜索内容"
|
||||
style="width: 300px; margin-bottom: 20px"
|
||||
@blur="getpicList()"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="getpicList()">
|
||||
<el-icon><search /></el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<div class="piclist">
|
||||
<div
|
||||
v-for="(item, index) in picList"
|
||||
:key="index"
|
||||
class="icon"
|
||||
:class="{ choose: currentIndex === index }"
|
||||
@click="selectImage(index, item)"
|
||||
>
|
||||
<img :src="`${mainUrl}/v1/attachment/get_attachment?aid=${item.attachment_id}`" />
|
||||
<div class="tit">{{ item.title ? item.title.slice(0, 8) : '未命名' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pagination-container" style="margin-top: 20px">
|
||||
<el-pagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:current-page="picPagin.page"
|
||||
:page-size="picPagin.count"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
@current-change="CurrentPageChange"
|
||||
@size-change="PageSizeChange"
|
||||
/>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="picSwitch = false">取消</el-button>
|
||||
<el-button type="primary" @click="tochoose">确认选择</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Search, Plus, Picture, Edit } from '@element-plus/icons-vue'
|
||||
import dayjs from 'dayjs'
|
||||
import { getServer } from '@/utils/acs/server'
|
||||
import { getImageTypeList, createImageType, updateImageType } from '@/utils/acs/mirror'
|
||||
import { uploadFile, getFileList } from '@/utils/acs/message'
|
||||
import { mainUrl } from '@/utils/request'
|
||||
|
||||
// 数据
|
||||
const loading = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const serverList = ref([])
|
||||
const categoryList = ref([])
|
||||
const selectedServer = ref('')
|
||||
const searchKey = ref('')
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const totalCount = ref(0)
|
||||
const dialogVisible = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const categoryFormRef = ref(null)
|
||||
const selectedFileName = ref(null)
|
||||
|
||||
const categoryForm = reactive({
|
||||
server_id: '',
|
||||
class_id: '',
|
||||
class_name: '',
|
||||
class_icon: ''
|
||||
})
|
||||
|
||||
const categoryRules = {
|
||||
server_id: [
|
||||
{ required: true, message: '请选择所属服务器', trigger: 'change' }
|
||||
],
|
||||
class_name: [
|
||||
{ required: true, message: '请输入分类名称', trigger: 'blur' },
|
||||
{ min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
// 素材库相关
|
||||
const picSwitch = ref(false)
|
||||
const picPagin = reactive({
|
||||
count: 50,
|
||||
page: 1,
|
||||
key: '',
|
||||
user_type: 1
|
||||
})
|
||||
const picList = ref([])
|
||||
const total = ref(10)
|
||||
const currentIndex = ref(null)
|
||||
|
||||
// 计算属性:过滤分类列表
|
||||
const filteredCategoryList = computed(() => {
|
||||
if (!searchKey.value) {
|
||||
return categoryList.value
|
||||
}
|
||||
return categoryList.value.filter(item =>
|
||||
item.name && item.name.toLowerCase().includes(searchKey.value.toLowerCase())
|
||||
)
|
||||
})
|
||||
|
||||
// 生命周期钩子
|
||||
onMounted(async () => {
|
||||
await fetchServerList()
|
||||
})
|
||||
|
||||
// 方法
|
||||
const fetchServerList = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
// 获取服务器列表,这里包含了所有类型的服务器
|
||||
const response = await getServer(1, 100, '', '')
|
||||
if (response.data.code === 200) {
|
||||
serverList.value = response.data.data || []
|
||||
// 如果没有选择服务器但有服务器列表数据,默认选择第一个服务器
|
||||
if (serverList.value.length > 0 && !selectedServer.value) {
|
||||
selectedServer.value = serverList.value[0].server_id
|
||||
// 获取默认服务器的分类列表
|
||||
fetchCategoryList()
|
||||
}
|
||||
} else {
|
||||
ElMessage.error('获取服务器列表失败:' + response.data.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取服务器列表出错:', error)
|
||||
ElMessage.error('获取服务器列表出错')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const fetchCategoryList = async () => {
|
||||
if (!selectedServer.value) {
|
||||
categoryList.value = []
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
const response = await getImageTypeList(selectedServer.value)
|
||||
if (response.data.code === 200) {
|
||||
categoryList.value = response.data.data || []
|
||||
totalCount.value = categoryList.value.length
|
||||
} else {
|
||||
ElMessage.error('获取镜像分类失败:' + response.data.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取镜像分类出错:', error)
|
||||
ElMessage.error('获取镜像分类出错')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleServerChange = () => {
|
||||
currentPage.value = 1
|
||||
fetchCategoryList()
|
||||
}
|
||||
|
||||
const handleSearch = () => {
|
||||
currentPage.value = 1
|
||||
}
|
||||
|
||||
const handleSizeChange = (val) => {
|
||||
pageSize.value = val
|
||||
currentPage.value = 1
|
||||
}
|
||||
|
||||
const handleCurrentChange = (val) => {
|
||||
currentPage.value = val
|
||||
}
|
||||
|
||||
const handleAddCategory = () => {
|
||||
isEdit.value = false
|
||||
categoryForm.server_id = selectedServer.value
|
||||
categoryForm.class_id = ''
|
||||
categoryForm.class_name = ''
|
||||
categoryForm.class_icon = ''
|
||||
selectedFileName.value = null
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleEditCategory = (row) => {
|
||||
isEdit.value = true
|
||||
categoryForm.server_id = row.server_id
|
||||
categoryForm.class_id = row.class_id
|
||||
categoryForm.class_name = row.name
|
||||
categoryForm.class_icon = row.class_ico
|
||||
selectedFileName.value = null
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
|
||||
// 处理文件变更
|
||||
const onFileSelected = (event) => {
|
||||
const file = event.target.files[0]
|
||||
if (file) {
|
||||
selectedFileName.value = file.name
|
||||
const isImage = /^image\/(jpeg|png|jpg|gif)$/.test(file.type)
|
||||
const isLt2M = file.size / 1024 / 1024 < 2
|
||||
|
||||
if (!isImage) {
|
||||
ElMessage.error('上传图标只能是图片格式!')
|
||||
return
|
||||
}
|
||||
if (!isLt2M) {
|
||||
ElMessage.error('上传图标大小不能超过 2MB!')
|
||||
return
|
||||
}
|
||||
|
||||
uploadFile({ file: file }).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
ElMessage.success('上传成功')
|
||||
categoryForm.class_icon = mainUrl + '/v1/attachment/get_attachment?aid=' + res.data.data.attachment_id
|
||||
} else {
|
||||
ElMessage.error('上传失败:' + res.data.message)
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('上传文件出错:', error)
|
||||
ElMessage.error('上传失败')
|
||||
})
|
||||
} else {
|
||||
selectedFileName.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const submitCategoryForm = () => {
|
||||
categoryFormRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
|
||||
try {
|
||||
submitLoading.value = true
|
||||
let response
|
||||
|
||||
if (isEdit.value) {
|
||||
// 编辑分类
|
||||
response = await updateImageType(
|
||||
categoryForm.class_id,
|
||||
categoryForm.class_name,
|
||||
categoryForm.class_icon
|
||||
)
|
||||
} else {
|
||||
// 添加分类
|
||||
response = await createImageType(
|
||||
categoryForm.server_id,
|
||||
categoryForm.class_name,
|
||||
categoryForm.class_icon
|
||||
)
|
||||
}
|
||||
|
||||
if (response.data.code === 200) {
|
||||
ElMessage.success(isEdit.value ? '更新分类成功' : '添加分类成功')
|
||||
dialogVisible.value = false
|
||||
fetchCategoryList()
|
||||
} else {
|
||||
ElMessage.error((isEdit.value ? '更新分类失败:' : '添加分类失败:') + response.data.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(isEdit.value ? '更新分类出错:' : '添加分类出错:', error)
|
||||
ElMessage.error(isEdit.value ? '更新分类出错' : '添加分类出错')
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 素材库相关方法
|
||||
const getpicList = () => {
|
||||
getFileList(picPagin).then(res => {
|
||||
if (res.data.code === 200) {
|
||||
picList.value = res.data.data || []
|
||||
total.value = res.data.count || 0
|
||||
} else {
|
||||
ElMessage.error('获取图片列表失败:' + res.data.message)
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('获取图片列表出错:', error)
|
||||
ElMessage.error('获取图片列表失败')
|
||||
})
|
||||
}
|
||||
|
||||
const selectImage = (index, data) => {
|
||||
currentIndex.value = index
|
||||
}
|
||||
|
||||
const CurrentPageChange = async newPage => {
|
||||
picPagin.page = newPage
|
||||
getpicList()
|
||||
}
|
||||
|
||||
const PageSizeChange = async newSize => {
|
||||
picPagin.count = newSize
|
||||
getpicList()
|
||||
}
|
||||
|
||||
const tochoose = () => {
|
||||
if (currentIndex.value != null) {
|
||||
categoryForm.class_icon = `${mainUrl}/v1/attachment/get_attachment?aid=${picList.value[currentIndex.value].attachment_id}`
|
||||
picSwitch.value = false
|
||||
ElMessage.success('已选择图标')
|
||||
} else {
|
||||
ElMessage.warning('请先选择一个图标')
|
||||
}
|
||||
}
|
||||
|
||||
const getServerName = (serverId) => {
|
||||
const server = serverList.value.find(item => item.server_id === serverId)
|
||||
return server ? server.name : '--'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.image-categories-container {
|
||||
padding: 24px;
|
||||
background-color: #f5f7fa;
|
||||
min-height: calc(100vh - 60px);
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-bottom: 24px;
|
||||
background: #fff;
|
||||
padding: 16px 24px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.page-header h2 {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
color: #303133;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.page-description {
|
||||
margin-top: 8px;
|
||||
color: #6b7280;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
margin-bottom: 24px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 24px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 16px;
|
||||
padding: 0 16px 16px;
|
||||
}
|
||||
|
||||
/* 图片上传区域样式 */
|
||||
.image-icon-upload {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.preview-container {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: 1px dashed #d9d9d9;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.preview-icon {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.empty-preview {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: #8c939d;
|
||||
}
|
||||
|
||||
.empty-preview .el-icon {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.upload-buttons {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.el-upload__tip {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* 素材库样式 */
|
||||
.piclist {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.piclist .icon {
|
||||
width: 100px;
|
||||
height: 110px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #ebeef5;
|
||||
transition: all 0.3s;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.piclist .icon:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
|
||||
.piclist .icon img {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.piclist .icon .tit {
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.piclist .choose {
|
||||
border-color: #409EFF;
|
||||
box-shadow: 0 0 12px rgba(64, 158, 255, 0.6);
|
||||
background-color: #ecf5ff;
|
||||
}
|
||||
|
||||
/* 对话框样式优化 */
|
||||
:deep(.el-dialog__header) {
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__footer) {
|
||||
border-top: 1px solid #ebeef5;
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
background-color: #f5f7fa;
|
||||
color: #606266;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:deep(.el-table__row:hover) {
|
||||
background-color: #ecf5ff !important;
|
||||
}
|
||||
|
||||
:deep(.el-button--link) {
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
:deep(.el-button--link):hover {
|
||||
background-color: #f0f2f5;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* 响应式调整 */
|
||||
@media (max-width: 768px) {
|
||||
.image-icon-upload {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.upload-buttons {
|
||||
margin-top: 12px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,728 @@
|
||||
<template>
|
||||
<div class="image-requests-container">
|
||||
<div class="page-header">
|
||||
<h2>申请镜像</h2>
|
||||
<div class="header-actions">
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<el-icon><plus /></el-icon>申请镜像
|
||||
</el-button>
|
||||
<el-button @click="handleRefresh">
|
||||
<el-icon><refresh /></el-icon>刷新
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 提示信息 -->
|
||||
<el-alert
|
||||
type="info"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="info-alert"
|
||||
>
|
||||
<el-icon><info-filled /></el-icon>
|
||||
申请的镜像需要经过安全审核,审核通过后可在创建云电脑或容器时使用,审核结果将通过站内信通知。
|
||||
</el-alert>
|
||||
|
||||
<!-- 搜索区域 -->
|
||||
<el-card class="search-card">
|
||||
<el-form :inline="true" :model="searchForm" class="search-form">
|
||||
<el-form-item label="镜像名称">
|
||||
<el-input v-model="searchForm.name" placeholder="请输入镜像名称" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="镜像类型">
|
||||
<el-select v-model="searchForm.type" placeholder="请选择镜像类型" clearable>
|
||||
<el-option label="Docker镜像" value="docker" />
|
||||
<el-option label="Windows镜像" value="windows" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请状态">
|
||||
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable>
|
||||
<el-option label="已通过" value="approved" />
|
||||
<el-option label="审核中" value="pending" />
|
||||
<el-option label="已拒绝" value="rejected" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">
|
||||
<el-icon><search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetSearch">
|
||||
<el-icon><refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<el-card class="table-card">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
border
|
||||
style="width: 100%"
|
||||
row-key="id"
|
||||
>
|
||||
<el-table-column prop="id" label="申请ID" width="150" align="center" />
|
||||
<el-table-column prop="name" label="镜像名称" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="type" label="类型" width="120" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.type === 'docker' ? 'success' : 'primary'">
|
||||
{{ scope.row.type === 'docker' ? 'Docker' : 'Windows' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="requestTime" label="申请时间" width="180" align="center" />
|
||||
<el-table-column prop="status" label="状态" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStatusType(scope.row.status)">
|
||||
{{ getStatusText(scope.row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="220" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" link @click="handleView(scope.row)">
|
||||
<el-icon><view /></el-icon>查看详情
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.status === 'rejected'"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleResubmit(scope.row)"
|
||||
>
|
||||
<el-icon><refresh /></el-icon>重新提交
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.currentPage"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="pagination.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 申请镜像对话框 -->
|
||||
<el-dialog
|
||||
v-model="requestDialogVisible"
|
||||
title="申请镜像"
|
||||
width="700px"
|
||||
:before-close="handleDialogClose"
|
||||
>
|
||||
<el-form :model="requestForm" label-width="120px" :rules="rules" ref="requestFormRef">
|
||||
<el-form-item label="镜像类型" prop="type">
|
||||
<el-radio-group v-model="requestForm.type">
|
||||
<el-radio label="docker">Docker镜像</el-radio>
|
||||
<el-radio label="windows">Windows镜像</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="镜像名称" prop="name">
|
||||
<el-input v-model="requestForm.name" placeholder="请输入镜像名称,例如:MySQL 8.0" />
|
||||
</el-form-item>
|
||||
|
||||
<template v-if="requestForm.type === 'docker'">
|
||||
<el-form-item label="Docker镜像地址" prop="dockerImage">
|
||||
<el-input v-model="requestForm.dockerImage" placeholder="请输入Docker镜像地址,例如:mysql:8.0">
|
||||
<template #prepend>
|
||||
<el-select v-model="requestForm.dockerSource" style="width: 120px">
|
||||
<el-option label="Docker Hub" value="dockerhub" />
|
||||
<el-option label="自定义" value="custom" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-input>
|
||||
<div class="form-tip">Docker Hub格式:mysql:8.0;自建仓库格式:namespace/repo:tag</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-divider content-position="left">环境变量配置</el-divider>
|
||||
|
||||
<div class="env-vars-container">
|
||||
<div class="env-vars-header">
|
||||
<div class="env-var-name">变量名</div>
|
||||
<div class="env-var-value">变量值</div>
|
||||
<div class="env-var-action"></div>
|
||||
</div>
|
||||
|
||||
<div v-for="(env, index) in requestForm.envVars" :key="index" class="env-vars-item">
|
||||
<el-input v-model="env.key" placeholder="KEY" />
|
||||
<el-input v-model="env.value" placeholder="VALUE" />
|
||||
<el-button circle type="danger" @click="removeEnvVar(index)">
|
||||
<el-icon><delete /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-button type="primary" plain @click="addEnvVar" class="add-env-btn">
|
||||
<el-icon><plus /></el-icon>添加环境变量
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-divider content-position="left">暴露端口</el-divider>
|
||||
|
||||
<div class="ports-container">
|
||||
<div class="ports-header">
|
||||
<div class="port-container">容器端口</div>
|
||||
<div class="port-protocol">协议</div>
|
||||
<div class="port-desc">描述</div>
|
||||
<div class="port-action"></div>
|
||||
</div>
|
||||
|
||||
<div v-for="(port, index) in requestForm.ports" :key="index" class="ports-item">
|
||||
<el-input-number v-model="port.containerPort" :min="1" :max="65535" controls-position="right" />
|
||||
<el-select v-model="port.protocol">
|
||||
<el-option label="TCP" value="TCP" />
|
||||
<el-option label="UDP" value="UDP" />
|
||||
</el-select>
|
||||
<el-input v-model="port.description" placeholder="请填写用途描述" />
|
||||
<el-button circle type="danger" @click="removePort(index)">
|
||||
<el-icon><delete /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-button type="primary" plain @click="addPort" class="add-port-btn">
|
||||
<el-icon><plus /></el-icon>添加端口
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<el-form-item label="Windows版本" prop="windowsVersion">
|
||||
<el-select v-model="requestForm.windowsVersion" placeholder="请选择Windows版本" style="width: 100%">
|
||||
<el-option label="Windows Server 2019" value="2019" />
|
||||
<el-option label="Windows Server 2022" value="2022" />
|
||||
<el-option label="Windows 10" value="10" />
|
||||
<el-option label="Windows 11" value="11" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="镜像链接" prop="windowsImageUrl">
|
||||
<el-input v-model="requestForm.windowsImageUrl" placeholder="请输入Windows镜像的下载链接" />
|
||||
<div class="form-tip">提供ISO镜像的下载链接,支持微软官方、MSDN等其他合法渠道的镜像</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="激活方式" prop="activationMethod">
|
||||
<el-radio-group v-model="requestForm.activationMethod">
|
||||
<el-radio label="kms">KMS激活</el-radio>
|
||||
<el-radio label="key">产品密钥</el-radio>
|
||||
<el-radio label="none">不需要激活</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<el-form-item label="申请理由" prop="reason">
|
||||
<el-input
|
||||
v-model="requestForm.reason"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="请详细说明申请该镜像的用途和理由"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleDialogClose">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">提交申请</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 查看详情对话框 -->
|
||||
<el-dialog
|
||||
v-model="detailDialogVisible"
|
||||
title="申请详情"
|
||||
width="700px"
|
||||
:before-close="handleDialogClose"
|
||||
>
|
||||
<div v-if="currentRequest.id" class="request-detail">
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="申请ID" :span="2">{{ currentRequest.id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="镜像名称">{{ currentRequest.name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="镜像类型">
|
||||
<el-tag :type="currentRequest.type === 'docker' ? 'success' : 'primary'">
|
||||
{{ currentRequest.type === 'docker' ? 'Docker' : 'Windows' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="申请时间">{{ currentRequest.requestTime }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<el-tag :type="getStatusType(currentRequest.status)">
|
||||
{{ getStatusText(currentRequest.status) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-divider content-position="left">详细信息</el-divider>
|
||||
|
||||
<template v-if="currentRequest.type === 'docker'">
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="Docker镜像地址">
|
||||
{{ currentRequest.dockerSource === 'dockerhub' ? 'Docker Hub: ' : '自定义: ' }}{{ currentRequest.dockerImage }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div v-if="currentRequest.envVars && currentRequest.envVars.length > 0">
|
||||
<el-divider content-position="left">环境变量</el-divider>
|
||||
<el-table :data="currentRequest.envVars" border style="width: 100%">
|
||||
<el-table-column prop="key" label="变量名" />
|
||||
<el-table-column prop="value" label="变量值" />
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="currentRequest.ports && currentRequest.ports.length > 0">
|
||||
<el-divider content-position="left">端口配置</el-divider>
|
||||
<el-table :data="currentRequest.ports" border style="width: 100%">
|
||||
<el-table-column prop="containerPort" label="容器端口" width="120" />
|
||||
<el-table-column prop="protocol" label="协议" width="100" />
|
||||
<el-table-column prop="description" label="描述" />
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="Windows版本">
|
||||
{{ getWindowsVersionText(currentRequest.windowsVersion) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="镜像链接">
|
||||
{{ currentRequest.windowsImageUrl }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="激活方式">
|
||||
{{ getActivationMethodText(currentRequest.activationMethod) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
|
||||
<el-divider content-position="left">申请理由</el-divider>
|
||||
<div class="request-reason">{{ currentRequest.reason }}</div>
|
||||
|
||||
<template v-if="currentRequest.reviewComment">
|
||||
<el-divider content-position="left">审核意见</el-divider>
|
||||
<div class="review-comment">{{ currentRequest.reviewComment }}</div>
|
||||
</template>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import {
|
||||
Plus, Refresh, Search, View, Delete, InfoFilled
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
name: '',
|
||||
type: '',
|
||||
status: ''
|
||||
})
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.name = ''
|
||||
searchForm.type = ''
|
||||
searchForm.status = ''
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 表格数据
|
||||
const loading = ref(false)
|
||||
const tableData = ref([])
|
||||
|
||||
// 分页
|
||||
const pagination = reactive({
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 处理页码变化
|
||||
const handleCurrentChange = (val) => {
|
||||
pagination.currentPage = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 处理每页条数变化
|
||||
const handleSizeChange = (val) => {
|
||||
pagination.pageSize = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 对话框相关
|
||||
const requestDialogVisible = ref(false)
|
||||
const detailDialogVisible = ref(false)
|
||||
const currentRequest = ref({})
|
||||
|
||||
// 表单对象和规则
|
||||
const requestFormRef = ref(null)
|
||||
const requestForm = reactive({
|
||||
type: 'docker',
|
||||
name: '',
|
||||
dockerSource: 'dockerhub',
|
||||
dockerImage: '',
|
||||
windowsVersion: '',
|
||||
windowsImageUrl: '',
|
||||
activationMethod: 'kms',
|
||||
reason: '',
|
||||
envVars: [],
|
||||
ports: []
|
||||
})
|
||||
|
||||
const rules = {
|
||||
type: [{ required: true, message: '请选择镜像类型', trigger: 'change' }],
|
||||
name: [{ required: true, message: '请输入镜像名称', trigger: 'blur' }],
|
||||
dockerImage: [{ required: true, message: '请输入Docker镜像地址', trigger: 'blur' }],
|
||||
windowsVersion: [{ required: true, message: '请选择Windows版本', trigger: 'change' }],
|
||||
windowsImageUrl: [{ required: true, message: '请输入镜像链接', trigger: 'blur' }],
|
||||
activationMethod: [{ required: true, message: '请选择激活方式', trigger: 'change' }],
|
||||
reason: [{ required: true, message: '请输入申请理由', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
// 状态标签样式
|
||||
const getStatusType = (status) => {
|
||||
const map = {
|
||||
approved: 'success',
|
||||
pending: 'warning',
|
||||
rejected: 'danger'
|
||||
}
|
||||
return map[status] || 'info'
|
||||
}
|
||||
|
||||
const getStatusText = (status) => {
|
||||
const map = {
|
||||
approved: '已通过',
|
||||
pending: '审核中',
|
||||
rejected: '已拒绝'
|
||||
}
|
||||
return map[status] || '未知'
|
||||
}
|
||||
|
||||
// Windows版本文本
|
||||
const getWindowsVersionText = (version) => {
|
||||
const map = {
|
||||
'2019': 'Windows Server 2019',
|
||||
'2022': 'Windows Server 2022',
|
||||
'10': 'Windows 10',
|
||||
'11': 'Windows 11'
|
||||
}
|
||||
return map[version] || '未知'
|
||||
}
|
||||
|
||||
// 激活方式文本
|
||||
const getActivationMethodText = (method) => {
|
||||
const map = {
|
||||
kms: 'KMS激活',
|
||||
key: '产品密钥',
|
||||
none: '不需要激活'
|
||||
}
|
||||
return map[method] || '未知'
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
const handleSearch = () => {
|
||||
pagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 刷新数据
|
||||
const handleRefresh = () => {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 添加环境变量
|
||||
const addEnvVar = () => {
|
||||
requestForm.envVars.push({ key: '', value: '' })
|
||||
}
|
||||
|
||||
// 移除环境变量
|
||||
const removeEnvVar = (index) => {
|
||||
requestForm.envVars.splice(index, 1)
|
||||
}
|
||||
|
||||
// 添加端口
|
||||
const addPort = () => {
|
||||
requestForm.ports.push({ containerPort: 80, protocol: 'TCP', description: '' })
|
||||
}
|
||||
|
||||
// 移除端口
|
||||
const removePort = (index) => {
|
||||
requestForm.ports.splice(index, 1)
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
const fetchData = () => {
|
||||
loading.value = true
|
||||
|
||||
// 模拟API请求
|
||||
setTimeout(() => {
|
||||
// 这里应该是真实的API请求
|
||||
const mockData = [
|
||||
{
|
||||
id: 'REQ20240501001',
|
||||
name: 'MySQL 8.0',
|
||||
type: 'docker',
|
||||
requestTime: '2024-05-01 10:23:45',
|
||||
status: 'approved',
|
||||
dockerSource: 'dockerhub',
|
||||
dockerImage: 'mysql:8.0',
|
||||
envVars: [
|
||||
{ key: 'MYSQL_ROOT_PASSWORD', value: 'password' },
|
||||
{ key: 'MYSQL_DATABASE', value: 'testdb' }
|
||||
],
|
||||
ports: [
|
||||
{ containerPort: 3306, protocol: 'TCP', description: 'MySQL默认端口' }
|
||||
],
|
||||
reason: '用于开发测试环境,需要MySQL数据库服务',
|
||||
reviewComment: '审核通过,已添加到镜像列表'
|
||||
},
|
||||
{
|
||||
id: 'REQ20240502001',
|
||||
name: 'Windows Server 2022',
|
||||
type: 'windows',
|
||||
requestTime: '2024-05-02 14:30:12',
|
||||
status: 'pending',
|
||||
windowsVersion: '2022',
|
||||
windowsImageUrl: 'https://example.com/windows-server-2022.iso',
|
||||
activationMethod: 'kms',
|
||||
reason: '用于测试Windows Server 2022的新功能和兼容性'
|
||||
},
|
||||
{
|
||||
id: 'REQ20240503001',
|
||||
name: 'Redis 7.0',
|
||||
type: 'docker',
|
||||
requestTime: '2024-05-03 09:15:36',
|
||||
status: 'rejected',
|
||||
dockerSource: 'dockerhub',
|
||||
dockerImage: 'redis:7.0',
|
||||
envVars: [],
|
||||
ports: [
|
||||
{ containerPort: 6379, protocol: 'TCP', description: 'Redis默认端口' }
|
||||
],
|
||||
reason: '用于缓存服务',
|
||||
reviewComment: '镜像存在安全漏洞,请使用Redis 7.0.2或更高版本'
|
||||
}
|
||||
]
|
||||
|
||||
tableData.value = mockData
|
||||
pagination.total = mockData.length
|
||||
loading.value = false
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 申请镜像
|
||||
const handleAdd = () => {
|
||||
requestForm.type = 'docker'
|
||||
requestForm.name = ''
|
||||
requestForm.dockerSource = 'dockerhub'
|
||||
requestForm.dockerImage = ''
|
||||
requestForm.windowsVersion = ''
|
||||
requestForm.windowsImageUrl = ''
|
||||
requestForm.activationMethod = 'kms'
|
||||
requestForm.reason = ''
|
||||
requestForm.envVars = []
|
||||
requestForm.ports = []
|
||||
requestDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleView = (row) => {
|
||||
currentRequest.value = { ...row }
|
||||
detailDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 重新提交
|
||||
const handleResubmit = (row) => {
|
||||
// 复制原有申请的信息到表单
|
||||
requestForm.type = row.type
|
||||
requestForm.name = row.name
|
||||
|
||||
if (row.type === 'docker') {
|
||||
requestForm.dockerSource = row.dockerSource
|
||||
requestForm.dockerImage = row.dockerImage
|
||||
requestForm.envVars = [...row.envVars]
|
||||
requestForm.ports = [...row.ports]
|
||||
} else {
|
||||
requestForm.windowsVersion = row.windowsVersion
|
||||
requestForm.windowsImageUrl = row.windowsImageUrl
|
||||
requestForm.activationMethod = row.activationMethod
|
||||
}
|
||||
|
||||
requestForm.reason = row.reason
|
||||
requestDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 关闭对话框
|
||||
const handleDialogClose = () => {
|
||||
requestDialogVisible.value = false
|
||||
detailDialogVisible.value = false
|
||||
if (requestFormRef.value) {
|
||||
requestFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = async () => {
|
||||
if (!requestFormRef.value) return
|
||||
|
||||
await requestFormRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success('申请提交成功,请等待审核')
|
||||
requestDialogVisible.value = false
|
||||
fetchData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.image-requests-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.info-alert {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* 表单样式 */
|
||||
.form-tip {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
/* 环境变量配置样式 */
|
||||
.env-vars-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.env-vars-header {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.env-vars-item {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.env-var-name {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.env-var-value {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.env-var-action {
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.add-env-btn {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* 端口配置样式 */
|
||||
.ports-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.ports-header {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ports-item {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.port-container {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.port-protocol {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.port-desc {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.port-action {
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.add-port-btn {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* 详情样式 */
|
||||
.request-detail {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.request-reason {
|
||||
background-color: #f8f8f8;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.review-comment {
|
||||
background-color: #f0f9eb;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
white-space: pre-wrap;
|
||||
border-left: 4px solid #67c23a;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,904 @@
|
||||
<template>
|
||||
<div class="vm-images-container" v-loading="loading">
|
||||
<div class="page-header">
|
||||
<h2>虚拟机镜像</h2>
|
||||
<div class="header-actions">
|
||||
<el-button type="primary" @click="toLoad(selectedServer)" :disabled="!selectedServer">
|
||||
<el-icon><plus /></el-icon>添加镜像
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索区域 -->
|
||||
<el-card class="search-card">
|
||||
<el-form :inline="true" :model="searchForm" class="search-form">
|
||||
<el-form-item label="服务器">
|
||||
<el-select
|
||||
v-model="selectedServer"
|
||||
placeholder="请选择服务器"
|
||||
clearable
|
||||
@change="handleServerChange"
|
||||
style="width: 220px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in serverList"
|
||||
:key="item.server_id"
|
||||
:label="item.name"
|
||||
:value="item.server_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="镜像名称">
|
||||
<el-input v-model="searchForm.name" placeholder="请输入镜像名称" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="操作系统">
|
||||
<el-select v-model="searchForm.os" placeholder="请选择操作系统" clearable>
|
||||
<el-option label="Windows" value="windows" />
|
||||
<el-option label="Ubuntu" value="ubuntu" />
|
||||
<el-option label="CentOS" value="centos" />
|
||||
<el-option label="Debian" value="debian" />
|
||||
<el-option label="其他" value="other" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable>
|
||||
<el-option label="可用" value="available" />
|
||||
<el-option label="创建中" value="creating" />
|
||||
<el-option label="已禁用" value="disabled" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">
|
||||
<el-icon><search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetSearch">
|
||||
<el-icon><refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 镜像列表 -->
|
||||
<el-card class="table-card" v-if="selectedServer">
|
||||
<el-table
|
||||
v-loading="tableLoading"
|
||||
:data="currentImages"
|
||||
border
|
||||
style="width: 100%"
|
||||
row-key="id"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column label="镜像信息" min-width="250">
|
||||
<template #default="scope">
|
||||
<div class="image-info-cell">
|
||||
<img :src="mainUrl + scope.row.image_ico" class="table-image-logo" />
|
||||
<div class="image-info-content">
|
||||
<div class="image-name-row">
|
||||
<span class="table-image-name">{{ scope.row.name }}</span>
|
||||
</div>
|
||||
<div class="image-desc-row">{{ scope.row.description || '暂无描述' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="show_name" label="展示名称" width="120" show-overflow-tooltip />
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStatusType(scope.row.state)">
|
||||
{{ getStatusText(scope.row.state) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="180" align="center" />
|
||||
<el-table-column label="操作" width="250" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
@click="handleCreateVM(scope.row)"
|
||||
v-if="scope.row.state === 1"
|
||||
>
|
||||
<el-icon><monitor /></el-icon>创建虚拟机
|
||||
</el-button>
|
||||
<el-button type="success" link @click="handleEdit(scope.row)">
|
||||
<el-icon><edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button type="danger" link @click="handleDelete(scope.row)">
|
||||
<el-icon><delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="totalCount"
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
@update:current-page="handleCurrentPageChange"
|
||||
@update:page-size="handleSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 未选择服务器时的提示 -->
|
||||
<el-empty
|
||||
v-if="!selectedServer && !loading"
|
||||
description="请选择一个服务器查看镜像列表"
|
||||
class="empty-tip"
|
||||
/>
|
||||
|
||||
<!-- 镜像表单对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="editOr ? '编辑镜像' : '添加镜像'"
|
||||
width="600px"
|
||||
:before-close="handleDialogClose"
|
||||
>
|
||||
<el-form :model="imageForm" label-width="120px" :rules="rules" ref="imageFormRef">
|
||||
<el-form-item label="镜像名称" prop="name">
|
||||
<el-input v-model="imageForm.name" placeholder="请输入镜像名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文件路径" prop="path" v-if="!editOr">
|
||||
<el-input v-model="imageForm.path" placeholder="请输入镜像文件路径" />
|
||||
</el-form-item>
|
||||
<el-form-item label="展示名称" prop="show_name">
|
||||
<el-input v-model="imageForm.show_name" placeholder="请输入展示名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类" prop="class_id" v-if="!editOr">
|
||||
<el-select v-model="imageForm.class_id" placeholder="请选择分类" clearable style="width: 100%">
|
||||
<el-option v-for="item in categoryList" :key="item.class_id" :label="item.name" :value="item.class_id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="图标" prop="image_ico">
|
||||
<div class="image-icon-upload">
|
||||
<img v-if="imageForm.image_ico" :src="mainUrl + imageForm.image_ico" class="preview-icon" />
|
||||
<div class="upload-buttons">
|
||||
<el-button type="primary" @click="$refs.fileInput.click()">选择文件</el-button>
|
||||
<input ref="fileInput" type="file" style="display: none" @change="onFileSelected" />
|
||||
<div class="el-upload__tip" v-if="selectedFileName">
|
||||
已选择: {{ selectedFileName }}
|
||||
</div>
|
||||
<el-button @click="picSwitch = true; getpicList()">从素材库选择</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="套餐" prop="plan_id">
|
||||
<el-select v-model="imageForm.plan_id" placeholder="请选择套餐" style="width: 100%">
|
||||
<el-option v-for="item in planlist" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input
|
||||
v-model="imageForm.description"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入镜像描述"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="getit">一键粘贴内容</el-button>
|
||||
<el-button @click="copyit">一键复制内容</el-button>
|
||||
<el-button @click="handleDialogClose">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确认</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 素材库对话框 -->
|
||||
<el-dialog v-model="picSwitch" title="素材库" width="70%" :before-close="() => picSwitch = false">
|
||||
<div class="pic-search">
|
||||
<el-input
|
||||
v-model="picPagin.key"
|
||||
placeholder="请输入搜索内容"
|
||||
style="width: 300px; margin-bottom: 20px"
|
||||
@blur="getpicList()"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="getpicList()">
|
||||
<el-icon><search /></el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<div class="piclist">
|
||||
<div
|
||||
v-for="(item, index) in picList"
|
||||
:key="index"
|
||||
class="icon"
|
||||
:class="{ choose: currentIndex === index }"
|
||||
@click="selectImage(index, item)"
|
||||
>
|
||||
<img :src="`${mainUrl}/v1/attachment/get_attachment?aid=${item.attachment_id}`" />
|
||||
<div class="tit">{{ item.title ? item.title.slice(0, 8) : '未命名' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pagination-container" style="margin-top: 20px">
|
||||
<el-pagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:current-page="picPagin.page"
|
||||
:page-size="picPagin.count"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
@current-change="CurrentPageChange"
|
||||
@size-change="PageSizeChange"
|
||||
/>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="picSwitch = false">取消</el-button>
|
||||
<el-button type="primary" @click="tochoose">确认选择</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import {
|
||||
Plus, Search, Refresh, Edit, Delete, TurnOff, Open, Monitor
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getServer, getServerPlan } from '@/utils/acs/server'
|
||||
import {
|
||||
editMirror, delMirror, getUserMirrorList, addVirtualMirror, getImageTypeList
|
||||
} from '@/utils/acs/mirror'
|
||||
import { uploadFile, getFileList } from '@/utils/acs/message'
|
||||
import { mainUrl } from '@/utils/request'
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
name: '',
|
||||
os: '',
|
||||
status: ''
|
||||
})
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.name = ''
|
||||
searchForm.os = ''
|
||||
searchForm.status = ''
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 表格数据
|
||||
const loading = ref(false)
|
||||
const tableLoading = ref(false)
|
||||
const serverList = ref([])
|
||||
const selectedServer = ref('')
|
||||
const currentImages = ref([])
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const totalCount = ref(0)
|
||||
|
||||
// 对话框相关
|
||||
const dialogVisible = ref(false)
|
||||
const editOr = ref(false)
|
||||
const selectedFileName = ref(null)
|
||||
const planlist = ref([])
|
||||
const nowserver_id = ref('')
|
||||
|
||||
// 表单对象和规则
|
||||
const imageFormRef = ref(null)
|
||||
const imageForm = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
show_name: '',
|
||||
description: '',
|
||||
server_type: 'hyperV',
|
||||
plan_id: '',
|
||||
image_ico: '',
|
||||
server_id: '',
|
||||
path: '',
|
||||
class_id: ''
|
||||
})
|
||||
|
||||
const rules = {
|
||||
name: [{ required: true, message: '请输入镜像名称', trigger: 'blur' }],
|
||||
path: [{ required: true, message: '请输入镜像文件路径', trigger: 'blur' }],
|
||||
show_name: [{ required: true, message: '请输入展示名称', trigger: 'blur' }],
|
||||
// plan_id: [{ required: true, message: '请选择套餐', trigger: 'change' }]
|
||||
}
|
||||
|
||||
// 素材库相关
|
||||
const picSwitch = ref(false)
|
||||
const picPagin = reactive({
|
||||
count: 50,
|
||||
page: 1,
|
||||
key: '',
|
||||
user_type: 1
|
||||
})
|
||||
const picList = ref([])
|
||||
const total = ref(10)
|
||||
const currentIndex = ref(null)
|
||||
const categoryList = ref([])
|
||||
|
||||
// 获取操作系统图标
|
||||
const getOsIcon = (os) => {
|
||||
const icons = {
|
||||
windows: 'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/windows8/windows8-original.svg',
|
||||
ubuntu: 'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/ubuntu/ubuntu-plain.svg',
|
||||
centos: 'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/redhat/redhat-original.svg',
|
||||
debian: 'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/debian/debian-original.svg',
|
||||
other: 'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/linux/linux-original.svg'
|
||||
}
|
||||
return icons[os] || icons.other
|
||||
}
|
||||
|
||||
// 状态标签样式
|
||||
const getStatusType = (state) => {
|
||||
const map = {
|
||||
0: 'warning',
|
||||
1: 'success',
|
||||
2: 'danger'
|
||||
}
|
||||
return map[state] || 'info'
|
||||
}
|
||||
|
||||
const getStatusText = (state) => {
|
||||
const map = {
|
||||
0: '上传中',
|
||||
1: '可用',
|
||||
2: '上传失败'
|
||||
}
|
||||
return map[state] || '未知'
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
const handleSearch = () => {
|
||||
if (selectedServer.value) {
|
||||
fetchImageList()
|
||||
}
|
||||
}
|
||||
|
||||
// 处理服务器变更
|
||||
const handleServerChange = () => {
|
||||
currentPage.value = 1
|
||||
if (selectedServer.value) {
|
||||
fetchImageList()
|
||||
} else {
|
||||
currentImages.value = []
|
||||
totalCount.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
// 获取服务器列表
|
||||
const fetchServerList = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
const response = await getServer(1, 100, '', 'hyperV')
|
||||
if (response.data.code === 200) {
|
||||
serverList.value = response.data.data || []
|
||||
// 如果有服务器列表且没有选择服务器,默认选择第一个
|
||||
if (serverList.value.length > 0 && !selectedServer.value) {
|
||||
selectedServer.value = serverList.value[0].server_id
|
||||
await fetchImageList()
|
||||
}
|
||||
} else {
|
||||
ElMessage.error('获取服务器列表失败:' + response.data.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取服务器列表出错:', error)
|
||||
ElMessage.error('获取服务器列表出错')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 获取镜像列表
|
||||
const fetchImageList = async () => {
|
||||
if (!selectedServer.value) return
|
||||
|
||||
try {
|
||||
tableLoading.value = true
|
||||
const response = await getUserMirrorList({
|
||||
server_id: selectedServer.value,
|
||||
count: pageSize.value,
|
||||
page: currentPage.value,
|
||||
key: searchForm.name || ''
|
||||
})
|
||||
|
||||
if (response.data.code === 200) {
|
||||
currentImages.value = response.data.data || []
|
||||
totalCount.value = response.data.count || 0
|
||||
} else {
|
||||
ElMessage.error('获取镜像列表失败:' + response.data.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取镜像列表出错:', error)
|
||||
ElMessage.error('获取镜像列表出错')
|
||||
} finally {
|
||||
tableLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 分页相关
|
||||
const handleCurrentPageChange = (newPage) => {
|
||||
currentPage.value = newPage
|
||||
fetchImageList()
|
||||
}
|
||||
|
||||
const handleSizeChange = (newSize) => {
|
||||
pageSize.value = newSize
|
||||
currentPage.value = 1
|
||||
fetchImageList()
|
||||
}
|
||||
|
||||
// 获取镜像分类列表
|
||||
const fetchCategoryList = async (serverId) => {
|
||||
try {
|
||||
const response = await getImageTypeList(serverId)
|
||||
if (response.data.code === 200) {
|
||||
categoryList.value = response.data.data || []
|
||||
} else {
|
||||
ElMessage.error('获取镜像分类失败:' + response.data.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取镜像分类出错:', error)
|
||||
ElMessage.error('获取镜像分类列表失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 新增镜像
|
||||
const toLoad = async (data) => {
|
||||
dialogVisible.value = true
|
||||
editOr.value = false
|
||||
Object.keys(imageForm).forEach(key => {
|
||||
imageForm[key] = ''
|
||||
})
|
||||
imageForm.server_id = data
|
||||
nowserver_id.value = data
|
||||
try {
|
||||
// 获取套餐列表
|
||||
let res = await getServerPlan({ server_id: data })
|
||||
planlist.value = res.data.data.map(item => {
|
||||
return {
|
||||
name: item.name,
|
||||
id: item.plan_id,
|
||||
}
|
||||
})
|
||||
// 获取分类列表
|
||||
await fetchCategoryList(data)
|
||||
} catch (error) {
|
||||
ElMessage.error('获取数据失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 处理文件变更
|
||||
const onFileSelected = (event) => {
|
||||
const file = event.target.files[0]
|
||||
if (file) {
|
||||
selectedFileName.value = file.name
|
||||
uploadFile({ file: file }).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
ElMessage.success('上传成功')
|
||||
selectedFileName.value = null
|
||||
imageForm.image_ico = '/v1/attachment/get_attachment?aid=' + res.data.data.attachment_id
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage.error('上传失败')
|
||||
})
|
||||
} else {
|
||||
selectedFileName.value = null
|
||||
}
|
||||
}
|
||||
|
||||
// 添加镜像
|
||||
const handleAdd = () => {
|
||||
if (!selectedServer.value) {
|
||||
ElMessage.warning('请先选择一个服务器')
|
||||
return
|
||||
}
|
||||
toLoad(selectedServer.value)
|
||||
}
|
||||
|
||||
// 编辑镜像
|
||||
const handleEdit = async (row) => {
|
||||
try {
|
||||
let res = await getServerPlan({ server_id: row.server_id })
|
||||
planlist.value = res.data.data.map(item => {
|
||||
return {
|
||||
name: item.name,
|
||||
id: item.plan_id,
|
||||
}
|
||||
})
|
||||
// 获取分类列表
|
||||
await fetchCategoryList(row.server_id)
|
||||
|
||||
editOr.value = true
|
||||
dialogVisible.value = true
|
||||
for (const key in row) {
|
||||
if (row.hasOwnProperty(key)) {
|
||||
imageForm[key] = row[key]
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('获取数据失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 删除镜像
|
||||
const handleDelete = (row) => {
|
||||
ElMessageBox.confirm(`确定要删除镜像"${row.name}"吗?删除后不可恢复!`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'error'
|
||||
}).then(() => {
|
||||
delMirror({ server_id: row.server_id, image_id: row.id }).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
ElMessage.success('删除成功')
|
||||
fetchImageList()
|
||||
} else {
|
||||
ElMessage.error(res.data.msg || '删除失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage.error('删除失败')
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 创建虚拟机
|
||||
const handleCreateVM = (row) => {
|
||||
ElMessage.success(`正在使用镜像"${row.name}"创建虚拟机,请前往虚拟机管理页面查看`)
|
||||
}
|
||||
|
||||
// 关闭对话框
|
||||
const handleDialogClose = () => {
|
||||
dialogVisible.value = false
|
||||
if (imageFormRef.value) {
|
||||
imageFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = async () => {
|
||||
if (!imageFormRef.value) return
|
||||
|
||||
await imageFormRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
if (editOr.value) {
|
||||
imageForm.image_id = imageForm.id
|
||||
delete imageForm.id
|
||||
editMirror(imageForm).then(res => {
|
||||
if (res.data.code == 200) {
|
||||
dialogVisible.value = false
|
||||
ElMessage.success('编辑成功')
|
||||
fetchImageList()
|
||||
} else {
|
||||
ElMessage.error(res.data.msg || '编辑失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage.error('编辑失败')
|
||||
})
|
||||
} else {
|
||||
addVirtualMirror(imageForm).then(res => {
|
||||
if (res.data.code == 200) {
|
||||
dialogVisible.value = false
|
||||
ElMessage.success('添加成功')
|
||||
fetchImageList()
|
||||
} else {
|
||||
ElMessage.error(res.data.msg || '添加失败')
|
||||
}
|
||||
}).catch((e) => {
|
||||
ElMessage.error('添加失败')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 素材库相关
|
||||
const getpicList = () => {
|
||||
getFileList(picPagin).then(res => {
|
||||
picList.value = res.data.data
|
||||
total.value = res.data.count
|
||||
}).catch(() => {
|
||||
ElMessage.error('获取图片列表失败')
|
||||
})
|
||||
}
|
||||
|
||||
const selectImage = (index, data) => {
|
||||
currentIndex.value = index
|
||||
}
|
||||
|
||||
const CurrentPageChange = async newPage => {
|
||||
picPagin.page = newPage
|
||||
getpicList()
|
||||
}
|
||||
|
||||
const PageSizeChange = async newSize => {
|
||||
picPagin.count = newSize
|
||||
getpicList()
|
||||
}
|
||||
|
||||
const tochoose = () => {
|
||||
if (currentIndex.value != null) {
|
||||
imageForm.image_ico = `/v1/attachment/get_attachment?aid=${picList.value[currentIndex.value].attachment_id}`
|
||||
picSwitch.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 复制粘贴相关
|
||||
const copytext = ref({})
|
||||
const copyit = async () => {
|
||||
copytext.value = JSON.parse(JSON.stringify(imageForm))
|
||||
ElMessage.success('复制成功')
|
||||
await navigator.clipboard.writeText(JSON.stringify(copytext.value))
|
||||
}
|
||||
|
||||
const getit = async () => {
|
||||
try {
|
||||
const text = await navigator.clipboard.readText()
|
||||
Object.keys(JSON.parse(text)).forEach(key => {
|
||||
imageForm[key] = JSON.parse(text)[key]
|
||||
})
|
||||
imageForm.server_id = nowserver_id.value
|
||||
ElMessage.success('粘贴成功')
|
||||
return text
|
||||
} catch (err) {
|
||||
ElMessage.error('无法读取剪贴板内容,请检查获取到的格式')
|
||||
}
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
onMounted(() => {
|
||||
fetchServerList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.vm-images-container {
|
||||
padding: 24px;
|
||||
background-color: #f5f7fa;
|
||||
min-height: calc(100vh - 60px);
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
background: #fff;
|
||||
padding: 16px 24px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.page-header h2 {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
color: #303133;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
margin-bottom: 24px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 24px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.image-info-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.table-image-logo {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 6px;
|
||||
object-fit: contain;
|
||||
background-color: #f5f7fa;
|
||||
border: 1px solid #ebeef5;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.image-info-content {
|
||||
flex: 1;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.image-name-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.table-image-name {
|
||||
font-weight: 600;
|
||||
margin-right: 12px;
|
||||
color: #303133;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.image-desc-row {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 0 16px 16px;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.image-icon-upload {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.preview-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 6px;
|
||||
object-fit: contain;
|
||||
background-color: #f5f7fa;
|
||||
border: 1px solid #ebeef5;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.upload-buttons {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.el-upload__tip {
|
||||
line-height: 1.5;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
/* 素材库样式 */
|
||||
.piclist {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.piclist .icon {
|
||||
width: 100px;
|
||||
height: 110px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #ebeef5;
|
||||
transition: all 0.3s;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.piclist .icon:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
|
||||
.piclist .icon img {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.piclist .icon .tit {
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.piclist .choose {
|
||||
border-color: #409EFF;
|
||||
box-shadow: 0 0 12px rgba(64, 158, 255, 0.6);
|
||||
background-color: #ecf5ff;
|
||||
}
|
||||
|
||||
/* 对话框样式优化 */
|
||||
:deep(.el-dialog__header) {
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__footer) {
|
||||
border-top: 1px solid #ebeef5;
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
background-color: #f5f7fa;
|
||||
color: #606266;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:deep(.el-table__row:hover) {
|
||||
background-color: #ecf5ff !important;
|
||||
}
|
||||
|
||||
:deep(.el-button--link) {
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
:deep(.el-button--link):hover {
|
||||
background-color: #f0f2f5;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* 响应式调整 */
|
||||
@media (max-width: 768px) {
|
||||
.image-info-cell {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.image-info-content {
|
||||
margin-left: 0;
|
||||
margin-top: 12px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.table-image-logo {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -0,0 +1,423 @@
|
||||
<template>
|
||||
<div class="announcements-container">
|
||||
<div class="page-header">
|
||||
<h2>官方公告</h2>
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<el-icon><plus /></el-icon>发布公告
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索区域 -->
|
||||
<el-card class="search-card">
|
||||
<el-form :inline="true" :model="searchForm" class="search-form">
|
||||
<el-form-item label="公告标题">
|
||||
<el-input v-model="searchForm.title" placeholder="请输入公告标题" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="发布时间">
|
||||
<el-date-picker
|
||||
v-model="searchForm.dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable>
|
||||
<el-option label="已发布" value="published" />
|
||||
<el-option label="草稿" value="draft" />
|
||||
<el-option label="已下线" value="offline" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">
|
||||
<el-icon><search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetSearch">
|
||||
<el-icon><refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<el-card class="table-card">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
border
|
||||
style="width: 100%"
|
||||
row-key="id"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="title" label="公告标题" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="publisher" label="发布人" width="120" align="center" />
|
||||
<el-table-column prop="publishTime" label="发布时间" width="180" align="center" />
|
||||
<el-table-column prop="viewCount" label="查看数" width="100" align="center" />
|
||||
<el-table-column prop="status" label="状态" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStatusType(scope.row.status)">
|
||||
{{ getStatusText(scope.row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="220" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" link @click="handleView(scope.row)">
|
||||
<el-icon><view /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button type="primary" link @click="handleEdit(scope.row)">
|
||||
<el-icon><edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
@click="handleChangeStatus(scope.row)"
|
||||
v-if="scope.row.status !== 'offline'"
|
||||
>
|
||||
<el-icon><turn-off /></el-icon>下线
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
@click="handleDelete(scope.row)"
|
||||
v-if="scope.row.status === 'offline'"
|
||||
>
|
||||
<el-icon><delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.currentPage"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="pagination.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 公告详情对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
width="800px"
|
||||
:before-close="handleDialogClose"
|
||||
>
|
||||
<div v-if="dialogType === 'view'" class="announcement-detail">
|
||||
<h2 class="detail-title">{{ currentAnnouncement.title }}</h2>
|
||||
<div class="detail-info">
|
||||
<span>发布人: {{ currentAnnouncement.publisher }}</span>
|
||||
<span>发布时间: {{ currentAnnouncement.publishTime }}</span>
|
||||
<span>状态: {{ getStatusText(currentAnnouncement.status) }}</span>
|
||||
</div>
|
||||
<div class="detail-content" v-html="currentAnnouncement.content"></div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-form :model="announcementForm" label-width="120px" :rules="rules" ref="announcementFormRef">
|
||||
<el-form-item label="公告标题" prop="title">
|
||||
<el-input v-model="announcementForm.title" placeholder="请输入公告标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="公告内容" prop="content">
|
||||
<el-input
|
||||
v-model="announcementForm.content"
|
||||
type="textarea"
|
||||
:rows="10"
|
||||
placeholder="请输入公告内容"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="announcementForm.status">
|
||||
<el-radio label="published">立即发布</el-radio>
|
||||
<el-radio label="draft">保存为草稿</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer" v-if="dialogType !== 'view'">
|
||||
<el-button @click="handleDialogClose">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确认</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import {
|
||||
Plus, Search, Refresh, View, Edit, TurnOff, Delete
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
title: '',
|
||||
dateRange: [],
|
||||
status: ''
|
||||
})
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.title = ''
|
||||
searchForm.dateRange = []
|
||||
searchForm.status = ''
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 表格数据
|
||||
const loading = ref(false)
|
||||
const tableData = ref([])
|
||||
|
||||
// 分页
|
||||
const pagination = reactive({
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 处理页码变化
|
||||
const handleCurrentChange = (val) => {
|
||||
pagination.currentPage = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 处理每页条数变化
|
||||
const handleSizeChange = (val) => {
|
||||
pagination.pageSize = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 对话框相关
|
||||
const dialogVisible = ref(false)
|
||||
const dialogType = ref('') // 'add', 'edit', 'view'
|
||||
const dialogTitle = computed(() => {
|
||||
if (dialogType.value === 'add') return '发布公告'
|
||||
if (dialogType.value === 'edit') return '编辑公告'
|
||||
return '公告详情'
|
||||
})
|
||||
|
||||
// 当前选中的公告
|
||||
const currentAnnouncement = ref({})
|
||||
|
||||
// 表单对象和规则
|
||||
const announcementFormRef = ref(null)
|
||||
const announcementForm = reactive({
|
||||
id: '',
|
||||
title: '',
|
||||
content: '',
|
||||
status: 'published'
|
||||
})
|
||||
|
||||
const rules = {
|
||||
title: [{ required: true, message: '请输入公告标题', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '请输入公告内容', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||
}
|
||||
|
||||
// 状态标签样式
|
||||
const getStatusType = (status) => {
|
||||
const map = {
|
||||
published: 'success',
|
||||
draft: 'info',
|
||||
offline: 'danger'
|
||||
}
|
||||
return map[status] || 'info'
|
||||
}
|
||||
|
||||
const getStatusText = (status) => {
|
||||
const map = {
|
||||
published: '已发布',
|
||||
draft: '草稿',
|
||||
offline: '已下线'
|
||||
}
|
||||
return map[status] || '未知'
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
const handleSearch = () => {
|
||||
pagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
const fetchData = () => {
|
||||
loading.value = true
|
||||
|
||||
// 模拟API请求
|
||||
setTimeout(() => {
|
||||
// 这里应该是真实的API请求
|
||||
const mockData = []
|
||||
for (let i = 0; i < pagination.pageSize; i++) {
|
||||
const id = (pagination.currentPage - 1) * pagination.pageSize + i + 1
|
||||
if (id > 35) break // 模拟总数
|
||||
|
||||
mockData.push({
|
||||
id: `announcement-${id}`,
|
||||
title: `关于云服务平台升级维护的公告 ${id}`,
|
||||
publisher: '系统管理员',
|
||||
publishTime: '2023-10-15 08:30:00',
|
||||
viewCount: Math.floor(Math.random() * 1000),
|
||||
status: ['published', 'draft', 'offline'][Math.floor(Math.random() * 3)],
|
||||
content: `<p>尊敬的用户:</p>
|
||||
<p>为了提供更好的服务体验,我们的云服务平台将于2023年10月20日凌晨2:00-6:00进行系统升级维护。</p>
|
||||
<p>维护期间,部分功能可能暂时无法使用,给您带来的不便敬请谅解。</p>
|
||||
<p>感谢您的理解与支持!</p>`
|
||||
})
|
||||
}
|
||||
|
||||
tableData.value = mockData
|
||||
pagination.total = 35
|
||||
loading.value = false
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 添加公告
|
||||
const handleAdd = () => {
|
||||
dialogType.value = 'add'
|
||||
dialogVisible.value = true
|
||||
announcementForm.id = ''
|
||||
announcementForm.title = ''
|
||||
announcementForm.content = ''
|
||||
announcementForm.status = 'published'
|
||||
}
|
||||
|
||||
// 查看公告
|
||||
const handleView = (row) => {
|
||||
dialogType.value = 'view'
|
||||
dialogVisible.value = true
|
||||
currentAnnouncement.value = { ...row }
|
||||
}
|
||||
|
||||
// 编辑公告
|
||||
const handleEdit = (row) => {
|
||||
dialogType.value = 'edit'
|
||||
dialogVisible.value = true
|
||||
announcementForm.id = row.id
|
||||
announcementForm.title = row.title
|
||||
announcementForm.content = row.content
|
||||
announcementForm.status = row.status
|
||||
}
|
||||
|
||||
// 更改公告状态(下线)
|
||||
const handleChangeStatus = (row) => {
|
||||
ElMessageBox.confirm(`确定要下线"${row.title}"吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success('操作成功')
|
||||
fetchData()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 删除公告
|
||||
const handleDelete = (row) => {
|
||||
ElMessageBox.confirm(`确定要删除"${row.title}"吗?删除后不可恢复!`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'error'
|
||||
}).then(() => {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success('删除成功')
|
||||
fetchData()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 关闭对话框
|
||||
const handleDialogClose = () => {
|
||||
dialogVisible.value = false
|
||||
if (announcementFormRef.value) {
|
||||
announcementFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = async () => {
|
||||
if (!announcementFormRef.value) return
|
||||
|
||||
await announcementFormRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success(dialogType.value === 'add' ? '发布成功' : '更新成功')
|
||||
dialogVisible.value = false
|
||||
fetchData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.announcements-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* 公告详情样式 */
|
||||
.announcement-detail {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
font-size: 22px;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.detail-info {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
color: #909399;
|
||||
margin-bottom: 30px;
|
||||
font-size: 14px;
|
||||
border-bottom: 1px solid #EBEEF5;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
line-height: 1.8;
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,490 @@
|
||||
<template>
|
||||
<div class="news-container">
|
||||
<div class="page-header">
|
||||
<h2>新闻咨询</h2>
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<el-icon><plus /></el-icon>发布新闻
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索区域 -->
|
||||
<el-card class="search-card">
|
||||
<el-form :inline="true" :model="searchForm" class="search-form">
|
||||
<el-form-item label="新闻标题">
|
||||
<el-input v-model="searchForm.title" placeholder="请输入新闻标题" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="新闻分类">
|
||||
<el-select v-model="searchForm.category" placeholder="请选择分类" clearable>
|
||||
<el-option label="产品动态" value="product" />
|
||||
<el-option label="技术干货" value="technology" />
|
||||
<el-option label="行业资讯" value="industry" />
|
||||
<el-option label="活动公告" value="activity" />
|
||||
<el-option label="其他" value="other" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发布时间">
|
||||
<el-date-picker
|
||||
v-model="searchForm.dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">
|
||||
<el-icon><search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetSearch">
|
||||
<el-icon><refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 新闻列表卡片 -->
|
||||
<div v-loading="loading" class="news-list">
|
||||
<el-card class="table-card">
|
||||
<el-table
|
||||
:data="newsData"
|
||||
border
|
||||
style="width: 100%"
|
||||
row-key="id"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="title" label="新闻标题" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="category" label="新闻分类" width="120" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getCategoryType(scope.row.category)">
|
||||
{{ getCategoryText(scope.row.category) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="author" label="作者" width="150" align="center" />
|
||||
<el-table-column prop="publishTime" label="发布时间" width="120" align="center" />
|
||||
<el-table-column prop="viewCount" label="阅读量" width="100" align="center" />
|
||||
<el-table-column label="操作" width="220" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" link @click="handleView(scope.row)">
|
||||
<el-icon><view /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button type="primary" link @click="handleEdit(scope.row)">
|
||||
<el-icon><edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button type="danger" link @click="handleDelete(scope.row)">
|
||||
<el-icon><delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.currentPage"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="pagination.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<!-- 新闻详情对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
width="800px"
|
||||
:before-close="handleDialogClose"
|
||||
>
|
||||
<div v-if="dialogType === 'view'" class="news-detail">
|
||||
<h2 class="detail-title">{{ currentNews.title }}</h2>
|
||||
<div class="detail-info">
|
||||
<span>
|
||||
<el-tag :type="getCategoryType(currentNews.category)" size="small">
|
||||
{{ getCategoryText(currentNews.category) }}
|
||||
</el-tag>
|
||||
</span>
|
||||
<span><el-icon><user /></el-icon> {{ currentNews.author }}</span>
|
||||
<span><el-icon><calendar /></el-icon> {{ currentNews.publishTime }}</span>
|
||||
<span><el-icon><view /></el-icon> {{ currentNews.viewCount }} 次阅读</span>
|
||||
</div>
|
||||
<el-image class="detail-cover" :src="currentNews.coverImage" fit="cover" />
|
||||
<div class="detail-content" v-html="currentNews.content"></div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-form :model="newsForm" label-width="120px" :rules="rules" ref="newsFormRef">
|
||||
<el-form-item label="新闻标题" prop="title">
|
||||
<el-input v-model="newsForm.title" placeholder="请输入新闻标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="新闻分类" prop="category">
|
||||
<el-select v-model="newsForm.category" placeholder="请选择分类" style="width: 100%">
|
||||
<el-option label="产品动态" value="product" />
|
||||
<el-option label="技术干货" value="technology" />
|
||||
<el-option label="行业资讯" value="industry" />
|
||||
<el-option label="活动公告" value="activity" />
|
||||
<el-option label="其他" value="other" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="封面图片" prop="coverImage">
|
||||
<el-input v-model="newsForm.coverImage" placeholder="请输入图片URL" />
|
||||
<div class="upload-tip">
|
||||
<el-icon><info-filled /></el-icon> 实际使用时应为图片上传组件
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="简介摘要" prop="summary">
|
||||
<el-input
|
||||
v-model="newsForm.summary"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入新闻简介(100字以内)"
|
||||
maxlength="100"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新闻内容" prop="content">
|
||||
<el-input
|
||||
v-model="newsForm.content"
|
||||
type="textarea"
|
||||
:rows="8"
|
||||
placeholder="请输入新闻正文内容"
|
||||
/>
|
||||
<div class="upload-tip">
|
||||
<el-icon><info-filled /></el-icon> 实际使用时应为富文本编辑器
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer" v-if="dialogType !== 'view'">
|
||||
<el-button @click="handleDialogClose">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确认</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import {
|
||||
Plus, Search, Refresh, View, Edit, Delete,
|
||||
User, Calendar, Picture, InfoFilled
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
title: '',
|
||||
category: '',
|
||||
dateRange: []
|
||||
})
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.title = ''
|
||||
searchForm.category = ''
|
||||
searchForm.dateRange = []
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 新闻数据
|
||||
const loading = ref(false)
|
||||
const newsData = ref([])
|
||||
|
||||
// 分页
|
||||
const pagination = reactive({
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 处理页码变化
|
||||
const handleCurrentChange = (val) => {
|
||||
pagination.currentPage = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 处理每页条数变化
|
||||
const handleSizeChange = (val) => {
|
||||
pagination.pageSize = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 对话框相关
|
||||
const dialogVisible = ref(false)
|
||||
const dialogType = ref('') // 'add', 'edit', 'view'
|
||||
const dialogTitle = computed(() => {
|
||||
if (dialogType.value === 'add') return '发布新闻'
|
||||
if (dialogType.value === 'edit') return '编辑新闻'
|
||||
return '新闻详情'
|
||||
})
|
||||
|
||||
// 当前选中的新闻
|
||||
const currentNews = ref({})
|
||||
|
||||
// 表单对象和规则
|
||||
const newsFormRef = ref(null)
|
||||
const newsForm = reactive({
|
||||
id: '',
|
||||
title: '',
|
||||
category: '',
|
||||
coverImage: '',
|
||||
summary: '',
|
||||
content: ''
|
||||
})
|
||||
|
||||
const rules = {
|
||||
title: [{ required: true, message: '请输入新闻标题', trigger: 'blur' }],
|
||||
category: [{ required: true, message: '请选择新闻分类', trigger: 'change' }],
|
||||
coverImage: [{ required: true, message: '请输入封面图片URL', trigger: 'blur' }],
|
||||
summary: [{ required: true, message: '请输入新闻简介', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '请输入新闻内容', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
// 新闻分类标签
|
||||
const getCategoryType = (category) => {
|
||||
const map = {
|
||||
product: 'primary',
|
||||
technology: 'success',
|
||||
industry: 'info',
|
||||
activity: 'warning',
|
||||
other: ''
|
||||
}
|
||||
return map[category] || ''
|
||||
}
|
||||
|
||||
const getCategoryText = (category) => {
|
||||
const map = {
|
||||
product: '产品动态',
|
||||
technology: '技术干货',
|
||||
industry: '行业资讯',
|
||||
activity: '活动公告',
|
||||
other: '其他'
|
||||
}
|
||||
return map[category] || '未知'
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
const handleSearch = () => {
|
||||
pagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
const fetchData = () => {
|
||||
loading.value = true
|
||||
|
||||
// 模拟API请求
|
||||
setTimeout(() => {
|
||||
// 这里应该是真实的API请求
|
||||
const mockData = []
|
||||
const categories = ['product', 'technology', 'industry', 'activity', 'other']
|
||||
|
||||
for (let i = 0; i < pagination.pageSize; i++) {
|
||||
const id = (pagination.currentPage - 1) * pagination.pageSize + i + 1
|
||||
if (id > 32) break // 模拟总数
|
||||
|
||||
const category = categories[Math.floor(Math.random() * categories.length)]
|
||||
|
||||
mockData.push({
|
||||
id: `news-${id}`,
|
||||
title: `零零七云计算平台${getCategoryText(category)}新闻 ${id}`,
|
||||
category,
|
||||
author: '零零七云计算小编',
|
||||
publishTime: '2023-10-12',
|
||||
viewCount: Math.floor(Math.random() * 1000),
|
||||
coverImage: `https://picsum.photos/id/${id + 30}/800/400`,
|
||||
summary: '零零七云计算平台重磅升级,新增多项功能特性,提供更优质的云服务体验。本次升级包含计算资源优化、存储系统升级、网络性能提升等多方面改进。',
|
||||
content: `<p>尊敬的用户:</p>
|
||||
<p>我们很高兴地宣布,零零七云计算平台已完成重大升级,带来全新的用户体验和技术改进。</p>
|
||||
<h3>一、主要升级内容</h3>
|
||||
<ol>
|
||||
<li>计算资源全面升级,性能提升30%</li>
|
||||
<li>存储系统架构优化,读写速度大幅提升</li>
|
||||
<li>网络架构重构,带宽翻倍,延迟降低</li>
|
||||
<li>控制台界面优化,操作更加便捷</li>
|
||||
<li>API接口全面升级,兼容性更好</li>
|
||||
</ol>
|
||||
<h3>二、升级优势</h3>
|
||||
<p>本次升级将为您带来更稳定、高效的云服务体验。我们的技术团队持续致力于提供业界领先的云计算解决方案。</p>
|
||||
<h3>三、后续计划</h3>
|
||||
<p>我们将继续投入研发,计划在年底前推出更多创新功能,敬请期待!</p>
|
||||
<p>感谢您一直以来对零零七云计算的支持与信任!</p>`
|
||||
})
|
||||
}
|
||||
|
||||
newsData.value = mockData
|
||||
pagination.total = 32
|
||||
loading.value = false
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 添加新闻
|
||||
const handleAdd = () => {
|
||||
dialogType.value = 'add'
|
||||
dialogVisible.value = true
|
||||
newsForm.id = ''
|
||||
newsForm.title = ''
|
||||
newsForm.category = ''
|
||||
newsForm.coverImage = ''
|
||||
newsForm.summary = ''
|
||||
newsForm.content = ''
|
||||
}
|
||||
|
||||
// 查看新闻
|
||||
const handleView = (row) => {
|
||||
dialogType.value = 'view'
|
||||
dialogVisible.value = true
|
||||
currentNews.value = { ...row }
|
||||
}
|
||||
|
||||
// 编辑新闻
|
||||
const handleEdit = (row) => {
|
||||
dialogType.value = 'edit'
|
||||
dialogVisible.value = true
|
||||
newsForm.id = row.id
|
||||
newsForm.title = row.title
|
||||
newsForm.category = row.category
|
||||
newsForm.coverImage = row.coverImage
|
||||
newsForm.summary = row.summary
|
||||
newsForm.content = row.content
|
||||
}
|
||||
|
||||
// 删除新闻
|
||||
const handleDelete = (row) => {
|
||||
ElMessageBox.confirm(`确定要删除"${row.title}"吗?删除后不可恢复!`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'error'
|
||||
}).then(() => {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success('删除成功')
|
||||
fetchData()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 关闭对话框
|
||||
const handleDialogClose = () => {
|
||||
dialogVisible.value = false
|
||||
if (newsFormRef.value) {
|
||||
newsFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = async () => {
|
||||
if (!newsFormRef.value) return
|
||||
|
||||
await newsFormRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success(dialogType.value === 'add' ? '发布成功' : '更新成功')
|
||||
dialogVisible.value = false
|
||||
fetchData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.news-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.news-list {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* 新闻详情样式 */
|
||||
.news-detail {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
font-size: 22px;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.detail-info {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
color: #909399;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.detail-info span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
.detail-info .el-icon {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.detail-cover {
|
||||
width: 100%;
|
||||
max-height: 400px;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
line-height: 1.8;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
margin-top: 5px;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.upload-tip .el-icon {
|
||||
margin-right: 5px;
|
||||
color: #E6A23C;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,498 @@
|
||||
<template>
|
||||
<div class="policies-container">
|
||||
<div class="page-header">
|
||||
<h2>官方政策</h2>
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<el-icon><plus /></el-icon>发布政策
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索区域 -->
|
||||
<el-card class="search-card">
|
||||
<el-form :inline="true" :model="searchForm" class="search-form">
|
||||
<el-form-item label="政策标题">
|
||||
<el-input v-model="searchForm.title" placeholder="请输入政策标题" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="政策类型">
|
||||
<el-select v-model="searchForm.type" placeholder="请选择政策类型" clearable>
|
||||
<el-option label="服务条款" value="terms" />
|
||||
<el-option label="定价政策" value="pricing" />
|
||||
<el-option label="隐私政策" value="privacy" />
|
||||
<el-option label="合规政策" value="compliance" />
|
||||
<el-option label="其他" value="other" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发布时间">
|
||||
<el-date-picker
|
||||
v-model="searchForm.dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">
|
||||
<el-icon><search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetSearch">
|
||||
<el-icon><refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<el-card class="table-card">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
border
|
||||
style="width: 100%"
|
||||
row-key="id"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="title" label="政策标题" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="type" label="政策类型" width="120" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getPolicyTypeTag(scope.row.type)">
|
||||
{{ getPolicyTypeText(scope.row.type) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="publisher" label="发布人" width="120" align="center" />
|
||||
<el-table-column prop="publishTime" label="发布时间" width="180" align="center" />
|
||||
<el-table-column prop="effectiveTime" label="生效时间" width="180" align="center" />
|
||||
<el-table-column prop="status" label="状态" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStatusType(scope.row.status)">
|
||||
{{ getStatusText(scope.row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="220" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" link @click="handleView(scope.row)">
|
||||
<el-icon><view /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button type="primary" link @click="handleEdit(scope.row)">
|
||||
<el-icon><edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
@click="handleChangeStatus(scope.row)"
|
||||
v-if="scope.row.status === 'active'"
|
||||
>
|
||||
<el-icon><turn-off /></el-icon>下线
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
@click="handleDelete(scope.row)"
|
||||
v-if="scope.row.status === 'inactive'"
|
||||
>
|
||||
<el-icon><delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.currentPage"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="pagination.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 政策详情对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
width="800px"
|
||||
:before-close="handleDialogClose"
|
||||
>
|
||||
<div v-if="dialogType === 'view'" class="policy-detail">
|
||||
<h2 class="detail-title">{{ currentPolicy.title }}</h2>
|
||||
<div class="detail-info">
|
||||
<span>类型: {{ getPolicyTypeText(currentPolicy.type) }}</span>
|
||||
<span>发布人: {{ currentPolicy.publisher }}</span>
|
||||
<span>发布时间: {{ currentPolicy.publishTime }}</span>
|
||||
<span>生效时间: {{ currentPolicy.effectiveTime }}</span>
|
||||
<span>状态: {{ getStatusText(currentPolicy.status) }}</span>
|
||||
</div>
|
||||
<div class="detail-content" v-html="currentPolicy.content"></div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-form :model="policyForm" label-width="120px" :rules="rules" ref="policyFormRef">
|
||||
<el-form-item label="政策标题" prop="title">
|
||||
<el-input v-model="policyForm.title" placeholder="请输入政策标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="政策类型" prop="type">
|
||||
<el-select v-model="policyForm.type" placeholder="请选择政策类型" style="width: 100%">
|
||||
<el-option label="服务条款" value="terms" />
|
||||
<el-option label="定价政策" value="pricing" />
|
||||
<el-option label="隐私政策" value="privacy" />
|
||||
<el-option label="合规政策" value="compliance" />
|
||||
<el-option label="其他" value="other" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="生效时间" prop="effectiveTime">
|
||||
<el-date-picker
|
||||
v-model="policyForm.effectiveTime"
|
||||
type="datetime"
|
||||
placeholder="选择生效时间"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="政策内容" prop="content">
|
||||
<el-input
|
||||
v-model="policyForm.content"
|
||||
type="textarea"
|
||||
:rows="10"
|
||||
placeholder="请输入政策内容"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="policyForm.status">
|
||||
<el-radio label="active">立即生效</el-radio>
|
||||
<el-radio label="pending">计划中</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer" v-if="dialogType !== 'view'">
|
||||
<el-button @click="handleDialogClose">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确认</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import {
|
||||
Plus, Search, Refresh, View, Edit, TurnOff, Delete
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
title: '',
|
||||
type: '',
|
||||
dateRange: []
|
||||
})
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.title = ''
|
||||
searchForm.type = ''
|
||||
searchForm.dateRange = []
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 表格数据
|
||||
const loading = ref(false)
|
||||
const tableData = ref([])
|
||||
|
||||
// 分页
|
||||
const pagination = reactive({
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 处理页码变化
|
||||
const handleCurrentChange = (val) => {
|
||||
pagination.currentPage = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 处理每页条数变化
|
||||
const handleSizeChange = (val) => {
|
||||
pagination.pageSize = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 对话框相关
|
||||
const dialogVisible = ref(false)
|
||||
const dialogType = ref('') // 'add', 'edit', 'view'
|
||||
const dialogTitle = computed(() => {
|
||||
if (dialogType.value === 'add') return '发布政策'
|
||||
if (dialogType.value === 'edit') return '编辑政策'
|
||||
return '政策详情'
|
||||
})
|
||||
|
||||
// 当前选中的政策
|
||||
const currentPolicy = ref({})
|
||||
|
||||
// 表单对象和规则
|
||||
const policyFormRef = ref(null)
|
||||
const policyForm = reactive({
|
||||
id: '',
|
||||
title: '',
|
||||
type: '',
|
||||
effectiveTime: '',
|
||||
content: '',
|
||||
status: 'active'
|
||||
})
|
||||
|
||||
const rules = {
|
||||
title: [{ required: true, message: '请输入政策标题', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '请选择政策类型', trigger: 'change' }],
|
||||
effectiveTime: [{ required: true, message: '请选择生效时间', trigger: 'change' }],
|
||||
content: [{ required: true, message: '请输入政策内容', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||
}
|
||||
|
||||
// 政策类型标签
|
||||
const getPolicyTypeTag = (type) => {
|
||||
const map = {
|
||||
terms: '',
|
||||
pricing: 'success',
|
||||
privacy: 'warning',
|
||||
compliance: 'danger',
|
||||
other: 'info'
|
||||
}
|
||||
return map[type] || 'info'
|
||||
}
|
||||
|
||||
const getPolicyTypeText = (type) => {
|
||||
const map = {
|
||||
terms: '服务条款',
|
||||
pricing: '定价政策',
|
||||
privacy: '隐私政策',
|
||||
compliance: '合规政策',
|
||||
other: '其他'
|
||||
}
|
||||
return map[type] || '未知'
|
||||
}
|
||||
|
||||
// 状态标签样式
|
||||
const getStatusType = (status) => {
|
||||
const map = {
|
||||
active: 'success',
|
||||
pending: 'warning',
|
||||
inactive: 'info'
|
||||
}
|
||||
return map[status] || 'info'
|
||||
}
|
||||
|
||||
const getStatusText = (status) => {
|
||||
const map = {
|
||||
active: '已生效',
|
||||
pending: '计划中',
|
||||
inactive: '已下线'
|
||||
}
|
||||
return map[status] || '未知'
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
const handleSearch = () => {
|
||||
pagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
const fetchData = () => {
|
||||
loading.value = true
|
||||
|
||||
// 模拟API请求
|
||||
setTimeout(() => {
|
||||
// 这里应该是真实的API请求
|
||||
const mockData = []
|
||||
const types = ['terms', 'pricing', 'privacy', 'compliance', 'other']
|
||||
const statuses = ['active', 'pending', 'inactive']
|
||||
|
||||
for (let i = 0; i < pagination.pageSize; i++) {
|
||||
const id = (pagination.currentPage - 1) * pagination.pageSize + i + 1
|
||||
if (id > 28) break // 模拟总数
|
||||
|
||||
const type = types[Math.floor(Math.random() * types.length)]
|
||||
const status = statuses[Math.floor(Math.random() * statuses.length)]
|
||||
|
||||
mockData.push({
|
||||
id: `policy-${id}`,
|
||||
title: `云平台${getPolicyTypeText(type)}(${id})`,
|
||||
type,
|
||||
publisher: '系统管理员',
|
||||
publishTime: '2023-09-30 14:00:00',
|
||||
effectiveTime: '2023-10-01 00:00:00',
|
||||
status,
|
||||
content: `<p><strong>第一条:总则</strong></p>
|
||||
<p>本政策适用于零零七云平台所有用户,请您仔细阅读并理解本政策的所有内容。</p>
|
||||
<p><strong>第二条:服务内容</strong></p>
|
||||
<p>本平台提供云计算、存储和网络等基础设施服务,以及相关的技术支持和咨询服务。</p>
|
||||
<p><strong>第三条:用户权利与义务</strong></p>
|
||||
<p>用户在使用本平台服务时,应当遵守中华人民共和国法律法规和平台规则,不得利用平台服务从事违法活动。</p>`
|
||||
})
|
||||
}
|
||||
|
||||
tableData.value = mockData
|
||||
pagination.total = 28
|
||||
loading.value = false
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 添加政策
|
||||
const handleAdd = () => {
|
||||
dialogType.value = 'add'
|
||||
dialogVisible.value = true
|
||||
policyForm.id = ''
|
||||
policyForm.title = ''
|
||||
policyForm.type = ''
|
||||
policyForm.effectiveTime = ''
|
||||
policyForm.content = ''
|
||||
policyForm.status = 'active'
|
||||
}
|
||||
|
||||
// 查看政策
|
||||
const handleView = (row) => {
|
||||
dialogType.value = 'view'
|
||||
dialogVisible.value = true
|
||||
currentPolicy.value = { ...row }
|
||||
}
|
||||
|
||||
// 编辑政策
|
||||
const handleEdit = (row) => {
|
||||
dialogType.value = 'edit'
|
||||
dialogVisible.value = true
|
||||
policyForm.id = row.id
|
||||
policyForm.title = row.title
|
||||
policyForm.type = row.type
|
||||
policyForm.effectiveTime = row.effectiveTime
|
||||
policyForm.content = row.content
|
||||
policyForm.status = row.status
|
||||
}
|
||||
|
||||
// 更改政策状态(下线)
|
||||
const handleChangeStatus = (row) => {
|
||||
ElMessageBox.confirm(`确定要下线"${row.title}"吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success('操作成功')
|
||||
fetchData()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 删除政策
|
||||
const handleDelete = (row) => {
|
||||
ElMessageBox.confirm(`确定要删除"${row.title}"吗?删除后不可恢复!`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'error'
|
||||
}).then(() => {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success('删除成功')
|
||||
fetchData()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 关闭对话框
|
||||
const handleDialogClose = () => {
|
||||
dialogVisible.value = false
|
||||
if (policyFormRef.value) {
|
||||
policyFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = async () => {
|
||||
if (!policyFormRef.value) return
|
||||
|
||||
await policyFormRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
// 这里应该是API请求
|
||||
ElMessage.success(dialogType.value === 'add' ? '发布成功' : '更新成功')
|
||||
dialogVisible.value = false
|
||||
fetchData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.policies-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.table-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* 政策详情样式 */
|
||||
.policy-detail {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
font-size: 22px;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.detail-info {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-around;
|
||||
color: #909399;
|
||||
margin-bottom: 30px;
|
||||
font-size: 14px;
|
||||
border-bottom: 1px solid #EBEEF5;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.detail-info span {
|
||||
margin: 5px 10px;
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
line-height: 1.8;
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,314 @@
|
||||
<template>
|
||||
<div class="vm-list-container">
|
||||
<div class="filter-section">
|
||||
<el-input
|
||||
v-model="searchKey"
|
||||
placeholder="输入关键字搜索"
|
||||
style="width: 200px; margin-right: 10px;"
|
||||
clearable
|
||||
@input="handleSearch"
|
||||
/>
|
||||
<el-button type="primary" @click="handleSearch">
|
||||
<el-icon><search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetSearch">
|
||||
<el-icon><refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="vmList"
|
||||
style="width: 100%"
|
||||
border
|
||||
>
|
||||
<el-table-column prop="instance_id" label="ID" width="100" />
|
||||
<el-table-column prop="name" label="名称" />
|
||||
<el-table-column prop="user_id" label="用户ID" width="100" />
|
||||
<el-table-column label="创建时间" width="180">
|
||||
<template #default="scope">
|
||||
{{ scope.row.created_at }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="到期时间" width="180">
|
||||
<template #default="scope">
|
||||
{{ scope.row.become_time }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStatusType(scope.row.state)">
|
||||
{{ getStatusText(scope.row.state) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="250" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click="handleManage(scope.row)"
|
||||
>
|
||||
<el-icon><menu /></el-icon>管理
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
link
|
||||
size="small"
|
||||
@click="handleStart(scope.row)"
|
||||
:disabled="scope.row.state === 'running'"
|
||||
>
|
||||
<el-icon><video-play /></el-icon>启动
|
||||
</el-button>
|
||||
<el-button
|
||||
type="warning"
|
||||
link
|
||||
size="small"
|
||||
@click="handleStop(scope.row)"
|
||||
:disabled="scope.row.state === 'stopped'"
|
||||
>
|
||||
<el-icon><video-pause /></el-icon>停止
|
||||
</el-button>
|
||||
<el-button
|
||||
type="info"
|
||||
link
|
||||
size="small"
|
||||
@click="handleRestart(scope.row)"
|
||||
:disabled="scope.row.state !== 'running'"
|
||||
>
|
||||
<el-icon><refresh-right /></el-icon>重启
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, defineProps, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
Search, Refresh, Menu, VideoPlay, VideoPause, RefreshRight
|
||||
} from '@element-plus/icons-vue';
|
||||
import {
|
||||
getContainer,
|
||||
startInstance,
|
||||
stopInstance,
|
||||
restartInstance
|
||||
} from '@/utils/acs/server';
|
||||
|
||||
const props = defineProps({
|
||||
ID: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const loading = ref(false);
|
||||
const vmList = ref([]);
|
||||
const total = ref(0);
|
||||
const currentPage = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const searchKey = ref('');
|
||||
|
||||
// 获取虚拟机列表
|
||||
const fetchVmList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const response = await getContainer({
|
||||
server_id: props.ID,
|
||||
page: currentPage.value,
|
||||
count: pageSize.value,
|
||||
key: searchKey.value,
|
||||
user_id: ''
|
||||
});
|
||||
|
||||
if (response && response.data && response.data.code === 200) {
|
||||
vmList.value = response.data.data || [];
|
||||
total.value = response.data.count || 0;
|
||||
} else {
|
||||
ElMessage.error('获取虚拟机列表失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取虚拟机列表出错:', error);
|
||||
ElMessage.error('获取虚拟机列表出错');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 获取状态类型
|
||||
const getStatusType = (state) => {
|
||||
switch (state) {
|
||||
case 'running':
|
||||
return 'success';
|
||||
case 'stopped':
|
||||
return 'danger';
|
||||
case 'paused':
|
||||
return 'warning';
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
};
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (state) => {
|
||||
switch (state) {
|
||||
case 'running':
|
||||
return '运行中';
|
||||
case 'stopped':
|
||||
return '已停止';
|
||||
case 'paused':
|
||||
return '已暂停';
|
||||
case 'creating':
|
||||
return '创建中';
|
||||
case 'error':
|
||||
return '错误';
|
||||
default:
|
||||
return '未知';
|
||||
}
|
||||
};
|
||||
|
||||
// 处理搜索
|
||||
const handleSearch = () => {
|
||||
currentPage.value = 1;
|
||||
fetchVmList();
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchKey.value = '';
|
||||
currentPage.value = 1;
|
||||
fetchVmList();
|
||||
};
|
||||
|
||||
// 处理页码变化
|
||||
const handleCurrentChange = (val) => {
|
||||
currentPage.value = val;
|
||||
fetchVmList();
|
||||
};
|
||||
|
||||
// 处理每页条数变化
|
||||
const handleSizeChange = (val) => {
|
||||
pageSize.value = val;
|
||||
currentPage.value = 1;
|
||||
fetchVmList();
|
||||
};
|
||||
|
||||
// 管理虚拟机
|
||||
const handleManage = (row) => {
|
||||
router.push(`/servers/vm?instance_id=${row.instance_id}`);
|
||||
};
|
||||
|
||||
// 启动虚拟机
|
||||
const handleStart = async (row) => {
|
||||
try {
|
||||
const res = await startInstance(row.instance_id);
|
||||
if (res && res.data && res.data.code === 200) {
|
||||
ElMessage.success('启动指令已发送');
|
||||
setTimeout(() => {
|
||||
fetchVmList();
|
||||
}, 2000);
|
||||
} else {
|
||||
ElMessage.error('启动失败: ' + (res.data.message || '未知错误'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('启动虚拟机出错:', error);
|
||||
ElMessage.error('启动虚拟机出错');
|
||||
}
|
||||
};
|
||||
|
||||
// 停止虚拟机
|
||||
const handleStop = async (row) => {
|
||||
try {
|
||||
ElMessageBox.confirm('确定要停止该虚拟机吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
const res = await stopInstance(row.instance_id);
|
||||
if (res && res.data && res.data.code === 200) {
|
||||
ElMessage.success('停止指令已发送');
|
||||
setTimeout(() => {
|
||||
fetchVmList();
|
||||
}, 2000);
|
||||
} else {
|
||||
ElMessage.error('停止失败: ' + (res.data.message || '未知错误'));
|
||||
}
|
||||
}).catch(() => {});
|
||||
} catch (error) {
|
||||
console.error('停止虚拟机出错:', error);
|
||||
ElMessage.error('停止虚拟机出错');
|
||||
}
|
||||
};
|
||||
|
||||
// 重启虚拟机
|
||||
const handleRestart = async (row) => {
|
||||
try {
|
||||
ElMessageBox.confirm('确定要重启该虚拟机吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
const res = await restartInstance(row.instance_id);
|
||||
if (res && res.data && res.data.code === 200) {
|
||||
ElMessage.success('重启指令已发送');
|
||||
setTimeout(() => {
|
||||
fetchVmList();
|
||||
}, 2000);
|
||||
} else {
|
||||
ElMessage.error('重启失败: ' + (res.data.message || '未知错误'));
|
||||
}
|
||||
}).catch(() => {});
|
||||
} catch (error) {
|
||||
console.error('重启虚拟机出错:', error);
|
||||
ElMessage.error('重启虚拟机出错');
|
||||
}
|
||||
};
|
||||
|
||||
// 监听ID变化
|
||||
watch(() => props.ID, (newVal) => {
|
||||
if (newVal) {
|
||||
fetchVmList();
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (props.ID) {
|
||||
fetchVmList();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.vm-list-container {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,340 @@
|
||||
<template>
|
||||
<div class="chart-container">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-card class="chart-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>CPU使用率</span>
|
||||
</div>
|
||||
</template>
|
||||
<div ref="cpuChart" class="chart"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-card class="chart-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>内存使用率</span>
|
||||
</div>
|
||||
</template>
|
||||
<div ref="memoryChart" class="chart"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20" style="margin-top: 20px;">
|
||||
<el-col :span="12">
|
||||
<el-card class="chart-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>磁盘使用率</span>
|
||||
</div>
|
||||
</template>
|
||||
<div ref="diskChart" class="chart"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-card class="chart-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>网络流量</span>
|
||||
</div>
|
||||
</template>
|
||||
<div ref="networkChart" class="chart"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onBeforeUnmount, defineProps } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import * as echarts from 'echarts';
|
||||
import { getServerStatus, getTraffic, getDiskInfo } from '@/utils/acs/server';
|
||||
|
||||
const props = defineProps({
|
||||
Type: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const cpuChart = ref(null);
|
||||
const memoryChart = ref(null);
|
||||
const diskChart = ref(null);
|
||||
const networkChart = ref(null);
|
||||
|
||||
let cpuChartInstance = null;
|
||||
let memoryChartInstance = null;
|
||||
let diskChartInstance = null;
|
||||
let networkChartInstance = null;
|
||||
|
||||
// 定时器ID
|
||||
let timer = null;
|
||||
|
||||
// 初始化图表
|
||||
const initCharts = () => {
|
||||
// 初始化CPU图表
|
||||
cpuChartInstance = echarts.init(cpuChart.value);
|
||||
const cpuOption = {
|
||||
tooltip: {
|
||||
formatter: '{a} <br/>{b} : {c}%'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'CPU',
|
||||
type: 'gauge',
|
||||
detail: { formatter: '{value}%' },
|
||||
data: [{ value: 0, name: '使用率' }],
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
width: 30,
|
||||
color: [
|
||||
[0.3, '#67C23A'],
|
||||
[0.7, '#E6A23C'],
|
||||
[1, '#F56C6C']
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
cpuChartInstance.setOption(cpuOption);
|
||||
|
||||
// 初始化内存图表
|
||||
memoryChartInstance = echarts.init(memoryChart.value);
|
||||
const memoryOption = {
|
||||
tooltip: {
|
||||
formatter: '{a} <br/>{b} : {c}%'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '内存',
|
||||
type: 'gauge',
|
||||
detail: { formatter: '{value}%' },
|
||||
data: [{ value: 0, name: '使用率' }],
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
width: 30,
|
||||
color: [
|
||||
[0.3, '#67C23A'],
|
||||
[0.7, '#E6A23C'],
|
||||
[1, '#F56C6C']
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
memoryChartInstance.setOption(memoryOption);
|
||||
|
||||
// 初始化磁盘图表
|
||||
diskChartInstance = echarts.init(diskChart.value);
|
||||
const diskOption = {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b} : {c} ({d}%)'
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
data: ['已使用', '可用']
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '磁盘空间',
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: [
|
||||
{ value: 0, name: '已使用' },
|
||||
{ value: 100, name: '可用' }
|
||||
],
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
diskChartInstance.setOption(diskOption);
|
||||
|
||||
// 初始化网络流量图表
|
||||
networkChartInstance = echarts.init(networkChart.value);
|
||||
const networkOption = {
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: ['上传', '下载']
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: Array(10).fill('').map((_, i) => `${i}`)
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
axisLabel: {
|
||||
formatter: '{value} MB/s'
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '上传',
|
||||
type: 'line',
|
||||
data: Array(10).fill(0),
|
||||
areaStyle: {}
|
||||
},
|
||||
{
|
||||
name: '下载',
|
||||
type: 'line',
|
||||
data: Array(10).fill(0),
|
||||
areaStyle: {}
|
||||
}
|
||||
]
|
||||
};
|
||||
networkChartInstance.setOption(networkOption);
|
||||
};
|
||||
|
||||
// 更新图表数据
|
||||
const updateCharts = async () => {
|
||||
try {
|
||||
// 获取服务器状态
|
||||
const statusRes = await getServerStatus(route.query.server_id);
|
||||
if (statusRes && statusRes.data && statusRes.data.code === 200) {
|
||||
const statusData = statusRes.data.data;
|
||||
|
||||
// 更新CPU图表
|
||||
if (cpuChartInstance) {
|
||||
const cpuUsage = statusData.cpu_usage || 0;
|
||||
cpuChartInstance.setOption({
|
||||
series: [
|
||||
{
|
||||
data: [{ value: parseFloat(cpuUsage).toFixed(2), name: '使用率' }]
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
// 更新内存图表
|
||||
if (memoryChartInstance) {
|
||||
const memoryUsage = statusData.memory_usage || 0;
|
||||
memoryChartInstance.setOption({
|
||||
series: [
|
||||
{
|
||||
data: [{ value: parseFloat(memoryUsage).toFixed(2), name: '使用率' }]
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 获取磁盘信息
|
||||
const diskRes = await getDiskInfo(route.query.server_id);
|
||||
if (diskRes && diskRes.data && diskRes.data.code === 200) {
|
||||
const diskData = diskRes.data.data;
|
||||
if (diskChartInstance && diskData) {
|
||||
const used = diskData.used || 0;
|
||||
const available = diskData.available || 100;
|
||||
diskChartInstance.setOption({
|
||||
series: [
|
||||
{
|
||||
data: [
|
||||
{ value: used, name: '已使用' },
|
||||
{ value: available, name: '可用' }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 获取网络流量
|
||||
const trafficRes = await getTraffic(route.query.server_id);
|
||||
if (trafficRes && trafficRes.data && trafficRes.data.code === 200) {
|
||||
const trafficData = trafficRes.data.data;
|
||||
if (networkChartInstance && trafficData) {
|
||||
// 假设API返回的是最近的流量数据点
|
||||
const uploadData = trafficData.upload || Array(10).fill(0);
|
||||
const downloadData = trafficData.download || Array(10).fill(0);
|
||||
|
||||
networkChartInstance.setOption({
|
||||
series: [
|
||||
{
|
||||
data: uploadData.slice(-10)
|
||||
},
|
||||
{
|
||||
data: downloadData.slice(-10)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新图表数据失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 调整图表大小
|
||||
const resizeCharts = () => {
|
||||
cpuChartInstance && cpuChartInstance.resize();
|
||||
memoryChartInstance && memoryChartInstance.resize();
|
||||
diskChartInstance && diskChartInstance.resize();
|
||||
networkChartInstance && networkChartInstance.resize();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
// 初始化图表
|
||||
initCharts();
|
||||
|
||||
// 定时更新数据
|
||||
updateCharts();
|
||||
timer = setInterval(updateCharts, 30000); // 每30秒更新一次
|
||||
|
||||
// 监听窗口大小变化
|
||||
window.addEventListener('resize', resizeCharts);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
// 清除定时器
|
||||
if (timer) {
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
}
|
||||
|
||||
// 移除事件监听
|
||||
window.removeEventListener('resize', resizeCharts);
|
||||
|
||||
// 销毁图表实例
|
||||
cpuChartInstance && cpuChartInstance.dispose();
|
||||
memoryChartInstance && memoryChartInstance.dispose();
|
||||
diskChartInstance && diskChartInstance.dispose();
|
||||
networkChartInstance && networkChartInstance.dispose();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chart-container {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.chart-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.chart {
|
||||
height: 300px;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,892 @@
|
||||
<template>
|
||||
<div class="dashboard-container">
|
||||
<!-- 统计卡片 -->
|
||||
<el-row :gutter="24">
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6" v-for="(card, index) in statisticsCards" :key="index">
|
||||
<el-card class="stat-card" :class="card.class" shadow="hover">
|
||||
<div class="card-top">
|
||||
<div class="card-meta">
|
||||
<div class="card-title">{{ card.title }}</div>
|
||||
<div class="card-value">{{ card.value }}</div>
|
||||
</div>
|
||||
<div class="card-icon">
|
||||
<el-icon><component :is="card.icon" /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<span>较昨日</span>
|
||||
<span :class="card.trend > 0 ? 'up' : 'down'">
|
||||
{{ card.trend > 0 ? '+' : '' }}{{ card.trend }}%
|
||||
<el-icon v-if="card.trend > 0"><arrow-up /></el-icon>
|
||||
<el-icon v-else><arrow-down /></el-icon>
|
||||
</span>
|
||||
</div>
|
||||
<div class="progress-bar">
|
||||
<div class="progress-inner" :style="{width: card.progress + '%', background: card.progressColor}"></div>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 图表部分 -->
|
||||
<el-row :gutter="24" class="chart-row">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
|
||||
<el-card class="chart-card" shadow="hover">
|
||||
<div class="chart-header">
|
||||
<div class="chart-title">
|
||||
<h3>销售趋势</h3>
|
||||
<p>本期销售数据分析与预测</p>
|
||||
</div>
|
||||
<div class="chart-actions">
|
||||
<el-radio-group v-model="salesRange" size="small">
|
||||
<el-radio-button label="week">本周</el-radio-button>
|
||||
<el-radio-button label="month">本月</el-radio-button>
|
||||
<el-radio-button label="year">全年</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-dropdown class="chart-more">
|
||||
<el-button size="small" text>
|
||||
<el-icon><more-filled /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>
|
||||
<el-icon><download /></el-icon> 导出数据
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
<el-icon><refresh /></el-icon> 刷新
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
<el-icon><setting /></el-icon> 配置
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart-overview">
|
||||
<div class="overview-item">
|
||||
<span class="label">总销售额</span>
|
||||
<span class="value">¥ 893,204</span>
|
||||
<span class="rate up">+21.5%</span>
|
||||
</div>
|
||||
<div class="overview-item">
|
||||
<span class="label">平均订单额</span>
|
||||
<span class="value">¥ 5,618</span>
|
||||
<span class="rate up">+6.8%</span>
|
||||
</div>
|
||||
<div class="overview-item">
|
||||
<span class="label">转化周期</span>
|
||||
<span class="value">24天</span>
|
||||
<span class="rate down">-2.3%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart-container" ref="salesChartRef"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
|
||||
<el-card class="chart-card" shadow="hover">
|
||||
<div class="chart-header">
|
||||
<div class="chart-title">
|
||||
<h3>客户构成</h3>
|
||||
<p>客户群体分布情况</p>
|
||||
</div>
|
||||
<el-dropdown class="chart-more">
|
||||
<el-button size="small" text>
|
||||
<el-icon><more-filled /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>
|
||||
<el-icon><download /></el-icon> 导出数据
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
<el-icon><refresh /></el-icon> 刷新
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
<div class="customer-legend">
|
||||
<div v-for="(item, index) in customerData" :key="index" class="legend-item">
|
||||
<span class="legend-color" :style="{background: item.color}"></span>
|
||||
<span class="legend-label">{{ item.name }}</span>
|
||||
<span class="legend-value">{{ item.percentage }}%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart-container" ref="customerChartRef"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 最近活动和待办事项 -->
|
||||
<el-row :gutter="24" class="activity-row">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
|
||||
<el-card class="activity-card" shadow="hover">
|
||||
<div class="card-header-custom">
|
||||
<div class="header-left">
|
||||
<h3>最近活动</h3>
|
||||
<el-badge :value="activities.length" class="badge" type="primary" />
|
||||
</div>
|
||||
<el-link type="primary" :underline="false" class="view-all">
|
||||
查看全部 <el-icon class="el-icon--right"><right /></el-icon>
|
||||
</el-link>
|
||||
</div>
|
||||
<div class="timeline-container">
|
||||
<el-timeline>
|
||||
<el-timeline-item
|
||||
v-for="(activity, index) in activities"
|
||||
:key="index"
|
||||
:timestamp="activity.timestamp"
|
||||
:type="activity.type"
|
||||
:hollow="index !== 0"
|
||||
:size="index === 0 ? 'large' : 'normal'"
|
||||
>
|
||||
<div class="timeline-content">
|
||||
<div class="timeline-title">{{ activity.content }}</div>
|
||||
<div class="timeline-detail" v-if="activity.detail">{{ activity.detail }}</div>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
|
||||
<el-card class="todo-card" shadow="hover">
|
||||
<div class="card-header-custom">
|
||||
<div class="header-left">
|
||||
<h3>待办事项</h3>
|
||||
<el-tag type="danger" size="small" effect="dark" class="task-tag">{{ todoList.length }} 任务</el-tag>
|
||||
</div>
|
||||
<el-button type="primary" size="small" plain class="add-btn">
|
||||
<el-icon><plus /></el-icon> 添加
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="todo-filter">
|
||||
<el-radio-group v-model="todoFilter" size="small">
|
||||
<el-radio-button label="all">全部</el-radio-button>
|
||||
<el-radio-button label="today">今日</el-radio-button>
|
||||
<el-radio-button label="important">重要</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-dropdown>
|
||||
<el-button size="small" text>
|
||||
<el-icon><filter /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>按优先级排序</el-dropdown-item>
|
||||
<el-dropdown-item>按截止日期排序</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
<div class="todo-list">
|
||||
<div v-for="(todo, index) in todoList" :key="index" class="todo-item">
|
||||
<div class="todo-check">
|
||||
<el-checkbox size="large" />
|
||||
</div>
|
||||
<div class="todo-content">
|
||||
<div class="todo-title">{{ todo.title }}</div>
|
||||
<div class="todo-info">
|
||||
<el-tag :type="getPriorityType(todo.priority)" size="small" effect="plain">
|
||||
{{ todo.priority }}
|
||||
</el-tag>
|
||||
<span class="todo-date">
|
||||
<el-icon><calendar /></el-icon> {{ todo.deadline }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="todo-actions">
|
||||
<el-button type="primary" link size="small" circle>
|
||||
<el-icon><check /></el-icon>
|
||||
</el-button>
|
||||
<el-button type="danger" link size="small" circle>
|
||||
<el-icon><delete /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, watch, computed } from 'vue'
|
||||
import {
|
||||
User, ShoppingCart, Money, DataAnalysis,
|
||||
MoreFilled, ArrowUp, ArrowDown, Right,
|
||||
Download, Refresh, Check, Delete, Plus,
|
||||
Setting, Calendar, Filter
|
||||
} from '@element-plus/icons-vue'
|
||||
import * as echarts from 'echarts'
|
||||
import Qrcode from '@/components/Qrcode.vue'
|
||||
import {useUserStore} from "@/store/userStore.js";
|
||||
|
||||
const userStore = useUserStore()
|
||||
// 数据统计卡片
|
||||
const statisticsCards = ref([
|
||||
{
|
||||
title: '访问量',
|
||||
value: '8,846',
|
||||
icon: 'User',
|
||||
trend: 12.5,
|
||||
class: 'visitors',
|
||||
progress: 78,
|
||||
progressColor: 'rgba(24, 144, 255, 0.8)'
|
||||
},
|
||||
{
|
||||
title: '订单量',
|
||||
value: '1,257',
|
||||
icon: 'ShoppingCart',
|
||||
trend: 5.2,
|
||||
class: 'orders',
|
||||
progress: 65,
|
||||
progressColor: 'rgba(82, 196, 26, 0.8)'
|
||||
},
|
||||
{
|
||||
title: '销售额',
|
||||
value: '¥ 125,430',
|
||||
icon: 'Money',
|
||||
trend: -2.3,
|
||||
class: 'sales',
|
||||
progress: 52,
|
||||
progressColor: 'rgba(250, 173, 20, 0.8)'
|
||||
},
|
||||
{
|
||||
title: '转化率',
|
||||
value: '32.8%',
|
||||
icon: 'DataAnalysis',
|
||||
trend: 4.6,
|
||||
class: 'conversion',
|
||||
progress: 83,
|
||||
progressColor: 'rgba(114, 46, 209, 0.8)'
|
||||
}
|
||||
])
|
||||
|
||||
// 客户构成数据
|
||||
const customerData = ref([
|
||||
{ name: '企业客户', value: 1048, percentage: 33, color: '#1890ff' },
|
||||
{ name: '个人客户', value: 735, percentage: 23, color: '#52c41a' },
|
||||
{ name: '政府单位', value: 580, percentage: 18, color: '#fa8c16' },
|
||||
{ name: '教育机构', value: 484, percentage: 15, color: '#722ed1' },
|
||||
{ name: '其他', value: 300, percentage: 11, color: '#f759ab' }
|
||||
])
|
||||
|
||||
const salesRange = ref('month')
|
||||
const todoFilter = ref('all')
|
||||
const salesChartRef = ref(null)
|
||||
const customerChartRef = ref(null)
|
||||
let salesChart = null
|
||||
let customerChart = null
|
||||
|
||||
// 活动数据
|
||||
const activities = ref([
|
||||
{
|
||||
content: '王经理 完成了销售目标',
|
||||
detail: '超额完成15%的销售指标',
|
||||
timestamp: '刚刚',
|
||||
type: 'success'
|
||||
},
|
||||
{
|
||||
content: '李明 上传了新的销售报告',
|
||||
detail: '包含Q2季度各区域销售数据',
|
||||
timestamp: '10分钟前',
|
||||
type: 'primary'
|
||||
},
|
||||
{
|
||||
content: '系统更新了安全策略',
|
||||
timestamp: '1小时前',
|
||||
type: 'info'
|
||||
},
|
||||
{
|
||||
content: '张经理 分配了新的任务',
|
||||
detail: '关于新产品线的市场调研',
|
||||
timestamp: '昨天',
|
||||
type: 'warning'
|
||||
},
|
||||
{
|
||||
content: '年度销售会议即将开始',
|
||||
timestamp: '2天前',
|
||||
type: 'danger'
|
||||
}
|
||||
])
|
||||
|
||||
// 待办事项
|
||||
const todoList = ref([
|
||||
{ title: '完成季度销售报告', priority: '高', deadline: '2024-06-10' },
|
||||
{ title: '召开团队周会', priority: '中', deadline: '2024-06-12' },
|
||||
{ title: '审核营销方案', priority: '高', deadline: '2024-06-14' },
|
||||
{ title: '客户回访', priority: '低', deadline: '2024-06-18' }
|
||||
])
|
||||
|
||||
// 根据优先级返回标签类型
|
||||
const getPriorityType = (priority) => {
|
||||
switch (priority) {
|
||||
case '高': return 'danger'
|
||||
case '中': return 'warning'
|
||||
case '低': return 'info'
|
||||
default: return 'info'
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initSalesChart()
|
||||
initCustomerChart()
|
||||
|
||||
// 窗口大小变化时重新调整图表大小
|
||||
window.addEventListener('resize', () => {
|
||||
salesChart?.resize()
|
||||
customerChart?.resize()
|
||||
})
|
||||
})
|
||||
|
||||
// 初始化销售趋势图表
|
||||
const initSalesChart = () => {
|
||||
if (!salesChartRef.value) return
|
||||
|
||||
salesChart = echarts.init(salesChartRef.value)
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
backgroundColor: 'rgba(255,255,255,0.9)',
|
||||
borderColor: '#e6e9ed',
|
||||
borderWidth: 1,
|
||||
textStyle: {
|
||||
color: '#5e6d82'
|
||||
},
|
||||
formatter: function(params) {
|
||||
let result = params[0].name + '<br/>';
|
||||
params.forEach(item => {
|
||||
result += `<div style="display:flex;align-items:center;margin:5px 0">
|
||||
<span style="display:inline-block;width:10px;height:10px;background:${item.color};margin-right:5px;border-radius:50%"></span>
|
||||
<span>${item.seriesName}: ${item.value} 元</span>
|
||||
</div>`;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '8%',
|
||||
top: '5%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#e6e9ed'
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#5e6d82'
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
axisLine: {
|
||||
show: false
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#5e6d82'
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: '#f0f3f8'
|
||||
}
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '销售额',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbolSize: 6,
|
||||
lineStyle: {
|
||||
width: 3,
|
||||
color: '#1890ff'
|
||||
},
|
||||
itemStyle: {
|
||||
color: '#1890ff',
|
||||
borderWidth: 2,
|
||||
borderColor: '#fff'
|
||||
},
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowColor: 'rgba(24, 144, 255, 0.5)'
|
||||
}
|
||||
},
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'rgba(24, 144, 255, 0.5)' },
|
||||
{ offset: 1, color: 'rgba(24, 144, 255, 0.05)' }
|
||||
])
|
||||
},
|
||||
data: [12000, 19000, 15000, 22000, 19000, 28000, 32000]
|
||||
}
|
||||
]
|
||||
}
|
||||
salesChart.setOption(option)
|
||||
}
|
||||
|
||||
// 初始化客户构成图表
|
||||
const initCustomerChart = () => {
|
||||
if (!customerChartRef.value) return
|
||||
|
||||
customerChart = echarts.init(customerChartRef.value)
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b}: {c} ({d}%)',
|
||||
backgroundColor: 'rgba(255,255,255,0.9)',
|
||||
borderColor: '#e6e9ed',
|
||||
borderWidth: 1,
|
||||
textStyle: {
|
||||
color: '#5e6d82'
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '客户构成',
|
||||
type: 'pie',
|
||||
radius: ['55%', '75%'],
|
||||
center: ['50%', '50%'],
|
||||
avoidLabelOverlap: false,
|
||||
itemStyle: {
|
||||
borderRadius: 10,
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
},
|
||||
label: {
|
||||
show: false
|
||||
},
|
||||
emphasis: {
|
||||
focus: 'self',
|
||||
scaleSize: 10,
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.2)'
|
||||
}
|
||||
},
|
||||
labelLine: {
|
||||
show: false
|
||||
},
|
||||
data: customerData.value.map(item => ({
|
||||
value: item.value,
|
||||
name: item.name,
|
||||
itemStyle: {
|
||||
color: item.color
|
||||
}
|
||||
}))
|
||||
}
|
||||
]
|
||||
}
|
||||
customerChart.setOption(option)
|
||||
}
|
||||
|
||||
// 监听销售范围变化
|
||||
watch(salesRange, (newVal) => {
|
||||
// 根据选择的时间范围更新图表数据
|
||||
if (salesChart) {
|
||||
const xAxisData = newVal === 'week'
|
||||
? ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
||||
: newVal === 'month'
|
||||
? ['1日', '5日', '10日', '15日', '20日', '25日', '30日']
|
||||
: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
|
||||
|
||||
const seriesData = newVal === 'week'
|
||||
? [12000, 19000, 15000, 22000, 19000, 28000, 32000]
|
||||
: newVal === 'month'
|
||||
? [32000, 45000, 39000, 52000, 48000, 58000, 62000]
|
||||
: [158000, 165000, 180000, 220000, 210000, 252000, 265000, 270000, 285000, 302000, 318000, 350000]
|
||||
|
||||
salesChart.setOption({
|
||||
xAxis: {
|
||||
data: xAxisData
|
||||
},
|
||||
series: [{
|
||||
data: seriesData
|
||||
}]
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dashboard-container {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
/* 统计卡片样式 */
|
||||
.stat-card {
|
||||
margin-bottom: 24px;
|
||||
border-radius: 12px;
|
||||
border: none;
|
||||
transition: all 0.3s;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.card-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20px 20px 10px;
|
||||
}
|
||||
|
||||
.card-meta {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 14px;
|
||||
color: #8c8c8c;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.card-value {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: #262626;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.card-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 12px;
|
||||
font-size: 28px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.visitors .card-icon {
|
||||
background: linear-gradient(135deg, #1890ff, #096dd9);
|
||||
}
|
||||
|
||||
.orders .card-icon {
|
||||
background: linear-gradient(135deg, #52c41a, #389e0d);
|
||||
}
|
||||
|
||||
.sales .card-icon {
|
||||
background: linear-gradient(135deg, #faad14, #d48806);
|
||||
}
|
||||
|
||||
.conversion .card-icon {
|
||||
background: linear-gradient(135deg, #722ed1, #531dab);
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
padding: 0 20px 15px;
|
||||
font-size: 13px;
|
||||
color: #8c8c8c;
|
||||
}
|
||||
|
||||
.up {
|
||||
color: #52c41a;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.down {
|
||||
color: #f5222d;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 4px;
|
||||
background-color: #f0f0f0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-inner {
|
||||
height: 100%;
|
||||
transition: width 0.8s ease;
|
||||
}
|
||||
|
||||
/* 图表样式 */
|
||||
.chart-row {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.chart-card {
|
||||
margin-bottom: 24px;
|
||||
border-radius: 12px;
|
||||
border: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chart-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 20px 20px 0;
|
||||
}
|
||||
|
||||
.chart-title h3 {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #262626;
|
||||
margin: 0 0 4px;
|
||||
}
|
||||
|
||||
.chart-title p {
|
||||
font-size: 13px;
|
||||
color: #8c8c8c;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.chart-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.chart-more {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.chart-overview {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
gap: 40px;
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px dashed #f0f0f0;
|
||||
}
|
||||
|
||||
.overview-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.overview-item .label {
|
||||
font-size: 13px;
|
||||
color: #8c8c8c;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.overview-item .value {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #262626;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.overview-item .rate {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
height: 300px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* 客户构成图表特有样式 */
|
||||
.customer-legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.legend-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.legend-color {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.legend-label {
|
||||
font-size: 13px;
|
||||
color: #262626;
|
||||
}
|
||||
|
||||
.legend-value {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #262626;
|
||||
}
|
||||
|
||||
/* 活动和待办事项 */
|
||||
.activity-row {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.activity-card, .todo-card {
|
||||
height: 100%;
|
||||
border-radius: 12px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.card-header-custom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.header-left h3 {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #262626;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.view-all {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.timeline-container {
|
||||
padding: 20px;
|
||||
height: 350px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.timeline-content {
|
||||
padding: 12px 16px;
|
||||
background-color: #f9f9f9;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.timeline-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #262626;
|
||||
}
|
||||
|
||||
.timeline-detail {
|
||||
font-size: 13px;
|
||||
color: #8c8c8c;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
/* 待办事项特有样式 */
|
||||
.task-tag {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.todo-filter {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.todo-list {
|
||||
padding: 10px 20px;
|
||||
height: 270px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.todo-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
}
|
||||
|
||||
.todo-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.todo-check {
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
.todo-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.todo-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #262626;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.todo-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.todo-date {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
color: #8c8c8c;
|
||||
}
|
||||
|
||||
.todo-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.dashboard-container {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.chart-overview {
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.timeline-container,
|
||||
.todo-list {
|
||||
height: 320px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,525 @@
|
||||
<template>
|
||||
<div class="change-password-container">
|
||||
<div class="page-header">
|
||||
<h2 class="page-title">修改密码</h2>
|
||||
</div>
|
||||
|
||||
<div class="password-layout">
|
||||
<!-- 修改密码表单 -->
|
||||
<div class="password-form-container">
|
||||
<el-card shadow="hover" class="password-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<el-icon><lock /></el-icon>
|
||||
<span>密码修改</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-form
|
||||
ref="passwordFormRef"
|
||||
:model="passwordForm"
|
||||
:rules="rules"
|
||||
label-width="120px"
|
||||
class="password-form"
|
||||
status-icon
|
||||
>
|
||||
<el-form-item label="当前密码" prop="oldPassword">
|
||||
<el-input
|
||||
v-model="passwordForm.oldPassword"
|
||||
type="password"
|
||||
placeholder="请输入当前密码"
|
||||
show-password
|
||||
prefix-icon="Key"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-input
|
||||
v-model="passwordForm.newPassword"
|
||||
type="password"
|
||||
placeholder="请输入新密码"
|
||||
show-password
|
||||
prefix-icon="Lock"
|
||||
/>
|
||||
|
||||
<!-- 密码强度指示器 -->
|
||||
<div class="password-strength" v-if="passwordForm.newPassword">
|
||||
<div class="strength-label">密码强度:</div>
|
||||
<div class="strength-bar">
|
||||
<div
|
||||
class="strength-indicator"
|
||||
:class="[
|
||||
passwordStrength === 'weak' ? 'weak' :
|
||||
passwordStrength === 'medium' ? 'medium' :
|
||||
passwordStrength === 'strong' ? 'strong' : ''
|
||||
]"
|
||||
:style="{ width: strengthPercentage + '%' }"
|
||||
></div>
|
||||
</div>
|
||||
<div class="strength-text" :class="passwordStrength">
|
||||
{{ passwordStrengthText }}
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="确认新密码" prop="confirmPassword">
|
||||
<el-input
|
||||
v-model="passwordForm.confirmPassword"
|
||||
type="password"
|
||||
placeholder="请再次输入新密码"
|
||||
show-password
|
||||
prefix-icon="Check"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="submitForm"
|
||||
:loading="loading"
|
||||
:disabled="submitDisabled"
|
||||
class="submit-btn"
|
||||
>
|
||||
保存修改
|
||||
</el-button>
|
||||
<el-button @click="resetForm">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<!-- 密码规则说明 -->
|
||||
<div class="password-tips-container">
|
||||
<el-card shadow="hover" class="tips-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<el-icon><InfoFilled /></el-icon>
|
||||
<span>密码要求</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="tips-content">
|
||||
<p class="tips-title">为了保障您的账号安全,密码需满足以下要求:</p>
|
||||
|
||||
<ul class="tips-list">
|
||||
<li class="tips-item" :class="{ passed: hasMinLength }">
|
||||
<el-icon :class="{ 'is-passed': hasMinLength }">
|
||||
<component :is="hasMinLength ? 'CircleCheck' : 'CircleClose'" />
|
||||
</el-icon>
|
||||
<span>长度至少8个字符</span>
|
||||
</li>
|
||||
<li class="tips-item" :class="{ passed: hasUpperCase }">
|
||||
<el-icon :class="{ 'is-passed': hasUpperCase }">
|
||||
<component :is="hasUpperCase ? 'CircleCheck' : 'CircleClose'" />
|
||||
</el-icon>
|
||||
<span>包含至少一个大写字母 (A-Z)</span>
|
||||
</li>
|
||||
<li class="tips-item" :class="{ passed: hasLowerCase }">
|
||||
<el-icon :class="{ 'is-passed': hasLowerCase }">
|
||||
<component :is="hasLowerCase ? 'CircleCheck' : 'CircleClose'" />
|
||||
</el-icon>
|
||||
<span>包含至少一个小写字母 (a-z)</span>
|
||||
</li>
|
||||
<li class="tips-item" :class="{ passed: hasNumber }">
|
||||
<el-icon :class="{ 'is-passed': hasNumber }">
|
||||
<component :is="hasNumber ? 'CircleCheck' : 'CircleClose'" />
|
||||
</el-icon>
|
||||
<span>包含至少一个数字 (0-9)</span>
|
||||
</li>
|
||||
<li class="tips-item" :class="{ passed: hasSpecialChar }">
|
||||
<el-icon :class="{ 'is-passed': hasSpecialChar }">
|
||||
<component :is="hasSpecialChar ? 'CircleCheck' : 'CircleClose'" />
|
||||
</el-icon>
|
||||
<span>包含至少一个特殊字符 (@$!%*#?&)</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tips-note">
|
||||
<el-icon><Warning /></el-icon>
|
||||
<p>为了您的账户安全,请不要使用与其他网站相同的密码,并定期更换密码。</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
Lock,
|
||||
Key,
|
||||
InfoFilled,
|
||||
CircleCheck,
|
||||
CircleClose,
|
||||
Warning,
|
||||
Check
|
||||
} from '@element-plus/icons-vue'
|
||||
|
||||
// 表单数据
|
||||
const passwordForm = reactive({
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: ''
|
||||
})
|
||||
|
||||
// 表单引用
|
||||
const passwordFormRef = ref(null)
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false)
|
||||
|
||||
// 密码强度计算
|
||||
const hasMinLength = computed(() =>
|
||||
passwordForm.newPassword.length >= 8
|
||||
)
|
||||
|
||||
const hasUpperCase = computed(() =>
|
||||
/[A-Z]/.test(passwordForm.newPassword)
|
||||
)
|
||||
|
||||
const hasLowerCase = computed(() =>
|
||||
/[a-z]/.test(passwordForm.newPassword)
|
||||
)
|
||||
|
||||
const hasNumber = computed(() =>
|
||||
/\d/.test(passwordForm.newPassword)
|
||||
)
|
||||
|
||||
const hasSpecialChar = computed(() =>
|
||||
/[@$!%*#?&]/.test(passwordForm.newPassword)
|
||||
)
|
||||
|
||||
// 密码强度计算
|
||||
const passwordStrength = computed(() => {
|
||||
let score = 0
|
||||
|
||||
// 最低长度要求
|
||||
if (hasMinLength.value) score++
|
||||
|
||||
// 大写字母
|
||||
if (hasUpperCase.value) score++
|
||||
|
||||
// 小写字母
|
||||
if (hasLowerCase.value) score++
|
||||
|
||||
// 数字
|
||||
if (hasNumber.value) score++
|
||||
|
||||
// 特殊字符
|
||||
if (hasSpecialChar.value) score++
|
||||
|
||||
if (score <= 2) return 'weak'
|
||||
if (score <= 4) return 'medium'
|
||||
return 'strong'
|
||||
})
|
||||
|
||||
// 密码强度百分比
|
||||
const strengthPercentage = computed(() => {
|
||||
if (passwordStrength.value === 'weak') return 30
|
||||
if (passwordStrength.value === 'medium') return 70
|
||||
return 100
|
||||
})
|
||||
|
||||
// 密码强度文字描述
|
||||
const passwordStrengthText = computed(() => {
|
||||
if (passwordStrength.value === 'weak') return '弱'
|
||||
if (passwordStrength.value === 'medium') return '中'
|
||||
return '强'
|
||||
})
|
||||
|
||||
// 提交按钮是否禁用
|
||||
const submitDisabled = computed(() => {
|
||||
return (
|
||||
!passwordForm.oldPassword ||
|
||||
!passwordForm.newPassword ||
|
||||
!passwordForm.confirmPassword ||
|
||||
passwordStrength.value === 'weak'
|
||||
)
|
||||
})
|
||||
|
||||
// 密码强度校验
|
||||
const validatePasswordStrength = (rule, value, callback) => {
|
||||
if (value === '') {
|
||||
callback(new Error('请输入密码'))
|
||||
return
|
||||
}
|
||||
|
||||
if (!hasMinLength.value) {
|
||||
callback(new Error('密码长度至少为8个字符'))
|
||||
return
|
||||
}
|
||||
|
||||
if (!(hasUpperCase.value && hasLowerCase.value && hasNumber.value && hasSpecialChar.value)) {
|
||||
callback(new Error('密码必须包含大小写字母、数字和特殊字符'))
|
||||
return
|
||||
}
|
||||
|
||||
callback()
|
||||
}
|
||||
|
||||
// 确认密码校验
|
||||
const validateConfirmPassword = (rule, value, callback) => {
|
||||
if (value === '') {
|
||||
callback(new Error('请再次输入密码'))
|
||||
return
|
||||
}
|
||||
|
||||
if (value !== passwordForm.newPassword) {
|
||||
callback(new Error('两次输入的密码不一致'))
|
||||
return
|
||||
}
|
||||
|
||||
callback()
|
||||
}
|
||||
|
||||
// 表单校验规则
|
||||
const rules = {
|
||||
oldPassword: [
|
||||
{ required: true, message: '请输入当前密码', trigger: 'blur' },
|
||||
{ min: 6, message: '密码长度至少为6个字符', trigger: 'blur' }
|
||||
],
|
||||
newPassword: [
|
||||
{ required: true, message: '请输入新密码', trigger: 'blur' },
|
||||
{ validator: validatePasswordStrength, trigger: 'blur' }
|
||||
],
|
||||
confirmPassword: [
|
||||
{ required: true, message: '请再次输入新密码', trigger: 'blur' },
|
||||
{ validator: validateConfirmPassword, trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = async () => {
|
||||
if (!passwordFormRef.value) return
|
||||
|
||||
await passwordFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
loading.value = true
|
||||
|
||||
// 模拟API调用
|
||||
await new Promise(resolve => setTimeout(resolve, 1500))
|
||||
|
||||
// 这里应该调用API修改密码
|
||||
// const res = await api.changePassword(passwordForm)
|
||||
|
||||
ElMessage.success('密码修改成功,请重新登录')
|
||||
loading.value = false
|
||||
|
||||
// 清空表单
|
||||
resetForm()
|
||||
|
||||
// 实际项目中可能需要跳转到登录页
|
||||
// router.push('/login')
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
ElMessage.error('密码修改失败,请重试')
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 重置表单
|
||||
const resetForm = () => {
|
||||
if (passwordFormRef.value) {
|
||||
passwordFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.change-password-container {
|
||||
padding: 24px;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
color: #1a1f36;
|
||||
}
|
||||
|
||||
.password-layout {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.password-form-container {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.password-tips-container {
|
||||
width: 380px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.password-card,
|
||||
.tips-card {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05) !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1a1f36;
|
||||
}
|
||||
|
||||
.card-header .el-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 18px;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.password-form {
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.password-strength {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.strength-label {
|
||||
margin-right: 8px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.strength-bar {
|
||||
width: 120px;
|
||||
height: 4px;
|
||||
background-color: #e4e7ed;
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
margin-right: 8px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.strength-indicator {
|
||||
height: 100%;
|
||||
transition: width 0.3s ease, background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.strength-indicator.weak {
|
||||
background-color: #f56c6c;
|
||||
}
|
||||
|
||||
.strength-indicator.medium {
|
||||
background-color: #e6a23c;
|
||||
}
|
||||
|
||||
.strength-indicator.strong {
|
||||
background-color: #67c23a;
|
||||
}
|
||||
|
||||
.strength-text {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.strength-text.weak {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.strength-text.medium {
|
||||
color: #e6a23c;
|
||||
}
|
||||
|
||||
.strength-text.strong {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.tips-content {
|
||||
padding: 0 0 15px;
|
||||
}
|
||||
|
||||
.tips-title {
|
||||
margin-top: 0;
|
||||
margin-bottom: 16px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.tips-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
|
||||
.tips-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8px 0;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
|
||||
.tips-item .el-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 16px;
|
||||
color: #c0c4cc;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
|
||||
.tips-item .el-icon.is-passed {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.tips-item.passed {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.tips-note {
|
||||
background-color: #fdf6ec;
|
||||
border-radius: 4px;
|
||||
padding: 10px 12px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.tips-note .el-icon {
|
||||
color: #e6a23c;
|
||||
font-size: 16px;
|
||||
margin-right: 8px;
|
||||
margin-top: 3px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tips-note p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: #af8741;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
@media (max-width: 992px) {
|
||||
.password-layout {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.password-tips-container {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,529 @@
|
||||
<template>
|
||||
<div class="user-info-container">
|
||||
<div class="page-header">
|
||||
<h2 class="page-title">个人信息</h2>
|
||||
<div class="page-actions">
|
||||
<el-button type="primary" @click="handleEdit" v-if="!isEditing">
|
||||
<el-icon><edit /></el-icon>编辑资料
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="profile-layout">
|
||||
<!-- 左侧用户基本信息卡片 -->
|
||||
<div class="profile-sidebar">
|
||||
<div class="profile-card">
|
||||
<div class="profile-avatar-container">
|
||||
<el-avatar
|
||||
:size="120"
|
||||
:src="userInfo.avatar || 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'"
|
||||
class="profile-avatar"
|
||||
/>
|
||||
<div class="profile-avatar-edit" v-if="isEditing">
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
action="/api/upload"
|
||||
:show-file-list="false"
|
||||
:on-success="handleAvatarSuccess"
|
||||
>
|
||||
<div class="upload-trigger">
|
||||
<el-icon><upload-filled /></el-icon>
|
||||
<span>更换头像</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="profile-name">{{ userInfo.realName }}</h3>
|
||||
<div class="profile-title">{{ userInfo.position }}</div>
|
||||
<div class="profile-role">
|
||||
<el-tag type="success" effect="plain">{{ userInfo.role }}</el-tag>
|
||||
</div>
|
||||
<div class="profile-stats">
|
||||
<div class="stat-item">
|
||||
<div class="stat-value">{{ userInfo.department }}</div>
|
||||
<div class="stat-label">部门</div>
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-value">{{ formatDate(userInfo.lastLogin) }}</div>
|
||||
<div class="stat-label">最近登录</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧详细信息内容 -->
|
||||
<div class="profile-content">
|
||||
<!-- 查看模式 -->
|
||||
<div v-if="!isEditing" class="info-display">
|
||||
<el-card shadow="hover" class="info-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<el-icon><user /></el-icon>
|
||||
<span>账号信息</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="info-list">
|
||||
<div class="info-item">
|
||||
<span class="info-label">用户名</span>
|
||||
<span class="info-value">{{ userInfo.username }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">真实姓名</span>
|
||||
<span class="info-value">{{ userInfo.realName }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">邮箱</span>
|
||||
<span class="info-value">{{ userInfo.email }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">手机号</span>
|
||||
<span class="info-value">{{ userInfo.phone }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="hover" class="info-card bio-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<el-icon><document /></el-icon>
|
||||
<span>个人简介</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="bio-content">
|
||||
{{ userInfo.bio || '暂无个人简介' }}
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="hover" class="info-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<el-icon><timer /></el-icon>
|
||||
<span>时间信息</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="info-list">
|
||||
<div class="info-item">
|
||||
<span class="info-label">账号创建时间</span>
|
||||
<span class="info-value">{{ formatDateFull(userInfo.createTime) }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-label">最后登录时间</span>
|
||||
<span class="info-value">{{ formatDateFull(userInfo.lastLogin) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<!-- 编辑表单部分 -->
|
||||
<div v-else class="info-edit">
|
||||
<el-card shadow="hover" class="edit-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<el-icon><edit-pen /></el-icon>
|
||||
<span>编辑个人资料</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="userFormRef" :model="userForm" :rules="rules" label-width="100px" class="edit-form">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="userForm.username" disabled />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="真实姓名" prop="realName">
|
||||
<el-input v-model="userForm.realName" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="userForm.email">
|
||||
<template #prefix>
|
||||
<el-icon><message /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="userForm.phone">
|
||||
<template #prefix>
|
||||
<el-icon><phone /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="部门">
|
||||
<el-input v-model="userForm.department">
|
||||
<template #prefix>
|
||||
<el-icon><office-building /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="职位">
|
||||
<el-input v-model="userForm.position" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="个人简介">
|
||||
<el-input v-model="userForm.bio" type="textarea" :rows="4" resize="none" maxlength="200" show-word-limit />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm" :loading="loading">保存</el-button>
|
||||
<el-button @click="cancelEdit">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
User, Edit, Document, Timer, EditPen, Message,
|
||||
Phone, OfficeBuilding, UploadFilled
|
||||
} from '@element-plus/icons-vue'
|
||||
|
||||
// 是否处于编辑模式
|
||||
const isEditing = ref(false)
|
||||
const loading = ref(false)
|
||||
|
||||
// 用户信息数据
|
||||
const userInfo = reactive({
|
||||
username: 'admin',
|
||||
realName: '管理员',
|
||||
email: 'admin@example.com',
|
||||
phone: '13800138000',
|
||||
department: '技术部',
|
||||
position: '系统管理员',
|
||||
role: '超级管理员',
|
||||
createTime: '2023-01-01 00:00:00',
|
||||
lastLogin: '2023-06-15 10:30:45',
|
||||
bio: '系统管理员,负责系统的日常维护和管理工作。拥有丰富的系统管理经验,精通Linux服务器配置和维护,熟悉网络安全,对系统性能优化有独到见解。',
|
||||
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
|
||||
})
|
||||
|
||||
// 表单数据
|
||||
const userForm = reactive({...userInfo})
|
||||
|
||||
// 表单校验规则
|
||||
const rules = {
|
||||
realName: [
|
||||
{ required: true, message: '请输入真实姓名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
],
|
||||
email: [
|
||||
{ required: true, message: '请输入邮箱地址', trigger: 'blur' },
|
||||
{ type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
|
||||
],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
const userFormRef = ref(null)
|
||||
|
||||
// 日期格式化函数
|
||||
const formatDate = (dateStr) => {
|
||||
const date = new Date(dateStr)
|
||||
const now = new Date()
|
||||
|
||||
// 如果是今天,只显示时间
|
||||
if (date.toDateString() === now.toDateString()) {
|
||||
return date.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' })
|
||||
}
|
||||
|
||||
// 否则显示日期
|
||||
return date.toLocaleDateString('zh-CN', { month: '2-digit', day: '2-digit' })
|
||||
}
|
||||
|
||||
// 完整日期格式化
|
||||
const formatDateFull = (dateStr) => {
|
||||
const date = new Date(dateStr)
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑按钮点击事件
|
||||
const handleEdit = () => {
|
||||
Object.assign(userForm, userInfo)
|
||||
isEditing.value = true
|
||||
}
|
||||
|
||||
// 取消编辑
|
||||
const cancelEdit = () => {
|
||||
isEditing.value = false
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = async () => {
|
||||
if (!userFormRef.value) return
|
||||
|
||||
await userFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
loading.value = true
|
||||
// 模拟API调用
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
|
||||
// 更新本地用户信息
|
||||
Object.assign(userInfo, userForm)
|
||||
ElMessage.success('个人信息更新成功')
|
||||
isEditing.value = false
|
||||
loading.value = false
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
ElMessage.error('保存失败,请重试')
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 头像上传成功回调
|
||||
const handleAvatarSuccess = (res) => {
|
||||
userForm.avatar = res.url
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
const fetchUserInfo = async () => {
|
||||
try {
|
||||
// 模拟API调用
|
||||
await new Promise(resolve => setTimeout(resolve, 500))
|
||||
// 实际项目中,应该从后端获取用户信息并更新userInfo
|
||||
} catch (error) {
|
||||
ElMessage.error('获取用户信息失败')
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchUserInfo()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.user-info-container {
|
||||
padding: 24px;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
color: #1a1f36;
|
||||
}
|
||||
|
||||
.profile-layout {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.profile-sidebar {
|
||||
width: 300px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.profile-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.profile-card {
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.profile-avatar-container {
|
||||
position: relative;
|
||||
margin-bottom: 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.profile-avatar {
|
||||
border: 4px solid #fff;
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.profile-avatar-edit {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.upload-trigger {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background-color: #409eff;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.5);
|
||||
}
|
||||
|
||||
.upload-trigger span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.upload-trigger:hover {
|
||||
width: auto;
|
||||
height: auto;
|
||||
border-radius: 18px;
|
||||
padding: 4px 12px;
|
||||
}
|
||||
|
||||
.upload-trigger:hover span {
|
||||
display: inline-block;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.profile-name {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 8px 0;
|
||||
color: #1a1f36;
|
||||
}
|
||||
|
||||
.profile-title {
|
||||
color: #667085;
|
||||
font-size: 16px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.profile-role {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.profile-stats {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-top: 1px solid #edf2f7;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
color: #94a3b8;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.divider {
|
||||
width: 1px;
|
||||
height: 30px;
|
||||
background-color: #edf2f7;
|
||||
margin: 0 15px;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
margin-bottom: 24px;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bio-card {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1a1f36;
|
||||
}
|
||||
|
||||
.card-header .el-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 18px;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.info-list {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
width: 120px;
|
||||
color: #64748b;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
color: #334155;
|
||||
font-weight: 500;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.bio-content {
|
||||
color: #475569;
|
||||
line-height: 1.6;
|
||||
font-size: 14px;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.edit-card {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.edit-form {
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
@media (max-width: 992px) {
|
||||
.profile-layout {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.profile-sidebar {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.profile-card {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,309 @@
|
||||
<template>
|
||||
<div class="domain-whitelist-container">
|
||||
<!-- 搜索和操作栏 -->
|
||||
<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="请输入域名" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="action-bar">
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<el-icon><plus /></el-icon>新增域名
|
||||
</el-button>
|
||||
<el-button type="danger" :disabled="!selectedRows.length" @click="handleBatchDelete">
|
||||
<el-icon><delete /></el-icon>批量删除
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 域名列表 -->
|
||||
<el-card class="table-container" shadow="never">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="domainList"
|
||||
@selection-change="handleSelectionChange"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="Id" label="ID" width="80" />
|
||||
<el-table-column prop="Domain" label="域名" min-width="200" >
|
||||
<template #default="{ row }">
|
||||
<el-link :href="`http://${row.Domain}`" target="_blank" type="primary">{{ row.Domain }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="CreatedAt" label="创建时间" width="180" :formatter="parseCreatedAt" />
|
||||
<el-table-column prop="UpdatedAt" label="更新时间" width="180" :formatter="parseUpdatedAt" />
|
||||
<el-table-column label="操作" width="100" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="danger" link @click="handleDelete(row)">删除</el-button>
|
||||
</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="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
background
|
||||
class="pagination"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- 域名表单对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
title="新增域名"
|
||||
width="500px"
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="domainFormRef"
|
||||
:model="domainForm"
|
||||
:rules="domainRules"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="域名" prop="domain">
|
||||
<el-input v-model="domainForm.domain" placeholder="请输入域名,例如: example.com" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Delete } from '@element-plus/icons-vue'
|
||||
import { getDomainList, addDomain, deleteDomain, batchDeleteDomain } from '@/api/domain'
|
||||
|
||||
// 查询参数
|
||||
const queryParams = reactive({
|
||||
domain: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
|
||||
// 域名表单
|
||||
const domainForm = reactive({
|
||||
domain: ''
|
||||
})
|
||||
|
||||
// 表单规则
|
||||
const domainRules = {
|
||||
domain: [
|
||||
{ required: true, message: '请输入域名', trigger: 'blur' },
|
||||
{
|
||||
pattern: /^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,6}$/,
|
||||
message: '请输入有效的域名格式',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// 数据加载和分页相关
|
||||
const loading = ref(false)
|
||||
const total = ref(0)
|
||||
const domainList = ref([])
|
||||
const selectedRows = ref([])
|
||||
const dialogVisible = ref(false)
|
||||
const domainFormRef = ref(null)
|
||||
|
||||
// 获取域名列表数据
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const params = {
|
||||
page: queryParams.pageNum,
|
||||
count: queryParams.pageSize,
|
||||
key_word: queryParams.domain
|
||||
}
|
||||
|
||||
const res = await getDomainList(params)
|
||||
domainList.value = res.data.data
|
||||
total.value = res.data.all_count
|
||||
} catch (error) {
|
||||
console.error('获取域名列表失败:', error)
|
||||
ElMessage.error('获取域名列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 查询按钮
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNum = 1
|
||||
|
||||
getList()
|
||||
}
|
||||
|
||||
// 重置查询条件
|
||||
const resetQuery = () => {
|
||||
queryParams.domain = ''
|
||||
queryParams.dateRange = []
|
||||
queryParams.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
// 表格复选框选择
|
||||
const handleSelectionChange = (selection) => {
|
||||
selectedRows.value = selection
|
||||
}
|
||||
|
||||
// 分页大小变化处理
|
||||
const handleSizeChange = (size) => {
|
||||
queryParams.pageSize = size
|
||||
getList()
|
||||
}
|
||||
|
||||
// 分页页码变化处理
|
||||
const handleCurrentChange = (page) => {
|
||||
queryParams.pageNum = page
|
||||
getList()
|
||||
}
|
||||
|
||||
// 打开添加域名对话框
|
||||
const handleAdd = () => {
|
||||
domainForm.domain = ''
|
||||
dialogVisible.value = true
|
||||
// 下一帧等DOM渲染后获取表单ref
|
||||
setTimeout(() => {
|
||||
if (domainFormRef.value) {
|
||||
domainFormRef.value.resetFields()
|
||||
}
|
||||
}, 0)
|
||||
}
|
||||
|
||||
// 提交添加域名表单
|
||||
const submitForm = () => {
|
||||
if (!domainFormRef.value) return
|
||||
|
||||
domainFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
await addDomain({ domain: domainForm.domain })
|
||||
ElMessage.success('添加域名成功')
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
} catch (error) {
|
||||
console.error('添加域名失败:', error)
|
||||
ElMessage.error('添加域名失败')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const parseCreatedAt = (item) => {
|
||||
return item.CreatedAt.replace('T', ' ').substring(0, 19)
|
||||
}
|
||||
|
||||
const parseUpdatedAt = (item) => {
|
||||
return item.UpdatedAt.replace('T', ' ').substring(0, 19)
|
||||
}
|
||||
// 删除单个域名
|
||||
const handleDelete = (row) => {
|
||||
ElMessageBox.confirm(`确认删除域名 ${row.domain} 吗?`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
await deleteDomain(row.Id)
|
||||
ElMessage.success('删除成功')
|
||||
getList()
|
||||
} catch (error) {
|
||||
console.error('删除域名失败:', error)
|
||||
ElMessage.error('删除失败')
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 批量删除域名
|
||||
const handleBatchDelete = () => {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请选择要删除的域名')
|
||||
return
|
||||
}
|
||||
|
||||
const ids = selectedRows.value.map(item => item.Id)
|
||||
const domains = selectedRows.value.map(item => item.domain).join('、')
|
||||
|
||||
ElMessageBox.confirm(`确认删除以下域名吗?\n${domains}`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
try {
|
||||
await batchDeleteDomain(ids)
|
||||
ElMessage.success('批量删除成功')
|
||||
getList()
|
||||
} catch (error) {
|
||||
console.error('批量删除域名失败:', error)
|
||||
ElMessage.error('批量删除失败')
|
||||
}
|
||||
await batchDeleteDomain(ids)
|
||||
ElMessage.success('批量删除成功')
|
||||
getList()
|
||||
} catch (error) {
|
||||
console.error('批量删除域名失败:', error)
|
||||
ElMessage.error('批量删除失败')
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.domain-whitelist-container {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.filter-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin-top: 15px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,395 @@
|
||||
<template>
|
||||
<div class="operation-log">
|
||||
<!-- 搜索和操作栏 -->
|
||||
<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.operator" placeholder="请输入操作人" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="操作类型">
|
||||
<el-select v-model="queryParams.type" placeholder="请选择操作类型" clearable>
|
||||
<el-option label="登录" value="login" />
|
||||
<el-option label="新增" value="create" />
|
||||
<el-option label="修改" value="update" />
|
||||
<el-option label="删除" value="delete" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作时间">
|
||||
<el-date-picker
|
||||
v-model="queryParams.dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="action-bar">
|
||||
<el-button type="success">
|
||||
<el-icon><upload /></el-icon>导入
|
||||
</el-button>
|
||||
<el-button type="primary" @click="handleExport">
|
||||
<el-icon><download /></el-icon>导出
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 日志列表 -->
|
||||
<el-card class="table-container" shadow="never">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="logList"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column prop="id" label="ID" width="80" />
|
||||
<el-table-column label="操作人" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<div class="operator-info">
|
||||
<el-avatar :size="32" :src="row.avatar"></el-avatar>
|
||||
<div class="operator-detail">
|
||||
<div class="username">{{ row.operator }}</div>
|
||||
<div class="ip">{{ row.ip }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="操作类型" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getTypeTag(row.type)">{{ getTypeText(row.type) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="description" label="操作描述" min-width="200" />
|
||||
<el-table-column prop="createTime" label="操作时间" width="180" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="handleDetail(row)">详情</el-button>
|
||||
</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="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
background
|
||||
class="pagination"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- 详情对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
title="操作日志详情"
|
||||
width="580px"
|
||||
append-to-body
|
||||
>
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="操作人">{{ detailData.operator }}</el-descriptions-item>
|
||||
<el-descriptions-item label="操作类型">
|
||||
<el-tag :type="getTypeTag(detailData.type)">{{ getTypeText(detailData.type) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="操作描述">{{ detailData.description }}</el-descriptions-item>
|
||||
<el-descriptions-item label="IP地址">{{ detailData.ip }}</el-descriptions-item>
|
||||
<el-descriptions-item label="操作时间">{{ detailData.createTime }}</el-descriptions-item>
|
||||
<el-descriptions-item label="请求参数" v-if="detailData.params">
|
||||
<pre class="params">{{ JSON.stringify(detailData.params, null, 2) }}</pre>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">关闭</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Upload, Download } from '@element-plus/icons-vue'
|
||||
|
||||
// 查询参数
|
||||
const queryParams = reactive({
|
||||
operator: '',
|
||||
type: '',
|
||||
dateRange: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
|
||||
// 日志列表数据
|
||||
const logList = ref([
|
||||
{
|
||||
id: 1,
|
||||
operator: 'admin',
|
||||
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
type: 'login',
|
||||
description: '用户登录系统',
|
||||
ip: '127.0.0.1',
|
||||
createTime: '2024-03-20 10:00:00',
|
||||
params: {
|
||||
username: 'admin',
|
||||
loginTime: '2024-03-20 10:00:00'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
operator: 'admin',
|
||||
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
type: 'create',
|
||||
description: '创建新用户',
|
||||
ip: '127.0.0.1',
|
||||
createTime: '2024-03-20 11:00:00',
|
||||
params: {
|
||||
username: 'test',
|
||||
role: '测试人员'
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
// 分页相关
|
||||
const loading = ref(false)
|
||||
const total = ref(100)
|
||||
const dialogVisible = ref(false)
|
||||
const detailData = ref({})
|
||||
|
||||
// 获取操作类型标签样式
|
||||
const getTypeTag = (type) => {
|
||||
const typeMap = {
|
||||
login: 'success',
|
||||
create: 'primary',
|
||||
update: 'warning',
|
||||
delete: 'danger'
|
||||
}
|
||||
return typeMap[type] || 'info'
|
||||
}
|
||||
|
||||
// 获取操作类型文本
|
||||
const getTypeText = (type) => {
|
||||
const typeMap = {
|
||||
login: '登录',
|
||||
create: '新增',
|
||||
update: '修改',
|
||||
delete: '删除'
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
|
||||
// 查询日志列表
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNum = 1
|
||||
getLogList()
|
||||
}
|
||||
|
||||
// 重置查询
|
||||
const resetQuery = () => {
|
||||
Object.assign(queryParams, {
|
||||
operator: '',
|
||||
type: '',
|
||||
dateRange: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
getLogList()
|
||||
}
|
||||
|
||||
// 获取日志列表
|
||||
const getLogList = () => {
|
||||
loading.value = true
|
||||
// TODO: 调用API获取数据
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 导出
|
||||
const handleExport = () => {
|
||||
ElMessage.success('导出成功')
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleDetail = (row) => {
|
||||
detailData.value = row
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
// 分页大小改变
|
||||
const handleSizeChange = (size) => {
|
||||
queryParams.pageSize = size
|
||||
getLogList()
|
||||
}
|
||||
|
||||
// 页码改变
|
||||
const handleCurrentChange = (page) => {
|
||||
queryParams.pageNum = page
|
||||
getLogList()
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getLogList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.operation-log {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.filter-container {
|
||||
margin-bottom: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
/* 表格样式优化 */
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
background-color: #f8f9fb !important;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
height: 50px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
:deep(.el-table--striped .el-table__body tr.el-table__row--striped td) {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
:deep(.el-table__body tr:hover > td) {
|
||||
background-color: #f1f5f9 !important;
|
||||
}
|
||||
|
||||
:deep(.el-table__body tr) {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.operator-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.operator-detail {
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 4px;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.ip {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
/* 分页样式优化 */
|
||||
.pagination {
|
||||
margin-top: 24px;
|
||||
justify-content: flex-end;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
:deep(.el-pagination) {
|
||||
--el-pagination-hover-color: #1f2937;
|
||||
}
|
||||
|
||||
:deep(.el-pagination button:disabled) {
|
||||
background-color: #f1f5f9;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pager li) {
|
||||
border-radius: 4px;
|
||||
margin: 0 2px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pager li.active) {
|
||||
background-color: #1f2937;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pager li:hover:not(.active)) {
|
||||
background-color: #f1f5f9;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.params {
|
||||
background-color: #f8f9fb;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
font-family: monospace;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 响应式优化 */
|
||||
@media (max-width: 768px) {
|
||||
.el-form-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.action-bar .el-button {
|
||||
width: 100%;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
padding: 8px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,578 @@
|
||||
<template>
|
||||
<div class="users-container">
|
||||
<!-- 搜索和操作栏 -->
|
||||
<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.username" placeholder="请输入用户名" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
||||
<el-option label="启用" value="1" />
|
||||
<el-option label="禁用" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间">
|
||||
<el-date-picker
|
||||
v-model="queryParams.dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="action-bar">
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<el-icon><plus /></el-icon>新增用户
|
||||
</el-button>
|
||||
<el-button type="danger" :disabled="!selectedRows.length" @click="handleBatchDelete">
|
||||
<el-icon><delete /></el-icon>批量删除
|
||||
</el-button>
|
||||
<el-button type="success">
|
||||
<el-icon><upload /></el-icon>导入
|
||||
</el-button>
|
||||
<el-button>
|
||||
<el-icon><download /></el-icon>导出
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 用户列表 -->
|
||||
<el-card class="table-container" shadow="never">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="userList"
|
||||
@selection-change="handleSelectionChange"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="id" label="ID" width="80" />
|
||||
<el-table-column label="用户信息" min-width="250">
|
||||
<template #default="{ row }">
|
||||
<div class="user-info">
|
||||
<el-avatar :size="40" :src="row.avatar"></el-avatar>
|
||||
<div class="user-detail">
|
||||
<div class="username">{{ row.username }}</div>
|
||||
<div class="email">{{ row.email }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="role" label="角色" />
|
||||
<el-table-column prop="phone" label="手机号码" />
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
v-model="row.status"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
@change="(val) => handleStatusChange(row, val)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" width="180" />
|
||||
<el-table-column label="操作" width="180" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button type="primary" link @click="handleRoleAssign(row)">分配角色</el-button>
|
||||
<el-button type="danger" link @click="handleDelete(row)">删除</el-button>
|
||||
</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="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
background
|
||||
class="pagination"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- 用户表单对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogType === 'add' ? '新增用户' : '编辑用户'"
|
||||
width="580px"
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="userFormRef"
|
||||
:model="userForm"
|
||||
:rules="userRules"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="userForm.username" placeholder="请输入用户名" />
|
||||
</el-form-item>
|
||||
<el-form-item label="昵称" prop="nickname">
|
||||
<el-input v-model="userForm.nickname" placeholder="请输入昵称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="phone">
|
||||
<el-input v-model="userForm.phone" placeholder="请输入手机号码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="userForm.email" placeholder="请输入邮箱" />
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="roleIds">
|
||||
<el-select
|
||||
v-model="userForm.roleIds"
|
||||
placeholder="请选择角色"
|
||||
multiple
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in roleOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="userForm.status">
|
||||
<el-radio :label="1">启用</el-radio>
|
||||
<el-radio :label="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="userForm.remark"
|
||||
type="textarea"
|
||||
placeholder="请输入备注"
|
||||
:rows="3"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Delete, Upload, Download } from '@element-plus/icons-vue'
|
||||
|
||||
// 查询参数
|
||||
const queryParams = reactive({
|
||||
username: '',
|
||||
status: '',
|
||||
dateRange: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
|
||||
// 用户表单
|
||||
const userForm = reactive({
|
||||
id: undefined,
|
||||
username: '',
|
||||
nickname: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
roleIds: [],
|
||||
status: 1,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
// 表单规则
|
||||
const userRules = {
|
||||
username: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
{ min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }
|
||||
],
|
||||
nickname: [
|
||||
{ required: true, message: '请输入昵称', trigger: 'blur' }
|
||||
],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号码', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
|
||||
],
|
||||
email: [
|
||||
{ required: true, message: '请输入邮箱地址', trigger: 'blur' },
|
||||
{ type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
// 角色选项
|
||||
const roleOptions = ref([
|
||||
{ id: 1, name: '管理员' },
|
||||
{ id: 2, name: '测试员' },
|
||||
{ id: 3, name: '普通用户' },
|
||||
{ id: 4, name: '访客' }
|
||||
])
|
||||
|
||||
// 其他状态数据
|
||||
const loading = ref(false)
|
||||
const userList = ref([])
|
||||
const total = ref(0)
|
||||
const selectedRows = ref([])
|
||||
const dialogVisible = ref(false)
|
||||
const dialogType = ref('add') // 'add' 或 'edit'
|
||||
const userFormRef = ref(null)
|
||||
|
||||
// 模拟获取用户列表
|
||||
const getUserList = () => {
|
||||
loading.value = true
|
||||
// 模拟API请求
|
||||
setTimeout(() => {
|
||||
userList.value = [
|
||||
{
|
||||
id: 1,
|
||||
username: 'admin',
|
||||
nickname: '管理员',
|
||||
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
email: 'admin@example.com',
|
||||
phone: '13800138000',
|
||||
role: '超级管理员',
|
||||
status: 1,
|
||||
createTime: '2024-06-01 10:00:00'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
username: 'test',
|
||||
nickname: '测试用户',
|
||||
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
email: 'test@example.com',
|
||||
phone: '13800138001',
|
||||
role: '测试人员',
|
||||
status: 1,
|
||||
createTime: '2024-06-02 14:23:10'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
username: 'zhangsan',
|
||||
nickname: '张三',
|
||||
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
email: 'zhangsan@example.com',
|
||||
phone: '13800138002',
|
||||
role: '普通用户',
|
||||
status: 0,
|
||||
createTime: '2024-06-03 08:15:30'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
username: 'lisi',
|
||||
nickname: '李四',
|
||||
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
email: 'lisi@example.com',
|
||||
phone: '13800138003',
|
||||
role: '普通用户',
|
||||
status: 1,
|
||||
createTime: '2024-06-03 16:42:50'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
username: 'wangwu',
|
||||
nickname: '王五',
|
||||
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
email: 'wangwu@example.com',
|
||||
phone: '13800138004',
|
||||
role: '访客',
|
||||
status: 1,
|
||||
createTime: '2024-06-04 09:30:15'
|
||||
}
|
||||
]
|
||||
total.value = 5
|
||||
loading.value = false
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 查询用户列表
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNum = 1
|
||||
getUserList()
|
||||
}
|
||||
|
||||
// 重置查询
|
||||
const resetQuery = () => {
|
||||
Object.assign(queryParams, {
|
||||
username: '',
|
||||
status: '',
|
||||
dateRange: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
getUserList()
|
||||
}
|
||||
|
||||
// 选择项变化
|
||||
const handleSelectionChange = (selection) => {
|
||||
selectedRows.value = selection
|
||||
}
|
||||
|
||||
// 分页大小变化
|
||||
const handleSizeChange = (size) => {
|
||||
queryParams.pageSize = size
|
||||
getUserList()
|
||||
}
|
||||
|
||||
// 分页页码变化
|
||||
const handleCurrentChange = (page) => {
|
||||
queryParams.pageNum = page
|
||||
getUserList()
|
||||
}
|
||||
|
||||
// 新增用户
|
||||
const handleAdd = () => {
|
||||
dialogType.value = 'add'
|
||||
dialogVisible.value = true
|
||||
// 重置表单
|
||||
Object.assign(userForm, {
|
||||
id: undefined,
|
||||
username: '',
|
||||
nickname: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
roleIds: [],
|
||||
status: 1,
|
||||
remark: ''
|
||||
})
|
||||
// 重置表单校验结果
|
||||
if (userFormRef.value) {
|
||||
userFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑用户
|
||||
const handleEdit = (row) => {
|
||||
dialogType.value = 'edit'
|
||||
dialogVisible.value = true
|
||||
// 填充表单数据
|
||||
Object.assign(userForm, {
|
||||
id: row.id,
|
||||
username: row.username,
|
||||
nickname: row.nickname,
|
||||
phone: row.phone,
|
||||
email: row.email,
|
||||
roleIds: [1], // 假设已有角色
|
||||
status: row.status,
|
||||
remark: row.remark || ''
|
||||
})
|
||||
// 重置表单校验结果
|
||||
if (userFormRef.value) {
|
||||
userFormRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
const handleDelete = (row) => {
|
||||
ElMessageBox.confirm(`确认删除用户 ${row.username} 吗?`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 执行删除操作
|
||||
ElMessage.success('删除成功')
|
||||
getUserList()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
const handleBatchDelete = () => {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请至少选择一条记录')
|
||||
return
|
||||
}
|
||||
ElMessageBox.confirm(`确认删除选中的 ${selectedRows.value.length} 条用户记录吗?`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 执行批量删除操作
|
||||
ElMessage.success('批量删除成功')
|
||||
getUserList()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 分配角色
|
||||
const handleRoleAssign = (row) => {
|
||||
ElMessage.info(`为用户 ${row.username} 分配角色功能待实现`)
|
||||
}
|
||||
|
||||
// 修改用户状态
|
||||
const handleStatusChange = (row, status) => {
|
||||
ElMessage.success(`修改用户 ${row.username} 状态为 ${status === 1 ? '启用' : '禁用'} 成功`)
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = () => {
|
||||
userFormRef.value?.validate((valid) => {
|
||||
if (valid) {
|
||||
if (dialogType.value === 'add') {
|
||||
// 新增用户
|
||||
ElMessage.success('新增用户成功')
|
||||
} else {
|
||||
// 修改用户
|
||||
ElMessage.success('修改用户成功')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
getUserList()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getUserList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.users-container {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.filter-container {
|
||||
margin-bottom: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
/* 表格样式优化 */
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
background-color: #f8f9fb !important;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
height: 50px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
:deep(.el-table--striped .el-table__body tr.el-table__row--striped td) {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
:deep(.el-table__body tr:hover > td) {
|
||||
background-color: #f1f5f9 !important;
|
||||
}
|
||||
|
||||
:deep(.el-table__body tr) {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.user-detail {
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 4px;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.email {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
/* 分页样式优化 */
|
||||
.pagination {
|
||||
margin-top: 24px;
|
||||
justify-content: flex-end;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
:deep(.el-pagination) {
|
||||
--el-pagination-hover-color: #1f2937;
|
||||
}
|
||||
|
||||
:deep(.el-pagination button:disabled) {
|
||||
background-color: #f1f5f9;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pager li) {
|
||||
border-radius: 4px;
|
||||
margin: 0 2px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pager li.active) {
|
||||
background-color: #1f2937;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pager li:hover:not(.active)) {
|
||||
background-color: #f1f5f9;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* 响应式优化 */
|
||||
@media (max-width: 768px) {
|
||||
.el-form-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.action-bar .el-button {
|
||||
width: 100%;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
padding: 8px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
+6
-1
@@ -1,7 +1,12 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
import { resolve } from 'path'
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src')
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user