fix(title): toggleAiAutoSelect 简化为纯 toggle,消除状态覆盖风险
This commit is contained in:
@@ -5,8 +5,6 @@ import type { TitleSettings } from "../../types"
|
||||
interface UseTitleStyleUpdatersOptions {
|
||||
titleSettings: TitleSettings
|
||||
onTitleSettingsChange: (settings: TitleSettings) => void
|
||||
/** AI 自动生成标题函数(由 useStep4Title 从 aiGenerator 注入) */
|
||||
autoGenerateTitle?: () => string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -16,7 +14,6 @@ interface UseTitleStyleUpdatersOptions {
|
||||
export function useTitleStyleUpdaters({
|
||||
titleSettings,
|
||||
onTitleSettingsChange,
|
||||
autoGenerateTitle,
|
||||
}: UseTitleStyleUpdatersOptions) {
|
||||
/** 匹配预设:只用 color/bold/italic/stroke/shadow,不再匹配 size */
|
||||
const getActivePreset = (settings: TitleSettings): string | null => {
|
||||
@@ -44,17 +41,8 @@ export function useTitleStyleUpdaters({
|
||||
)
|
||||
|
||||
const toggleAiAutoSelect = useCallback(() => {
|
||||
if (!titleSettings.aiAutoSelect) {
|
||||
// 打开开关:自动生成标题
|
||||
if (autoGenerateTitle) {
|
||||
autoGenerateTitle()
|
||||
}
|
||||
}
|
||||
onTitleSettingsChange({
|
||||
...titleSettings,
|
||||
aiAutoSelect: !titleSettings.aiAutoSelect,
|
||||
})
|
||||
}, [titleSettings, onTitleSettingsChange, autoGenerateTitle])
|
||||
onTitleSettingsChange({ ...titleSettings, aiAutoSelect: !titleSettings.aiAutoSelect })
|
||||
}, [titleSettings, onTitleSettingsChange])
|
||||
|
||||
const updatePosition = useCallback(
|
||||
(position: string) => {
|
||||
|
||||
Reference in New Issue
Block a user