|  |  |  | 
|---|
|  |  |  | <template> | 
|---|
|  |  |  | <div class="login-form-wrapper"> | 
|---|
|  |  |  | <div class="login-form-title">{{ $t('login.form.title') }}</div> | 
|---|
|  |  |  | <!--    <div class="login-form-sub-title">{{ $t('login.form.title') }}</div>--> | 
|---|
|  |  |  | <!--    <div class="login-form-sub-title">{{ $t('login.form.title') }}</div>--> | 
|---|
|  |  |  | <div class="login-form-error-msg">{{ errorMessage }}</div> | 
|---|
|  |  |  | <a-form | 
|---|
|  |  |  | ref="loginForm" | 
|---|
|  |  |  | 
|---|
|  |  |  | :validate-trigger="['change', 'blur']" | 
|---|
|  |  |  | hide-label | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <a-input | 
|---|
|  |  |  | v-model="userInfo.email" | 
|---|
|  |  |  | placeholder="请输入邮箱" | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <a-input v-model="userInfo.email" placeholder="请输入邮箱"> | 
|---|
|  |  |  | <template #prefix> | 
|---|
|  |  |  | <icon-user /> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | 
|---|
|  |  |  | </a-form-item> | 
|---|
|  |  |  | <a-space :size="16" direction="vertical"> | 
|---|
|  |  |  | <div class="login-form-password-actions"> | 
|---|
|  |  |  | <a-checkbox | 
|---|
|  |  |  | <!-- <a-checkbox | 
|---|
|  |  |  | checked="rememberPassword" | 
|---|
|  |  |  | :model-value="loginConfig.rememberPassword" | 
|---|
|  |  |  | @change="setRememberPassword as any" | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {{ $t('login.form.rememberPassword') }} | 
|---|
|  |  |  | </a-checkbox> | 
|---|
|  |  |  | <a-link>{{ $t('login.form.forgetPassword') }}</a-link> | 
|---|
|  |  |  | </a-checkbox> --> | 
|---|
|  |  |  | <!-- <a-link>{{ $t("login.form.forgetPassword") }}</a-link> --> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <a-button type="primary" html-type="submit" long :loading="loading"> | 
|---|
|  |  |  | {{ $t('login.form.login') }} | 
|---|
|  |  |  | </a-button> | 
|---|
|  |  |  | <a-button type="text" long class="login-form-register-btn"> | 
|---|
|  |  |  | <!-- <a-button type="text" long class="login-form-register-btn"> | 
|---|
|  |  |  | {{ $t('login.form.register') }} | 
|---|
|  |  |  | </a-button> | 
|---|
|  |  |  | </a-button> --> | 
|---|
|  |  |  | </a-space> | 
|---|
|  |  |  | </a-form> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script lang="ts" setup> | 
|---|
|  |  |  | import { ref, reactive } from 'vue'; | 
|---|
|  |  |  | import { reactive, ref } from 'vue'; | 
|---|
|  |  |  | import { useRouter } from 'vue-router'; | 
|---|
|  |  |  | import { Message } from '@arco-design/web-vue'; | 
|---|
|  |  |  | import { ValidatedError } from '@arco-design/web-vue/es/form/interface'; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const loginConfig = useStorage('login-config', { | 
|---|
|  |  |  | rememberPassword: true, | 
|---|
|  |  |  | email: '1750082535@qq.com', // 演示默认值 | 
|---|
|  |  |  | password: 'basic2024', // demo default value | 
|---|
|  |  |  | email: '', // 演示默认值 | 
|---|
|  |  |  | password: '', // demo default value | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | const userInfo = reactive({ | 
|---|
|  |  |  | email: '1750082535@qq.com', // 演示默认值 | 
|---|
|  |  |  | password: 'basic2024', // demo default value | 
|---|
|  |  |  | email: '', // 演示默认值 | 
|---|
|  |  |  | password: '', // demo default value | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleSubmit = async ({ | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!errors) { | 
|---|
|  |  |  | setLoading(true); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // const rsaPassWord = rsaPsw(values.password) as string; | 
|---|
|  |  |  | // console.log(values,'登录信息'); | 
|---|
|  |  |  | // await userStore.login({ | 
|---|
|  |  |  | //   email: values.email, | 
|---|
|  |  |  | //   password: rsaPassWord, | 
|---|
|  |  |  | // } as LoginData); | 
|---|
|  |  |  | // const { redirect, ...othersQuery } = router.currentRoute.value.query; | 
|---|
|  |  |  | const rsaPassWord = rsaPsw(values.password) as string; | 
|---|
|  |  |  | console.log(values, '登录信息'); | 
|---|
|  |  |  | let goto = await userStore.login({ | 
|---|
|  |  |  | email: values.email, | 
|---|
|  |  |  | password: rsaPassWord, | 
|---|
|  |  |  | } as LoginData); | 
|---|
|  |  |  | const { redirect, ...othersQuery } = router.currentRoute.value.query; | 
|---|
|  |  |  | router.push({ | 
|---|
|  |  |  | name: 'knowledgeLib', | 
|---|
|  |  |  | // query: { | 
|---|
|  |  |  | //   ...othersQuery, | 
|---|
|  |  |  | // }, | 
|---|
|  |  |  | name: goto, | 
|---|
|  |  |  | query: { | 
|---|
|  |  |  | ...othersQuery, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | Message.success(t('欢迎回来')); | 
|---|
|  |  |  | Message.success(t('登录成功')); | 
|---|
|  |  |  | const { rememberPassword } = loginConfig.value; | 
|---|
|  |  |  | const { email, password } = values; | 
|---|
|  |  |  | // 实际生产环境需要进行加密存储。 | 
|---|
|  |  |  | // The actual production environment requires encrypted storage. | 
|---|
|  |  |  | loginConfig.value.email = rememberPassword ? email : ''; | 
|---|
|  |  |  | loginConfig.value.password = rememberPassword ? password : ''; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (err) { | 
|---|
|  |  |  | errorMessage.value = (err as Error).message; | 
|---|
|  |  |  | } finally { | 
|---|