Skip to content

Commit c6d99f4

Browse files
authored
Feature/page (#235)
* feat: 修改集合返回字段 * fix: 修复post请求重发机制 fix #233 * feat(User): edit nickname * docs(version): 版本更新日志 * feat(user): add group name * Update .env.production
1 parent eff576c commit c6d99f4

File tree

19 files changed

+183
-318
lines changed

19 files changed

+183
-318
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ENV = 'development'
22

3-
VUE_APP_BASE_URL = 'http://koa.lin.colorful3.com/'
3+
VUE_APP_BASE_URL = 'http://localhost:5000/'

.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
VUE_APP_BASE_URL = 'http://dev.lin.colorful3.com'
3+
VUE_APP_BASE_URL = 'http://localhost:5000/'

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,22 @@ QQ群搜索:林间有风 或 643205479
8989

9090
## 版本日志
9191

92-
<<<<<<< HEAD
93-
最新版本 `0.2.0`
92+
最新版本 `0.2.1`
93+
94+
### 0.2.1
95+
96+
1. `A` 新增一键清除 reuse tab
97+
2. `A` 新增侧边导航搜索,可在 config 配置是否启用
98+
3. `F` 修复 post put 等请求不能自动重发问题
99+
4. `U` 优化异常处理,框架默认弹出前端配置异常信息,可通过 handleError 和 showBackend 控制本次请求是否开发者自行处理和是否直接展示后端返回异常信息
100+
5. `C` 登录用户名字段由 nickname -> username,同时新增 nickname 为昵称字段,可以更新昵称(需后端同步修改)
101+
6. `U` 优化了一些移动端适配
102+
7. `C` 列表信息字段由 collection -> items, total_nums -> tatal, 增加 count、page、total_page字段(需后端同步修改)
94103

95104
### 0.2.0
96105

97106
1. `A` 新增图像上传、图像预览、富文本等自定义组件
98107
2. `A` 新增 lin-cms-ui 多个基础组件
99-
=======
100-
最新版本 `0.1.0-beta.3`
101-
>>>>>>> 0b890cda57f1aaa11af9315d031ae15fae4def51
102108

103109
### 0.1.0-beta.3
104110

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "lin-cms",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"private": true,
55
"scripts": {
66
"serve": "node script/plugin-get-config.js && vue-cli-service serve",
77
"build": "node script/plugin-get-config.js && vue-cli-service build",
88
"lint": "vue-cli-service lint",
9-
"commitizen": "commitizen init cz-conventional-changelog --save-dev --save-exact",
9+
"commit": "git-cz",
1010
"plugin-init": "node script/plugin-init.js",
1111
"plugin-new": "node script/plugin-new.js",
1212
"plugin-reconfig": "node script/plugin-get-config.js",

public/iconfont111.css

Lines changed: 0 additions & 201 deletions
This file was deleted.

src/assets/styles/realize/element-variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ thead tr {
429429
}
430430

431431
.el-menu-vertical-demo {
432-
padding-top: 20px;
432+
padding-top: 10px;
433433
border-right: 1px solid #1d2a60;
434434
}
435435

src/components/layout/SideBar.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ export default {
165165
}, 200)
166166
},
167167
search(val) {
168-
if (!val) {
169-
this.showSearchList = false
170-
return
171-
}
168+
// if (!val) {
169+
// this.showSearchList = false
170+
// return
171+
// }
172172
this.groups = []
173173
174174
// 深度遍历配置树, 摘取叶子节点作为路由部分
@@ -331,14 +331,14 @@ export default {
331331
width: 80%;
332332
margin: 0 auto;
333333
height: 36px;
334-
border-bottom: 1px $theme solid;
334+
border-bottom: 1px rgb(185, 190, 195) solid;
335335
cursor: pointer;
336336
337337
.el-icon-search {
338338
position: absolute;
339339
left: 1px;
340340
top: 10px;
341-
color: $theme;
341+
color: rgb(185, 190, 195);
342342
}
343343
}
344344

src/components/layout/User.vue

Lines changed: 75 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,25 @@
1212
<img :src="user.avatar || defaultAvatar" alt="头像">
1313
<label class="mask">
1414
<i class="iconfont icon-icon-test" style="font-size: 20px;"></i>
15-
<input
16-
ref="avatarInput"
17-
type="file"
18-
accept="image/*"
19-
@change="fileChange" />
15+
<input ref="avatarInput" type="file" accept="image/*" @change="fileChange" />
2016
</label>
2117
</div>
2218
<div class="text">
23-
<div class="username">{{ nickname }}</div>
24-
<div class="desc">{{ title }}</div>
19+
<div class="username" @click="changeNickname" v-if="!nicknameChanged">{{ nickname }}</div>
20+
<el-input
21+
placeholder="请输入内容"
22+
size="small"
23+
v-else
24+
v-model="nickname"
25+
ref="input"
26+
@blur="blur"></el-input>
2527
</div>
2628
<img src="../../assets/img/user/corner.png" class="corner">
29+
<div class="info">
30+
<div class="username">{{ username }}</div>
31+
<div class="mid">|</div>
32+
<div class="desc">{{ groupName }}</div>
33+
</div>
2734
</div>
2835
<ul class="dropdown-box">
2936
<li class="password" @click="changePassword">
@@ -150,8 +157,11 @@ export default {
150157
}
151158
}
152159
return {
153-
nickname: null,
160+
username: null,
154161
dialogFormVisible: false,
162+
nicknameChanged: false,
163+
nickname: null,
164+
groupName: null,
155165
form: {
156166
old_password: '',
157167
new_password: '',
@@ -185,13 +195,6 @@ export default {
185195
}
186196
},
187197
computed: {
188-
title() {
189-
const { isSuper } = this.user || {}
190-
if (isSuper) {
191-
return '超级管理员'
192-
}
193-
return '管理员'
194-
},
195198
...mapGetters(['user']),
196199
},
197200
watch: {
@@ -263,7 +266,7 @@ export default {
263266
264267
return this.$axios({
265268
method: 'post',
266-
url: '/cms/file/',
269+
url: '/cms/file',
267270
data: {
268271
file,
269272
},
@@ -302,9 +305,47 @@ export default {
302305
})
303306
})
304307
},
308+
changeNickname() {
309+
this.nicknameChanged = true
310+
setTimeout(() => {
311+
this.$refs.input.focus()
312+
}, 200)
313+
},
314+
async blur() {
315+
if (this.nickname) {
316+
const { user } = this.$store.state
317+
if (this.nickname !== user.nickname && this.nickname !== '佚名') {
318+
this.$axios({
319+
method: 'put',
320+
url: '/cms/user',
321+
data: {
322+
nickname: this.nickname,
323+
},
324+
params: {
325+
showBackend: true,
326+
},
327+
}).then((res) => {
328+
if (res.error_code === 0) {
329+
this.$message({
330+
type: 'success',
331+
message: '更新昵称成功',
332+
})
333+
// 触发重新获取用户信息
334+
return User.getInformation()
335+
}
336+
this.nickname = user.nickname
337+
}).then((res) => { // eslint-disable-line
338+
this.setUserAndState(res)
339+
})
340+
}
341+
}
342+
this.nicknameChanged = false
343+
},
305344
init() {
306345
const { user } = this.$store.state
307-
this.nickname = user ? user.nickname : '未登录'
346+
this.username = user ? user.username : '未登录'
347+
this.groupName = user.groupName ? user.groupName : '超级管理员'
348+
this.nickname = user && user.nickname ? user.nickname : '佚名'
308349
},
309350
changePassword() {
310351
this.dialogFormVisible = true
@@ -372,6 +413,7 @@ export default {
372413
373414
.user {
374415
height: 40px;
416+
375417
.el-dropdown-link {
376418
cursor: pointer;
377419
@@ -458,13 +500,29 @@ export default {
458500
.username {
459501
margin-bottom: 10px;
460502
font-size: 16px;
503+
cursor: pointer;
461504
}
462505
463506
.desc {
464507
font-size: 14px;
465508
color: rgba(222, 226, 230, 1);
466509
}
467510
}
511+
512+
.info {
513+
position: absolute;
514+
bottom: 10px;
515+
right: 10px;
516+
display: flex;
517+
color: #fff;
518+
font-size: 14px;
519+
height: 20px;
520+
line-height: 20px;
521+
522+
.mid {
523+
padding: 0 5px;
524+
}
525+
}
468526
}
469527
470528
.dropdown-box {

src/config/error-code.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
const stateCode = {
3-
777: '未知错误',
3+
777: '前端不知道,找后端小哥哥',
44
999: '服务器未知错误',
55
10000: '认证失败',
66
10020: '资源不存在',
77
10030: '参数错误',
8-
10040: '令牌失效',
9-
10050: '令牌过期',
8+
10040: 'assessToken令牌失效',
9+
10050: 'assessToken令牌过期',
1010
10060: '字段重复',
1111
10070: '不可操作',
1212
10100: 'refreshToken异常',

src/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const Config = {
2-
baseUrl: process.env.VUE_APP_BASE_URL,
2+
baseURL: process.env.VUE_APP_BASE_URL,
33
stagnateTime: 1 * 60 * 60 * 1000, // 无操作停滞时间 默认1小时
44
openAutoJumpOut: true, // 是否开启无操作跳出
55
notLoginRoute: ['login'], // 无需登录即可访问的路由 name,

src/lin/models/log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class Log {
112112
if (page === 0) {
113113
this.lPage = 0
114114
}
115-
const res = await get('cms/log/', {
115+
const res = await get('cms/log', {
116116
count: count || this.lCount,
117117
page: page || this.lPage,
118118
name: name || this.name,

src/lin/models/user.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,58 @@ const SUPER_VALUE = 2
1010
const ACTIVE_VALUE = 1
1111

1212
export default class User {
13+
// 当前用户是否在激活状态
1314
isActive = null
1415

15-
// 当前用户是否在激活状态
16+
// 邮箱
1617
email = null
1718

18-
// 邮箱
19+
// 权限分组id
1920
groupId = null
2021

21-
// 权限分组id
22-
nickname = null
22+
// 用户名
23+
username = null
2324

24-
// 昵称
25+
// 是否为超级管理员
2526
isSuper = null
2627

27-
// 是否为超级管理员
28-
auths = [] // 拥有的权限
28+
// 拥有的权限
29+
auths = []
30+
31+
// 昵称
32+
nickname = null
33+
34+
// 分组名称
35+
groupName = null
2936

30-
constructor(active, email, groupId, nickname, _super, avatar, auths) {
37+
constructor(active, email, groupId, username, _super, avatar, auths, nickname, groupName) {
3138
this.isActive = active === ACTIVE_VALUE
3239
this.email = email
3340
this.groupId = groupId
34-
this.nickname = nickname
41+
this.username = username
3542
this.avatar = avatar
3643
this.isSuper = _super === SUPER_VALUE
3744
this.auths = auths || []
45+
this.nickname = nickname
46+
this.groupName = groupName
3847
}
3948

4049
/**
41-
* 用户注册,正式发布时将废弃
50+
* 分配用户
4251
* @param {object} data 注册信息
4352
*/
4453
static register(data) {
45-
return post('cms/user/register', data)
54+
return post('cms/user/register', data, { handleError: true })
4655
}
4756

4857
/**
4958
* 登陆获取tokens
50-
* @param {string} nickname 昵称
59+
* @param {string} username 用户名
5160
* @param {string} password 密码
5261
*/
53-
static async getToken(nickname, password) {
62+
static async getToken(username, password) {
5463
const tokens = await post('cms/user/login', {
55-
nickname,
64+
username,
5665
password,
5766
})
5867
saveTokens(tokens.access_token, tokens.refresh_token)
@@ -64,15 +73,15 @@ export default class User {
6473
*/
6574
static async getInformation() {
6675
const info = await get('cms/user/information')
67-
return new User(info.active, info.email, info.group_id, info.nickname, info.admin, info.avatar)
76+
return new User(info.active, info.email, info.group_id, info.username, info.admin, info.avatar, info.nickname, info.group_name)
6877
}
6978

7079
/**
7180
* 获取当前用户信息和所拥有的权限
7281
*/
7382
static async getAuths() {
7483
const info = await get('cms/user/auths')
75-
return new User(info.active, info.email, info.group_id, info.nickname, info.admin, info.avatar, info.auths)
84+
return new User(info.active, info.email, info.group_id, info.username, info.admin, info.avatar, info.auths, info.nickname, info.group_name)
7685
}
7786

7887
/**

0 commit comments

Comments
 (0)