Skip to content

Commit

Permalink
fix(app): not query timestamp in app
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Aug 17, 2023
1 parent 5533800 commit 7bc1b9f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
6 changes: 5 additions & 1 deletion packages/app/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { types, fansubs } from '../constant';
export interface Props {
title: string;
timestamp?: Date;
}
const { title } = Astro.props;
Expand All @@ -25,7 +27,9 @@ const page = Astro.params.page ?? Astro.url.searchParams.get('page') ?? '1';
const enableFeed = page === '1' && !Astro.url.pathname.startsWith('/resource/');
const runtime = getRuntime<Env>(Astro.request);
const timestamp = new Date((await runtime?.env.animegarden.get('state/refresh-timestamp')) ?? 0);
const timestamp =
Astro.props.timestamp ??
new Date((await runtime?.env.animegarden.get('state/refresh-timestamp')) ?? 0);
const hasFansubSearch = search.has('fansubId');
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { wfetch, fetchResources } from '../fetch';
const runtime = getRuntime<Env>(Astro.request);
const { ok, resources } = await fetchResources(
const { ok, resources, timestamp } = await fetchResources(
1,
{ pageSize: 80 },
{ fetch: wfetch(runtime?.env?.worker) }
);
---

<Layout title="Anime Garden">
<Layout title="Anime Garden" timestamp={timestamp}>
<div class="mt-4vh w-full">
{
ok ? (
Expand Down
25 changes: 8 additions & 17 deletions packages/app/src/pages/resources/[page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const {
ok,
complete,
resources,
filter: searchParams
filter: searchParams,
timestamp
} = await fetchResources(
page,
{ ...params },
Expand All @@ -55,7 +56,7 @@ const keywords = {
};
---

<Layout title="所有资源 | Anime Garden">
<Layout title="所有资源 | Anime Garden" timestamp={timestamp}>
<div class="mt-4vh w-full">
{
ok ? (
Expand All @@ -65,19 +66,15 @@ const keywords = {
<div class="mb4 p4 w-full bg-gray-100 rounded-md space-y-2">
{type && (
<div class="space-x-2 select-none text-0">
<span class="text-4 text-base-800 font-bold mr2 keyword">
类型
</span>
<span class="text-4 text-base-800 font-bold mr2 keyword">类型</span>
<span class={`text-4 select-text text-base-600 ${DisplayTypeColor[type]}`}>
{type in DisplayType ? DisplayType[type] : type}
</span>
</div>
)}
{fansub && (
<div class="space-x-2 select-none text-0">
<span class="text-4 text-base-800 font-bold mr2 keyword">
字幕组
</span>
<span class="text-4 text-base-800 font-bold mr2 keyword">字幕组</span>
{fansub.map((fansub) => (
<a
href={`/resources/1?fansubId=${fansub.id}`}
Expand All @@ -90,19 +87,15 @@ const keywords = {
)}
{after && (
<div class="space-x-2 select-none text-0">
<span class="text-4 text-base-800 font-bold mr2 keyword">
搜索开始于
</span>
<span class="text-4 text-base-800 font-bold mr2 keyword">搜索开始于</span>
<span class="text-4 select-text">
{format(after, 'yyyy 年 M 月 d 日 hh:mm')}
</span>
</div>
)}
{before && (
<div class="space-x-2 select-none text-0">
<span class="text-4 text-base-800 font-bold mr2 keyword">
搜索结束于
</span>
<span class="text-4 text-base-800 font-bold mr2 keyword">搜索结束于</span>
<span class="text-4 select-text">
{format(before, 'yyyy 年 M 月 d 日 hh:mm')}
</span>
Expand All @@ -121,9 +114,7 @@ const keywords = {
)}
{keywords.include.length > 0 && (
<div class="space-x-2 select-none text-0">
<span class="text-4 text-base-800 font-bold mr2 keyword">
包含关键词
</span>
<span class="text-4 text-base-800 font-bold mr2 keyword">包含关键词</span>
{keywords.include.map((i, idx) => (
<>
{idx > 0 && isComplicated && <span class="text-4 text-base-500">+</span>}
Expand Down

0 comments on commit 7bc1b9f

Please sign in to comment.