mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-04-12 21:50:23 +08:00
Merge pull request #408 from webzard-io/fix/windlike-patch
Fix/windlike patch
This commit is contained in:
commit
533ab4723e
@ -134,10 +134,9 @@ export const Editor: React.FC<Props> = observer(
|
||||
}, [activeDataSource, services, activeDataSourceType]);
|
||||
|
||||
const onRefresh = useCallback(() => {
|
||||
services.stateManager.clear();
|
||||
setIsDisplayApp(false);
|
||||
onRefreshApp();
|
||||
}, [services.stateManager, onRefreshApp]);
|
||||
}, [onRefreshApp]);
|
||||
useEffect(() => {
|
||||
// Wait until the app is completely unmounted before remounting it
|
||||
if (isDisplayApp === false) {
|
||||
|
@ -99,7 +99,15 @@ export function initSunmaoUIEditor(props: SunmaoUIEditorProps = {}) {
|
||||
const Editor: React.FC = () => {
|
||||
const [store, setStore] = useState(stateManager.store);
|
||||
const onRefresh = useCallback(() => {
|
||||
// need to reregister all the traits to clear the trait states which like `HasInitializedMap`
|
||||
const traits = registry.getAllTraits();
|
||||
|
||||
stateManager.clear();
|
||||
setStore(stateManager.store);
|
||||
registry.unregisterAllTraits();
|
||||
traits.forEach(trait => {
|
||||
registry.registerTrait(trait);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
@ -24,7 +24,7 @@ export const ImplWrapperMain = React.forwardRef<HTMLDivElement, ImplWrapperProps
|
||||
|
||||
const [traitResults, setTraitResults] = useState<TraitResult<string, string>[]>(
|
||||
() => {
|
||||
return c.traits.map(t => executeTrait(t, stateManager.deepEval(t.properties)));
|
||||
return c.traits.map(t => executeTrait(t, stateManager.deepEval(t.properties, { fallbackWhenError: () => undefined })));
|
||||
}
|
||||
);
|
||||
|
||||
@ -49,7 +49,8 @@ export const ImplWrapperMain = React.forwardRef<HTMLDivElement, ImplWrapperProps
|
||||
newResults[i] = traitResult;
|
||||
return newResults;
|
||||
});
|
||||
}
|
||||
},
|
||||
{ fallbackWhenError: () => undefined }
|
||||
);
|
||||
stops.push(stop);
|
||||
properties.push(result);
|
||||
|
@ -176,6 +176,10 @@ export class Registry {
|
||||
this.modules = new Map<string, Map<string, ImplementedRuntimeModule>>();
|
||||
}
|
||||
|
||||
unregisterAllTraits() {
|
||||
this.traits = new Map<string, Map<string, ImplementedRuntimeTrait>>();
|
||||
}
|
||||
|
||||
registerUtilMethod<T>(m: UtilMethod<T>) {
|
||||
if (this.utilMethods.get(m.name)) {
|
||||
throw new Error(`Already has utilMethod ${m.name} in this registry.`);
|
||||
|
@ -29,7 +29,7 @@ export type ImplementedRuntimeTraitFactory = RuntimeTrait & {
|
||||
factory: TraitImplFactory;
|
||||
};
|
||||
|
||||
export type ImplementedRuntimeTrait = RuntimeTrait & {
|
||||
export type ImplementedRuntimeTrait = ImplementedRuntimeTraitFactory & {
|
||||
impl: TraitImpl;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user