初始化项目启动器代码

This commit is contained in:
xintaofei
2026-03-27 13:05:27 +08:00
parent 77204e2295
commit 7c89e150f9
25 changed files with 1434 additions and 15 deletions

View File

@@ -0,0 +1,50 @@
"use client"
import { useMemo, useState } from "react"
import {
ResizablePanelGroup,
ResizablePanel,
ResizableHandle,
} from "@/components/ui/resizable"
import { ShadcnConfigPanel } from "./shadcn-config-panel"
import { ShadcnPreview } from "./shadcn-preview"
import {
DEFAULT_PRESET_CONFIG,
encodePreset,
buildPreviewUrl,
type ShadcnPresetConfig,
} from "./constants"
export function ShadcnLauncher() {
const [config, setConfig] = useState<ShadcnPresetConfig>(
DEFAULT_PRESET_CONFIG
)
const presetCode = useMemo(() => encodePreset(config), [config])
const previewUrl = useMemo(
() => buildPreviewUrl(config.base, presetCode),
[config.base, presetCode]
)
const updateConfig = (key: keyof ShadcnPresetConfig, value: string) => {
setConfig((prev) => ({ ...prev, [key]: value }))
}
return (
<ResizablePanelGroup direction="horizontal" className="h-full">
<ResizablePanel defaultSize={40} minSize={30} maxSize={50}>
<ShadcnConfigPanel
config={config}
onConfigChange={updateConfig}
presetCode={presetCode}
/>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={60} minSize={40}>
<ShadcnPreview previewUrl={previewUrl} />
</ResizablePanel>
</ResizablePanelGroup>
)
}