Эх сурвалжийг харах

fix(成员管理页): 修复成员管理表格游戏名显示错误问题

fxs 1 долоо хоног өмнө
parent
commit
9f5808ff0c

+ 22 - 11
src/stores/useCommon.ts

@@ -61,7 +61,7 @@ const getMultipleChoice = (): string[] | null => {
   return tempPf
 }
 
-const updateGameList = async () => {
+const getGameList = async () => {
   const response = (await axiosInstance.post(AllApi.pidToGidList, {
     active: false
   })) as ResponseInfo
@@ -73,7 +73,8 @@ const updateGameList = async () => {
   return {
     gid: data[0].gidList[0].gid,
     pf: defaultPf,
-    tempPf: defaultPf
+    tempPf: defaultPf,
+    gameInfoList: data
   }
 }
 
@@ -85,26 +86,29 @@ const updateGameList = async () => {
 export const initSelect = async () => {
   let gid: string = '',
     pf: Array<string>,
-    multiPf: Array<string>
+    multiPf: Array<string>,
+    gameInfoList: Array<PlatformInfo>
 
   const localSelectInfo = getSelectInfo()
   const localMultiPf = getMultipleChoice()
+  const res = await getGameList()
+  if (!res) {
+    throw new Error('获取游戏列表失败')
+  }
+
   if (!localSelectInfo || !localMultiPf) {
-    const res = await updateGameList()
-    if (!res) {
-      throw new Error('获取游戏列表失败')
-    }
-    console.log('使用新的')
     gid = res.gid
     pf = res.pf
     multiPf = res.pf
+    gameInfoList = res.gameInfoList
   } else {
     gid = localSelectInfo.gid
     pf = localSelectInfo.pf
     multiPf = localMultiPf
+    gameInfoList = res.gameInfoList
   }
 
-  return { gid, pf, multiPf }
+  return { gid, pf, multiPf, gameInfoList }
 }
 
 export const useCommonStore = defineStore('commonStore', () => {
@@ -120,6 +124,9 @@ export const useCommonStore = defineStore('commonStore', () => {
     pf: defaultPf
   })
 
+  const gameInfoList = reactive<Array<PlatformInfo>>([])
+  const allGameInfo = reactive<Array<GameInfo>>([])
+
   // initSelect(selectInfo, multipleChoice)
 
   /**
@@ -150,13 +157,17 @@ export const useCommonStore = defineStore('commonStore', () => {
     saveLocalInfo('tempMultipleChoice', newMultipleChoice)
   }
 
-  const gameInfoList = reactive<Array<PlatformInfo>>([])
-  const allGameInfo = reactive<Array<GameInfo>>([])
+  const updateGameInfoList = (newGameInfoList: Array<PlatformInfo>) => {
+    // Object.assign(gameInfoList, newGameInfoList)
+    gameInfoList.splice(0, gameInfoList.length, ...newGameInfoList)
+  }
+
   return {
     gameInfoList,
     selectInfo,
     allGameInfo,
     updateSelectInfo,
+    updateGameInfoList,
     tempMultipleChoice: multipleChoice,
     saveSelectInfo,
 

+ 5 - 3
src/views/IndexView.vue

@@ -47,7 +47,8 @@ import router from '@/router'
 // }
 
 const route = useRoute()
-const { selectInfo, gameInfoList, saveSelectInfo, updateSelectInfo } = useCommonStore()
+const { selectInfo, gameInfoList, saveSelectInfo, updateSelectInfo, updateGameInfoList } =
+  useCommonStore()
 const { AllApi } = useRequest()
 const { updateUserInfo } = useUser()
 
@@ -357,7 +358,7 @@ onMounted(async () => {
   // // 去加载所有需要的资源
   // // await updateNavbarGameSelect('', true)
   // // await updateGameInfo()
-  const { gid, pf, multiPf } = await initSelect()
+  const { gid, pf, multiPf, gameInfoList } = await initSelect()
   updateSelectInfo(
     {
       pf,
@@ -368,7 +369,8 @@ onMounted(async () => {
       pf: multiPf
     }
   )
-  console.log(selectInfo)
+  updateGameInfoList(gameInfoList)
+
   await updateNavbarGameSelect('', true)
 
   initLoadResource(resourceInfo).then((data) => {