feat(pet): validate local pet pack manifests
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run

这个提交存在于:
YokiiroBW 2026-07-20 12:36:20 +08:00
父节点 4f13581809
当前提交 1828c6183a
共有 3 个文件被更改,包括 86 次插入 和 0 次删除

查看文件

@ -4,6 +4,7 @@ import { useCallback, useEffect, useState } from "react";
import { ChatPanel } from "./features/chat/ChatPanel";
import { StatusBubble } from "./features/chat/StatusBubble";
import { ProfileManager } from "./features/profiles/ProfileManager";
import { PetPackImporter } from "./features/pet/PetPackImporter";
import { bootstrapStatusSchema, type BootstrapStatus } from "./types/bootstrap";
const initialStatus: BootstrapStatus = {
@ -189,6 +190,7 @@ export function App() {
/>
</section>
<ProfileManager />
<PetPackImporter />
<button type="button" onClick={() => void refreshStatus()}>
閲嶆柊妫€鏌?IPC

查看文件

@ -0,0 +1,58 @@
import { useState } from "react";
import { petPackManifestSchema, type PetPackManifest } from "./types";
export function PetPackImporter() {
const [manifest, setManifest] = useState<PetPackManifest | null>(null);
const [error, setError] = useState<string | null>(null);
const [fileName, setFileName] = useState<string | null>(null);
const importManifest = async (file: File) => {
setFileName(file.name);
setManifest(null);
setError(null);
if (!file.name.toLowerCase().endsWith(".json") || file.size > 256 * 1024) {
setError("?????? 256 KiB ? JSON manifest ???");
return;
}
try {
const parsed = petPackManifestSchema.parse(JSON.parse(await file.text()));
setManifest(parsed);
} catch (reason) {
setError(reason instanceof Error ? reason.message : "??? manifest ???");
}
};
return (
<section className="pet-pack-importer" aria-label="???????">
<div>
<p className="eyebrow">Q6 pet pack</p>
<h2>?????</h2>
<p className="form-note">
????? JSON manifest?????????????????????????
</p>
</div>
<input
accept=".json,application/json"
aria-label="???? manifest"
type="file"
onChange={(event) => {
const file = event.target.files?.[0];
if (file) void importManifest(file);
}}
/>
{fileName ? <p className="form-note">???{fileName}</p> : null}
{error ? <p className="error-banner">{error}</p> : null}
{manifest ? (
<div className="pet-pack-preview">
<strong>{manifest.name}</strong>
<span>{manifest.version}</span>
<span>
{manifest.width} ? {manifest.height}
</span>
<span>{manifest.animations.length} ?????</span>
</div>
) : null}
</section>
);
}

查看文件

@ -691,3 +691,29 @@ select:focus {
grid-template-columns: 1fr;
}
}
.pet-pack-importer {
display: grid;
gap: 1rem;
margin: 2rem 0;
padding: 1.5rem;
border: 1px solid rgb(137 175 232 / 28%);
border-radius: 1rem;
background: rgb(13 29 52 / 78%);
}
.pet-pack-importer h2 {
margin: 0.3rem 0;
}
.pet-pack-preview {
display: flex;
flex-wrap: wrap;
gap: 0.8rem 1.2rem;
padding: 1rem;
border: 1px solid rgb(96 211 153 / 42%);
border-radius: 0.8rem;
color: #c8f7dc;
background: rgb(20 83 57 / 45%);
}