<route lang="yaml"> meta: title: 登录 constant: true layout: false </route> <script lang="ts" setup name="Login"> import { ElMessage, type FormInstance, type FormRules } from 'element-plus' import { getUserMenus } from '@/api/system/login' import useUserStore from '@/store/modules/user' import useMenuStore from '@/store/modules/menu' import useRouteStore from '@/store/modules/route' import ResetPwd from '@/layouts/components/Tools/resetPwd.vue' const routeStore = useRouteStore() const route = useRoute() const router = useRouter() const menuStore = useMenuStore() const userStore = useUserStore() // localStorage.removeItem('currentSys') // 获取用户子系统列表 const sysList = ref() const common = ref({ name: '' }) const fetchSyatemList = () => { getUserMenus({ resourceType: '02', parentCode: '' }).then((res) => { // 子系统列表 sysList.value = res.data.menus.filter((item: any) => item.code !== 'common') // 通用用户设置 const user = res.data.menus.filter((item: any) => item.code === 'common') if (user.length) { common.value = user[0] } // 如果只有一个 子系统不用选择直接跳转 if (sysList.value.length === 1 && !user.length) { changeSys(sysList.value[0]) } }) } fetchSyatemList() const title = import.meta.env.VITE_APP_TITLE async function changeSys(system: any) { // 判断是否外部系统 if (system.url.includes('http')) { const token = userStore.token const params = `?token=${token}` // console.log(system.url + params) window.open(system.url + params) } else { console.log(' ========synstem', system.name, system.code) localStorage.setItem('currentSys', JSON.stringify({ name: system.name, code: system.code })) routeStore.generateRoutesAtBack({ name: system.name, code: system.code }).then((res) => { if (menuStore.sidebarMenus.length > 0) { router.replace({ path: menuStore.sidebarMenusFirstDeepestPath }) } else { ElMessage.error('子系统无菜单') } }) } } const resetPwd = ref() function userCommand(command: 'dashboard' | 'resetPassword' | 'setting' | 'hotkeys' | 'logout' | 'index') { switch (command) { case 'resetPassword': resetPwd.value.initDialog() break case 'logout': localStorage.removeItem('currentSys') routeStore.removeRoutes() userStore.logout().then(() => { router.push({ name: 'login', }) }) break } } </script> <template> <div> <!-- <div class="bg-top-banner"> {{ title }} </div> --> <div class="bg-banner" /> <!-- 子系统 --> <div class="container-all-sys"> <div class="container-sys"> <div v-for="(item, index) in sysList" :key="index" class="sys-container" @click="changeSys(item)"> <div class="title"> {{ item.name }} </div> <div :class="`sys-logo sys-logo${index}`" /> </div> </div> </div> <!-- 通用设置 --> <div v-if="common.name" class="common-container" @click="changeSys(common)"> <!-- {{ common.name }} --> <div class="title"> 账户管理 </div> </div> <!-- 退出登录 --> <el-dropdown class="user-container" size="default" @command="userCommand"> <div class="user-wrapper"> {{ userStore.name }} <el-icon> <svg-icon name="ep:caret-bottom" /> </el-icon> </div> <template #dropdown> <el-dropdown-menu class="user-dropdown" style="font-size: 20px;"> <!-- <el-dropdown-item divided command="resetPassword"> 修改密码 </el-dropdown-item> --> <el-dropdown-item divided command="logout"> 退出登录 </el-dropdown-item> </el-dropdown-menu> </template> </el-dropdown> <reset-pwd ref="resetPwd" /> <copyright /> </div> </template> <style lang="scss" scoped> :deep(.user-container) { display: inline-block; height: 24px; line-height: 24px; cursor: pointer; position: absolute; top: 2%; right: 3%; width: 8%; text-align: center; z-index: 999999; color: #fff; font-size: 18px; font-weight: 700; // border: 2px solid #fff; .user-wrapper { .el-avatar { vertical-align: middle; margin-top: -2px; margin-right: 4px; } } } .container-all-sys { width: 100%; position: absolute; z-index: 99999; top: 50%; transform: translateY(-50%); .container-sys { width: 80%; margin: 0 auto; display: flex; justify-content: space-around; } } .sys-container { position: relative; width: 18%; height: 450px; min-height: 450px; color: #fff; text-align: center; background: url("../assets/images/login-image-new/uncheck.png") no-repeat center / contain; background-size: 100% 100%; border-radius: 10px; &:hover { cursor: pointer; background: url("../assets/images/login-image-new/checked.png") no-repeat center / contain; background-size: 100% 100%; } .title { font-size: 26px; padding: 20px; font-weight: 700; } .sys-logo { position: absolute; width: 260px; height: 250px; bottom: -25px; right: -60px; } .sys-logo0 { background: url("../assets/images/login-image-new/balance.png") no-repeat center / contain; } .sys-logo1 { background: url("../assets/images/login-image-new/multimeter.png") no-repeat center / contain; } .sys-logo2 { background: url("../assets/images/login-image-new/humidity.png") no-repeat center / contain; } } .common-container { position: absolute; // z-index: 99999; width: 8%; height: 80px; font-size: 20px; font-weight: 700; background-color: #1c6de3; color: #fff; // padding: 30px; line-height: 80px; text-align: center; top: 5%; right: 3%; border-radius: 15px; background-size: 100% 100%; border: 2px solid #fff; &:hover { cursor: pointer; background-size: 100% 100%; background-color: #0048d4; } } [data-mode="mobile"] { #login-box { position: relative; width: 100%; height: 100%; top: inherit; left: inherit; transform: translateX(0) translateY(0); flex-direction: column; justify-content: start; border-radius: 0; box-shadow: none; .login-banner { width: 100%; padding: 20px 0; .banner { position: relative; right: inherit; width: 100%; max-width: 375px; margin: 0 auto; display: inherit; top: inherit; transform: translateY(0); } } .login-form { width: 100%; min-height: auto; padding: 30px; } } .copyright { position: relative; bottom: 0; padding-bottom: 10px; } } :deep(input[type="password"]::-ms-reveal) { display: none; } .bg-top-banner { position: fixed; top: 0; width: 100%; height: 17vh; z-index: 999; line-height: 10vh; text-align: center; font-size: 30px; color: #fff; background: url("../assets/images/login-image/banner.png") no-repeat center / cover; } .bg-banner { position: fixed; z-index: 0; width: 100%; height: 100%; // background: radial-gradient(circle at center, var(--el-fill-color-lighter), var(--el-bg-color-page)); background: url("../assets/images/login-image-new/bg.png") no-repeat center / cover; } #login-box { display: flex; justify-content: space-between; position: absolute; // top: 50%; // left: 50%; // transform: translateX(-50%) translateY(-50%); // background-color: var(--el-bg-color); border-radius: 10px; overflow: hidden; box-shadow: var(--el-box-shadow); .login-banner { position: relative; width: 450px; background-color: var(--el-fill-color-light); overflow: hidden; .banner { width: 100%; @include position-center(y); } .logo { position: absolute; top: 20px; left: 20px; width: 30px; height: 30px; border-radius: 4px; background: url("../assets/images/logo.png") no-repeat; background-size: contain; box-shadow: var(--el-box-shadow-light); } } .login-form { display: flex; flex-direction: column; justify-content: center; min-height: 500px; width: 500px; padding: 50px; background: url("../assets/images/login-image/frame.png") no-repeat center / cover; overflow: hidden; .title-container { position: relative; .title { font-size: 1.3em; color: #fff; margin: 0 auto 30px; text-align: center; font-weight: bold; } } } .el-form-item { margin-bottom: 24px; :deep(.el-input) { height: 48px; line-height: inherit; width: 100%; input { height: 48px; } .el-input__prefix, .el-input__suffix { display: flex; align-items: center; } .el-input__prefix { left: 10px; } .el-input__suffix { right: 10px; } } } .flex-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; } .sub-link { display: flex; align-items: center; justify-content: center; margin-top: 20px; font-size: 14px; color: var(--el-text-color-secondary); .text { margin-right: 10px; } } } .copyright { position: absolute; bottom: 30px; width: 100%; margin: 0; } :deep .el-input__wrapper { background-color: transparent !important; } :deep .el-input__inner { color: #fff !important; } </style> <style lang="scss"> // 详情页面隐藏小红点 .isDetail { ::v-deep { .el-form-item.is-required:not(.is-no-asterisk) .el-form-item__label-wrap > .el-form-item__label::before, .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label::before { content: ""; display: none; } } } </style>