index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <div class="auth-view" :style="{ '--login-background-url': `url(${loginBackgroundUrl})` }">
  3. <!-- 右侧切换主题、语言按钮 -->
  4. <!-- <div class="auth-view__toolbar">
  5. <el-tooltip :content="t('login.themeToggle')" placement="bottom">
  6. <CommonWrapper>
  7. <ThemeSwitch />
  8. </CommonWrapper>
  9. </el-tooltip>
  10. <el-tooltip :content="t('login.languageToggle')" placement="bottom">
  11. <CommonWrapper>
  12. <LangSelect size="text-20px" />
  13. </CommonWrapper>
  14. </el-tooltip>
  15. </div> -->
  16. <!-- 登录页主体 -->
  17. <div class="auth-view__wrapper">
  18. <!-- 可选:左侧产品介绍区域,如不需要可整段删除,右侧登录表单会自动居中展示 -->
  19. <section class="auth-feature">
  20. <!-- <div class="auth-feature__badge">-->
  21. <!-- <span class="auth-feature__dot" />-->
  22. <!-- Enterprise Ready-->
  23. <!-- </div>-->
  24. <!-- <h1 class="auth-feature__title">企业级管理系统</h1>-->
  25. <!-- <p class="auth-feature__subtitle">-->
  26. <!-- 提供安全、高效、可扩展的管理解决方案,助力企业数字化转型与业务增长。-->
  27. <!-- </p>-->
  28. <!-- <ul class="auth-feature__highlights">-->
  29. <!-- <li>-->
  30. <!-- <span>✓</span>-->
  31. <!-- 统一身份认证与权限管理-->
  32. <!-- </li>-->
  33. <!-- <li>-->
  34. <!-- <span>✓</span>-->
  35. <!-- 支持定时任务与任务调度-->
  36. <!-- </li>-->
  37. <!-- <li>-->
  38. <!-- <span>✓</span>-->
  39. <!-- 数据安全与操作审计-->
  40. <!-- </li>-->
  41. <!-- <li>-->
  42. <!-- <span>✓</span>-->
  43. <!-- 灵活扩展与高可用架构-->
  44. <!-- </li>-->
  45. <!-- </ul>-->
  46. </section>
  47. <!-- 登录页主体容器 -->
  48. <section class="auth-panel">
  49. <!-- 标题 -->
  50. <div class="auth-panel__brand">
  51. <div class="auth-panel__logo-wrap">
  52. <!-- logo -->
  53. <!-- <el-image
  54. :src="configStore.configData?.sys_web_logo?.config_value || ''"
  55. class="auth-panel__logo"
  56. /> -->
  57. </div>
  58. <div class="auth-panel__meta">
  59. <div class="auth-panel__title-row">
  60. <span class="auth-panel__title">
  61. {{ configStore.configData?.sys_web_title?.config_value || "" }}
  62. </span>
  63. <!-- <el-tooltip
  64. :content="configStore.configData?.sys_web_description?.config_value || ''"
  65. placement="bottom"
  66. >
  67. <el-icon class="cursor-help"><QuestionFilled /></el-icon>
  68. </el-tooltip> -->
  69. </div>
  70. <div class="auth-panel__version-row">
  71. <span class="auth-panel__version-label">Version</span>
  72. <span class="auth-panel__version-pill">
  73. v{{ configStore.configData?.sys_web_version?.config_value || "" }}
  74. </span>
  75. </div>
  76. </div>
  77. </div>
  78. <!-- 组件切换 -->
  79. <transition name="fade-slide" mode="out-in">
  80. <component
  81. :is="formComponents[component]"
  82. v-model="component"
  83. v-model:preset-username="loginPreset.username"
  84. v-model:preset-password="loginPreset.password"
  85. class="auth-panel__form"
  86. />
  87. </transition>
  88. <!-- 登录页底部版权 -->
  89. <footer class="auth-panel__footer">
  90. <el-text size="small">
  91. <a :href="configStore.configData?.sys_git_code?.config_value || ''" target="_blank">
  92. {{ configStore.configData?.sys_web_copyright?.config_value || "" }}
  93. </a>
  94. |
  95. <a :href="configStore.configData?.sys_help_doc?.config_value || ''" target="_blank">
  96. 帮助
  97. </a>
  98. |
  99. <a :href="configStore.configData?.sys_web_privacy?.config_value || ''" target="_blank">
  100. 隐私
  101. </a>
  102. |
  103. <a :href="configStore.configData?.sys_web_clause?.config_value || ''" target="_blank">
  104. 条款
  105. </a>
  106. {{ configStore.configData?.sys_keep_record?.config_value || "" }}
  107. </el-text>
  108. </footer>
  109. </section>
  110. </div>
  111. </div>
  112. </template>
  113. <script setup lang="ts">
  114. // import logo from "@/assets/logo.png";
  115. // import { defaultSettings } from "@/settings";
  116. import CommonWrapper from "@/components/CommonWrapper/index.vue";
  117. import ThemeSwitch from "@/components/ThemeSwitch/index.vue";
  118. import { useConfigStore } from "@/store";
  119. const configStore = useConfigStore();
  120. // 添加计算属性处理背景图片URL
  121. const loginBackgroundUrl = computed(() => {
  122. // 使用可选链操作符确保安全访问
  123. return (
  124. configStore.configData?.sys_login_background?.config_value ||
  125. new URL("@/assets/images/login-bg.svg", import.meta.url).href
  126. );
  127. });
  128. type LayoutMap = "login" | "register" | "resetPwd";
  129. const t = useI18n().t;
  130. const component = ref<LayoutMap>("login"); // 切换显示的组件
  131. const formComponents = {
  132. login: defineAsyncComponent(() => import("./components/Login.vue")),
  133. register: defineAsyncComponent(() => import("./components/Register.vue")),
  134. resetPwd: defineAsyncComponent(() => import("./components/ResetPwd.vue")),
  135. };
  136. // 预填登录信息(通过具名 v-model 双向绑定传递)
  137. const loginPreset = reactive<{ username: string; password: string }>({
  138. username: "",
  139. password: "",
  140. });
  141. let notificationInstance: ReturnType<typeof ElNotification> | null = null;
  142. const showVoteNotification = () => {
  143. notificationInstance = ElNotification({
  144. title: "⭐ FastapiAdmin 完全开源 · 期待您的 Star 支持 🙏",
  145. message: `项目持续迭代中,若对您有所帮助,欢迎点亮 Star 支持!
  146. <br/><a href="https://github.com/fastapiadmin/FastapiAdmin" target="_blank" style="color: var(--el-color-primary); text-decoration: none; font-weight: 500;">Github仓库 →</a>
  147. <br/><a href="https://gitee.com/fastapiadmin/FastapiAdmin" target="_blank" style="color: var(--el-color-warning); text-decoration: none; font-weight: 500;">Gitee仓库 →</a>`,
  148. type: "success",
  149. position: "bottom-left",
  150. duration: 0,
  151. dangerouslyUseHTMLString: true,
  152. });
  153. };
  154. onMounted(() => {
  155. // setTimeout(showVoteNotification, 500);
  156. });
  157. onBeforeUnmount(() => {
  158. if (notificationInstance) {
  159. notificationInstance.close();
  160. notificationInstance = null;
  161. }
  162. });
  163. </script>
  164. <style lang="scss" scoped>
  165. .auth-view {
  166. position: relative;
  167. z-index: 1;
  168. display: flex;
  169. flex-direction: column;
  170. width: 100%;
  171. height: 100%;
  172. padding: clamp(1rem, 3vw, 2rem);
  173. overflow: hidden;
  174. background-color: var(--el-bg-color-page);
  175. &::before {
  176. position: fixed;
  177. inset: 0;
  178. z-index: -2;
  179. content: "";
  180. background: var(--login-background-url) center/cover no-repeat;
  181. }
  182. &::after {
  183. position: fixed;
  184. inset: 0;
  185. z-index: -1;
  186. pointer-events: none;
  187. content: "";
  188. background: linear-gradient(120deg, var(--el-bg-color), transparent);
  189. }
  190. }
  191. .auth-view__toolbar {
  192. display: inline-flex;
  193. gap: 0.75rem;
  194. align-self: flex-end;
  195. padding: 0.5rem 0.75rem;
  196. background-color: var(--el-bg-color-overlay);
  197. border: 1px solid var(--el-border-color-light);
  198. border-radius: 999px;
  199. box-shadow: var(--el-box-shadow-light);
  200. transition:
  201. transform 0.3s ease,
  202. box-shadow 0.3s ease;
  203. &:hover {
  204. box-shadow: var(--el-box-shadow);
  205. transform: translateY(-2px);
  206. }
  207. @media (max-width: 640px) {
  208. position: fixed;
  209. top: 12px;
  210. right: 16px;
  211. z-index: 20;
  212. align-self: flex-end;
  213. justify-content: center;
  214. }
  215. // 暗色/亮色交给 Element Plus 变量处理,不在页面里写死颜色分支
  216. }
  217. /* 暗色样式交给全局主题变量 */
  218. .auth-view__wrapper {
  219. display: grid;
  220. flex: 1;
  221. grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  222. gap: clamp(1.5rem, 3vw, 3rem);
  223. align-items: stretch;
  224. padding: clamp(1.5rem, 2vw, 2.5rem);
  225. }
  226. .auth-feature {
  227. display: flex;
  228. flex-direction: column;
  229. justify-content: center;
  230. padding: clamp(1.5rem, 3vw, 3rem);
  231. color: var(--el-text-color-primary);
  232. animation: featureFade 0.8s ease-out;
  233. }
  234. @media (max-width: 768px) {
  235. .auth-view__wrapper {
  236. display: block;
  237. padding: 1.25rem 0.75rem 1.75rem;
  238. }
  239. .auth-feature {
  240. display: none;
  241. }
  242. .auth-panel {
  243. width: 100%;
  244. margin-inline: 0;
  245. box-shadow: var(--el-box-shadow);
  246. }
  247. }
  248. .auth-feature__badge {
  249. display: inline-flex;
  250. gap: 0.5rem;
  251. align-items: center;
  252. width: fit-content;
  253. padding: 0.3rem 0.9rem;
  254. font-size: 0.875rem;
  255. color: var(--el-color-primary);
  256. text-transform: uppercase;
  257. letter-spacing: 0.08em;
  258. background: var(--el-color-primary-light-9);
  259. border-radius: 999px;
  260. }
  261. .auth-feature__dot {
  262. width: 0.5rem;
  263. height: 0.5rem;
  264. background: var(--el-color-primary);
  265. border-radius: 50%;
  266. box-shadow: var(--el-box-shadow-light);
  267. }
  268. .auth-feature__title {
  269. margin: 1.5rem 0 0.5rem;
  270. font-size: clamp(2rem, 4vw, 2.75rem);
  271. font-weight: 600;
  272. line-height: 1.2;
  273. }
  274. .auth-feature__subtitle {
  275. margin-bottom: 1.5rem;
  276. font-size: 1rem;
  277. line-height: 1.7;
  278. color: var(--el-text-color-regular);
  279. }
  280. .auth-feature__highlights {
  281. display: grid;
  282. gap: 0.75rem;
  283. padding: 0;
  284. margin: 0;
  285. list-style: none;
  286. li {
  287. display: flex;
  288. gap: 0.5rem;
  289. align-items: flex-start;
  290. padding: 0.75rem 1rem;
  291. font-weight: 500;
  292. color: var(--el-text-color-primary);
  293. background: var(--el-bg-color-overlay);
  294. border: 1px solid var(--el-border-color-lighter);
  295. border-radius: 12px;
  296. backdrop-filter: blur(6px);
  297. span {
  298. font-size: 0.75rem;
  299. line-height: 1.6;
  300. color: var(--el-color-primary);
  301. }
  302. }
  303. }
  304. .auth-panel {
  305. display: flex;
  306. flex-direction: column;
  307. gap: 1.5rem;
  308. justify-content: flex-start;
  309. justify-self: end;
  310. width: min(500px, 100%);
  311. padding: clamp(2rem, 3vw, 2.75rem);
  312. margin-inline: auto;
  313. background: var(--el-bg-color-overlay);
  314. border: 1px solid var(--el-border-color-light);
  315. border-radius: 24px;
  316. box-shadow: var(--el-box-shadow);
  317. backdrop-filter: blur(20px);
  318. animation: panelLift 0.7s ease;
  319. }
  320. .auth-panel__brand {
  321. display: flex;
  322. gap: 1rem;
  323. align-items: center;
  324. justify-content: space-between;
  325. padding-bottom: 0.85rem;
  326. margin-bottom: 1rem;
  327. border-bottom: 1px solid var(--el-border-color-lighter);
  328. }
  329. .auth-panel__logo-wrap {
  330. display: inline-flex;
  331. align-items: center;
  332. justify-content: center;
  333. width: 52px;
  334. height: 52px;
  335. background: var(--el-fill-color-light);
  336. border-radius: 18px;
  337. box-shadow: var(--el-box-shadow-light);
  338. }
  339. .auth-panel__logo {
  340. flex-shrink: 0;
  341. width: 52px;
  342. height: 52px;
  343. }
  344. .auth-panel__meta {
  345. display: flex;
  346. flex: 1;
  347. flex-direction: column;
  348. gap: 0.35rem;
  349. min-width: 0;
  350. }
  351. .auth-panel__title-row {
  352. display: flex;
  353. gap: 0.5rem;
  354. align-items: baseline;
  355. }
  356. .auth-panel__title {
  357. overflow: hidden;
  358. text-overflow: ellipsis;
  359. font-size: 1.2rem;
  360. font-weight: 650;
  361. line-height: 1.4;
  362. color: var(--el-text-color-primary);
  363. white-space: nowrap;
  364. }
  365. .auth-panel__version-row {
  366. display: inline-flex;
  367. gap: 0.5rem;
  368. align-items: center;
  369. font-size: 0.78rem;
  370. }
  371. .auth-panel__version-label {
  372. color: var(--el-text-color-placeholder);
  373. text-transform: uppercase;
  374. letter-spacing: 0.08em;
  375. }
  376. .auth-panel__version-pill {
  377. padding: 0.1rem 0.55rem;
  378. font-weight: 500;
  379. color: var(--el-color-primary);
  380. background: var(--el-color-primary-light-9);
  381. border: 1px solid var(--el-border-color-lighter);
  382. border-radius: 999px;
  383. }
  384. .auth-panel__form {
  385. width: 100%;
  386. max-width: 100%;
  387. margin-inline: auto;
  388. :deep(.el-form-item) {
  389. margin-bottom: 1.25rem;
  390. }
  391. :deep(.el-input__wrapper) {
  392. box-shadow: 0 0 0 1px var(--el-border-color) inset;
  393. transition: all 0.2s ease;
  394. &:hover {
  395. box-shadow: 0 0 0 1px var(--el-border-color-hover) inset;
  396. }
  397. &.is-focus {
  398. box-shadow: 0 0 0 1px var(--el-color-primary) inset;
  399. }
  400. }
  401. :deep(.el-card) {
  402. background: transparent;
  403. box-shadow: none;
  404. }
  405. }
  406. .auth-panel__footer {
  407. padding-top: 0.875rem;
  408. margin-top: 0.125rem;
  409. font-size: 0.875rem;
  410. text-align: center;
  411. border-top: 1px solid var(--el-border-color-lighter);
  412. a {
  413. margin-left: 0.1rem;
  414. color: var(--el-text-color-regular);
  415. text-decoration: none;
  416. transition: color 0.2s ease;
  417. &:hover {
  418. color: var(--el-color-primary);
  419. }
  420. }
  421. }
  422. @keyframes featureFade {
  423. from {
  424. opacity: 0;
  425. transform: translateY(20px);
  426. }
  427. to {
  428. opacity: 1;
  429. transform: translateY(0);
  430. }
  431. }
  432. @keyframes panelLift {
  433. from {
  434. opacity: 0;
  435. transform: translateY(30px) scale(0.98);
  436. }
  437. to {
  438. opacity: 1;
  439. transform: translateY(0) scale(1);
  440. }
  441. }
  442. .fade-slide-enter-active,
  443. .fade-slide-leave-active {
  444. transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  445. }
  446. .fade-slide-enter-from {
  447. opacity: 0;
  448. transform: translateX(-40px) scale(0.95);
  449. }
  450. .fade-slide-leave-to {
  451. opacity: 0;
  452. transform: translateX(40px) scale(0.95);
  453. }
  454. .fade-slide-enter-to,
  455. .fade-slide-leave-from {
  456. opacity: 1;
  457. transform: translateX(0) scale(1);
  458. }
  459. </style>