perf: 发送消息未设置昵称的优化

This commit is contained in:
kuaifan 2022-04-21 21:17:28 +08:00
parent 493d05f807
commit 52392e2e0a
7 changed files with 44 additions and 38 deletions

View File

@ -216,7 +216,9 @@ class UsersController extends AbstractController
$user = User::auth(); $user = User::auth();
User::token($user); User::token($user);
// //
return Base::retSuccess('success', $user); $data = $user->toArray();
$data['nickname_original'] = $user->getRawOriginal('nickname');
return Base::retSuccess('success', $data);
} }
/** /**

View File

@ -1,6 +1,6 @@
{ {
"name": "DooTask", "name": "DooTask",
"version": "0.13.61", "version": "0.13.63",
"description": "DooTask is task management system.", "description": "DooTask is task management system.",
"scripts": { "scripts": {
"start": "./cmd dev", "start": "./cmd dev",

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
61bd45c11d667932 a5809f9f890436ce

View File

@ -65,7 +65,8 @@ export default {
if (!$A.strExists(this.userInfo.userimg, '/avatar/default_')) { if (!$A.strExists(this.userInfo.userimg, '/avatar/default_')) {
this.$set(this.formData, 'userimg', this.userInfo.userimg); this.$set(this.formData, 'userimg', this.userInfo.userimg);
} }
this.$set(this.formData, 'nickname', this.userInfo.nickname); const nickname = typeof this.userInfo.nickname_original !== "undefined" ? this.userInfo.nickname_original : this.userInfo.nickname;
this.$set(this.formData, 'nickname', nickname);
this.$set(this.formData, 'profession', this.userInfo.profession); this.$set(this.formData, 'profession', this.userInfo.profession);
this.formData_bak = $A.cloneJSON(this.formData); this.formData_bak = $A.cloneJSON(this.formData);
}, },

View File

@ -57,8 +57,8 @@ export default {
dispatch("call", Object.assign(cloneParams, { dispatch("call", Object.assign(cloneParams, {
checkNick: false checkNick: false
})).then(resolve).catch(reject); })).then(resolve).catch(reject);
}).catch(() => { }).catch(({msg}) => {
reject({ret: -1, data, msg: $A.L('请设置昵称!')}) reject({ret: -1, data, msg: msg || $A.L('请设置昵称!')})
}); });
return; return;
} }
@ -386,46 +386,49 @@ export default {
*/ */
userNickNameInput({dispatch}) { userNickNameInput({dispatch}) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
let callback = (cb, success) => { let callback = (cb, result) => {
if (typeof cb === "function") { if (typeof cb === "function") {
cb(); cb();
} }
if (success === true) { if (result === true) {
setTimeout(resolve, 301) setTimeout(resolve, 301)
} else { } else {
setTimeout(reject, 301) setTimeout(_ => {
reject(result === false ? {} : {msg: result})
}, 301)
} }
} }
$A.modalInput({ setTimeout(_ => {
title: "设置昵称", $A.modalInput({
placeholder: "请输入昵称", title: "设置昵称",
okText: "保存", placeholder: "请输入昵称",
onOk: (value, cb) => { okText: "保存",
if (value) { onOk: (value, cb) => {
dispatch("call", { if (value) {
url: 'users/editdata', dispatch("call", {
data: { url: 'users/editdata',
nickname: value, data: {
}, nickname: value,
checkNick: false, },
}).then(() => { checkNick: false,
dispatch('getUserInfo').then(() => { }).then(() => {
callback(cb, true); dispatch('getUserInfo').then(() => {
}).catch(() => { callback(cb, true);
callback(cb, false); }).catch(() => {
callback(cb, false);
});
}).catch(({msg}) => {
callback(cb, msg);
}); });
}).catch(({msg}) => { } else {
$A.modalError(msg, 301);
callback(cb, false); callback(cb, false);
}); }
} else { },
callback(cb, false); onCancel: () => {
callback(null, false);
} }
}, });
onCancel: () => { }, 100)
callback(null, false);
}
});
}); });
}, },