123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- <script setup lang="ts">
- import { RouterView } from 'vue-router'
- import { onMounted, reactive, ref } from 'vue'
- import { ElMessage } from 'element-plus'
- import { getAllGameInfo } from '@/utils/table/table'
- import router from '@/router'
- import { getAssetsImageUrl } from '@/utils/common'
- import type { DropDownInfo, DropDownItem } from '@/types/dataAnalysis'
- import DropDownSelection from '@/components/dataAnalysis/DropDownSelection.vue'
- import { useCommonStore } from '@/stores/useCommon'
- const { selectInfo } = useCommonStore()
- const isCollapse = ref(false)
- const menuList = [
- {
- title: '数据总览',
- icon: 'PieChart',
- children: [
- {
- pathName: 'OverView',
- title: '工作台'
- }
- ]
- },
- {
- title: '信息管理',
- icon: 'Histogram',
- children: [
- {
- pathName: 'GameManageView',
- title: '游戏管理'
- },
- {
- pathName: 'PlayerManageView',
- title: '玩家管理'
- }
- ]
- },
- {
- title: '数据分析',
- icon: 'DataAnalysis',
- children: [
- {
- pathName: 'KeepView',
- title: '留存分析'
- },
- {
- pathName: 'UserTrendView',
- title: '用户趋势'
- }
- ]
- }
- ]
- const changeCollapse = () => {
- isCollapse.value = !isCollapse.value
- }
- // 登出
- const logOut = () => {
- ElMessage({
- type: 'success',
- message: '退出成功',
- duration: 1000
- })
- localStorage.removeItem('token')
- localStorage.removeItem('refreshToken')
- router.push('/login')
- }
- const iconUrl = {
- logo: getAssetsImageUrl('logo.svg'),
- defaultHead: getAssetsImageUrl('default/defaultHead.png')
- }
- // const gameSelectList = reactive<Array<DropDownItem>>([])
- // 游戏下拉选择框需要的数据
- const gameSelectInfo = reactive<DropDownInfo>({
- defaultSelect: '1001',
- title: '请选择游戏',
- optionsList: []
- })
- const gameinfoLoad = ref(false)
- /**
- * @description: 更新整个页面的游戏选择
- * @param {*} gid 游戏id
- * @return {*}
- */
- const changeGame = (gid: any) => {
- selectInfo.gid = gid
- }
- getAllGameInfo().then((data) => {
- if (data) {
- data.map((item) => {
- gameSelectInfo.optionsList.push({
- value: item.gid,
- label: item.gameName
- })
- })
- }
- gameinfoLoad.value = true
- })
- </script>
- <template>
- <div class="body">
- <div class="sideBarBox">
- <el-menu :router="true" :default-active="$route.name" class="sideBar" :collapse="isCollapse">
- <el-menu-item index="/" class="logoBox">
- <el-image :fit="'fill'" class="logoImg" :src="iconUrl.logo"></el-image>
- <template #title><span class="logoText">淳皓科技</span></template>
- </el-menu-item>
- <el-sub-menu v-for="item in menuList" :index="item.title">
- <template #title>
- <el-icon><component :is="item.icon" /></el-icon>
- <span class="menuTitle">{{ item.title }}</span>
- </template>
- <el-menu-item v-for="v in item.children" :index="v.pathName">{{ v.title }}</el-menu-item>
- </el-sub-menu>
- <div class="sideBarFold" @click="changeCollapse">
- <el-icon :size="25"><Fold /></el-icon>
- </div>
- </el-menu>
- </div>
- <div class="navBarBox">
- <div class="gameSelect">
- <el-icon class="gameIcon" :size="20">
- <icon-icon-park-game-three></icon-icon-park-game-three>
- </el-icon>
- <DropDownSelection
- :default-select="gameSelectInfo.defaultSelect"
- :title="gameSelectInfo.title"
- :options-list="gameSelectInfo.optionsList"
- :size="'default'"
- @change-select="changeGame"
- ></DropDownSelection>
- </div>
- <div class="headPortraitBox">
- <el-popover popper-class="headPopper" placement="bottom-end" trigger="click">
- <template #reference>
- <el-image class="headPortrait" :src="iconUrl.defaultHead"></el-image>
- </template>
- <div class="userTools">
- <span class="userToolsItem" @click="logOut">
- <icon-material-symbols-light-logout></icon-material-symbols-light-logout>
- <span> 退出登录</span>
- </span>
- </div>
- </el-popover>
- </div>
- </div>
- <div class="content">
- <RouterView v-if="gameinfoLoad" />
- </div>
- </div>
- </template>
- <style scoped>
- .body {
- width: 100%;
- display: flex;
- height: 100vh;
- }
- .gameSelect {
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- /* width: 10%; */
- height: 80%;
- display: flex;
- align-items: center;
- right: 10%;
- display: flex;
- align-items: center;
- /* background-color: lightblue; */
- }
- .gameIcon {
- /* box-sizing: border-box; */
- /* padding-right: 12px; */
- margin-right: 12px;
- }
- /* 设置宽度后,content无法适应宽度,只能去间接的调整内部元素的宽度 */
- .sideBarBox {
- position: relative;
- /* width: 12%; */
- z-index: 2;
- height: 100vh;
- top: 0;
- }
- .sideBar {
- /* width: 12vw; */
- height: 100vh;
- position: relative;
- overflow: scroll;
- }
- /* 设置弹出层的样式 */
- .el-popper > .logoText {
- width: 100px;
- font-size: 16px;
- /* color: red; */
- }
- /* 调整LOGO */
- .logoBox {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .logoImg {
- display: flex;
- align-items: center;
- width: 33px;
- /* margin-right: 20px; */
- /* height: 50px; */
- }
- .logoText {
- width: 80%;
- height: 100%;
- margin-left: 15%;
- display: flex;
- font-size: 18px;
- align-items: center;
- /* background-color: lightcoral; */
- }
- /* 主要用来调整整个menu的宽度 */
- .menuTitle {
- margin-right: 40px;
- }
- .sideBarFold {
- width: 5%;
- height: 3%;
- position: absolute;
- right: 40px;
- bottom: 20px;
- }
- .navBarBox {
- position: fixed;
- width: 100vw;
- z-index: 1;
- height: 7vh;
- top: 0;
- background-color: white;
- right: 0;
- border-bottom: 1px solid gainsboro;
- }
- .headPortraitBox {
- position: absolute;
- right: 3%;
- top: 50%;
- transform: translateY(-50%);
- }
- .userTools {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- align-items: center;
- }
- .userToolsItem {
- cursor: pointer;
- width: 100%;
- height: 4vh;
- display: flex;
- align-items: center;
- justify-content: center;
- /* padding: 10px; */
- margin: 2%;
- }
- .userToolsItem > span {
- margin-left: 10%;
- }
- .userToolsItem:hover {
- background-color: #f2f3f5;
- }
- .headPortrait {
- cursor: pointer;
- width: 50px;
- }
- .content {
- /* flex-grow: 1; */
- /* position: absolute; */
- width: 100%;
- /* height: 93%; */
- margin-top: 7vh;
- overflow: scroll;
- background-color: #f2f3f5;
- right: 0vw;
- top: 0vh;
- }
- </style>
- <!-- 为了让popper-class生效,需要的单独写一份 -->
- <style>
- .headPopper {
- padding: 0px !important;
- border: 1px solid #e5e6eb;
- background-color: white;
- }
- </style>
|