Skip to content

Commit 734aa21

Browse files
committed
版本更新1.1.1
1 parent fc4d227 commit 734aa21

File tree

18 files changed

+471
-71
lines changed

18 files changed

+471
-71
lines changed

example/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import router from './router';
55
import store from './store';
66
import '@/styles/index.styl';
77

8-
if (process.env.VUE_APP_MOCK) import('@/mock/index');
8+
if (process.env.VUE_APP_MOCK === '1') import('@/mock/index');
99

1010
createApp(App).use(store).use(router).mount('#app');
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import axios from '@/axios/fetch';
2+
import MockPath from '@/mock/mock_api';
3+
4+
const mockpath = new MockPath();
5+
class Api {
6+
VUE_APP_MOCK = process.env.VUE_APP_MOCK === '1'
7+
8+
/**
9+
* 登录接口
10+
* @param data 登录信息
11+
*/
12+
login = (data: unknown) => {
13+
let path = './api/user/login';
14+
if (this.VUE_APP_MOCK) {
15+
path = mockpath.login;
16+
}
17+
return axios
18+
.post(path, data);
19+
}
20+
21+
/**
22+
* 获取用户信息
23+
*/
24+
getByCode = () => axios.post(this.VUE_APP_MOCK ? mockpath.getByCode : './api/user/getByCode', {
25+
code: sessionStorage.code,
26+
})
27+
28+
/**
29+
* 修改用户信息
30+
* @param formData 用户信息
31+
*/
32+
changeUserInfo = (formData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.changeUserName : './api/user/changeUserInfo', formData)
33+
34+
/**
35+
* 创建学生&教师
36+
* @param formData 创建学生&教师
37+
*/
38+
createClassMember = (formData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.createUser : './api/classMember/createClassMember', formData)
39+
40+
/**
41+
* 查询用户列表
42+
* @param searchData 查询条件
43+
*/
44+
queryUserList = (searchData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.getUserList : './api/user/queryUserList', searchData)
45+
46+
/**
47+
* 查询学生列表
48+
* @param searchData
49+
*/
50+
queryStudentList = (searchData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.getStudentList : './api/classMember/listStudent', searchData)
51+
52+
/**
53+
* 重置用户密码
54+
* @param BaseUserCodeRequest code
55+
*/
56+
adminResetPassword = (BaseUserCodeRequest: string) => axios.post(this.VUE_APP_MOCK ? mockpath.resetPassword : './api/user/adminResetPassword', { code: BaseUserCodeRequest })
57+
58+
/**
59+
* 删除学生
60+
* @param formData
61+
*/
62+
delStudent = (formData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.delteStudent : './api/userManage/delStudent', formData)
63+
64+
/**
65+
* 删除教师
66+
* @param formData
67+
*/
68+
delTeacher = (formData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.delteTeacher : './api/userManage/delTeacher', formData)
69+
70+
/**
71+
* 更改个人信息
72+
* @param formData
73+
*/
74+
changeUserSignature = (formData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.changeUserSignatures : './api/user/changeUserSignature', formData)
75+
76+
/**
77+
* 修改密码
78+
* @param formData
79+
*/
80+
changePassword = (formData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.changePasswords : './api/user/changePassword', formData)
81+
82+
/**
83+
* 查询班级列表
84+
* @param searchData
85+
*/
86+
getClassList = (searchData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.getClassList : './api/class/queryClass', searchData)
87+
88+
/**
89+
* 编辑&创建班级
90+
* @param formData
91+
*/
92+
editClassData = (formData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.editClass : './api/class/createOrUpdateClass', formData)
93+
94+
/**
95+
* 删除班级
96+
* @param formData
97+
*/
98+
delClass = (formData: unknown) => axios.post(this.VUE_APP_MOCK ? mockpath.delClass : './api/userManage/delClass', formData)
99+
100+
/**
101+
* 导入学生——没有处理mock
102+
* @param formData
103+
* @param classId 班级id
104+
*/
105+
uploadStudentByClass=(formData: unknown, classId: string) => axios.post(`./api/classMember/insertStudent?classId=${classId}`, formData)
106+
}
107+
108+
export default new Api();

