Forráskód Böngészése

feat: 调整激活账号和重置密码逻辑

Jack Zhou 3 hónapja
szülő
commit
cd32bcb067

+ 13 - 1
src/views/Login/src/components/ActivatedDialog.vue

@@ -1,7 +1,15 @@
 <script setup lang="ts">
+import { useRouter } from 'vue-router'
+
+const router = useRouter()
 const dialogModel = ref(false)
 const state = ref<'reset' | 'activate'>('activate')
 
+const openDialog = (stateValue: 'reset' | 'activate') => {
+  state.value = stateValue
+  dialogModel.value = true
+}
+
 const tipsData = ref({
   reset: {
     title: 'Password Reset Successfully',
@@ -16,8 +24,12 @@ const tipsData = ref({
 })
 const handleGotoLogin = () => {
   dialogModel.value = false
-  // Navigate to login page
+  router.push({ name: 'Login' })
 }
+
+defineExpose({
+  openDialog
+})
 </script>
 
 <template>

+ 13 - 6
src/views/Login/src/components/SetPasswordDialog.vue

@@ -2,6 +2,11 @@
 const dialogModel = ref(false)
 const state = ref<'reset' | 'activate'>('activate')
 
+const openDialog = (stateValue: 'reset' | 'activate') => {
+  state.value = stateValue
+  dialogModel.value = true
+}
+
 const loginForm = ref({
   username: '',
   oldPassword: '',
@@ -16,6 +21,8 @@ const loginError: any = ref({
   confirmPassword: false
 })
 
+const emit = defineEmits(['submit'])
+
 const handleChangePwd = () => {
   if (loginForm.value.newPassword !== loginForm.value.confirmPassword) {
     loginError.value.confirmPassword = true
@@ -48,6 +55,8 @@ const handleChangePwd = () => {
       password: loginForm.value.newPassword
     })
     .then((res: any) => {
+      emit('submit')
+      dialogModel.value = false
       // if (res.code === 200) {
       //   router.push({
       //     name: 'Login',
@@ -93,15 +102,13 @@ const confirmPwd = () => {
     loginError.value.confirmPassword = false
   }
 }
+defineExpose({
+  openDialog
+})
 </script>
 
 <template>
-  <el-dialog
-    v-model="dialogModel"
-    class="set-password-dialog"
-    width="480"
-    :close-on-click-modal="false"
-  >
+  <el-dialog v-model="dialogModel" class="set-password-dialog" width="480">
     <div class="content">
       <div class="top-section">
         <div class="title">Set Your Password</div>

+ 15 - 2
src/views/Login/src/loginView.vue

@@ -14,6 +14,19 @@ const router = useRouter()
 const route = useRoute()
 const themeStore = useThemeStore()
 
+const activatedDialogState = ref()
+const activatedDialogRef = ref()
+const setPasswordDialogRef = ref()
+onMounted(() => {
+  if (route.query.state) {
+    activatedDialogState.value = route.query.state
+    setPasswordDialogRef.value.openDialog(activatedDialogState.value)
+  }
+})
+const handleSetPassword = () => {
+  activatedDialogRef.value.openDialog(activatedDialogState.value)
+}
+
 // 手动获取url中的参数,直接获取route.query的参数时如果有+号会被转义成空格
 const getQueryParams = (url: string) => {
   const params = url.split('?')[1]
@@ -478,8 +491,8 @@ const firstLoginTipsRef = ref()
     ></VSliderVerification>
     <ErrorTips ref="errorTipsRef" @forget-password="status = 'reset'"></ErrorTips>
     <FirstLoginTips ref="firstLoginTipsRef" @forget-password="status = 'reset'"></FirstLoginTips>
-    <ActivatedDialog></ActivatedDialog>
-    <SetPasswordDialog></SetPasswordDialog>
+    <ActivatedDialog ref="activatedDialogRef"></ActivatedDialog>
+    <SetPasswordDialog @submit="handleSetPassword" ref="setPasswordDialogRef"></SetPasswordDialog>
   </div>
 </template>