|
|
@@ -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,
|
|
|
|