|
@@ -7,7 +7,10 @@
|
|
|
*
|
|
|
-->
|
|
|
<script setup lang="ts">
|
|
|
+import { useRequest } from '@/hooks/useRequest.ts'
|
|
|
import type { DropDownInfo } from '@/types/dataAnalysis'
|
|
|
+import type { ResponseInfo } from '@/types/res.ts'
|
|
|
+import AxiosInstance from '@/utils/axios/axiosInstance.ts'
|
|
|
|
|
|
import { zhCn } from 'element-plus/es/locales.mjs'
|
|
|
import { type RouteRecordRaw, RouterView, useRoute } from 'vue-router'
|
|
@@ -21,10 +24,17 @@ import { setLoginState } from '@/utils/localStorage/localStorage'
|
|
|
import { removeAllToken } from '@/utils/token/token'
|
|
|
|
|
|
import router from '@/router'
|
|
|
-import DropDownSelection from '@/components/dataAnalysis/DropDownSelection.vue'
|
|
|
+
|
|
|
+interface GameSelectItemInfo {
|
|
|
+ id: number
|
|
|
+ pid: string
|
|
|
+ gid: string
|
|
|
+ gameName: string
|
|
|
+}
|
|
|
|
|
|
const route = useRoute()
|
|
|
const { selectInfo, allGameInfo, saveSelectInfo } = useCommonStore()
|
|
|
+const { AllApi } = useRequest()
|
|
|
|
|
|
const isCollapse = ref(false)
|
|
|
const navBarSelect = ref<string>('Home')
|
|
@@ -122,6 +132,15 @@ const blobUrlInfo = reactive<Record<string, string>>({})
|
|
|
// 侧边栏跳转路由的基本路由
|
|
|
const basePath = ref<string | undefined>()
|
|
|
|
|
|
+// 是否过滤不活跃的游戏
|
|
|
+const isFilterNotActiveGame = ref<boolean>(false)
|
|
|
+
|
|
|
+// 游戏选择框的选中值
|
|
|
+const gameSelectVal = ref<string>('')
|
|
|
+
|
|
|
+// 游戏选择框的加载状态
|
|
|
+const gameSelectLoading = ref<boolean>(false)
|
|
|
+
|
|
|
/**
|
|
|
* 创建侧边栏菜单
|
|
|
*/
|
|
@@ -186,27 +205,18 @@ watch(
|
|
|
/**
|
|
|
* 获取所有游戏列表
|
|
|
*/
|
|
|
-const getGameInfo = () => {
|
|
|
+const updateGameInfo = () => {
|
|
|
getAllGameInfo()
|
|
|
.then((data) => {
|
|
|
if (data) {
|
|
|
allGameInfo.splice(0, allGameInfo.length)
|
|
|
- gameSelectInfo.optionsList.splice(0, gameSelectInfo.optionsList.length)
|
|
|
+
|
|
|
data.map((item) => {
|
|
|
allGameInfo.push({
|
|
|
gid: item.gid,
|
|
|
gameName: item.gameName
|
|
|
})
|
|
|
- gameSelectInfo.optionsList.push({
|
|
|
- value: item.gid,
|
|
|
- label: item.gameName
|
|
|
- })
|
|
|
})
|
|
|
- gameSelectInfo.defaultSelect = data[0].gid
|
|
|
- // 去找本地的gid,如果有,就赋值,否则用请求回来的第一个gid
|
|
|
-
|
|
|
- changeGame(selectInfo.gid)
|
|
|
- gameSelectInfo.defaultSelect = selectInfo.gid
|
|
|
|
|
|
loadingState.value = true
|
|
|
} else {
|
|
@@ -219,6 +229,49 @@ const getGameInfo = () => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 设置导航栏的游戏选择框数据
|
|
|
+ */
|
|
|
+const setNavbarGameSelect = (optionsList: Array<GameSelectItemInfo>) => {
|
|
|
+ gameSelectInfo.optionsList.splice(0, gameSelectInfo.optionsList.length)
|
|
|
+ if (!optionsList || optionsList.length === 0) return
|
|
|
+ optionsList.forEach((item) => {
|
|
|
+ gameSelectInfo.optionsList.push({
|
|
|
+ value: item.gid,
|
|
|
+ label: item.gameName
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ gameSelectInfo.defaultSelect = optionsList[0].gid
|
|
|
+ changeGame(optionsList[0].gid)
|
|
|
+ // 去找本地的gid,如果有,就赋值,否则用请求回来的第一个gid
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取导航栏游戏选择框的数据
|
|
|
+ */
|
|
|
+const updateNavbarGameSelect = async (query: string) => {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ setNavbarGameSelect(res.data)
|
|
|
+ } catch (err) {
|
|
|
+ setNavbarGameSelect([])
|
|
|
+ console.error(err)
|
|
|
+ ElMessage.error('游戏列表获取失败')
|
|
|
+ } finally {
|
|
|
+ gameSelectLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
* 监听游戏列表的变化
|
|
|
*
|
|
|
* 此处只是声明,在后续加载完成后,会被赋值唯一一个监听器
|
|
@@ -258,7 +311,8 @@ const watchLoadingState = watch(
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-getGameInfo()
|
|
|
+updateGameInfo()
|
|
|
+updateNavbarGameSelect('')
|
|
|
onMounted(() => {
|
|
|
// 去加载所有需要的资源
|
|
|
initLoadResource(resourceInfo).then((data) => {
|
|
@@ -282,13 +336,44 @@ onMounted(() => {
|
|
|
<icon-icon-park-game-three></icon-icon-park-game-three>
|
|
|
<!-- <icon-icon-park-solid-ad></icon-icon-park-solid-ad>-->
|
|
|
</el-icon>
|
|
|
- <DropDownSelection
|
|
|
- :default-select="gameSelectInfo.defaultSelect"
|
|
|
- :title="gameSelectInfo.title"
|
|
|
- :options-list="gameSelectInfo.optionsList"
|
|
|
- :size="'default'"
|
|
|
- @change-select="changeGame"
|
|
|
- ></DropDownSelection>
|
|
|
+ <div style="width: 150px">
|
|
|
+ <el-select
|
|
|
+ style="width: 100%"
|
|
|
+ @change="changeGame"
|
|
|
+ v-model="gameSelectInfo.defaultSelect"
|
|
|
+ :placeholder="gameSelectInfo.title"
|
|
|
+ filterable
|
|
|
+ remote
|
|
|
+ :loading="gameSelectLoading"
|
|
|
+ :remote-method="updateNavbarGameSelect"
|
|
|
+ v-bind="$attrs"
|
|
|
+ >
|
|
|
+ <template #header>
|
|
|
+ <el-checkbox v-model="isFilterNotActiveGame" @change="updateNavbarGameSelect('')"
|
|
|
+ >是否过滤不活跃游戏
|
|
|
+ </el-checkbox>
|
|
|
+ </template>
|
|
|
+ <el-option
|
|
|
+ v-for="item in gameSelectInfo.optionsList"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <!-- <DropDownSelection-->
|
|
|
+ <!-- :default-select="gameSelectInfo.defaultSelect"-->
|
|
|
+ <!-- :title="gameSelectInfo.title"-->
|
|
|
+ <!-- :options-list="gameSelectInfo.optionsList"-->
|
|
|
+ <!-- :size="'default'"-->
|
|
|
+ <!-- @change-select="changeGame"-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- <template #header>-->
|
|
|
+ <!-- <el-checkbox v-model="isFilterNotActiveGame" @change="updateGameInfo"-->
|
|
|
+ <!-- >是否过滤不活跃游戏</el-checkbox-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- </template>-->
|
|
|
+ <!-- </DropDownSelection>-->
|
|
|
</div>
|
|
|
<!-- 顶部导航栏 -->
|
|
|
|
|
@@ -333,7 +418,8 @@ onMounted(() => {
|
|
|
:key="item.name"
|
|
|
>
|
|
|
<template #title>
|
|
|
- <el-icon><component :is="item.icon"></component></el-icon>
|
|
|
+ <!-- <el-icon><component :is="item.icon"></component></el-icon>-->
|
|
|
+ <DynamicIcon :icon="item.icon" />
|
|
|
<span>{{ item.cnName }}</span>
|
|
|
</template>
|
|
|
<router-link
|
|
@@ -353,7 +439,8 @@ onMounted(() => {
|
|
|
:key="index"
|
|
|
>
|
|
|
<el-menu-item :index="item.path">
|
|
|
- <el-icon><component :is="item.icon" /></el-icon>
|
|
|
+ <!-- <el-icon><component :is="item.icon" /></el-icon>-->
|
|
|
+ <DynamicIcon :icon="item.icon" />
|
|
|
<template #title>
|
|
|
<span class="menuTitle">{{ item.cnName }}</span>
|
|
|
</template>
|