generator/template/src/axios/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ http.interceptors.response.use(
4747
content: response.data.message,
4848
onOk() {
4949
sessionStorage.clear();
50-
window.location.href = '/dcaw';
50+
window.location.href = '/';
5151
},
5252
});
5353
} else if (!response.data.success) {

generator/template/src/components/Teacher/header.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
.navigation-bar(v-else)
1313
.user-profile(ref="userProfile")
1414
a-badge
15-
b-icon(type="bell", :style="{ fontSize: '24px', cursor: 'pointer' }")
15+
b-icon(type="icontongzhi4", :style="{ fontSize: '24px', cursor: 'pointer' }")
1616
a-popover(
1717
placement="bottom",
1818
:getPopupContainer="() => $refs.userProfile"
1919
)
2020
template(#content)
2121
.menu
22-
.menu-item(@click="changePath('/Teacher/userInfo')")
23-
//- b-icon(type="iconzhongzhi", :style="{ fontSize: '16px' }")
22+
.menu-item.align-items-center(@click="changePath('/Teacher/userInfo')")
23+
b-icon(type="iconzhanghao", :style="{ fontSize: '16px' }")
2424
span 个人中心
25-
.menu-item(@click="outLogin")
26-
//- b-icon(type="iconzhongzhi", :style="{ fontSize: '16px' }")
25+
.menu-item.align-items-center(@click="outLogin")
26+
b-icon(type="icontuichu11", :style="{ fontSize: '16px' }")
2727
span 退出账号
2828
.user
2929
a-avatar(shape="square", :size="32", :src="user.headImagePath")
@@ -149,7 +149,7 @@ export default defineComponent({
149149
.user-profile
150150
display flex
151151
align-items center
152-
width 130px
152+
width 124px
153153
justify-content space-between
154154
font-size 14px
155155
font-family MicrosoftYaHeiUI
@@ -166,7 +166,7 @@ export default defineComponent({
166166
.menu
167167
width 120px
168168
padding 0 16px
169-
padding-top 16px
169+
// padding-top 16px
170170
.menu-item
171171
cursor pointer
172172
height 36px

generator/template/src/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import router from './router';
55
import store from './store';
66
import '@/styles/index.styl';
77

8-
if (process.env.VUE_APP_MOCK) {
9-
import('@/mock/index');
10-
console.log(process.env);
11-
}
8+
if (process.env.VUE_APP_MOCK === '1') import('@/mock/index');
129

1310
createApp(App).use(store).use(router).mount('#app');

generator/template/src/mock/demo.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import Mock from 'mockjs';
22

3-
import { getDemoList } from './demo';
4-
53
Mock.setup({
6-
timeout: '500-1000',
4+
timeout: '10-1500',
75
});
86

9-
Mock.mock('mock/demo', 'post', getDemoList);
7+
export default Mock;
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import Mock from './index';
2+
import {
3+
getByCode, login, getStudentList, delteStudent,
4+
getUserList,
5+
resetPassword,
6+
delteTeacher,
7+
changeUserName,
8+
createUser,
9+
} from './modules/user';
10+
import {
11+
getClassList, editClass, delClass, insertStudent,
12+
} from './modules/classe';
13+
import { changeUserSignatures, changePasswords } from './modules/public/userInfo';
14+
15+
export default class MockPath {
16+
login = './mock/user/login';
17+
18+
getByCode = './mock/user/getByCode';
19+
20+
getClassList = './mock/class/queryClass'
21+
22+
editClass = './mock/class/createOrUpdateClass'
23+
24+
delClass = './mock/userManage/delClass'
25+
26+
insertStudent = './mock/classMember/insertStudent'
27+
28+
getUserList = './mock/user/queryUserList'
29+
30+
getStudentList = './mock/classMember/listStudent'
31+
32+
resetPassword = './mock/user/adminResetPassword'
33+
34+
delteTeacher = './mock/userManage/delTeacher'
35+
36+
delteStudent = './mock/userManage/delStudent'
37+
38+
changeUserName = './mock/user/changeUserInfo'
39+
40+
createUser = './mock/classMember/createClassMember'
41+
42+
changeUserSignatures = './mock/user/changeUserSignature'
43+
44+
changePasswords = './mock/user/changePassword'
45+
}
46+
47+
const mockPath = new MockPath();
48+
// 登录模块
49+
Mock.mock(mockPath.login, 'post', login);
50+
Mock.mock(mockPath.getByCode, 'post', getByCode);
51+
52+
// 班级模块
53+
Mock.mock(mockPath.getClassList, 'post', getClassList);
54+
Mock.mock(mockPath.editClass, 'post', editClass);
55+
Mock.mock(mockPath.delClass, 'post', delClass);
56+
Mock.mock(mockPath.insertStudent, 'post', insertStudent);
57+
58+
// 教师列表
59+
Mock.mock(mockPath.getUserList, 'post', getUserList);
60+
// 学生列表
61+
Mock.mock(mockPath.getStudentList, 'post', getStudentList);
62+
// 重置密码
63+
Mock.mock(mockPath.resetPassword, 'post', resetPassword);
64+
// 删除教师
65+
Mock.mock(mockPath.delteTeacher, 'post', delteTeacher);
66+
// 删除学生
67+
Mock.mock(mockPath.delteStudent, 'post', delteStudent);
68+
// 编辑用户姓名
69+
Mock.mock(mockPath.changeUserName, 'post', changeUserName);
70+
// 添加用户
71+
Mock.mock(mockPath.createUser, 'post', createUser);
72+
// 更改个人信息
73+
Mock.mock(mockPath.changeUserSignatures, 'post', changeUserSignatures);
74+
// 修改密码
75+
Mock.mock(mockPath.changePasswords, 'post', changePasswords);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Mock from 'mockjs';
2+
import MockRequest, { AjaxDate } from '../MockRequest';
3+
4+
export function getClassList(data: AjaxDate) {
5+
const { pageNo = 1, pageSize = 15, totalRecords = 100 } = JSON.parse(data.body);
6+
return new MockRequest(
7+
Mock.mock({
8+
[`list|${pageSize}`]: [{
9+
id: '@guid',
10+
name: '@cname 的班级',
11+
stuNum: '@integer(0,100)',
12+
remarks: '@word()',
13+
userNames: '@cname',
14+
teacherCodes: '@name',
15+
}],
16+
pageNo,
17+
totalRecords,
18+
}), '请求成功', true,
19+
);
20+
}
21+
22+
export function editClass(data: AjaxDate) {
23+
const { id } = JSON.parse(data.body);
24+
return new MockRequest(
25+
true, id ? '编辑成功' : '添加成功', true,
26+
);
27+
}
28+
29+
export function delClass(data: AjaxDate) {
30+
const { ids } = JSON.parse(data.body);
31+
return new MockRequest(
32+
ids, '删除成功', true,
33+
);
34+
}
35+
36+
export function insertStudent(data: AjaxDate) {
37+
const ids = JSON.parse(data.body);
38+
return new MockRequest(
39+
ids, '导入成功', true,
40+
);
41+
}
42+
43+
export function test() { return {}; }
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Mock from 'mockjs';
2+
import MockRequest from '../../MockRequest';
3+
4+
function getCode() {
5+
return Mock.mock(
6+
new MockRequest(
7+
{
8+
// 账号
9+
code: '@id',
10+
// 创建时间
11+
createTime: '@datetime',
12+
// 是否禁用
13+
disable: false,
14+
// 头像
15+
headImagePath: "@image('50x50', '#50B347', '#FFF', '头像')",
16+
// 名称
17+
name: '@ctitle(3,5)',
18+
// 个人简介
19+
personalSignature: '@sentence(3, 5)',
20+
// 是否为学生
21+
student: false,
22+
// 是否为管理员
23+
admin: true,
24+
// 是否为教师
25+
teacher: true,
26+
},
27+
null,
28+
true,
29+
),
30+
);
31+
}
32+
33+
function changeUserSignatures() {
34+
return Mock.mock(new MockRequest({}, null, true));
35+
}
36+
function changePasswords() {
37+
return Mock.mock(new MockRequest({}, null, true));
38+
}
39+
40+
export { getCode, changeUserSignatures, changePasswords };

0 commit comments

Comments
 (0)