Skip to content

Commit 1b38a81

Browse files
committed
fix: 增加必要的方法
1 parent b8b2658 commit 1b38a81

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"setup:test": "./scripts/setup-for-test.sh",
2525
"setup:skip-build": "./scripts/setup-skip-build.sh",
2626
"start": "./scripts/start.sh",
27-
"start:demo": "./scripts/start.sh @ali/lowcode-demo",
2827
"test": "lerna run test --stream",
2928
"test:snapshot": "lerna run test:snapshot",
3029
"watchdog:build": "node ./scripts/watchdog.js",

packages/editor-skeleton/src/components/settings/settings-pane.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import { SkeletonContext } from '../../context';
1010
// import { Icon } from '@alifd/next';
1111
import { intl } from '../../locale';
1212

13-
function transformStringToFunction(str) {
14-
if (typeof str !== 'string') return str;
15-
// eslint-disable-next-line no-new-func
16-
return new Function(`"use strict"; return ${str}`)();
17-
}
18-
1913
function isStandardComponent(componentMeta: ComponentMeta | null) {
2014
if (!componentMeta) return false;
2115
const { prototype } = componentMeta;
@@ -38,8 +32,9 @@ function isInitialValueNotEmpty(initialValue: any) {
3832
}
3933

4034
type SettingFieldViewProps = { field: SettingField };
35+
type SettingFieldViewState = { fromOnChange: boolean; value: any };
4136
@observer
42-
class SettingFieldView extends Component<{ field: SettingField }> {
37+
class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldViewState> {
4338
static contextType = SkeletonContext;
4439

4540
stageName: string | undefined;
@@ -150,9 +145,10 @@ class SettingFieldView extends Component<{ field: SettingField }> {
150145

151146
// 当前 field 没有 value 值时,将 initialValue 写入 field
152147
// 之所以用 initialValue,而不是 defaultValue 是为了保持跟 props.onInitial 的逻辑一致
153-
if (value === undefined && isInitialValueNotEmpty(initialValue)) {
148+
if (!this.state?.fromOnChange && value === undefined && isInitialValueNotEmpty(initialValue)) {
154149
const _initialValue = typeof initialValue === 'function' ? initialValue(field.internalToShellPropEntry()) : initialValue;
155150
field.setValue(_initialValue);
151+
value = _initialValue;
156152
}
157153

158154
let _onChange = extraProps?.onChange;
@@ -183,8 +179,10 @@ class SettingFieldView extends Component<{ field: SettingField }> {
183179
field: field.internalToShellPropEntry(),
184180
// === IO
185181
value, // reaction point
182+
initialValue,
186183
onChange: (value: any) => {
187184
this.setState({
185+
fromOnChange: true,
188186
// eslint-disable-next-line react/no-unused-state
189187
value,
190188
});

packages/shell/src/setting-prop-entry.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ export default class SettingPropEntry {
124124
this[settingPropEntrySymbol].setPropValue(propName, value);
125125
}
126126

127+
/**
128+
* 清空指定属性值
129+
* @param propName
130+
*/
131+
clearPropValue(propName: string | number) {
132+
this[settingPropEntrySymbol].clearPropValue(propName);
133+
}
134+
127135
/**
128136
* 获取配置的默认值
129137
* @returns

0 commit comments

Comments
 (0)