LoginView.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import { useRoute, useRouter } from 'vue-router'
  4. import { defaultRouteFor, login } from '../auth'
  5. const route = useRoute()
  6. const router = useRouter()
  7. const username = ref('')
  8. const password = ref('')
  9. const busy = ref(false)
  10. const error = ref('')
  11. async function submit() {
  12. if (busy.value) return
  13. busy.value = true
  14. error.value = ''
  15. try {
  16. const user = await login(username.value, password.value)
  17. const requested = typeof route.query.redirect === 'string' && route.query.redirect.startsWith('/')
  18. ? route.query.redirect
  19. : defaultRouteFor(user)
  20. const normalUserCanOpen = requested === '/demand-map' || requested === '/video-discovery'
  21. await router.replace(user.role === 'admin' || normalUserCanOpen ? requested : defaultRouteFor(user))
  22. } catch (cause) {
  23. error.value = cause instanceof Error ? cause.message : '登录失败,请稍后重试'
  24. } finally {
  25. busy.value = false
  26. }
  27. }
  28. </script>
  29. <template>
  30. <main class="login-page">
  31. <section class="login-brand">
  32. <div class="brand-lockup">
  33. <span>S</span>
  34. <div>
  35. <strong>SupplyAgent</strong>
  36. <small>CONTENT INTELLIGENCE</small>
  37. </div>
  38. </div>
  39. <div class="brand-message">
  40. <span>AI-NATIVE CONTENT SUPPLY</span>
  41. <h1>让内容需求转化为<br />可执行的供给方向</h1>
  42. <p>连接需求信号、智能决策与内容生产,形成清晰、可靠、可追溯的供给链路。</p>
  43. </div>
  44. <div class="brand-grid" aria-hidden="true">
  45. <i v-for="index in 24" :key="index" />
  46. </div>
  47. </section>
  48. <section class="login-panel">
  49. <form class="login-card" @submit.prevent="submit">
  50. <header>
  51. <span>WELCOME BACK</span>
  52. <h2>登录 SupplyAgent</h2>
  53. <p>使用管理员分配的系统账号继续。</p>
  54. </header>
  55. <label>
  56. <span>用户名</span>
  57. <input
  58. v-model.trim="username"
  59. name="username"
  60. autocomplete="username"
  61. minlength="3"
  62. maxlength="64"
  63. placeholder="请输入用户名"
  64. required
  65. autofocus
  66. />
  67. </label>
  68. <label>
  69. <span>密码</span>
  70. <input
  71. v-model="password"
  72. type="password"
  73. name="password"
  74. autocomplete="current-password"
  75. maxlength="128"
  76. placeholder="请输入密码"
  77. required
  78. />
  79. </label>
  80. <p v-if="error" class="login-error" role="alert">{{ error }}</p>
  81. <button type="submit" :disabled="busy">
  82. <span v-if="busy" class="spinner" />
  83. {{ busy ? '正在登录…' : '登录系统' }}
  84. </button>
  85. <footer>登录遇到问题,请联系系统管理员</footer>
  86. </form>
  87. </section>
  88. </main>
  89. </template>
  90. <style scoped>
  91. .login-page {
  92. display: grid;
  93. min-height: 100vh;
  94. grid-template-columns: minmax(420px, 1.08fr) minmax(420px, .92fr);
  95. background: #f7f8fb;
  96. }
  97. .login-brand {
  98. position: relative;
  99. display: flex;
  100. min-height: 100vh;
  101. padding: 46px 58px;
  102. flex-direction: column;
  103. overflow: hidden;
  104. background:
  105. radial-gradient(circle at 74% 24%, rgba(117, 117, 224, .34), transparent 27%),
  106. linear-gradient(145deg, #22234f 0%, #333476 48%, #595bc2 100%);
  107. color: #fff;
  108. }
  109. .brand-lockup { display: flex; align-items: center; gap: 13px; position: relative; z-index: 2; }
  110. .brand-lockup > span {
  111. display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px;
  112. background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25);
  113. font-size: 20px; font-weight: 800; box-shadow: 0 16px 36px rgba(14,15,51,.24);
  114. }
  115. .brand-lockup strong, .brand-lockup small { display: block; }
  116. .brand-lockup strong { font-size: 17px; }
  117. .brand-lockup small { margin-top: 3px; color: #c4c5f0; font-size: 8px; letter-spacing: .18em; }
  118. .brand-message { position: relative; z-index: 2; margin: auto 0; max-width: 620px; }
  119. .brand-message > span { color: #bfc0f2; font-size: 11px; font-weight: 800; letter-spacing: .18em; }
  120. .brand-message h1 { margin: 20px 0; font-size: clamp(38px, 4vw, 62px); line-height: 1.16; letter-spacing: -.045em; }
  121. .brand-message p { max-width: 520px; margin: 0; color: #d7d8f4; font-size: 15px; line-height: 1.9; }
  122. .brand-grid {
  123. position: absolute; right: -75px; bottom: -80px; display: grid; width: 430px; height: 360px;
  124. grid-template-columns: repeat(6, 1fr); gap: 12px; transform: rotate(-8deg); opacity: .34;
  125. }
  126. .brand-grid i { border: 1px solid rgba(255,255,255,.28); border-radius: 14px; }
  127. .login-panel { display: grid; min-height: 100vh; padding: 48px; place-items: center; }
  128. .login-card { width: min(100%, 400px); }
  129. .login-card header { margin-bottom: 38px; }
  130. .login-card header > span { color: #6768ce; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
  131. .login-card h2 { margin: 10px 0 8px; color: #252b3b; font-size: 30px; letter-spacing: -.035em; }
  132. .login-card header p { margin: 0; color: #838a98; font-size: 13px; }
  133. .login-card label { display: grid; gap: 8px; margin-top: 20px; }
  134. .login-card label span { color: #4e5667; font-size: 12px; font-weight: 700; }
  135. .login-card input {
  136. height: 48px; padding: 0 15px; border: 1px solid #d8dce5; border-radius: 10px;
  137. outline: none; background: #fff; color: #252b3b; font: inherit; transition: .16s;
  138. }
  139. .login-card input:focus { border-color: #6a6bd5; box-shadow: 0 0 0 3px rgba(106,107,213,.12); }
  140. .login-card button {
  141. display: flex; width: 100%; height: 48px; margin-top: 24px; align-items: center;
  142. justify-content: center; gap: 9px; border: 0; border-radius: 10px; background: #5b5cc9;
  143. color: #fff; font-size: 13px; font-weight: 700; cursor: pointer;
  144. box-shadow: 0 12px 28px rgba(74,75,175,.24);
  145. }
  146. .login-card button:hover:not(:disabled) { background: #5051bd; }
  147. .login-card button:disabled { cursor: wait; opacity: .72; }
  148. .login-error {
  149. margin: 16px 0 -6px; padding: 10px 12px; border: 1px solid #f2c7ce; border-radius: 8px;
  150. background: #fff4f5; color: #b4233b; font-size: 12px;
  151. }
  152. .login-card footer { margin-top: 22px; color: #9aa0ac; font-size: 11px; text-align: center; }
  153. .spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
  154. @keyframes spin { to { transform: rotate(360deg); } }
  155. @media (max-width: 860px) {
  156. .login-page { display: block; }
  157. .login-brand { min-height: 240px; padding: 28px; }
  158. .brand-message { margin: auto 0 10px; }
  159. .brand-message > span, .brand-message p { display: none; }
  160. .brand-message h1 { margin: 30px 0 0; font-size: 32px; }
  161. .login-panel { min-height: calc(100vh - 240px); padding: 36px 24px; }
  162. }
  163. </style>