@@ -4,50 +4,37 @@ import { SlotNode } from '@alilc/lowcode-designer';
4
4
import {
5
5
ComponentPublicInstance ,
6
6
h ,
7
- ref ,
8
7
Fragment ,
9
- computed ,
10
8
reactive ,
11
9
onUnmounted ,
12
10
defineComponent ,
13
11
} from 'vue' ;
14
12
import { leafProps } from './base' ;
15
13
import { useRendererContext } from '../context' ;
16
- import { ensureArray , parseSchema } from '../utils' ;
14
+ import { ensureArray } from '../utils' ;
17
15
import { PropSchemaMap , SlotSchemaMap , useLeaf } from './use' ;
18
16
19
17
export const Hoc = defineComponent ( {
20
18
name : 'Hoc' ,
21
19
props : leafProps ,
22
20
setup ( props ) {
23
- const hidden = ref ( ! ! props . schema . hidden ) ;
24
- const condition = ref < unknown > ( props . schema . condition ?? true ) ;
25
-
26
21
const { triggerCompGetCtx } = useRendererContext ( ) ;
27
- const { node, locked, buildSchema, buildProps, buildSlost, buildLoop } =
22
+ const { node, locked, buildSchema, buildProps, buildSlost, buildLoop, buildShow } =
28
23
useLeaf ( props ) ;
29
24
25
+ const { show, hidden, condition } = buildShow ( props . schema ) ;
30
26
const { loop, updateLoop, updateLoopArg, buildLoopScope } = buildLoop ( props . schema ) ;
27
+
31
28
const compProps : PropSchemaMap = reactive ( { } ) ;
32
29
const compSlots : SlotSchemaMap = reactive ( { } ) ;
33
30
const result = buildSchema ( ) ;
34
31
Object . assign ( compProps , result . props ) ;
35
32
Object . assign ( compSlots , result . slots ) ;
36
33
37
- const show = computed ( ( ) => {
38
- if ( hidden . value ) return false ;
39
- const { value : showCondition } = condition ;
40
- if ( typeof showCondition === 'boolean' ) return showCondition ;
41
- return ! ! parseSchema ( showCondition , props . scope ) ;
42
- } ) ;
43
-
44
34
// hoc
45
35
if ( node ) {
46
36
const disposeFunctions : Array < CallableFunction | undefined > = [ ] ;
47
37
onUnmounted ( ( ) => disposeFunctions . forEach ( ( dispose ) => dispose ?.( ) ) ) ;
48
- disposeFunctions . push (
49
- node . onVisibleChange ( ( visible ) => void ( hidden . value = ! visible ) )
50
- ) ;
51
38
disposeFunctions . push (
52
39
node . onChildrenChange ( ( ) => {
53
40
const schema = node . export ( TransformStage . Render ) ;
@@ -59,9 +46,12 @@ export const Hoc = defineComponent({
59
46
const { key, prop, newValue, oldValue } = info ;
60
47
if ( key === '___isLocked___' ) {
61
48
locked . value = newValue ;
49
+ } else if ( key === '___hidden___' ) {
50
+ // 设计器控制组件渲染
51
+ hidden ( newValue ) ;
62
52
} else if ( key === '___condition___' ) {
63
53
// 条件渲染更新 v-if
64
- condition . value = newValue ;
54
+ condition ( newValue ) ;
65
55
} else if ( key === '___loop___' ) {
66
56
// 循环数据更新 v-for
67
57
updateLoop ( newValue ) ;
0 commit comments