2024-05-19 21:20:42 +08:00
|
|
|
<script lang="ts" setup>
|
2024-06-16 23:20:09 +08:00
|
|
|
import type { LoginAndRegisterParams } from '@vben/universal-ui';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
2024-06-16 23:20:09 +08:00
|
|
|
import { AuthenticationLogin } from '@vben/universal-ui';
|
2024-06-01 23:15:29 +08:00
|
|
|
|
2024-06-22 00:25:13 +08:00
|
|
|
import { App } from 'ant-design-vue';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
2024-07-07 00:17:44 +08:00
|
|
|
import { $t } from '#/locales';
|
2024-07-05 23:15:46 +08:00
|
|
|
import { useAccessStore } from '#/store';
|
2024-06-16 23:40:52 +08:00
|
|
|
|
2024-05-19 21:20:42 +08:00
|
|
|
defineOptions({ name: 'Login' });
|
|
|
|
|
|
|
|
const accessStore = useAccessStore();
|
2024-06-22 00:25:13 +08:00
|
|
|
const { notification } = App.useApp();
|
2024-05-19 21:20:42 +08:00
|
|
|
|
|
|
|
/**
|
2024-07-05 23:15:46 +08:00
|
|
|
* @param params 登录表单数据
|
2024-05-19 21:20:42 +08:00
|
|
|
*/
|
2024-07-05 23:15:46 +08:00
|
|
|
async function handleLogin(params: LoginAndRegisterParams) {
|
|
|
|
const { userInfo } = await accessStore.authLogin(params);
|
|
|
|
if (userInfo?.realName) {
|
2024-05-19 21:20:42 +08:00
|
|
|
notification.success({
|
2024-07-05 23:15:46 +08:00
|
|
|
description: `${$t('authentication.login-success-desc')}:${userInfo?.realName}`,
|
2024-05-19 21:20:42 +08:00
|
|
|
duration: 3,
|
|
|
|
message: $t('authentication.login-success'),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-06-02 21:21:34 +08:00
|
|
|
<AuthenticationLogin
|
2024-07-05 23:15:46 +08:00
|
|
|
:loading="accessStore.loading"
|
2024-06-09 13:31:43 +08:00
|
|
|
password-placeholder="123456"
|
|
|
|
username-placeholder="vben"
|
2024-06-02 21:21:34 +08:00
|
|
|
@submit="handleLogin"
|
|
|
|
/>
|
2024-05-19 21:20:42 +08:00
|
|
|
</template>
|