显示长期 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("dingDing", userModel.getDingDing());
map.put("workWx", userModel.getWorkWx());
map.put("md5Token", userModel.getUserMd5Key());
return JsonMessage.getString(200, "success", map);
}

View File

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