Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/draggable on component #21

Closed

Conversation

leefinder
Copy link
Contributor

拖拽热点从左上角按钮,调整到整个组件

@Liberty-liu
Copy link
Owner

我觉的这里不要直接把之前的逻辑删掉
在这里加一个新的prop:

const props = defineProps(_.merge({
fieldsPanelWidth: {
type: String,
default: '220px'
},
fieldsPanelDefaultOpeneds: {
type: Array,
default: () => ['defaultField', 'field', 'container']
},
delHandle: {
type: Function,
default: () => {}
},
copyHandle: {
type: Function,
default: () => {}
},
inlineMax: {
type: Number,
default: 4
},
isShowClear: {
type: Boolean,
default: true
},
isShowI18n: {
type: Boolean,
default: true
}
}, defaultProps))

dragMode: {
  type: String,
  default: 'icon',
  validator: (value) => ['full', 'icon'].includes(value)
}

这样有两种选择,由使用者自由选择,你觉的怎么样?

@leefinder
Copy link
Contributor Author

我觉的这里不要直接把之前的逻辑删掉 在这里加一个新的prop:

const props = defineProps(_.merge({
fieldsPanelWidth: {
type: String,
default: '220px'
},
fieldsPanelDefaultOpeneds: {
type: Array,
default: () => ['defaultField', 'field', 'container']
},
delHandle: {
type: Function,
default: () => {}
},
copyHandle: {
type: Function,
default: () => {}
},
inlineMax: {
type: Number,
default: 4
},
isShowClear: {
type: Boolean,
default: true
},
isShowI18n: {
type: Boolean,
default: true
}
}, defaultProps))

dragMode: {
  type: String,
  default: 'icon',
  validator: (value) => ['full', 'icon'].includes(value)
}

这样有两种选择,由使用者自由选择,你觉的怎么样?

挺灵活的

有点小建议看看有没有机会沟通一下
(在Everright-formEditor的架构思路基础上),看看能不能采纳,把工程改造成多包的模式,编辑器与物料,设置器分离,输出3个包

image

  • @engine/core
  • @engine/widgets
  • @engine/utils

Engine通过注册机注册物料与设置器,用户通过schema规范自行拓展

import Engine from '@engine/core'
import { baseWidgets, baseSetters } from '@engine/widgets'
Engine.registerWidgets(baseWidgets)
Engine.registerSetters(baseSetters)

物料面板与设置面板通过策略渲染,可以考虑把所有配置写进物料里面,后面可以考虑把packages\formEditor\componentsConfig.js 拆到细粒度

// 物料
import { installedWidgets } from '@engine/utils'
  import Widgets from './widgets.vue'
  const groupBy = (arr, key) =>
    (arr || []).reduce((acc, x = {}) => ({
      ...acc,
      [x[key] ?? '未分组']: [...acc[x[key] ?? '未分组'] || [], x]
    }), {})

    const data =[...installedWidgets].sort((a: any,b: any) => a.rank - b.rank)
<template v-for="([key, propConfig]) in currentProps" :key="key">
          <FormItem :label="propConfig.label">
            <component v-model:value="selected.props[key]" :is="baseSetters[propConfig.eNodeType]" v-bind="propConfig" :config="selected.props"
              @change-props="handleChangeProps" />
          </FormItem>
        </template>

image

@Liberty-liu
Copy link
Owner

蛮好的,改动也蛮大,这个issue #15 也希望能够自定义,加这些功能目前没有完整的单元测试会更累,单元测试覆盖率高一些做这些事情会容易省心一些,接下来我尽可能把测试覆盖率加上去

@leefinder leefinder closed this Aug 14, 2023
@leefinder leefinder deleted the feature/draggable-on-component branch August 14, 2023 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants