豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 055290c

Browse files
authored
Merge pull request #310 from SkyCryptWebsite/dev
Use combined endpoint for sections data and refactor components
2 parents f77e022 + a7ff238 commit 055290c

35 files changed

+559
-2918
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"skycrypt-frontend": patch
3+
---
4+
5+
fix: refactor SectionBoundary to use query function instead of promise

.changeset/modern-eggs-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"skycrypt-frontend": minor
3+
---
4+
5+
feat: use the combined endpoint for the sections data

.changeset/ninety-plants-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"skycrypt-frontend": minor
3+
---
4+
5+
feat: refactor inventory components to improve data fetching and rendering logic

.changeset/pre.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"mode": "pre",
3+
"tag": "beta",
4+
"initialVersions": {
5+
"skycrypt-frontend": "3.4.1"
6+
},
7+
"changesets": [
8+
"chilly-garlics-divide",
9+
"modern-eggs-shave",
10+
"ninety-plants-bathe"
11+
]
12+
}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 3.5.0-beta.0
4+
5+
### Minor Changes
6+
7+
- feat: use the combined endpoint for the sections data ([`638f564`](https://github.com/SkyCryptWebsite/SkyCrypt-Frontend/commit/638f564eb6e904eb08b847460d95ab430f4c26aa))
8+
9+
- feat: refactor inventory components to improve data fetching and rendering logic ([`2c80f2d`](https://github.com/SkyCryptWebsite/SkyCrypt-Frontend/commit/2c80f2d153a3cbd324f307458e4a43ee99c1d852))
10+
11+
### Patch Changes
12+
13+
- fix: refactor SectionBoundary to use query function instead of promise ([`bd7398b`](https://github.com/SkyCryptWebsite/SkyCrypt-Frontend/commit/bd7398b93213bbd0db3ca24ba83bbb79c7765b7e))
14+
315
## 3.4.1
416

517
### Patch Changes

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "skycrypt-frontend",
3-
"version": "3.4.1",
3+
"version": "3.5.0-beta.0",
44
"private": true,
55
"type": "module",
66
"repository": {
@@ -108,7 +108,7 @@
108108
"@sentry/sveltekit": "^10.47.0",
109109
"culori": "^4.0.2",
110110
"simple-git-hooks": "^2.13.1",
111-
"takumi-js": "1.0.0-rc.14"
111+
"takumi-js": "1.0.0-rc.15"
112112
},
113113
"engines": {
114114
"node": "^24",

pnpm-lock.yaml

Lines changed: 51 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context/createContext.svelte.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { IsHover } from "$lib/hooks/is-hover.svelte";
22
import type { IsMobile } from "$lib/hooks/is-mobile.svelte";
3-
import type { ModelsMiscOutput, ModelsResourcePackConfig, ModelsSkillsOutput, ModelsStatsOutput } from "$lib/shared/api/orval-generated";
3+
import type { ModelsCombinedOutput, ModelsMiscOutput, ModelsResourcePackConfig, ModelsSkillsOutput, ModelsStatsOutput } from "$lib/shared/api/orval-generated";
4+
import type { RemoteQuery } from "@sveltejs/kit";
45
import { createContext } from "svelte";
56

67
export class ProfileContext {
@@ -15,6 +16,30 @@ export class ProfileContext {
1516
}
1617
}
1718

19+
export class CombinedContext {
20+
#current: ModelsCombinedOutput | null = $state(null);
21+
22+
get current() {
23+
return this.#current;
24+
}
25+
26+
set current(value: ModelsCombinedOutput | null) {
27+
this.#current = value;
28+
}
29+
}
30+
31+
export class CombinedQueryContext {
32+
#current: RemoteQuery<ModelsCombinedOutput> | null = $state(null);
33+
34+
get current() {
35+
return this.#current;
36+
}
37+
38+
set current(value: RemoteQuery<ModelsCombinedOutput> | null) {
39+
this.#current = value;
40+
}
41+
}
42+
1843
export class PacksContext {
1944
#packs: ModelsResourcePackConfig[] = $state([]);
2045

@@ -52,6 +77,8 @@ export class SkillsContext {
5277
}
5378

5479
export const [getProfileContext, setProfileContext] = createContext<ProfileContext>();
80+
export const [getCombinedContext, setCombinedContext] = createContext<CombinedContext>();
81+
export const [getCombinedQueryContext, setCombinedQueryContext] = createContext<CombinedQueryContext>();
5582
export const [getSkillsContext, setSkillsContext] = createContext<SkillsContext>();
5683
export const [getMiscContext, setMiscContext] = createContext<MiscContext>();
5784
export const [getMobileContext, setMobileContext] = createContext<IsMobile>();

src/lib/components/header/Header.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
const packageVersion = __NPM_PACKAGE_VERSION__;
1616
</script>
1717

18+
<div class="invisible h-12 w-full"></div>
1819
<header class="@container fixed top-0 left-0 z-30 h-12 w-full overflow-clip bg-header px-2.5 pt-[env(safe-area-inset-top,0)] pr-[max(0.625rem,env(safe-area-inset-right))] pb-[env(safe-area-inset-bottom,0)] pl-[max(0.625rem,env(safe-area-inset-left))] leading-12">
1920
<div class="flex h-full w-full justify-center @md:justify-between">
2021
<div class="flex gap-2">
Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
11
<script lang="ts">
22
import { getPreferences } from "$ctx";
3-
import { SectionBoundary } from "$lib/components/sections";
43
import { type ModelsStrippedItem } from "$lib/shared/api/orval-generated";
5-
import { getInventorySection } from "$lib/shared/api/skycrypt-api.remote";
64
import { shouldShine } from "$lib/shared/helper";
75
import type { Snippet } from "svelte";
86
97
const preferences = getPreferences();
108
11-
let { uuid, profileId, inventoryId, gap, itemSnippet }: { uuid: string; profileId: string; inventoryId: string; gap: number; itemSnippet: Snippet<[ModelsStrippedItem]> } = $props();
9+
let { inventoryId, gap, itemSnippet, items = [] }: { inventoryId: string; gap: number; itemSnippet: Snippet<[ModelsStrippedItem]>; items?: ModelsStrippedItem[] } = $props();
1210
</script>
1311

14-
<SectionBoundary promise={getInventorySection({ uuid, profileId, inventoryId })}>
15-
{#snippet children(items)}
16-
{#if items?.length ?? 0 > 0}
17-
<div class="grid grid-cols-[repeat(9,minmax(1.875rem,4.875rem))] place-content-center gap-1 pt-5 @md:gap-1.5 @xl:gap-2">
18-
{#each items as item, index (index)}
19-
{#if index > 0}
20-
{#if index % gap === 0}
21-
<hr class="col-span-full h-4 border-0" />
22-
{/if}
12+
{#snippet content(items: ModelsStrippedItem[] | undefined)}
13+
{#if items?.length ?? 0 > 0}
14+
<div class="grid grid-cols-[repeat(9,minmax(1.875rem,4.875rem))] place-content-center gap-1 pt-5 @md:gap-1.5 @xl:gap-2">
15+
{#each items as item, index (index)}
16+
{#if index > 0}
17+
{#if index % gap === 0}
18+
<hr class="col-span-full h-4 border-0" />
2319
{/if}
24-
{#if item.texture_path}
25-
<div class="relative flex aspect-square items-center justify-center rounded-sm bg-text/4 data-[shine=true]:shine" data-shine={!preferences.performanceMode && shouldShine(item)}>
26-
{@render itemSnippet(inventoryId === "inventory" ? ({ ...item, rarity: item.rarity ?? "uncommon" } as ModelsStrippedItem) : item)}
27-
</div>
28-
{:else}
29-
<div class="aspect-square rounded-sm bg-text/4"></div>
30-
{/if}
31-
{/each}
32-
</div>
33-
{:else}
34-
<p class="mt-2 space-x-0.5 text-center leading-6">
35-
No items found in the {inventoryId.replaceAll("_", " ")}.
36-
</p>
37-
{/if}
38-
{/snippet}
39-
</SectionBoundary>
20+
{/if}
21+
{#if item.texture_path}
22+
<div class="relative flex aspect-square items-center justify-center rounded-sm bg-text/4 data-[shine=true]:shine" data-shine={!preferences.performanceMode && shouldShine(item)}>
23+
{@render itemSnippet(inventoryId === "inventory" ? ({ ...item, rarity: item.rarity ?? "uncommon" } as ModelsStrippedItem) : item)}
24+
</div>
25+
{:else}
26+
<div class="aspect-square rounded-sm bg-text/4"></div>
27+
{/if}
28+
{/each}
29+
</div>
30+
{:else}
31+
<p class="mt-2 space-x-0.5 text-center leading-6">
32+
No items found in the {inventoryId.replaceAll("_", " ")}.
33+
</p>
34+
{/if}
35+
{/snippet}
36+
37+
{@render content(items)}

0 commit comments

Comments
 (0)