authentication.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <script setup lang="ts">
  2. import { computed } from 'vue';
  3. import { $t } from '@vben/locales';
  4. import { preferences, usePreferences } from '@vben/preferences';
  5. import AuthenticationFormView from './form.vue';
  6. import SloganIcon from './icons/slogan.vue';
  7. import Toolbar from './toolbar.vue';
  8. interface Props {
  9. pageTitle?: string;
  10. pageDescription?: string;
  11. sloganImage?: string;
  12. toolbar?: boolean;
  13. toolbarList?: ('color' | 'language' | 'layout' | 'theme')[];
  14. }
  15. defineOptions({ name: 'Authentication' });
  16. withDefaults(defineProps<Props>(), {
  17. pageDescription: '',
  18. pageTitle: '',
  19. sloganImage: '',
  20. toolbar: true,
  21. toolbarList: () => ['color', 'language', 'layout', 'theme'],
  22. });
  23. const { authPanelCenter, authPanelLeft, authPanelRight } = usePreferences();
  24. const appName = computed(() => preferences.app.name);
  25. const logoSource = computed(() => preferences.logo.source);
  26. </script>
  27. <template>
  28. <div class="flex min-h-full flex-1 select-none overflow-x-hidden">
  29. <!-- 左侧认证面板 -->
  30. <AuthenticationFormView
  31. v-if="authPanelLeft"
  32. class="min-h-full w-2/5"
  33. transition-name="slide-left"
  34. >
  35. <template v-if="toolbar" #toolbar>
  36. <Toolbar :toolbar-list="toolbarList" />
  37. </template>
  38. </AuthenticationFormView>
  39. <!-- 头部 Logo 和应用名称 -->
  40. <div class="absolute left-0 top-0 z-10 flex flex-1">
  41. <div
  42. :class="authPanelRight ? 'lg:text-white' : 'lg:text-foreground'"
  43. class="text-foreground ml-4 mt-4 flex flex-1 items-center sm:left-6 sm:top-6"
  44. >
  45. <img :alt="appName" :src="logoSource" class="mr-2" width="42" />
  46. <p class="text-xl font-medium">
  47. {{ appName }}
  48. </p>
  49. </div>
  50. </div>
  51. <!-- 系统介绍 -->
  52. <div v-if="!authPanelCenter" class="relative hidden w-0 flex-1 lg:block">
  53. <div class="absolute inset-0 h-full w-full bg-[#070709]">
  54. <div class="login-background absolute left-0 top-0 size-full"></div>
  55. <div class="flex-col-center -enter-x mr-20 h-full">
  56. <template v-if="sloganImage">
  57. <img
  58. :alt="appName"
  59. :src="sloganImage"
  60. class="animate-float h-64 w-2/5"
  61. />
  62. </template>
  63. <SloganIcon v-else :alt="appName" class="animate-float h-64 w-2/5" />
  64. <div class="text-1xl mt-6 font-sans text-white lg:text-2xl">
  65. {{ pageTitle || $t('authentication.pageTitle') }}
  66. </div>
  67. <div class="dark:text-muted-foreground mt-2 text-white/60">
  68. {{ pageDescription || $t('authentication.pageDesc') }}
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <!-- 中心认证面板 -->
  74. <div v-if="authPanelCenter" class="flex-center relative w-full">
  75. <div class="login-background absolute left-0 top-0 size-full"></div>
  76. <AuthenticationFormView
  77. class="md:bg-background shadow-primary/10 w-full rounded-3xl pb-20 shadow-2xl md:w-2/3 lg:w-1/2 xl:w-[36%]"
  78. >
  79. <template v-if="toolbar" #toolbar>
  80. <Toolbar :toolbar-list="toolbarList" />
  81. </template>
  82. </AuthenticationFormView>
  83. </div>
  84. <!-- 右侧认证面板 -->
  85. <AuthenticationFormView
  86. v-if="authPanelRight"
  87. class="min-h-full w-2/5 flex-1"
  88. >
  89. <template v-if="toolbar" #toolbar>
  90. <Toolbar :toolbar-list="toolbarList" />
  91. </template>
  92. </AuthenticationFormView>
  93. </div>
  94. </template>
  95. <style scoped>
  96. .login-background {
  97. background: linear-gradient(
  98. 154deg,
  99. #07070915 30%,
  100. hsl(var(--primary) / 15%) 48%,
  101. #07070915 64%
  102. );
  103. filter: blur(100px);
  104. }
  105. </style>