mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-12 17:08:14 +00:00
chore: engine-ext / engine-core / vision-polyfill 工程化统一
feat: 增加设置 i18n 的方式 chore: ignitor devServer useLocalIp
This commit is contained in:
parent
9eb31c4c9d
commit
7ec3bf335d
@ -144,6 +144,10 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
return this.get('device') || 'default';
|
||||
}
|
||||
|
||||
@computed get locale(): string {
|
||||
return this.get('locale') || '';
|
||||
}
|
||||
|
||||
@computed get deviceClassName(): string | undefined {
|
||||
return this.get('deviceClassName');
|
||||
}
|
||||
|
||||
@ -14,20 +14,20 @@
|
||||
"rax": "var window.Rax",
|
||||
"monaco-editor/esm/vs/editor/editor.api": "var window.monaco",
|
||||
"monaco-editor/esm/vs/editor/editor.main.js": "var window.monaco",
|
||||
"@alifd/next": "var Next",
|
||||
"@ali/lowcode-engine-ext": "var window.AliLowCodeEngineExt",
|
||||
"moment": "var moment",
|
||||
"lodash": "var _"
|
||||
},
|
||||
"browserslist": {
|
||||
"chrome": 80
|
||||
},
|
||||
"polyfill": false,
|
||||
"outputDir": "dist",
|
||||
"vendor": false,
|
||||
"ignoreHtmlTemplate": true,
|
||||
"sourceMap": true,
|
||||
"plugins": [
|
||||
"build-plugin-react-app",
|
||||
"build-plugin-fusion",
|
||||
["build-plugin-fusion", {
|
||||
}],
|
||||
["build-plugin-moment-locales", {
|
||||
"locales": ["zh-cn"]
|
||||
}],
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
"start": "build-scripts start",
|
||||
"version:update": "node ./scripts/version.js",
|
||||
"build": "build-scripts build --skip-demo",
|
||||
"cloud-build": "build-scripts build --config build.cloud.json",
|
||||
"cloud-build": "build-scripts build --config build.cloud.json && tnpm run version:update",
|
||||
"test": "build-scripts test --config build.test.json"
|
||||
},
|
||||
"license": "MIT",
|
||||
|
||||
@ -9,7 +9,7 @@ const reBranchVersion = /^(?:[a-z]+\/)(\d+\.\d+\.\d+)$/im;
|
||||
|
||||
const match = reBranchVersion.exec(gitBranchName);
|
||||
if (!match) {
|
||||
console.warn(`[checkversion] gitBranchName: ${gitBranchName}`);
|
||||
console.warn(`[engine] gitBranchName: ${gitBranchName}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -17,13 +17,18 @@ const releaseVersion = match[1];
|
||||
|
||||
const distDir = join(__dirname, '../dist');
|
||||
|
||||
const distFile = join(distDir, 'engine.js');
|
||||
const distFileNames = ['engine.js', 'engine-core.js'];
|
||||
|
||||
if (!fse.existsSync(distFile)) {
|
||||
console.warn('dist dir doesn\'t exists');
|
||||
return;
|
||||
}
|
||||
distFileNames.forEach(name => {
|
||||
const distFile = join(distDir, 'js', name);
|
||||
if (!fse.existsSync(distFile)) {
|
||||
console.warn(`[engine] distFile: ${distFile} doesn\'t exist`);
|
||||
return;
|
||||
}
|
||||
|
||||
const indexContent = fse.readFileSync(distFile, 'utf-8');
|
||||
const indexContent = fse.readFileSync(distFile, 'utf-8');
|
||||
|
||||
fse.writeFileSync(distFile, indexContent.replace('{{VERSION_PLACEHOLDER}}', releaseVersion));
|
||||
fse.writeFileSync(distFile, indexContent.replace('{{VERSION_PLACEHOLDER}}', releaseVersion));
|
||||
});
|
||||
|
||||
console.log('[engine] update engine version successfully!');
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
},
|
||||
"vendor": false,
|
||||
"devServer": {
|
||||
"useLocalIp": true,
|
||||
"hot": false
|
||||
},
|
||||
"publicPath": "/",
|
||||
|
||||
@ -14,6 +14,7 @@ interface DesignerPluginState {
|
||||
extraEnvironment?: any[] | null;
|
||||
renderEnv?: string;
|
||||
device?: string;
|
||||
locale?: string;
|
||||
designMode?: string;
|
||||
deviceClassName?: string;
|
||||
simulatorUrl: Asset | null;
|
||||
@ -30,6 +31,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
||||
extraEnvironment: null,
|
||||
renderEnv: 'default',
|
||||
device: 'default',
|
||||
locale: '',
|
||||
designMode: 'live',
|
||||
deviceClassName: '',
|
||||
simulatorUrl: null,
|
||||
@ -49,6 +51,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
||||
const assets = await editor.onceGot('assets');
|
||||
const renderEnv = await editor.get('renderEnv');
|
||||
const device = await editor.get('device');
|
||||
const locale = await editor.get('locale');
|
||||
const designMode = await editor.get('designMode');
|
||||
const deviceClassName = await editor.get('deviceClassName');
|
||||
const simulatorUrl = await editor.get('simulatorUrl');
|
||||
@ -68,6 +71,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
||||
deviceClassName,
|
||||
simulatorUrl,
|
||||
requestHandlersMap,
|
||||
locale,
|
||||
};
|
||||
this.setState(state);
|
||||
} catch (e) {
|
||||
@ -100,6 +104,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
||||
deviceClassName,
|
||||
simulatorUrl,
|
||||
requestHandlersMap,
|
||||
locale,
|
||||
} = this.state;
|
||||
|
||||
if (!library || !componentMetadatas) {
|
||||
@ -119,6 +124,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
||||
extraEnvironment,
|
||||
renderEnv,
|
||||
device,
|
||||
locale,
|
||||
designMode,
|
||||
deviceClassName,
|
||||
simulatorUrl,
|
||||
|
||||
@ -138,9 +138,8 @@ class Renderer extends Component<{
|
||||
render() {
|
||||
const { documentInstance, rendererContainer: renderer } = this.props;
|
||||
const { container } = documentInstance;
|
||||
const { designMode, device } = container;
|
||||
const { designMode, device, locale } = container;
|
||||
const messages = container.context?.utils?.i18n?.messages || {};
|
||||
const locale = container.context?.utils?.i18n?.currentLocale || Object.keys(messages)[0] || DEFAULT_SIMULATOR_LOCALE;
|
||||
|
||||
return (
|
||||
<LowCodeRenderer
|
||||
|
||||
@ -212,6 +212,8 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
||||
// sync designMode
|
||||
this._designMode = host.designMode;
|
||||
|
||||
this._locale = host.locale;
|
||||
|
||||
// sync requestHandlersMap
|
||||
this._requestHandlersMap = host.requestHandlersMap;
|
||||
|
||||
@ -269,13 +271,10 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
||||
},
|
||||
i18n: {
|
||||
setLocale: (loc: string) => {
|
||||
const newCtx = {
|
||||
...this._appContext,
|
||||
};
|
||||
newCtx.utils.i18n.currentLocale = loc;
|
||||
this._appContext = newCtx;
|
||||
this._appContext.utils.i18n.currentLocale = loc;
|
||||
this._locale = loc;
|
||||
},
|
||||
currentLocale: undefined,
|
||||
currentLocale: this.locale,
|
||||
messages: {},
|
||||
},
|
||||
},
|
||||
@ -321,7 +320,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
||||
return this._components;
|
||||
}
|
||||
// context from: utils、constants、history、location、match
|
||||
@obx.ref private _appContext = {};
|
||||
@obx.ref private _appContext: any = {};
|
||||
@computed get context(): any {
|
||||
return this._appContext;
|
||||
}
|
||||
@ -333,6 +332,10 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
||||
@computed get device() {
|
||||
return this._device;
|
||||
}
|
||||
@obx.ref private _locale: string = '';
|
||||
@computed get locale() {
|
||||
return this._locale;
|
||||
}
|
||||
@obx.ref private _componentsMap = {};
|
||||
@computed get componentsMap(): any {
|
||||
return this._componentsMap;
|
||||
|
||||
@ -15,19 +15,19 @@
|
||||
"monaco-editor/esm/vs/editor/editor.main.js": "var window.monaco",
|
||||
"@ali/lowcode-engine": "var window.AliLowCodeEngine",
|
||||
"@ali/lowcode-engine-ext": "var window.AliLowCodeEngineExt",
|
||||
"@alifd/next": "var Next",
|
||||
"moment": "var moment",
|
||||
"lodash": "var _"
|
||||
},
|
||||
"browserslist": {
|
||||
"chrome": 80
|
||||
},
|
||||
"polyfill": false,
|
||||
"outputDir": "dist",
|
||||
"vendor": false,
|
||||
"ignoreHtmlTemplate": true,
|
||||
"sourceMap": true,
|
||||
"plugins": [
|
||||
"build-plugin-react-app",
|
||||
"build-plugin-fusion",
|
||||
["build-plugin-fusion", {
|
||||
}],
|
||||
["build-plugin-moment-locales", {
|
||||
"locales": ["zh-cn"]
|
||||
}],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user