diff --git a/webapp/app/assets/json/slideSettings/rectangle.json b/webapp/app/assets/json/slideSettings/rectangle.json index 126e0f430..21fe0c73a 100644 --- a/webapp/app/assets/json/slideSettings/rectangle.json +++ b/webapp/app/assets/json/slideSettings/rectangle.json @@ -44,7 +44,7 @@ "name": "backgroundImage", "title": "背景图片", "component": "upload", - "action": "slide/widget/{id}/bgImage", + "action": "slide/widget/{layerId}/bgImage", "accept": "image/*", "autoUpdate": true, "labelCol": 12, diff --git a/webapp/app/assets/json/slideSettings/slide.json b/webapp/app/assets/json/slideSettings/slide.json index 4921f1a3f..0fbcdbc47 100644 --- a/webapp/app/assets/json/slideSettings/slide.json +++ b/webapp/app/assets/json/slideSettings/slide.json @@ -28,7 +28,7 @@ "name": "backgroundImage", "title": "背景图片", "component": "upload", - "action": "slide/{id}/upload/bgImage", + "action": "slide/{slideId}/upload/bgImage", "accept": "image/*", "autoUpdate": true, "labelCol": 12, diff --git a/webapp/app/containers/Display/components/Setting/Form/Form.tsx b/webapp/app/containers/Display/components/Setting/Form/Form.tsx index 38cbbcd9f..684702443 100644 --- a/webapp/app/containers/Display/components/Setting/Form/Form.tsx +++ b/webapp/app/containers/Display/components/Setting/Form/Form.tsx @@ -42,13 +42,13 @@ interface ISettingFormProps extends FormComponentProps { } const SettingForm: React.FC = (props, ref) => { - const { form, setting, slideId } = props + const { form, setting, slideId, layerId } = props useImperativeHandle(ref, () => form) return (
- + {setting.params.map((param) => ( ))} @@ -58,7 +58,6 @@ const SettingForm: React.FC = (props, ref) => { } let cachedValues = {} -let debouncedChange = null export default Form.create({ onValuesChange: (props, changedValues) => { @@ -67,12 +66,10 @@ export default Form.create({ } cachedValues = { ...cachedValues, ...changedValues } const { onChange, layerId } = props - if (!debouncedChange) { - debouncedChange = debounce((layerId) => { - onChange({ ...cachedValues }, layerId) - cachedValues = {} - }, 1000) - } + const debouncedChange = debounce((layerId) => { + onChange({ ...cachedValues }, layerId) + cachedValues = {} + }, 1000) debouncedChange(layerId) } })(forwardRef(SettingForm)) diff --git a/webapp/app/containers/Display/components/Setting/Form/Item.tsx b/webapp/app/containers/Display/components/Setting/Form/Item.tsx index e0d66bb5a..7f7ee44bb 100644 --- a/webapp/app/containers/Display/components/Setting/Form/Item.tsx +++ b/webapp/app/containers/Display/components/Setting/Form/Item.tsx @@ -52,7 +52,7 @@ interface IItemProps { const Item: React.FC = (props) => { const { item } = props - const { form, size, slideId } = useContext(SlideSettingContext) + const { form, size, slideId, layerId } = useContext(SlideSettingContext) let visible = true const { relatedItems } = item if (Array.isArray(relatedItems)) { @@ -131,10 +131,9 @@ const Item: React.FC = (props) => { ) break case 'upload': - const action = `${api.display}/${item.action}`.replace( - /({id})/, - slideId.toString() - ) + const action = `${api.display}/${item.action}` + .replace(/({slideId})/, slideId ? `${slideId}` : '') + .replace(/({layerId})/, layerId ? `${layerId}` : '') const img = form.getFieldValue(item.name) control = ( diff --git a/webapp/app/containers/Display/components/Setting/Form/util.ts b/webapp/app/containers/Display/components/Setting/Form/util.ts index 815a0b113..c251a05a5 100644 --- a/webapp/app/containers/Display/components/Setting/Form/util.ts +++ b/webapp/app/containers/Display/components/Setting/Form/util.ts @@ -25,6 +25,7 @@ export const SlideSettingContext = React.createContext<{ form: WrappedFormUtils size: 'large' | 'small' | 'default' slideId?: number + layerId?: number }>({ form: null, size: 'small'