diff --git a/src/components/Sidebar/Sidebar.svelte b/src/components/Sidebar/Sidebar.svelte index e29cc13e..99fd8ba5 100644 --- a/src/components/Sidebar/Sidebar.svelte +++ b/src/components/Sidebar/Sidebar.svelte @@ -60,6 +60,7 @@ {/if} + + import { mdiChevronRight, mdiEarth, mdiLoading, mdiStar } from '@mdi/js'; + import { onMount, createEventDispatcher, tick } from 'svelte'; + + import { t } from 'svelte-i18n'; + import Icon from '../../components/Icon.svelte'; + + const numberFormat = Intl.NumberFormat('en', { + maximumFractionDigits: 0, + minimumFractionDigits: 0, + }); + + const dispatch = createEventDispatcher(); + + export let featured; + export let bannerId; + + let loading = true; + let featuredPull = 0; + let percentage = '...'; + let average = '...'; + + async function getData() { + const url = new URL(`${__paimon.env.API_HOST}/wish`); + const query = new URLSearchParams({ banner: bannerId }); + url.search = query.toString(); + + try { + const res = await fetch(url, { + method: 'GET', + headers: { 'Content-Type': 'application/json' }, + }); + + const data = await res.json(); + + const item = data.list.find((e) => e.name === featured); + featuredPull = item.count; + percentage = numberFormat.format((item.count / data.total.legendary) * 100); + average = numberFormat.format(data.pityAverage.legendary); + + loading = false; + } catch (err) { + console.error(err); + } + } + + onMount(async () => { + getData(); + await tick(); + dispatch('done'); + }); + + +
+
+ venti +
+

+ {#if loading} + + {:else} + {featuredPull} + {/if} +

+
+

{$t('home.banner.featured')}

+

{$t('home.banner.summoned')}

+
+
+
+
+

+ {percentage}% + {$t('home.banner.percentage')} +

+

{$t('home.banner.avg')} {average}

+
+

※ {$t('home.banner.subtitle')}

+ + + {$t('home.banner.detail')} + + +
diff --git a/src/routes/_index/calculator.svelte b/src/routes/_index/calculator.svelte new file mode 100644 index 00000000..00993e3c --- /dev/null +++ b/src/routes/_index/calculator.svelte @@ -0,0 +1,19 @@ + + +
+

{$t('home.calculator.title')}

+ + wish + {$t('home.calculator.detail')} + + +
diff --git a/src/routes/_index/discord.svelte b/src/routes/_index/discord.svelte new file mode 100644 index 00000000..99ebad46 --- /dev/null +++ b/src/routes/_index/discord.svelte @@ -0,0 +1,49 @@ + + +
+ discord +

+ ⬤ + {online} + {$t('home.discord.online')} +

+

+ {$t('home.discord.message')} +

+ + {$t('home.discord.join')} + + +
diff --git a/src/routes/_index/event.svelte b/src/routes/_index/event.svelte new file mode 100644 index 00000000..ecdcc496 --- /dev/null +++ b/src/routes/_index/event.svelte @@ -0,0 +1,91 @@ + + +
+ {#if upcoming.length > 0} +

{$t('home.event.upcoming')}

+
+ {#each upcoming as item} +
+ + {item.name} + + {item.time} +
+ {/each} +
+ {/if} + {#if current.length > 0} +

{$t('home.event.current')}

+
+ {#each current as item} +
+ + {item.name} + + {item.time} +
+ {/each} +
+ {/if} + + wish + {$t('home.event.detail')} + + +
diff --git a/src/routes/_index/item.svelte b/src/routes/_index/item.svelte new file mode 100644 index 00000000..577b238f --- /dev/null +++ b/src/routes/_index/item.svelte @@ -0,0 +1,96 @@ + + +
+

{$t('home.items.title')}

+ + {#each Object.entries(characterItems) as [id, characters]} + + + + + {/each} + + + +
+ {id} + + {#each characters as char} + {char} + {/each} +
+ {#each Object.entries(weaponItems) as [id, _]} +
+ {id} +
+ {/each} +
+ + wish + {$t('home.items.detail')} + + +
diff --git a/src/routes/_index/reminder.svelte b/src/routes/_index/reminder.svelte new file mode 100644 index 00000000..bd64976d --- /dev/null +++ b/src/routes/_index/reminder.svelte @@ -0,0 +1,17 @@ + + +
+

{$t('home.reminder.message')}

+
+ + {$t('home.reminder.detail')} + +
+
diff --git a/src/routes/_index/welcome.svelte b/src/routes/_index/welcome.svelte new file mode 100644 index 00000000..6688b2fa --- /dev/null +++ b/src/routes/_index/welcome.svelte @@ -0,0 +1,8 @@ + + +
+

{$t('home.welcome')}

+

{$t('home.message')}

+
diff --git a/src/routes/_index/wish.svelte b/src/routes/_index/wish.svelte new file mode 100644 index 00000000..3ddc5966 --- /dev/null +++ b/src/routes/_index/wish.svelte @@ -0,0 +1,107 @@ + + +
+ {#if latestPull === null} +

{$t('home.wish.message')}

+ {:else} +

{$t('home.wish.latest')}

+
+
+ {latestPull.id} +
+ + + + + + + + + + + + + + + + + +
{$t('home.wish.banner')}{latestBanner.name}
{$t('home.wish.time')}{dayjs.unix(latestPull.time).format('ddd YYYY-MM-DD HH:mm:ss')}
{$t('home.wish.name')} + {latestPull.type === 'character' + ? characters[latestPull.id].name + : latestPull.type === 'weapon' + ? weaponList[latestPull.id].name + : 'Unknown'} +
{$t('home.wish.pity')}{latestPull.pity}
+
+ {/if} + + wish + {$t('home.wish.detail')} + + +
diff --git a/src/routes/_layout.svelte b/src/routes/_layout.svelte index 0c2ed7cc..08899770 100644 --- a/src/routes/_layout.svelte +++ b/src/routes/_layout.svelte @@ -77,7 +77,7 @@
Discord diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 3b15c2f6..ee298260 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -1,5 +1,52 @@ - - + + Paimon.moe + + + +
+ + + + + + + + + + +
diff --git a/static/images/home.png b/static/images/home.png new file mode 100644 index 00000000..7df537ba Binary files /dev/null and b/static/images/home.png differ diff --git a/static/images/home/discord.svg b/static/images/home/discord.svg new file mode 100644 index 00000000..22dd1136 --- /dev/null +++ b/static/images/home/discord.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/images/home/venti.png b/static/images/home/venti.png new file mode 100644 index 00000000..4450c81e Binary files /dev/null and b/static/images/home/venti.png differ