<template>
|
<div class="w100 h100">
|
<div class="aisde-title">
|
<div
|
class="flex items-center set-li"
|
v-for="(item, index) in state.asideTitleList"
|
:key="index"
|
@click="handleClick(item)"
|
:class="{ 'set-li-active': item.routerName === currentRoute.name }"
|
>
|
<img :src="item.icon" alt="" class="pl-2.5 pr-2.5 w-4 h-4" style="box-sizing: content-box" />
|
<span class="font-medium text-white tracking-wide">{{ item.title }}</span>
|
</div>
|
</div>
|
<div class="user_text" v-if="isLoginStatus">
|
<div class="user_head">
|
<span
|
><span
|
><span class="user-head">{{ firstUserCharacter }}</span
|
><span class="identifying"><!----></span></span
|
><span class="user_name"> {{ userName }} </span></span
|
><span ref="toggleExitLoginBtnRef"
|
><span
|
class="ywifont text-white"
|
:class="{ 'ywicon-fold': !state.isShowExitLogin, 'ywicon-unfold': state.isShowExitLogin }"
|
@click="toggleShowExitLogin"
|
></span
|
></span>
|
</div>
|
<div class="pop_up actived" v-show="state.isShowExitLogin">
|
<el-popover placement="right" :width="200" trigger="hover" popper-class="set-theme">
|
<template #reference>
|
<div class="exit"><i class="ywifont ywicon-yingyongzhongxin"></i> 界面主题</div>
|
</template>
|
<template #default>
|
<div class="px-0 m-0 relative">
|
<div class="set-theme-content">
|
<div
|
v-for="(theme, index) in THEME_LIST"
|
:key="index"
|
:style="{ backgroundColor: theme.bgColor }"
|
class="theme-item flex items-center justify-center text-[#fff] text-[12px] px-1 py-0"
|
@click="changeTheme(theme.themeCss)"
|
>
|
{{ theme.name }}主题
|
</div>
|
</div>
|
</div>
|
</template>
|
</el-popover>
|
<div class="exit" @click="informationClick"><i class="ywifont ywicon-wode"></i> 我的信息</div>
|
<div class="exit" @click="logoutClick"><i class="ywifont ywicon-tuichu"></i> 退出登录</div>
|
</div>
|
</div>
|
<div v-else class="user_login">
|
<div class="set-login" @click="openLoginDlg">
|
<span class="text-stone-100 font-medium text-center">登录 / 注册</span>
|
</div>
|
</div>
|
<UserInformation v-model="userInformationVisible" />
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import { onClickOutside } from '@vueuse/core';
|
import { computed, onMounted, reactive, ref, watchEffect } from 'vue';
|
import UserInformation from './UserInformation.vue';
|
import router from '/@/router';
|
import { isLoginStatus, isSharePage, isShowLogin } from '/@/stores/chatRoom';
|
import emitter from '/@/utils/mitt';
|
import { accessSessionKey, userNameKey } from '/@/utils/request';
|
import { gotoRoute } from '/@/utils/route';
|
import { Local, LoginInfo } from '/@/utils/storage';
|
const userName = ref('');
|
const firstUserCharacter = computed(() => userName.value?.[0]?.toUpperCase());
|
isLoginStatus.value = !!Local.get(accessSessionKey);
|
watchEffect(() => {
|
if (!isLoginStatus.value) return;
|
userName.value = Local.get(userNameKey);
|
});
|
let state = reactive({
|
asideTitleList: [
|
{
|
id: 4,
|
icon: '/static/images/wave/AsideIcon.png',
|
title: '关于WI 水务智能',
|
routerName: 'AboutUs',
|
},
|
],
|
isShowExitLogin: false,
|
loginForm: {
|
account: '',
|
pwd: '',
|
},
|
loginPhoneForm: {
|
phoneUser: '',
|
verifyCode: '',
|
},
|
activeLoginName: 'accountUser',
|
});
|
//#region ====================== 关于公司 ======================
|
const handleClick = (item) => {
|
if (!item.routerName) return;
|
gotoRoute({ name: item.routerName });
|
};
|
//#endregion
|
//#region ====================== 用户登录 ======================
|
const toggleExitLoginBtnRef = ref<HTMLDivElement>(null);
|
const currentRoute = router.currentRoute;
|
//登录
|
const openLoginDlg = async () => {
|
// 分享页不需要
|
if (isSharePage.value) return;
|
isShowLogin.value = true;
|
};
|
//是否显示退出登录弹窗cpolar.top/login
|
const toggleShowExitLogin = () => {
|
state.isShowExitLogin = !state.isShowExitLogin;
|
};
|
//退出登录
|
const logoutClick = () => {
|
state.isShowExitLogin = false;
|
isLoginStatus.value = false;
|
LoginInfo.remove();
|
};
|
onClickOutside(
|
toggleExitLoginBtnRef,
|
() => {
|
state.isShowExitLogin = false;
|
},
|
{
|
ignore: ['.set-theme'],
|
}
|
);
|
//#endregion
|
//#region ====================== 界面主题 ======================
|
const THEME_LIST = ref([
|
{ name: '默认', themeCss: 'theme-default', bgColor: '#1c1e1d' },
|
{ name: '粉色', themeCss: 'theme-pink', bgColor: '#ec4899' },
|
{ name: '蓝色', themeCss: 'theme-blue', bgColor: '#3b82f6' },
|
]);
|
|
const changeTheme = (theme = '') => {
|
const classList = document.documentElement.classList;
|
// 移除所有主题类
|
THEME_LIST.value.forEach((item) => {
|
if (item.themeCss !== 'theme-default') {
|
classList.remove(item.themeCss);
|
}
|
// 如果提供了主题,则添加它
|
if (theme && theme !== 'theme-default') {
|
classList.add(theme);
|
}
|
});
|
};
|
//#endregion
|
//#region ====================== 我的信息 ======================
|
const userInformationVisible = ref(false);
|
const informationClick = () => {
|
userInformationVisible.value = true;
|
};
|
//#endregion
|
onMounted(() => {
|
emitter.on('openLoginDlg', () => {
|
if (isShowLogin.value || isLoginStatus.value) return;
|
openLoginDlg();
|
});
|
|
emitter.on('logout', () => {
|
logoutClick();
|
});
|
});
|
</script>
|
<style scoped lang="scss">
|
.aisde-title {
|
padding-top: 18px;
|
margin-left: 16px;
|
margin-right: 22px;
|
border-top: 1px solid #383838;
|
margin-bottom: 22px;
|
}
|
.set-li {
|
height: 30px;
|
margin-bottom: 4px;
|
display: flex;
|
-webkit-box-align: center;
|
-ms-flex-align: center;
|
align-items: center;
|
cursor: pointer;
|
}
|
.set-li-active {
|
width: 214px;
|
height: 30px;
|
background-color: var(--color-bg-base);
|
|
border-radius: 6px;
|
span {
|
background: linear-gradient(90deg, #84fdd4 0, #2a82e4);
|
background-clip: text;
|
-webkit-background-clip: text;
|
-webkit-text-fill-color: transparent;
|
}
|
}
|
.user_text {
|
box-sizing: border-box;
|
width: 100%;
|
padding: 0 20px 10px;
|
position: relative;
|
.user_head {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 12px;
|
span:first-child {
|
display: flex;
|
align-items: center;
|
span:first-child {
|
position: relative;
|
.user-head {
|
margin-right: 6px;
|
width: 30px;
|
height: 30px;
|
border-radius: 50%;
|
cursor: pointer;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
background-color: var(--color-bg-avatar);
|
font-size: 12px;
|
color: #fff;
|
}
|
.identifying {
|
position: absolute;
|
left: 17px;
|
top: -12px;
|
color: #fff;
|
display: flex;
|
}
|
}
|
.user_name {
|
position: relative;
|
width: 145px;
|
overflow: hidden;
|
-o-text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
font-size: 14px;
|
font-weight: 700;
|
letter-spacing: 0;
|
line-height: 23.17px;
|
color: #fff;
|
white-space: nowrap;
|
}
|
}
|
span:last-child {
|
margin-right: 21px;
|
cursor: pointer;
|
span {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
width: 30px;
|
height: 30px;
|
border: 1px solid var(--color-bg-base-exr);
|
border-radius: 50%;
|
}
|
}
|
}
|
.pop_up {
|
position: absolute;
|
// top: -60px;
|
left: 5px;
|
width: 240px;
|
min-height: 47px;
|
opacity: 1;
|
border-radius: 15px;
|
background: var(--color-bg-side);
|
border: 1px solid var(--color-bg-border);
|
.exit {
|
font-size: 14px;
|
font-weight: 400;
|
line-height: 20.27px;
|
color: var(--color-text-font);
|
margin-top: 17px;
|
margin-left: 24px;
|
cursor: pointer;
|
padding-bottom: 10px;
|
}
|
}
|
.actived {
|
bottom: 60px !important;
|
}
|
}
|
.user_login {
|
box-sizing: border-box;
|
width: 100%;
|
padding: 0 20px 10px;
|
position: relative;
|
}
|
.set-login {
|
margin-top: 14px;
|
width: 100%;
|
height: 36px;
|
background: var(--color-bg-avatar);
|
-webkit-box-shadow: 0 2px 6px 0 rgba(8, 101, 207, 0.2), inset 0 0 7px 0 hsla(0, 0%, 100%, 0.5);
|
box-shadow: 0 2px 6px 0 rgba(8, 101, 207, 0.2), inset 0 0 7px 0 hsla(0, 0%, 100%, 0.5);
|
display: flex;
|
-webkit-box-align: center;
|
-ms-flex-align: center;
|
align-items: center;
|
-webkit-box-pack: center;
|
-ms-flex-pack: center;
|
justify-content: center;
|
font-size: 14px;
|
font-weight: 500;
|
color: #eee;
|
border-radius: 8px;
|
-webkit-user-select: none;
|
-moz-user-select: none;
|
-ms-user-select: none;
|
user-select: none;
|
cursor: pointer;
|
-webkit-transition: all 0.3s;
|
-o-transition: all 0.3s;
|
transition: all 0.3s;
|
}
|
.offices {
|
padding: 0 20px;
|
cursor: pointer;
|
text-decoration: none;
|
position: relative;
|
}
|
.officeText {
|
width: 100%;
|
height: 36px;
|
background: #1c2d57;
|
border-radius: 8px;
|
display: flex;
|
-webkit-box-align: center;
|
-ms-flex-align: center;
|
align-items: center;
|
-webkit-box-pack: center;
|
-ms-flex-pack: center;
|
justify-content: center;
|
}
|
|
.pc-login {
|
position: fixed;
|
top: 0;
|
left: 0;
|
width: 100vw;
|
height: 100vh;
|
z-index: 2000;
|
background-color: rgba(0, 0, 0, 0.6);
|
.login_box {
|
position: relative;
|
width: 450px;
|
margin: 15vh auto;
|
.sign_in {
|
padding: 39px;
|
position: relative;
|
width: 100%;
|
height: 100%;
|
border-radius: 12px;
|
-webkit-box-sizing: border-box;
|
box-sizing: border-box;
|
display: flex;
|
-webkit-box-orient: vertical;
|
-webkit-box-direction: normal;
|
-ms-flex-direction: column;
|
flex-direction: column;
|
-webkit-box-align: center;
|
-ms-flex-align: center;
|
align-items: center;
|
background-color: #fff;
|
-webkit-box-shadow: 0 0 16px 0 rgba(20, 29, 53, 0.21);
|
box-shadow: 0 0 16px 0 rgba(20, 29, 53, 0.21);
|
.closes {
|
position: absolute;
|
top: -28px;
|
right: -38px;
|
font-size: 30px;
|
cursor: pointer;
|
color: #eee;
|
-o-transition: color 0.1s;
|
transition: color 0.1s;
|
}
|
h1 {
|
box-sizing: content-box;
|
width: 100%;
|
font-size: 30px;
|
font-weight: 500;
|
color: #1c153a;
|
text-align: left !important;
|
}
|
.demo-ruleForm {
|
:deep(.el-input__wrapper) {
|
position: relative;
|
margin-bottom: 12px;
|
display: flex;
|
-webkit-box-align: center;
|
-ms-flex-align: center;
|
align-items: center;
|
width: 346px;
|
// height: 44px;
|
background-color: #fff;
|
border-radius: 5px;
|
}
|
:deep(.el-form-item--large .el-form-item__error) {
|
padding: unset !important;
|
}
|
}
|
.set-pwd {
|
text-align: right;
|
font-size: 14px;
|
font-weight: 300;
|
color: #999;
|
width: 100%;
|
padding: 0px 32px;
|
}
|
.set-login_btn {
|
width: 366px;
|
height: 44px;
|
font-size: 16px;
|
font-weight: 500;
|
color: #fff;
|
background: #0a58ed;
|
border-radius: 12px;
|
-webkit-box-shadow: 4px 6px 15px rgba(10, 88, 237, 0.2);
|
box-shadow: 4px 6px 15px rgba(10, 88, 237, 0.2);
|
}
|
}
|
}
|
}
|
.set-theme-content {
|
width: 200px;
|
height: 124px;
|
display: flex;
|
border-radius: 8px;
|
gap: 4px;
|
overflow: visible;
|
.theme-item {
|
position: relative;
|
flex-shrink: 0;
|
flex-grow: 0;
|
cursor: pointer;
|
border-radius: 5px;
|
overflow: hidden;
|
}
|
}
|
</style>
|