Compare commits

...

4 Commits

Author SHA1 Message Date
LeoYuan 袁力皓
f197355f19 chore(release): code-generator - 1.0.7-beta.4 2022-12-16 14:13:54 +08:00
LeoYuan 袁力皓
f93e17c530 chore: update UT snapshots of CodeGenerator 2022-12-14 15:32:06 +08:00
eternalsky
b4ffa02314 feat(codegen): add demo slots & add new cli option solutionOptions 2022-12-14 14:07:53 +08:00
LeoYuan 袁力皓
1a453e2d21 feat: support UIPaaS-Component code generator solution 2022-12-13 11:36:44 +08:00
122 changed files with 1143 additions and 1125 deletions

View File

@ -14,6 +14,7 @@ program
.option('-c, --cwd <cwd>', 'specify the working directory', '.') .option('-c, --cwd <cwd>', 'specify the working directory', '.')
.option('-q, --quiet', 'be quiet, do not output anything unless get error', false) .option('-q, --quiet', 'be quiet, do not output anything unless get error', false)
.option('-v, --verbose', 'be verbose, output more information', false) .option('-v, --verbose', 'be verbose, output more information', false)
.option('--solution-options <options>', 'specify the solution options', '{}')
.arguments('[input-schema] ali lowcode schema JSON file') .arguments('[input-schema] ali lowcode schema JSON file')
.action(function doGenerate(inputSchema, command) { .action(function doGenerate(inputSchema, command) {
var options = command.opts(); var options = command.opts();

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-code-generator", "name": "@alilc/lowcode-code-generator",
"version": "1.0.7-beta.3", "version": "1.0.7-beta.4",
"description": "出码引擎 for LowCode Engine", "description": "出码引擎 for LowCode Engine",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",

View File

@ -25,6 +25,7 @@ export async function run(
output?: string; output?: string;
quiet?: boolean; quiet?: boolean;
verbose?: boolean; verbose?: boolean;
solutionOptions?: string;
}, },
): Promise<number> { ): Promise<number> {
try { try {
@ -41,6 +42,19 @@ export async function run(
); );
} }
let solutionOptions = {};
if (options.solutionOptions) {
try {
solutionOptions = JSON.parse(options.solutionOptions);
} catch (err: any) {
throw new Error(
`solution options parse error, error message is "${err.message}"`,
);
}
}
// 读取 Schema // 读取 Schema
const schema = await loadSchemaFile(schemaFile); const schema = await loadSchemaFile(schemaFile);
@ -48,7 +62,7 @@ export async function run(
const createProjectBuilder = await getProjectBuilderFactory(options.solution, { const createProjectBuilder = await getProjectBuilderFactory(options.solution, {
quiet: options.quiet, quiet: options.quiet,
}); });
const builder = createProjectBuilder(); const builder = createProjectBuilder(solutionOptions);
// 生成代码 // 生成代码
const generatedSourceCodes = await builder.generateProject(schema); const generatedSourceCodes = await builder.generateProject(schema);
@ -75,7 +89,7 @@ export async function run(
async function getProjectBuilderFactory( async function getProjectBuilderFactory(
solution: string, solution: string,
{ quiet }: { quiet?: boolean }, { quiet }: { quiet?: boolean },
): Promise<() => IProjectBuilder> { ): Promise<(options: {[prop: string]: any}) => IProjectBuilder> {
if (solution in CodeGenerator.solutions) { if (solution in CodeGenerator.solutions) {
return CodeGenerator.solutions[solution as 'icejs' | 'rax']; return CodeGenerator.solutions[solution as 'icejs' | 'rax'];
} }

View File

@ -559,8 +559,8 @@ codealike.json
"registry": "https://registry.npm.xxx.com" "registry": "https://registry.npm.xxx.com"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-code-generator": "^1.0.0-beta.16", "@alilc/lowcode-code-generator": "^1.0.0",
"@alilc/lowcode-types": "^1.0.0-beta.21", "@alilc/lowcode-types": "^1.0.0",
"tslib": "^2.3.0" "tslib": "^2.3.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -62,10 +62,10 @@ export class ProjectBuilder implements IProjectBuilder {
private projectPostProcessors: ProjectPostProcessor[]; private projectPostProcessors: ProjectPostProcessor[];
/** 是否处于严格模式 */ /** 是否处于严格模式 */
public readonly inStrictMode: boolean; readonly inStrictMode: boolean;
/** 一些额外的上下文数据 */ /** 一些额外的上下文数据 */
public readonly extraContextData: IContextData; readonly extraContextData: IContextData;
constructor({ constructor({
template, template,
@ -241,6 +241,15 @@ export class ProjectBuilder implements IProjectBuilder {
}); });
} }
// demo
if (parseResult.project && builders.demo) {
const { files } = await builders.demo.generateModule(parseResult.project);
buildResult.push({
path: this.template.slots.demo.path,
files,
});
}
// TODO: 更多 slots 的处理??是不是可以考虑把 template 中所有的 slots 都处理下? // TODO: 更多 slots 的处理??是不是可以考虑把 template 中所有的 slots 都处理下?
// Post Process // Post Process
@ -260,7 +269,10 @@ export class ProjectBuilder implements IProjectBuilder {
let finalResult = projectRoot; let finalResult = projectRoot;
for (const projectPostProcessor of this.projectPostProcessors) { for (const projectPostProcessor of this.projectPostProcessors) {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
finalResult = await projectPostProcessor(finalResult, schema, originalSchema); finalResult = await projectPostProcessor(finalResult, schema, originalSchema, {
template: this.template,
parseResult,
});
} }
return finalResult; return finalResult;

View File

@ -32,7 +32,7 @@ import {
import { SUPPORT_SCHEMA_VERSION_LIST } from '../const'; import { SUPPORT_SCHEMA_VERSION_LIST } from '../const';
import { getErrorMessage } from '../utils/errors'; import { getErrorMessage } from '../utils/errors';
import { handleSubNodes } from '../utils/schema'; import { handleSubNodes, isValidContainerType } from '../utils/schema';
import { uniqueArray } from '../utils/common'; import { uniqueArray } from '../utils/common';
import { componentAnalyzer } from '../analyzer/componentAnalyzer'; import { componentAnalyzer } from '../analyzer/componentAnalyzer';
import { ensureValidClassName } from '../utils/validate'; import { ensureValidClassName } from '../utils/validate';
@ -141,7 +141,7 @@ export class SchemaParser implements ISchemaParser {
if (schema.componentsTree.length > 0) { if (schema.componentsTree.length > 0) {
const firstRoot: ContainerSchema = schema.componentsTree[0] as ContainerSchema; const firstRoot: ContainerSchema = schema.componentsTree[0] as ContainerSchema;
if (!('fileName' in firstRoot) || !firstRoot.fileName) { if (!firstRoot.fileName && !isValidContainerType(firstRoot)) {
// 整个 schema 描述一个容器,且无根节点定义 // 整个 schema 描述一个容器,且无根节点定义
const container: IContainerInfo = { const container: IContainerInfo = {
...firstRoot, ...firstRoot,
@ -259,8 +259,7 @@ export class SchemaParser implements ISchemaParser {
utils = schema.utils; utils = schema.utils;
utilsDeps = schema.utils utilsDeps = schema.utils
.filter( .filter(
(u): u is { name: string; type: 'npm' | 'tnpm'; content: NpmInfo } => (u): u is { name: string; type: 'npm' | 'tnpm'; content: NpmInfo } => u.type !== 'function',
u.type !== 'function',
) )
.map( .map(
(u): IExternalDependency => ({ (u): IExternalDependency => ({

View File

@ -9,7 +9,7 @@ const PARSERS = ['css', 'scss', 'less', 'json', 'html', 'vue'];
export interface ProcessorConfig { export interface ProcessorConfig {
customFileTypeParser: Record<string, string>; customFileTypeParser: Record<string, string>;
plugins?: Array<prettier.Plugin>; plugins?: prettier.Plugin[];
} }
const factory: PostProcessorFactory<ProcessorConfig> = (config?: ProcessorConfig) => { const factory: PostProcessorFactory<ProcessorConfig> = (config?: ProcessorConfig) => {
@ -33,6 +33,8 @@ const factory: PostProcessorFactory<ProcessorConfig> = (config?: ProcessorConfig
return prettier.format(content, { return prettier.format(content, {
parser, parser,
plugins: [parserBabel, parserPostCss, parserHtml, ...(cfg.plugins || [])], plugins: [parserBabel, parserPostCss, parserHtml, ...(cfg.plugins || [])],
singleQuote: true,
jsxSingleQuote: false,
}); });
}; };

View File

@ -25,6 +25,7 @@ export enum FileType {
TS = 'ts', TS = 'ts',
TSX = 'tsx', TSX = 'tsx',
JSON = 'json', JSON = 'json',
MD = 'md',
} }
export enum ChunkType { export enum ChunkType {
@ -170,11 +171,17 @@ export interface IProjectBuilder {
/** 项目级别的前置处理器 */ /** 项目级别的前置处理器 */
export type ProjectPreProcessor = (schema: ProjectSchema) => Promise<ProjectSchema> | ProjectSchema; export type ProjectPreProcessor = (schema: ProjectSchema) => Promise<ProjectSchema> | ProjectSchema;
export interface ProjectPostProcessorOptions {
parseResult?: IParseResult;
template?: IProjectTemplate;
}
/** 项目级别的后置处理器 */ /** 项目级别的后置处理器 */
export type ProjectPostProcessor = ( export type ProjectPostProcessor = (
result: ResultDir, result: ResultDir,
schema: ProjectSchema, schema: ProjectSchema,
originalSchema: ProjectSchema | string, originalSchema: ProjectSchema | string,
options: ProjectPostProcessorOptions,
) => Promise<ResultDir> | ResultDir; ) => Promise<ResultDir> | ResultDir;
/** 模块级别的后置处理器的工厂方法 */ /** 模块级别的后置处理器的工厂方法 */

View File

@ -1,7 +1,7 @@
import changeCase from 'change-case'; import changeCase from 'change-case';
import type { IProjectInfo } from '../types/intermediate'; import type { IProjectInfo } from '../types/intermediate';
export type DataSourceDependenciesConfig = { export interface DataSourceDependenciesConfig {
/** 数据源引擎的版本 */ /** 数据源引擎的版本 */
engineVersion?: string; engineVersion?: string;
/** 数据源引擎的包名 */ /** 数据源引擎的包名 */
@ -14,7 +14,7 @@ export type DataSourceDependenciesConfig = {
handlersPackages?: { handlersPackages?: {
[key: string]: string; [key: string]: string;
}; };
}; }
export function buildDataSourceDependencies( export function buildDataSourceDependencies(
ir: IProjectInfo, ir: IProjectInfo,
@ -22,13 +22,13 @@ export function buildDataSourceDependencies(
): Record<string, string> { ): Record<string, string> {
return { return {
// 数据源引擎的依赖包 // 数据源引擎的依赖包
[cfg.enginePackage || '@alilc/lowcode-datasource-engine']: cfg.engineVersion || 'latest', [cfg.enginePackage || '@alilc/lowcode-datasource-engine']: cfg.engineVersion || '^1.0.0',
// 各种数据源的 handlers 的依赖包 // 各种数据源的 handlers 的依赖包
...(ir.dataSourcesTypes || []).reduce( ...(ir.dataSourcesTypes || []).reduce(
(acc, dsType) => ({ (acc, dsType) => ({
...acc, ...acc,
[getDataSourceHandlerPackageName(dsType)]: cfg.handlersVersion?.[dsType] || 'latest', [getDataSourceHandlerPackageName(dsType)]: cfg.handlersVersion?.[dsType] || '^1.0.0',
}), }),
{}, {},
), ),

View File

@ -11,6 +11,7 @@ import * as schema from './schema';
import * as version from './version'; import * as version from './version';
import * as scope from './Scope'; import * as scope from './Scope';
import * as expressionParser from './expressionParser'; import * as expressionParser from './expressionParser';
import * as dataSource from './dataSource';
export { export {
common, common,
@ -25,4 +26,5 @@ export {
version, version,
scope, scope,
expressionParser, expressionParser,
dataSource,
}; };

View File

@ -182,7 +182,7 @@ function generateSimpleNode(
function linkPieces(pieces: CodePiece[]): string { function linkPieces(pieces: CodePiece[]): string {
const tagsPieces = pieces.filter((p) => p.type === PIECE_TYPE.TAG); const tagsPieces = pieces.filter((p) => p.type === PIECE_TYPE.TAG);
if (tagsPieces.length !== 1) { if (tagsPieces.length !== 1) {
throw new CodeGeneratorError('One node only need one tag define'); throw new CodeGeneratorError('Only one tag definition required', tagsPieces);
} }
const tagName = tagsPieces[0].value; const tagName = tagsPieces[0].value;
@ -270,8 +270,7 @@ export function generateReactLoopCtrl(
const loopDataExpr = pipe( const loopDataExpr = pipe(
nodeItem.loop, nodeItem.loop,
// 将 JSExpression 转换为 JS 表达式代码: // 将 JSExpression 转换为 JS 表达式代码:
(expr) => (expr) => generateCompositeType(expr, scope, {
generateCompositeType(expr, scope, {
handlers: config?.handlers, handlers: config?.handlers,
tolerateEvalErrors: false, // 这个内部不需要包 try catch, 下面会统一加的 tolerateEvalErrors: false, // 这个内部不需要包 try catch, 下面会统一加的
}), }),
@ -391,8 +390,7 @@ export function createNodeGenerator(cfg: NodeGeneratorConfig = {}): NodeGenerato
return `{${valueStr}}`; return `{${valueStr}}`;
}; };
return (nodeItem: NodeDataType, scope: IScope) => return (nodeItem: NodeDataType, scope: IScope) => unwrapJsExprQuoteInJsx(generateNode(nodeItem, scope));
unwrapJsExprQuoteInJsx(generateNode(nodeItem, scope));
} }
const defaultReactGeneratorConfig: NodeGeneratorConfig = { const defaultReactGeneratorConfig: NodeGeneratorConfig = {

View File

@ -138,3 +138,11 @@ export function handleSubNodes<T>(
return []; return [];
} }
} }
export function isValidContainerType(schema: NodeSchema) {
return [
'Page',
'Component',
'Block',
].includes(schema.componentName);
}

View File

@ -19,7 +19,7 @@ describe(testCaseBaseName, () => {
` `
<Greetings <Greetings
content={this._i18nText({ content={this._i18nText({
key: "greetings.hello", key: 'greetings.hello',
params: { name: this.state.name }, params: { name: this.state.name },
})} })}
/> />

View File

@ -27,7 +27,7 @@ describe(testCaseBaseName, () => {
}); });
const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx'); const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx');
expect(generatedPageFileContent).toContain(`import Foo from "example-package/lib/index.js";`); expect(generatedPageFileContent).toContain('import Foo from \'example-package/lib/index.js\';');
}); });
test('named import with no alias', async () => { test('named import with no alias', async () => {
@ -47,7 +47,7 @@ describe(testCaseBaseName, () => {
const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx'); const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx');
expect(generatedPageFileContent).toContain( expect(generatedPageFileContent).toContain(
`import { Foo } from "example-package/lib/index.js";`, 'import { Foo } from \'example-package/lib/index.js\';',
); );
}); });
@ -68,7 +68,7 @@ describe(testCaseBaseName, () => {
const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx'); const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx');
expect(generatedPageFileContent).toContain( expect(generatedPageFileContent).toContain(
`import { Bar as Foo } from "example-package/lib/index.js";`, 'import { Bar as Foo } from \'example-package/lib/index.js\';',
); );
}); });
@ -88,7 +88,7 @@ describe(testCaseBaseName, () => {
}); });
const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx'); const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx');
expect(generatedPageFileContent).toContain(`import Foo from "example-package/lib/index.js";`); expect(generatedPageFileContent).toContain('import Foo from \'example-package/lib/index.js\';');
}); });
test('default import with sub name and export name', async () => { test('default import with sub name and export name', async () => {
@ -107,9 +107,9 @@ describe(testCaseBaseName, () => {
}); });
const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx'); const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx');
expect(generatedPageFileContent).toContain(`import Bar from "example-package/lib/index.js";`); expect(generatedPageFileContent).toContain('import Bar from \'example-package/lib/index.js\';');
expect(generatedPageFileContent).toContain(`const Foo = Bar.Baz;`); expect(generatedPageFileContent).toContain('const Foo = Bar.Baz;');
}); });
test('default import with sub name without export name', async () => { test('default import with sub name without export name', async () => {
@ -129,10 +129,10 @@ describe(testCaseBaseName, () => {
const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx'); const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx');
expect(generatedPageFileContent).toContain( expect(generatedPageFileContent).toContain(
`import __$examplePackage_default from "example-package/lib/index.js";`, 'import __$examplePackage_default from \'example-package/lib/index.js\';',
); );
expect(generatedPageFileContent).toContain(`const Foo = __$examplePackage_default.Baz;`); expect(generatedPageFileContent).toContain('const Foo = __$examplePackage_default.Baz;');
}); });
test('named import with sub name', async () => { test('named import with sub name', async () => {
@ -152,10 +152,10 @@ describe(testCaseBaseName, () => {
const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx'); const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx');
expect(generatedPageFileContent).toContain( expect(generatedPageFileContent).toContain(
`import { Bar } from "example-package/lib/index.js";`, 'import { Bar } from \'example-package/lib/index.js\';',
); );
expect(generatedPageFileContent).toContain(`const Foo = Bar.Baz;`); expect(generatedPageFileContent).toContain('const Foo = Bar.Baz;');
}); });
test('default imports with different componentName', async () => { test('default imports with different componentName', async () => {
@ -187,11 +187,11 @@ describe(testCaseBaseName, () => {
}); });
const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx'); const generatedPageFileContent = readOutputTextFile('demo-project/src/pages/Test/index.jsx');
expect(generatedPageFileContent).toContain(`import Foo from "example-package";`); expect(generatedPageFileContent).toContain('import Foo from \'example-package\';');
expect(generatedPageFileContent).toContain(`import Baz from "example-package";`); expect(generatedPageFileContent).toContain('import Baz from \'example-package\';');
expect(generatedPageFileContent).not.toContain(`const Foo =`); expect(generatedPageFileContent).not.toContain('const Foo =');
expect(generatedPageFileContent).not.toContain(`const Baz =`); expect(generatedPageFileContent).not.toContain('const Baz =');
}); });
}); });

View File

@ -22,7 +22,7 @@ test(testCaseBaseName, async () => {
Button, Button,
Typography, Typography,
Tag, Tag,
} from "@alilc/antd-lowcode-materials/dist/antd-lowcode.esm.js";`); } from '@alilc/antd-lowcode-materials/dist/antd-lowcode.esm.js';`);
}); });
function exportProject(inputPath: string, outputPath: string) { function exportProject(inputPath: string, outputPath: string) {

View File

@ -19,15 +19,15 @@ test(testCaseBaseName, async () => {
// 里面有的数据源则应该生成对应的 dependencies // 里面有的数据源则应该生成对应的 dependencies
expect(generatedPackageJson.dependencies).toMatchObject({ expect(generatedPackageJson.dependencies).toMatchObject({
'@alilc/lowcode-datasource-engine': 'latest', '@alilc/lowcode-datasource-engine': '^1.0.0',
'@alilc/lowcode-datasource-fetch-handler': 'latest', '@alilc/lowcode-datasource-fetch-handler': '^1.0.0',
}); });
// 里面没有的,则不应该生成对应的 dependencies // 里面没有的,则不应该生成对应的 dependencies
expect(generatedPackageJson.dependencies).not.toMatchObject({ expect(generatedPackageJson.dependencies).not.toMatchObject({
'@alilc/lowcode-datasource-url-params-handler': 'latest', '@alilc/lowcode-datasource-url-params-handler': '^1.0.0',
'@alilc/lowcode-datasource-mtop-handler': 'latest', '@alilc/lowcode-datasource-mtop-handler': '^1.0.0',
'@alilc/lowcode-datasource-mopen-handler': 'latest', '@alilc/lowcode-datasource-mopen-handler': '^1.0.0',
}); });
}); });

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,9 +11,9 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-url-params-handler": "latest", "@alilc/lowcode-datasource-url-params-handler": "^1.0.0",
"@alilc/lowcode-datasource-fetch-handler": "latest", "@alilc/lowcode-datasource-fetch-handler": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -253,6 +253,7 @@ class Home$$Page extends Component {
if (!response.success) { if (!response.success) {
throw new Error(response.message); throw new Error(response.message);
} }
return response.data; return response.data;
}, },
isInit: true, isInit: true,
@ -279,6 +280,7 @@ class Home$$Page extends Component {
if (!response.success) { if (!response.success) {
throw new Error(response.message); throw new Error(response.message);
} }
return response.data.result; return response.data.result;
}, },
isInit: true, isInit: true,

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,8 +11,8 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-url-params-handler": "latest", "@alilc/lowcode-datasource-url-params-handler": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,7 +11,7 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,8 +11,8 @@
"lint": "npm run eslint && npm run stylelint" "lint": "npm run eslint && npm run stylelint"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-http-handler": "latest", "@alilc/lowcode-datasource-http-handler": "^1.0.0",
"universal-env": "^3.2.0", "universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"rax": "^1.1.0", "rax": "^1.1.0",

View File

@ -11,9 +11,9 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-url-params-handler": "latest", "@alilc/lowcode-datasource-url-params-handler": "^1.0.0",
"@alilc/lowcode-datasource-fetch-handler": "latest", "@alilc/lowcode-datasource-fetch-handler": "^1.0.0",
"@alifd/next": "1.19.18" "@alifd/next": "1.19.18"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,3 +1,3 @@
const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; const __$$constants = { ENV: 'prod', DOMAIN: 'xxx.xxx.com' };
export default __$$constants; export default __$$constants;

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,9 +1,9 @@
const i18nConfig = {}; const i18nConfig = {};
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -13,22 +13,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -49,7 +49,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -61,7 +61,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,22 +1,22 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import { Form, Input, NumberPicker, Select, Button } from "@alifd/next"; import { Form, Input, NumberPicker, Select, Button } from '@alifd/next';
import { createUrlParamsHandler as __$$createUrlParamsRequestHandler } from "@alilc/lowcode-datasource-url-params-handler"; import { createUrlParamsHandler as __$$createUrlParamsRequestHandler } from '@alilc/lowcode-datasource-url-params-handler';
import { createFetchHandler as __$$createFetchRequestHandler } from "@alilc/lowcode-datasource-fetch-handler"; import { createFetchHandler as __$$createFetchRequestHandler } from '@alilc/lowcode-datasource-fetch-handler';
import { create as __$$createDataSourceEngine } from "@alilc/lowcode-datasource-engine/runtime"; import { create as __$$createDataSourceEngine } from '@alilc/lowcode-datasource-engine/runtime';
import utils, { RefsManager } from "../../utils"; import utils, { RefsManager } from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
class Test$$Page extends React.Component { class Test$$Page extends React.Component {
_context = this; _context = this;
@ -51,7 +51,7 @@ class Test$$Page extends React.Component {
__$$i18n._inject2(this); __$$i18n._inject2(this);
this.state = { text: "outter" }; this.state = { text: 'outter' };
} }
$ = (refName) => { $ = (refName) => {
@ -67,8 +67,8 @@ class Test$$Page extends React.Component {
return { return {
list: [ list: [
{ {
id: "urlParams", id: 'urlParams',
type: "urlParams", type: 'urlParams',
isInit: function () { isInit: function () {
return undefined; return undefined;
}, },
@ -77,12 +77,12 @@ class Test$$Page extends React.Component {
}, },
}, },
{ {
id: "user", id: 'user',
type: "fetch", type: 'fetch',
options: function () { options: function () {
return { return {
method: "GET", method: 'GET',
uri: "https://shs.xxx.com/mock/1458/demo/user", uri: 'https://shs.xxx.com/mock/1458/demo/user',
isSync: true, isSync: true,
}; };
}, },
@ -90,6 +90,7 @@ class Test$$Page extends React.Component {
if (!response.data.success) { if (!response.data.success) {
throw new Error(response.data.message); throw new Error(response.data.message);
} }
return response.data.data; return response.data.data;
}, },
isInit: function () { isInit: function () {
@ -97,12 +98,12 @@ class Test$$Page extends React.Component {
}, },
}, },
{ {
id: "orders", id: 'orders',
type: "fetch", type: 'fetch',
options: function () { options: function () {
return { return {
method: "GET", method: 'GET',
uri: "https://shs.xxx.com/mock/1458/demo/orders", uri: 'https://shs.xxx.com/mock/1458/demo/orders',
isSync: true, isSync: true,
}; };
}, },
@ -110,6 +111,7 @@ class Test$$Page extends React.Component {
if (!response.data.success) { if (!response.data.success) {
throw new Error(response.data.message); throw new Error(response.data.message);
} }
return response.data.data.result; return response.data.data.result;
}, },
isInit: function () { isInit: function () {
@ -118,7 +120,7 @@ class Test$$Page extends React.Component {
}, },
], ],
dataHandler: function (dataMap) { dataHandler: function (dataMap) {
console.info("All datasources loaded:", dataMap); console.info('All datasources loaded:', dataMap);
}, },
}; };
} }
@ -126,18 +128,18 @@ class Test$$Page extends React.Component {
componentDidMount() { componentDidMount() {
this._dataSourceEngine.reloadDataSource(); this._dataSourceEngine.reloadDataSource();
console.log("componentDidMount"); console.log('componentDidMount');
} }
render() { render() {
const __$$context = this._context || this; const __$$context = this._context || this;
const { state } = __$$context; const { state } = __$$context;
return ( return (
<div ref={this._refsManager.linkRef("outterView")} autoLoading={true}> <div ref={this._refsManager.linkRef('outterView')} autoLoading={true}>
<Form <Form
labelCol={__$$eval(() => this.state.colNum)} labelCol={__$$eval(() => this.state.colNum)}
style={{}} style={{}}
ref={this._refsManager.linkRef("testForm")} ref={this._refsManager.linkRef('testForm')}
> >
<Form.Item label="姓名:" name="name" initValue="李雷"> <Form.Item label="姓名:" name="name" initValue="李雷">
<Input placeholder="请输入" size="medium" style={{ width: 320 }} /> <Input placeholder="请输入" size="medium" style={{ width: 320 }} />
@ -148,18 +150,18 @@ class Test$$Page extends React.Component {
<Form.Item label="职业:" name="profession"> <Form.Item label="职业:" name="profession">
<Select <Select
dataSource={[ dataSource={[
{ label: "教师", value: "t" }, { label: '教师', value: 't' },
{ label: "医生", value: "d" }, { label: '医生', value: 'd' },
{ label: "歌手", value: "s" }, { label: '歌手', value: 's' },
]} ]}
/> />
</Form.Item> </Form.Item>
<div style={{ textAlign: "center" }}> <div style={{ textAlign: 'center' }}>
<Button.Group> <Button.Group>
{__$$evalArray(() => ["a", "b", "c"]).map((item, index) => {__$$evalArray(() => ['a', 'b', 'c']).map((item, index) =>
((__$$context) => ((__$$context) =>
!!__$$eval(() => index >= 1) && ( !!__$$eval(() => index >= 1) && (
<Button type="primary" style={{ margin: "0 5px 0 5px" }}> <Button type="primary" style={{ margin: '0 5px 0 5px' }}>
{__$$eval(() => item)} {__$$eval(() => item)}
</Button> </Button>
))(__$$createChildContext(__$$context, { item, index })) ))(__$$createChildContext(__$$context, { item, index }))

View File

@ -1,14 +1,14 @@
import Test from "@/pages/Test"; import Test from '@/pages/Test';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "/", path: '/',
component: Test, component: Test,
}, },
], ],

View File

@ -1,4 +1,4 @@
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -11,8 +11,8 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-url-params-handler": "latest", "@alilc/lowcode-datasource-url-params-handler": "^1.0.0",
"@alilc/b6-page": "^0.1.0", "@alilc/b6-page": "^0.1.0",
"@alilc/b6-text": "^0.1.0", "@alilc/b6-text": "^0.1.0",
"@alilc/b6-compact-legao-builtin": "1.x", "@alilc/b6-compact-legao-builtin": "1.x",

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,9 +1,9 @@
const i18nConfig = {}; const i18nConfig = {};
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -13,22 +13,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -49,7 +49,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -61,7 +61,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,22 +1,22 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import { Page } from "@alilc/b6-page"; import { Page } from '@alilc/b6-page';
import { Text } from "@alilc/b6-text"; import { Text } from '@alilc/b6-text';
import { createUrlParamsHandler as __$$createUrlParamsRequestHandler } from "@alilc/lowcode-datasource-url-params-handler"; import { createUrlParamsHandler as __$$createUrlParamsRequestHandler } from '@alilc/lowcode-datasource-url-params-handler';
import { create as __$$createDataSourceEngine } from "@alilc/lowcode-datasource-engine/runtime"; import { create as __$$createDataSourceEngine } from '@alilc/lowcode-datasource-engine/runtime';
import utils from "../../utils"; import utils from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
class Aaaa$$Page extends React.Component { class Aaaa$$Page extends React.Component {
_context = this; _context = this;
@ -60,12 +60,12 @@ class Aaaa$$Page extends React.Component {
return { return {
list: [ list: [
{ {
id: "urlParams", id: 'urlParams',
type: "urlParams", type: 'urlParams',
description: "URL参数", description: 'URL参数',
options: function () { options: function () {
return { return {
uri: "", uri: '',
}; };
}, },
isInit: function () { isInit: function () {

View File

@ -1,14 +1,14 @@
import Aaaa from "@/pages/Aaaa"; import Aaaa from '@/pages/Aaaa';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "/aaaa", path: '/aaaa',
component: Aaaa, component: Aaaa,
}, },
], ],

View File

@ -1,10 +1,10 @@
import legaoBuiltin from "@alilc/b6-compact-legao-builtin"; import legaoBuiltin from '@alilc/b6-compact-legao-builtin';
import { message, Modal as modal } from "antd"; import { message, Modal as modal } from 'antd';
import { mocks } from "@alilc/b6-util-mocks"; import { mocks } from '@alilc/b6-util-mocks';
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -11,7 +11,7 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alifd/next": "1.19.18" "@alifd/next": "1.19.18"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,3 +1,3 @@
const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; const __$$constants = { ENV: 'prod', DOMAIN: 'xxx.xxx.com' };
export default __$$constants; export default __$$constants;

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,18 +1,18 @@
const i18nConfig = { const i18nConfig = {
"zh-CN": { 'zh-CN': {
"i18n-jwg27yo4": "你好", 'i18n-jwg27yo4': '你好',
"i18n-jwg27yo3": "中国", 'i18n-jwg27yo3': '中国',
}, },
"en-US": { 'en-US': {
"i18n-jwg27yo4": "Hello", 'i18n-jwg27yo4': 'Hello',
"i18n-jwg27yo3": "China", 'i18n-jwg27yo3': 'China',
}, },
}; };
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -22,22 +22,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -58,7 +58,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -70,7 +70,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,16 +1,16 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import { Form, Input, NumberPicker, Select, Button } from "@alifd/next"; import { Form, Input, NumberPicker, Select, Button } from '@alifd/next';
import utils, { RefsManager } from "../../utils"; import utils, { RefsManager } from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
class Test$$Page extends React.Component { class Test$$Page extends React.Component {
_context = this; _context = this;
@ -28,7 +28,7 @@ class Test$$Page extends React.Component {
__$$i18n._inject2(this); __$$i18n._inject2(this);
this.state = { text: "outter" }; this.state = { text: 'outter' };
} }
$ = (refName) => { $ = (refName) => {
@ -40,21 +40,21 @@ class Test$$Page extends React.Component {
}; };
componentDidMount() { componentDidMount() {
console.log("componentDidMount"); console.log('componentDidMount');
} }
render() { render() {
const __$$context = this._context || this; const __$$context = this._context || this;
const { state } = __$$context; const { state } = __$$context;
return ( return (
<div ref={this._refsManager.linkRef("outterView")} autoLoading={true}> <div ref={this._refsManager.linkRef('outterView')} autoLoading={true}>
<Form <Form
labelCol={__$$eval(() => this.state.colNum)} labelCol={__$$eval(() => this.state.colNum)}
style={{}} style={{}}
ref={this._refsManager.linkRef("testForm")} ref={this._refsManager.linkRef('testForm')}
> >
<Form.Item <Form.Item
label={__$$eval(() => this.i18n("i18n-jwg27yo4"))} label={__$$eval(() => this.i18n('i18n-jwg27yo4'))}
name="name" name="name"
initValue="李雷" initValue="李雷"
> >
@ -66,24 +66,24 @@ class Test$$Page extends React.Component {
<Form.Item label="职业:" name="profession"> <Form.Item label="职业:" name="profession">
<Select <Select
dataSource={[ dataSource={[
{ label: "教师", value: "t" }, { label: '教师', value: 't' },
{ label: "医生", value: "d" }, { label: '医生', value: 'd' },
{ label: "歌手", value: "s" }, { label: '歌手', value: 's' },
]} ]}
/> />
</Form.Item> </Form.Item>
<div style={{ textAlign: "center" }}> <div style={{ textAlign: 'center' }}>
<Button.Group> <Button.Group>
<Button <Button
type="primary" type="primary"
style={{ margin: "0 5px 0 5px" }} style={{ margin: '0 5px 0 5px' }}
htmlType="submit" htmlType="submit"
> >
提交 提交
</Button> </Button>
<Button <Button
type="normal" type="normal"
style={{ margin: "0 5px 0 5px" }} style={{ margin: '0 5px 0 5px' }}
htmlType="reset" htmlType="reset"
> >
重置 重置

View File

@ -1,14 +1,14 @@
import Test from "@/pages/Test"; import Test from '@/pages/Test';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "/", path: '/',
component: Test, component: Test,
}, },
], ],

View File

@ -1,4 +1,4 @@
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -11,7 +11,7 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alifd/next": "1.19.18" "@alifd/next": "1.19.18"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,3 +1,3 @@
const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; const __$$constants = { ENV: 'prod', DOMAIN: 'xxx.xxx.com' };
export default __$$constants; export default __$$constants;

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,18 +1,18 @@
const i18nConfig = { const i18nConfig = {
"zh-CN": { 'zh-CN': {
"i18n-jwg27yo4": "你好", 'i18n-jwg27yo4': '你好',
"i18n-jwg27yo3": "中国", 'i18n-jwg27yo3': '中国',
}, },
"en-US": { 'en-US': {
"i18n-jwg27yo4": "Hello", 'i18n-jwg27yo4': 'Hello',
"i18n-jwg27yo3": "China", 'i18n-jwg27yo3': 'China',
}, },
}; };
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -22,22 +22,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -58,7 +58,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -70,7 +70,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,6 +1,6 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import Super, { import Super, {
Button, Button,
@ -9,17 +9,17 @@ import Super, {
NumberPicker, NumberPicker,
Select, Select,
SearchTable as SearchTableExport, SearchTable as SearchTableExport,
} from "@alifd/next"; } from '@alifd/next';
import SuperOther from "@alifd/next"; import SuperOther from '@alifd/next';
import utils from "../../utils"; import utils from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
const SuperSub = Super.Sub; const SuperSub = Super.Sub;

View File

@ -1,14 +1,14 @@
import Test from "@/pages/Test"; import Test from '@/pages/Test';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "/", path: '/',
component: Test, component: Test,
}, },
], ],

View File

@ -1,4 +1,4 @@
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -11,9 +11,9 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-fetch-handler": "latest", "@alilc/lowcode-datasource-fetch-handler": "^1.0.0",
"@alife/container": "latest", "@alife/container": "^1.0.0",
"@alife/mc-assets-1935": "0.1.9" "@alife/mc-assets-1935": "0.1.9"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,9 +1,9 @@
const i18nConfig = {}; const i18nConfig = {};
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -13,22 +13,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -49,7 +49,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -61,7 +61,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,27 +1,27 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import { import {
Page as NextPage, Page as NextPage,
Block as NextBlock, Block as NextBlock,
P as NextP, P as NextP,
Text as NextText, Text as NextText,
} from "@alife/container/lib/index.js"; } from '@alife/container/lib/index.js';
import { AliSearchTable as AliSearchTableExport } from "@alife/mc-assets-1935/build/lowcode/index.js"; import { AliSearchTable as AliSearchTableExport } from '@alife/mc-assets-1935/build/lowcode/index.js';
import { createFetchHandler as __$$createFetchRequestHandler } from "@alilc/lowcode-datasource-fetch-handler"; import { createFetchHandler as __$$createFetchRequestHandler } from '@alilc/lowcode-datasource-fetch-handler';
import { create as __$$createDataSourceEngine } from "@alilc/lowcode-datasource-engine/runtime"; import { create as __$$createDataSourceEngine } from '@alilc/lowcode-datasource-engine/runtime';
import utils, { RefsManager } from "../../utils"; import utils, { RefsManager } from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
const NextBlockCell = NextBlock.Cell; const NextBlockCell = NextBlock.Cell;
@ -57,7 +57,7 @@ class Test$$Page extends React.Component {
__$$i18n._inject2(this); __$$i18n._inject2(this);
this.state = { text: "outter", isShowDialog: false }; this.state = { text: 'outter', isShowDialog: false };
} }
$ = (refName) => { $ = (refName) => {
@ -73,28 +73,28 @@ class Test$$Page extends React.Component {
return { return {
list: [ list: [
{ {
type: "fetch", type: 'fetch',
isInit: function () { isInit: function () {
return true; return true;
}, },
options: function () { options: function () {
return { return {
params: {}, params: {},
method: "GET", method: 'GET',
isCors: true, isCors: true,
timeout: 5000, timeout: 5000,
headers: {}, headers: {},
uri: "https://mocks.xxx.com/mock/jjpin/user/list", uri: 'https://mocks.xxx.com/mock/jjpin/user/list',
}; };
}, },
id: "users", id: 'users',
}, },
], ],
}; };
} }
componentWillUnmount() { componentWillUnmount() {
console.log("will umount"); console.log('will umount');
} }
componentDidUpdate(prevProps, prevState, snapshot) { componentDidUpdate(prevProps, prevState, snapshot) {
@ -102,7 +102,7 @@ class Test$$Page extends React.Component {
} }
testFunc() { testFunc() {
console.log("test func"); console.log('test func');
} }
onClick() { onClick() {
@ -118,13 +118,13 @@ class Test$$Page extends React.Component {
} }
onSearch(values) { onSearch(values) {
console.log("search form:", values); console.log('search form:', values);
console.log(this.dataSourceMap); console.log(this.dataSourceMap);
this.dataSourceMap["users"].load(values); this.dataSourceMap['users'].load(values);
} }
onClear() { onClear() {
console.log("form reset"); console.log('form reset');
this.setState({ this.setState({
isShowDialog: true, isShowDialog: true,
}); });
@ -137,7 +137,7 @@ class Test$$Page extends React.Component {
componentDidMount() { componentDidMount() {
this._dataSourceEngine.reloadDataSource(); this._dataSourceEngine.reloadDataSource();
console.log("did mount"); console.log('did mount');
} }
render() { render() {
@ -145,12 +145,12 @@ class Test$$Page extends React.Component {
const { state } = __$$context; const { state } = __$$context;
return ( return (
<div <div
ref={this._refsManager.linkRef("outterView")} ref={this._refsManager.linkRef('outterView')}
style={{ height: "100%" }} style={{ height: '100%' }}
> >
<NextPage <NextPage
columns={12} columns={12}
placeholderStyle={{ gridRowEnd: "span 1", gridColumnEnd: "span 12" }} placeholderStyle={{ gridRowEnd: 'span 1', gridColumnEnd: 'span 12' }}
placeholder="页面主体内容拖拽Block布局组件到这里" placeholder="页面主体内容拖拽Block布局组件到这里"
header={ header={
<NextP <NextP
@ -165,13 +165,13 @@ class Test$$Page extends React.Component {
</NextP> </NextP>
} }
headerTest={[]} headerTest={[]}
headerProps={{ background: "surface" }} headerProps={{ background: 'surface' }}
footer={null} footer={null}
minHeight="100vh" minHeight="100vh"
> >
<NextBlock <NextBlock
prefix="next-" prefix="next-"
placeholderStyle={{ height: "100%" }} placeholderStyle={{ height: '100%' }}
noPadding={false} noPadding={false}
noBorder={false} noBorder={false}
background="surface" background="surface"
@ -183,7 +183,7 @@ class Test$$Page extends React.Component {
title="" title=""
primaryKey="732" primaryKey="732"
prefix="next-" prefix="next-"
placeholderStyle={{ height: "100%" }} placeholderStyle={{ height: '100%' }}
colSpan={1} colSpan={1}
rowSpan={1} rowSpan={1}
> >
@ -199,13 +199,13 @@ class Test$$Page extends React.Component {
dataSource={__$$eval(() => this.state.users.data)} dataSource={__$$eval(() => this.state.users.data)}
rowKey="workid" rowKey="workid"
columns={[ columns={[
{ title: "花名", dataIndex: "cname" }, { title: '花名', dataIndex: 'cname' },
{ title: "user_id", dataIndex: "workid" }, { title: 'user_id', dataIndex: 'workid' },
{ title: "部门", dataIndex: "dep" }, { title: '部门', dataIndex: 'dep' },
]} ]}
searchItems={[ searchItems={[
{ label: "姓名", name: "cname" }, { label: '姓名', name: 'cname' },
{ label: "部门", name: "dep" }, { label: '部门', name: 'dep' },
]} ]}
onSearch={function () { onSearch={function () {
return this.onSearch.apply( return this.onSearch.apply(
@ -220,7 +220,7 @@ class Test$$Page extends React.Component {
); );
}.bind(this)} }.bind(this)}
pagination={{ pagination={{
defaultPageSize: "", defaultPageSize: '',
onPageChange: function () { onPageChange: function () {
return this.onPageChange.apply( return this.onPageChange.apply(
this, this,
@ -237,16 +237,16 @@ class Test$$Page extends React.Component {
<NextPage <NextPage
columns={12} columns={12}
headerDivider={true} headerDivider={true}
placeholderStyle={{ gridRowEnd: "span 1", gridColumnEnd: "span 12" }} placeholderStyle={{ gridRowEnd: 'span 1', gridColumnEnd: 'span 12' }}
placeholder="页面主体内容拖拽Block布局组件到这里" placeholder="页面主体内容拖拽Block布局组件到这里"
header={null} header={null}
headerProps={{ background: "surface" }} headerProps={{ background: 'surface' }}
footer={null} footer={null}
minHeight="100vh" minHeight="100vh"
> >
<NextBlock <NextBlock
prefix="next-" prefix="next-"
placeholderStyle={{ height: "100%" }} placeholderStyle={{ height: '100%' }}
noPadding={false} noPadding={false}
noBorder={false} noBorder={false}
background="surface" background="surface"
@ -258,7 +258,7 @@ class Test$$Page extends React.Component {
title="" title=""
primaryKey="472" primaryKey="472"
prefix="next-" prefix="next-"
placeholderStyle={{ height: "100%" }} placeholderStyle={{ height: '100%' }}
colSpan={1} colSpan={1}
rowSpan={1} rowSpan={1}
/> />

View File

@ -1,14 +1,14 @@
import Test from "@/pages/Test"; import Test from '@/pages/Test';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "", path: '',
component: Test, component: Test,
}, },
], ],

View File

@ -1,4 +1,4 @@
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -12,7 +12,7 @@
}, },
{ {
"package": "@alife/container", "package": "@alife/container",
"version": "latest", "version": "^1.0.0",
"exportName": "P", "exportName": "P",
"main": "lib/index.js", "main": "lib/index.js",
"destructuring": true, "destructuring": true,
@ -21,7 +21,7 @@
}, },
{ {
"package": "@alife/container", "package": "@alife/container",
"version": "latest", "version": "^1.0.0",
"exportName": "Block", "exportName": "Block",
"main": "lib/index.js", "main": "lib/index.js",
"destructuring": true, "destructuring": true,
@ -30,7 +30,7 @@
}, },
{ {
"package": "@alife/container", "package": "@alife/container",
"version": "latest", "version": "^1.0.0",
"exportName": "Block", "exportName": "Block",
"main": "lib/index.js", "main": "lib/index.js",
"destructuring": true, "destructuring": true,
@ -39,7 +39,7 @@
}, },
{ {
"package": "@alife/container", "package": "@alife/container",
"version": "latest", "version": "^1.0.0",
"exportName": "Text", "exportName": "Text",
"main": "lib/index.js", "main": "lib/index.js",
"destructuring": true, "destructuring": true,
@ -48,7 +48,7 @@
}, },
{ {
"package": "@alife/container", "package": "@alife/container",
"version": "latest", "version": "^1.0.0",
"exportName": "Page", "exportName": "Page",
"main": "lib/index.js", "main": "lib/index.js",
"destructuring": true, "destructuring": true,

View File

@ -11,7 +11,7 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"undefined": "*", "undefined": "*",
"@alife/container": "0.3.7", "@alife/container": "0.3.7",
"@alilc/antd-lowcode": "0.5.4", "@alilc/antd-lowcode": "0.5.4",

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,9 +1,9 @@
const i18nConfig = {}; const i18nConfig = {};
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -13,22 +13,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -49,7 +49,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -61,7 +61,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,12 +1,12 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import { import {
Page as NextPage, Page as NextPage,
Block as NextBlock, Block as NextBlock,
P as NextP, P as NextP,
} from "@alife/container/lib/index.js"; } from '@alife/container/lib/index.js';
import { import {
Card, Card,
@ -18,17 +18,17 @@ import {
Form, Form,
InputNumber, InputNumber,
Input, Input,
} from "@alilc/antd-lowcode/dist/antd-lowcode.esm.js"; } from '@alilc/antd-lowcode/dist/antd-lowcode.esm.js';
import { AliAutoSearchTable } from "@alife/mc-assets-1935/build/lowcode/index.js"; import { AliAutoSearchTable } from '@alife/mc-assets-1935/build/lowcode/index.js';
import utils, { RefsManager } from "../../utils"; import utils, { RefsManager } from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
const NextBlockCell = NextBlock.Cell; const NextBlockCell = NextBlock.Cell;
@ -51,7 +51,7 @@ class Test$$Page extends React.Component {
__$$i18n._inject2(this); __$$i18n._inject2(this);
this.state = { this.state = {
name: "nongzhou", name: 'nongzhou',
gateways: [], gateways: [],
selectedGateway: null, selectedGateway: null,
records: [], records: [],
@ -102,23 +102,23 @@ class Test$$Page extends React.Component {
const { state } = __$$context; const { state } = __$$context;
return ( return (
<div <div
ref={this._refsManager.linkRef("outterView")} ref={this._refsManager.linkRef('outterView')}
style={{ height: "100%" }} style={{ height: '100%' }}
> >
<NextPage <NextPage
columns={12} columns={12}
headerDivider={true} headerDivider={true}
placeholderStyle={{ gridRowEnd: "span 1", gridColumnEnd: "span 12" }} placeholderStyle={{ gridRowEnd: 'span 1', gridColumnEnd: 'span 12' }}
placeholder="页面主体内容拖拽Block布局组件到这里" placeholder="页面主体内容拖拽Block布局组件到这里"
header={null} header={null}
headerProps={{ background: "surface" }} headerProps={{ background: 'surface' }}
footer={null} footer={null}
minHeight="100vh" minHeight="100vh"
style={{ cursor: "pointer" }} style={{ cursor: 'pointer' }}
> >
<NextBlock <NextBlock
prefix="next-" prefix="next-"
placeholderStyle={{ height: "100%" }} placeholderStyle={{ height: '100%' }}
noPadding={false} noPadding={false}
noBorder={false} noBorder={false}
background="surface" background="surface"
@ -130,7 +130,7 @@ class Test$$Page extends React.Component {
<NextBlockCell <NextBlockCell
title="" title=""
prefix="next-" prefix="next-"
placeholderStyle={{ height: "100%" }} placeholderStyle={{ height: '100%' }}
layoutmode="O" layoutmode="O"
childTotalColumns={12} childTotalColumns={12}
isAutoContainer={true} isAutoContainer={true}
@ -151,16 +151,16 @@ class Test$$Page extends React.Component {
<Typography.Text>所在网关</Typography.Text> <Typography.Text>所在网关</Typography.Text>
<Select <Select
style={{ style={{
marginTop: "16px", marginTop: '16px',
marginRight: "16px", marginRight: '16px',
marginBottom: "16px", marginBottom: '16px',
marginLeft: "16px", marginLeft: '16px',
width: "400px", width: '400px',
display: "inline-block", display: 'inline-block',
}} }}
options={__$$eval(() => this.state.gateways)} options={__$$eval(() => this.state.gateways)}
mode="single" mode="single"
defaultValue={["auto-edd-uniproxy"]} defaultValue={['auto-edd-uniproxy']}
labelInValue={true} labelInValue={true}
showSearch={true} showSearch={true}
allowClear={false} allowClear={false}
@ -171,23 +171,23 @@ class Test$$Page extends React.Component {
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onChange", name: 'onChange',
relatedEventName: "onChange", relatedEventName: 'onChange',
}, },
], ],
eventList: [ eventList: [
{ name: "onBlur", disabled: false }, { name: 'onBlur', disabled: false },
{ name: "onChange", disabled: true }, { name: 'onChange', disabled: true },
{ name: "onDeselect", disabled: false }, { name: 'onDeselect', disabled: false },
{ name: "onFocus", disabled: false }, { name: 'onFocus', disabled: false },
{ name: "onInputKeyDown", disabled: false }, { name: 'onInputKeyDown', disabled: false },
{ name: "onMouseEnter", disabled: false }, { name: 'onMouseEnter', disabled: false },
{ name: "onMouseLeave", disabled: false }, { name: 'onMouseLeave', disabled: false },
{ name: "onPopupScroll", disabled: false }, { name: 'onPopupScroll', disabled: false },
{ name: "onSearch", disabled: false }, { name: 'onSearch', disabled: false },
{ name: "onSelect", disabled: false }, { name: 'onSelect', disabled: false },
{ name: "onDropdownVisibleChange", disabled: false }, { name: 'onDropdownVisibleChange', disabled: false },
], ],
}} }}
onChange={function () { onChange={function () {
@ -201,19 +201,19 @@ class Test$$Page extends React.Component {
<Button <Button
type="primary" type="primary"
style={{ style={{
display: "block", display: 'block',
marginTop: "20px", marginTop: '20px',
marginBottom: "20px", marginBottom: '20px',
}} }}
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onClick", name: 'onClick',
relatedEventName: "onCreateOrder", relatedEventName: 'onCreateOrder',
}, },
], ],
eventList: [{ name: "onClick", disabled: true }], eventList: [{ name: 'onClick', disabled: true }],
}} }}
onClick={function () { onClick={function () {
this.onCreateOrder.apply( this.onCreateOrder.apply(
@ -231,14 +231,14 @@ class Test$$Page extends React.Component {
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onCancel", name: 'onCancel',
relatedEventName: "onCancelModal", relatedEventName: 'onCancelModal',
}, },
], ],
eventList: [ eventList: [
{ name: "onCancel", disabled: true }, { name: 'onCancel', disabled: true },
{ name: "onOk", disabled: false }, { name: 'onOk', disabled: false },
], ],
}} }}
onCancel={function () { onCancel={function () {
@ -262,16 +262,16 @@ class Test$$Page extends React.Component {
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onFinish", name: 'onFinish',
relatedEventName: "onConfirmCreateOrder", relatedEventName: 'onConfirmCreateOrder',
}, },
], ],
eventList: [ eventList: [
{ name: "onFinish", disabled: true }, { name: 'onFinish', disabled: true },
{ name: "onFinishFailed", disabled: false }, { name: 'onFinishFailed', disabled: false },
{ name: "onFieldsChange", disabled: false }, { name: 'onFieldsChange', disabled: false },
{ name: "onValuesChange", disabled: false }, { name: 'onValuesChange', disabled: false },
], ],
}} }}
> >
@ -287,10 +287,10 @@ class Test$$Page extends React.Component {
<Form.Item <Form.Item
wrapperCol={{ offset: 6 }} wrapperCol={{ offset: 6 }}
style={{ style={{
flexDirection: "row", flexDirection: 'row',
alignItems: "flex-end", alignItems: 'flex-end',
justifyContent: "center", justifyContent: 'center',
display: "flex", display: 'flex',
}} }}
labelAlign="right" labelAlign="right"
> >
@ -302,12 +302,12 @@ class Test$$Page extends React.Component {
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onClick", name: 'onClick',
relatedEventName: "onCancelModal", relatedEventName: 'onCancelModal',
}, },
], ],
eventList: [{ name: "onClick", disabled: true }], eventList: [{ name: 'onClick', disabled: true }],
}} }}
onClick={function () { onClick={function () {
this.onCancelModal.apply( this.onCancelModal.apply(
@ -326,27 +326,27 @@ class Test$$Page extends React.Component {
dataSource={__$$eval(() => this.state.records)} dataSource={__$$eval(() => this.state.records)}
columns={[ columns={[
{ {
title: "发布名称", title: '发布名称',
dataIndex: "order_name", dataIndex: 'order_name',
key: "name", key: 'name',
}, },
{ {
title: "类型", title: '类型',
dataIndex: "order_type_desc", dataIndex: 'order_type_desc',
key: "age", key: 'age',
}, },
{ {
title: "发布状态", title: '发布状态',
dataIndex: "order_status_desc", dataIndex: 'order_status_desc',
key: "address", key: 'address',
}, },
{ title: "发布人", dataIndex: "creator_name" }, { title: '发布人', dataIndex: 'creator_name' },
{ title: "当前批次/总批次", dataIndex: "cur_batch_no" }, { title: '当前批次/总批次', dataIndex: 'cur_batch_no' },
{ {
title: "发布机器/总机器", title: '发布机器/总机器',
dataIndex: "pubblish_ip_finish_num", dataIndex: 'pubblish_ip_finish_num',
}, },
{ title: "发布时间", dataIndex: "publish_id" }, { title: '发布时间', dataIndex: 'publish_id' },
]} ]}
actions={__$$eval(() => this.actions || [])} actions={__$$eval(() => this.actions || [])}
getActions={function () { getActions={function () {

View File

@ -1,14 +1,14 @@
import Test from "@/pages/Test"; import Test from '@/pages/Test';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "", path: '',
component: Test, component: Test,
}, },
], ],

View File

@ -1,4 +1,4 @@
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -11,9 +11,9 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-url-params-handler": "latest", "@alilc/lowcode-datasource-url-params-handler": "^1.0.0",
"@alilc/lowcode-datasource-fetch-handler": "latest", "@alilc/lowcode-datasource-fetch-handler": "^1.0.0",
"@alifd/next": "1.19.18" "@alifd/next": "1.19.18"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,3 +1,3 @@
const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; const __$$constants = { ENV: 'prod', DOMAIN: 'xxx.xxx.com' };
export default __$$constants; export default __$$constants;

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,9 +1,9 @@
const i18nConfig = {}; const i18nConfig = {};
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -13,22 +13,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -49,7 +49,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -61,7 +61,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,22 +1,22 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import { Form, Input, NumberPicker, Select, Button } from "@alifd/next"; import { Form, Input, NumberPicker, Select, Button } from '@alifd/next';
import { createUrlParamsHandler as __$$createUrlParamsRequestHandler } from "@alilc/lowcode-datasource-url-params-handler"; import { createUrlParamsHandler as __$$createUrlParamsRequestHandler } from '@alilc/lowcode-datasource-url-params-handler';
import { createFetchHandler as __$$createFetchRequestHandler } from "@alilc/lowcode-datasource-fetch-handler"; import { createFetchHandler as __$$createFetchRequestHandler } from '@alilc/lowcode-datasource-fetch-handler';
import { create as __$$createDataSourceEngine } from "@alilc/lowcode-datasource-engine/runtime"; import { create as __$$createDataSourceEngine } from '@alilc/lowcode-datasource-engine/runtime';
import utils, { RefsManager } from "../../utils"; import utils, { RefsManager } from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
class Test$$Page extends React.Component { class Test$$Page extends React.Component {
_context = this; _context = this;
@ -51,7 +51,7 @@ class Test$$Page extends React.Component {
__$$i18n._inject2(this); __$$i18n._inject2(this);
this.state = { text: "outter" }; this.state = { text: 'outter' };
} }
$ = (refName) => { $ = (refName) => {
@ -67,8 +67,8 @@ class Test$$Page extends React.Component {
return { return {
list: [ list: [
{ {
id: "urlParams", id: 'urlParams',
type: "urlParams", type: 'urlParams',
isInit: function () { isInit: function () {
return undefined; return undefined;
}, },
@ -77,12 +77,12 @@ class Test$$Page extends React.Component {
}, },
}, },
{ {
id: "user", id: 'user',
type: "fetch", type: 'fetch',
options: function () { options: function () {
return { return {
method: "GET", method: 'GET',
uri: "https://shs.xxx.com/mock/1458/demo/user", uri: 'https://shs.xxx.com/mock/1458/demo/user',
isSync: true, isSync: true,
}; };
}, },
@ -90,6 +90,7 @@ class Test$$Page extends React.Component {
if (!response.data.success) { if (!response.data.success) {
throw new Error(response.data.message); throw new Error(response.data.message);
} }
return response.data.data; return response.data.data;
}, },
isInit: function () { isInit: function () {
@ -97,12 +98,12 @@ class Test$$Page extends React.Component {
}, },
}, },
{ {
id: "orders", id: 'orders',
type: "fetch", type: 'fetch',
options: function () { options: function () {
return { return {
method: "GET", method: 'GET',
uri: "https://shs.xxx.com/mock/1458/demo/orders", uri: 'https://shs.xxx.com/mock/1458/demo/orders',
isSync: true, isSync: true,
}; };
}, },
@ -110,6 +111,7 @@ class Test$$Page extends React.Component {
if (!response.data.success) { if (!response.data.success) {
throw new Error(response.data.message); throw new Error(response.data.message);
} }
return response.data.data.result; return response.data.data.result;
}, },
isInit: function () { isInit: function () {
@ -118,7 +120,7 @@ class Test$$Page extends React.Component {
}, },
], ],
dataHandler: function (dataMap) { dataHandler: function (dataMap) {
console.info("All datasources loaded:", dataMap); console.info('All datasources loaded:', dataMap);
}, },
}; };
} }
@ -126,18 +128,18 @@ class Test$$Page extends React.Component {
componentDidMount() { componentDidMount() {
this._dataSourceEngine.reloadDataSource(); this._dataSourceEngine.reloadDataSource();
console.log("componentDidMount"); console.log('componentDidMount');
} }
render() { render() {
const __$$context = this._context || this; const __$$context = this._context || this;
const { state } = __$$context; const { state } = __$$context;
return ( return (
<div ref={this._refsManager.linkRef("outterView")} autoLoading={true}> <div ref={this._refsManager.linkRef('outterView')} autoLoading={true}>
<Form <Form
labelCol={__$$eval(() => this.state.colNum)} labelCol={__$$eval(() => this.state.colNum)}
style={{}} style={{}}
ref={this._refsManager.linkRef("testForm")} ref={this._refsManager.linkRef('testForm')}
> >
<Form.Item label="姓名:" name="name" initValue="李雷"> <Form.Item label="姓名:" name="name" initValue="李雷">
<Input placeholder="请输入" size="medium" style={{ width: 320 }} /> <Input placeholder="请输入" size="medium" style={{ width: 320 }} />
@ -148,18 +150,18 @@ class Test$$Page extends React.Component {
<Form.Item label="职业:" name="profession"> <Form.Item label="职业:" name="profession">
<Select <Select
dataSource={[ dataSource={[
{ label: "教师", value: "t" }, { label: '教师', value: 't' },
{ label: "医生", value: "d" }, { label: '医生', value: 'd' },
{ label: "歌手", value: "s" }, { label: '歌手', value: 's' },
]} ]}
/> />
</Form.Item> </Form.Item>
<div style={{ textAlign: "center" }}> <div style={{ textAlign: 'center' }}>
<Button.Group> <Button.Group>
{__$$evalArray(() => ["a", "b", "c"]).map((item, index) => {__$$evalArray(() => ['a', 'b', 'c']).map((item, index) =>
((__$$context) => ((__$$context) =>
!!false && ( !!false && (
<Button type="primary" style={{ margin: "0 5px 0 5px" }}> <Button type="primary" style={{ margin: '0 5px 0 5px' }}>
{__$$eval(() => item)} {__$$eval(() => item)}
</Button> </Button>
))(__$$createChildContext(__$$context, { item, index })) ))(__$$createChildContext(__$$context, { item, index }))

View File

@ -1,14 +1,14 @@
import Test from "@/pages/Test"; import Test from '@/pages/Test';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "/", path: '/',
component: Test, component: Test,
}, },
], ],

View File

@ -1,4 +1,4 @@
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -11,7 +11,7 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"undefined": "*", "undefined": "*",
"@alilc/antd-lowcode": "0.8.0", "@alilc/antd-lowcode": "0.8.0",
"@alife/container": "0.3.7" "@alife/container": "0.3.7"

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,9 +1,9 @@
const i18nConfig = {}; const i18nConfig = {};
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -13,22 +13,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -49,7 +49,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -61,7 +61,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,6 +1,6 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import { import {
Modal, Modal,
@ -12,22 +12,22 @@ import {
DatePicker, DatePicker,
InputNumber, InputNumber,
Button, Button,
} from "@alilc/antd-lowcode/dist/antd-lowcode.esm.js"; } from '@alilc/antd-lowcode/dist/antd-lowcode.esm.js';
import { import {
Text as NextText, Text as NextText,
Page as NextPage, Page as NextPage,
Block as NextBlock, Block as NextBlock,
P as NextP, P as NextP,
} from "@alife/container/lib/index.js"; } from '@alife/container/lib/index.js';
import utils, { RefsManager } from "../../utils"; import utils, { RefsManager } from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
const NextBlockCell = NextBlock.Cell; const NextBlockCell = NextBlock.Cell;
@ -52,9 +52,9 @@ class Test$$Page extends React.Component {
currentStep: 0, currentStep: 0,
isModifyDialogVisible: false, isModifyDialogVisible: false,
isModifyStatus: false, isModifyStatus: false,
secondCommitText: "完成并提交", secondCommitText: '完成并提交',
thirdAuditText: "审核中", thirdAuditText: '审核中',
thirdButtonText: "修改", thirdButtonText: '修改',
customerProjectInfo: { customerProjectInfo: {
id: null, id: null,
systemProjectName: null, systemProjectName: null,
@ -75,28 +75,28 @@ class Test$$Page extends React.Component {
status: null, status: null,
}, },
versionLinesArray: [ versionLinesArray: [
{ label: "AmapAuto 485", value: 1 }, { label: 'AmapAuto 485', value: 1 },
{ label: "AmapAuto 505", value: 2 }, { label: 'AmapAuto 505', value: 2 },
], ],
projectModalsArray: [ projectModalsArray: [
{ label: "车机", value: 1 }, { label: '车机', value: 1 },
{ label: "车镜", value: 2 }, { label: '车镜', value: 2 },
{ label: "记录仪", value: 3 }, { label: '记录仪', value: 3 },
{ label: "其他", value: 4 }, { label: '其他', value: 4 },
], ],
osVersionsArray: [ osVersionsArray: [
{ label: "安卓5", value: 1 }, { label: '安卓5', value: 1 },
{ label: "安卓6", value: 2 }, { label: '安卓6', value: 2 },
{ label: "安卓7", value: 3 }, { label: '安卓7', value: 3 },
{ label: "安卓8", value: 4 }, { label: '安卓8', value: 4 },
{ label: "安卓9", value: 5 }, { label: '安卓9', value: 5 },
{ label: "安卓10", value: 6 }, { label: '安卓10', value: 6 },
], ],
instructionsArray: [ instructionsArray: [
{ label: "ARM64-V8", value: "ARM64-V8" }, { label: 'ARM64-V8', value: 'ARM64-V8' },
{ label: "ARM32-V7", value: "ARM32-V7" }, { label: 'ARM32-V7', value: 'ARM32-V7' },
{ label: "X86", value: "X86" }, { label: 'X86', value: 'X86' },
{ label: "X64", value: "X64" }, { label: 'X64', value: 'X64' },
], ],
}; };
} }
@ -151,7 +151,6 @@ class Test$$Page extends React.Component {
onOkModifyDialogThird() { onOkModifyDialogThird() {
// //
this.setState({ this.setState({
currentStep: 0, currentStep: 0,
isModifyDialogVisible: false, isModifyDialogVisible: false,
@ -160,7 +159,6 @@ class Test$$Page extends React.Component {
onCancelModifyDialogThird() { onCancelModifyDialogThird() {
// //
this.setState({ this.setState({
isModifyDialogVisible: false, isModifyDialogVisible: false,
}); });
@ -177,17 +175,17 @@ class Test$$Page extends React.Component {
onClickFirstBack() { onClickFirstBack() {
// //
this.$router.push("/myProjectList"); this.$router.push('/myProjectList');
} }
onClickSecondBack() { onClickSecondBack() {
// //
this.$router.push("/myProjectList"); this.$router.push('/myProjectList');
} }
onClickThirdBack() { onClickThirdBack() {
// //
this.$router.push("/myProjectList"); this.$router.push('/myProjectList');
} }
onValuesChange(_, values) { onValuesChange(_, values) {
@ -206,8 +204,8 @@ class Test$$Page extends React.Component {
const { state } = __$$context; const { state } = __$$context;
return ( return (
<div <div
ref={this._refsManager.linkRef("outterView")} ref={this._refsManager.linkRef('outterView')}
style={{ height: "100%" }} style={{ height: '100%' }}
> >
<Modal <Modal
title="是否修改" title="是否修改"
@ -222,19 +220,19 @@ class Test$$Page extends React.Component {
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onOk", name: 'onOk',
relatedEventName: "onOkModifyDialogThird", relatedEventName: 'onOkModifyDialogThird',
}, },
{ {
type: "componentEvent", type: 'componentEvent',
name: "onCancel", name: 'onCancel',
relatedEventName: "onCancelModifyDialogThird", relatedEventName: 'onCancelModifyDialogThird',
}, },
], ],
eventList: [ eventList: [
{ name: "onCancel", disabled: true }, { name: 'onCancel', disabled: true },
{ name: "onOk", disabled: true }, { name: 'onOk', disabled: true },
], ],
}} }}
onOk={function () { onOk={function () {
@ -253,11 +251,11 @@ class Test$$Page extends React.Component {
<NextText <NextText
type="inherit" type="inherit"
style={{ style={{
fontStyle: "normal", fontStyle: 'normal',
textAlign: "left", textAlign: 'left',
display: "block", display: 'block',
fontFamily: "arial, helvetica, microsoft yahei", fontFamily: 'arial, helvetica, microsoft yahei',
fontWeight: "normal", fontWeight: 'normal',
}} }}
> >
修改将撤回此前填写的信息 修改将撤回此前填写的信息
@ -266,17 +264,17 @@ class Test$$Page extends React.Component {
<NextPage <NextPage
columns={12} columns={12}
headerDivider={true} headerDivider={true}
placeholderStyle={{ gridRowEnd: "span 1", gridColumnEnd: "span 12" }} placeholderStyle={{ gridRowEnd: 'span 1', gridColumnEnd: 'span 12' }}
placeholder="页面主体内容拖拽Block布局组件到这里" placeholder="页面主体内容拖拽Block布局组件到这里"
header={null} header={null}
headerProps={{ background: "surface" }} headerProps={{ background: 'surface' }}
footer={null} footer={null}
minHeight="100vh" minHeight="100vh"
style={{}} style={{}}
> >
<NextBlock <NextBlock
prefix="next-" prefix="next-"
placeholderStyle={{ height: "100%" }} placeholderStyle={{ height: '100%' }}
noPadding={false} noPadding={false}
noBorder={false} noBorder={false}
background="surface" background="surface"
@ -288,7 +286,7 @@ class Test$$Page extends React.Component {
<NextBlockCell <NextBlockCell
title="" title=""
prefix="next-" prefix="next-"
placeholderStyle={{ height: "100%" }} placeholderStyle={{ height: '100%' }}
layoutmode="O" layoutmode="O"
childTotalColumns={12} childTotalColumns={12}
isAutoContainer={true} isAutoContainer={true}
@ -302,7 +300,7 @@ class Test$$Page extends React.Component {
textSpacing={true} textSpacing={true}
align="left" align="left"
flex={true} flex={true}
style={{ marginBottom: "24px" }} style={{ marginBottom: '24px' }}
> >
<Steps current={__$$eval(() => this.state.currentStep)}> <Steps current={__$$eval(() => this.state.currentStep)}>
<Steps.Step title="版本申请" description="" /> <Steps.Step title="版本申请" description="" />
@ -319,7 +317,7 @@ class Test$$Page extends React.Component {
align="left" align="left"
full={true} full={true}
flex={true} flex={true}
style={{ display: "flex", justifyContent: "center" }} style={{ display: 'flex', justifyContent: 'center' }}
> >
<Form <Form
labelCol={{ span: 10 }} labelCol={{ span: 10 }}
@ -332,30 +330,30 @@ class Test$$Page extends React.Component {
}.bind(this)} }.bind(this)}
name="basic" name="basic"
style={{ style={{
display: "flex", display: 'flex',
flexDirection: "column", flexDirection: 'column',
width: "600px", width: '600px',
justifyContent: "center", justifyContent: 'center',
}} }}
layout="vertical" layout="vertical"
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onFinish", name: 'onFinish',
relatedEventName: "onFinishFirst", relatedEventName: 'onFinishFirst',
}, },
{ {
type: "componentEvent", type: 'componentEvent',
name: "onValuesChange", name: 'onValuesChange',
relatedEventName: "onValuesChange", relatedEventName: 'onValuesChange',
}, },
], ],
eventList: [ eventList: [
{ name: "onFinish", disabled: true }, { name: 'onFinish', disabled: true },
{ name: "onFinishFailed", disabled: false }, { name: 'onFinishFailed', disabled: false },
{ name: "onFieldsChange", disabled: false }, { name: 'onFieldsChange', disabled: false },
{ name: "onValuesChange", disabled: true }, { name: 'onValuesChange', disabled: true },
], ],
}} }}
initialValues={__$$eval( initialValues={__$$eval(
@ -371,13 +369,13 @@ class Test$$Page extends React.Component {
{!!false && ( {!!false && (
<Form.Item <Form.Item
label="" label=""
style={{ width: "600px" }} style={{ width: '600px' }}
colon={false} colon={false}
name="id" name="id"
> >
<Input <Input
placeholder="" placeholder=""
style={{ width: "600px" }} style={{ width: '600px' }}
bordered={false} bordered={false}
disabled={true} disabled={true}
/> />
@ -390,20 +388,20 @@ class Test$$Page extends React.Component {
labelAlign="left" labelAlign="left"
colon={false} colon={false}
required={true} required={true}
style={{ flexDirection: "column", width: "600px" }} style={{ flexDirection: 'column', width: '600px' }}
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请选择版本类型", message: '请选择版本类型',
}} }}
> >
<Checkbox.Group <Checkbox.Group
options={[ options={[
{ label: "基础版本", value: "3" }, { label: '基础版本', value: '3' },
{ label: "AR导航", value: "1" }, { label: 'AR导航', value: '1' },
{ label: "货车导航", value: "2" }, { label: '货车导航', value: '2' },
{ label: "UI定制", value: "4", disabled: false }, { label: 'UI定制', value: '4', disabled: false },
]} ]}
style={{ width: "600px" }} style={{ width: '600px' }}
disabled={__$$eval( disabled={__$$eval(
() => () =>
this.state.customerProjectInfo.id > 0 && this.state.customerProjectInfo.id > 0 &&
@ -416,13 +414,13 @@ class Test$$Page extends React.Component {
labelAlign="left" labelAlign="left"
colon={false} colon={false}
required={true} required={true}
style={{ width: "600px" }} style={{ width: '600px' }}
name="versionLine" name="versionLine"
requiredobj={{ required: true, message: "请选择版本线" }} requiredobj={{ required: true, message: '请选择版本线' }}
extra="" extra=""
> >
<Select <Select
style={{ width: "600px" }} style={{ width: '600px' }}
options={__$$eval(() => this.state.versionLinesArray)} options={__$$eval(() => this.state.versionLinesArray)}
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -436,27 +434,27 @@ class Test$$Page extends React.Component {
label="项目名称" label="项目名称"
colon={false} colon={false}
required={true} required={true}
style={{ display: "flex" }} style={{ display: 'flex' }}
labelAlign="left" labelAlign="left"
extra="" extra=""
name="systemProjectName" name="systemProjectName"
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请按格式填写项目名称", message: '请按格式填写项目名称',
}} }}
typeobj={{ typeobj={{
type: "string", type: 'string',
message: message:
"请输入项目名称,格式:公司简称-产品名称-版本类型", '请输入项目名称,格式:公司简称-产品名称-版本类型',
}} }}
lenobj={{ lenobj={{
max: 100, max: 100,
message: "项目名称不能超过100个字符", message: '项目名称不能超过100个字符',
}} }}
> >
<Input <Input
placeholder="公司简称-产品名称-版本类型" placeholder="公司简称-产品名称-版本类型"
style={{ width: "600px" }} style={{ width: '600px' }}
disabled={__$$eval( disabled={__$$eval(
() => () =>
this.state.customerProjectInfo.id > 0 && this.state.customerProjectInfo.id > 0 &&
@ -466,18 +464,18 @@ class Test$$Page extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="预期交付时间" label="预期交付时间"
style={{ width: "600px" }} style={{ width: '600px' }}
colon={false} colon={false}
required={true} required={true}
name="expectedTime" name="expectedTime"
labelAlign="left" labelAlign="left"
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请填写预期交付时间", message: '请填写预期交付时间',
}} }}
> >
<DatePicker <DatePicker
style={{ width: "600px" }} style={{ width: '600px' }}
disabled={__$$eval( disabled={__$$eval(
() => () =>
this.state.customerProjectInfo.id > 0 && this.state.customerProjectInfo.id > 0 &&
@ -487,11 +485,11 @@ class Test$$Page extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="预期出货量" label="预期出货量"
style={{ width: "600px" }} style={{ width: '600px' }}
required={true} required={true}
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请填写预期出货量", message: '请填写预期出货量',
}} }}
name="expectedNum" name="expectedNum"
labelAlign="left" labelAlign="left"
@ -499,7 +497,7 @@ class Test$$Page extends React.Component {
> >
<InputNumber <InputNumber
value={3} value={3}
style={{ width: "600px" }} style={{ width: '600px' }}
placeholder="单位(台)使用该版本的机器数量+预计出货量,请如实填写" placeholder="单位(台)使用该版本的机器数量+预计出货量,请如实填写"
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -511,28 +509,28 @@ class Test$$Page extends React.Component {
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
wrapperCol={{ offset: "" }} wrapperCol={{ offset: '' }}
style={{ style={{
flexDirection: "row", flexDirection: 'row',
alignItems: "baseline", alignItems: 'baseline',
justifyContent: "space-between", justifyContent: 'space-between',
width: "600px", width: '600px',
display: "block", display: 'block',
}} }}
labelAlign="left" labelAlign="left"
colon={false} colon={false}
> >
<Button <Button
style={{ margin: "0px" }} style={{ margin: '0px' }}
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onClick", name: 'onClick',
relatedEventName: "onClickFirstBack", relatedEventName: 'onClickFirstBack',
}, },
], ],
eventList: [{ name: "onClick", disabled: true }], eventList: [{ name: 'onClick', disabled: true }],
}} }}
onClick={function () { onClick={function () {
this.onClickFirstBack.apply( this.onClickFirstBack.apply(
@ -547,12 +545,12 @@ class Test$$Page extends React.Component {
type="primary" type="primary"
htmlType="submit" htmlType="submit"
style={{ style={{
boxShadow: "rgba(31, 56, 88, 0.2) 0px 0px 0px 0px", boxShadow: 'rgba(31, 56, 88, 0.2) 0px 0px 0px 0px',
float: "right", float: 'right',
}} }}
__events={{ __events={{
eventDataList: [], eventDataList: [],
eventList: [{ name: "onClick", disabled: false }], eventList: [{ name: 'onClick', disabled: false }],
}} }}
> >
下一步 下一步
@ -570,7 +568,7 @@ class Test$$Page extends React.Component {
align="left" align="left"
full={true} full={true}
flex={true} flex={true}
style={{ display: "flex", justifyContent: "center" }} style={{ display: 'flex', justifyContent: 'center' }}
> >
<Form <Form
labelCol={{ span: 10 }} labelCol={{ span: 10 }}
@ -583,31 +581,31 @@ class Test$$Page extends React.Component {
}.bind(this)} }.bind(this)}
name="basic" name="basic"
style={{ style={{
display: "flex", display: 'flex',
flexDirection: "column", flexDirection: 'column',
width: "600px", width: '600px',
justifyContent: "center", justifyContent: 'center',
height: "800px", height: '800px',
}} }}
layout="vertical" layout="vertical"
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onFinish", name: 'onFinish',
relatedEventName: "onFinishSecond", relatedEventName: 'onFinishSecond',
}, },
{ {
type: "componentEvent", type: 'componentEvent',
name: "onValuesChange", name: 'onValuesChange',
relatedEventName: "onValuesChange", relatedEventName: 'onValuesChange',
}, },
], ],
eventList: [ eventList: [
{ name: "onFinish", disabled: true }, { name: 'onFinish', disabled: true },
{ name: "onFinishFailed", disabled: false }, { name: 'onFinishFailed', disabled: false },
{ name: "onFieldsChange", disabled: false }, { name: 'onFieldsChange', disabled: false },
{ name: "onValuesChange", disabled: true }, { name: 'onValuesChange', disabled: true },
], ],
}} }}
initialValues={__$$eval( initialValues={__$$eval(
@ -625,15 +623,15 @@ class Test$$Page extends React.Component {
labelAlign="left" labelAlign="left"
colon={false} colon={false}
required={true} required={true}
style={{ width: "600px" }} style={{ width: '600px' }}
name="projectModal" name="projectModal"
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请选择设备类型", message: '请选择设备类型',
}} }}
> >
<Select <Select
style={{ width: "600px" }} style={{ width: '600px' }}
options={__$$eval(() => this.state.projectModalsArray)} options={__$$eval(() => this.state.projectModalsArray)}
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -645,19 +643,19 @@ class Test$$Page extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="屏幕分辨率宽" label="屏幕分辨率宽"
style={{ width: "600px" }} style={{ width: '600px' }}
name="displayWidth" name="displayWidth"
colon={false} colon={false}
required={true} required={true}
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请输入屏幕分辨率宽", message: '请输入屏幕分辨率宽',
}} }}
labelAlign="left" labelAlign="left"
> >
<InputNumber <InputNumber
value={3} value={3}
style={{ width: "600px" }} style={{ width: '600px' }}
placeholder="例如1280" placeholder="例如1280"
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -669,19 +667,19 @@ class Test$$Page extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="屏幕分辨率高" label="屏幕分辨率高"
style={{ width: "600px" }} style={{ width: '600px' }}
labelAlign="left" labelAlign="left"
colon={false} colon={false}
name="displayHeight" name="displayHeight"
required={true} required={true}
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请输入屏幕分辨率高", message: '请输入屏幕分辨率高',
}} }}
> >
<InputNumber <InputNumber
value={3} value={3}
style={{ width: "600px" }} style={{ width: '600px' }}
placeholder="例如720" placeholder="例如720"
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -693,19 +691,19 @@ class Test$$Page extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="屏幕尺寸inch" label="屏幕尺寸inch"
style={{ width: "600px" }} style={{ width: '600px' }}
name="displayInch" name="displayInch"
labelAlign="left" labelAlign="left"
required={true} required={true}
colon={false} colon={false}
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请输入屏幕尺寸", message: '请输入屏幕尺寸',
}} }}
> >
<InputNumber <InputNumber
value={3} value={3}
style={{ width: "600px" }} style={{ width: '600px' }}
placeholder="请输入尺寸" placeholder="请输入尺寸"
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -717,7 +715,7 @@ class Test$$Page extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="屏幕DPI" label="屏幕DPI"
style={{ width: "600px" }} style={{ width: '600px' }}
labelAlign="left" labelAlign="left"
colon={false} colon={false}
required={false} required={false}
@ -725,7 +723,7 @@ class Test$$Page extends React.Component {
> >
<InputNumber <InputNumber
value={3} value={3}
style={{ width: "600px" }} style={{ width: '600px' }}
placeholder="UI定制项目必填" placeholder="UI定制项目必填"
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -739,19 +737,19 @@ class Test$$Page extends React.Component {
label="芯片名称" label="芯片名称"
colon={false} colon={false}
required={true} required={true}
style={{ display: "flex" }} style={{ display: 'flex' }}
labelAlign="left" labelAlign="left"
extra="" extra=""
name="mainSoc" name="mainSoc"
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请输入芯片名称", message: '请输入芯片名称',
}} }}
lenobj={{ max: 50, message: "芯片名称不能超过50个字符" }} lenobj={{ max: 50, message: '芯片名称不能超过50个字符' }}
> >
<Input <Input
placeholder="请输入芯片名称" placeholder="请输入芯片名称"
style={{ width: "600px" }} style={{ width: '600px' }}
disabled={__$$eval( disabled={__$$eval(
() => () =>
this.state.customerProjectInfo.id > 0 && this.state.customerProjectInfo.id > 0 &&
@ -761,11 +759,11 @@ class Test$$Page extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="芯片核数" label="芯片核数"
style={{ width: "600px" }} style={{ width: '600px' }}
required={true} required={true}
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请输入芯片核数", message: '请输入芯片核数',
}} }}
name="cpuCoreNum" name="cpuCoreNum"
labelAlign="left" labelAlign="left"
@ -773,7 +771,7 @@ class Test$$Page extends React.Component {
> >
<InputNumber <InputNumber
value={3} value={3}
style={{ width: "600px" }} style={{ width: '600px' }}
placeholder="请输入芯片核数" placeholder="请输入芯片核数"
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -786,14 +784,14 @@ class Test$$Page extends React.Component {
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="指令集" label="指令集"
style={{ width: "600px" }} style={{ width: '600px' }}
required={true} required={true}
requiredobj={{ required: true, message: "请选择指令集" }} requiredobj={{ required: true, message: '请选择指令集' }}
name="instructions" name="instructions"
colon={false} colon={false}
> >
<Select <Select
style={{ width: "600px" }} style={{ width: '600px' }}
options={__$$eval(() => this.state.instructionsArray)} options={__$$eval(() => this.state.instructionsArray)}
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -807,15 +805,15 @@ class Test$$Page extends React.Component {
labelAlign="left" labelAlign="left"
colon={false} colon={false}
required={true} required={true}
style={{ width: "600px" }} style={{ width: '600px' }}
name="osVersion" name="osVersion"
requiredobj={{ requiredobj={{
required: true, required: true,
message: "请选择系统版本", message: '请选择系统版本',
}} }}
> >
<Select <Select
style={{ width: "600px" }} style={{ width: '600px' }}
options={__$$eval(() => this.state.osVersionsArray)} options={__$$eval(() => this.state.osVersionsArray)}
disabled={__$$eval( disabled={__$$eval(
() => () =>
@ -826,24 +824,24 @@ class Test$$Page extends React.Component {
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
wrapperCol={{ offset: "" }} wrapperCol={{ offset: '' }}
style={{ style={{
flexDirection: "row", flexDirection: 'row',
width: "600px", width: '600px',
display: "flex", display: 'flex',
}} }}
> >
<Button <Button
style={{ marginLeft: "0" }} style={{ marginLeft: '0' }}
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onClick", name: 'onClick',
relatedEventName: "onClickSecondBack", relatedEventName: 'onClickSecondBack',
}, },
], ],
eventList: [{ name: "onClick", disabled: true }], eventList: [{ name: 'onClick', disabled: true }],
}} }}
onClick={function () { onClick={function () {
this.onClickSecondBack.apply( this.onClickSecondBack.apply(
@ -857,7 +855,7 @@ class Test$$Page extends React.Component {
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
style={{ float: "right", marginLeft: "20px" }} style={{ float: 'right', marginLeft: '20px' }}
loading={__$$eval( loading={__$$eval(
() => () =>
this.state.LOADING_ADD_OR_UPDATE_CUSTOMER_PROJECT this.state.LOADING_ADD_OR_UPDATE_CUSTOMER_PROJECT
@ -868,16 +866,16 @@ class Test$$Page extends React.Component {
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
style={{ marginLeft: "0px", float: "right" }} style={{ marginLeft: '0px', float: 'right' }}
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onClick", name: 'onClick',
relatedEventName: "onClickPreSecond", relatedEventName: 'onClickPreSecond',
}, },
], ],
eventList: [{ name: "onClick", disabled: true }], eventList: [{ name: 'onClick', disabled: true }],
}} }}
onClick={function () { onClick={function () {
this.onClickPreSecond.apply( this.onClickPreSecond.apply(
@ -901,7 +899,7 @@ class Test$$Page extends React.Component {
align="left" align="left"
full={true} full={true}
flex={true} flex={true}
style={{ display: "flex", justifyContent: "center" }} style={{ display: 'flex', justifyContent: 'center' }}
> >
<Form <Form
labelCol={{ span: 10 }} labelCol={{ span: 10 }}
@ -914,25 +912,25 @@ class Test$$Page extends React.Component {
}.bind(this)} }.bind(this)}
name="basic" name="basic"
style={{ style={{
display: "flex", display: 'flex',
flexDirection: "column", flexDirection: 'column',
width: "600px", width: '600px',
justifyContent: "center", justifyContent: 'center',
}} }}
layout="vertical" layout="vertical"
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onFinishFailed", name: 'onFinishFailed',
relatedEventName: "onFinishFailed", relatedEventName: 'onFinishFailed',
}, },
], ],
eventList: [ eventList: [
{ name: "onFinish", disabled: false }, { name: 'onFinish', disabled: false },
{ name: "onFinishFailed", disabled: true }, { name: 'onFinishFailed', disabled: true },
{ name: "onFieldsChange", disabled: false }, { name: 'onFieldsChange', disabled: false },
{ name: "onValuesChange", disabled: false }, { name: 'onValuesChange', disabled: false },
], ],
}} }}
> >
@ -940,11 +938,11 @@ class Test$$Page extends React.Component {
<Steps <Steps
current={1} current={1}
style={{ style={{
width: "600px", width: '600px',
display: "flex", display: 'flex',
justifyContent: "space-around", justifyContent: 'space-around',
alignItems: "center", alignItems: 'center',
height: "300px", height: '300px',
}} }}
labelPlacement="horizontal" labelPlacement="horizontal"
direction="vertical" direction="vertical"
@ -952,35 +950,35 @@ class Test$$Page extends React.Component {
<Steps.Step <Steps.Step
title="提交完成" title="提交完成"
description="" description=""
style={{ width: "200px" }} style={{ width: '200px' }}
/> />
<Steps.Step <Steps.Step
title={__$$eval(() => this.state.thirdAuditText)} title={__$$eval(() => this.state.thirdAuditText)}
subTitle="" subTitle=""
description="" description=""
style={{ width: "200px" }} style={{ width: '200px' }}
/> />
</Steps> </Steps>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
wrapperCol={{ offset: "" }} wrapperCol={{ offset: '' }}
style={{ style={{
flexDirection: "row", flexDirection: 'row',
width: "600px", width: '600px',
display: "flex", display: 'flex',
}} }}
> >
<Button <Button
style={{ marginLeft: "0" }} style={{ marginLeft: '0' }}
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onClick", name: 'onClick',
relatedEventName: "onClickThirdBack", relatedEventName: 'onClickThirdBack',
}, },
], ],
eventList: [{ name: "onClick", disabled: true }], eventList: [{ name: 'onClick', disabled: true }],
}} }}
onClick={function () { onClick={function () {
this.onClickThirdBack.apply( this.onClickThirdBack.apply(
@ -994,16 +992,16 @@ class Test$$Page extends React.Component {
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
style={{ float: "right", marginLeft: "20px" }} style={{ float: 'right', marginLeft: '20px' }}
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onClick", name: 'onClick',
relatedEventName: "onClickModifyThird", relatedEventName: 'onClickModifyThird',
}, },
], ],
eventList: [{ name: "onClick", disabled: true }], eventList: [{ name: 'onClick', disabled: true }],
}} }}
onClick={function () { onClick={function () {
this.onClickModifyThird.apply( this.onClickModifyThird.apply(
@ -1020,16 +1018,16 @@ class Test$$Page extends React.Component {
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
style={{ marginLeft: "0px", float: "right" }} style={{ marginLeft: '0px', float: 'right' }}
__events={{ __events={{
eventDataList: [ eventDataList: [
{ {
type: "componentEvent", type: 'componentEvent',
name: "onClick", name: 'onClick',
relatedEventName: "onClickPreThird", relatedEventName: 'onClickPreThird',
}, },
], ],
eventList: [{ name: "onClick", disabled: true }], eventList: [{ name: 'onClick', disabled: true }],
}} }}
onClick={function () { onClick={function () {
this.onClickPreThird.apply( this.onClickPreThird.apply(

View File

@ -1,14 +1,14 @@
import Test from "@/pages/Test"; import Test from '@/pages/Test';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "", path: '',
component: Test, component: Test,
}, },
], ],

View File

@ -1,4 +1,4 @@
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -11,8 +11,8 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-http-handler": "latest", "@alilc/lowcode-datasource-http-handler": "^1.0.0",
"@alilc/lowcode-components": "^1.0.0" "@alilc/lowcode-components": "^1.0.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

View File

@ -1,5 +1,5 @@
// 引入默认全局样式 // 引入默认全局样式
@import "@alifd/next/reset.scss"; @import '@alifd/next/reset.scss';
body { body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -1,9 +1,9 @@
const i18nConfig = {}; const i18nConfig = {};
let locale = let locale =
typeof navigator === "object" && typeof navigator.language === "string" typeof navigator === 'object' && typeof navigator.language === 'string'
? navigator.language ? navigator.language
: "zh-CN"; : 'zh-CN';
const getLocale = () => locale; const getLocale = () => locale;
@ -13,22 +13,22 @@ const setLocale = (target) => {
const isEmptyVariables = (variables) => const isEmptyVariables = (variables) =>
(Array.isArray(variables) && variables.length === 0) || (Array.isArray(variables) && variables.length === 0) ||
(typeof variables === "object" && (typeof variables === 'object' &&
(!variables || Object.keys(variables).length === 0)); (!variables || Object.keys(variables).length === 0));
// 按低代码规范里面的要求进行变量替换 // 按低代码规范里面的要求进行变量替换
const format = (msg, variables) => const format = (msg, variables) =>
typeof msg === "string" typeof msg === 'string'
? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? "") ? msg.replace(/\$\{(\w+)\}/g, (match, key) => variables?.[key] ?? '')
: msg; : msg;
const i18nFormat = ({ id, defaultMessage, fallback }, variables) => { const i18nFormat = ({ id, defaultMessage, fallback }, variables) => {
const msg = const msg =
i18nConfig[locale]?.[id] ?? i18nConfig[locale]?.[id] ??
i18nConfig[locale.replace("-", "_")]?.[id] ?? i18nConfig[locale.replace('-', '_')]?.[id] ??
defaultMessage; defaultMessage;
if (msg == null) { if (msg == null) {
console.warn("[i18n]: unknown message id: %o (locale=%o)", id, locale); console.warn('[i18n]: unknown message id: %o (locale=%o)', id, locale);
return fallback === undefined ? `${id}` : fallback; return fallback === undefined ? `${id}` : fallback;
} }
@ -49,7 +49,7 @@ const _inject2 = (target) => {
}; };
target._i18nText = (t) => { target._i18nText = (t) => {
// 优先取直接传过来的语料 // 优先取直接传过来的语料
const localMsg = t[locale] ?? t[String(locale).replace("-", "_")]; const localMsg = t[locale] ?? t[String(locale).replace('-', '_')];
if (localMsg != null) { if (localMsg != null) {
return format(localMsg, t.params); return format(localMsg, t.params);
} }
@ -61,7 +61,7 @@ const _inject2 = (target) => {
} }
// 兜底用 use 指定的或默认语言的 // 兜底用 use 指定的或默认语言的
return format(t[t.use || "zh-CN"] ?? t.en_US, t.params); return format(t[t.use || 'zh-CN'] ?? t.en_US, t.params);
}; };
// 注入到上下文中去 // 注入到上下文中去

View File

@ -1,20 +1,20 @@
// : "__$$" 访 // : "__$$" 访
// react // react
import React from "react"; import React from 'react';
import { Page, Table } from "@alilc/lowcode-components"; import { Page, Table } from '@alilc/lowcode-components';
import { createHttpHandler as __$$createHttpRequestHandler } from "@alilc/lowcode-datasource-http-handler"; import { createHttpHandler as __$$createHttpRequestHandler } from '@alilc/lowcode-datasource-http-handler';
import { create as __$$createDataSourceEngine } from "@alilc/lowcode-datasource-engine/runtime"; import { create as __$$createDataSourceEngine } from '@alilc/lowcode-datasource-engine/runtime';
import utils from "../../utils"; import utils from '../../utils';
import * as __$$i18n from "../../i18n"; import * as __$$i18n from '../../i18n';
import __$$constants from "../../constants"; import __$$constants from '../../constants';
import "./index.css"; import './index.css';
class Example$$Page extends React.Component { class Example$$Page extends React.Component {
_context = this; _context = this;
@ -56,12 +56,12 @@ class Example$$Page extends React.Component {
return { return {
list: [ list: [
{ {
id: "userList", id: 'userList',
type: "http", type: 'http',
description: "用户列表", description: '用户列表',
options: function () { options: function () {
return { return {
uri: "https://api.example.com/user/list", uri: 'https://api.example.com/user/list',
}; };
}, },
isInit: function () { isInit: function () {
@ -82,10 +82,10 @@ class Example$$Page extends React.Component {
return ( return (
<div> <div>
<Table <Table
dataSource={__$$eval(() => this.dataSourceMap["userList"])} dataSource={__$$eval(() => this.dataSourceMap['userList'])}
columns={[ columns={[
{ dataIndex: "name", title: "姓名" }, { dataIndex: 'name', title: '姓名' },
{ dataIndex: "age", title: "年龄" }, { dataIndex: 'age', title: '年龄' },
]} ]}
/> />
</div> </div>

View File

@ -1,14 +1,14 @@
import Example from "@/pages/Example"; import Example from '@/pages/Example';
import BasicLayout from "@/layouts/BasicLayout"; import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [ const routerConfig = [
{ {
path: "/", path: '/',
component: BasicLayout, component: BasicLayout,
children: [ children: [
{ {
path: "", path: '',
component: Example, component: Example,
}, },
], ],

View File

@ -1,4 +1,4 @@
import { createRef } from "react"; import { createRef } from 'react';
export class RefsManager { export class RefsManager {
constructor() { constructor() {

View File

@ -11,8 +11,8 @@
"intl-messageformat": "^9.3.6", "intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3", "@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-datasource-jsonp-handler": "latest", "@alilc/lowcode-datasource-jsonp-handler": "^1.0.0",
"@alifd/next": "1.19.18" "@alifd/next": "1.19.18"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,11 +1,11 @@
import { createApp } from "ice"; import { createApp } from 'ice';
const appConfig = { const appConfig = {
app: { app: {
rootId: "app", rootId: 'app',
}, },
router: { router: {
type: "hash", type: 'hash',
}, },
}; };
createApp(appConfig); createApp(appConfig);

Some files were not shown because too many files have changed in this diff Show More