mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-15 10:48:17 +00:00
refactor: 修改语言切换处理方式
This commit is contained in:
parent
f0cb1cd8ea
commit
a11585a543
@ -96,7 +96,6 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
this.initOnPropsChangeEvent();
|
this.initOnPropsChangeEvent();
|
||||||
this.initOnChildrenChangeEvent();
|
this.initOnChildrenChangeEvent();
|
||||||
this.initOnVisibleChangeEvent();
|
this.initOnVisibleChangeEvent();
|
||||||
this.initLangChangeEvent();
|
|
||||||
this.state = {
|
this.state = {
|
||||||
nodeChildren: null,
|
nodeChildren: null,
|
||||||
childrenInState: false,
|
childrenInState: false,
|
||||||
@ -189,26 +188,6 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
dispose && this.disposeFunctions.push(dispose);
|
dispose && this.disposeFunctions.push(dispose);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 监听语言切换
|
|
||||||
*/
|
|
||||||
initLangChangeEvent() {
|
|
||||||
if (this.leaf?.componentName !== 'Page') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const dispose = (window as any).VisualEngine.Env.onEnvChange(() => {
|
|
||||||
this.beforeRender(RerenderType.LangChanged);
|
|
||||||
const nextProps = getProps(this.leaf?.export?.(TransformStage.Render) as types.ISchema, Comp, this.componentInfo);
|
|
||||||
const nextChildren = getChildren(this.leaf?.export?.(TransformStage.Render) as types.ISchema, Comp);
|
|
||||||
this.setState({
|
|
||||||
nodeChildren: nextChildren,
|
|
||||||
nodeProps: nextProps,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
dispose && this.disposeFunctions.push(dispose);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.disposeFunctions.forEach(fn => fn());
|
this.disposeFunctions.forEach(fn => fn());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import logger from '@ali/vu-logger';
|
import logger from '@ali/vu-logger';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { editor } from '@ali/lowcode-engine';
|
import { editor, designer } from '@ali/lowcode-engine';
|
||||||
import { GlobalEvent, isJSExpression } from '@ali/lowcode-types';
|
import { GlobalEvent, isJSExpression } from '@ali/lowcode-types';
|
||||||
|
import env from './env';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bus class as an EventEmitter
|
* Bus class as an EventEmitter
|
||||||
@ -77,6 +78,13 @@ editor?.on('history.forward', (data) => {
|
|||||||
bus.emit('ve.history.forward', data);
|
bus.emit('ve.history.forward', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
env.onEnvChange((_envs, name, value) => {
|
||||||
|
if (name !== 'locale') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
designer.project.simulator?.set(name, value.replace('_', '-'));
|
||||||
|
});
|
||||||
|
|
||||||
function triggerUseVariableChange(data: any) {
|
function triggerUseVariableChange(data: any) {
|
||||||
const { node, prop, oldValue, newValue } = data;
|
const { node, prop, oldValue, newValue } = data;
|
||||||
const propConfig = node.componentMeta.prototype?.options.configure.find((o: any) => o.name === prop.getKey());
|
const propConfig = node.componentMeta.prototype?.options.configure.find((o: any) => o.name === prop.getKey());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user