显示长期 token

This commit is contained in:
bwcx_jzy 2021-08-24 14:55:51 +08:00
parent ec7e76c130
commit a621d3dd7c
2 changed files with 87 additions and 85 deletions

View File

@ -62,6 +62,7 @@ public class UserBasicInfoController extends BaseServerController {
map.put("email", userModel.getEmail()); map.put("email", userModel.getEmail());
map.put("dingDing", userModel.getDingDing()); map.put("dingDing", userModel.getDingDing());
map.put("workWx", userModel.getWorkWx()); map.put("workWx", userModel.getWorkWx());
map.put("md5Token", userModel.getUserMd5Key());
return JsonMessage.getString(200, "success", map); return JsonMessage.getString(200, "success", map);
} }

View File

@ -1,17 +1,22 @@
<template> <template>
<div class="user-header"> <div class="user-header">
<a-tooltip placement="left" > <a-tooltip placement="left">
<a-button title="只保留当前的 Tab" :disabled="getTabList.length <= 1" class="close-all jpom-close-tabs" @click="closeTabs">关闭 Tab</a-button> <a-button title="只保留当前的 Tab" :disabled="getTabList.length <= 1" class="close-all jpom-close-tabs" @click="closeTabs">关闭 Tab</a-button>
<!-- <a-button title="回到旧版 UI" class="close-all jpom-old-version" @click="toOldIndex">旧版</a-button>--> <!-- <a-button title="回到旧版 UI" class="close-all jpom-old-version" @click="toOldIndex">旧版</a-button>-->
</a-tooltip> </a-tooltip>
<a-dropdown> <a-dropdown>
<!-- <a-avatar--> <!-- <a-avatar-->
<!-- shape="square"--> <!-- shape="square"-->
<!-- size="large"--> <!-- size="large"-->
<!-- :style="{ backgroundColor: '#f56a00', verticalAlign: 'middle' ,fontSize:'40px'}">--> <!-- :style="{ backgroundColor: '#f56a00', verticalAlign: 'middle' ,fontSize:'40px'}">-->
<!-- --> <!-- -->
<!-- </a-avatar>--> <!-- </a-avatar>-->
<a-button class="ant-dropdown-link jpom-user-operation" :style="{ backgroundColor: '#f56a00', color: '#fff', verticalAlign: 'middle'}" @click="e => e.preventDefault()" :title="getUserInfo.name"> <a-button
class="ant-dropdown-link jpom-user-operation"
:style="{ backgroundColor: '#f56a00', color: '#fff', verticalAlign: 'middle' }"
@click="(e) => e.preventDefault()"
:title="getUserInfo.name"
>
{{ avatarName }} <a-icon type="down" /> {{ avatarName }} <a-icon type="down" />
</a-button> </a-button>
<a-menu slot="overlay"> <a-menu slot="overlay">
@ -33,29 +38,32 @@
<a-modal v-model="updateNameVisible" title="修改密码" @ok="handleUpdatePwdOk" :maskClosable="false"> <a-modal v-model="updateNameVisible" title="修改密码" @ok="handleUpdatePwdOk" :maskClosable="false">
<a-form-model ref="pwdForm" :rules="rules" :model="temp" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }"> <a-form-model ref="pwdForm" :rules="rules" :model="temp" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }">
<a-form-model-item label="原密码" prop="oldPwd"> <a-form-model-item label="原密码" prop="oldPwd">
<a-input-password v-model="temp.oldPwd" placeholder="Old password"/> <a-input-password v-model="temp.oldPwd" placeholder="Old password" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="新密码" prop="newPwd"> <a-form-model-item label="新密码" prop="newPwd">
<a-input-password v-model="temp.newPwd" placeholder="New password"/> <a-input-password v-model="temp.newPwd" placeholder="New password" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="确认密码" prop="confirmPwd"> <a-form-model-item label="确认密码" prop="confirmPwd">
<a-input-password v-model="temp.confirmPwd" placeholder="Confirm password"/> <a-input-password v-model="temp.confirmPwd" placeholder="Confirm password" />
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
</a-modal> </a-modal>
<!-- 修改用户资料区 --> <!-- 修改用户资料区 -->
<a-modal v-model="updateUserVisible" title="修改用户资料" @ok="handleUpdateUserOk" :maskClosable="false"> <a-modal v-model="updateUserVisible" title="修改用户资料" @ok="handleUpdateUserOk" :maskClosable="false">
<a-form-model ref="userForm" :rules="rules" :model="temp" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }"> <a-form-model ref="userForm" :rules="rules" :model="temp" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }">
<a-form-model-item label="Token" prop="token"> <a-form-model-item label="临时token" prop="token">
<a-input v-model="temp.token" placeholder="Token"/> <a-input v-model="temp.token" placeholder="Token" />
</a-form-model-item>
<a-form-model-item label="长期token" prop="md5Token">
<a-input v-model="temp.md5Token" placeholder="Token" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="邮箱地址" prop="email"> <a-form-model-item label="邮箱地址" prop="email">
<a-input v-model="temp.email" placeholder="邮箱地址"/> <a-input v-model="temp.email" placeholder="邮箱地址" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item v-show="showCode" label="邮箱验证码" prop="code"> <a-form-model-item v-show="showCode" label="邮箱验证码" prop="code">
<a-row :gutter="8"> <a-row :gutter="8">
<a-col :span="15"> <a-col :span="15">
<a-input v-model="temp.code" placeholder="邮箱验证码"/> <a-input v-model="temp.code" placeholder="邮箱验证码" />
</a-col> </a-col>
<a-col :span="4"> <a-col :span="4">
<a-button type="primary" :disabled="!temp.email" @click="sendEmailCode">发送验证码</a-button> <a-button type="primary" :disabled="!temp.email" @click="sendEmailCode">发送验证码</a-button>
@ -63,19 +71,19 @@
</a-row> </a-row>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="钉钉通知地址" prop="dingDing"> <a-form-model-item label="钉钉通知地址" prop="dingDing">
<a-input v-model="temp.dingDing" placeholder="钉钉通知地址"/> <a-input v-model="temp.dingDing" placeholder="钉钉通知地址" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="企业微信通知地址" prop="workWx"> <a-form-model-item label="企业微信通知地址" prop="workWx">
<a-input v-model="temp.workWx" placeholder="企业微信通知地址"/> <a-input v-model="temp.workWx" placeholder="企业微信通知地址" />
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
</a-modal> </a-modal>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from "vuex";
import { updatePwd, sendEmailCode, editUserInfo } from '../../api/user'; import { updatePwd, sendEmailCode, editUserInfo, getUserInfo } from "../../api/user";
import sha1 from 'sha1'; import sha1 from "sha1";
export default { export default {
data() { data() {
return { return {
@ -86,27 +94,15 @@ export default {
temp: {}, temp: {},
// //
rules: { rules: {
oldPwd: [ oldPwd: [{ required: true, message: "Please input old password", trigger: "blur" }],
{ required: true, message: 'Please input old password', trigger: 'blur' } newPwd: [{ required: true, message: "Please input new password", trigger: "blur" }],
], confirmPwd: [{ required: true, message: "Please input confirmPwd password", trigger: "blur" }],
newPwd: [ email: [{ required: true, message: "Please input email", trigger: "blur" }],
{ required: true, message: 'Please input new password', trigger: 'blur' } },
], };
confirmPwd: [
{ required: true, message: 'Please input confirmPwd password', trigger: 'blur' }
],
email: [
{ required: true, message: 'Please input email', trigger: 'blur' }
]
}
}
}, },
computed: { computed: {
...mapGetters([ ...mapGetters(["getToken", "getUserInfo", "getTabList"]),
'getToken',
'getUserInfo',
'getTabList'
]),
// 3 4 // 3 4
avatarName() { avatarName() {
const reg = new RegExp("[\u4E00-\u9FA5]+"); const reg = new RegExp("[\u4E00-\u9FA5]+");
@ -118,29 +114,29 @@ export default {
}, },
showCode() { showCode() {
return this.getUserInfo.email !== this.temp.email; return this.getUserInfo.email !== this.temp.email;
} },
}, },
methods: { methods: {
// 退 // 退
logOut() { logOut() {
this.$confirm({ this.$confirm({
title: '系统提示', title: "系统提示",
content: '真的要退出系统么?', content: "真的要退出系统么?",
okText: '确认', okText: "确认",
cancelText: '取消', cancelText: "取消",
onOk: () => { onOk: () => {
return new Promise((resolve) => { return new Promise((resolve) => {
// 退 // 退
this.$store.dispatch('logOut').then(() => { this.$store.dispatch("logOut").then(() => {
this.$notification.success({ this.$notification.success({
message: '退出登录成功', message: "退出登录成功",
duration: 2 duration: 2,
}); });
this.$router.push('/login'); this.$router.push("/login");
resolve(); resolve();
}) });
}) });
} },
}); });
}, },
// //
@ -151,99 +147,104 @@ export default {
// //
handleUpdatePwdOk() { handleUpdatePwdOk() {
// //
this.$refs['pwdForm'].validate(valid => { this.$refs["pwdForm"].validate((valid) => {
if (!valid) { if (!valid) {
return false; return false;
} }
// //
if (this.temp.newPwd !== this.temp.confirmPwd) { if (this.temp.newPwd !== this.temp.confirmPwd) {
this.$notification.error({ this.$notification.error({
message: '两次密码不一致...', message: "两次密码不一致...",
duration: 2 duration: 2,
}); });
return; return;
} }
// //
const params = { const params = {
oldPwd: sha1(this.temp.oldPwd), oldPwd: sha1(this.temp.oldPwd),
newPwd: sha1(this.temp.newPwd) newPwd: sha1(this.temp.newPwd),
} };
updatePwd(params).then(res => { updatePwd(params).then((res) => {
// //
if (res.code === 200) { if (res.code === 200) {
// 退 // 退
this.$store.dispatch('logOut').then(() => { this.$store.dispatch("logOut").then(() => {
this.$notification.success({ this.$notification.success({
message: res.msg, message: res.msg,
duration: 2 duration: 2,
}); });
this.$refs['pwdForm'].resetFields(); this.$refs["pwdForm"].resetFields();
this.updateNameVisible = false; this.updateNameVisible = false;
this.$router.push('/login'); this.$router.push("/login");
}) });
} }
}) });
}) });
}, },
// //
handleUpdateUser() { handleUpdateUser() {
this.temp = {...this.getUserInfo}; this.temp = { ...this.getUserInfo };
this.temp.token = this.getToken; this.temp.token = this.getToken;
this.updateUserVisible = true; getUserInfo().then((res) => {
if (res.code == 200) {
this.temp.md5Token = res.data.md5Token;
this.updateUserVisible = true;
}
});
}, },
// //
sendEmailCode() { sendEmailCode() {
if (!this.temp.email) { if (!this.temp.email) {
this.$notification.error({ this.$notification.error({
message: '请输入邮箱地址', message: "请输入邮箱地址",
duration: 2 duration: 2,
}); });
return; return;
} }
sendEmailCode(this.temp.email).then(res => { sendEmailCode(this.temp.email).then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.$notification.success({ this.$notification.success({
message: res.msg, message: res.msg,
duration: 2 duration: 2,
}); });
} }
}) });
}, },
// //
handleUpdateUserOk() { handleUpdateUserOk() {
// //
this.$refs['userForm'].validate(valid => { this.$refs["userForm"].validate((valid) => {
if (!valid) { if (!valid) {
return false; return false;
} }
editUserInfo(this.temp).then(res => { editUserInfo(this.temp).then((res) => {
// //
if (res.code === 200) { if (res.code === 200) {
this.$notification.success({ this.$notification.success({
message: res.msg, message: res.msg,
duration: 2 duration: 2,
}); });
// //
this.$refs['userForm'].resetFields(); this.$refs["userForm"].resetFields();
this.updateUserVisible = false; this.updateUserVisible = false;
} }
}) });
}) });
}, },
// tabs // tabs
closeTabs() { closeTabs() {
this.$notification.success({ this.$notification.success({
message: '操作成功', message: "操作成功",
top: '100px', top: "100px",
duration: 1 duration: 1,
}); });
this.$store.dispatch('clearTabs'); this.$store.dispatch("clearTabs");
}, },
// toOldIndex() { // toOldIndex() {
// window.location.href = '/old.html' // window.location.href = '/old.html'
// } // }
} },
} };
</script> </script>
<style scoped> <style scoped>
.user-header { .user-header {
@ -256,4 +257,4 @@ export default {
.close-all { .close-all {
margin-right: 10px; margin-right: 10px;
} }
</style> </style>