|
@@ -8,8 +8,10 @@
|
|
|
-->
|
|
|
<script setup lang="ts">
|
|
|
import { useRequest } from '@/hooks/useRequest.ts'
|
|
|
+import { useUser } from '@/stores/useUser.ts'
|
|
|
import type { DropDownInfo } from '@/types/dataAnalysis'
|
|
|
import type { ResponseInfo } from '@/types/res.ts'
|
|
|
+import { clearClientInfo } from '@/utils/auth/auth.ts'
|
|
|
import AxiosInstance from '@/utils/axios/axiosInstance.ts'
|
|
|
|
|
|
import { zhCn } from 'element-plus/es/locales.mjs'
|
|
@@ -20,8 +22,7 @@ import { getAllGameInfo } from '@/utils/table/table'
|
|
|
|
|
|
import { useCommonStore } from '@/stores/useCommon'
|
|
|
import { initLoadResource } from '@/utils/resource'
|
|
|
-import { setLoginState } from '@/utils/localStorage/localStorage'
|
|
|
-import { removeAllToken } from '@/utils/token/token'
|
|
|
+import { getLoginState, getUserInfo } from '@/utils/localStorage/localStorage'
|
|
|
|
|
|
import router from '@/router'
|
|
|
|
|
@@ -35,6 +36,8 @@ interface GameSelectItemInfo {
|
|
|
const route = useRoute()
|
|
|
const { selectInfo, allGameInfo, saveSelectInfo } = useCommonStore()
|
|
|
const { AllApi } = useRequest()
|
|
|
+const { updateUserInfo } = useUser()
|
|
|
+const userInfo = getUserInfo()
|
|
|
|
|
|
const isCollapse = ref(false)
|
|
|
const navBarSelect = ref<string>('Home')
|
|
@@ -49,25 +52,37 @@ const defaultActive = computed<string>(() => {
|
|
|
})
|
|
|
|
|
|
// 顶部导航栏信息
|
|
|
-const navBarMenuList = [
|
|
|
- {
|
|
|
- name: 'Home',
|
|
|
- title: '应用分析'
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: 'AppManage',
|
|
|
- title: '应用管理'
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'FileManage',
|
|
|
- title: '文件管理'
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'MemberManage',
|
|
|
- title: '成员管理'
|
|
|
- }
|
|
|
-]
|
|
|
+const navBarMenuList = computed(() => {
|
|
|
+ const allNavBar = [
|
|
|
+ {
|
|
|
+ name: 'Home',
|
|
|
+ title: '应用分析',
|
|
|
+ needSuper: false
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ name: 'AppManage',
|
|
|
+ title: '应用管理',
|
|
|
+ needSuper: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'FileManage',
|
|
|
+ title: '文件管理',
|
|
|
+ needSuper: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'MemberManage',
|
|
|
+ title: '成员管理',
|
|
|
+ needSuper: true
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ return allNavBar.filter((item) => {
|
|
|
+ if (item.needSuper) {
|
|
|
+ return userInfo?.isSuper
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ })
|
|
|
+})
|
|
|
|
|
|
/**
|
|
|
* 侧边栏折叠改变
|
|
@@ -87,8 +102,7 @@ const logOut = () => {
|
|
|
message: '退出成功',
|
|
|
duration: 1000
|
|
|
})
|
|
|
- setLoginState(false)
|
|
|
- removeAllToken()
|
|
|
+ clearClientInfo()
|
|
|
router.push('/login')
|
|
|
}
|
|
|
|
|
@@ -135,12 +149,12 @@ const basePath = ref<string | undefined>()
|
|
|
// 是否过滤不活跃的游戏
|
|
|
const isFilterNotActiveGame = ref<boolean>(false)
|
|
|
|
|
|
-// 游戏选择框的选中值
|
|
|
-const gameSelectVal = ref<string>('')
|
|
|
-
|
|
|
// 游戏选择框的加载状态
|
|
|
const gameSelectLoading = ref<boolean>(false)
|
|
|
|
|
|
+// 选中的游戏
|
|
|
+const selectedGame = ref<string>('')
|
|
|
+
|
|
|
/**
|
|
|
* 创建侧边栏菜单
|
|
|
*/
|
|
@@ -233,30 +247,41 @@ const updateGameInfo = () => {
|
|
|
*/
|
|
|
const setNavbarGameSelect = (optionsList: Array<GameSelectItemInfo>) => {
|
|
|
gameSelectInfo.optionsList.splice(0, gameSelectInfo.optionsList.length)
|
|
|
- if (!optionsList || optionsList.length === 0) return
|
|
|
+ if (!optionsList || optionsList.length === 0) {
|
|
|
+ selectedGame.value = ''
|
|
|
+ gameSelectInfo.optionsList = []
|
|
|
+ return
|
|
|
+ }
|
|
|
optionsList.forEach((item) => {
|
|
|
gameSelectInfo.optionsList.push({
|
|
|
value: item.gid,
|
|
|
label: item.gameName
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
- gameSelectInfo.defaultSelect = optionsList[0].gid
|
|
|
- changeGame(optionsList[0].gid)
|
|
|
- // 去找本地的gid,如果有,就赋值,否则用请求回来的第一个gid
|
|
|
+ // 这个主要是用在初始化
|
|
|
+ // if (selectInfo.gid) {
|
|
|
+ // selectedGame.value = selectInfo.gid
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * TODO 这里好像没有必要
|
|
|
+ *
|
|
|
* 获取导航栏游戏选择框的数据
|
|
|
*/
|
|
|
-const updateNavbarGameSelect = async (query: string) => {
|
|
|
+const updateNavbarGameSelect = async (query: string, force = false) => {
|
|
|
+ if (!query && !force) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
gameSelectLoading.value = true
|
|
|
- console.log(gameSelectInfo.defaultSelect)
|
|
|
+
|
|
|
const res = (await AxiosInstance.post(AllApi.getGidList, {
|
|
|
active: isFilterNotActiveGame.value,
|
|
|
search: query
|
|
|
})) as ResponseInfo
|
|
|
+
|
|
|
if (res.code !== 0) {
|
|
|
setNavbarGameSelect([])
|
|
|
return false
|
|
@@ -312,12 +337,17 @@ const watchLoadingState = watch(
|
|
|
)
|
|
|
|
|
|
updateGameInfo()
|
|
|
-updateNavbarGameSelect('')
|
|
|
+updateNavbarGameSelect('', true)
|
|
|
onMounted(() => {
|
|
|
// 去加载所有需要的资源
|
|
|
initLoadResource(resourceInfo).then((data) => {
|
|
|
Object.assign(blobUrlInfo, data)
|
|
|
})
|
|
|
+ selectedGame.value = selectInfo.gid
|
|
|
+
|
|
|
+ updateUserInfo({
|
|
|
+ ...userInfo
|
|
|
+ })
|
|
|
})
|
|
|
</script>
|
|
|
|
|
@@ -340,16 +370,18 @@ onMounted(() => {
|
|
|
<el-select
|
|
|
style="width: 100%"
|
|
|
@change="changeGame"
|
|
|
- v-model="gameSelectInfo.defaultSelect"
|
|
|
+ v-model="selectedGame"
|
|
|
:placeholder="gameSelectInfo.title"
|
|
|
filterable
|
|
|
- remote
|
|
|
:loading="gameSelectLoading"
|
|
|
- :remote-method="updateNavbarGameSelect"
|
|
|
v-bind="$attrs"
|
|
|
>
|
|
|
+ <!-- :remote-method="updateNavbarGameSelect"-->
|
|
|
+ <!-- remote-->
|
|
|
<template #header>
|
|
|
- <el-checkbox v-model="isFilterNotActiveGame" @change="updateNavbarGameSelect('')"
|
|
|
+ <el-checkbox
|
|
|
+ v-model="isFilterNotActiveGame"
|
|
|
+ @change="updateNavbarGameSelect('', true)"
|
|
|
>是否过滤不活跃游戏
|
|
|
</el-checkbox>
|
|
|
</template>
|
|
@@ -394,17 +426,18 @@ onMounted(() => {
|
|
|
</el-menu>
|
|
|
</div>
|
|
|
<div class="headPortraitBox">
|
|
|
- <el-popover popper-class="headPopper" placement="bottom-end" trigger="click">
|
|
|
- <template #reference>
|
|
|
- <el-image class="headPortrait" :src="blobUrlInfo.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>
|
|
|
+ <UserHeadIcon :head-icon="blobUrlInfo.defaultHead"></UserHeadIcon>
|
|
|
+ <!-- <el-popover popper-class="headPopper" placement="bottom-end" trigger="click">-->
|
|
|
+ <!-- <template #reference>-->
|
|
|
+ <!-- <el-image class="headPortrait" :src="blobUrlInfo.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>
|
|
|
<!-- 侧边栏 -->
|