11<template >
2- <el-dialog
3- :modelValue =" show"
4- modal-class =" positioned-mask"
5- width =" 300"
6- :title =" $t('chat.passwordValidator.title')"
7- custom-class =" no-close-button"
8- :close-on-click-modal =" false"
9- :close-on-press-escape =" false"
10- :show-close =" false"
11- top =" 25vh"
12- center
13- :modal =" true"
14- >
15- <el-form ref =" FormRef" :model =" form" @submit.prevent =" validator" >
16- <el-form-item prop =" value" :rules =" rules.value" >
17- <el-input show-password v-model =" form.value" />
18- </el-form-item >
19- <el-button class =" w-full mt-8" type =" primary" @click =" validator" :loading =" loading" >
20- {{ $t('common.confirm') }}</el-button
21- >
22- </el-form >
23- </el-dialog >
2+ <el-form ref =" FormRef" :model =" form" @submit.prevent =" validator" >
3+ <el-form-item prop =" value" :rules =" rules.password" >
4+ <el-input show-password v-model =" form.password" />
5+ </el-form-item >
6+ <el-button class =" w-full mt-8" type =" primary" @click =" validator" :loading =" loading" >
7+ {{ $t('common.confirm') }}</el-button
8+ >
9+ </el-form >
2410</template >
2511<script setup lang="ts">
2612import { ref , computed } from ' vue'
27- import { useRoute } from ' vue-router '
13+
2814import useStore from ' @/stores'
2915import { t } from ' @/locales'
16+ import { useRoute , useRouter } from ' vue-router'
3017const route = useRoute ()
3118const FormRef = ref ()
32- const {
33- params : { accessToken }
34- } = route as any
35- const { application } = useStore ()
19+
20+ const { chatUser } = useStore ()
3621const props = defineProps <{ applicationProfile: any ; modelValue: boolean }>()
3722const loading = ref <boolean >(false )
38- const show = computed (() => {
39- if (props .applicationProfile ) {
40- if (props .modelValue ) {
41- return false
42- }
43- return props .applicationProfile .authentication
44- }
45- return false
46- })
23+ const router = useRouter ()
24+
4725const emit = defineEmits ([' update:modelValue' ])
4826const auth = () => {
49- return application . asyncAppAuthentication ( accessToken , loading , form .value ).then (() => {
50- emit ( ' update:modelValue ' , true )
27+ return chatUser . passwordAuthentication ( form .value . password ).then ((ok ) => {
28+ router . push ({ name: ' chat ' , params: { accessToken: chatUser . accessToken } } )
5129 })
5230}
5331const validator_auth = (rule : any , value : string , callback : any ) => {
@@ -64,12 +42,11 @@ const validator = () => {
6442}
6543
6644const rules = {
67- value : [{ required: true , validator: validator_auth , trigger: ' manual' }]
45+ password : [{ required: true , validator: validator_auth , trigger: ' manual' }],
6846}
6947
7048const form = ref ({
71- type: ' password' ,
72- value: ' '
49+ password: ' ' ,
7350})
7451 </script >
7552<style lang="scss">
0 commit comments