Skip to content

Commit c8cae1b

Browse files
committed
升级了部分功能
1 parent f70c937 commit c8cae1b

17 files changed

+1971
-245
lines changed

components.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ declare module '@vue/runtime-core' {
1515
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
1616
ElCol: typeof import('element-plus/es')['ElCol']
1717
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
18+
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
19+
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
1820
ElDialog: typeof import('element-plus/es')['ElDialog']
1921
ElDropdown: typeof import('element-plus/es')['ElDropdown']
2022
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
@@ -48,6 +50,8 @@ declare module '@vue/runtime-core' {
4850
RouterLink: typeof import('vue-router')['RouterLink']
4951
RouterView: typeof import('vue-router')['RouterView']
5052
Sidebar: typeof import('./src/components/sidebar.vue')['default']
53+
TableDetail: typeof import('./src/components/table-detail.vue')['default']
54+
TableEdit: typeof import('./src/components/table-edit.vue')['default']
5155
Tags: typeof import('./src/components/tags.vue')['default']
5256
}
5357
}

index.html

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
<!DOCTYPE html>
2-
<html lang="">
3-
4-
<head>
5-
<meta charset="utf-8">
6-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
8-
<title>vue-manage-system</title>
9-
<link rel="stylesheet" href="https://at.alicdn.com/t/font_830376_qzecyukz0s.css">
10-
</head>
11-
12-
<body>
13-
<noscript>
14-
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
15-
Please enable it to continue.</strong>
16-
</noscript>
17-
<div id="app"></div>
18-
<script type="module" src="/src/main.ts"></script>
19-
<!-- built files will be auto injected -->
20-
</body>
21-
1+
<!DOCTYPE html>
2+
<html lang="">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
8+
<title>vue-manage-system后台管理系统</title>
9+
<link rel="stylesheet" href="https://at.alicdn.com/t/font_830376_qzecyukz0s.css">
10+
</head>
11+
12+
<body>
13+
<noscript>
14+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
15+
Please enable it to continue.</strong>
16+
</noscript>
17+
<div id="app"></div>
18+
<script type="module" src="/src/main.ts"></script>
19+
<!-- built files will be auto injected -->
20+
</body>
21+
2222
</html>

package.json

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{
22
"name": "vue-manage-system",
3-
"version": "5.3.0",
3+
"version": "5.3.5",
44
"private": true,
55
"scripts": {
66
"dev": "vite",
77
"build": "vue-tsc --noEmit && vite build",
88
"serve": "vite preview"
99
},
1010
"dependencies": {
11-
"@element-plus/icons-vue": "^2.0.9",
12-
"axios": "^0.27.2",
13-
"element-plus": "^2.2.14",
14-
"md-editor-v3": "^2.2.1",
15-
"pinia": "^2.0.20",
16-
"vue": "^3.2.37",
11+
"@element-plus/icons-vue": "*",
12+
"@wangeditor/editor": "^5.1.23",
13+
"@wangeditor/editor-for-vue": "^5.1.12",
14+
"axios": "^1.6.3",
15+
"element-plus": "^2.4.4",
16+
"md-editor-v3": "^2.11.2",
17+
"nprogress": "^0.2.0",
18+
"pinia": "^2.1.7",
19+
"vue": "^3.3.0",
1720
"vue-cropperjs": "^5.0.0",
18-
"vue-router": "^4.1.3",
21+
"vue-router": "^4.2.5",
1922
"vue-schart": "^2.0.0",
20-
"wangeditor": "^4.7.15",
2123
"xlsx": "^0.18.5"
2224
},
2325
"devDependencies": {

src/App.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
2-
<el-config-provider :locale="zhCn">
3-
<router-view />
4-
</el-config-provider>
2+
<el-config-provider :locale="zhCn">
3+
<router-view />
4+
</el-config-provider>
55
</template>
66

77
<script setup lang="ts">
@@ -10,5 +10,5 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn';
1010
</script>
1111
<style>
1212
@import './assets/css/main.css';
13-
@import './assets/css/color-dark.css';
13+
@import './assets/css/color-dark.scss';
1414
</style>

src/api/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import request from '../utils/request';
22

33
export const fetchData = () => {
44
return request({
5-
url: './table.json',
6-
method: 'get'
5+
url: 'https://www.fastmock.site/mock/dc695d037038802def4b989ba4650c3f/vms/getUser',
6+
method: 'post'
77
});
88
};

src/assets/css/color-dark.css renamed to src/assets/css/color-dark.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
background: #eef1f6;
99
}
1010
.plugins-tips a{
11-
color: #20a0ff;
11+
color: var(--el-color-primary);
1212
}
1313

1414
.tags-li.active {
15-
border: 1px solid #409EFF;
16-
background-color: #409EFF;
15+
border: 1px solid var(--el-color-primary);
16+
background-color: var(--el-color-primary);
1717
}
1818
.message-title{
19-
color: #20a0ff;
19+
color: var(--el-color-primary);
2020
}
2121
.collapse-btn:hover{
2222
background: rgb(40,52,70);

src/assets/css/main.css

-5
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ a {
7474
margin-left: 10px;
7575
}
7676

77-
.el-table tr:hover {
78-
background: #f6faff;
79-
}
80-
8177
.mgb20 {
8278
margin-bottom: 20px;
8379
}
@@ -113,7 +109,6 @@ a {
113109

114110

115111
[class*=" el-icon-"], [class^=el-icon-] {
116-
speak: none;
117112
font-style: normal;
118113
font-weight: 400;
119114
font-variant: normal;

src/components/table-detail.vue

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<template>
2+
<el-descriptions title="" :column="2" border>
3+
<el-descriptions-item>
4+
<template #label> 用户ID </template>
5+
{{ data.id }}
6+
</el-descriptions-item>
7+
<el-descriptions-item>
8+
<template #label> 用户名 </template>
9+
{{ data.name }}
10+
</el-descriptions-item>
11+
<el-descriptions-item>
12+
<template #label> 账户余额 </template>
13+
{{ data.money }}
14+
</el-descriptions-item>
15+
<el-descriptions-item>
16+
<template #label> 账户状态 </template>
17+
{{ data.state ? '正常' : '异常' }}
18+
</el-descriptions-item>
19+
<el-descriptions-item :span="2">
20+
<template #label> 地址 </template>
21+
{{ data.address }}
22+
</el-descriptions-item>
23+
<el-descriptions-item>
24+
<template #label> 日期 </template>
25+
{{ data.date }}
26+
</el-descriptions-item>
27+
<el-descriptions-item>
28+
<template #label> 头像 </template>
29+
<img :src="data.thumb" style="width: 120px" alt="" />
30+
</el-descriptions-item>
31+
</el-descriptions>
32+
</template>
33+
34+
<script lang="ts" setup>
35+
const props = defineProps({
36+
data: {
37+
type: Object,
38+
required: true
39+
}
40+
});
41+
</script>

src/components/table-edit.vue

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<template>
2+
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
3+
<el-form-item label="用户名" prop="name">
4+
<el-input v-model="form.name"></el-input>
5+
</el-form-item>
6+
<el-form-item label="账户余额" prop="money">
7+
<el-input v-model.number="form.money"></el-input>
8+
</el-form-item>
9+
<el-form-item label="地址" prop="address">
10+
<el-input v-model="form.address"></el-input>
11+
</el-form-item>
12+
<el-form-item label="账户状态" prop="state">
13+
<el-switch
14+
v-model="form.state"
15+
:active-value="1"
16+
:inactive-value="0"
17+
active-text="正常"
18+
inactive-text="异常"
19+
></el-switch>
20+
</el-form-item>
21+
<el-form-item label="注册日期" prop="date">
22+
<el-date-picker type="date" v-model="form.date" value-format="YYYY-MM-DD"></el-date-picker>
23+
</el-form-item>
24+
<el-form-item label="上传头像" prop="thumb">
25+
<el-upload
26+
class="avatar-uploader"
27+
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
28+
:show-file-list="false"
29+
:on-success="handleAvatarSuccess"
30+
:before-upload="beforeAvatarUpload"
31+
>
32+
<img v-if="form.thumb" :src="form.thumb" class="avatar" />
33+
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
34+
</el-upload>
35+
</el-form-item>
36+
<el-form-item>
37+
<el-button type="primary" @click="saveEdit(formRef)">保 存</el-button>
38+
</el-form-item>
39+
</el-form>
40+
</template>
41+
42+
<script lang="ts" setup>
43+
import { ElMessage, FormInstance, FormRules, UploadProps } from 'element-plus';
44+
import { ref } from 'vue';
45+
46+
const props = defineProps({
47+
data: {
48+
type: Object,
49+
required: true
50+
},
51+
edit: {
52+
type: Boolean,
53+
required: false
54+
},
55+
update: {
56+
type: Function,
57+
required: true
58+
}
59+
});
60+
61+
const defaultData = {
62+
id: '',
63+
name: '',
64+
address: '',
65+
thumb: '',
66+
money: 0,
67+
state: 0,
68+
date: new Date()
69+
};
70+
71+
const form = ref({ ...(props.edit ? props.data : defaultData) });
72+
73+
const rules: FormRules = {
74+
name: [{ required: true, message: '用户名', trigger: 'blur' }]
75+
};
76+
const formRef = ref<FormInstance>();
77+
const saveEdit = (formEl: FormInstance | undefined) => {
78+
if (!formEl) return;
79+
formEl.validate(valid => {
80+
if (!valid) return false;
81+
props.update(form.value);
82+
ElMessage.success('保存成功!');
83+
});
84+
};
85+
86+
const handleAvatarSuccess: UploadProps['onSuccess'] = (response, uploadFile) => {
87+
form.value.thumb = URL.createObjectURL(uploadFile.raw!);
88+
};
89+
90+
const beforeAvatarUpload: UploadProps['beforeUpload'] = rawFile => {
91+
if (rawFile.type !== 'image/jpeg') {
92+
ElMessage.error('Avatar picture must be JPG format!');
93+
return false;
94+
} else if (rawFile.size / 1024 / 1024 > 2) {
95+
ElMessage.error('Avatar picture size can not exceed 2MB!');
96+
return false;
97+
}
98+
return true;
99+
};
100+
</script>
101+
102+
<style>
103+
.avatar-uploader .el-upload {
104+
border: 1px dashed var(--el-border-color);
105+
border-radius: 6px;
106+
cursor: pointer;
107+
position: relative;
108+
overflow: hidden;
109+
transition: var(--el-transition-duration-fast);
110+
}
111+
112+
.avatar-uploader .el-upload:hover {
113+
border-color: var(--el-color-primary);
114+
}
115+
116+
.el-icon.avatar-uploader-icon {
117+
font-size: 28px;
118+
color: #8c939d;
119+
width: 178px;
120+
height: 178px;
121+
text-align: center;
122+
}
123+
</style>

src/router/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
22
import { usePermissStore } from '../store/permiss';
33
import Home from '../views/home.vue';
4+
import NProgress from 'nprogress'
5+
import 'nprogress/nprogress.css'
46

57
const routes: RouteRecordRaw[] = [
68
{
@@ -163,7 +165,7 @@ const router = createRouter({
163165
});
164166

165167
router.beforeEach((to, from, next) => {
166-
document.title = `${to.meta.title} | vue-manage-system`;
168+
NProgress.start();
167169
const role = localStorage.getItem('ms_username');
168170
const permiss = usePermissStore();
169171
if (!role && to.path !== '/login') {
@@ -176,4 +178,8 @@ router.beforeEach((to, from, next) => {
176178
}
177179
});
178180

181+
router.afterEach(() => {
182+
NProgress.done()
183+
})
184+
179185
export default router;

src/utils/request.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import axios, {AxiosInstance, AxiosError, AxiosResponse, AxiosRequestConfig} from 'axios';
1+
import axios, { AxiosInstance, AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
22

3-
const service:AxiosInstance = axios.create({
3+
const service: AxiosInstance = axios.create({
44
timeout: 5000
55
});
66

77
service.interceptors.request.use(
8-
(config: AxiosRequestConfig) => {
8+
(config: InternalAxiosRequestConfig) => {
99
return config;
1010
},
1111
(error: AxiosError) => {

0 commit comments

Comments
 (0)