fetch wiki data client-side to bypass cloudflare
This commit is contained in:
parent
ed6a9fd2f4
commit
b50c1854d6
3 changed files with 32 additions and 9 deletions
|
|
@ -10,6 +10,7 @@
|
|||
import { entityQueries } from '$lib/api/queries/entity.queries'
|
||||
import { entityAdapter } from '$lib/api/adapters/entity.adapter'
|
||||
import { withInitialData } from '$lib/query/ssr'
|
||||
import { fetchWikiPage } from '$lib/api/wiki'
|
||||
|
||||
// Components
|
||||
import DetailScaffold, { type DetailTab } from '$lib/features/database/detail/DetailScaffold.svelte'
|
||||
|
|
@ -275,11 +276,17 @@
|
|||
gameRawJp={rawDataQuery.data?.gameRawJp}
|
||||
isLoading={rawDataQuery.isLoading}
|
||||
{canEdit}
|
||||
onFetchWiki={canEdit && character?.id
|
||||
onFetchWiki={canEdit && character?.id && character?.wiki?.en
|
||||
? async () => {
|
||||
const result = await entityAdapter.fetchCharacterWiki(character.id)
|
||||
// Fetch wiki data client-side (bypasses CloudFlare)
|
||||
const wikiResult = await fetchWikiPage(character.wiki!.en!)
|
||||
if (wikiResult.error) {
|
||||
throw new Error(wikiResult.error)
|
||||
}
|
||||
// Update the character with the wiki_raw data
|
||||
await entityAdapter.updateCharacter(character.id, { wiki_raw: wikiResult.wikiRaw })
|
||||
rawDataQuery.refetch()
|
||||
return result
|
||||
return { wikiRaw: wikiResult.wikiRaw ?? null, gameRawEn: null, gameRawJp: null }
|
||||
}
|
||||
: undefined}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
import { entityQueries } from '$lib/api/queries/entity.queries'
|
||||
import { entityAdapter } from '$lib/api/adapters/entity.adapter'
|
||||
import { withInitialData } from '$lib/query/ssr'
|
||||
import { fetchWikiPage } from '$lib/api/wiki'
|
||||
|
||||
// Components
|
||||
import DetailScaffold, { type DetailTab } from '$lib/features/database/detail/DetailScaffold.svelte'
|
||||
|
|
@ -303,11 +304,17 @@
|
|||
gameRawJp={rawDataQuery.data?.gameRawJp}
|
||||
isLoading={rawDataQuery.isLoading}
|
||||
{canEdit}
|
||||
onFetchWiki={canEdit && summon?.id
|
||||
onFetchWiki={canEdit && summon?.id && summon?.wiki?.en
|
||||
? async () => {
|
||||
const result = await entityAdapter.fetchSummonWiki(summon.id)
|
||||
// Fetch wiki data client-side (bypasses CloudFlare)
|
||||
const wikiResult = await fetchWikiPage(summon.wiki!.en!)
|
||||
if (wikiResult.error) {
|
||||
throw new Error(wikiResult.error)
|
||||
}
|
||||
// Update the summon with the wiki_raw data
|
||||
await entityAdapter.updateSummon(summon.id, { wiki_raw: wikiResult.wikiRaw })
|
||||
rawDataQuery.refetch()
|
||||
return result
|
||||
return { wikiRaw: wikiResult.wikiRaw ?? null, gameRawEn: null, gameRawJp: null }
|
||||
}
|
||||
: undefined}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
import { entityQueries } from '$lib/api/queries/entity.queries'
|
||||
import { entityAdapter } from '$lib/api/adapters/entity.adapter'
|
||||
import { withInitialData } from '$lib/query/ssr'
|
||||
import { fetchWikiPage } from '$lib/api/wiki'
|
||||
|
||||
// Components
|
||||
import DetailScaffold, { type DetailTab } from '$lib/features/database/detail/DetailScaffold.svelte'
|
||||
|
|
@ -17,6 +18,7 @@
|
|||
import WeaponUncapSection from '$lib/features/database/weapons/sections/WeaponUncapSection.svelte'
|
||||
import WeaponTaxonomySection from '$lib/features/database/weapons/sections/WeaponTaxonomySection.svelte'
|
||||
import WeaponStatsSection from '$lib/features/database/weapons/sections/WeaponStatsSection.svelte'
|
||||
import WeaponGachaSection from '$lib/features/database/weapons/sections/WeaponGachaSection.svelte'
|
||||
import EntityImagesTab from '$lib/features/database/detail/tabs/EntityImagesTab.svelte'
|
||||
import EntityRawDataTab from '$lib/features/database/detail/tabs/EntityRawDataTab.svelte'
|
||||
import DetailsContainer from '$lib/components/ui/DetailsContainer.svelte'
|
||||
|
|
@ -189,6 +191,7 @@
|
|||
<WeaponUncapSection {weapon} />
|
||||
<WeaponTaxonomySection {weapon} />
|
||||
<WeaponStatsSection {weapon} />
|
||||
<WeaponGachaSection {weapon} />
|
||||
|
||||
{#if weapon.releaseDate || weapon.flbDate || weapon.ulbDate || weapon.transcendenceDate}
|
||||
<DetailsContainer title="Dates">
|
||||
|
|
@ -272,11 +275,17 @@
|
|||
gameRawJp={rawDataQuery.data?.gameRawJp}
|
||||
isLoading={rawDataQuery.isLoading}
|
||||
{canEdit}
|
||||
onFetchWiki={canEdit && weapon?.id
|
||||
onFetchWiki={canEdit && weapon?.id && weapon?.wiki?.en
|
||||
? async () => {
|
||||
const result = await entityAdapter.fetchWeaponWiki(weapon.id)
|
||||
// Fetch wiki data client-side (bypasses CloudFlare)
|
||||
const wikiResult = await fetchWikiPage(weapon.wiki!.en!)
|
||||
if (wikiResult.error) {
|
||||
throw new Error(wikiResult.error)
|
||||
}
|
||||
// Update the weapon with the wiki_raw data
|
||||
await entityAdapter.updateWeapon(weapon.id, { wiki_raw: wikiResult.wikiRaw })
|
||||
rawDataQuery.refetch()
|
||||
return result
|
||||
return { wikiRaw: wikiResult.wikiRaw ?? null, gameRawEn: null, gameRawJp: null }
|
||||
}
|
||||
: undefined}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue