authentication.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <script setup lang="ts">
  2. import type { ToolbarType } from './types';
  3. import { preferences, usePreferences } from '@vben/preferences';
  4. import { Copyright } from '../basic/copyright';
  5. import AuthenticationFormView from './form.vue';
  6. import SloganIcon from './icons/slogan.vue';
  7. import Toolbar from './toolbar.vue';
  8. interface Props {
  9. appName?: string;
  10. logo?: string;
  11. pageTitle?: string;
  12. pageDescription?: string;
  13. sloganImage?: string;
  14. toolbar?: boolean;
  15. copyright?: boolean;
  16. toolbarList?: ToolbarType[];
  17. clickLogo?: () => void;
  18. }
  19. withDefaults(defineProps<Props>(), {
  20. appName: '',
  21. copyright: true,
  22. logo: '',
  23. pageDescription: '',
  24. pageTitle: '',
  25. sloganImage: '',
  26. toolbar: true,
  27. toolbarList: () => ['color', 'language', 'layout', 'theme'],
  28. clickLogo: () => {},
  29. });
  30. const { authPanelCenter, authPanelLeft, authPanelRight, isDark } =
  31. usePreferences();
  32. </script>
  33. <template>
  34. <div
  35. :class="[isDark]"
  36. class="flex min-h-full flex-1 select-none overflow-x-hidden"
  37. >
  38. <template v-if="toolbar">
  39. <slot name="toolbar">
  40. <Toolbar :toolbar-list="toolbarList" />
  41. </slot>
  42. </template>
  43. <!-- 左侧认证面板 -->
  44. <AuthenticationFormView
  45. v-if="authPanelLeft"
  46. class="min-h-full w-2/5 flex-1"
  47. transition-name="slide-left"
  48. >
  49. <template v-if="copyright" #copyright>
  50. <slot name="copyright">
  51. <Copyright
  52. v-if="preferences.copyright.enable"
  53. v-bind="preferences.copyright"
  54. />
  55. </slot>
  56. </template>
  57. </AuthenticationFormView>
  58. <!-- 头部 Logo 和应用名称 -->
  59. <div
  60. v-if="logo || appName"
  61. class="absolute left-0 top-0 z-10 flex flex-1"
  62. @click="clickLogo"
  63. >
  64. <div
  65. class="text-foreground lg:text-foreground ml-4 mt-4 flex flex-1 items-center sm:left-6 sm:top-6"
  66. >
  67. <img v-if="logo" :alt="appName" :src="logo" class="mr-2" width="42" />
  68. <p v-if="appName" class="m-0 text-xl font-medium">
  69. {{ appName }}
  70. </p>
  71. </div>
  72. </div>
  73. <!-- 系统介绍 -->
  74. <div v-if="!authPanelCenter" class="relative hidden w-0 flex-1 lg:block">
  75. <div
  76. class="bg-background-deep absolute inset-0 h-full w-full dark:bg-[#070709]"
  77. >
  78. <div class="login-background absolute left-0 top-0 size-full"></div>
  79. <div class="flex-col-center -enter-x mr-20 h-full">
  80. <template v-if="sloganImage">
  81. <img
  82. :alt="appName"
  83. :src="sloganImage"
  84. class="animate-float h-64 w-2/5"
  85. />
  86. </template>
  87. <SloganIcon v-else :alt="appName" class="animate-float h-64 w-2/5" />
  88. <div class="text-1xl text-foreground mt-6 font-sans lg:text-2xl">
  89. {{ pageTitle }}
  90. </div>
  91. <div class="dark:text-muted-foreground mt-2">
  92. {{ pageDescription }}
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <!-- 中心认证面板 -->
  98. <div v-if="authPanelCenter" class="flex-center relative w-full">
  99. <div class="login-background absolute left-0 top-0 size-full"></div>
  100. <AuthenticationFormView
  101. class="md:bg-background shadow-primary/5 shadow-float w-full rounded-3xl pb-20 md:w-2/3 lg:w-1/2 xl:w-[36%]"
  102. >
  103. <template v-if="copyright" #copyright>
  104. <slot name="copyright">
  105. <Copyright
  106. v-if="preferences.copyright.enable"
  107. v-bind="preferences.copyright"
  108. />
  109. </slot>
  110. </template>
  111. </AuthenticationFormView>
  112. </div>
  113. <!-- 右侧认证面板 -->
  114. <AuthenticationFormView
  115. v-if="authPanelRight"
  116. class="min-h-full w-[34%] flex-1"
  117. >
  118. <template v-if="copyright" #copyright>
  119. <slot name="copyright">
  120. <Copyright
  121. v-if="preferences.copyright.enable"
  122. v-bind="preferences.copyright"
  123. />
  124. </slot>
  125. </template>
  126. </AuthenticationFormView>
  127. </div>
  128. </template>
  129. <style scoped>
  130. .login-background {
  131. background: linear-gradient(
  132. 154deg,
  133. #07070915 30%,
  134. hsl(var(--primary) / 30%) 48%,
  135. #07070915 64%
  136. );
  137. filter: blur(100px);
  138. }
  139. .dark {
  140. .login-background {
  141. background: linear-gradient(
  142. 154deg,
  143. #07070915 30%,
  144. hsl(var(--primary) / 20%) 48%,
  145. #07070915 64%
  146. );
  147. filter: blur(100px);
  148. }
  149. }
  150. </style>