初始化 M0:Astro SSR + node:sqlite 脚手架与只读页面
This commit is contained in:
1 parent
97440b4120
commit
8430e5304d
39 files changed
+6398
-1
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog';
|
||||
|
||||
/**
|
||||
* shadcn/ui PoC:整棵 Radix 树必须写在同一个 React 组件里,
|
||||
* 分散在 .astro 模板中会被拆成多个 island,Context 无法传递。
|
||||
*/
|
||||
export default function DemoDialog() {
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="outline">打开对话框</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>组件自检</DialogTitle>
|
||||
<DialogDescription>
|
||||
这段弹窗由 React island 渲染,用于验证 shadcn/ui 在 Astro SSR 下的可用性。
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
能看到这个框、能按 Esc 关闭、焦点能回到触发按钮,就说明集成没问题。
|
||||
</p>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button>知道了</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import * as React from 'react';
|
||||
import { Slot } from '@radix-ui/react-slot';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const buttonVariants = cva(
|
||||
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
||||
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
||||
outline: 'border border-border bg-transparent hover:bg-accent hover:text-accent-foreground',
|
||||
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
||||
destructive: 'bg-destructive text-white hover:bg-destructive/90',
|
||||
link: 'text-primary underline-offset-4 hover:underline',
|
||||
},
|
||||
size: {
|
||||
default: 'h-9 px-4 py-2',
|
||||
sm: 'h-8 px-3 text-xs',
|
||||
lg: 'h-10 px-6',
|
||||
icon: 'h-9 w-9',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'default',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean;
|
||||
}
|
||||
|
||||
export function Button({ className, variant, size, asChild = false, ...props }: ButtonProps) {
|
||||
const Comp = asChild ? Slot : 'button';
|
||||
return <Comp className={cn(buttonVariants({ variant, size }), className)} {...props} />;
|
||||
}
|
||||
|
||||
export { buttonVariants };
|
||||
@@ -0,0 +1,34 @@
|
||||
import * as React from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export function Card({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'rounded-lg border border-border bg-card text-card-foreground shadow-sm transition-colors',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function CardHeader({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn('flex flex-col gap-1.5 p-5', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function CardTitle({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) {
|
||||
return <h3 className={cn('text-base font-semibold leading-tight', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function CardDescription({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) {
|
||||
return <p className={cn('text-sm text-muted-foreground', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function CardContent({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn('p-5 pt-0', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function CardFooter({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn('flex items-center gap-2 p-5 pt-0', className)} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import * as React from 'react';
|
||||
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
||||
import { X } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export const Dialog = DialogPrimitive.Root;
|
||||
export const DialogTrigger = DialogPrimitive.Trigger;
|
||||
export const DialogClose = DialogPrimitive.Close;
|
||||
|
||||
export function DialogContent({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DialogPrimitive.Content>) {
|
||||
return (
|
||||
<DialogPrimitive.Portal>
|
||||
<DialogPrimitive.Overlay className="fixed inset-0 z-50 bg-black/60 backdrop-blur-sm" />
|
||||
<DialogPrimitive.Content
|
||||
className={cn(
|
||||
'fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border border-border bg-card p-6 shadow-2xl',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm text-muted-foreground opacity-70 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">关闭</span>
|
||||
</DialogPrimitive.Close>
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPrimitive.Portal>
|
||||
);
|
||||
}
|
||||
|
||||
export function DialogHeader({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn('flex flex-col gap-1.5', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function DialogFooter({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn('flex justify-end gap-2', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
||||
return <DialogPrimitive.Title className={cn('text-lg font-semibold', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function DialogDescription({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
||||
return <DialogPrimitive.Description className={cn('text-sm text-muted-foreground', className)} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
import '../styles/global.css';
|
||||
|
||||
interface Props {
|
||||
title?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
const {
|
||||
title = 'LFSpecs',
|
||||
description = '公开硬件规格库:收录手机、芯片等设备的详细参数,支持横向对比。',
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<meta name="description" content={description} />
|
||||
<title>{title}</title>
|
||||
</head>
|
||||
<body class="min-h-dvh">
|
||||
<header class="border-b border-border/60">
|
||||
<div class="mx-auto flex h-14 max-w-6xl items-center gap-6 px-5">
|
||||
<a href="/" class="text-sm font-semibold tracking-tight">LFSpecs</a>
|
||||
<nav class="flex items-center gap-1 text-sm text-muted-foreground">
|
||||
<a href="/devices" class="rounded-md px-2.5 py-1.5 transition-colors hover:bg-accent hover:text-foreground">手机</a>
|
||||
<a href="/chips" class="rounded-md px-2.5 py-1.5 transition-colors hover:bg-accent hover:text-foreground">芯片</a>
|
||||
<a href="/poc" class="rounded-md px-2.5 py-1.5 transition-colors hover:bg-accent hover:text-foreground">组件自检</a>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="mx-auto max-w-6xl px-5 py-10">
|
||||
<slot />
|
||||
</main>
|
||||
|
||||
<footer class="mt-16 border-t border-border/60 py-8">
|
||||
<div class="mx-auto max-w-6xl px-5 text-xs text-muted-foreground">
|
||||
<p>数据由人工与 AI 辅助整理,仅供参考。</p>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,43 @@
|
||||
import { DatabaseSync } from 'node:sqlite';
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
|
||||
const DB_PATH = process.env.DB_PATH ?? 'data/app.db';
|
||||
const MIGRATIONS_DIR = 'migrations';
|
||||
|
||||
let instance: DatabaseSync | undefined;
|
||||
|
||||
/** 单例连接。首次调用时建目录、开 WAL、跑未应用的迁移。 */
|
||||
export function getDb(): DatabaseSync {
|
||||
if (!instance) {
|
||||
mkdirSync(dirname(DB_PATH), { recursive: true });
|
||||
instance = new DatabaseSync(DB_PATH);
|
||||
instance.exec('PRAGMA journal_mode = WAL;');
|
||||
instance.exec('PRAGMA foreign_keys = ON;');
|
||||
applyMigrations(instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
function applyMigrations(db: DatabaseSync): void {
|
||||
db.exec('CREATE TABLE IF NOT EXISTS _migrations (name TEXT PRIMARY KEY, applied_at TEXT NOT NULL)');
|
||||
|
||||
if (!existsSync(MIGRATIONS_DIR)) return;
|
||||
|
||||
const applied = new Set(
|
||||
(db.prepare('SELECT name FROM _migrations').all() as { name: string }[]).map((r) => r.name),
|
||||
);
|
||||
|
||||
const files = readdirSync(MIGRATIONS_DIR)
|
||||
.filter((f) => f.endsWith('.sql'))
|
||||
.sort();
|
||||
|
||||
for (const file of files) {
|
||||
if (applied.has(file)) continue;
|
||||
db.exec(readFileSync(join(MIGRATIONS_DIR, file), 'utf8'));
|
||||
db.prepare('INSERT INTO _migrations (name, applied_at) VALUES (?, ?)').run(
|
||||
file,
|
||||
new Date().toISOString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
import { getDb } from './db';
|
||||
import { chipSchema, deviceSchema, type Chip, type Device, type DeviceCategory } from './schema';
|
||||
|
||||
type Row = Record<string, unknown>;
|
||||
|
||||
function parseJson<T>(value: unknown, fallback: T): T {
|
||||
if (typeof value !== 'string' || value.length === 0) return fallback;
|
||||
try {
|
||||
return JSON.parse(value) as T;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function toNullable(value: string | undefined | null): string | null {
|
||||
return value ?? null;
|
||||
}
|
||||
|
||||
function rowToDevice(row: Row): Device {
|
||||
return deviceSchema.parse({
|
||||
slug: row.slug,
|
||||
category: row.category,
|
||||
brand: row.brand,
|
||||
model: row.model,
|
||||
aliases: parseJson(row.aliases_json, []),
|
||||
announceDate: row.announce_date ?? undefined,
|
||||
releaseDate: row.release_date ?? undefined,
|
||||
lifecycle: row.lifecycle,
|
||||
cover: row.cover_key ?? undefined,
|
||||
gallery: parseJson(row.gallery_json, []),
|
||||
tags: parseJson(row.tags_json, []),
|
||||
summary: row.summary ?? undefined,
|
||||
chipRefs: parseJson(row.chip_refs_json, {}),
|
||||
meta: parseJson(row.meta_json, []),
|
||||
specs: parseJson(row.specs_json, {}),
|
||||
});
|
||||
}
|
||||
|
||||
function rowToChip(row: Row): Chip {
|
||||
return chipSchema.parse({
|
||||
slug: row.slug,
|
||||
type: row.type,
|
||||
brand: row.brand,
|
||||
model: row.model,
|
||||
codename: row.codename ?? undefined,
|
||||
aliases: parseJson(row.aliases_json, []),
|
||||
process: row.process ?? undefined,
|
||||
arch: row.arch ?? undefined,
|
||||
meta: parseJson(row.meta_json, []),
|
||||
detail: parseJson(row.detail_json, {}),
|
||||
});
|
||||
}
|
||||
|
||||
/* ------------------------------- devices ------------------------------- */
|
||||
|
||||
export function listDevices(options: { category?: DeviceCategory } = {}): Device[] {
|
||||
const db = getDb();
|
||||
const rows = options.category
|
||||
? db
|
||||
.prepare(
|
||||
'SELECT * FROM devices WHERE category = ? ORDER BY release_date DESC, brand, model',
|
||||
)
|
||||
.all(options.category)
|
||||
: db.prepare('SELECT * FROM devices ORDER BY release_date DESC, brand, model').all();
|
||||
return (rows as Row[]).map(rowToDevice);
|
||||
}
|
||||
|
||||
export function getDevice(slug: string): Device | undefined {
|
||||
const row = getDb().prepare('SELECT * FROM devices WHERE slug = ?').get(slug) as Row | undefined;
|
||||
return row ? rowToDevice(row) : undefined;
|
||||
}
|
||||
|
||||
export function countDevices(category?: DeviceCategory): number {
|
||||
const db = getDb();
|
||||
const row = category
|
||||
? (db.prepare('SELECT COUNT(*) AS n FROM devices WHERE category = ?').get(category) as { n: number })
|
||||
: (db.prepare('SELECT COUNT(*) AS n FROM devices').get() as { n: number });
|
||||
return row.n;
|
||||
}
|
||||
|
||||
/** 反查:搭载某颗芯片的设备(按 chipRefs 中任一引用匹配) */
|
||||
export function devicesUsingChip(chipSlug: string): Device[] {
|
||||
const rows = getDb()
|
||||
.prepare(
|
||||
`SELECT * FROM devices
|
||||
WHERE json_extract(chip_refs_json, '$.soc') = ?
|
||||
OR json_extract(chip_refs_json, '$.cpu') = ?
|
||||
OR json_extract(chip_refs_json, '$.gpu') = ?
|
||||
OR json_extract(chip_refs_json, '$.npu') = ?
|
||||
OR json_extract(chip_refs_json, '$.modem') = ?
|
||||
ORDER BY release_date DESC`,
|
||||
)
|
||||
.all(chipSlug, chipSlug, chipSlug, chipSlug, chipSlug);
|
||||
return (rows as Row[]).map(rowToDevice);
|
||||
}
|
||||
|
||||
export function saveDevice(input: Device): Device {
|
||||
const device = deviceSchema.parse(input);
|
||||
const now = new Date().toISOString();
|
||||
getDb()
|
||||
.prepare(
|
||||
`INSERT INTO devices (
|
||||
slug, category, sub_category, brand, model, aliases_json,
|
||||
announce_date, release_date, lifecycle, cover_key, gallery_json,
|
||||
tags_json, summary, specs_json, chip_refs_json, meta_json,
|
||||
created_at, updated_at
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
ON CONFLICT(slug) DO UPDATE SET
|
||||
category = excluded.category,
|
||||
sub_category = excluded.sub_category,
|
||||
brand = excluded.brand,
|
||||
model = excluded.model,
|
||||
aliases_json = excluded.aliases_json,
|
||||
announce_date = excluded.announce_date,
|
||||
release_date = excluded.release_date,
|
||||
lifecycle = excluded.lifecycle,
|
||||
cover_key = excluded.cover_key,
|
||||
gallery_json = excluded.gallery_json,
|
||||
tags_json = excluded.tags_json,
|
||||
summary = excluded.summary,
|
||||
specs_json = excluded.specs_json,
|
||||
chip_refs_json = excluded.chip_refs_json,
|
||||
meta_json = excluded.meta_json,
|
||||
updated_at = excluded.updated_at`,
|
||||
)
|
||||
.run(
|
||||
device.slug,
|
||||
device.category,
|
||||
null,
|
||||
device.brand,
|
||||
device.model,
|
||||
JSON.stringify(device.aliases),
|
||||
toNullable(device.announceDate),
|
||||
toNullable(device.releaseDate),
|
||||
device.lifecycle,
|
||||
toNullable(device.cover),
|
||||
JSON.stringify(device.gallery),
|
||||
JSON.stringify(device.tags),
|
||||
toNullable(device.summary),
|
||||
JSON.stringify(device.specs),
|
||||
JSON.stringify(device.chipRefs),
|
||||
JSON.stringify(device.meta),
|
||||
now,
|
||||
now,
|
||||
);
|
||||
return getDevice(device.slug)!;
|
||||
}
|
||||
|
||||
/* -------------------------------- chips -------------------------------- */
|
||||
|
||||
export function listChips(options: { type?: Chip['type'] } = {}): Chip[] {
|
||||
const db = getDb();
|
||||
const rows = options.type
|
||||
? db.prepare('SELECT * FROM chips WHERE type = ? ORDER BY brand, model').all(options.type)
|
||||
: db.prepare('SELECT * FROM chips ORDER BY brand, model').all();
|
||||
return (rows as Row[]).map(rowToChip);
|
||||
}
|
||||
|
||||
export function getChip(slug: string): Chip | undefined {
|
||||
const row = getDb().prepare('SELECT * FROM chips WHERE slug = ?').get(slug) as Row | undefined;
|
||||
return row ? rowToChip(row) : undefined;
|
||||
}
|
||||
|
||||
export function countChips(type?: Chip['type']): number {
|
||||
const db = getDb();
|
||||
const row = type
|
||||
? (db.prepare('SELECT COUNT(*) AS n FROM chips WHERE type = ?').get(type) as { n: number })
|
||||
: (db.prepare('SELECT COUNT(*) AS n FROM chips').get() as { n: number });
|
||||
return row.n;
|
||||
}
|
||||
|
||||
export function saveChip(input: Chip): Chip {
|
||||
const chip = chipSchema.parse(input);
|
||||
const now = new Date().toISOString();
|
||||
getDb()
|
||||
.prepare(
|
||||
`INSERT INTO chips (
|
||||
slug, type, brand, model, codename, aliases_json,
|
||||
process, arch, detail_json, meta_json, created_at, updated_at
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
ON CONFLICT(slug) DO UPDATE SET
|
||||
type = excluded.type,
|
||||
brand = excluded.brand,
|
||||
model = excluded.model,
|
||||
codename = excluded.codename,
|
||||
aliases_json = excluded.aliases_json,
|
||||
process = excluded.process,
|
||||
arch = excluded.arch,
|
||||
detail_json = excluded.detail_json,
|
||||
meta_json = excluded.meta_json,
|
||||
updated_at = excluded.updated_at`,
|
||||
)
|
||||
.run(
|
||||
chip.slug,
|
||||
chip.type,
|
||||
chip.brand,
|
||||
chip.model,
|
||||
toNullable(chip.codename),
|
||||
JSON.stringify(chip.aliases),
|
||||
toNullable(chip.process),
|
||||
toNullable(chip.arch),
|
||||
JSON.stringify(chip.detail),
|
||||
JSON.stringify(chip.meta),
|
||||
now,
|
||||
now,
|
||||
);
|
||||
return getChip(chip.slug)!;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { z } from 'zod';
|
||||
import { phoneSpecsSchema } from './phone';
|
||||
import { socDetailSchema } from './soc';
|
||||
import { fieldMetaSchema, dateStringSchema } from './meta';
|
||||
|
||||
export const deviceCategorySchema = z.enum([
|
||||
'phone',
|
||||
'tablet',
|
||||
'laptop',
|
||||
'desktop',
|
||||
'handheld',
|
||||
'peripheral',
|
||||
]);
|
||||
export type DeviceCategory = z.infer<typeof deviceCategorySchema>;
|
||||
|
||||
export const lifecycleSchema = z.enum(['announced', 'released', 'discontinued']);
|
||||
export const chipTypeSchema = z.enum(['soc', 'cpu', 'gpu', 'npu', 'modem']);
|
||||
|
||||
export const slugSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, 'slug 只能用小写字母、数字和连字符');
|
||||
|
||||
export const chipRefsSchema = z
|
||||
.object({
|
||||
soc: z.string().optional(),
|
||||
cpu: z.string().optional(),
|
||||
gpu: z.string().optional(),
|
||||
npu: z.string().optional(),
|
||||
modem: z.string().optional(),
|
||||
})
|
||||
.default({});
|
||||
|
||||
const deviceBaseSchema = z.object({
|
||||
slug: slugSchema,
|
||||
brand: z.string().min(1),
|
||||
model: z.string().min(1),
|
||||
aliases: z.array(z.string()).default([]),
|
||||
announceDate: dateStringSchema.optional(),
|
||||
releaseDate: dateStringSchema.optional(),
|
||||
lifecycle: lifecycleSchema.default('released'),
|
||||
/** 存储 key,不是 URL */
|
||||
cover: z.string().optional(),
|
||||
gallery: z.array(z.string()).default([]),
|
||||
tags: z.array(z.string()).default([]),
|
||||
summary: z.string().optional(),
|
||||
chipRefs: chipRefsSchema,
|
||||
meta: z.array(fieldMetaSchema).default([]),
|
||||
});
|
||||
|
||||
/** M0 只实现 phone,后续 tablet/laptop/... 逐个加进 discriminatedUnion */
|
||||
export const phoneDeviceSchema = deviceBaseSchema.extend({
|
||||
category: z.literal('phone'),
|
||||
specs: phoneSpecsSchema,
|
||||
});
|
||||
export type PhoneDevice = z.infer<typeof phoneDeviceSchema>;
|
||||
|
||||
export const deviceSchema = z.discriminatedUnion('category', [phoneDeviceSchema]);
|
||||
export type Device = z.infer<typeof deviceSchema>;
|
||||
|
||||
const chipBaseSchema = z.object({
|
||||
slug: slugSchema,
|
||||
brand: z.string().min(1),
|
||||
model: z.string().min(1),
|
||||
codename: z.string().optional(),
|
||||
aliases: z.array(z.string()).default([]),
|
||||
process: z.string().optional(), // "TSMC N4P"
|
||||
arch: z.string().optional(), // "ARMv9.2"
|
||||
meta: z.array(fieldMetaSchema).default([]),
|
||||
});
|
||||
|
||||
export const socChipSchema = chipBaseSchema.extend({
|
||||
type: z.literal('soc'),
|
||||
detail: socDetailSchema,
|
||||
});
|
||||
export type SocChip = z.infer<typeof socChipSchema>;
|
||||
|
||||
export const chipSchema = z.discriminatedUnion('type', [socChipSchema]);
|
||||
export type Chip = z.infer<typeof chipSchema>;
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from './meta';
|
||||
export * from './phone';
|
||||
export * from './soc';
|
||||
export * from './device';
|
||||
@@ -0,0 +1,23 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/** 字段置信度:AI 分级录入的唯一依据 */
|
||||
export const confidenceSchema = z.enum(['high', 'medium', 'low']);
|
||||
export type Confidence = z.infer<typeof confidenceSchema>;
|
||||
|
||||
/**
|
||||
* 字段级元数据。path 是扁平路径(如 specs.rearCamera[0].sensorModel),
|
||||
* 与 AI 接口返回的字段路径一一对应。
|
||||
*/
|
||||
export const fieldMetaSchema = z.object({
|
||||
path: z.string(),
|
||||
confidence: confidenceSchema,
|
||||
sourceUrl: z.url().optional(),
|
||||
verified: z.boolean().default(false),
|
||||
capturedAt: z.string(),
|
||||
});
|
||||
export type FieldMeta = z.infer<typeof fieldMetaSchema>;
|
||||
|
||||
/** ISO 日期字符串(只到日或 datetime 均可) */
|
||||
export const dateStringSchema = z.string().refine((v) => !Number.isNaN(new Date(v).getTime()), {
|
||||
message: '不是有效日期',
|
||||
});
|
||||
@@ -0,0 +1,164 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const extraSchema = z.record(z.string(), z.string()).default({});
|
||||
|
||||
export const cameraPositionSchema = z.enum([
|
||||
'wide',
|
||||
'ultrawide',
|
||||
'tele',
|
||||
'periscope',
|
||||
'macro',
|
||||
'depth',
|
||||
'mono',
|
||||
'front',
|
||||
]);
|
||||
|
||||
/** 单颗摄像头。多摄必须逐颗建模,才能检索与对比 */
|
||||
export const cameraModuleSchema = z.object({
|
||||
position: cameraPositionSchema,
|
||||
sensorModel: z.string().optional(), // "Sony IMX890"
|
||||
resolution: z.string().optional(), // "50MP"
|
||||
aperture: z.string().optional(), // "f/1.8"
|
||||
focalLength: z.string().optional(), // "24mm"
|
||||
sensorSize: z.string().optional(), // "1/1.56\""
|
||||
pixelSize: z.string().optional(), // "1.0µm"
|
||||
lensElements: z.string().optional(), // "7P"
|
||||
ois: z.boolean().optional(),
|
||||
eis: z.boolean().optional(),
|
||||
zoom: z.string().optional(), // "3x 光学 / 30x 数码"
|
||||
autofocusType: z.string().optional(), // "双像素 PDAF"
|
||||
video: z
|
||||
.object({
|
||||
max: z.string().optional(), // "8K@24fps"
|
||||
modes: z.array(z.string()).default([]),
|
||||
stabilization: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
flash: z.string().optional(),
|
||||
extra: extraSchema,
|
||||
});
|
||||
export type CameraModule = z.infer<typeof cameraModuleSchema>;
|
||||
|
||||
export const phoneSpecsSchema = z.object({
|
||||
body: z
|
||||
.object({
|
||||
dimensions: z.string().optional(), // "161.4 x 74.6 x 8.2 mm"
|
||||
weight: z.string().optional(), // "193 g"
|
||||
build: z
|
||||
.object({
|
||||
front: z.string().optional(),
|
||||
back: z.string().optional(),
|
||||
frame: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
sim: z.string().optional(),
|
||||
ipRating: z.string().optional(), // "IP68"
|
||||
colors: z.array(z.string()).default([]),
|
||||
buttons: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
display: z
|
||||
.object({
|
||||
size: z.string().optional(), // "6.79 英寸"
|
||||
resolution: z.string().optional(), // "2712 x 1220"
|
||||
aspectRatio: z.string().optional(),
|
||||
panel: z.string().optional(), // "LTPO AMOLED"
|
||||
refreshRate: z.string().optional(), // "120Hz"
|
||||
refreshRange: z.string().optional(), // "1-120Hz"
|
||||
touchSampling: z.string().optional(),
|
||||
brightnessTypical: z.string().optional(),
|
||||
brightnessPeak: z.string().optional(),
|
||||
hdr: z.string().optional(),
|
||||
protection: z.string().optional(), // "康宁大猩猩 Victus 2"
|
||||
pwmDimming: z.string().optional(),
|
||||
alwaysOn: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
platform: z
|
||||
.object({
|
||||
os: z.string().optional(),
|
||||
skin: z.string().optional(),
|
||||
chipset: z.string().optional(), // 冗余展示用,权威值在 chipRefs.soc
|
||||
})
|
||||
.optional(),
|
||||
memory: z
|
||||
.object({
|
||||
ram: z.string().optional(),
|
||||
ramType: z.string().optional(), // "LPDDR5X"
|
||||
storage: z.string().optional(),
|
||||
storageType: z.string().optional(), // "UFS 4.0"
|
||||
cardSlot: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
rearCamera: z.array(cameraModuleSchema).default([]),
|
||||
frontCamera: z.array(cameraModuleSchema).default([]),
|
||||
/** 振动马达:X轴/Z轴线性、转子;型号如 "AAC 0809" */
|
||||
vibration: z
|
||||
.object({
|
||||
type: z.string().optional(),
|
||||
model: z.string().optional(),
|
||||
size: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
speakers: z
|
||||
.object({
|
||||
count: z.number().optional(),
|
||||
stereo: z.boolean().optional(),
|
||||
units: z
|
||||
.array(
|
||||
z.object({
|
||||
model: z.string().optional(),
|
||||
size: z.string().optional(),
|
||||
power: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.default([]),
|
||||
dolbyAtmos: z.boolean().optional(),
|
||||
hiRes: z.boolean().optional(),
|
||||
loudnessDba: z.string().optional(),
|
||||
headphoneJack: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
connectivity: z
|
||||
.object({
|
||||
cellular: z.string().optional(),
|
||||
wifi: z.string().optional(),
|
||||
bluetooth: z.string().optional(),
|
||||
nfc: z.boolean().optional(),
|
||||
gps: z.string().optional(),
|
||||
usb: z.string().optional(),
|
||||
ir: z.boolean().optional(),
|
||||
uwb: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
battery: z
|
||||
.object({
|
||||
capacity: z.string().optional(), // "5400mAh"
|
||||
type: z.string().optional(),
|
||||
wired: z.string().optional(),
|
||||
wireless: z.string().optional(),
|
||||
reverse: z.string().optional(),
|
||||
chargingProtocol: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
sensors: z
|
||||
.object({
|
||||
fingerprint: z.string().optional(),
|
||||
fingerprintType: z.string().optional(), // 超声波 / 光学
|
||||
fingerprintPosition: z.string().optional(),
|
||||
gyro: z.boolean().optional(),
|
||||
barometer: z.boolean().optional(),
|
||||
colorSensor: z.boolean().optional(),
|
||||
flickerSensor: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
software: z
|
||||
.object({
|
||||
launchVersion: z.string().optional(),
|
||||
currentVersion: z.string().optional(),
|
||||
updatePolicy: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
extra: extraSchema,
|
||||
});
|
||||
export type PhoneSpecs = z.infer<typeof phoneSpecsSchema>;
|
||||
@@ -0,0 +1,70 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* SoC 详情。与设备 specs 分开维护,供多机型引用。
|
||||
*/
|
||||
export const socDetailSchema = z.object({
|
||||
cpuClusters: z
|
||||
.array(
|
||||
z.object({
|
||||
name: z.string().optional(), // "性能簇" / "能效簇"
|
||||
cores: z
|
||||
.array(
|
||||
z.object({
|
||||
microArch: z.string().optional(), // "Cortex-X4"
|
||||
count: z.number().optional(),
|
||||
clockMax: z.string().optional(), // "3.3GHz"
|
||||
l1: z.string().optional(),
|
||||
l2: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.default([]),
|
||||
l3: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.default([]),
|
||||
gpuBlock: z
|
||||
.object({
|
||||
name: z.string().optional(), // "Adreno 750"
|
||||
arch: z.string().optional(),
|
||||
cores: z.number().optional(),
|
||||
clockMax: z.string().optional(),
|
||||
apis: z.array(z.string()).default([]),
|
||||
})
|
||||
.optional(),
|
||||
npuBlock: z
|
||||
.object({
|
||||
name: z.string().optional(),
|
||||
tops: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
ispBlock: z.string().optional(),
|
||||
dspBlock: z.string().optional(),
|
||||
modemBlock: z.string().optional(),
|
||||
memorySupport: z
|
||||
.object({
|
||||
type: z.string().optional(), // "LPDDR5X"
|
||||
maxClock: z.string().optional(),
|
||||
bandwidth: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
storageSupport: z.string().optional(), // "UFS 4.0"
|
||||
displaySupport: z.string().optional(), // 最高分辨率/刷新率
|
||||
videoCodec: z
|
||||
.object({
|
||||
encode: z.array(z.string()).default([]),
|
||||
decode: z.array(z.string()).default([]),
|
||||
})
|
||||
.optional(),
|
||||
benchmarks: z
|
||||
.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
score: z.string(),
|
||||
unit: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.default([]),
|
||||
extra: z.record(z.string(), z.string()).default({}),
|
||||
});
|
||||
export type SocDetail = z.infer<typeof socDetailSchema>;
|
||||
@@ -0,0 +1,65 @@
|
||||
import { mkdir, rm, writeFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
|
||||
export interface StorageDriver {
|
||||
put(key: string, buf: Uint8Array, contentType: string): Promise<void>;
|
||||
delete(key: string): Promise<void>;
|
||||
publicUrl(key: string): string;
|
||||
}
|
||||
|
||||
const LOCAL_ROOT = process.env.UPLOADS_DIR ?? 'data/uploads';
|
||||
|
||||
/**
|
||||
* 本地磁盘驱动。key 形如 `devices/xiaomi-14/cover.webp`,
|
||||
* 落盘到 data/uploads 下,URL 由 /uploads/[...key] 端点提供。
|
||||
*/
|
||||
class LocalDriver implements StorageDriver {
|
||||
async put(key: string, buf: Uint8Array, _contentType: string): Promise<void> {
|
||||
const target = join(LOCAL_ROOT, key);
|
||||
await mkdir(join(target, '..'), { recursive: true });
|
||||
await writeFile(target, buf);
|
||||
}
|
||||
|
||||
async delete(key: string): Promise<void> {
|
||||
await rm(join(LOCAL_ROOT, key), { force: true });
|
||||
}
|
||||
|
||||
publicUrl(key: string): string {
|
||||
return `/uploads/${key}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* S3 兼容驱动占位。M2 接入(@aws-sdk/client-s3 或 SigV4 手写),
|
||||
* 配置项:S3_ENDPOINT / S3_BUCKET / S3_REGION / S3_KEY / S3_SECRET / S3_PUBLIC_BASE_URL
|
||||
*/
|
||||
class S3Driver implements StorageDriver {
|
||||
private readonly base: string;
|
||||
constructor() {
|
||||
this.base = process.env.S3_PUBLIC_BASE_URL ?? '';
|
||||
}
|
||||
async put(): Promise<void> {
|
||||
throw new Error('S3 驱动尚未实现(M2 接入)');
|
||||
}
|
||||
async delete(): Promise<void> {
|
||||
throw new Error('S3 驱动尚未实现(M2 接入)');
|
||||
}
|
||||
publicUrl(key: string): string {
|
||||
if (!this.base) throw new Error('缺少 S3_PUBLIC_BASE_URL');
|
||||
return `${this.base.replace(/\/$/, '')}/${key}`;
|
||||
}
|
||||
}
|
||||
|
||||
let driver: StorageDriver | undefined;
|
||||
|
||||
export function getStorage(): StorageDriver {
|
||||
if (!driver) {
|
||||
const kind = process.env.STORAGE_DRIVER ?? 'local';
|
||||
driver = kind === 's3' ? new S3Driver() : new LocalDriver();
|
||||
}
|
||||
return driver;
|
||||
}
|
||||
|
||||
export function storageRoot(): string {
|
||||
return LOCAL_ROOT;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
---
|
||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||
import { devicesUsingChip, getChip } from '@/lib/repo';
|
||||
|
||||
const slug = Astro.params.slug ?? '';
|
||||
const chip = getChip(slug);
|
||||
if (!chip) {
|
||||
return new Response('未找到该芯片', { status: 404 });
|
||||
}
|
||||
|
||||
const detail = chip.detail;
|
||||
const devices = devicesUsingChip(chip.slug);
|
||||
const coreTotal = detail.cpuClusters.reduce(
|
||||
(sum, c) => sum + (c.cores ?? []).reduce((n, x) => n + (x.count ?? 0), 0),
|
||||
0,
|
||||
);
|
||||
---
|
||||
|
||||
<BaseLayout title={`${chip.brand} ${chip.model} 规格 · LFSpecs`}>
|
||||
<nav class="text-xs text-muted-foreground">
|
||||
<a href="/chips" class="hover:text-foreground">芯片</a>
|
||||
<span class="mx-1.5">/</span>
|
||||
<span class="text-foreground">{chip.model}</span>
|
||||
</nav>
|
||||
|
||||
<header class="mt-3">
|
||||
<p class="text-sm text-muted-foreground">{chip.brand}</p>
|
||||
<h1 class="mt-1 text-3xl font-semibold tracking-tight">{chip.model}</h1>
|
||||
<p class="tabular mt-1.5 text-xs text-muted-foreground">
|
||||
{chip.codename ?? ''} {chip.aliases.length > 0 && `· 别名:${chip.aliases.join('、')}`}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<dl class="tabular mt-6 grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6">
|
||||
{
|
||||
[
|
||||
['制程', chip.process],
|
||||
['架构', chip.arch],
|
||||
['CPU 核心', coreTotal ? `${coreTotal} 核` : undefined],
|
||||
['GPU', detail.gpuBlock?.name],
|
||||
['NPU', detail.npuBlock?.name],
|
||||
['基带', detail.modemBlock],
|
||||
].map(([label, value]) => (
|
||||
<div class="rounded-lg border border-border bg-card p-3">
|
||||
<dt class="text-[11px] text-muted-foreground">{label}</dt>
|
||||
<dd class="mt-1 truncate text-sm font-medium">{value ?? '—'}</dd>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</dl>
|
||||
|
||||
<section class="mt-10">
|
||||
<h2 class="text-lg font-semibold">CPU 核心簇</h2>
|
||||
<div class="mt-3 overflow-hidden rounded-lg border border-border">
|
||||
<table class="w-full border-collapse text-sm">
|
||||
<thead class="bg-secondary/60 text-xs text-muted-foreground">
|
||||
<tr>
|
||||
<th class="px-4 py-2 text-left font-normal">簇</th>
|
||||
<th class="px-4 py-2 text-left font-normal">微架构</th>
|
||||
<th class="px-4 py-2 text-right font-normal">数量</th>
|
||||
<th class="px-4 py-2 text-right font-normal">最高频率</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
detail.cpuClusters.map((cluster) =>
|
||||
cluster.cores.map((core) => (
|
||||
<tr class="border-t border-border/60">
|
||||
<td class="px-4 py-2">{cluster.name ?? '—'}</td>
|
||||
<td class="px-4 py-2">{core.microArch ?? '—'}</td>
|
||||
<td class="tabular px-4 py-2 text-right">{core.count ?? '—'}</td>
|
||||
<td class="tabular px-4 py-2 text-right">{core.clockMax ?? '—'}</td>
|
||||
</tr>
|
||||
)),
|
||||
)
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="mt-10 grid gap-3 sm:grid-cols-2">
|
||||
<div class="rounded-lg border border-border bg-card p-5">
|
||||
<h3 class="text-sm font-semibold">GPU</h3>
|
||||
<dl class="tabular mt-3 grid grid-cols-2 gap-x-3 gap-y-1 text-xs">
|
||||
<dt class="text-muted-foreground">型号</dt>
|
||||
<dd class="text-right">{detail.gpuBlock?.name ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">最高频率</dt>
|
||||
<dd class="text-right">{detail.gpuBlock?.clockMax ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">API</dt>
|
||||
<dd class="text-right">{detail.gpuBlock?.apis.join(' / ') || '—'}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg border border-border bg-card p-5">
|
||||
<h3 class="text-sm font-semibold">内存与存储支持</h3>
|
||||
<dl class="tabular mt-3 grid grid-cols-2 gap-x-3 gap-y-1 text-xs">
|
||||
<dt class="text-muted-foreground">内存类型</dt>
|
||||
<dd class="text-right">{detail.memorySupport?.type ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">带宽</dt>
|
||||
<dd class="text-right">{detail.memorySupport?.bandwidth ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">存储</dt>
|
||||
<dd class="text-right">{detail.storageSupport ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">显示支持</dt>
|
||||
<dd class="text-right">{detail.displaySupport ?? '—'}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{
|
||||
detail.benchmarks.length > 0 && (
|
||||
<section class="mt-10">
|
||||
<h2 class="text-lg font-semibold">跑分</h2>
|
||||
<div class="mt-3 grid gap-3 sm:grid-cols-3">
|
||||
{detail.benchmarks.map((b) => (
|
||||
<div class="rounded-lg border border-border bg-card p-4">
|
||||
<div class="text-xs text-muted-foreground">{b.name}</div>
|
||||
<div class="tabular mt-1 text-xl font-semibold">
|
||||
{b.score}
|
||||
<span class="ml-1 text-xs font-normal text-muted-foreground">{b.unit ?? ''}</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
<section class="mt-10">
|
||||
<h2 class="text-lg font-semibold">搭载该芯片的设备</h2>
|
||||
{devices.length > 0 ? (
|
||||
<ul class="mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{devices.map((d) => (
|
||||
<li>
|
||||
<a
|
||||
href={`/devices/${d.slug}`}
|
||||
class="block rounded-lg border border-border bg-card p-4 transition-colors hover:border-primary/40"
|
||||
>
|
||||
<div class="text-xs text-muted-foreground">{d.brand}</div>
|
||||
<div class="text-sm font-medium">{d.model}</div>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p class="mt-3 text-sm text-muted-foreground">暂无收录设备。</p>
|
||||
)}
|
||||
</section>
|
||||
</BaseLayout>
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||
import { listChips } from '@/lib/repo';
|
||||
|
||||
const chips = listChips({ type: 'soc' });
|
||||
---
|
||||
|
||||
<BaseLayout title="芯片库 · LFSpecs">
|
||||
<div class="flex items-baseline justify-between">
|
||||
<h1 class="text-2xl font-semibold tracking-tight">SoC</h1>
|
||||
<span class="tabular text-sm text-muted-foreground">{chips.length} 颗</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{
|
||||
chips.map((chip) => {
|
||||
const clusters = chip.detail.cpuClusters ?? [];
|
||||
const coreCount = clusters.reduce(
|
||||
(sum, c) => sum + (c.cores ?? []).reduce((n, x) => n + (x.count ?? 0), 0),
|
||||
0,
|
||||
);
|
||||
return (
|
||||
<a
|
||||
href={`/chips/${chip.slug}`}
|
||||
class="group rounded-lg border border-border bg-card p-5 transition-colors hover:border-primary/40"
|
||||
>
|
||||
<div class="text-xs text-muted-foreground">{chip.brand}</div>
|
||||
<div class="mt-0.5 text-base font-semibold">{chip.model}</div>
|
||||
<dl class="tabular mt-4 grid grid-cols-2 gap-x-4 gap-y-1 text-xs">
|
||||
<dt class="text-muted-foreground">制程</dt>
|
||||
<dd class="truncate text-right">{chip.process ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">核心</dt>
|
||||
<dd class="text-right">{coreCount || '—'} 核</dd>
|
||||
<dt class="text-muted-foreground">GPU</dt>
|
||||
<dd class="truncate text-right">{chip.detail.gpuBlock?.name ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">架构</dt>
|
||||
<dd class="truncate text-right">{chip.arch ?? '—'}</dd>
|
||||
</dl>
|
||||
</a>
|
||||
);
|
||||
})
|
||||
}
|
||||
</div>
|
||||
|
||||
{
|
||||
chips.length === 0 && (
|
||||
<p class="mt-6 rounded-lg border border-dashed border-border p-8 text-center text-sm text-muted-foreground">
|
||||
暂无芯片数据,运行 <code class="font-mono text-foreground">pnpm db:seed</code> 写入种子数据。
|
||||
</p>
|
||||
)
|
||||
}
|
||||
</BaseLayout>
|
||||
@@ -0,0 +1,254 @@
|
||||
---
|
||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||
import { getChip, getDevice } from '@/lib/repo';
|
||||
|
||||
const slug = Astro.params.slug ?? '';
|
||||
const device = getDevice(slug);
|
||||
if (!device) {
|
||||
return new Response('未找到该设备', { status: 404 });
|
||||
}
|
||||
|
||||
const s = device.specs;
|
||||
const soc = device.chipRefs.soc ? getChip(device.chipRefs.soc) : undefined;
|
||||
|
||||
function fmt(value: unknown): string | undefined {
|
||||
if (value === undefined || value === null || value === '') return undefined;
|
||||
if (typeof value === 'boolean') return value ? '支持' : '不支持';
|
||||
if (Array.isArray(value)) return value.length > 0 ? value.join(' / ') : undefined;
|
||||
return String(value);
|
||||
}
|
||||
|
||||
const build = [s.body?.build?.front, s.body?.build?.back, s.body?.build?.frame]
|
||||
.filter(Boolean)
|
||||
.join(' / ');
|
||||
|
||||
const groups = [
|
||||
{
|
||||
title: '外观',
|
||||
rows: [
|
||||
['尺寸', fmt(s.body?.dimensions)],
|
||||
['重量', fmt(s.body?.weight)],
|
||||
['机身材质', build || undefined],
|
||||
['SIM', fmt(s.body?.sim)],
|
||||
['防护等级', fmt(s.body?.ipRating)],
|
||||
['配色', fmt(s.body?.colors)],
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '屏幕',
|
||||
rows: [
|
||||
['尺寸', fmt(s.display?.size)],
|
||||
['分辨率', fmt(s.display?.resolution)],
|
||||
['比例', fmt(s.display?.aspectRatio)],
|
||||
['面板', fmt(s.display?.panel)],
|
||||
['刷新率', fmt(s.display?.refreshRate)],
|
||||
['刷新范围', fmt(s.display?.refreshRange)],
|
||||
['触控采样率', fmt(s.display?.touchSampling)],
|
||||
['典型亮度', fmt(s.display?.brightnessTypical)],
|
||||
['峰值亮度', fmt(s.display?.brightnessPeak)],
|
||||
['HDR', fmt(s.display?.hdr)],
|
||||
['保护玻璃', fmt(s.display?.protection)],
|
||||
['调光', fmt(s.display?.pwmDimming)],
|
||||
['息屏显示', fmt(s.display?.alwaysOn)],
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '平台与存储',
|
||||
rows: [
|
||||
['系统', fmt(s.platform?.os)],
|
||||
['定制 UI', fmt(s.platform?.skin)],
|
||||
['内存', fmt(s.memory?.ram)],
|
||||
['内存类型', fmt(s.memory?.ramType)],
|
||||
['存储', fmt(s.memory?.storage)],
|
||||
['存储类型', fmt(s.memory?.storageType)],
|
||||
['存储卡', fmt(s.memory?.cardSlot)],
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '音频与振动',
|
||||
rows: [
|
||||
['马达类型', fmt(s.vibration?.type)],
|
||||
['马达型号', fmt(s.vibration?.model)],
|
||||
['扬声器数量', fmt(s.speakers?.count)],
|
||||
['立体声', fmt(s.speakers?.stereo)],
|
||||
[
|
||||
'扬声器单元',
|
||||
s.speakers?.units?.length
|
||||
? s.speakers.units.map((u) => [u.model, u.size].filter(Boolean).join(' ')).join(' / ')
|
||||
: undefined,
|
||||
],
|
||||
['杜比全景声', fmt(s.speakers?.dolbyAtmos)],
|
||||
['Hi-Res', fmt(s.speakers?.hiRes)],
|
||||
['响度', fmt(s.speakers?.loudnessDba)],
|
||||
['耳机孔', fmt(s.speakers?.headphoneJack)],
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '连接',
|
||||
rows: [
|
||||
['蜂窝', fmt(s.connectivity?.cellular)],
|
||||
['Wi-Fi', fmt(s.connectivity?.wifi)],
|
||||
['蓝牙', fmt(s.connectivity?.bluetooth)],
|
||||
['NFC', fmt(s.connectivity?.nfc)],
|
||||
['定位', fmt(s.connectivity?.gps)],
|
||||
['USB', fmt(s.connectivity?.usb)],
|
||||
['红外', fmt(s.connectivity?.ir)],
|
||||
['UWB', fmt(s.connectivity?.uwb)],
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '电池与充电',
|
||||
rows: [
|
||||
['容量', fmt(s.battery?.capacity)],
|
||||
['电池类型', fmt(s.battery?.type)],
|
||||
['有线充电', fmt(s.battery?.wired)],
|
||||
['无线充电', fmt(s.battery?.wireless)],
|
||||
['反向充电', fmt(s.battery?.reverse)],
|
||||
['充电协议', fmt(s.battery?.chargingProtocol)],
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '传感器',
|
||||
rows: [
|
||||
['指纹', fmt(s.sensors?.fingerprint)],
|
||||
['指纹类型', fmt(s.sensors?.fingerprintType)],
|
||||
['指纹位置', fmt(s.sensors?.fingerprintPosition)],
|
||||
['陀螺仪', fmt(s.sensors?.gyro)],
|
||||
['气压计', fmt(s.sensors?.barometer)],
|
||||
['色温传感器', fmt(s.sensors?.colorSensor)],
|
||||
['闪烁传感器', fmt(s.sensors?.flickerSensor)],
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '系统与更新',
|
||||
rows: [
|
||||
['出厂版本', fmt(s.software?.launchVersion)],
|
||||
['当前版本', fmt(s.software?.currentVersion)],
|
||||
['更新策略', fmt(s.software?.updatePolicy)],
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const visibleGroups = groups
|
||||
.map((g) => ({ title: g.title, rows: g.rows.filter((row) => row[1] !== undefined) }))
|
||||
.filter((g) => g.rows.length > 0);
|
||||
|
||||
const cameras = [
|
||||
{ title: '后置影像', list: s.rearCamera },
|
||||
{ title: '前置影像', list: s.frontCamera },
|
||||
].filter((c) => c.list.length > 0);
|
||||
---
|
||||
|
||||
<BaseLayout title={`${device.brand} ${device.model} 规格 · LFSpecs`} description={device.summary}>
|
||||
<nav class="text-xs text-muted-foreground">
|
||||
<a href="/devices" class="hover:text-foreground">手机</a>
|
||||
<span class="mx-1.5">/</span>
|
||||
<span class="text-foreground">{device.model}</span>
|
||||
</nav>
|
||||
|
||||
<header class="mt-3">
|
||||
<p class="text-sm text-muted-foreground">{device.brand}</p>
|
||||
<h1 class="mt-1 text-3xl font-semibold tracking-tight">{device.model}</h1>
|
||||
{device.aliases.length > 0 && (
|
||||
<p class="mt-1.5 text-xs text-muted-foreground">别名:{device.aliases.join('、')}</p>
|
||||
)}
|
||||
{device.summary && <p class="mt-3 max-w-2xl text-sm text-muted-foreground">{device.summary}</p>}
|
||||
</header>
|
||||
|
||||
<dl class="tabular mt-6 grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6">
|
||||
{
|
||||
[
|
||||
['SoC', s.platform?.chipset],
|
||||
['屏幕', s.display?.size],
|
||||
['电池', s.battery?.capacity],
|
||||
['主摄', s.rearCamera[0]?.resolution],
|
||||
['重量', s.body?.weight],
|
||||
['存储', s.memory?.storage],
|
||||
].map(([label, value]) => (
|
||||
<div class="rounded-lg border border-border bg-card p-3">
|
||||
<dt class="text-[11px] text-muted-foreground">{label}</dt>
|
||||
<dd class="mt-1 truncate text-sm font-medium">{value ?? '—'}</dd>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</dl>
|
||||
|
||||
{
|
||||
soc && (
|
||||
<div class="mt-6 rounded-lg border border-border bg-card p-4">
|
||||
<div class="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<div>
|
||||
<span class="text-xs text-muted-foreground">SoC</span>
|
||||
<a href={`/chips/${soc.slug}`} class="ml-2 text-sm font-medium text-primary hover:underline">
|
||||
{soc.brand} {soc.model}
|
||||
</a>
|
||||
</div>
|
||||
<span class="tabular text-xs text-muted-foreground">
|
||||
{soc.process ?? ''} {soc.arch ? `· ${soc.arch}` : ''}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
cameras.map((section) => (
|
||||
<section class="mt-10">
|
||||
<h2 class="text-lg font-semibold">{section.title}</h2>
|
||||
<div class="mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{section.list.map((cam) => (
|
||||
<div class="rounded-lg border border-border bg-card p-4">
|
||||
<div class="flex items-baseline justify-between">
|
||||
<span class="text-sm font-medium">{cam.position}</span>
|
||||
<span class="tabular text-xs text-muted-foreground">{cam.resolution ?? ''}</span>
|
||||
</div>
|
||||
<dl class="tabular mt-3 grid grid-cols-2 gap-x-3 gap-y-1 text-xs">
|
||||
{[
|
||||
['传感器', cam.sensorModel],
|
||||
['光圈', cam.aperture],
|
||||
['等效焦距', cam.focalLength],
|
||||
['传感器尺寸', cam.sensorSize],
|
||||
['单像素', cam.pixelSize],
|
||||
['镜片', cam.lensElements],
|
||||
['变焦', cam.zoom],
|
||||
['OIS', fmt(cam.ois)],
|
||||
['对焦', cam.autofocusType],
|
||||
['最高视频', cam.video?.max],
|
||||
]
|
||||
.filter(([, v]) => v !== undefined)
|
||||
.map(([k, v]) => (
|
||||
<>
|
||||
<dt class="text-muted-foreground">{k}</dt>
|
||||
<dd class="text-right">{v}</dd>
|
||||
</>
|
||||
))}
|
||||
</dl>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
))
|
||||
}
|
||||
|
||||
{
|
||||
visibleGroups.map((group) => (
|
||||
<section class="mt-10">
|
||||
<h2 class="text-lg font-semibold">{group.title}</h2>
|
||||
<table class="mt-3 w-full border-collapse text-sm">
|
||||
<tbody>
|
||||
{group.rows.map(([label, value]) => (
|
||||
<tr class="border-b border-border/60">
|
||||
<th class="w-36 py-2 text-left align-top text-xs font-normal text-muted-foreground">{label}</th>
|
||||
<td class="tabular py-2">{value}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
))
|
||||
}
|
||||
|
||||
<p class="mt-12 text-xs text-muted-foreground">
|
||||
共 {device.meta.length} 条字段级来源记录,其中人工核实 {device.meta.filter((m) => m.verified).length} 条。
|
||||
</p>
|
||||
</BaseLayout>
|
||||
@@ -0,0 +1,55 @@
|
||||
---
|
||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||
import { listDevices } from '@/lib/repo';
|
||||
|
||||
const devices = listDevices({ category: 'phone' });
|
||||
---
|
||||
|
||||
<BaseLayout title="手机规格库 · LFSpecs">
|
||||
<div class="flex items-baseline justify-between">
|
||||
<h1 class="text-2xl font-semibold tracking-tight">手机</h1>
|
||||
<span class="tabular text-sm text-muted-foreground">{devices.length} 款</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{
|
||||
devices.map((device) => (
|
||||
<a
|
||||
href={`/devices/${device.slug}`}
|
||||
class="group rounded-lg border border-border bg-card p-5 transition-colors hover:border-primary/40"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div>
|
||||
<div class="text-xs text-muted-foreground">{device.brand}</div>
|
||||
<div class="mt-0.5 text-base font-semibold">{device.model}</div>
|
||||
</div>
|
||||
<span class="rounded-full border border-border px-2 py-0.5 text-[11px] text-muted-foreground">
|
||||
{device.lifecycle === 'discontinued' ? '已停产' : device.lifecycle === 'announced' ? '已发布' : '在售'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<dl class="tabular mt-4 grid grid-cols-2 gap-x-4 gap-y-1 text-xs">
|
||||
<dt class="text-muted-foreground">SoC</dt>
|
||||
<dd class="truncate text-right">{device.specs.platform?.chipset ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">屏幕</dt>
|
||||
<dd class="truncate text-right">{device.specs.display?.size ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">电池</dt>
|
||||
<dd class="truncate text-right">{device.specs.battery?.capacity ?? '—'}</dd>
|
||||
<dt class="text-muted-foreground">重量</dt>
|
||||
<dd class="truncate text-right">{device.specs.body?.weight ?? '—'}</dd>
|
||||
</dl>
|
||||
|
||||
{device.summary && <p class="mt-4 line-clamp-2 text-xs text-muted-foreground">{device.summary}</p>}
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
|
||||
{
|
||||
devices.length === 0 && (
|
||||
<p class="mt-6 rounded-lg border border-dashed border-border p-8 text-center text-sm text-muted-foreground">
|
||||
暂无手机数据,运行 <code class="font-mono text-foreground">pnpm db:seed</code> 写入种子数据。
|
||||
</p>
|
||||
)
|
||||
}
|
||||
</BaseLayout>
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||
import { countChips, countDevices, listDevices } from '@/lib/repo';
|
||||
|
||||
const phoneCount = countDevices('phone');
|
||||
const socCount = countChips('soc');
|
||||
const latest = listDevices({ category: 'phone' }).slice(0, 6);
|
||||
---
|
||||
|
||||
<BaseLayout>
|
||||
<section>
|
||||
<h1 class="text-3xl font-semibold tracking-tight">硬件规格库</h1>
|
||||
<p class="mt-2 max-w-2xl text-sm text-muted-foreground">
|
||||
收录手机与芯片的详细参数,颗粒度到摄像头传感器型号、振动马达与扬声器单元。
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="mt-8 grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<a href="/devices" class="rounded-lg border border-border bg-card p-5 transition-colors hover:border-primary/40">
|
||||
<div class="text-xs text-muted-foreground">手机收录</div>
|
||||
<div class="tabular mt-1 text-2xl font-semibold">{phoneCount}</div>
|
||||
</a>
|
||||
<a href="/chips" class="rounded-lg border border-border bg-card p-5 transition-colors hover:border-primary/40">
|
||||
<div class="text-xs text-muted-foreground">SoC 收录</div>
|
||||
<div class="tabular mt-1 text-2xl font-semibold">{socCount}</div>
|
||||
</a>
|
||||
</section>
|
||||
|
||||
<section class="mt-12">
|
||||
<div class="flex items-baseline justify-between">
|
||||
<h2 class="text-lg font-semibold">最新收录</h2>
|
||||
<a href="/devices" class="text-sm text-muted-foreground hover:text-foreground">全部手机 →</a>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{
|
||||
latest.map((device) => (
|
||||
<a
|
||||
href={`/devices/${device.slug}`}
|
||||
class="group rounded-lg border border-border bg-card p-5 transition-colors hover:border-primary/40"
|
||||
>
|
||||
<div class="text-xs text-muted-foreground">{device.brand}</div>
|
||||
<div class="mt-0.5 text-base font-semibold">{device.model}</div>
|
||||
<div class="tabular mt-3 text-xs text-muted-foreground">
|
||||
{device.specs.platform?.chipset ?? '未填写 SoC'}
|
||||
{' · '}
|
||||
{device.specs.display?.size ?? '—'}
|
||||
{' · '}
|
||||
{device.specs.battery?.capacity ?? '—'}
|
||||
</div>
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
|
||||
{
|
||||
latest.length === 0 && (
|
||||
<p class="mt-4 rounded-lg border border-dashed border-border p-8 text-center text-sm text-muted-foreground">
|
||||
还没有数据。先运行 <code class="font-mono text-foreground">pnpm db:seed</code> 写入种子数据。
|
||||
</p>
|
||||
)
|
||||
}
|
||||
</section>
|
||||
</BaseLayout>
|
||||
@@ -0,0 +1,57 @@
|
||||
---
|
||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||
import DemoDialog from '@/components/DemoDialog.tsx';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
---
|
||||
|
||||
<BaseLayout title="组件自检 · LFSpecs">
|
||||
<h1 class="text-2xl font-semibold tracking-tight">组件自检</h1>
|
||||
<p class="mt-2 max-w-2xl text-sm text-muted-foreground">
|
||||
验证 Button / Card / Dialog 三个 shadcn/ui 组件在 Astro 中的渲染与交互。M0 验收后可删除此页。
|
||||
</p>
|
||||
|
||||
<section class="mt-8">
|
||||
<h2 class="text-sm font-semibold text-muted-foreground">Button</h2>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
<Button>主要</Button>
|
||||
<Button variant="secondary">次要</Button>
|
||||
<Button variant="outline">描边</Button>
|
||||
<Button variant="ghost">幽灵</Button>
|
||||
<Button variant="destructive">危险</Button>
|
||||
<Button size="sm">小号</Button>
|
||||
<Button size="lg">大号</Button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="mt-8">
|
||||
<h2 class="text-sm font-semibold text-muted-foreground">Card</h2>
|
||||
<div class="mt-3 grid gap-3 sm:grid-cols-2">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>普通卡片</CardTitle>
|
||||
<CardDescription>服务端渲染,零 JS</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent class="text-sm text-muted-foreground">卡片主体内容。</CardContent>
|
||||
<CardFooter>
|
||||
<Button size="sm" variant="outline">操作</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
<Card class="border-primary/40">
|
||||
<CardHeader>
|
||||
<CardTitle>强调卡片</CardTitle>
|
||||
<CardDescription>强调色描边</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent class="text-sm text-muted-foreground">用于高亮关键信息。</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="mt-8">
|
||||
<h2 class="text-sm font-semibold text-muted-foreground">Dialog(需要 JS)</h2>
|
||||
<div class="mt-3">
|
||||
<DemoDialog client:load />
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { APIRoute } from 'astro';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { extname, join, normalize } from 'node:path';
|
||||
|
||||
const ROOT = process.env.UPLOADS_DIR ?? 'data/uploads';
|
||||
|
||||
const CONTENT_TYPES: Record<string, string> = {
|
||||
'.webp': 'image/webp',
|
||||
'.jpg': 'image/jpeg',
|
||||
'.jpeg': 'image/jpeg',
|
||||
'.png': 'image/png',
|
||||
'.avif': 'image/avif',
|
||||
'.svg': 'image/svg+xml',
|
||||
};
|
||||
|
||||
export const GET: APIRoute = async ({ params }) => {
|
||||
const rel = (params.path ?? '').replace(/\\/g, '/');
|
||||
const safe = normalize(rel);
|
||||
|
||||
// 防路径穿越:拒绝任何包含 .. 的请求
|
||||
if (safe.startsWith('..') || safe.includes('..') || rel.startsWith('/')) {
|
||||
return new Response('Bad request', { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const buf = await readFile(join(ROOT, safe));
|
||||
return new Response(new Uint8Array(buf), {
|
||||
headers: {
|
||||
'content-type': CONTENT_TYPES[extname(safe).toLowerCase()] ?? 'application/octet-stream',
|
||||
'cache-control': 'public, max-age=31536000, immutable',
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
/* 深色为主的中性色板,强调色用青绿 */
|
||||
:root {
|
||||
--background: #0b0d0f;
|
||||
--foreground: #e8eaed;
|
||||
--card: #121518;
|
||||
--card-foreground: #e8eaed;
|
||||
--popover: #121518;
|
||||
--popover-foreground: #e8eaed;
|
||||
--primary: #2dd4bf;
|
||||
--primary-foreground: #04110f;
|
||||
--secondary: #1c2126;
|
||||
--secondary-foreground: #e8eaed;
|
||||
--muted: #1a1e23;
|
||||
--muted-foreground: #9aa3ad;
|
||||
--accent: #1c2126;
|
||||
--accent-foreground: #e8eaed;
|
||||
--destructive: #f87171;
|
||||
--border: #242a30;
|
||||
--input: #242a30;
|
||||
--ring: #2dd4bf;
|
||||
--radius: 0.625rem;
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
|
||||
--font-sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
|
||||
--font-mono: ui-monospace, "JetBrains Mono", Consolas, monospace;
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
border-color: var(--color-border);
|
||||
}
|
||||
|
||||
html {
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--color-background);
|
||||
color: var(--color-foreground);
|
||||
font-family: var(--font-sans);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* 参数值对齐:等宽数字 */
|
||||
.tabular {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user