fix bug fetch data
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 1m35s

This commit is contained in:
2025-08-15 23:43:07 +07:00
parent e2450aa39c
commit 2b1d0b39a6
8 changed files with 9304 additions and 247 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -10,6 +10,8 @@ import { ToastContainer } from 'react-toastify';
import AvatarBar from "@/components/avatarBar"; import AvatarBar from "@/components/avatarBar";
import ActionBar from "@/components/actionBar"; import ActionBar from "@/components/actionBar";
import QueryProviderWrapper from "@/components/queryProvider"; import QueryProviderWrapper from "@/components/queryProvider";
import ClientDataFetcher from "@/components/clientDataFetcher";
const geistSans = Geist({ const geistSans = Geist({
variable: "--font-geist-sans", variable: "--font-geist-sans",
@@ -60,6 +62,7 @@ export default async function RootLayout({
}>) { }>) {
const messages = await getMessages(); const messages = await getMessages();
const locale = await getLocale() const locale = await getLocale()
return ( return (
<html lang={locale} suppressHydrationWarning> <html lang={locale} suppressHydrationWarning>
<body <body
@@ -70,6 +73,7 @@ export default async function RootLayout({
<QueryProviderWrapper> <QueryProviderWrapper>
<ThemeProvider> <ThemeProvider>
<ClientThemeWrapper> <ClientThemeWrapper>
<ClientDataFetcher />
<div className="min-h-screen w-full"> <div className="min-h-screen w-full">
<Header /> <Header />
<div className="grid grid-cols-12 w-full"> <div className="grid grid-cols-12 w-full">

View File

@@ -5,17 +5,6 @@ import CharacterCard from "../card/characterCard"
import useLocaleStore from "@/stores/localeStore" import useLocaleStore from "@/stores/localeStore"
import useAvatarStore from "@/stores/avatarStore" import useAvatarStore from "@/stores/avatarStore"
import { useTranslations } from "next-intl" import { useTranslations } from "next-intl"
import {
useFetchASData,
useFetchAvatarData,
useFetchConfigData,
useFetchLightconeData,
useFetchMOCData,
useFetchMonsterData,
useFetchPEAKData,
useFetchPFData,
useFetchRelicData
} from "@/hooks"
export default function AvatarBar() { export default function AvatarBar() {
@@ -25,15 +14,7 @@ export default function AvatarBar() {
const transI18n = useTranslations("DataPage") const transI18n = useTranslations("DataPage")
const { locale } = useLocaleStore() const { locale } = useLocaleStore()
useFetchConfigData()
useFetchAvatarData()
useFetchLightconeData()
useFetchRelicData()
useFetchMonsterData()
useFetchPFData()
useFetchMOCData()
useFetchASData()
useFetchPEAKData()
useEffect(() => { useEffect(() => {
setFilter({ ...filter, locale: locale, element: Object.keys(listElement).filter((key) => listElement[key]), path: Object.keys(listPath).filter((key) => listPath[key]) }) setFilter({ ...filter, locale: locale, element: Object.keys(listElement).filter((key) => listElement[key]), path: Object.keys(listPath).filter((key) => listPath[key]) })

View File

@@ -0,0 +1,27 @@
"use client";
import {
useFetchASData,
useFetchAvatarData,
useFetchConfigData,
useFetchLightconeData,
useFetchMOCData,
useFetchMonsterData,
useFetchPEAKData,
useFetchPFData,
useFetchRelicData
} from "@/hooks";
export default function ClientDataFetcher() {
useFetchConfigData();
useFetchAvatarData();
useFetchLightconeData();
useFetchRelicData();
useFetchMonsterData();
useFetchPFData();
useFetchMOCData();
useFetchASData();
useFetchPEAKData();
return null;
}

View File

@@ -11,6 +11,7 @@ import { MonsterStore } from "@/types";
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
import useMazeStore from "@/stores/mazeStore"; import useMazeStore from "@/stores/mazeStore";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import { listCurrentLanguageApi } from "@/constant/constant";
export default function AsBar() { export default function AsBar() {
const { ASEvent, mapASInfo } = useEventStore() const { ASEvent, mapASInfo } = useEventStore()
@@ -53,84 +54,88 @@ export default function AsBar() {
useEffect(() => { useEffect(() => {
const challenge = mapASInfo[as_config.event_id.toString()]?.Level.find((as) => as.Id === as_config.challenge_id) if (!challengeSelected || as_config.event_id === 0 || as_config.challenge_id === 0) return
if (as_config.event_id !== 0 && as_config.challenge_id !== 0 && challenge) { const newBattleConfig = cloneDeep(as_config)
const newBattleConfig = cloneDeep(as_config) newBattleConfig.cycle_count = 0
newBattleConfig.cycle_count = 0
newBattleConfig.blessings = [] newBattleConfig.blessings = []
if (as_config.buff_id !== 0) { if (as_config.buff_id !== 0) {
newBattleConfig.blessings.push({ newBattleConfig.blessings.push({
id: as_config.buff_id, id: as_config.buff_id,
level: 1 level: 1
}) })
}
if (AS[as_config.challenge_id.toString()]) {
newBattleConfig.blessings.push({
id: Number(AS[as_config.challenge_id.toString()].maze_buff),
level: 1
})
}
newBattleConfig.monsters = []
newBattleConfig.stage_id = 0
if ((as_config.floor_side === "Upper" || as_config.floor_side === "Upper -> Lower") && challenge.EventIDList1.length > 0) {
newBattleConfig.stage_id = challenge.EventIDList1[0].StageID
for (const wave of challenge.EventIDList1[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challenge.EventIDList1[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
if ((as_config.floor_side === "Lower" || as_config.floor_side === "Lower -> Upper") && challenge.EventIDList2.length > 0) {
newBattleConfig.stage_id = challenge.EventIDList2[0].StageID
for (const wave of challenge.EventIDList2[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challenge.EventIDList2[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
if (as_config.floor_side === "Lower -> Upper" && challenge.EventIDList1.length > 0) {
for (const wave of challenge.EventIDList1[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challenge.EventIDList1[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
} else if (as_config.floor_side === "Upper -> Lower" && challenge.EventIDList2.length > 0) {
for (const wave of challenge.EventIDList2[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challenge.EventIDList2[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
setAsConfig(newBattleConfig)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps if (AS[as_config.challenge_id.toString()]) {
newBattleConfig.blessings.push({
id: Number(AS[as_config.challenge_id.toString()].maze_buff),
level: 1
})
}
newBattleConfig.monsters = []
newBattleConfig.stage_id = 0
if ((as_config.floor_side === "Upper" || as_config.floor_side === "Upper -> Lower")
&& challengeSelected.EventIDList1.length > 0) {
newBattleConfig.stage_id = challengeSelected.EventIDList1[0].StageID
for (const wave of challengeSelected.EventIDList1[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challengeSelected.EventIDList1[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
if ((as_config.floor_side === "Lower" || as_config.floor_side === "Lower -> Upper")
&& challengeSelected.EventIDList2.length > 0) {
newBattleConfig.stage_id = challengeSelected.EventIDList2[0].StageID
for (const wave of challengeSelected.EventIDList2[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challengeSelected.EventIDList2[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
if (as_config.floor_side === "Lower -> Upper"
&& challengeSelected.EventIDList1.length > 0) {
for (const wave of challengeSelected.EventIDList1[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challengeSelected.EventIDList1[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
} else if (as_config.floor_side === "Upper -> Lower"
&& challengeSelected.EventIDList2.length > 0) {
for (const wave of challengeSelected.EventIDList2[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challengeSelected.EventIDList2[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
setAsConfig(newBattleConfig)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ }, [
challengeSelected,
as_config.event_id, as_config.event_id,
as_config.challenge_id, as_config.challenge_id,
as_config.floor_side, as_config.floor_side,
@@ -139,7 +144,7 @@ export default function AsBar() {
AS, AS,
]) ])
if (!ASEvent) return null
return ( return (
<div className="container mx-auto px-4 py-8 relative"> <div className="container mx-auto px-4 py-8 relative">
@@ -147,7 +152,7 @@ export default function AsBar() {
<div className="rounded-xl p-4 mb-2 border border-warning"> <div className="rounded-xl p-4 mb-2 border border-warning">
<div className="mb-4 w-full"> <div className="mb-4 w-full">
<SelectCustomText <SelectCustomText
customSet={ASEvent.filter(as => as.lang.get(locale)).map((as) => ({ customSet={ASEvent.filter(as => as.lang.get(listCurrentLanguageApi[locale])).map((as) => ({
id: as.id, id: as.id,
name: getLocaleName(locale, as), name: getLocaleName(locale, as),
time: `${as.begin} - ${as.end}`, time: `${as.begin} - ${as.end}`,

View File

@@ -111,7 +111,7 @@ export default function MocBar() {
moc_config.use_cycle_count, moc_config.use_cycle_count,
moc_config.use_turbulence_buff, moc_config.use_turbulence_buff,
]) ])
if (!MOCEvent) return null
return ( return (
<div className="container mx-auto px-4 py-8 relative"> <div className="container mx-auto px-4 py-8 relative">

View File

@@ -8,7 +8,6 @@ import useUserDataStore from "@/stores/userDataStore";
import useMonsterStore from "@/stores/monsterStore"; import useMonsterStore from "@/stores/monsterStore";
import Image from "next/image"; import Image from "next/image";
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import { MonsterStore } from "@/types"; import { MonsterStore } from "@/types";
@@ -99,6 +98,7 @@ export default function PeakBar() {
mapPEAKInfo, mapPEAKInfo,
]) ])
if (!PEAKEvent) return null
return ( return (
<div className="container mx-auto px-4 py-8 relative"> <div className="container mx-auto px-4 py-8 relative">
@@ -106,8 +106,11 @@ export default function PeakBar() {
{/* Title Card */} {/* Title Card */}
<div className="rounded-xl p-4 mb-2 border border-warning"> <div className="rounded-xl p-4 mb-2 border border-warning">
<div className="mb-4 w-full"> <div className="mb-4 w-full">
{PEAKEvent.map((peak) => (
<div key={peak.id}>{peak.id}</div>
))}
<SelectCustomText <SelectCustomText
customSet={PEAKEvent.filter(peak => peak.lang.get(locale)).map((peak) => ({ customSet={PEAKEvent.map((peak) => ({
id: peak.id, id: peak.id,
name: `${getLocaleName(locale, peak)} (${peak.id}) `, name: `${getLocaleName(locale, peak)} (${peak.id}) `,
}))} }))}

View File

@@ -32,83 +32,84 @@ export default function PfBar() {
}, [pf_config, mapPFInfo]) }, [pf_config, mapPFInfo])
useEffect(() => { useEffect(() => {
const challenge = mapPFInfo[pf_config.event_id.toString()]?.Level.find((pf) => pf.Id === pf_config.challenge_id) if (!challengeSelected || pf_config.event_id === 0 || pf_config.challenge_id === 0) {
if (pf_config.event_id !== 0 && pf_config.challenge_id !== 0 && challenge) { return
const newBattleConfig = cloneDeep(pf_config)
newBattleConfig.cycle_count = 4
newBattleConfig.blessings = []
if (pf_config.buff_id !== 0) {
newBattleConfig.blessings.push({
id: pf_config.buff_id,
level: 1
})
}
if (PF[pf_config.challenge_id.toString()]) {
newBattleConfig.blessings.push({
id: Number(PF[pf_config.challenge_id.toString()].maze_buff),
level: 1
})
}
newBattleConfig.monsters = []
newBattleConfig.stage_id = 0
if ((pf_config.floor_side === "Upper" || pf_config.floor_side === "Upper -> Lower" ) && challenge.EventIDList1.length > 0 ) {
newBattleConfig.stage_id = challenge.EventIDList1[0].StageID
for (const wave of challenge.EventIDList1[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challenge.EventIDList1[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
if ((pf_config.floor_side === "Lower" || pf_config.floor_side === "Lower -> Upper") && challenge.EventIDList2.length > 0) {
newBattleConfig.stage_id = challenge.EventIDList2[0].StageID
for (const wave of challenge.EventIDList2[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challenge.EventIDList2[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
if (pf_config.floor_side === "Lower -> Upper" && challenge.EventIDList1.length > 0) {
for (const wave of challenge.EventIDList1[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challenge.EventIDList1[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
} else if (pf_config.floor_side === "Upper -> Lower" && challenge.EventIDList2.length > 0) {
for (const wave of challenge.EventIDList2[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challenge.EventIDList2[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
setPfConfig(newBattleConfig)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps const newBattleConfig = cloneDeep(pf_config)
newBattleConfig.cycle_count = 4
newBattleConfig.blessings = []
if (pf_config.buff_id !== 0) {
newBattleConfig.blessings.push({
id: pf_config.buff_id,
level: 1
})
}
if (PF[pf_config.challenge_id.toString()]) {
newBattleConfig.blessings.push({
id: Number(PF[pf_config.challenge_id.toString()].maze_buff),
level: 1
})
}
newBattleConfig.monsters = []
newBattleConfig.stage_id = 0
if ((pf_config.floor_side === "Upper" || pf_config.floor_side === "Upper -> Lower") && challengeSelected.EventIDList1.length > 0) {
newBattleConfig.stage_id = challengeSelected.EventIDList1[0].StageID
for (const wave of challengeSelected.EventIDList1[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challengeSelected.EventIDList1[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
if ((pf_config.floor_side === "Lower" || pf_config.floor_side === "Lower -> Upper") && challengeSelected.EventIDList2.length > 0) {
newBattleConfig.stage_id = challengeSelected.EventIDList2[0].StageID
for (const wave of challengeSelected.EventIDList2[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challengeSelected.EventIDList2[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
if (pf_config.floor_side === "Lower -> Upper" && challengeSelected.EventIDList1.length > 0) {
for (const wave of challengeSelected.EventIDList1[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challengeSelected.EventIDList1[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
} else if (pf_config.floor_side === "Upper -> Lower" && challengeSelected.EventIDList2.length > 0) {
for (const wave of challengeSelected.EventIDList2[0].MonsterList) {
const newWave: MonsterStore[] = []
for (const value of Object.values(wave)) {
newWave.push({
monster_id: Number(value),
level: challengeSelected.EventIDList2[0].Level,
amount: 1,
})
}
newBattleConfig.monsters.push(newWave)
}
}
setPfConfig(newBattleConfig)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ }, [
challengeSelected,
pf_config.event_id, pf_config.event_id,
pf_config.challenge_id, pf_config.challenge_id,
pf_config.floor_side, pf_config.floor_side,
@@ -116,7 +117,7 @@ export default function PfBar() {
mapPFInfo, mapPFInfo,
PF, PF,
]) ])
if (!PFEvent) return null
return ( return (
<div className="container mx-auto px-4 py-8 relative"> <div className="container mx-auto px-4 py-8 relative">