feat(hololake): bind direct-language V1 baseline
This commit is contained in:
parent
e88805cf91
commit
3df6b1d3ca
14 changed files with 809 additions and 23 deletions
|
|
@ -17,6 +17,7 @@ import {
|
|||
jumpToHeading,
|
||||
splitFrontmatter,
|
||||
} from "./modules/knowledge-render";
|
||||
import { formatHoloLakeTime } from "./time";
|
||||
|
||||
type View =
|
||||
| "channel"
|
||||
|
|
@ -389,11 +390,7 @@ function ReceiptStream({ data }: { data: SystemSnapshot }) {
|
|||
<strong>{e.title}</strong>
|
||||
<p>{e.content}</p>
|
||||
<time>
|
||||
{new Date(e.occurredAt).toLocaleTimeString("zh-CN", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
})}
|
||||
{formatHoloLakeTime(e.occurredAt)}
|
||||
</time>
|
||||
</div>
|
||||
))
|
||||
|
|
@ -885,7 +882,7 @@ function History({ data }: { data: SystemSnapshot }) {
|
|||
<section className="timeline-list">
|
||||
{data.timeline.map((e) => (
|
||||
<article key={e.eventId}>
|
||||
<time>{new Date(e.occurredAt).toLocaleString("zh-CN")}</time>
|
||||
<time>{formatHoloLakeTime(e.occurredAt, true)}</time>
|
||||
<div>
|
||||
<strong>
|
||||
{labels[e.sourceKind]} · {e.title}
|
||||
|
|
|
|||
18
product-source/hololake-clean-desktop/src/time.ts
Normal file
18
product-source/hololake-clean-desktop/src/time.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const legacyUnixSeconds = /^(\d{10})(?:\.(\d{1,3}))?Z$/;
|
||||
|
||||
export function parseHoloLakeTime(value: string): Date | null {
|
||||
const legacy = legacyUnixSeconds.exec(value);
|
||||
const date = legacy
|
||||
? new Date(Number(legacy[1]) * 1000 + Number((legacy[2] ?? "0").padEnd(3, "0")))
|
||||
: new Date(value);
|
||||
return Number.isNaN(date.getTime()) ? null : date;
|
||||
}
|
||||
|
||||
export function formatHoloLakeTime(value: string, withDate = false): string {
|
||||
const date = parseHoloLakeTime(value);
|
||||
if (!date) return "时间待校验";
|
||||
return withDate
|
||||
? date.toLocaleString("zh-CN")
|
||||
: date.toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit", second: "2-digit" });
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue