Skip to content

Commit

Permalink
升级了部分功能
Browse files Browse the repository at this point in the history
  • Loading branch information
lin-xin committed Jan 6, 2024
1 parent f70c937 commit c8cae1b
Show file tree
Hide file tree
Showing 17 changed files with 1,971 additions and 245 deletions.
4 changes: 4 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ declare module '@vue/runtime-core' {
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
ElCol: typeof import('element-plus/es')['ElCol']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
Expand Down Expand Up @@ -48,6 +50,8 @@ declare module '@vue/runtime-core' {
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Sidebar: typeof import('./src/components/sidebar.vue')['default']
TableDetail: typeof import('./src/components/table-detail.vue')['default']
TableEdit: typeof import('./src/components/table-edit.vue')['default']
Tags: typeof import('./src/components/tags.vue')['default']
}
}
42 changes: 21 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<!DOCTYPE html>
<html lang="">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>vue-manage-system</title>
<link rel="stylesheet" href="https://at.alicdn.com/t/font_830376_qzecyukz0s.css">
</head>

<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<!-- built files will be auto injected -->
</body>

<!DOCTYPE html>
<html lang="">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>vue-manage-system后台管理系统</title>
<link rel="stylesheet" href="https://at.alicdn.com/t/font_830376_qzecyukz0s.css">
</head>

<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<!-- built files will be auto injected -->
</body>

</html>
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{
"name": "vue-manage-system",
"version": "5.3.0",
"version": "5.3.5",
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.0.9",
"axios": "^0.27.2",
"element-plus": "^2.2.14",
"md-editor-v3": "^2.2.1",
"pinia": "^2.0.20",
"vue": "^3.2.37",
"@element-plus/icons-vue": "*",
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.12",
"axios": "^1.6.3",
"element-plus": "^2.4.4",
"md-editor-v3": "^2.11.2",
"nprogress": "^0.2.0",
"pinia": "^2.1.7",
"vue": "^3.3.0",
"vue-cropperjs": "^5.0.0",
"vue-router": "^4.1.3",
"vue-router": "^4.2.5",
"vue-schart": "^2.0.0",
"wangeditor": "^4.7.15",
"xlsx": "^0.18.5"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<el-config-provider :locale="zhCn">
<router-view />
</el-config-provider>
<el-config-provider :locale="zhCn">
<router-view />
</el-config-provider>
</template>

<script setup lang="ts">
Expand All @@ -10,5 +10,5 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn';
</script>
<style>
@import './assets/css/main.css';
@import './assets/css/color-dark.css';
@import './assets/css/color-dark.scss';
</style>
4 changes: 2 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import request from '../utils/request';

export const fetchData = () => {
return request({
url: './table.json',
method: 'get'
url: 'https://www.fastmock.site/mock/dc695d037038802def4b989ba4650c3f/vms/getUser',
method: 'post'
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
background: #eef1f6;
}
.plugins-tips a{
color: #20a0ff;
color: var(--el-color-primary);
}

.tags-li.active {
border: 1px solid #409EFF;
background-color: #409EFF;
border: 1px solid var(--el-color-primary);
background-color: var(--el-color-primary);
}
.message-title{
color: #20a0ff;
color: var(--el-color-primary);
}
.collapse-btn:hover{
background: rgb(40,52,70);
Expand Down
5 changes: 0 additions & 5 deletions src/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ a {
margin-left: 10px;
}

.el-table tr:hover {
background: #f6faff;
}

.mgb20 {
margin-bottom: 20px;
}
Expand Down Expand Up @@ -113,7 +109,6 @@ a {


[class*=" el-icon-"], [class^=el-icon-] {
speak: none;
font-style: normal;
font-weight: 400;
font-variant: normal;
Expand Down
41 changes: 41 additions & 0 deletions src/components/table-detail.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<el-descriptions title="" :column="2" border>
<el-descriptions-item>
<template #label> 用户ID </template>
{{ data.id }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> 用户名 </template>
{{ data.name }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> 账户余额 </template>
{{ data.money }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> 账户状态 </template>
{{ data.state ? '正常' : '异常' }}
</el-descriptions-item>
<el-descriptions-item :span="2">
<template #label> 地址 </template>
{{ data.address }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> 日期 </template>
{{ data.date }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> 头像 </template>
<img :src="data.thumb" style="width: 120px" alt="" />
</el-descriptions-item>
</el-descriptions>
</template>

<script lang="ts" setup>
const props = defineProps({
data: {
type: Object,
required: true
}
});
</script>
123 changes: 123 additions & 0 deletions src/components/table-edit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<template>
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="用户名" prop="name">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="账户余额" prop="money">
<el-input v-model.number="form.money"></el-input>
</el-form-item>
<el-form-item label="地址" prop="address">
<el-input v-model="form.address"></el-input>
</el-form-item>
<el-form-item label="账户状态" prop="state">
<el-switch
v-model="form.state"
:active-value="1"
:inactive-value="0"
active-text="正常"
inactive-text="异常"
></el-switch>
</el-form-item>
<el-form-item label="注册日期" prop="date">
<el-date-picker type="date" v-model="form.date" value-format="YYYY-MM-DD"></el-date-picker>
</el-form-item>
<el-form-item label="上传头像" prop="thumb">
<el-upload
class="avatar-uploader"
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<img v-if="form.thumb" :src="form.thumb" class="avatar" />
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveEdit(formRef)">保 存</el-button>
</el-form-item>
</el-form>
</template>

<script lang="ts" setup>
import { ElMessage, FormInstance, FormRules, UploadProps } from 'element-plus';
import { ref } from 'vue';
const props = defineProps({
data: {
type: Object,
required: true
},
edit: {
type: Boolean,
required: false
},
update: {
type: Function,
required: true
}
});
const defaultData = {
id: '',
name: '',
address: '',
thumb: '',
money: 0,
state: 0,
date: new Date()
};
const form = ref({ ...(props.edit ? props.data : defaultData) });
const rules: FormRules = {
name: [{ required: true, message: '用户名', trigger: 'blur' }]
};
const formRef = ref<FormInstance>();
const saveEdit = (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(valid => {
if (!valid) return false;
props.update(form.value);
ElMessage.success('保存成功!');
});
};
const handleAvatarSuccess: UploadProps['onSuccess'] = (response, uploadFile) => {
form.value.thumb = URL.createObjectURL(uploadFile.raw!);
};
const beforeAvatarUpload: UploadProps['beforeUpload'] = rawFile => {
if (rawFile.type !== 'image/jpeg') {
ElMessage.error('Avatar picture must be JPG format!');
return false;
} else if (rawFile.size / 1024 / 1024 > 2) {
ElMessage.error('Avatar picture size can not exceed 2MB!');
return false;
}
return true;
};
</script>

<style>
.avatar-uploader .el-upload {
border: 1px dashed var(--el-border-color);
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
transition: var(--el-transition-duration-fast);
}
.avatar-uploader .el-upload:hover {
border-color: var(--el-color-primary);
}
.el-icon.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
text-align: center;
}
</style>
8 changes: 7 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import { usePermissStore } from '../store/permiss';
import Home from '../views/home.vue';
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const routes: RouteRecordRaw[] = [
{
Expand Down Expand Up @@ -163,7 +165,7 @@ const router = createRouter({
});

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

router.afterEach(() => {
NProgress.done()
})

export default router;
6 changes: 3 additions & 3 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import axios, {AxiosInstance, AxiosError, AxiosResponse, AxiosRequestConfig} from 'axios';
import axios, { AxiosInstance, AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';

const service:AxiosInstance = axios.create({
const service: AxiosInstance = axios.create({
timeout: 5000
});

service.interceptors.request.use(
(config: AxiosRequestConfig) => {
(config: InternalAxiosRequestConfig) => {
return config;
},
(error: AxiosError) => {
Expand Down
Loading

0 comments on commit c8cae1b

Please sign in to comment.