|
@@ -1,5 +1,6 @@
|
|
|
import type { ComponentSchema, IComponentModelConfig } from './type'
|
|
import type { ComponentSchema, IComponentModelConfig } from './type'
|
|
|
import type { VariableType } from '@/types/variables'
|
|
import type { VariableType } from '@/types/variables'
|
|
|
|
|
+import { klona } from 'klona'
|
|
|
|
|
|
|
|
type VariableConfig = {
|
|
type VariableConfig = {
|
|
|
type: VariableType
|
|
type: VariableType
|
|
@@ -38,6 +39,54 @@ const commonWidgetVariableConfig: Record<string, VariableConfig> = {
|
|
|
'props.scrollbar': { type: 'enum', enumMap: scrollbarEnumMap }
|
|
'props.scrollbar': { type: 'enum', enumMap: scrollbarEnumMap }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const createBezierDefaultConfig = () => ({
|
|
|
|
|
+ enabled: false,
|
|
|
|
|
+ mode: 'time',
|
|
|
|
|
+ time: {
|
|
|
|
|
+ duration: 500,
|
|
|
|
|
+ easing: 'linear',
|
|
|
|
|
+ repeatCount: -1,
|
|
|
|
|
+ playback: {
|
|
|
|
|
+ enabled: false,
|
|
|
|
|
+ duration: 500,
|
|
|
|
|
+ delay: 500
|
|
|
|
|
+ },
|
|
|
|
|
+ autoPlay: false,
|
|
|
|
|
+ reverse: false,
|
|
|
|
|
+ scale: {
|
|
|
|
|
+ enabled: false,
|
|
|
|
|
+ targetWidth: undefined,
|
|
|
|
|
+ targetHeight: undefined,
|
|
|
|
|
+ duration: 500,
|
|
|
|
|
+ delay: 500
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ value: {
|
|
|
|
|
+ range: {
|
|
|
|
|
+ min: 0,
|
|
|
|
|
+ max: 100
|
|
|
|
|
+ },
|
|
|
|
|
+ current: 50
|
|
|
|
|
+ },
|
|
|
|
|
+ path: {
|
|
|
|
|
+ source: 'resource',
|
|
|
|
|
+ resourceId: '',
|
|
|
|
|
+ segments: []
|
|
|
|
|
+ },
|
|
|
|
|
+ showTrack: true
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+const bezierConfigSchema: ComponentSchema = {
|
|
|
|
|
+ label: '贝塞尔动画',
|
|
|
|
|
+ field: 'props.bezierConfig',
|
|
|
|
|
+ valueType: 'bezier',
|
|
|
|
|
+ componentProps: {}
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const hasBezierConfigSchema = (props?: ComponentSchema[]) => {
|
|
|
|
|
+ return props?.some((item) => item.field === 'props.bezierConfig')
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const widgetVariableConfigMap: WidgetVariableConfigMap = {
|
|
const widgetVariableConfigMap: WidgetVariableConfigMap = {
|
|
|
lv_button: {
|
|
lv_button: {
|
|
|
...commonPositionSizeFields,
|
|
...commonPositionSizeFields,
|
|
@@ -269,11 +318,33 @@ export const enhanceWidgetVariableConfig = (widget: IComponentModelConfig): ICom
|
|
|
...(widgetVariableConfigMap[widget.key] || {})
|
|
...(widgetVariableConfigMap[widget.key] || {})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 给所有非 page 控件统一补上贝塞尔动画配置,避免每个组件重复维护。
|
|
|
|
|
+ const nextDefaultSchema = {
|
|
|
|
|
+ ...widget.defaultSchema,
|
|
|
|
|
+ props:
|
|
|
|
|
+ widget.key === 'page'
|
|
|
|
|
+ ? widget.defaultSchema.props
|
|
|
|
|
+ : {
|
|
|
|
|
+ ...(widget.defaultSchema.props || {}),
|
|
|
|
|
+ ...(widget.defaultSchema.props?.bezierConfig
|
|
|
|
|
+ ? {}
|
|
|
|
|
+ : {
|
|
|
|
|
+ bezierConfig: klona(createBezierDefaultConfig())
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const nextProps = widget.config.props ? [...widget.config.props] : []
|
|
|
|
|
+ if (widget.key !== 'page' && !hasBezierConfigSchema(nextProps)) {
|
|
|
|
|
+ nextProps.push(bezierConfigSchema)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
...widget,
|
|
...widget,
|
|
|
|
|
+ defaultSchema: nextDefaultSchema,
|
|
|
config: {
|
|
config: {
|
|
|
...widget.config,
|
|
...widget.config,
|
|
|
- props: widget.config.props?.map((item) => withVariableConfig(item, configMap)),
|
|
|
|
|
|
|
+ props: nextProps.map((item) => withVariableConfig(item, configMap)),
|
|
|
coreProps: widget.config.coreProps?.map((item) => withVariableConfig(item, configMap)),
|
|
coreProps: widget.config.coreProps?.map((item) => withVariableConfig(item, configMap)),
|
|
|
styles: widget.config.styles?.map((item) => withVariableConfig(item, configMap))
|
|
styles: widget.config.styles?.map((item) => withVariableConfig(item, configMap))
|
|
|
}
|
|
}
|