feat: 修改密码前端持久化

This commit is contained in:
dataeaseShu 2023-02-15 17:08:45 +08:00
parent 496feb435a
commit c37f86f742
2 changed files with 12 additions and 2 deletions

View File

@ -7,6 +7,7 @@
component-name="ThemeSetting"
/>
<el-dialog
v-if="$route.path !== '/login'"
:visible.sync="showPasswordModifiedDialog"
append-to-body
:title="$t('user.change_password')"
@ -35,6 +36,12 @@ export default {
showPasswordModifiedDialog: false
}
},
mounted() {
const passwordModified = JSON.parse(localStorage.getItem('passwordModified'))
if (typeof passwordModified === 'boolean') {
this.$store.commit('user/SET_PASSWORD_MODIFIED', passwordModified)
}
},
watch: {
passwordModified: {
handler(val) {

View File

@ -83,9 +83,12 @@ const actions = {
commit('SET_TOKEN', data.token)
commit('SET_LOGIN_MSG', null)
setToken(data.token)
if(data.hasOwnProperty('passwordModified')){
commit('SET_PASSWORD_MODIFIED', data.passwordModified)
let passwordModified = true
if (data.hasOwnProperty('passwordModified')) {
passwordModified = data.passwordModified
}
commit('SET_PASSWORD_MODIFIED', passwordModified)
localStorage.setItem('passwordModified', passwordModified)
resolve()
}).catch(error => {
reject(error)