@tmagic/editor 1.5.15 → 1.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -156,52 +156,63 @@ export const displayTabConfig: TabPaneConfig = {
156
156
  * @param config 组件属性配置
157
157
  * @returns Object
158
158
  */
159
- export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormConfig => [
160
- {
161
- type: 'tab',
162
- labelWidth,
163
- items: [
164
- {
165
- title: '属性',
166
- items: [
167
- // 组件类型,必须要有
168
- {
169
- text: 'type',
170
- name: 'type',
171
- type: 'hidden',
172
- },
173
- // 组件id,必须要有
174
- {
175
- name: 'id',
176
- text: 'ID',
177
- type: 'text',
178
- disabled: true,
179
- append: {
180
- type: 'button',
181
- text: '复制',
182
- handler: (vm, { model }) => {
183
- navigator.clipboard
184
- .writeText(`${model.id}`)
185
- .then(() => {
186
- tMagicMessage.success('已复制');
187
- })
188
- .catch(() => {
189
- tMagicMessage.error('复制失败');
190
- });
191
- },
192
- },
193
- },
194
- {
195
- name: 'name',
196
- text: '组件名称',
197
- },
198
- ...config,
199
- ],
159
+ export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormConfig => {
160
+ const propsConfig: FormConfig = [];
161
+
162
+ // 组件类型,必须要有
163
+ if (!config.find((item) => item.name === 'type')) {
164
+ propsConfig.push({
165
+ text: 'type',
166
+ name: 'type',
167
+ type: 'hidden',
168
+ });
169
+ }
170
+
171
+ if (!config.find((item) => item.name === 'id')) {
172
+ // 组件id,必须要有
173
+ propsConfig.push({
174
+ name: 'id',
175
+ text: 'ID',
176
+ type: 'text',
177
+ disabled: true,
178
+ append: {
179
+ type: 'button',
180
+ text: '复制',
181
+ handler: (vm, { model }) => {
182
+ navigator.clipboard
183
+ .writeText(`${model.id}`)
184
+ .then(() => {
185
+ tMagicMessage.success('已复制');
186
+ })
187
+ .catch(() => {
188
+ tMagicMessage.error('复制失败');
189
+ });
190
+ },
200
191
  },
201
- { ...styleTabConfig },
202
- { ...eventTabConfig },
203
- { ...advancedTabConfig },
204
- { ...displayTabConfig },
205
- ],
206
- },
207
- ];
192
+ });
193
+ }
194
+
195
+ if (!config.find((item) => item.name === 'name')) {
196
+ propsConfig.push({
197
+ name: 'name',
198
+ text: '组件名称',
199
+ });
200
+ }
201
+
202
+ return [
203
+ {
204
+ type: 'tab',
205
+ labelWidth,
206
+ items: [
207
+ {
208
+ title: '属性',
209
+ items: [...propsConfig, ...config],
210
+ },
211
+ { ...styleTabConfig },
212
+ { ...eventTabConfig },
213
+ { ...advancedTabConfig },
214
+ { ...displayTabConfig },
215
+ ],
216
+ },
217
+ ];
218
+ };