diff --git a/src/App.vue b/src/App.vue index 366470c..3abec56 100644 --- a/src/App.vue +++ b/src/App.vue @@ -137,7 +137,7 @@ html, body, #app { /* 大屏页面特殊处理 */ .router-view-container { - background: #08104C; /* 深色背景 */ + background-color: #08104C; /* 深色背景 */ color: #fff; } } diff --git a/src/assets/login/account_icon.png b/src/assets/login/account_icon.png new file mode 100644 index 0000000..e49c384 Binary files /dev/null and b/src/assets/login/account_icon.png differ diff --git a/src/assets/login/big_bg.png b/src/assets/login/big_bg.png new file mode 100644 index 0000000..d21ba11 Binary files /dev/null and b/src/assets/login/big_bg.png differ diff --git a/src/assets/login/left_arrow.png b/src/assets/login/left_arrow.png new file mode 100644 index 0000000..1bdf4b9 Binary files /dev/null and b/src/assets/login/left_arrow.png differ diff --git a/src/assets/login/login_bg.png b/src/assets/login/login_bg.png new file mode 100644 index 0000000..bfe143f Binary files /dev/null and b/src/assets/login/login_bg.png differ diff --git a/src/assets/login/login_title.png b/src/assets/login/login_title.png new file mode 100644 index 0000000..006ad5f Binary files /dev/null and b/src/assets/login/login_title.png differ diff --git a/src/assets/login/password_icon.png b/src/assets/login/password_icon.png new file mode 100644 index 0000000..23cd347 Binary files /dev/null and b/src/assets/login/password_icon.png differ diff --git a/src/assets/login/right_arrow.png b/src/assets/login/right_arrow.png new file mode 100644 index 0000000..a17e107 Binary files /dev/null and b/src/assets/login/right_arrow.png differ diff --git a/src/assets/login/title.png b/src/assets/login/title.png new file mode 100644 index 0000000..be2121c Binary files /dev/null and b/src/assets/login/title.png differ diff --git a/src/router/index.ts b/src/router/index.ts index 115a264..46bd994 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -21,7 +21,7 @@ const router = createRouter({ meta: { keepAlive: false, requiresAuth: false, - isDashboard: false, + isDashboard: true, }, }, { diff --git a/src/stores/user.ts b/src/stores/user.ts index 487f735..b455860 100644 --- a/src/stores/user.ts +++ b/src/stores/user.ts @@ -1,14 +1,22 @@ +/* + * @Author: donghao donghao@supervision.ltd + * @Date: 2025-03-06 17:57:05 + * @LastEditors: donghao donghao@supervision.ltd + * @LastEditTime: 2025-03-10 13:48:21 + * @FilePath: \5G-Loading-Bay-Web\src\stores\user.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ /* * @Author: donghao donghao@supervision.ltd * @Date: 2025-03-06 13:51:46 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2025-03-06 17:45:26 + * @LastEditTime: 2025-03-10 13:40:39 * @FilePath: \vite-ai\data-dashboard\src\stores\user.ts * @Description: 用户状态管理 */ import { defineStore } from "pinia"; import router, { resetRouter } from "@/router"; - +import { setLocal, removeLocal} from "@/utils/local"; interface UserState { token: string | null; } @@ -18,9 +26,15 @@ export const useUserStore = defineStore("user", { token: localStorage.getItem("token"), }), actions: { - login(token: string) { + login( + token: string, + form: { remember: boolean; username: string; password: string } + ) { this.token = token; - localStorage.setItem("token", token); + setLocal("token", token) + form.remember + ? setLocal("userLoginInfo", form) + : removeLocal("userLoginInfo"); }, logout() { this.token = null; diff --git a/src/utils/local.ts b/src/utils/local.ts new file mode 100644 index 0000000..8c9296c --- /dev/null +++ b/src/utils/local.ts @@ -0,0 +1,36 @@ +/** + * get localStorage 获取本地存储 + * @param { String } key + */ +export function getLocal(key: string) { + if (!key) throw new Error("key is empty"); + const value = localStorage.getItem(key); + return value ? JSON.parse(value) : null; +} + +/** + * set localStorage 设置本地存储 + * @param { String } key + * @param value + */ +export function setLocal(key: string, value: unknown) { + if (!key) throw new Error("key is empty"); + if (!value) return; + return localStorage.setItem(key, JSON.stringify(value)); +} + +/** + * remove localStorage 移除某个本地存储 + * @param { String } key + */ +export function removeLocal(key: string) { + if (!key) throw new Error("key is empty"); + return localStorage.removeItem(key); +} + +/** + * clear localStorage 清除本地存储 + */ +export function clearLocal() { + return localStorage.clear(); +} diff --git a/src/views/login/Login.scss b/src/views/login/Login.scss new file mode 100644 index 0000000..c56f107 --- /dev/null +++ b/src/views/login/Login.scss @@ -0,0 +1,162 @@ +.login-container { + width: 100vw; + height: 100vh; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + // background-image: url('https://via.placeholder.com/1920x1080?text=铁路货车背景图'); + background-image: url("@/assets/login/big_bg.png"); + + + background-size: contain; + background-position: center; + background-repeat: no-repeat; + .bg-login-title { + width: 100%; + height: 45px; + background-image: url("@/assets/login/title.png"); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + margin: 0 auto 72px; + } + + .login-box { + background-image: url("@/assets/login/login_bg.png"); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + width: 630px; + height: 455px; + position: relative; + padding: 20px 0; + + .title { + width: 424px; + height: 70px; + color: #87ceeb; + text-align: center; + font-family: PingFang SC, PingFang SC; + font-weight: bold; + font-size: 28px; + letter-spacing: 2px; + color: #e9f6ff; + position: relative; + background-image: url("@/assets/login/login_title.png"); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + display: flex; + gap: 20px; + margin: 0 auto 48px; + .left-arrow, + .right-arrow { + width: 31px; + height: 15px; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + } + + .left-arrow { + left: 120px; + background-image: url("@/assets/login/right_arrow.png"); + } + + .right-arrow { + right: -30px; + background-image: url("@/assets/login/left_arrow.png"); + } + } + + .login-form { + width: 400px; + margin: 0 auto; + .el-form-item--large { + margin-bottom: 20px; + } + .input-group { + display: flex; + align-items: center; + overflow: hidden; + width: 100%; + background: #03366b; + box-shadow: inset 2px 2px 4px 0px #105890, + inset -2px -2px 4px 0px #105890; + border-radius: 4px; + border: 1px solid #105890; + + .el-input__wrapper { + background-color: transparent; + border: none; + box-shadow: none; + padding: 0; + height: 48px; + font-size: 14px; + } + + .input-icon { + margin: 0 12px; + width: 20px; + height: 20px; + background: rgba(58, 145, 255, 0.1); + display: flex; + align-items: center; + justify-content: center; + } + + .custom-input { + .el-input__inner { + background: transparent; + border: none; + color: white; + height: 48px; + &::placeholder { + color: #7b96b2; + } + } + } + } + .remember-item { + margin: 0 0 40px; + .el-form-item--large .el-form-item__content { + line-height: 22px; + } + .el-checkbox.el-checkbox--large { + height: 22px; + } + .el-checkbox__label { + color: #ffffff; + line-height: 22px; + } + + .el-checkbox.el-checkbox--large .el-checkbox__inner { + height: 16px; + width: 16px; + } + .el-checkbox__inner:after { + left: 5px; + top: 2px; + } + } + + .login-btn { + width: 400px; + height: 48px; + background: linear-gradient(180deg, #2589ff 0%, #46a9ed 100%); + border-radius: 4px; + font-size: 18px; + font-family: PingFangSC-Medium, PingFang SC; + font-weight: 500; + color: #ffffff; + line-height: 25px; + letter-spacing: 2px; + border-radius: 4px; + &:hover { + background: linear-gradient(135deg, #1976d2, #42a5f5); + } + } + } + } +} diff --git a/src/views/login/Login.vue b/src/views/login/Login.vue index 9eb97e2..a3ba781 100644 --- a/src/views/login/Login.vue +++ b/src/views/login/Login.vue @@ -2,24 +2,33 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2025-03-06 13:56:27 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2025-03-07 15:12:33 + * @LastEditTime: 2025-03-10 13:50:05 * @FilePath: \vite-ai\data-dashboard\src\views\login\login.vue * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE -->