Skip to content

Commit 12d74a5

Browse files
liujupingJackLian
authored andcommitted
fix: fix lowcode-plugin-simulator-select plug-in default selection and configuration inconsistency
1 parent 1c76f9d commit 12d74a5

2 files changed

Lines changed: 36 additions & 21 deletions

File tree

packages/plugin-simulator-size/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alilc/lowcode-plugin-simulator-select",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "画布切换",
55
"main": "lib/index.js",
66
"scripts": {

packages/plugin-simulator-size/src/index.tsx

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ export class SimulatorResizePane extends React.Component {
3131
currentWidth
3232
});
3333
});
34+
project.onSimulatorHostReady?.((simulator) => {
35+
if (simulator.get('device')) {
36+
this.setState({
37+
active: simulator.get('device'),
38+
});
39+
}
40+
});
3441
}
3542

3643
change = (device: string) => {
@@ -47,7 +54,7 @@ export class SimulatorResizePane extends React.Component {
4754
currentWidth
4855
});
4956
}, 0);
50-
}
57+
};
5158

5259
renderItemSVG(device: string) {
5360
switch (device) {
@@ -76,31 +83,39 @@ export class SimulatorResizePane extends React.Component {
7683
>
7784
{this.renderItemSVG(item.key)}
7885
</span>
79-
)
86+
);
8087
})
8188
}
82-
<div className='lp-simulator-width-setter'>
83-
<NumberPicker className="lp-simulator-width-input" addonTextAfter="px" value={currentWidth} placeholder="请输入" onChange={(value) => {
84-
this.setState({
85-
currentWidth: value
86-
});
87-
}} onPressEnter={(event: any) => {
88-
const value = event?.target?.value;
89-
const simulator = project.simulatorHost;
90-
simulator?.set('deviceStyle', {
91-
canvas: {
92-
width: `${value}px`,
93-
}
94-
})
95-
this.setState({
96-
currentWidth: value
97-
});
98-
}} />
89+
<div className="lp-simulator-width-setter">
90+
<NumberPicker
91+
className="lp-simulator-width-input"
92+
addonTextAfter="px"
93+
value={currentWidth}
94+
placeholder="请输入"
95+
onChange={(value) => {
96+
this.setState({
97+
currentWidth: value
98+
});
99+
}}
100+
onPressEnter={(event: any) => {
101+
const value = event?.target?.value;
102+
const simulator = project.simulatorHost;
103+
simulator?.set('deviceStyle', {
104+
canvas: {
105+
width: `${value}px`,
106+
},
107+
});
108+
this.setState({
109+
currentWidth: value
110+
});
111+
}}
112+
/>
99113
</div>
100114
</div>
101115
);
102116
}
103117
}
118+
104119
const plugin = (ctx: ILowCodePluginContext) => {
105120
const SimulatorResizePaneRef = React.createRef<SimulatorResizePane>();
106121

@@ -114,7 +129,7 @@ const plugin = (ctx: ILowCodePluginContext) => {
114129
type: 'Widget',
115130
props: {
116131
description: '切换画布尺寸',
117-
align: "center",
132+
align: 'center',
118133
},
119134
content: (
120135
<SimulatorResizePane

0 commit comments

Comments
 (0)