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