Files
xiaoxia-saas/apps/web/src/pages/editing-planner/components/StickerPanel/index.tsx
T
xiaoxia 223bb530dd
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 2m20s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 2m28s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 3m21s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 3m49s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 5m18s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 5m41s
CI/CD Pipeline / Integration Tests (push) Successful in 2m25s
CI/CD Pipeline / Unit Tests (push) Failing after 10m1s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 12m34s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 30s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 33s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 4m37s
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Failing after 5m1s
refactor(StickerPanel): 贴纸面板目录化拆分(516→103行, -80%) (#1191)
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
2026-07-30 12:16:12 +08:00

102 lines
2.3 KiB
TypeScript

import React from "react"
import { Drawer, Switch } from "antd"
import type { StickerConfig } from "../../types"
import { useStickerPanel } from "./hooks/useStickerPanel"
import { StickerTabs } from "./components/StickerTabs"
import { StickerList } from "./components/StickerList"
import { StickerPropsEditor } from "./components/StickerPropsEditor"
export interface StickerPanelProps {
open: boolean
onClose: () => void
config: StickerConfig
onChange: (config: StickerConfig) => void
totalDuration: number
}
const StickerPanel: React.FC<StickerPanelProps> = ({
open,
onClose,
config,
onChange,
totalDuration,
}) => {
const {
selectedId,
setSelectedId,
selectedSticker,
activeTab,
setActiveTab,
textInput,
setTextInput,
updateItem,
addSticker,
removeSticker,
} = useStickerPanel({ config, onChange, totalDuration })
const handleEmojiAdd = (emoji: string) => {
addSticker("emoji", emoji)
}
const handleImageAdd = (url: string) => {
addSticker("image", url)
}
const handleTextAdd = (text: string) => {
addSticker("text", text)
setTextInput("")
}
return (
<Drawer
title="贴纸"
placement="right"
width={460}
open={open}
onClose={onClose}
className="sticker-panel-drawer"
>
{/* 顶部开关 */}
<div className="sticker-header">
<span className="sticker-header-label">启用贴纸</span>
<Switch
size="small"
checked={config.enabled}
onChange={(checked) => onChange({ ...config, enabled: checked })}
/>
</div>
{/* Tab 选择器 + 内容 */}
<StickerTabs
activeTab={activeTab}
onTabChange={setActiveTab}
textInput={textInput}
onTextInputChange={setTextInput}
onAddEmoji={handleEmojiAdd}
onAddImage={handleImageAdd}
onAddText={handleTextAdd}
/>
{/* 已添加贴纸列表 */}
<StickerList
items={config.items}
selectedId={selectedId}
onSelect={setSelectedId}
onRemove={removeSticker}
/>
{/* 选中贴纸的属性编辑 */}
{selectedSticker && (
<StickerPropsEditor
sticker={selectedSticker}
totalDuration={totalDuration}
onChange={updateItem}
/>
)}
</Drawer>
)
}
export default StickerPanel