mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +00:00
refactor:会员注销完善、修改密码后自动注销会员登录态
This commit is contained in:
parent
8820c1f783
commit
5855ffa044
@ -19,7 +19,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<el-menu-item @click="router.push({ name: 'user' })" v-blur index="user-index">{{ $t('index.Member Center') }}</el-menu-item>
|
||||
<el-menu-item @click="logout()" v-blur index="user-logout">{{ $t('user.user.Logout login') }}</el-menu-item>
|
||||
<el-menu-item @click="userInfo.logout()" v-blur index="user-logout">{{ $t('user.user.Logout login') }}</el-menu-item>
|
||||
</el-sub-menu>
|
||||
<el-menu-item v-else @click="router.push({ name: 'user' })" v-blur index="user">{{ $t('index.Member Center') }}</el-menu-item>
|
||||
<el-sub-menu v-blur index="switch-language">
|
||||
@ -50,10 +50,7 @@ import { useSiteConfig } from '/@/stores/siteConfig'
|
||||
import { useConfig } from '/@/stores/config'
|
||||
import { useMemberCenter } from '/@/stores/memberCenter'
|
||||
import { editDefaultLang } from '/@/lang/index'
|
||||
import { postLogout } from '/@/api/frontend/user/index'
|
||||
import 'element-plus/theme-chalk/display.css'
|
||||
import { Local } from '/@/utils/storage'
|
||||
import { USER_INFO } from '/@/stores/constant/cacheKey'
|
||||
import Aside from '/@/layouts/frontend/components/aside.vue'
|
||||
import 'element-plus/theme-chalk/display.css'
|
||||
|
||||
@ -76,15 +73,6 @@ switch (route.name) {
|
||||
state.activeMenu = 'user'
|
||||
break
|
||||
}
|
||||
|
||||
const logout = () => {
|
||||
postLogout().then((res) => {
|
||||
if (res.code == 1) {
|
||||
Local.remove(USER_INFO)
|
||||
router.go(0)
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { USER_INFO } from '/@/stores/constant/cacheKey'
|
||||
import { UserInfo } from '/@/stores/interface'
|
||||
import { postLogout } from '/@/api/frontend/user/index'
|
||||
import { Local } from '/@/utils/storage'
|
||||
import router from '../router'
|
||||
|
||||
export const useUserInfo = defineStore('userInfo', {
|
||||
state: (): UserInfo => {
|
||||
@ -40,6 +43,14 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
}
|
||||
return icon
|
||||
},
|
||||
logout() {
|
||||
postLogout().then((res) => {
|
||||
if (res.code == 1) {
|
||||
Local.remove(USER_INFO)
|
||||
router.go(0)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
key: USER_INFO,
|
||||
|
@ -47,11 +47,11 @@ import { buildValidatorData } from '/@/utils/validate'
|
||||
import { changePassword } from '/@/api/frontend/user/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import FormItem from '/@/components/formItem/index.vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useUserInfo } from '/@/stores/userInfo'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const router = useRouter()
|
||||
const userInfo = useUserInfo()
|
||||
const formRef = ref<FormInstance>()
|
||||
const state = reactive({
|
||||
formSubmitLoading: false,
|
||||
@ -92,7 +92,7 @@ const onSubmit = (formEl: FormInstance | undefined) => {
|
||||
.then((res) => {
|
||||
state.formSubmitLoading = false
|
||||
if (res.code == 1) {
|
||||
router.push({ name: 'userLogin' })
|
||||
userInfo.logout()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user