Commit a41b35b76d2cef5337b973bddf7bc323a97c033e

Authored by ww
1 parent 18b300be

perf: auto save data source on open interaction event or open dynamic effect

... ... @@ -5068,11 +5068,18 @@ DataFormatPanel.prototype.addDataFont = function (container) {
5068 5068 }
5069 5069
5070 5070 /**
5071   - * @description 刷新页面
  5071 + * @description 刷新页面 用于在其他位置调用更新数据面板的操作,默认是个空函数,在生成数据源面板中进行了拓展
5072 5072 */
5073 5073 function echoRefreshFn() {
5074 5074 }
5075 5075
  5076 + /**
  5077 + * @description 用于在其他位置获取数据源绑定的数据,在生成数据源面板中进行了改写
  5078 + */
  5079 + function getDataSourceBindValue() {
  5080 +
  5081 + }
  5082 +
5076 5083
5077 5084 // 获取url的请求参数函数
5078 5085 function getRequest() {
... ... @@ -5154,6 +5161,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
5154 5161 await echoActionType()
5155 5162 }
5156 5163
  5164 + /**
  5165 + * @description 回显动效类型
  5166 + */
5157 5167 async function echoActionType() {
5158 5168 const act = currentNodeData.act ?? []
5159 5169 const event = currentNodeData.event ?? []
... ... @@ -5213,7 +5223,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
5213 5223
5214 5224
5215 5225 async function mount() {
5216   - const { component, echoDataSource } = generatorDataSourceComponent({ validate: false })
  5226 + const { component, echoDataSource, getValue } = generatorDataSourceComponent({ validate: false })
5217 5227 $(fragment).append(title).append(component)
5218 5228 $(container).append(fragment)
5219 5229
... ... @@ -5228,6 +5238,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
5228 5238 echoDataSource(dataSource)
5229 5239 form.render(null, CONTAINER_FILTER)
5230 5240 }
  5241 +
  5242 + // 改写获取数据源绑定的值
  5243 + getDataSourceBindValue = getValue
5231 5244 }
5232 5245
5233 5246 mount()
... ... @@ -7618,17 +7631,31 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7618 7631 // 异步设置此处才能生效 -- 设置默认select和样式和初始化侧边栏生成组件和事件绑定
7619 7632 setTimeout(() => {
7620 7633
  7634 + function proxyFn(fn) {
  7635 + return (...args) => {
  7636 + const currentDataSource = getDataSourceBindValue() || {}
  7637 +
  7638 + to(ConfigurationNodeApi.updateNodeInfo({
  7639 + configurationId,
  7640 + contentId: currentPageId.id,
  7641 + nodeId: graphId,
  7642 + [enumCategory.DATA_SOURCE]: currentDataSource
  7643 + }))
  7644 + fn.apply(null, args)
  7645 + }
  7646 + }
  7647 +
7621 7648 // TODO 数据交互事件
7622   - $(`#${enumDynamicEffectType.IMAGE}`).click({ type: enumDynamicEffectType.IMAGE }, handleSettingVarImage);
  7649 + $(`#${enumDynamicEffectType.IMAGE}`).click({ type: enumDynamicEffectType.IMAGE }, proxyFn(handleSettingVarImage));
7623 7650
7624   - $(`#${enumInteractionType.DOWN}`).click({ type: enumInteractionType.DOWN }, handleDownOrUpEvent);
7625   - $(`#${enumInteractionType.UP}`).click({ type: enumInteractionType.UP }, handleDownOrUpEvent);
7626   - $(`#${enumInteractionType.SINGLE}`).click({ type: enumInteractionType.SINGLE }, handleClickOrDbClick);
7627   - $(`#${enumInteractionType.DOUBLE}`).click({ type: enumInteractionType.DOUBLE }, handleClickOrDbClick);
  7651 + $(`#${enumInteractionType.DOWN}`).click({ type: enumInteractionType.DOWN }, proxyFn(handleDownOrUpEvent));
  7652 + $(`#${enumInteractionType.UP}`).click({ type: enumInteractionType.UP }, proxyFn(handleDownOrUpEvent));
  7653 + $(`#${enumInteractionType.SINGLE}`).click({ type: enumInteractionType.SINGLE }, proxyFn(handleClickOrDbClick));
  7654 + $(`#${enumInteractionType.DOUBLE}`).click({ type: enumInteractionType.DOUBLE }, proxyFn(handleClickOrDbClick));
7628 7655 // 数据动效事件
7629   - $(`#${enumDynamicEffectType.FLASH}`).click({ type: enumDynamicEffectType.FLASH }, handleDataDynamicEffect);
7630   - $(`#${enumDynamicEffectType.DISPLAY}`).click({ type: enumDynamicEffectType.DISPLAY }, handleDataDynamicEffect);
7631   - $(`#${enumDynamicEffectType.ROTATE}`).click({ type: enumDynamicEffectType.ROTATE }, handleDataDynamicEffect);
  7656 + $(`#${enumDynamicEffectType.FLASH}`).click({ type: enumDynamicEffectType.FLASH }, proxyFn(handleDataDynamicEffect));
  7657 + $(`#${enumDynamicEffectType.DISPLAY}`).click({ type: enumDynamicEffectType.DISPLAY }, proxyFn(handleDataDynamicEffect));
  7658 + $(`#${enumDynamicEffectType.ROTATE}`).click({ type: enumDynamicEffectType.ROTATE }, proxyFn(handleDataDynamicEffect));
7632 7659 });
7633 7660 };
7634 7661
... ...