Skip to content

Commit 896db39

Browse files
committed
fix(bugs): fix canvas component border & switch style & add validator & tree plugin display sync & bind variable confirm disabled
1 parent 1109de0 commit 896db39

6 files changed

Lines changed: 69 additions & 25 deletions

File tree

packages/canvas/container/src/components/CanvasAction.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export default {
252252
253253
const hide = () => {
254254
getRenderer().setCondition(getCurrent().schema?.id, false)
255+
useCanvas().pageState.nodesStatus[getCurrent().schema?.id] = false
255256
updateRect()
256257
}
257258

packages/canvas/container/src/container.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,19 @@ export const updateRect = (id?: string) => {
481481
const isBodySelected = !selectState.componentName && selectState.width > 0
482482

483483
if (id || isBodySelected) {
484-
setTimeout(() => setSelectRect(id))
484+
// 获取元素动画持续时间
485+
const element = querySelectById(id) || getDocument().body
486+
const duration = window.getComputedStyle(element).getPropertyValue('transition-duration')
487+
let waitTime = 0
488+
if (duration) {
489+
const unit = duration.slice(-2)
490+
if (unit === 'ms') {
491+
waitTime = parseFloat(duration)
492+
} else {
493+
waitTime = parseFloat(duration) * 1000
494+
}
495+
}
496+
setTimeout(() => setSelectRect(id), waitTime)
485497
} else {
486498
clearSelect()
487499
}

packages/configurator/src/html-attributes-configurator/HtmlAttributesConfigurator.vue

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="attr-header">
3-
<span class="header-title">自定义属性</span>
3+
<span class="header-title">原生属性</span>
44
<tiny-popover
55
v-model="state.visible"
66
placement="bottom"
@@ -11,11 +11,18 @@
1111
>
1212
<div class="attr-form">
1313
<icon-close class="icon-close" @click="closePopover"></icon-close>
14-
<tiny-form label-position="left" label-width="53px">
15-
<tiny-form-item label="name">
14+
<tiny-form
15+
ref="attrFormRef"
16+
:model="state.formData"
17+
:rules="rules"
18+
validate-type="text"
19+
label-position="left"
20+
label-width="53px"
21+
>
22+
<tiny-form-item label="name" prop="key">
1623
<tiny-input v-model="state.formData.key"></tiny-input>
1724
</tiny-form-item>
18-
<tiny-form-item label="value">
25+
<tiny-form-item label="value" prop="value">
1926
<tiny-input v-model="state.formData.value"></tiny-input>
2027
</tiny-form-item>
2128
<div class="footer">
@@ -81,9 +88,18 @@ export default {
8188
currentAttr: {}
8289
})
8390
91+
const attrFormRef = ref()
8492
const attrs = ref([])
8593
const properties = ['style']
8694
95+
const rules = {
96+
key: [
97+
{ required: true, message: '名称必填', tigger: 'blur' },
98+
{ max: 20, message: '长度不大于20', trigger: 'change' }
99+
],
100+
value: [{ max: 200, message: '长度不大于200', trigger: 'change' }]
101+
}
102+
87103
watchEffect(() => {
88104
if (!useProperties().getSchema()?.props) {
89105
return
@@ -144,24 +160,29 @@ export default {
144160
}
145161
146162
const save = () => {
147-
state.visible = false
148-
const data = {}
149-
let index = -1
163+
attrFormRef.value.validate((valid) => {
164+
if (!valid) {
165+
return
166+
}
167+
state.visible = false
168+
const data = {}
169+
let index = -1
150170
151-
if (state.currentAttr.id) {
152-
index = attrs.value.findIndex((item) => item.id === state.currentAttr.id)
153-
data.id = state.currentAttr.id
154-
state.currentAttr = {}
155-
} else {
156-
data.id = utils.guid()
157-
index = attrs.value.length
158-
}
171+
if (state.currentAttr.id) {
172+
index = attrs.value.findIndex((item) => item.id === state.currentAttr.id)
173+
data.id = state.currentAttr.id
174+
state.currentAttr = {}
175+
} else {
176+
data.id = utils.guid()
177+
index = attrs.value.length
178+
}
159179
160-
data.text = `${state.formData.key} = '${state.formData.value}'`
161-
data.data = { key: state.formData.key, value: state.formData.value }
180+
data.text = `${state.formData.key} = '${state.formData.value}'`
181+
data.data = { key: state.formData.key, value: state.formData.value }
162182
163-
attrs.value.splice(index, 1, data)
164-
updateSchema()
183+
attrs.value.splice(index, 1, data)
184+
updateSchema()
185+
})
165186
}
166187
167188
const edit = (attr) => {
@@ -187,7 +208,9 @@ export default {
187208
}
188209
189210
return {
211+
attrFormRef,
190212
state,
213+
rules,
191214
cancel,
192215
save,
193216
attrs,

packages/configurator/src/slot-configurator/SlotConfigurator.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export default {
186186
.e__switch-core::after {
187187
content: '';
188188
position: absolute;
189-
top: 1px;
189+
top: 2px;
190190
left: 1px;
191191
border-radius: 100%;
192192
transition: all 0.3s;

packages/configurator/src/variable-configurator/VariableConfigurator.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
:value="state.variable"
7171
:options="editorOptions"
7272
@editorDidMount="editorDidMount"
73+
@change="editorChange"
7374
></monaco-editor>
7475
<div v-if="isDataSource" class="datasource-poll-wrap">
7576
<tiny-tooltip
@@ -112,7 +113,7 @@
112113
<tiny-button type="danger" plain @click="remove">移除绑定</tiny-button>
113114
<div class="right">
114115
<tiny-button @click="cancel">取 消</tiny-button>
115-
<tiny-button type="info" @click="confirm">确 定</tiny-button>
116+
<tiny-button type="info" :disabled="confirmDisabled" @click="confirm">确 定</tiny-button>
116117
</div>
117118
</div>
118119
</template>
@@ -260,6 +261,8 @@ export default {
260261
261262
const isDataSource = computed(() => state.active === CONSTANTS.DATASOUCE)
262263
264+
const confirmDisabled = computed(() => !state.variable)
265+
263266
// 每次弹窗打开时都记录下绑定变量的旧值,用来判断保存按钮状态
264267
watch(
265268
() => state.isVisible,
@@ -309,6 +312,10 @@ export default {
309312
})
310313
}
311314
315+
const editorChange = (value) => {
316+
state.variable = value
317+
}
318+
312319
const removeInterval = (start, end, intervalId, pageSchema) => {
313320
const unmountedFn = pageSchema.lifeCycles?.onUnmounted?.value
314321
const fetchBody = `
@@ -543,7 +550,9 @@ export default {
543550
}
544551
545552
return {
553+
confirmDisabled,
546554
editorDidMount,
555+
editorChange,
547556
editorOptions,
548557
variableClick,
549558
remove,

packages/plugins/tree/src/Main.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export default {
9696
const translateChild = (data) => {
9797
data.forEach((item) => {
9898
item.show = pageState.nodesStatus[item.id] !== false
99-
item.showEye = !item.show
10099
const child = item.children
101100
if (Array.isArray(child)) {
102101
translateChild(item.children)
@@ -151,8 +150,8 @@ export default {
151150
}
152151
153152
const showNode = (data) => {
154-
data.show = !data.show
155-
pageState.nodesStatus[data.id] = data.show
153+
pageState.nodesStatus[data.id] = !(pageState.nodesStatus[data.id] !== false)
154+
data.show = pageState.nodesStatus[data.id]
156155
157156
const { getRenderer, clearSelect } = useCanvas().canvasApi.value
158157

0 commit comments

Comments
 (0)