admin-vben5/packages/effects/common-ui/src/authentication/qrcode-login.vue

70 lines
1.4 KiB
Vue
Raw Normal View History

2024-05-19 21:20:42 +08:00
<script setup lang="ts">
2024-06-08 19:49:06 +08:00
import { ref } from 'vue';
import { useRouter } from 'vue-router';
2024-05-19 21:20:42 +08:00
import { LOGIN_PATH } from '@vben/constants';
import { $t } from '@vben-core/locales';
2024-06-08 19:49:06 +08:00
import { VbenButton } from '@vben-core/shadcn-ui';
2024-05-19 21:20:42 +08:00
import { useQRCode } from '@vueuse/integrations/useQRCode';
import Title from './auth-title.vue';
interface Props {
/**
* @zh_CN 是否处于加载处理状态
*/
loading?: boolean;
/**
* @zh_CN 登陆路径
*/
loginPath?: string;
}
2024-05-19 21:20:42 +08:00
defineOptions({
name: 'AuthenticationQrCodeLogin',
});
const props = withDefaults(defineProps<Props>(), {
loading: false,
loginPath: LOGIN_PATH,
});
2024-05-19 21:20:42 +08:00
const router = useRouter();
const text = ref('https://vben.vvbin.cn');
const qrcode = useQRCode(text, {
errorCorrectionLevel: 'H',
margin: 4,
});
function goToLogin() {
router.push(props.loginPath);
2024-05-19 21:20:42 +08:00
}
</script>
<template>
<div>
<Title>
{{ $t('authentication.welcomeBack') }} 📱
2024-05-19 21:20:42 +08:00
<template #desc>
<span class="text-muted-foreground">
{{ $t('authentication.qrcodeSubtitle') }}
2024-05-19 21:20:42 +08:00
</span>
</template>
</Title>
2024-05-28 23:53:15 +08:00
<div class="flex-col-center mt-6">
2024-05-19 21:20:42 +08:00
<img :src="qrcode" alt="qrcode" class="w-1/2" />
<p class="text-muted-foreground mt-4 text-sm">
{{ $t('authentication.qrcodePrompt') }}
2024-05-19 21:20:42 +08:00
</p>
</div>
<VbenButton class="mt-4 w-full" variant="outline" @click="goToLogin()">
2024-05-19 21:20:42 +08:00
{{ $t('common.back') }}
</VbenButton>
</div>
</template>