qrcode-login.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <script setup lang="ts">
  2. import { ref } from 'vue';
  3. import { useRouter } from 'vue-router';
  4. import { $t } from '@vben/locales';
  5. import { VbenButton } from '@vben-core/shadcn-ui';
  6. import { useQRCode } from '@vueuse/integrations/useQRCode';
  7. import Title from './auth-title.vue';
  8. interface Props {
  9. /**
  10. * @zh_CN 是否处于加载处理状态
  11. */
  12. loading?: boolean;
  13. /**
  14. * @zh_CN 登陆路径
  15. */
  16. loginPath?: string;
  17. }
  18. defineOptions({
  19. name: 'AuthenticationQrCodeLogin',
  20. });
  21. const props = withDefaults(defineProps<Props>(), {
  22. loading: false,
  23. loginPath: '/auth/login',
  24. });
  25. const router = useRouter();
  26. const text = ref('https://vben.vvbin.cn');
  27. const qrcode = useQRCode(text, {
  28. errorCorrectionLevel: 'H',
  29. margin: 4,
  30. });
  31. function goToLogin() {
  32. router.push(props.loginPath);
  33. }
  34. </script>
  35. <template>
  36. <div>
  37. <Title>
  38. {{ $t('authentication.welcomeBack') }} 📱
  39. <template #desc>
  40. <span class="text-muted-foreground">
  41. {{ $t('authentication.qrcodeSubtitle') }}
  42. </span>
  43. </template>
  44. </Title>
  45. <div class="flex-col-center mt-6">
  46. <img :src="qrcode" alt="qrcode" class="w-1/2" />
  47. <p class="text-muted-foreground mt-4 text-sm">
  48. {{ $t('authentication.qrcodePrompt') }}
  49. </p>
  50. </div>
  51. <VbenButton class="mt-4 w-full" variant="outline" @click="goToLogin()">
  52. {{ $t('common.back') }}
  53. </VbenButton>
  54. </div>
  55. </template>