authentication.vue 4.1 KB

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