mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2024-12-22 06:25:10 +01:00
Separate build getter
This commit is contained in:
parent
e780ab18bf
commit
edc036f62f
4 changed files with 34 additions and 6 deletions
|
@ -4,13 +4,13 @@
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
|
||||||
import { characters } from '../../data/characters';
|
import { characters } from '../../data/characters';
|
||||||
import { builds } from '../../data/build';
|
|
||||||
|
|
||||||
import Icon from '../../components/Icon.svelte';
|
import Icon from '../../components/Icon.svelte';
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
const promoted = ['kaedehara_kazuha', 'shikanoin_heizou'];
|
export let builds;
|
||||||
|
const promoted = Object.keys(builds);
|
||||||
let current = 0;
|
let current = 0;
|
||||||
|
|
||||||
async function change(index) {
|
async function change(index) {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<script context="module">
|
<script context="module">
|
||||||
import { builds as buildsJson } from '../../data/build';
|
|
||||||
import artifactData from '../../data/artifacts/en.json';
|
import artifactData from '../../data/artifacts/en.json';
|
||||||
import weaponData from '../../data/weapons/en.json';
|
import weaponData from '../../data/weapons/en.json';
|
||||||
|
|
||||||
export async function load({ params }) {
|
export async function load({ params, fetch }) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const data = await import(`../../data/characterData/${id}.json`);
|
const data = await import(`../../data/characterData/${id}.json`);
|
||||||
const buildData = buildsJson[id];
|
const buildData = await (await fetch(`/characters/build/${id}.json`)).json();
|
||||||
|
|
||||||
return { props: { id, data, buildData } };
|
return { props: { id, data, buildData } };
|
||||||
}
|
}
|
||||||
|
|
11
src/routes/characters/build/[id].json.js
Normal file
11
src/routes/characters/build/[id].json.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { builds } from '../../../data/build';
|
||||||
|
|
||||||
|
/** @type {import('./__types/items').RequestHandler} */
|
||||||
|
export async function GET({ params }) {
|
||||||
|
const { id } = params;
|
||||||
|
const build = builds[id];
|
||||||
|
|
||||||
|
return {
|
||||||
|
body: build,
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,3 +1,19 @@
|
||||||
|
<script context="module">
|
||||||
|
export async function load({ fetch }) {
|
||||||
|
const promoted = ['kaedehara_kazuha', 'shikanoin_heizou'];
|
||||||
|
const builds = {};
|
||||||
|
for (const p of promoted) {
|
||||||
|
const response = await fetch(`/characters/build/${p}.json`);
|
||||||
|
const b = await response.json();
|
||||||
|
builds[p] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: { builds },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import debounce from 'lodash.debounce';
|
import debounce from 'lodash.debounce';
|
||||||
|
@ -19,6 +35,8 @@
|
||||||
import Build from './_index/build.svelte';
|
import Build from './_index/build.svelte';
|
||||||
import Ad from '../components/Ad.svelte';
|
import Ad from '../components/Ad.svelte';
|
||||||
|
|
||||||
|
export let builds;
|
||||||
|
|
||||||
let refreshLayout;
|
let refreshLayout;
|
||||||
let isMobile = false;
|
let isMobile = false;
|
||||||
|
|
||||||
|
@ -64,7 +82,7 @@
|
||||||
<Ad type="mobile" variant="mpu" id="1" />
|
<Ad type="mobile" variant="mpu" id="1" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<Build on:done={onDone} />
|
<Build on:done={onDone} {builds} />
|
||||||
<Event on:done={onDone} />
|
<Event on:done={onDone} />
|
||||||
<Item on:done={onDone} />
|
<Item on:done={onDone} />
|
||||||
<Discord on:done={onDone} />
|
<Discord on:done={onDone} />
|
||||||
|
|
Loading…
Reference in a new issue