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::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",
"version": "0.13.61",
"version": "0.13.63",
"description": "DooTask is task management system.",
"scripts": {
"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_')) {
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.formData_bak = $A.cloneJSON(this.formData);
},

View File

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