mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-09 08:57:14 +08:00
fix: 修复修改密码后不弹出跳转提示的问题
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-modal v-model:visible="visible" :title="title" :mask-closable="false" :esc-to-close="false"
|
<a-modal v-model:visible="visible" :title="title" :mask-closable="false" :esc-to-close="false"
|
||||||
:width="width >= 500 ? 500 : '100%'" draggable @before-ok="save" @close="reset">
|
:width="width >= 500 ? 500 : '100%'" draggable @before-ok="save" @ok="saveAfter" @close="reset">
|
||||||
<GiForm ref="formRef" v-model="form" :options="options" :columns="columns">
|
<GiForm ref="formRef" v-model="form" :options="options" :columns="columns">
|
||||||
<template #captcha>
|
<template #captcha>
|
||||||
<a-input v-model="form.captcha" placeholder="请输入验证码" :max-length="6" allow-clear style="flex: 1 1" />
|
<a-input v-model="form.captcha" placeholder="请输入验证码" :max-length="6" allow-clear style="flex: 1 1" />
|
||||||
@@ -18,13 +18,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useWindowSize } from '@vueuse/core'
|
import { useWindowSize } from '@vueuse/core'
|
||||||
import { Message } from '@arco-design/web-vue'
|
import { Message } from '@arco-design/web-vue'
|
||||||
import { getEmailCaptcha, updateUserEmail, updateUserPassword } from '@/apis'
|
import NProgress from 'nprogress'
|
||||||
|
import { getEmailCaptcha, updateUserEmail, updateUserPassword, updateUserPhone } from '@/apis'
|
||||||
import { encryptByRsa } from '@/utils/encrypt'
|
import { encryptByRsa } from '@/utils/encrypt'
|
||||||
import { useUserStore } from '@/stores'
|
import { useUserStore } from '@/stores'
|
||||||
import { type Columns, GiForm, type Options } from '@/components/GiForm'
|
import { type Columns, GiForm, type Options } from '@/components/GiForm'
|
||||||
import { useForm } from '@/hooks'
|
import { useForm } from '@/hooks'
|
||||||
import * as Regexp from '@/utils/regexp'
|
import * as Regexp from '@/utils/regexp'
|
||||||
|
import modalErrorWrapper from '@/utils/modal-error-wrapper'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
const { width } = useWindowSize()
|
const { width } = useWindowSize()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
@@ -210,17 +212,19 @@ const save = async () => {
|
|||||||
if (isInvalid) return false
|
if (isInvalid) return false
|
||||||
try {
|
try {
|
||||||
if (verifyType.value === 'phone') {
|
if (verifyType.value === 'phone') {
|
||||||
// await updateUserPhone({
|
await updateUserPhone({
|
||||||
// phone: form.phone,
|
phone: form.phone,
|
||||||
// captcha: form.captcha,
|
captcha: form.captcha,
|
||||||
// oldPassword: encryptByRsa(form.oldPassword) as string
|
oldPassword: encryptByRsa(form.oldPassword) as string
|
||||||
// })
|
})
|
||||||
|
Message.success('修改成功')
|
||||||
} else if (verifyType.value === 'email') {
|
} else if (verifyType.value === 'email') {
|
||||||
await updateUserEmail({
|
await updateUserEmail({
|
||||||
email: form.email,
|
email: form.email,
|
||||||
captcha: form.captcha,
|
captcha: form.captcha,
|
||||||
oldPassword: encryptByRsa(form.oldPassword) as string
|
oldPassword: encryptByRsa(form.oldPassword) as string
|
||||||
})
|
})
|
||||||
|
Message.success('修改成功')
|
||||||
} else if (verifyType.value === 'password') {
|
} else if (verifyType.value === 'password') {
|
||||||
if (form.newPassword !== form.rePassword) {
|
if (form.newPassword !== form.rePassword) {
|
||||||
Message.error('两次新密码不一致')
|
Message.error('两次新密码不一致')
|
||||||
@@ -235,14 +239,31 @@ const save = async () => {
|
|||||||
newPassword: encryptByRsa(form.newPassword) || ''
|
newPassword: encryptByRsa(form.newPassword) || ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Message.success('修改成功')
|
|
||||||
// 修改成功后,重新获取用户信息
|
|
||||||
await userStore.getInfo()
|
|
||||||
return true
|
return true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const saveAfter = async () => {
|
||||||
|
if (verifyType.value === 'password') {
|
||||||
|
modalErrorWrapper({
|
||||||
|
title: '提示',
|
||||||
|
content: '密码修改成功! 请保存好新密码,并使用新密码重新登录',
|
||||||
|
maskClosable: false,
|
||||||
|
escToClose: false,
|
||||||
|
okText: '重新登录',
|
||||||
|
async onOk() {
|
||||||
|
NProgress.done()
|
||||||
|
const userStore = useUserStore()
|
||||||
|
await userStore.logoutCallBack()
|
||||||
|
await router.replace('/login')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 修改成功后,重新获取用户信息
|
||||||
|
await userStore.getInfo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
// 打开弹框
|
// 打开弹框
|
||||||
|
Reference in New Issue
Block a user