Login.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="login-root">
  3. <div class="bg-image" v-if="!ui.loginBgVideo"></div>
  4. <video v-if="ui.loginBgVideo" class="bg-video" autoplay muted loop playsinline poster="@/assets/login/login-bg.jpg">
  5. <source src="@/assets/login/login-bg.mp4" type="video/mp4" />
  6. </video>
  7. <header class="top-bar">
  8. <img class="kyland-logo" :src="brand.logo" :alt="brand.title" />
  9. <div class="top-right-actions">
  10. <FullscreenToggle />
  11. </div>
  12. </header>
  13. <div class="main-content">
  14. <div class="left-panel">
  15. <div class="login-box">
  16. <div class="title-wrap">
  17. <img v-if="!brand.loginTitle" class="title-img" :src="brand.loginTitle" :alt="brand.title" />
  18. <div v-else class="title-text glow-text">{{ brand.title }}</div>
  19. </div>
  20. <LoginForm @login-success="onLoginSuccess" />
  21. </div>
  22. </div>
  23. <div class="right-panel"></div>
  24. </div>
  25. <footer class="copyright">{{ brand.company }}</footer>
  26. </div>
  27. </template>
  28. <script>
  29. import LoginForm from "@/components/ui/LoginForm.vue";
  30. import FullscreenToggle from "@/components/ui/FullscreenToggle.vue";
  31. import brand, { ui } from "@/utils/brand";
  32. // webpack 解析为带 hash 的真实 URL,用于在登录页预取主页背景视频
  33. import mainBgVideo from "@/assets/main/main-bg.mp4";
  34. export default {
  35. name: "LoginPage",
  36. components: { LoginForm, FullscreenToggle },
  37. data() {
  38. return {
  39. brand,
  40. ui,
  41. };
  42. },
  43. mounted() {
  44. this.prefetchMainBgVideo();
  45. },
  46. methods: {
  47. onLoginSuccess() {
  48. this.$router.push('/main').catch(() => {});
  49. },
  50. // Login→Main 为固定路径,提前预取主页背景视频,进入主页时即命中缓存。
  51. // 仅在主页视频开启时预取,避免为关闭视频的部署浪费带宽。
  52. prefetchMainBgVideo() {
  53. if (!this.ui.mainBgVideo || !mainBgVideo) return;
  54. const link = document.createElement("link");
  55. link.rel = "prefetch";
  56. link.as = "video";
  57. link.href = mainBgVideo;
  58. document.head.appendChild(link);
  59. },
  60. },
  61. };
  62. </script>
  63. <style scoped>
  64. .login-root {
  65. width: 100vw;
  66. height: 100vh;
  67. position: relative;
  68. overflow: hidden;
  69. background: #050a17;
  70. display: flex;
  71. flex-direction: column;
  72. }
  73. .bg-image {
  74. position: absolute;
  75. inset: 0;
  76. background: url('@/assets/login/login-bg.jpg') no-repeat center / cover;
  77. z-index: 0;
  78. }
  79. .bg-video {
  80. position: absolute;
  81. top: 50%;
  82. left: 50%;
  83. transform: translate(-50%, -50%);
  84. width: 100%;
  85. height: 100%;
  86. object-fit: cover;
  87. z-index: 1;
  88. }
  89. .top-bar {
  90. position: relative;
  91. z-index: 2;
  92. display: flex;
  93. justify-content: center;
  94. align-items: center;
  95. height: 10vh;
  96. flex-shrink: 0;
  97. }
  98. .kyland-logo {
  99. height: clamp(30px, 5vh, 56px);
  100. width: auto;
  101. }
  102. .top-right-actions {
  103. position: absolute;
  104. top: 50%;
  105. right: 50px;
  106. transform: translateY(-50%);
  107. display: flex;
  108. align-items: center;
  109. gap: 12px;
  110. }
  111. .main-content {
  112. position: relative;
  113. z-index: 2;
  114. flex: 1;
  115. display: grid;
  116. grid-template-columns: 45fr 55fr;
  117. align-items: center;
  118. padding: 0 8vw;
  119. min-height: 0;
  120. }
  121. .left-panel {
  122. display: flex;
  123. flex-direction: column;
  124. justify-content: center;
  125. align-items: center;
  126. }
  127. .login-box {
  128. width: 566px;
  129. background: transparent;
  130. border: none;
  131. box-shadow: none;
  132. padding: 0;
  133. box-sizing: border-box;
  134. display: flex;
  135. flex-direction: column;
  136. }
  137. .title-wrap {
  138. display: flex;
  139. align-items: center;
  140. margin-bottom: 22px;
  141. flex-shrink: 0;
  142. }
  143. .title-img {
  144. width: auto;
  145. max-width: 100%;
  146. }
  147. .title-text {
  148. font-family: var(--title-font-family);
  149. font-size: 48px;
  150. color: #ffffff;
  151. line-height: 63px;
  152. text-align: center;
  153. font-style: normal;
  154. text-transform: none;
  155. white-space: nowrap;
  156. }
  157. .right-panel {
  158. height: 100%;
  159. }
  160. .copyright {
  161. position: relative;
  162. z-index: 2;
  163. text-align: center;
  164. color: rgba(255, 255, 255, 0.85);
  165. font-size: clamp(12px, 1vw, 18px);
  166. padding-bottom: clamp(10px, 1.8vh, 22px);
  167. flex-shrink: 0;
  168. text-shadow: 0 0 8px rgba(0, 150, 255, 0.6), 0 1px 3px rgba(0, 0, 0, 0.8);
  169. letter-spacing: 1px;
  170. }
  171. :fullscreen .login-root .top-bar {
  172. height: 14vh;
  173. }
  174. </style>