Skip to content

Commit

Permalink
feat: display refreshed timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Apr 12, 2023
1 parent b5819f3 commit d60de4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/app/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// <reference types="astro/client" />
/// <reference types="vite-plugin-info/client" />

interface Env {}
export interface Env {
animegarden: KVNamespace;
}
9 changes: 7 additions & 2 deletions packages/app/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
import now from '~build/time';
import { getRuntime } from "@astrojs/cloudflare/runtime";
import type { Env } from '../env';
import Dropdown from '../components/Dropdown.astro'
Expand All @@ -12,6 +14,9 @@ const { title } = Astro.props;
const url = Astro.url.pathname;
const types = ["动画", "季度全集", "音乐", "动漫音乐", "同人音乐", "流行音乐", "日剧", "RAW", "其他", "漫画", "港台原版", "日文原版", "游戏", "电脑游戏", "主机游戏", "掌机游戏", "网络游戏 ", "游戏周边", "特摄"];
const runtime = getRuntime<Env>(Astro.request);
const timestamp = new Date((await runtime?.env.animegarden.get('state/refresh-timestamp')) ?? 0);
---

<!DOCTYPE html>
Expand Down Expand Up @@ -54,7 +59,7 @@ const types = ["动画", "季度全集", "音乐", "动漫音乐", "同人音乐
<span> © 2023</span>
</div>
<div font-sm text-base-400>
Rendered at {now.toLocaleString('zh-CN', { timeZone: 'Asia/ShangHai' })}
Refreshed at {timestamp.toLocaleString('zh-CN', { timeZone: 'Asia/ShangHai' })}
</div>
<div font-sm text-base-400>Powered by Astro</div>
<div font-sm text-base-400>Hosted on Cloudflare Pages</div>
Expand Down

0 comments on commit d60de4c

Please sign in to comment.