| | |
| | | :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-sm text-white tracking-wide">{{ item.title }}</span> |
| | | <span class="font-medium text-white tracking-wide">{{ item.title }}</span> |
| | | </div> |
| | | </div> |
| | | <div class="user_text" v-if="isLoginStatus"> |
| | |
| | | ></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-sm text-center">登录 / 注册</span> |
| | | <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'; |
| | | import emitter from '/@/utils/mitt'; |
| | | const userName = ref(''); |
| | | const firstUserCharacter = computed(() => userName.value?.[0]?.toUpperCase()); |
| | | isLoginStatus.value = !!Local.get(accessSessionKey); |
| | |
| | | }); |
| | | let state = reactive({ |
| | | asideTitleList: [ |
| | | // { |
| | | // id: 1, |
| | | // icon: '/static/images/wave/AsideIcon.png', |
| | | // title: '应用场景', |
| | | // routerName: 'AllScenario', |
| | | // }, |
| | | // { |
| | | // id: 2, |
| | | // icon: '/static/images/wave/AsideIcon.png', |
| | | // title: '帮助中心', |
| | | // // routerName:'Scenario', |
| | | // }, |
| | | // { |
| | | // id: 3, |
| | | // icon: '/static/images/wave/AsideIcon.png', |
| | | // title: '个人设置', |
| | | // }, |
| | | { |
| | | id: 4, |
| | | icon: '/static/images/wave/AsideIcon.png', |
| | |
| | | }, |
| | | 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; |
| | | }; |
| | | |
| | | const currentRoute = router.currentRoute; |
| | | |
| | | //是否显示退出登录弹窗cpolar.top/login |
| | | const toggleShowExitLogin = () => { |
| | | state.isShowExitLogin = !state.isShowExitLogin; |
| | |
| | | isLoginStatus.value = false; |
| | | LoginInfo.remove(); |
| | | }; |
| | | const toggleExitLoginBtnRef = ref<HTMLDivElement>(null); |
| | | |
| | | const listenClickOtherExit = (e) => { |
| | | if (toggleExitLoginBtnRef.value !== e.target && !toggleExitLoginBtnRef.value?.contains(e.target)) { |
| | | 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; |
| | |
| | | emitter.on('logout', () => { |
| | | logoutClick(); |
| | | }); |
| | | document.addEventListener('click', listenClickOtherExit); |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | |
| | | .set-li-active { |
| | | width: 214px; |
| | | height: 30px; |
| | | background-color: #3b3d40; |
| | | background-color: var(--color-bg-base); |
| | | |
| | | border-radius: 6px; |
| | | span { |
| | |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | background-color: #1d86ff; |
| | | background-color: var(--color-bg-avatar); |
| | | font-size: 12px; |
| | | color: #fff; |
| | | } |
| | |
| | | align-items: center; |
| | | width: 30px; |
| | | height: 30px; |
| | | border: 1px solid #414141; |
| | | border: 1px solid var(--color-bg-base-exr); |
| | | border-radius: 50%; |
| | | } |
| | | } |
| | | } |
| | | .pop_up { |
| | | position: absolute; |
| | | top: -60px; |
| | | // top: -60px; |
| | | left: 5px; |
| | | width: 240px; |
| | | min-height: 47px; |
| | | opacity: 1; |
| | | border-radius: 15px; |
| | | background: #1f1f1f; |
| | | border: 1px solid #737373; |
| | | background: var(--color-bg-side); |
| | | border: 1px solid var(--color-bg-border); |
| | | .exit { |
| | | font-size: 14px; |
| | | font-weight: 400; |
| | | line-height: 20.27px; |
| | | color: #b9b9b9; |
| | | color: var(--color-text-font); |
| | | margin-top: 17px; |
| | | margin-left: 24px; |
| | | cursor: pointer; |
| | |
| | | } |
| | | } |
| | | .actived { |
| | | top: -60px !important; |
| | | bottom: 60px !important; |
| | | } |
| | | } |
| | | .user_login { |
| | |
| | | margin-top: 14px; |
| | | width: 100%; |
| | | height: 36px; |
| | | background: #1c86ff; |
| | | 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; |
| | |
| | | } |
| | | } |
| | | } |
| | | .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> |