diff --git a/src/App.tsx b/src/App.tsx index 74f8ff9..6fe60bd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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() { /> + void refreshStatus()}> 閲嶆柊妫€鏌?IPC diff --git a/src/features/pet/PetPackImporter.tsx b/src/features/pet/PetPackImporter.tsx new file mode 100644 index 0000000..2fabad6 --- /dev/null +++ b/src/features/pet/PetPackImporter.tsx @@ -0,0 +1,58 @@ +import { useState } from "react"; + +import { petPackManifestSchema, type PetPackManifest } from "./types"; + +export function PetPackImporter() { + const [manifest, setManifest] = useState(null); + const [error, setError] = useState(null); + const [fileName, setFileName] = useState(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 ( + + + Q6 pet pack + ????? + + ????? JSON manifest????????????????????????? + + + { + const file = event.target.files?.[0]; + if (file) void importManifest(file); + }} + /> + {fileName ? ???{fileName} : null} + {error ? {error} : null} + {manifest ? ( + + {manifest.name} + {manifest.version} + + {manifest.width} ? {manifest.height} + + {manifest.animations.length} ????? + + ) : null} + + ); +} diff --git a/src/styles.css b/src/styles.css index 18725a4..3a7f840 100644 --- a/src/styles.css +++ b/src/styles.css @@ -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%); +}
Q6 pet pack
+ ????? JSON manifest????????????????????????? +
???{fileName}
{error}