From 4a01c97ea6bf23eb677888ba1aba54e5c9f4f630 Mon Sep 17 00:00:00 2001 From: Clarence Pan Date: Tue, 8 Mar 2022 12:51:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=87=BA=E7=A0=81?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98=20(#87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 修正一些示例地址 * chore: update release scripts * chore(release): 1.0.1 --- modules/code-generator/.gitignore | 4 + modules/code-generator/CHANGELOG.md | 26 + modules/code-generator/README.md | 2 +- modules/code-generator/example-schema.json | 6 +- modules/code-generator/example-schema.json5 | 6 +- modules/code-generator/package.json | 5 +- .../src/cli/solutions/example-solution.ts | 8 +- .../framework/icejs/plugins/packageJSON.ts | 2 +- .../rax/types/RaxFrameworkOptions.ts | 1 - .../code-generator/src/utils/jsExpression.ts | 2 - .../demo-project/src/pages/Home/index.jsx | 2 +- .../test-cases/rax-app/demo02/schema.json5 | 6 +- .../demo11-utils-name-alias/schema.json5 | 72 - .../demo1/expected/demo-project/package.json | 2 +- .../expected/demo-project/src/constants.js | 2 +- .../demo-project/src/pages/Test/index.jsx | 4 +- .../test-cases/react-app/demo1/schema.json5 | 10 +- .../expected/demo-project/package.json | 2 +- .../demo2-utils-name-alias/schema.json5 | 72 - .../demo2/expected/demo-project/package.json | 2 +- .../expected/demo-project/src/constants.js | 2 +- .../test-cases/react-app/demo2/schema.json5 | 2 +- .../demo3/expected/demo-project/package.json | 2 +- .../expected/demo-project/src/constants.js | 2 +- .../test-cases/react-app/demo3/schema.json5 | 2 +- .../demo4/expected/demo-project/package.json | 2 +- .../demo-project/src/pages/Test/index.jsx | 2 +- .../test-cases/react-app/demo4/schema.json5 | 4 +- .../demo5/expected/demo-project/package.json | 2 +- .../demo-project/src/pages/Test/index.jsx | 116 +- .../test-cases/react-app/demo5/schema.json5 | 1160 ++++++++--------- .../expected/demo-project/package.json | 2 +- .../expected/demo-project/src/constants.js | 2 +- .../demo-project/src/pages/Test/index.jsx | 4 +- .../demo6-literal-condition/schema.json5 | 10 +- .../expected/demo-project/package.json | 2 +- .../demo-project/src/pages/Test/index.jsx | 286 +--- .../demo7-literal-condition2/schema.json5 | 20 +- .../expected/demo-project/package.json | 2 +- .../expected/demo-project/package.json | 2 +- .../expected/demo-project/package.json | 2 +- .../demo-project/src/pages/Test/index.jsx | 206 +-- .../react-app/demo_10-jsslot/schema.json5 | 18 +- .../expected/demo-project/package.json | 2 +- .../demo-project/src/pages/Test/index.jsx | 345 +---- .../react-app/demo_11-jsslot-2/schema.json5 | 38 +- .../demo1/expected/demo-project/package.json | 2 +- .../expected/demo-project/src/constants.js | 2 +- .../react-module/demo1/schema.json5 | 8 +- .../bugfix/icejs-js-function1.schema.json | 26 +- .../icejs-missing-imports-1.schema.json | 38 +- .../SchemaParser/data/schema-with-slot.json | 54 +- .../utils/schema/data/schema-with-slot.json | 52 +- 53 files changed, 855 insertions(+), 1800 deletions(-) diff --git a/modules/code-generator/.gitignore b/modules/code-generator/.gitignore index b233ed9b3..ec49a4955 100644 --- a/modules/code-generator/.gitignore +++ b/modules/code-generator/.gitignore @@ -111,3 +111,7 @@ codealike.json # types /types + +# backup files +*.bak + diff --git a/modules/code-generator/CHANGELOG.md b/modules/code-generator/CHANGELOG.md index dc960f958..4f8603792 100644 --- a/modules/code-generator/CHANGELOG.md +++ b/modules/code-generator/CHANGELOG.md @@ -2,6 +2,32 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.0.1](https://github.com/alibaba/lowcode-engine/compare/@alilc/lowcode-code-generator@1.0.0...@alilc/lowcode-code-generator@1.0.1) (2022-03-08) + + +### Features + +* 在 skeleton 增加几个方法和事件 ([a7d436a](https://github.com/alibaba/lowcode-engine/commit/a7d436a0525a0ce0c7229710077111f283b452f4)) +* modify npm private control & version ([ee55d02](https://github.com/alibaba/lowcode-engine/commit/ee55d024a7f964ccf35a0efabec817364cea8041)) +* modify yuque link in README ([d522034](https://github.com/alibaba/lowcode-engine/commit/d522034879d20a7b5ed12f8fe02a30662a2ea7c6)) +* remove CHANGELOG.md ([b996414](https://github.com/alibaba/lowcode-engine/commit/b996414c436b5d2439c8368eb4e001cdbcd02892)) +* remove module field in material-parser package.json ([6141c27](https://github.com/alibaba/lowcode-engine/commit/6141c273c9c32eea22b5374679fe625e6ea15394)) +* rename build:umd ([23c7959](https://github.com/alibaba/lowcode-engine/commit/23c795931e1d5cf43e9c21cd902441c69c1ecc63)) +* replace tnpm with npm ([36caf0f](https://github.com/alibaba/lowcode-engine/commit/36caf0f18980c16f7ebb82ac845ad6b33e033567)) +* support UMD packageing for react-renderer ([982d0d6](https://github.com/alibaba/lowcode-engine/commit/982d0d676b3dfbfc10a2190c0040126d6925ed37)) + + +### Bug Fixes + +* 🐛 修正一些示例地址 ([8d21283](https://github.com/alibaba/lowcode-engine/commit/8d212832e77a1ec763db668683917705774acd0d)) +* 兼容 setters 为空的情况 ([56b459a](https://github.com/alibaba/lowcode-engine/commit/56b459a017a8350a911ef20f0166d1e62b6390e4)) +* 修复 setup 的逻辑 ([1cfb15a](https://github.com/alibaba/lowcode-engine/commit/1cfb15aebea9796af23b2135f2aa4409d81283d7)) +* 修正一些对内的地址 ([07cc1f2](https://github.com/alibaba/lowcode-engine/commit/07cc1f2954530c64a1a3d260e8d532c9e19892e8)) +* 增加必要的方法 ([1b38a81](https://github.com/alibaba/lowcode-engine/commit/1b38a812653656aa02100a3b1b2a581188d1b3ef)) +* fix tsconfig of material-parser ([46725cb](https://github.com/alibaba/lowcode-engine/commit/46725cb9f3166912c8f5b42f1e0b1177158c1ee3)) +* lint&fix auto generated types.ts ([7dde970](https://github.com/alibaba/lowcode-engine/commit/7dde9701c7960b29523abddf32421cdbac47016d)) +* The outline tree does not display the loop flag when the loop is an empty array ([191e284](https://github.com/alibaba/lowcode-engine/commit/191e284f2fa190c2b3aecb4df31849b2bdc99d38)) + ## 1.0.0 (2022-02-17) diff --git a/modules/code-generator/README.md b/modules/code-generator/README.md index be661559a..03ce94b54 100644 --- a/modules/code-generator/README.md +++ b/modules/code-generator/README.md @@ -110,4 +110,4 @@ console.log(result); // 出码结果(默认是递归结构描述的,可以传 ## 参与共建 -欢迎参与共建,如何共建请参阅:[./CONTRIBUTING.md](https://code.aone.alibaba-inc.com/ali-lowcode/code-generator/blob/develop/CONTRIBUTING.md) +欢迎参与共建,如何共建请参阅:[./CONTRIBUTING.md](https://github.com/alibaba/lowcode-engine/blob/main/modules/code-generator/CONTRIBUTING.md) diff --git a/modules/code-generator/example-schema.json b/modules/code-generator/example-schema.json index bdcfd7399..aaf3a3e0d 100644 --- a/modules/code-generator/example-schema.json +++ b/modules/code-generator/example-schema.json @@ -87,7 +87,7 @@ "type": "fetch", "options": { "method": "GET", - "uri": "https://shs.alibaba-inc.com/mock/1458/demo/user", + "uri": "https://shs.xxx.com/mock/1458/demo/user", "isSync": true }, "dataHandler": { @@ -101,7 +101,7 @@ "type": "fetch", "options": { "method": "GET", - "uri": "https://shs.alibaba-inc.com/mock/1458/demo/orders", + "uri": "https://shs.xxx.com/mock/1458/demo/orders", "isSync": true }, "dataHandler": { @@ -245,7 +245,7 @@ ], "constants": { "ENV": "prod", - "DOMAIN": "xxx.alibaba-inc.com" + "DOMAIN": "xxx.xxx.com" }, "css": "body {font-size: 12px;} .table { width: 100px;}", "config": { diff --git a/modules/code-generator/example-schema.json5 b/modules/code-generator/example-schema.json5 index 1c9e6641c..f71096fc4 100644 --- a/modules/code-generator/example-schema.json5 +++ b/modules/code-generator/example-schema.json5 @@ -87,7 +87,7 @@ type: 'fetch', options: { method: 'GET', - uri: 'https://shs.alibaba-inc.com/mock/1458/demo/user', + uri: 'https://shs.xxx.com/mock/1458/demo/user', isSync: true, }, dataHandler: { @@ -101,7 +101,7 @@ type: 'fetch', options: { method: 'GET', - uri: 'https://shs.alibaba-inc.com/mock/1458/demo/orders', + uri: 'https://shs.xxx.com/mock/1458/demo/orders', isSync: true, }, dataHandler: { @@ -245,7 +245,7 @@ ], constants: { ENV: 'prod', - DOMAIN: 'xxx.alibaba-inc.com', + DOMAIN: 'xxx.xxx.com', }, css: 'body {font-size: 12px;} .table { width: 100px;}', config: { diff --git a/modules/code-generator/package.json b/modules/code-generator/package.json index e79d359e8..df2b9a46d 100644 --- a/modules/code-generator/package.json +++ b/modules/code-generator/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-code-generator", - "version": "1.0.0", + "version": "1.0.1", "description": "出码引擎 for LowCode Engine", "license": "MIT", "main": "lib/index.js", @@ -42,7 +42,8 @@ "test:update-snapshots": "cross-env UPDATE_EXPECTED=true jest -u", "analyze:standalone": "ANALYZE=true node scripts/build-standalone", "release:beta": "standard-version -t @alilc/lowcode-code-generator\\@ --prerelease beta && git push --follow-tags && npm publish --tag beta", - "release": "standard-version -t @alilc/lowcode-code-generator\\@ && git push --follow-tags && npm publish", + "release:patch": "standard-version -t @alilc/lowcode-code-generator\\@ -r patch && git push --follow-tags && npm publish", + "release:minor": "standard-version -t @alilc/lowcode-code-generator\\@ -r minor && git push --follow-tags && npm publish", "prepublishOnly": "npm run build", "demo": "node bin/lowcode-code-generator.js -i example-schema.json -o demo -s icejs" }, diff --git a/modules/code-generator/src/cli/solutions/example-solution.ts b/modules/code-generator/src/cli/solutions/example-solution.ts index 40fc265dd..df87c9f97 100644 --- a/modules/code-generator/src/cli/solutions/example-solution.ts +++ b/modules/code-generator/src/cli/solutions/example-solution.ts @@ -309,7 +309,7 @@ codealike.json "type": "fetch", "options": { "method": "GET", - "uri": "https://shs.alibaba-inc.com/mock/1458/demo/user", + "uri": "https://shs.xxx.com/mock/1458/demo/user", "isSync": true }, "dataHandler": { @@ -323,7 +323,7 @@ codealike.json "type": "fetch", "options": { "method": "GET", - "uri": "https://shs.alibaba-inc.com/mock/1458/demo/orders", + "uri": "https://shs.xxx.com/mock/1458/demo/orders", "isSync": true }, "dataHandler": { @@ -467,7 +467,7 @@ codealike.json ], "constants": { "ENV": "prod", - "DOMAIN": "xxx.alibaba-inc.com" + "DOMAIN": "xxx.xxx.com" }, "css": "body {font-size: 12px;} .table { width: 100px;}", "config": { @@ -556,7 +556,7 @@ codealike.json "author": "", "license": "ISC", "publishConfig": { - "registry": "https://registry.npm.alibaba-inc.com" + "registry": "https://registry.npm.xxx.com" }, "dependencies": { "@alilc/lowcode-code-generator": "^1.0.0-beta.16", diff --git a/modules/code-generator/src/plugins/project/framework/icejs/plugins/packageJSON.ts b/modules/code-generator/src/plugins/project/framework/icejs/plugins/packageJSON.ts index 8c9bd95d7..e76b423e0 100644 --- a/modules/code-generator/src/plugins/project/framework/icejs/plugins/packageJSON.ts +++ b/modules/code-generator/src/plugins/project/framework/icejs/plugins/packageJSON.ts @@ -75,7 +75,7 @@ const pluginFactory: BuilderComponentPluginFactory = () => { }, repository: { type: 'git', - url: 'http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master', + url: 'http://gitlab.xxx.com/msd/leak-scan/tree/master', }, private: true, originTemplate: '@alifd/scaffold-lite-js', diff --git a/modules/code-generator/src/plugins/project/framework/rax/types/RaxFrameworkOptions.ts b/modules/code-generator/src/plugins/project/framework/rax/types/RaxFrameworkOptions.ts index 2a67231c9..5e5a01b4d 100644 --- a/modules/code-generator/src/plugins/project/framework/rax/types/RaxFrameworkOptions.ts +++ b/modules/code-generator/src/plugins/project/framework/rax/types/RaxFrameworkOptions.ts @@ -16,7 +16,6 @@ export type RaxFrameworkOptions = { /** * 构建配置 - * @see https://rax.alibaba-inc.com/docs/guide/build-config */ buildConfig?: { inlineStyle?: boolean | { forceEnableCSS: boolean }; diff --git a/modules/code-generator/src/utils/jsExpression.ts b/modules/code-generator/src/utils/jsExpression.ts index edd3556ce..73a8ab649 100644 --- a/modules/code-generator/src/utils/jsExpression.ts +++ b/modules/code-generator/src/utils/jsExpression.ts @@ -6,8 +6,6 @@ import { JSExpression, JSFunction, isJSExpression, isJSFunction } from '@alilc/l import { CodeGeneratorError, IScope } from '../types'; import { transformExpressionLocalRef, ParseError } from './expressionParser'; -// demo: https://riddle.alibaba-inc.com/riddles/3d4c977f - function parseFunction(content: string): t.FunctionExpression | null { try { const ast = parser.parse(`(${content});`); diff --git a/modules/code-generator/test-cases/rax-app/demo02/expected/demo-project/src/pages/Home/index.jsx b/modules/code-generator/test-cases/rax-app/demo02/expected/demo-project/src/pages/Home/index.jsx index 0c1443200..b3c234b27 100644 --- a/modules/code-generator/test-cases/rax-app/demo02/expected/demo-project/src/pages/Home/index.jsx +++ b/modules/code-generator/test-cases/rax-app/demo02/expected/demo-project/src/pages/Home/index.jsx @@ -248,7 +248,7 @@ class Home$$Page extends Component { options: function () { return { method: 'GET', - uri: 'https://shs.alibaba-inc.com/mock/1458/demo/user', + uri: 'https://shs.xxx.com/mock/1458/demo/user', isSync: true, }; }, diff --git a/modules/code-generator/test-cases/rax-app/demo02/schema.json5 b/modules/code-generator/test-cases/rax-app/demo02/schema.json5 index a9f5813cd..fa39cdb45 100644 --- a/modules/code-generator/test-cases/rax-app/demo02/schema.json5 +++ b/modules/code-generator/test-cases/rax-app/demo02/schema.json5 @@ -78,13 +78,13 @@ id: 'urlParams', type: 'urlParams', }, - // 示例数据源:https://shs.alibaba-inc.com/mock/1458/demo/user + // 示例数据源:https://shs.xxx.com/mock/1458/demo/user { id: 'user', type: 'fetch', options: { method: 'GET', - uri: 'https://shs.alibaba-inc.com/mock/1458/demo/user', + uri: 'https://shs.xxx.com/mock/1458/demo/user', isSync: true, }, dataHandler: { @@ -92,7 +92,7 @@ value: 'function (response) {\nif (!response.success){\n throw new Error(response.message);\n }\n return response.data;\n}', }, }, - // 示例数据源:https://shs.alibaba-inc.com/mock/1458/demo/orders + // 示例数据源:https://shs.xxx.com/mock/1458/demo/orders { id: 'orders', type: 'fetch', diff --git a/modules/code-generator/test-cases/rax-app/demo11-utils-name-alias/schema.json5 b/modules/code-generator/test-cases/rax-app/demo11-utils-name-alias/schema.json5 index d7e92775d..1d0f64fbe 100644 --- a/modules/code-generator/test-cases/rax-app/demo11-utils-name-alias/schema.json5 +++ b/modules/code-generator/test-cases/rax-app/demo11-utils-name-alias/schema.json5 @@ -133,76 +133,4 @@ spma: 'spmademo', creator: '张三', }, - b6ExtAttrs: { - externals: [ - { - name: 'moment', - jsUrl: 'https://g.alicdn.com/code/lib/moment.js/2.29.1/moment-with-locales.min.js', - }, - { - name: '@alilc/b6-setters', - jsUrl: 'https://build-success.oss-cn-hangzhou.aliyuncs.com/bundle/umd-pkg/default/library/%40ali/b6-setters/0.1.15.js', - }, - { - name: 'shallowequal', - jsUrl: 'https://build-success.oss-cn-hangzhou.aliyuncs.com/bundle/umd-pkg/default/library/shallowequal/1.1.0.js', - }, - { - name: 'tslib', - jsUrl: 'https://build-success.oss-cn-hangzhou.aliyuncs.com/bundle/umd-pkg/default/library/tslib/2.1.0.js', - }, - { - name: 'antd', - jsUrl: 'https://g.alicdn.com/code/lib/antd/3.26.15/antd-with-locales.min.js', - cssUrl: 'https://g.alicdn.com/code/lib/antd/3.26.15/antd.min.css', - }, - { - name: 'lodash', - jsUrl: 'https://g.alicdn.com/code/lib/lodash.js/4.17.20/lodash.min.js', - }, - ], - utils: [ - { - name: 'message', - type: 'npm', - content: { - package: 'antd', - version: '3.x', - destructuring: true, - exportName: 'message', - }, - }, - { - name: 'modal', - type: 'npm', - content: { - package: 'antd', - version: '3.x', - destructuring: true, - exportName: 'Modal', - }, - }, - { - name: 'legaoBuiltin', - type: 'npm', - content: { - exportName: 'legaoBuiltin', - package: '@alilc/b6-compact-legao-builtin', - version: '1.x', - }, - }, - { - name: 'mocks', - type: 'npm', - content: { - package: '@alilc/b6-util-mocks', - version: '1.x', - exportName: 'mocks', - destructuring: true, - }, - }, - ], - routerType: 'memory', - routerExact: true, - }, } diff --git a/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/package.json index 69f73ca4b..485c3422a 100644 --- a/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/package.json @@ -36,7 +36,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/src/constants.js b/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/src/constants.js index 4742ed117..c4a5859ee 100644 --- a/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/src/constants.js +++ b/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/src/constants.js @@ -1,3 +1,3 @@ -const __$$constants = { ENV: "prod", DOMAIN: "xxx.alibaba-inc.com" }; +const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; export default __$$constants; diff --git a/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/src/pages/Test/index.jsx b/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/src/pages/Test/index.jsx index 8ece6246a..32a5fbc94 100644 --- a/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/src/pages/Test/index.jsx +++ b/modules/code-generator/test-cases/react-app/demo1/expected/demo-project/src/pages/Test/index.jsx @@ -70,7 +70,7 @@ class Test$$Page extends React.Component { options: function () { return { method: "GET", - uri: "https://shs.alibaba-inc.com/mock/1458/demo/user", + uri: "https://shs.xxx.com/mock/1458/demo/user", isSync: true, }; }, @@ -91,7 +91,7 @@ class Test$$Page extends React.Component { options: function () { return { method: "GET", - uri: "https://shs.alibaba-inc.com/mock/1458/demo/orders", + uri: "https://shs.xxx.com/mock/1458/demo/orders", isSync: true, }; }, diff --git a/modules/code-generator/test-cases/react-app/demo1/schema.json5 b/modules/code-generator/test-cases/react-app/demo1/schema.json5 index a92c5f6c9..5a1cfc4d9 100644 --- a/modules/code-generator/test-cases/react-app/demo1/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo1/schema.json5 @@ -81,13 +81,13 @@ id: 'urlParams', type: 'urlParams', }, - // 示例数据源:https://shs.alibaba-inc.com/mock/1458/demo/user + // 示例数据源:https://shs.xxx.com/mock/1458/demo/user { id: 'user', type: 'fetch', options: { method: 'GET', - uri: 'https://shs.alibaba-inc.com/mock/1458/demo/user', + uri: 'https://shs.xxx.com/mock/1458/demo/user', isSync: true, }, dataHandler: { @@ -95,13 +95,13 @@ value: 'function (response) {\nif (!response.data.success){\n throw new Error(response.data.message);\n }\n return response.data.data;\n}', }, }, - // 示例数据源:https://shs.alibaba-inc.com/mock/1458/demo/orders + // 示例数据源:https://shs.xxx.com/mock/1458/demo/orders { id: 'orders', type: 'fetch', options: { method: 'GET', - uri: "https://shs.alibaba-inc.com/mock/1458/demo/orders", + uri: "https://shs.xxx.com/mock/1458/demo/orders", isSync: true, }, dataHandler: { @@ -245,7 +245,7 @@ ], "constants": { "ENV": "prod", - "DOMAIN": "xxx.alibaba-inc.com" + "DOMAIN": "xxx.xxx.com" }, "css": "body {font-size: 12px;} .table { width: 100px;}", "config": { diff --git a/modules/code-generator/test-cases/react-app/demo2-utils-name-alias/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo2-utils-name-alias/expected/demo-project/package.json index cc5b8c8ce..304d1033c 100644 --- a/modules/code-generator/test-cases/react-app/demo2-utils-name-alias/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo2-utils-name-alias/expected/demo-project/package.json @@ -40,7 +40,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo2-utils-name-alias/schema.json5 b/modules/code-generator/test-cases/react-app/demo2-utils-name-alias/schema.json5 index 625b1fe4e..76e8248cb 100644 --- a/modules/code-generator/test-cases/react-app/demo2-utils-name-alias/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo2-utils-name-alias/schema.json5 @@ -120,76 +120,4 @@ spma: 'spmademo', creator: '张三', }, - b6ExtAttrs: { - externals: [ - { - name: 'moment', - jsUrl: 'https://g.alicdn.com/code/lib/moment.js/2.29.1/moment-with-locales.min.js', - }, - { - name: '@alilc/b6-setters', - jsUrl: 'https://build-success.oss-cn-hangzhou.aliyuncs.com/bundle/umd-pkg/default/library/%40ali/b6-setters/0.1.15.js', - }, - { - name: 'shallowequal', - jsUrl: 'https://build-success.oss-cn-hangzhou.aliyuncs.com/bundle/umd-pkg/default/library/shallowequal/1.1.0.js', - }, - { - name: 'tslib', - jsUrl: 'https://build-success.oss-cn-hangzhou.aliyuncs.com/bundle/umd-pkg/default/library/tslib/2.1.0.js', - }, - { - name: 'antd', - jsUrl: 'https://g.alicdn.com/code/lib/antd/3.26.15/antd-with-locales.min.js', - cssUrl: 'https://g.alicdn.com/code/lib/antd/3.26.15/antd.min.css', - }, - { - name: 'lodash', - jsUrl: 'https://g.alicdn.com/code/lib/lodash.js/4.17.20/lodash.min.js', - }, - ], - utils: [ - { - name: 'message', - type: 'npm', - content: { - package: 'antd', - version: '3.x', - destructuring: true, - exportName: 'message', - }, - }, - { - name: 'modal', - type: 'npm', - content: { - package: 'antd', - version: '3.x', - destructuring: true, - exportName: 'Modal', - }, - }, - { - name: 'legaoBuiltin', - type: 'npm', - content: { - exportName: 'legaoBuiltin', - package: '@alilc/b6-compact-legao-builtin', - version: '1.x', - }, - }, - { - name: 'mocks', - type: 'npm', - content: { - package: '@alilc/b6-util-mocks', - version: '1.x', - exportName: 'mocks', - destructuring: true, - }, - }, - ], - routerType: 'memory', - routerExact: true, - }, } diff --git a/modules/code-generator/test-cases/react-app/demo2/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo2/expected/demo-project/package.json index 69f73ca4b..485c3422a 100644 --- a/modules/code-generator/test-cases/react-app/demo2/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo2/expected/demo-project/package.json @@ -36,7 +36,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo2/expected/demo-project/src/constants.js b/modules/code-generator/test-cases/react-app/demo2/expected/demo-project/src/constants.js index 4742ed117..c4a5859ee 100644 --- a/modules/code-generator/test-cases/react-app/demo2/expected/demo-project/src/constants.js +++ b/modules/code-generator/test-cases/react-app/demo2/expected/demo-project/src/constants.js @@ -1,3 +1,3 @@ -const __$$constants = { ENV: "prod", DOMAIN: "xxx.alibaba-inc.com" }; +const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; export default __$$constants; diff --git a/modules/code-generator/test-cases/react-app/demo2/schema.json5 b/modules/code-generator/test-cases/react-app/demo2/schema.json5 index bf438eb44..8678b4e92 100644 --- a/modules/code-generator/test-cases/react-app/demo2/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo2/schema.json5 @@ -215,7 +215,7 @@ ], "constants": { "ENV": "prod", - "DOMAIN": "xxx.alibaba-inc.com" + "DOMAIN": "xxx.xxx.com" }, "i18n": { "zh-CN": { diff --git a/modules/code-generator/test-cases/react-app/demo3/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo3/expected/demo-project/package.json index 69f73ca4b..485c3422a 100644 --- a/modules/code-generator/test-cases/react-app/demo3/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo3/expected/demo-project/package.json @@ -36,7 +36,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo3/expected/demo-project/src/constants.js b/modules/code-generator/test-cases/react-app/demo3/expected/demo-project/src/constants.js index 4742ed117..c4a5859ee 100644 --- a/modules/code-generator/test-cases/react-app/demo3/expected/demo-project/src/constants.js +++ b/modules/code-generator/test-cases/react-app/demo3/expected/demo-project/src/constants.js @@ -1,3 +1,3 @@ -const __$$constants = { ENV: "prod", DOMAIN: "xxx.alibaba-inc.com" }; +const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; export default __$$constants; diff --git a/modules/code-generator/test-cases/react-app/demo3/schema.json5 b/modules/code-generator/test-cases/react-app/demo3/schema.json5 index bcb17683d..173b793e1 100644 --- a/modules/code-generator/test-cases/react-app/demo3/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo3/schema.json5 @@ -118,7 +118,7 @@ ], "constants": { "ENV": "prod", - "DOMAIN": "xxx.alibaba-inc.com" + "DOMAIN": "xxx.xxx.com" }, "i18n": { "zh-CN": { diff --git a/modules/code-generator/test-cases/react-app/demo4/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo4/expected/demo-project/package.json index a96fb758a..2f33f5c71 100644 --- a/modules/code-generator/test-cases/react-app/demo4/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo4/expected/demo-project/package.json @@ -37,7 +37,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo4/expected/demo-project/src/pages/Test/index.jsx b/modules/code-generator/test-cases/react-app/demo4/expected/demo-project/src/pages/Test/index.jsx index 27382db64..86cb40fb6 100644 --- a/modules/code-generator/test-cases/react-app/demo4/expected/demo-project/src/pages/Test/index.jsx +++ b/modules/code-generator/test-cases/react-app/demo4/expected/demo-project/src/pages/Test/index.jsx @@ -72,7 +72,7 @@ class Test$$Page extends React.Component { isCors: true, timeout: 5000, headers: {}, - uri: "https://mocks.alibaba-inc.com/mock/jjpin/user/list", + uri: "https://mocks.xxx.com/mock/jjpin/user/list", }; }, id: "users", diff --git a/modules/code-generator/test-cases/react-app/demo4/schema.json5 b/modules/code-generator/test-cases/react-app/demo4/schema.json5 index 94bcf87ea..0695b843e 100644 --- a/modules/code-generator/test-cases/react-app/demo4/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo4/schema.json5 @@ -78,7 +78,7 @@ "isCors": true, "timeout": 5000, "headers": {}, - "uri": "https://mocks.alibaba-inc.com/mock/jjpin/user/list" + "uri": "https://mocks.xxx.com/mock/jjpin/user/list" }, "id": "users" } @@ -350,4 +350,4 @@ } ], "i18n": {} -} \ No newline at end of file +} diff --git a/modules/code-generator/test-cases/react-app/demo5/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo5/expected/demo-project/package.json index 20d042ad0..aee367e7d 100644 --- a/modules/code-generator/test-cases/react-app/demo5/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo5/expected/demo-project/package.json @@ -39,7 +39,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo5/expected/demo-project/src/pages/Test/index.jsx b/modules/code-generator/test-cases/react-app/demo5/expected/demo-project/src/pages/Test/index.jsx index 38ca57e4d..3d1d2ecde 100644 --- a/modules/code-generator/test-cases/react-app/demo5/expected/demo-project/src/pages/Test/index.jsx +++ b/modules/code-generator/test-cases/react-app/demo5/expected/demo-project/src/pages/Test/index.jsx @@ -60,128 +60,34 @@ class Test$$Page extends React.Component { }; componentWillUnmount() { - console.log("will umount"); + /* ... */ } - componentDidUpdate(prevProps, prevState, snapshot) { - console.log(this.state); + componentDidUpdate() { + /* ... */ } - onChange(optionItem, data) { - this.setState({ - selectedGateway: optionItem.value, - }); - fetch( - "https://oneapi.alibaba-inc.com/mock/knk1s2w7/ws/tconf/gate/publish/list/" + - optionItem.value - ) - .then((res) => { - return res.json(); - }) - .then((resData) => { - this.setState({ - records: resData.data, - }); - }); + onChange() { + /* ... */ } - getActions(item) { - const actions = []; - - if (item.show_detail) { - actions.push({ - text: "详情", - needConfirm: false, - handler: () => { - console.log("详情"); - }, - }); - } - - if (item.show_roll_back) { - actions.push({ - text: "回滚到此版本", - needConfirm: false, - handler: () => { - console.log("回滚到此版本"); - }, - }); - } - - if (item.show_continue) { - actions.push({ - text: "继续", - needConfirm: false, - handler: () => { - console.log("继续"); - }, - }); - } - - return actions; + getActions() { + /* ... */ } onCreateOrder() { - if (!this.state.selectedGateway) { - alert("请先选择网关"); - return; - } - - this.setState({ - modalVisible: true, - }); + /* ... */ } onCancelModal() { - this.setState({ - modalVisible: false, - }); + /* ... */ } onConfirmCreateOrder() { - fetch( - `https://oneapi.alibaba-inc.com/mock/knk1s2w7/ws/tconf/gate/publish/app/${this.state.selectedGateway}`, - { - method: "POST", - } - ) - .then((res) => { - return res.json(); - }) - .then((resJson) => { - console.log("create result: ", resJson); - - if (resJson.result !== true) { - throw new Error(resJson.message + resJson.errdetail); - } - }) - .then(() => { - console.log("创建发布单成功"); - this.onCancelModal(); - }) - .catch((err) => { - console.error(err); - alert("创建失败"); - }); + /* ... */ } - componentDidMount() { - this.setState({ - gateways: [ - { - domain: "uniproxy.amap.com:7001", - gate_code: "auto-edd-uniproxy", - gate_status_desc: "解锁", - label: "auto-edd-uniproxy", - value: "auto-edd-uniproxy", - }, - ], - }); - console.log("-----------", this, this.page); - setTimeout(() => { - console.log(this.state.gateways); - }, 1000); - } + componentDidMount() {} render() { const __$$context = this; diff --git a/modules/code-generator/test-cases/react-app/demo5/schema.json5 b/modules/code-generator/test-cases/react-app/demo5/schema.json5 index 5174d5bf4..b59b97e76 100644 --- a/modules/code-generator/test-cases/react-app/demo5/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo5/schema.json5 @@ -1,679 +1,677 @@ { - "version": "1.0.0", - "componentsMap": [ + version: '1.0.0', + componentsMap: [ { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Typography", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "subName": "Text", - "componentName": "Typography.Text" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Typography', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + subName: 'Text', + componentName: 'Typography.Text', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Select", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "componentName": "Select" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Select', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + componentName: 'Select', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Space", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "componentName": "Space" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Space', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + componentName: 'Space', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Button", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "componentName": "Button" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Button', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + componentName: 'Button', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "InputNumber", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "componentName": "InputNumber" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'InputNumber', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + componentName: 'InputNumber', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Form", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "subName": "Item", - "componentName": "Form.Item" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Form', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + subName: 'Item', + componentName: 'Form.Item', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Input", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "subName": "TextArea", - "componentName": "Input.TextArea" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Input', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + subName: 'TextArea', + componentName: 'Input.TextArea', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Form", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "componentName": "Form" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Form', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + componentName: 'Form', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Modal", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "componentName": "Modal" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Modal', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + componentName: 'Modal', }, { - "package": "@alife/mc-assets-1935", - "version": "0.1.16", - "exportName": "AliAutoSearchTable", - "main": "build/lowcode/index.js", - "destructuring": true, - "subName": "default", - "componentName": "AliAutoSearchTableDefault" + package: '@alife/mc-assets-1935', + version: '0.1.16', + exportName: 'AliAutoSearchTable', + main: 'build/lowcode/index.js', + destructuring: true, + subName: 'default', + componentName: 'AliAutoSearchTableDefault', }, { - "package": "@alilc/antd-lowcode", - "version": "0.5.4", - "exportName": "Card", - "main": "dist/antd-lowcode.esm.js", - "destructuring": true, - "componentName": "Card" + package: '@alilc/antd-lowcode', + version: '0.5.4', + exportName: 'Card', + main: 'dist/antd-lowcode.esm.js', + destructuring: true, + componentName: 'Card', }, { - "package": "@alife/container", - "version": "0.3.7", - "exportName": "P", - "main": "lib/index.js", - "destructuring": true, - "subName": "", - "componentName": "NextP" + package: '@alife/container', + version: '0.3.7', + exportName: 'P', + main: 'lib/index.js', + destructuring: true, + subName: '', + componentName: 'NextP', }, { - "package": "@alife/container", - "version": "0.3.7", - "exportName": "Block", - "main": "lib/index.js", - "destructuring": true, - "subName": "Cell", - "componentName": "NextBlockCell" + package: '@alife/container', + version: '0.3.7', + exportName: 'Block', + main: 'lib/index.js', + destructuring: true, + subName: 'Cell', + componentName: 'NextBlockCell', }, { - "package": "@alife/container", - "version": "0.3.7", - "exportName": "Block", - "main": "lib/index.js", - "destructuring": true, - "subName": "", - "componentName": "NextBlock" + package: '@alife/container', + version: '0.3.7', + exportName: 'Block', + main: 'lib/index.js', + destructuring: true, + subName: '', + componentName: 'NextBlock', }, { - "devMode": "lowcode", - "componentName": "Slot" + devMode: 'lowcode', + componentName: 'Slot', }, { - "package": "@alife/container", - "version": "0.3.7", - "exportName": "Page", - "main": "lib/index.js", - "destructuring": true, - "subName": "", - "componentName": "NextPage" + package: '@alife/container', + version: '0.3.7', + exportName: 'Page', + main: 'lib/index.js', + destructuring: true, + subName: '', + componentName: 'NextPage', }, { - "devMode": "lowcode", - "componentName": "Page" - } + devMode: 'lowcode', + componentName: 'Page', + }, ], - "componentsTree": [ + componentsTree: [ { - "componentName": "Page", - "id": "node_dockcviv8fo1", - "props": { - "ref": "outterView", - "style": { - "height": "100%" - } + componentName: 'Page', + id: 'node_dockcviv8fo1', + props: { + ref: 'outterView', + style: { + height: '100%', + }, }, - "fileName": "test", - "dataSource": { - "list": [] + fileName: 'test', + dataSource: { + list: [], }, - "css": "body {\n font-size: 12px;\n}\n\n.botton {\n width: 100px;\n color: #ff00ff\n}", - "lifeCycles": { - "componentDidMount": { - "type": "JSFunction", - "value": "function() {\n this.setState({\n gateways: [{\n \"domain\": \"uniproxy.amap.com:7001\",\n \"gate_code\": \"auto-edd-uniproxy\",\n \"gate_status_desc\": \"解锁\",\n \"label\": \"auto-edd-uniproxy\",\n \"value\": \"auto-edd-uniproxy\"\n }],\n });\n console.log('-----------', this, this.page);\n setTimeout(() => {\n console.log(this.state.gateways);\n }, 1000);\n }" + css: 'body {\n font-size: 12px;\n}\n\n.botton {\n width: 100px;\n color: #ff00ff\n}', + lifeCycles: { + componentDidMount: { + type: 'JSFunction', + value: 'function() { /* ... */ }', }, - "componentWillUnmount": { - "type": "JSFunction", - "value": "function() {\n console.log('will umount');\n }" + componentWillUnmount: { + type: 'JSFunction', + value: 'function() { /* ... */ }', + }, + componentDidUpdate: { + type: 'JSFunction', + value: 'function() { /* ... */ }', }, - "componentDidUpdate": { - "type": "JSFunction", - "value": "function(prevProps, prevState, snapshot) {\n console.log(this.state);\n }" - } }, - "methods": { - "onChange": { - "type": "JSFunction", - "value": "function(optionItem, data) {\n this.setState({\n selectedGateway: optionItem.value,\n });\n fetch('https://oneapi.alibaba-inc.com/mock/knk1s2w7/ws/tconf/gate/publish/list/' + optionItem.value)\n .then(res => {\n return res.json();\n })\n .then(resData => {\n this.setState({\n records: resData.data,\n });\n });\n }" + methods: { + onChange: { + type: 'JSFunction', + value: 'function() { /* ... */ }', }, - "getActions": { - "type": "JSFunction", - "value": "function(item) {\n const actions = [];\n if (item.show_detail) {\n actions.push({\n text: '详情',\n needConfirm: false,\n handler: () => {\n console.log('详情');\n },\n });\n }\n if (item.show_roll_back) {\n actions.push({\n text: '回滚到此版本',\n needConfirm: false,\n handler: () => {\n console.log('回滚到此版本');\n },\n });\n }\n if (item.show_continue) {\n actions.push({\n text: '继续',\n needConfirm: false,\n handler: () => {\n console.log(\"继续\");\n },\n });\n }\n return actions;\n }" + getActions: { + type: 'JSFunction', + value: 'function() { /* ... */ }', }, - "onCreateOrder": { - "type": "JSFunction", - "value": "function() {\n if (!this.state.selectedGateway) {\n alert('请先选择网关');\n return;\n }\n this.setState({\n modalVisible: true,\n });\n }" + onCreateOrder: { + type: 'JSFunction', + value: 'function() { /* ... */ }', }, - "onCancelModal": { - "type": "JSFunction", - "value": "function() {\n this.setState({\n modalVisible: false,\n });\n }" + onCancelModal: { + type: 'JSFunction', + value: 'function() { /* ... */ }', + }, + onConfirmCreateOrder: { + type: 'JSFunction', + value: 'function() { /* ... */ }', }, - "onConfirmCreateOrder": { - "type": "JSFunction", - "value": "function() {\n fetch(`https://oneapi.alibaba-inc.com/mock/knk1s2w7/ws/tconf/gate/publish/app/${this.state.selectedGateway}`, {\n method: 'POST',\n }).then(res => {\n return res.json()\n }).then(resJson => {\n console.log('create result: ', resJson);\n if (resJson.result !== true) {\n throw new Error(resJson.message + resJson.errdetail);\n }\n }).then(() => {\n console.log('创建发布单成功');\n this.onCancelModal();\n }).catch(err => {\n console.error(err);\n alert('创建失败');\n });\n }" - } }, - "state": { - "name": "nongzhou", - "gateways": [], - "selectedGateway": null, - "records": [], - "modalVisible": false + state: { + name: 'nongzhou', + gateways: [], + selectedGateway: null, + records: [], + modalVisible: false, }, - "children": [ + children: [ { - "componentName": "NextPage", - "id": "node_ocknqx3esma", - "props": { - "columns": 12, - "headerDivider": true, - "placeholderStyle": { - "gridRowEnd": "span 1", - "gridColumnEnd": "span 12" + componentName: 'NextPage', + id: 'node_ocknqx3esma', + props: { + columns: 12, + headerDivider: true, + placeholderStyle: { + gridRowEnd: 'span 1', + gridColumnEnd: 'span 12', }, - "placeholder": "页面主体内容:拖拽Block布局组件到这里", - "header": { - "type": "JSSlot", - "title": "header" + placeholder: '页面主体内容:拖拽Block布局组件到这里', + header: { + type: 'JSSlot', + title: 'header', }, - "headerProps": { - "background": "surface" + headerProps: { + background: 'surface', }, - "footer": { - "type": "JSSlot", - "title": "footer" + footer: { + type: 'JSSlot', + title: 'footer', + }, + minHeight: '100vh', + style: { + cursor: 'pointer', }, - "minHeight": "100vh", - "style": { - "cursor": "pointer" - } }, - "title": "页面", - "children": [ + title: '页面', + children: [ { - "componentName": "NextBlock", - "id": "node_ocknqx3esmb", - "props": { - "prefix": "next-", - "placeholderStyle": { - "height": "100%" + componentName: 'NextBlock', + id: 'node_ocknqx3esmb', + props: { + prefix: 'next-', + placeholderStyle: { + height: '100%', }, - "noPadding": false, - "noBorder": false, - "background": "surface", - "layoutmode": "O", - "colSpan": 12, - "rowSpan": 1, - "childTotalColumns": 12 + noPadding: false, + noBorder: false, + background: 'surface', + layoutmode: 'O', + colSpan: 12, + rowSpan: 1, + childTotalColumns: 12, }, - "title": "区块", - "children": [ + title: '区块', + children: [ { - "componentName": "NextBlockCell", - "id": "node_ocknqx3esmc", - "props": { - "title": "", - "prefix": "next-", - "placeholderStyle": { - "height": "100%" + componentName: 'NextBlockCell', + id: 'node_ocknqx3esmc', + props: { + title: '', + prefix: 'next-', + placeholderStyle: { + height: '100%', }, - "layoutmode": "O", - "childTotalColumns": 12, - "isAutoContainer": true, - "colSpan": 12, - "rowSpan": 1 + layoutmode: 'O', + childTotalColumns: 12, + isAutoContainer: true, + colSpan: 12, + rowSpan: 1, }, - "children": [ + children: [ { - "componentName": "NextP", - "id": "node_ocknqx3esm1j", - "props": { - "wrap": false, - "type": "body2", - "verAlign": "middle", - "textSpacing": true, - "align": "left", - "full": true, - "flex": true + componentName: 'NextP', + id: 'node_ocknqx3esm1j', + props: { + wrap: false, + type: 'body2', + verAlign: 'middle', + textSpacing: true, + align: 'left', + full: true, + flex: true, }, - "title": "段落", - "children": [ + title: '段落', + children: [ { - "componentName": "Card", - "id": "node_ocknqx3esm1k", - "props": { - "title": "" + componentName: 'Card', + id: 'node_ocknqx3esm1k', + props: { + title: '', }, - "children": [ + children: [ { - "componentName": "Space", - "id": "node_ocknqx3esm1n", - "props": { - "size": 0, - "align": "center", - "direction": "horizontal" + componentName: 'Space', + id: 'node_ocknqx3esm1n', + props: { + size: 0, + align: 'center', + direction: 'horizontal', }, - "children": [ + children: [ { - "componentName": "Typography.Text", - "id": "node_ocknqx3esm1l", - "props": { - "children": "所在网关:" - } - }, - { - "componentName": "Select", - "id": "node_ocknqx3esm1m", - "props": { - "style": { - "marginTop": "16px", - "marginRight": "16px", - "marginBottom": "16px", - "marginLeft": "16px", - "width": "400px", - "display": "inline-block" - }, - "options": { - "type": "JSExpression", - "value": "this.state.gateways" - }, - "mode": "single", - "defaultValue": [ - "auto-edd-uniproxy" - ], - "labelInValue": true, - "showSearch": true, - "allowClear": false, - "placeholder": "请选取网关", - "showArrow": true, - "loading": false, - "tokenSeparators": [], - "__events": { - "eventDataList": [ - { - "type": "componentEvent", - "name": "onChange", - "relatedEventName": "onChange" - } - ], - "eventList": [ - { - "name": "onBlur", - "disabled": false - }, - { - "name": "onChange", - "disabled": true - }, - { - "name": "onDeselect", - "disabled": false - }, - { - "name": "onFocus", - "disabled": false - }, - { - "name": "onInputKeyDown", - "disabled": false - }, - { - "name": "onMouseEnter", - "disabled": false - }, - { - "name": "onMouseLeave", - "disabled": false - }, - { - "name": "onPopupScroll", - "disabled": false - }, - { - "name": "onSearch", - "disabled": false - }, - { - "name": "onSelect", - "disabled": false - }, - { - "name": "onDropdownVisibleChange", - "disabled": false - } - ] - }, - "onChange": { - "type": "JSFunction", - "value": "function(){this.onChange.apply(this,Array.prototype.slice.call(arguments).concat([])) }" - } - } - } - ] - }, - { - "componentName": "Button", - "id": "node_ockntwgdsn7", - "props": { - "type": "primary", - "children": "创建发布单", - "style": { - "display": "block", - "marginTop": "20px", - "marginBottom": "20px" - }, - "__events": { - "eventDataList": [ - { - "type": "componentEvent", - "name": "onClick", - "relatedEventName": "onCreateOrder" - } - ], - "eventList": [ - { - "name": "onClick", - "disabled": true - } - ] - }, - "onClick": { - "type": "JSFunction", - "value": "function(){this.onCreateOrder.apply(this,Array.prototype.slice.call(arguments).concat([])) }" - } - } - }, - { - "componentName": "Modal", - "id": "node_ockntx4eo9p", - "props": { - "title": "创建发布单", - "visible": { - "type": "JSExpression", - "value": "this.state.modalVisible" - }, - "footer": "", - "__events": { - "eventDataList": [ - { - "type": "componentEvent", - "name": "onCancel", - "relatedEventName": "onCancelModal" - } - ], - "eventList": [ - { - "name": "onCancel", - "disabled": true - }, - { - "name": "onOk", - "disabled": false - } - ] - }, - "onCancel": { - "type": "JSFunction", - "value": "function(){this.onCancelModal.apply(this,Array.prototype.slice.call(arguments).concat([])) }" - }, - "zIndex": 2000 - }, - "hidden": true, - "children": [ - { - "componentName": "Form", - "id": "node_ockntx4eo9s", - "props": { - "labelCol": { - "span": 6 - }, - "wrapperCol": { - "span": 14 - }, - "onFinish": { - "type": "JSFunction", - "value": "function(){this.onConfirmCreateOrder.apply(this,Array.prototype.slice.call(arguments).concat([])) }" - }, - "name": "basic", - "__events": { - "eventDataList": [ - { - "type": "componentEvent", - "name": "onFinish", - "relatedEventName": "onConfirmCreateOrder" - } - ], - "eventList": [ - { - "name": "onFinish", - "disabled": true - }, - { - "name": "onFinishFailed", - "disabled": false - }, - { - "name": "onFieldsChange", - "disabled": false - }, - { - "name": "onValuesChange", - "disabled": false - } - ] - } + componentName: 'Typography.Text', + id: 'node_ocknqx3esm1l', + props: { + children: '所在网关:', }, - "children": [ - { - "componentName": "Form.Item", - "id": "node_ockntx4eo91k", - "props": { - "label": "发布批次" - }, - "children": [ - { - "componentName": "InputNumber", - "id": "node_ockntx4eo91l", - "props": { - "value": 3, - "min": 1 - } - } - ] + }, + { + componentName: 'Select', + id: 'node_ocknqx3esm1m', + props: { + style: { + marginTop: '16px', + marginRight: '16px', + marginBottom: '16px', + marginLeft: '16px', + width: '400px', + display: 'inline-block', }, - { - "componentName": "Form.Item", - "id": "node_ockntx4eo91r", - "props": { - "label": "批次间隔时间" - }, - "children": [ - { - "componentName": "InputNumber", - "id": "node_ockntx4eo91s", - "props": { - "value": 3 - } - } - ] + options: { + type: 'JSExpression', + value: 'this.state.gateways', }, - { - "componentName": "Form.Item", - "id": "node_ockntx4eo91y", - "props": { - "label": "备注 " - }, - "children": [ + mode: 'single', + defaultValue: ['auto-edd-uniproxy'], + labelInValue: true, + showSearch: true, + allowClear: false, + placeholder: '请选取网关', + showArrow: true, + loading: false, + tokenSeparators: [], + __events: { + eventDataList: [ { - "componentName": "Input.TextArea", - "id": "node_ockntx4eo91z", - "props": { - "rows": 3, - "placeholder": "请输入" - } - } - ] - }, - { - "componentName": "Form.Item", - "id": "node_ockntx4eo9v", - "props": { - "wrapperCol": { - "offset": 6 + type: 'componentEvent', + name: 'onChange', + relatedEventName: 'onChange', }, - "style": { - "flexDirection": "row", - "alignItems": "flex-end", - "justifyContent": "center", - "display": "flex" - }, - "labelAlign": "right" - }, - "children": [ + ], + eventList: [ { - "componentName": "Button", - "id": "node_ockntx4eo9w", - "props": { - "type": "primary", - "children": "提交", - "htmlType": "submit" - } + name: 'onBlur', + disabled: false, }, { - "componentName": "Button", - "id": "node_ockntx4eo9x", - "props": { - "style": { - "marginLeft": 20 + name: 'onChange', + disabled: true, + }, + { + name: 'onDeselect', + disabled: false, + }, + { + name: 'onFocus', + disabled: false, + }, + { + name: 'onInputKeyDown', + disabled: false, + }, + { + name: 'onMouseEnter', + disabled: false, + }, + { + name: 'onMouseLeave', + disabled: false, + }, + { + name: 'onPopupScroll', + disabled: false, + }, + { + name: 'onSearch', + disabled: false, + }, + { + name: 'onSelect', + disabled: false, + }, + { + name: 'onDropdownVisibleChange', + disabled: false, + }, + ], + }, + onChange: { + type: 'JSFunction', + value: 'function(){this.onChange.apply(this,Array.prototype.slice.call(arguments).concat([])) }', + }, + }, + }, + ], + }, + { + componentName: 'Button', + id: 'node_ockntwgdsn7', + props: { + type: 'primary', + children: '创建发布单', + style: { + display: 'block', + marginTop: '20px', + marginBottom: '20px', + }, + __events: { + eventDataList: [ + { + type: 'componentEvent', + name: 'onClick', + relatedEventName: 'onCreateOrder', + }, + ], + eventList: [ + { + name: 'onClick', + disabled: true, + }, + ], + }, + onClick: { + type: 'JSFunction', + value: 'function(){this.onCreateOrder.apply(this,Array.prototype.slice.call(arguments).concat([])) }', + }, + }, + }, + { + componentName: 'Modal', + id: 'node_ockntx4eo9p', + props: { + title: '创建发布单', + visible: { + type: 'JSExpression', + value: 'this.state.modalVisible', + }, + footer: '', + __events: { + eventDataList: [ + { + type: 'componentEvent', + name: 'onCancel', + relatedEventName: 'onCancelModal', + }, + ], + eventList: [ + { + name: 'onCancel', + disabled: true, + }, + { + name: 'onOk', + disabled: false, + }, + ], + }, + onCancel: { + type: 'JSFunction', + value: 'function(){this.onCancelModal.apply(this,Array.prototype.slice.call(arguments).concat([])) }', + }, + zIndex: 2000, + }, + hidden: true, + children: [ + { + componentName: 'Form', + id: 'node_ockntx4eo9s', + props: { + labelCol: { + span: 6, + }, + wrapperCol: { + span: 14, + }, + onFinish: { + type: 'JSFunction', + value: 'function(){this.onConfirmCreateOrder.apply(this,Array.prototype.slice.call(arguments).concat([])) }', + }, + name: 'basic', + __events: { + eventDataList: [ + { + type: 'componentEvent', + name: 'onFinish', + relatedEventName: 'onConfirmCreateOrder', + }, + ], + eventList: [ + { + name: 'onFinish', + disabled: true, + }, + { + name: 'onFinishFailed', + disabled: false, + }, + { + name: 'onFieldsChange', + disabled: false, + }, + { + name: 'onValuesChange', + disabled: false, + }, + ], + }, + }, + children: [ + { + componentName: 'Form.Item', + id: 'node_ockntx4eo91k', + props: { + label: '发布批次', + }, + children: [ + { + componentName: 'InputNumber', + id: 'node_ockntx4eo91l', + props: { + value: 3, + min: 1, + }, + }, + ], + }, + { + componentName: 'Form.Item', + id: 'node_ockntx4eo91r', + props: { + label: '批次间隔时间', + }, + children: [ + { + componentName: 'InputNumber', + id: 'node_ockntx4eo91s', + props: { + value: 3, + }, + }, + ], + }, + { + componentName: 'Form.Item', + id: 'node_ockntx4eo91y', + props: { + label: '备注 ', + }, + children: [ + { + componentName: 'Input.TextArea', + id: 'node_ockntx4eo91z', + props: { + rows: 3, + placeholder: '请输入', + }, + }, + ], + }, + { + componentName: 'Form.Item', + id: 'node_ockntx4eo9v', + props: { + wrapperCol: { + offset: 6, + }, + style: { + flexDirection: 'row', + alignItems: 'flex-end', + justifyContent: 'center', + display: 'flex', + }, + labelAlign: 'right', + }, + children: [ + { + componentName: 'Button', + id: 'node_ockntx4eo9w', + props: { + type: 'primary', + children: '提交', + htmlType: 'submit', + }, + }, + { + componentName: 'Button', + id: 'node_ockntx4eo9x', + props: { + style: { + marginLeft: 20, }, - "children": "取消", - "__events": { - "eventDataList": [ + children: '取消', + __events: { + eventDataList: [ { - "type": "componentEvent", - "name": "onClick", - "relatedEventName": "onCancelModal" - } + type: 'componentEvent', + name: 'onClick', + relatedEventName: 'onCancelModal', + }, ], - "eventList": [ + eventList: [ { - "name": "onClick", - "disabled": true - } - ] + name: 'onClick', + disabled: true, + }, + ], }, - "onClick": { - "type": "JSFunction", - "value": "function(){this.onCancelModal.apply(this,Array.prototype.slice.call(arguments).concat([])) }" - } - } - } - ] - } - ] - } - ] + onClick: { + type: 'JSFunction', + value: 'function(){this.onCancelModal.apply(this,Array.prototype.slice.call(arguments).concat([])) }', + }, + }, + }, + ], + }, + ], + }, + ], }, { - "componentName": "AliAutoSearchTableDefault", - "id": "node_ocknqx3esm1q", - "props": { - "rowKey": "key", - "dataSource": { - "type": "JSExpression", - "value": "this.state.records" + componentName: 'AliAutoSearchTableDefault', + id: 'node_ocknqx3esm1q', + props: { + rowKey: 'key', + dataSource: { + type: 'JSExpression', + value: 'this.state.records', }, - "columns": [ + columns: [ { - "title": "发布名称", - "dataIndex": "order_name", - "key": "name" + title: '发布名称', + dataIndex: 'order_name', + key: 'name', }, { - "title": "类型", - "dataIndex": "order_type_desc", - "key": "age" + title: '类型', + dataIndex: 'order_type_desc', + key: 'age', }, { - "title": "发布状态", - "dataIndex": "order_status_desc", - "key": "address" + title: '发布状态', + dataIndex: 'order_status_desc', + key: 'address', }, { - "title": "发布人", - "dataIndex": "creator_name" + title: '发布人', + dataIndex: 'creator_name', }, { - "title": "当前批次/总批次", - "dataIndex": "cur_batch_no" + title: '当前批次/总批次', + dataIndex: 'cur_batch_no', }, { - "title": "发布机器/总机器", - "dataIndex": "pubblish_ip_finish_num" + title: '发布机器/总机器', + dataIndex: 'pubblish_ip_finish_num', }, { - "title": "发布时间", - "dataIndex": "publish_id" - } + title: '发布时间', + dataIndex: 'publish_id', + }, ], - "actions": { - "type": "JSExpression", - "value": "this.actions || []" + actions: { + type: 'JSExpression', + value: 'this.actions || []', }, - "getActions": { - "type": "JSFunction", - "value": "function(){ return this.getActions.apply(this,Array.prototype.slice.call(arguments).concat([])) }" - } - } - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - } + getActions: { + type: 'JSFunction', + value: 'function(){ return this.getActions.apply(this,Array.prototype.slice.call(arguments).concat([])) }', + }, + }, + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }, ], - "i18n": {} -} \ No newline at end of file + i18n: {}, +} diff --git a/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/package.json index 69f73ca4b..485c3422a 100644 --- a/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/package.json @@ -36,7 +36,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/src/constants.js b/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/src/constants.js index 4742ed117..c4a5859ee 100644 --- a/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/src/constants.js +++ b/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/src/constants.js @@ -1,3 +1,3 @@ -const __$$constants = { ENV: "prod", DOMAIN: "xxx.alibaba-inc.com" }; +const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; export default __$$constants; diff --git a/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/src/pages/Test/index.jsx b/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/src/pages/Test/index.jsx index 2eac7c970..c351e3a56 100644 --- a/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/src/pages/Test/index.jsx +++ b/modules/code-generator/test-cases/react-app/demo6-literal-condition/expected/demo-project/src/pages/Test/index.jsx @@ -70,7 +70,7 @@ class Test$$Page extends React.Component { options: function () { return { method: "GET", - uri: "https://shs.alibaba-inc.com/mock/1458/demo/user", + uri: "https://shs.xxx.com/mock/1458/demo/user", isSync: true, }; }, @@ -91,7 +91,7 @@ class Test$$Page extends React.Component { options: function () { return { method: "GET", - uri: "https://shs.alibaba-inc.com/mock/1458/demo/orders", + uri: "https://shs.xxx.com/mock/1458/demo/orders", isSync: true, }; }, diff --git a/modules/code-generator/test-cases/react-app/demo6-literal-condition/schema.json5 b/modules/code-generator/test-cases/react-app/demo6-literal-condition/schema.json5 index 2c1892821..6d3a60137 100644 --- a/modules/code-generator/test-cases/react-app/demo6-literal-condition/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo6-literal-condition/schema.json5 @@ -81,13 +81,13 @@ id: 'urlParams', type: 'urlParams', }, - // 示例数据源:https://shs.alibaba-inc.com/mock/1458/demo/user + // 示例数据源:https://shs.xxx.com/mock/1458/demo/user { id: 'user', type: 'fetch', options: { method: 'GET', - uri: 'https://shs.alibaba-inc.com/mock/1458/demo/user', + uri: 'https://shs.xxx.com/mock/1458/demo/user', isSync: true, }, dataHandler: { @@ -95,13 +95,13 @@ value: 'function (response) {\nif (!response.data.success){\n throw new Error(response.data.message);\n }\n return response.data.data;\n}', }, }, - // 示例数据源:https://shs.alibaba-inc.com/mock/1458/demo/orders + // 示例数据源:https://shs.xxx.com/mock/1458/demo/orders { id: 'orders', type: 'fetch', options: { method: 'GET', - uri: 'https://shs.alibaba-inc.com/mock/1458/demo/orders', + uri: 'https://shs.xxx.com/mock/1458/demo/orders', isSync: true, }, dataHandler: { @@ -242,7 +242,7 @@ ], constants: { ENV: 'prod', - DOMAIN: 'xxx.alibaba-inc.com', + DOMAIN: 'xxx.xxx.com', }, css: 'body {font-size: 12px;} .table { width: 100px;}', config: { diff --git a/modules/code-generator/test-cases/react-app/demo7-literal-condition2/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo7-literal-condition2/expected/demo-project/package.json index 9fdc9592a..9a863dbbb 100644 --- a/modules/code-generator/test-cases/react-app/demo7-literal-condition2/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo7-literal-condition2/expected/demo-project/package.json @@ -38,7 +38,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo7-literal-condition2/expected/demo-project/src/pages/Test/index.jsx b/modules/code-generator/test-cases/react-app/demo7-literal-condition2/expected/demo-project/src/pages/Test/index.jsx index 4c9e344be..e12ec9bd2 100644 --- a/modules/code-generator/test-cases/react-app/demo7-literal-condition2/expected/demo-project/src/pages/Test/index.jsx +++ b/modules/code-generator/test-cases/react-app/demo7-literal-condition2/expected/demo-project/src/pages/Test/index.jsx @@ -87,46 +87,6 @@ class Test$$Page extends React.Component { { label: "X64", value: "X64" }, ], }; - - // customerProjectInfo: { - // id: null, - // systemProjectName: '锐捷AR', - // projectVersionTypeArray: ['1', '2'], - // projectVersionType: '1,2', - // versionLine: 1, - // expectedTime: '2021-05-06', - // expectedNum: '5000', - // projectModal: 1, - // displayWidth: 12, - // displayHeight: 13, - // displayInch: 14, - // displayDpi: 15, - // mainSoc: 'MTK856', - // cpuCoreNum: 6, - // instructions: 'ARMv7', - // osVersion: 2, - // status: 1, - // }, - // "customerProjectInfo": { - // "id": null, - // "systemProjectName": null, - // "projectVersionTypeArray": null, - // "projectVersionType": null, - // "versionLine": 2, - // "expectedTime": null, - // "expectedNum": null, - // "projectModal": 0, - // "displayWidth": null, - // "displayHeight": null, - // "displayInch": null, - // "displayDpi": null, - // "mainSoc": null, - // "cpuCoreNum": null, - // "instructions": null, - // "osVersion": 0 - // "status": null, - // }, - this.__jp__init(); } $ = (refName) => { @@ -146,263 +106,39 @@ class Test$$Page extends React.Component { componentWillUnmount() {} __jp__init() { - this.__jp__initEnv(); - - this.__jp__initDataSource(); - - this.__jp__initRouter(); - - this.__jp__initUtils(); + /*...*/ } __jp__initRouter() { - if (window.arsenal) { - this.$router = new window.jianpin.ArsenalRouter({ - app: this.props.microApp, - }); - } else { - this.$router = new window.jianpin.ArsenalRouter(); - } + /*...*/ } __jp__initDataSource() { - // 数据源面板存在缺陷,先用次数代码模式代替 - this.$apis = { - ADD_OR_UPDATE_CUSTOMER_PROJECT: { - name: "添加或删除用户项目", - code: "ADD_OR_UPDATE_CUSTOMER_PROJECT", - url: "/customer/project/addOrUpdate", - method: "POST", - state: "customerProjectInfo", - params: {}, - data: {}, - dataHandler: (res) => { - console.log("res.data.data = " + JSON.stringify(res.data.data)); - - if (res.data.code === "200") { - this.$utils.message.success(res.data.message); //关闭修改状态 - - this.setState({ - isModifyStatus: false, - }); - this.setState({ - currentStep: 2, - }); - } else { - this.$utils.message.error(res.data.message); - } //修改步骤三审核的显示文本 - - switch (res.data.data.status) { - case 1: - this.setState({ - thirdAuditText: "审核中", - thirdButtonText: "修改", - }); - break; - - case 2: - this.setState({ - thirdAuditText: "审核未通过", - thirdButtonText: "修改", - }); - break; - - case 3: - case 4: - case 5: - case 6: - this.setState({ - thirdAuditText: "审核通过", - thirdButtonText: "开始配置", - }); - break; - } - - return res.data.data; - }, - }, - }; - this.$ds = new window.jianpin.DataSource(this, { - apiPrefix: { - dev: "http://localhost:7001/ws/autozeus", - online: "/ws/autozeus", - }, - headers: { - "X-Tproxy-User-Mozi-Tid": "10005920384", - "X-Tproxy-User-Mozi-Uid": "1627124", - "X-Tproxy-User-Mozi-User": "shitao", - "X-Tproxy-User-Refer-Id": "239355", - }, - }); + /*...*/ } __jp__initEnv() { - const hostname = window.location.hostname; - let env = "prod"; - - if (window.jianpin.env === "dev") { - env = "dev"; - } else if (window.arsenalConfig) { - env = window.arsenalConfig.env; - } - - const urlSearchParams = new URLSearchParams(window.location.search); - const searchParams = {}; - - for (const [key, value] of urlSearchParams) { - searchParams[key] = value; - } - - this.$env = env; - this.$searchParams = searchParams; + /*...*/ } __jp__initUtils() { - this.$utils = { - message: window.jianpin.utils.message, - axios: window.jianpin.utils.axios, - moment: window.jianpin.utils.moment, - }; + /*...*/ } - onFinishFirst(data) { - //第一步 下一步 - console.log("first data", data); - this.setState({ - //customerProjectInfo: data, - currentStep: 1, - }); // this.state.customerProjectInfo.systemProjectName = data.systemProjectName; - // this.state.customerProjectInfo.projectVersionTypeArray = data.projectVersionTypeArray; - // this.state.customerProjectInfo.projectVersionType = data.projectVersionType; - // this.state.customerProjectInfo.versionLine = data.versionLine; - // this.state.customerProjectInfo.expectedTime = data.expectedTime; - // this.state.customerProjectInfo.expectedNum = data.expectedNum; - - this.setState({ - customerProjectInfo: { - ...this.state.customerProjectInfo, - ...data, // systemProjectName: data.systemProjectName, - // projectVersionTypeArray: data.projectVersionTypeArray, - // projectVersionType: data.projectVersionType, - // versionLine: data.versionLine, - // expectedTime: data.expectedTime, - // expectedNum: data.expectedNum, - }, - }); - console.log("first customerProjectInfo", this.state.customerProjectInfo); - - if (this.state.customerProjectInfo.id > 0 && !this.state.isModifyStatus) { - //按钮显示为下一步 - this.setState({ - secondCommitText: "下一步", - }); - } else { - //按钮显示为完成并提交 - this.setState({ - secondCommitText: "完成并提交", - }); - } + onFinishFirst() { + /*...*/ } onClickPreSecond() { - //第二步 上一步 - this.setState({ - currentStep: 0, - }); + /*...*/ } - onFinishSecond(data) { - //第二步 完成并提交 下一步 - console.log("second data", data); - - if (this.state.customerProjectInfo.id > 0 && !this.state.isModifyStatus) { - //下一步 执行的动作 - //修改步骤三审核的显示文本 - switch (this.state.customerProjectInfo.status) { - case 1: - this.setState({ - thirdAuditText: "审核中", - thirdButtonText: "修改", - }); - break; - - case 2: - this.setState({ - thirdAuditText: "审核未通过", - thirdButtonText: "修改", - }); - break; - - case 3: - case 4: - case 5: - case 6: - this.setState({ - thirdAuditText: "审核通过", - thirdButtonText: "开始配置", - }); - break; - } - - this.setState({ - currentStep: 2, - }); - } else { - // 完成并提交 执行的动作 - // this.setState({ - // currentStep: 2, - // }); - // this.state.customerProjectInfo.projectModal = data.projectModal; - // this.state.customerProjectInfo.displayWidth = data.displayWidth; - // this.state.customerProjectInfo.displayHeight = data.displayHeight; - // this.state.customerProjectInfo.displayInch = data.displayInch; - // this.state.customerProjectInfo.displayDpi = data.displayDpi; - // this.state.customerProjectInfo.mainSoc = data.mainSoc; - // this.state.customerProjectInfo.cpuCoreNum = data.cpuCoreNum; - // this.state.customerProjectInfo.instructions = data.instructions; - // this.state.customerProjectInfo.osVersion = data.osVersion; - this.setState({ - customerProjectInfo: { - ...this.state.customerProjectInfo, - ...data, // projectModal: data.projectModal, - // displayWidth: data.displayWidth, - // displayHeight: data.displayHeight, - // displayInch: data.displayInch, - // displayDpi: data.displayDpi, - // mainSoc: data.mainSoc, - // cpuCoreNum: data.cpuCoreNum, - // instructions: data.instructions, - // osVersion: data.osVersion, - }, - }); - console.log("second customerProjectInfo", this.state.customerProjectInfo); - this.$ds.resolve(this.$apis.ADD_OR_UPDATE_CUSTOMER_PROJECT, { - data: this.state.customerProjectInfo, - }); - } + onFinishSecond() { + /*...*/ } onClickModifyThird() { - //第三步 修改 开始配置 - if (this.state.customerProjectInfo.status > 2) { - //状态大于2说明审核通过了,可以开始配置 - // todo 路由跳转 - alert("功能配置/版本管理等功能暂未上线,敬请期待"); - this.$router.push("/"); - } else { - //状态小于2说明审核未通过了,可以修改 - //置为修改状态 - // this.setState({ - // isModifyDialogVisible: true, - // isModifyStatus: true, - // }); - //20210609 产品修改为直接跳转到第一步,无需对话框 - this.setState({ - isModifyDialogVisible: false, - isModifyStatus: true, - currentStep: 0, - }); - } + /*...*/ } onOkModifyDialogThird() { diff --git a/modules/code-generator/test-cases/react-app/demo7-literal-condition2/schema.json5 b/modules/code-generator/test-cases/react-app/demo7-literal-condition2/schema.json5 index 258f4f09b..4c829cfab 100644 --- a/modules/code-generator/test-cases/react-app/demo7-literal-condition2/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo7-literal-condition2/schema.json5 @@ -164,7 +164,7 @@ lifeCycles: { constructor: { type: 'JSFunction', - value: 'function() {\n // customerProjectInfo: {\n // id: null,\n // systemProjectName: \'锐捷AR\',\n // projectVersionTypeArray: [\'1\', \'2\'],\n // projectVersionType: \'1,2\',\n // versionLine: 1,\n // expectedTime: \'2021-05-06\',\n // expectedNum: \'5000\',\n // projectModal: 1,\n // displayWidth: 12,\n // displayHeight: 13,\n // displayInch: 14,\n // displayDpi: 15,\n // mainSoc: \'MTK856\',\n // cpuCoreNum: 6,\n // instructions: \'ARMv7\',\n // osVersion: 2,\n // status: 1,\n // },\n // "customerProjectInfo": {\n // "id": null,\n // "systemProjectName": null,\n // "projectVersionTypeArray": null,\n // "projectVersionType": null,\n // "versionLine": 2,\n // "expectedTime": null,\n // "expectedNum": null,\n // "projectModal": 0,\n // "displayWidth": null,\n // "displayHeight": null,\n // "displayInch": null,\n // "displayDpi": null,\n // "mainSoc": null,\n // "cpuCoreNum": null,\n // "instructions": null,\n // "osVersion": 0\n // "status": null,\n // },\n\n this.__jp__init();\n }', + value: "function() { /*...*/ }", }, componentDidMount: { type: 'JSFunction', @@ -182,39 +182,39 @@ methods: { __jp__init: { type: 'JSFunction', - value: 'function() {\n this.__jp__initEnv();\n this.__jp__initDataSource();\n this.__jp__initRouter();\n this.__jp__initUtils();\n}', + value: "function() { /*...*/ }", }, __jp__initRouter: { type: 'JSFunction', - value: 'function() {\n if (window.arsenal) {\n this.$router = new window.jianpin.ArsenalRouter({\n app: this.props.microApp,\n });\n } else {\n this.$router = new window.jianpin.ArsenalRouter();\n }\n}', + value: "function() { /*...*/ }", }, __jp__initDataSource: { type: 'JSFunction', - value: "function() {\n // 数据源面板存在缺陷,先用次数代码模式代替\n this.$apis = {\n ADD_OR_UPDATE_CUSTOMER_PROJECT: {\n name: '添加或删除用户项目',\n code: 'ADD_OR_UPDATE_CUSTOMER_PROJECT',\n url: '/customer/project/addOrUpdate',\n method: 'POST',\n state: 'customerProjectInfo',\n params: {},\n data: {},\n dataHandler: res => {\n console.log('res.data.data = ' + JSON.stringify(res.data.data));\n if (res.data.code === '200') {\n this.$utils.message.success(res.data.message);\n //关闭修改状态\n this.setState({\n isModifyStatus: false,\n });\n this.setState({\n currentStep: 2,\n });\n } else {\n this.$utils.message.error(res.data.message);\n }\n //修改步骤三审核的显示文本\n switch (res.data.data.status) {\n case 1:\n this.setState({\n thirdAuditText: '审核中',\n thirdButtonText: '修改',\n });\n break;\n case 2:\n this.setState({\n thirdAuditText: '审核未通过',\n thirdButtonText: '修改',\n });\n break;\n case 3:\n case 4:\n case 5:\n case 6:\n this.setState({\n thirdAuditText: '审核通过',\n thirdButtonText: '开始配置',\n });\n break;\n }\n\n return res.data.data;\n },\n },\n};\n\n this.$ds = new window.jianpin.DataSource(this,{\n apiPrefix: {\n dev: 'http://localhost:7001/ws/autozeus',\n online: '/ws/autozeus',\n },\n headers: {\n 'X-Tproxy-User-Mozi-Tid': '10005920384',\n 'X-Tproxy-User-Mozi-Uid': '1627124',\n 'X-Tproxy-User-Mozi-User': 'shitao',\n 'X-Tproxy-User-Refer-Id': '239355',\n },\n});\n }", + value: "function() { /*...*/ }", }, __jp__initEnv: { type: 'JSFunction', - value: "function() {\n const hostname = window.location.hostname;\n let env = 'prod';\n\n if (window.jianpin.env === 'dev') {\n env = 'dev';\n } else if (window.arsenalConfig) {\n env = window.arsenalConfig.env;\n }\n\n const urlSearchParams = new URLSearchParams(window.location.search);\n const searchParams = {};\n for (const [key, value] of urlSearchParams) {\n searchParams[key] = value;\n }\n this.$env = env;\n this.$searchParams = searchParams;\n}", + value: "function() { /*...*/ }", }, __jp__initUtils: { type: 'JSFunction', - value: 'function() {\n this.$utils = {\n message: window.jianpin.utils.message,\n axios: window.jianpin.utils.axios,\n moment: window.jianpin.utils.moment,\n };\n}', + value: "function() { /*...*/ }", }, onFinishFirst: { type: 'JSFunction', - value: "function(data) {\n //第一步 下一步\n\n console.log('first data', data);\n this.setState({\n //customerProjectInfo: data,\n currentStep: 1,\n });\n // this.state.customerProjectInfo.systemProjectName = data.systemProjectName;\n // this.state.customerProjectInfo.projectVersionTypeArray = data.projectVersionTypeArray;\n // this.state.customerProjectInfo.projectVersionType = data.projectVersionType;\n // this.state.customerProjectInfo.versionLine = data.versionLine;\n // this.state.customerProjectInfo.expectedTime = data.expectedTime;\n // this.state.customerProjectInfo.expectedNum = data.expectedNum;\n\n this.setState({\n customerProjectInfo: {\n ...this.state.customerProjectInfo,\n ...data,\n // systemProjectName: data.systemProjectName,\n // projectVersionTypeArray: data.projectVersionTypeArray,\n // projectVersionType: data.projectVersionType,\n // versionLine: data.versionLine,\n // expectedTime: data.expectedTime,\n // expectedNum: data.expectedNum,\n },\n });\n\n console.log(\n 'first customerProjectInfo',\n this.state.customerProjectInfo\n );\n\n if (\n this.state.customerProjectInfo.id > 0 &&\n !this.state.isModifyStatus\n ) {\n //按钮显示为下一步\n this.setState({\n secondCommitText: '下一步',\n });\n } else {\n //按钮显示为完成并提交\n this.setState({\n secondCommitText: '完成并提交',\n });\n }\n }", + value: "function() { /*...*/ }", }, onClickPreSecond: { type: 'JSFunction', - value: 'function() {\n //第二步 上一步\n\n this.setState({\n currentStep: 0,\n });\n }', + value: "function() { /*...*/ }", }, onFinishSecond: { type: 'JSFunction', - value: "function(data) {\n //第二步 完成并提交 下一步\n\n console.log('second data', data);\n\n if (\n this.state.customerProjectInfo.id > 0 &&\n !this.state.isModifyStatus\n ) {\n //下一步 执行的动作\n\n //修改步骤三审核的显示文本\n switch (this.state.customerProjectInfo.status) {\n case 1:\n this.setState({\n thirdAuditText: '审核中',\n thirdButtonText: '修改',\n });\n break;\n case 2:\n this.setState({\n thirdAuditText: '审核未通过',\n thirdButtonText: '修改',\n });\n break;\n case 3:\n case 4:\n case 5:\n case 6:\n this.setState({\n thirdAuditText: '审核通过',\n thirdButtonText: '开始配置',\n });\n break;\n }\n\n this.setState({\n currentStep: 2,\n });\n } else {\n // 完成并提交 执行的动作\n\n // this.setState({\n // currentStep: 2,\n // });\n\n // this.state.customerProjectInfo.projectModal = data.projectModal;\n // this.state.customerProjectInfo.displayWidth = data.displayWidth;\n // this.state.customerProjectInfo.displayHeight = data.displayHeight;\n // this.state.customerProjectInfo.displayInch = data.displayInch;\n // this.state.customerProjectInfo.displayDpi = data.displayDpi;\n // this.state.customerProjectInfo.mainSoc = data.mainSoc;\n // this.state.customerProjectInfo.cpuCoreNum = data.cpuCoreNum;\n // this.state.customerProjectInfo.instructions = data.instructions;\n // this.state.customerProjectInfo.osVersion = data.osVersion;\n\n this.setState({\n customerProjectInfo: {\n ...this.state.customerProjectInfo,\n ...data,\n // projectModal: data.projectModal,\n // displayWidth: data.displayWidth,\n // displayHeight: data.displayHeight,\n // displayInch: data.displayInch,\n // displayDpi: data.displayDpi,\n // mainSoc: data.mainSoc,\n // cpuCoreNum: data.cpuCoreNum,\n // instructions: data.instructions,\n // osVersion: data.osVersion,\n },\n });\n\n console.log(\n 'second customerProjectInfo',\n this.state.customerProjectInfo\n );\n\n this.$ds.resolve(this.$apis.ADD_OR_UPDATE_CUSTOMER_PROJECT, {\n data: this.state.customerProjectInfo,\n });\n }\n }", + value: "function() { /*...*/ }", }, onClickModifyThird: { type: 'JSFunction', - value: "function() {\n //第三步 修改 开始配置\n\n if (this.state.customerProjectInfo.status > 2) {\n //状态大于2说明审核通过了,可以开始配置\n // todo 路由跳转\n alert('功能配置/版本管理等功能暂未上线,敬请期待');\n this.$router.push('/');\n } else {\n //状态小于2说明审核未通过了,可以修改\n //置为修改状态\n // this.setState({\n // isModifyDialogVisible: true,\n // isModifyStatus: true,\n // });\n //20210609 产品修改为直接跳转到第一步,无需对话框\n this.setState({\n isModifyDialogVisible: false,\n isModifyStatus: true,\n currentStep: 0,\n });\n }\n }", + value: "function() { /*...*/ }", }, onOkModifyDialogThird: { type: 'JSFunction', diff --git a/modules/code-generator/test-cases/react-app/demo8-datasource-prop/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo8-datasource-prop/expected/demo-project/package.json index cb62bf2f5..d1c005b90 100644 --- a/modules/code-generator/test-cases/react-app/demo8-datasource-prop/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo8-datasource-prop/expected/demo-project/package.json @@ -36,7 +36,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo9-datasource-engine/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo9-datasource-engine/expected/demo-project/package.json index 69f73ca4b..485c3422a 100644 --- a/modules/code-generator/test-cases/react-app/demo9-datasource-engine/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo9-datasource-engine/expected/demo-project/package.json @@ -36,7 +36,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo_10-jsslot/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo_10-jsslot/expected/demo-project/package.json index 78698ce33..fef2c4422 100644 --- a/modules/code-generator/test-cases/react-app/demo_10-jsslot/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo_10-jsslot/expected/demo-project/package.json @@ -39,7 +39,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo_10-jsslot/expected/demo-project/src/pages/Test/index.jsx b/modules/code-generator/test-cases/react-app/demo_10-jsslot/expected/demo-project/src/pages/Test/index.jsx index 277b08fd4..d95e13b89 100644 --- a/modules/code-generator/test-cases/react-app/demo_10-jsslot/expected/demo-project/src/pages/Test/index.jsx +++ b/modules/code-generator/test-cases/react-app/demo_10-jsslot/expected/demo-project/src/pages/Test/index.jsx @@ -80,11 +80,7 @@ class Test$$Page extends React.Component { componentWillUnmount() {} __jp__init() { - this.__jp__initEnv && this.__jp__initEnv(); - this.__jp__initConfig && this.__jp__initConfig(); - this.__jp__initDataSource && this.__jp__initDataSource(); - this.__jp__initRouter && this.__jp__initRouter(); - this.__jp__initUtils && this.__jp__initUtils(); + /*...*/ } __jp__initRouter() { @@ -98,103 +94,15 @@ class Test$$Page extends React.Component { } __jp__initDataSource() { - this.$apis = { - PKG_LIST: { - name: "打包列表", - code: "PKG_LIST", - url: "https://auto-nvwa.amap.com/cpp/api/configbuild/", - method: "GET", - dataHandler: (res) => { - console.log("debug res", res); - return res; - }, - }, - PROJECTS: { - name: "项目名称/渠道号", - code: "PROJECTS", - url: "http://auto-nvwa-staging.alibaba.com/ws/nvwa/cpp/select_projects/", - method: "GET", - state: "projects", - dataHandler: (res) => { - console.log("debug res", res); - return res.data.data.result.map((d) => { - const { id, channelId, project_name } = d; - return { - label: `${project_name}/${channelId}`, - value: id, - }; - }); - }, - }, - RELOAD: { - name: "重新执行", - code: "RELOAD", - url: "https://auto-nvwa.amap.com/cpp/configbuild/rebuild/", - method: "GET", - }, - BUILD_RESULT: { - name: "打包结果", - code: "BUILD_RESULT", - url: "https://auto-nvwa.amap.com/cpp/api/configbuild/get_build_result/", - method: "GET", - state: "results", - dataHandler: (res) => { - return res.data.result; - }, - }, - }; - this.$ds = new window.jianpin.DataSource(this, {}); + /*...*/ } __jp__initEnv() { - const hostname = window.location.hostname; - let env = "prod"; - - if (window.jianpin && window.jianpin.env === "dev") { - env = "dev"; - } else if (window.arsenalConfig) { - env = window.arsenalConfig.env; - } - - const urlSearchParams = new URLSearchParams(window.location.search); - const searchParams = {}; - - for (const [key, value] of urlSearchParams) { - searchParams[key] = value; - } - - this.$env = env; - this.$searchParams = searchParams; - - if (window.arsenal && window.arsenal.store) { - this.$user = window.arsenal.store.getState("user"); - this.$store = window.arsenal.store; - window.arsenal.store.subscribe("user", () => { - this.$user = window.arsenal.store.getState("user"); - }); - } else { - this.$store = { - subscribe: () => {}, - getState: () => {}, - }; - this.$user = this.__jp__mockUser || {}; - } + /*...*/ } __jp__initConfig() { - const __config = { - default: {}, - dev: {}, - daily: {}, - pre: {}, - prod: {}, - }; - this.$config = window.jianpin.utils.extend( - true, - {}, - __config.default, - __config[this.$env] - ); + /*...*/ } __jp__initUtils() { @@ -205,21 +113,8 @@ class Test$$Page extends React.Component { }; } - fetchPkgs(params) { - const { pageIndex, pageSize } = this.pageParams; - this.$ds - .resolve("PKG_LIST", { - params: { ...params, page: pageIndex, page_size: pageSize }, - }) - .then((res) => { - const { builds, page } = res.data; - const { num_pages, per_page } = page; - this.setState({ - isSearch: true, - pkgs: builds, - total: num_pages * per_page, - }); - }); + fetchPkgs() { + /*...*/ } onPageChange(pageIndex, pageSize) { @@ -238,64 +133,12 @@ class Test$$Page extends React.Component { return user.user_name; } - reload(id) { - if (!confirm("确实要重新执行?")) { - return; - } - - this.$ds - .resolve("RELOAD", { - params: { - build_id: id, - }, - }) - .then((res) => { - const { code, message } = res.data.status; - - if (code == 0) { - this.$utils.message.error(message); - } else { - const { pageIndex, pageSize } = this.pageParams; - this.onPageChange(pageIndex, pageSize); - } - }) - .catch((err) => { - this.$utils.message.error(err.message); - }); + reload() { + /*...*/ } - handleResult(e) { - // e.persist(); - e.preventDefault(); - e.stopPropagation(); - let href; - let tagName; - let target = e.target; - - do { - tagName = target.tagName.toUpperCase(); - href = target.getAttribute("href"); - target = target.parentNode; - } while (!href && tagName !== "TD"); - - if (!href) { - return; - } - - this.$ds - .resolve("BUILD_RESULT", { - params: { - build_id: href, - }, - }) - .then((res) => { - this.setState({ - resultVisible: true, - }); - }) - .catch((err) => { - this.$utils.message.error(`打包结果获取失败: ${err.message}`); - }); + handleResult() { + /*...*/ } handleDetail() { @@ -318,34 +161,11 @@ class Test$$Page extends React.Component { } handleDownload() { - const { results } = this.state; - - if (!results || results.length < 1) { - return; - } - - let link = document.createElement("a"); - link.style.display = "none"; - document.body.appendChild(link); - results.forEach((r) => { - link.href = r.download_link; - link.click(); - }); - document.body.removeChild(link); - link = null; + /*...*/ } - onFinish(f) { - const params = Object.keys(f).reduce((pre, key) => { - const value = f[key]; - - if (value === undefined) { - return pre; - } - - return { ...pre, [key]: value }; - }, {}); - this.fetchPkgs(params); + onFinish() { + /*...*/ } componentDidMount() { diff --git a/modules/code-generator/test-cases/react-app/demo_10-jsslot/schema.json5 b/modules/code-generator/test-cases/react-app/demo_10-jsslot/schema.json5 index 45762334c..a499dfc65 100644 --- a/modules/code-generator/test-cases/react-app/demo_10-jsslot/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo_10-jsslot/schema.json5 @@ -191,7 +191,7 @@ methods: { __jp__init: { type: 'JSFunction', - value: 'function() {\n this.__jp__initEnv && this.__jp__initEnv();\n this.__jp__initConfig && this.__jp__initConfig();\n this.__jp__initDataSource && this.__jp__initDataSource();\n this.__jp__initRouter && this.__jp__initRouter();\n this.__jp__initUtils && this.__jp__initUtils();\n}', + value: 'function() { /*...*/ }', }, __jp__initRouter: { type: 'JSFunction', @@ -199,15 +199,15 @@ }, __jp__initDataSource: { type: 'JSFunction', - value: "function() {\n this.$apis = {\n PKG_LIST: {\n name: '打包列表',\n code: 'PKG_LIST',\n url: 'https://auto-nvwa.amap.com/cpp/api/configbuild/',\n method: 'GET',\n dataHandler: res => {\n console.log('debug res', res);\n return res;\n },\n },\n PROJECTS: {\n name: '项目名称/渠道号',\n code: 'PROJECTS',\n url:\n 'http://auto-nvwa-staging.alibaba.com/ws/nvwa/cpp/select_projects/',\n method: 'GET',\n state: 'projects',\n dataHandler: res => {\n console.log('debug res', res);\n return res.data.data.result.map(d => {\n const { id, channelId, project_name } = d;\n return {\n label: `${project_name}/${channelId}`,\n value: id,\n };\n });\n },\n },\n RELOAD: {\n name: '重新执行',\n code: 'RELOAD',\n url: 'https://auto-nvwa.amap.com/cpp/configbuild/rebuild/',\n method: 'GET',\n },\n BUILD_RESULT: {\n name: '打包结果',\n code: 'BUILD_RESULT',\n url:\n 'https://auto-nvwa.amap.com/cpp/api/configbuild/get_build_result/',\n method: 'GET',\n state: 'results',\n dataHandler: res => {\n return res.data.result;\n },\n },\n};\n this.$ds = new window.jianpin.DataSource(this, {});\n}", + value: 'function() { /*...*/ }', }, __jp__initEnv: { type: 'JSFunction', - value: "function() {\n const hostname = window.location.hostname;\n let env = 'prod';\n\n if (window.jianpin && window.jianpin.env === 'dev') {\n env = 'dev';\n } else if (window.arsenalConfig) {\n env = window.arsenalConfig.env;\n }\n\n const urlSearchParams = new URLSearchParams(window.location.search);\n const searchParams = {};\n for (const [key, value] of urlSearchParams) {\n searchParams[key] = value;\n }\n this.$env = env;\n this.$searchParams = searchParams;\n\n if (window.arsenal && window.arsenal.store) {\n this.$user = window.arsenal.store.getState('user');\n this.$store = window.arsenal.store;\n window.arsenal.store.subscribe('user', () => {\n this.$user = window.arsenal.store.getState('user');\n });\n } else {\n this.$store = {\n subscribe: () => {},\n getState: () => {},\n };\n this.$user = this.__jp__mockUser || {};\n }\n}", + value: 'function() { /*...*/ }', }, __jp__initConfig: { type: 'JSFunction', - value: 'function() {\n const __config = {\n "default": {},\n "dev": {},\n "daily": {},\n "pre": {},\n "prod": {}\n};\n\n this.$config = window.jianpin.utils.extend(true, {}, __config.default, __config[this.$env]);\n}', + value: 'function() { /*...*/ }', }, __jp__initUtils: { type: 'JSFunction', @@ -215,7 +215,7 @@ }, fetchPkgs: { type: 'JSFunction', - value: "function(params) {\n const { pageIndex, pageSize } = this.pageParams;\n this.$ds\n .resolve('PKG_LIST', {\n params: {\n ...params,\n page: pageIndex,\n page_size: pageSize,\n },\n })\n .then(res => {\n const { builds, page } = res.data;\n const { num_pages, per_page } = page;\n this.setState({\n isSearch: true,\n pkgs: builds,\n total: num_pages * per_page,\n });\n });\n }", + value: 'function() { /*...*/ }', }, onPageChange: { type: 'JSFunction', @@ -231,11 +231,11 @@ }, reload: { type: 'JSFunction', - value: "function(id) {\n if (!confirm('确实要重新执行?')) {\n return;\n }\n this.$ds\n .resolve('RELOAD', {\n params: {\n build_id: id,\n },\n })\n .then(res => {\n const { code, message } = res.data.status;\n if (code == 0) {\n this.$utils.message.error(message);\n } else {\n const { pageIndex, pageSize } = this.pageParams;\n this.onPageChange(pageIndex, pageSize);\n }\n })\n .catch(err => {\n this.$utils.message.error(err.message);\n });\n }", + value: 'function() { /*...*/ }', }, handleResult: { type: 'JSFunction', - value: "function(e) {\n // e.persist();\n e.preventDefault();\n e.stopPropagation();\n let href;\n let tagName;\n let target = e.target;\n do {\n tagName = target.tagName.toUpperCase();\n href = target.getAttribute('href');\n target = target.parentNode;\n } while (!href && tagName !== 'TD');\n if (!href) {\n return;\n }\n\n this.$ds\n .resolve('BUILD_RESULT', {\n params: {\n build_id: href,\n },\n })\n .then(res => {\n this.setState({\n resultVisible: true,\n });\n })\n .catch(err => {\n this.$utils.message.error(`打包结果获取失败: ${err.message}`);\n });\n }", + value: 'function() { /*...*/ }', }, handleDetail: { type: 'JSFunction', @@ -251,11 +251,11 @@ }, handleDownload: { type: 'JSFunction', - value: "function() {\n const { results } = this.state;\n if (!results || results.length < 1) {\n return;\n }\n let link = document.createElement('a');\n link.style.display = 'none';\n document.body.appendChild(link);\n results.forEach(r => {\n link.href = r.download_link;\n link.click();\n });\n document.body.removeChild(link);\n link = null;\n }", + value: 'function() { /*...*/ }', }, onFinish: { type: 'JSFunction', - value: 'function(f) {\n const params = Object.keys(f).reduce((pre, key) => {\n const value = f[key];\n if (value === undefined) {\n return pre;\n }\n return {\n ...pre,\n [key]: value,\n };\n }, {});\n this.fetchPkgs(params);\n }', + value: 'function() { /*...*/ }', }, }, state: { diff --git a/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/expected/demo-project/package.json b/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/expected/demo-project/package.json index 3cc1248b9..e4c9f407e 100644 --- a/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/expected/demo-project/package.json @@ -39,7 +39,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/expected/demo-project/src/pages/Test/index.jsx b/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/expected/demo-project/src/pages/Test/index.jsx index b14bcead6..4dacde34e 100644 --- a/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/expected/demo-project/src/pages/Test/index.jsx +++ b/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/expected/demo-project/src/pages/Test/index.jsx @@ -88,195 +88,39 @@ class Test$$Page extends React.Component { componentWillUnmount() {} __jp__init() { - this.__jp__initEnv && this.__jp__initEnv(); - this.__jp__initConfig && this.__jp__initConfig(); - this.__jp__initDataSource && this.__jp__initDataSource(); - this.__jp__initRouter && this.__jp__initRouter(); - this.__jp__initUtils && this.__jp__initUtils(); + /*...*/ } __jp__initRouter() { - if (window.arsenal) { - this.$router = new window.jianpin.ArsenalRouter({ - app: this.props.microApp, - }); - } else { - this.$router = new window.jianpin.ArsenalRouter(); - } + /*...*/ } __jp__initDataSource() { - this.$apis = { - PKG_LIST: { - name: "打包列表", - code: "PKG_LIST", - url: "https://auto-nvwa.amap.com/ws/nvwa/cpp5x/packages/", - method: "GET", - dataHandler: (res) => res.data, - }, - PROJECTS: { - name: "项目名称/渠道号", - code: "PROJECTS", - url: "http://auto-nvwa-staging.alibaba.com/ws/nvwa/cpp/select_projects/", - method: "GET", - state: "projects", - params: { - size: 5000, - }, - dataHandler: (res) => { - return res.data.data.result.map((d) => { - const { id, channelId, project_name } = d; - return { - label: `${project_name} / ${channelId}`, - value: id, - }; - }); - }, - }, - RELOAD: { - name: "重新执行", - code: "RELOAD", - url: "https://auto-nvwa.amap.com/cpp/configbuild/rebuild/", - method: "GET", - }, - BUILD_RESULT: { - name: "打包结果", - code: "BUILD_RESULT", - url: "https://auto-nvwa.amap.com/cpp/api/configbuild/get_build_result/", - method: "GET", - state: "results", - dataHandler: (res) => { - return res.data.result; - }, - }, - BUC_USER: { - name: "搜索用户", - code: "BUC_USER", - url: "https://auto-nvwa.amap.com/ws/nvwa/sso_users/", - method: "GET", - dataHandler: (res) => res.data.items, - }, - }; - this.$ds = new window.jianpin.DataSource(this, {}); + /*...*/ } __jp__initEnv() { - const hostname = window.location.hostname; - let env = "prod"; - - if (window.jianpin && window.jianpin.env === "dev") { - env = "dev"; - } else if (window.arsenalConfig) { - env = window.arsenalConfig.env; - } - - const urlSearchParams = new URLSearchParams(window.location.search); - const searchParams = {}; - - for (const [key, value] of urlSearchParams) { - searchParams[key] = value; - } - - this.$env = env; - this.$searchParams = searchParams; - - if (window.arsenal && window.arsenal.store) { - this.$user = window.arsenal.store.getState("user"); - this.$store = window.arsenal.store; - window.arsenal.store.subscribe("user", () => { - this.$user = window.arsenal.store.getState("user"); - }); - } else { - this.$store = { - subscribe: () => {}, - getState: () => {}, - }; - this.$user = this.__jp__mockUser || {}; - } + /*...*/ } __jp__initConfig() { - const __config = { - default: {}, - dev: {}, - daily: {}, - pre: {}, - prod: {}, - }; - this.$config = window.jianpin.utils.extend( - true, - {}, - __config.default, - __config[this.$env] - ); + /*...*/ } __jp__initUtils() { - this.$utils = { - message: window.jianpin.utils.message, - axios: window.jianpin.utils.axios, - moment: window.jianpin.utils.moment, - }; + /*...*/ } - setSearchItem(item) { - const searchState = this.state.searchValues; - - const reducer = (pre, key) => { - let value = searchState[key]; - - if (item.hasOwnProperty(key)) { - value = item[key]; - } - - return { ...pre, [key]: value || null }; - }; - - const searchValues = Object.keys(searchState).reduce(reducer, {}); - this.setState({ - searchValues, - }); + setSearchItem() { + /*...*/ } - fetchProject(value, callback) { - if (this.projectTimeout) { - clearTimeout(this.projectTimeout); - this.projectTimeout = null; - } - - this.currentProject = value; - - const fake = () => { - this.$ds - .resolve("PROJECTS", { - params: { - search_param: value, - }, - }) - .then((res) => { - if (this.currentProject !== value) { - return; - } - - callback(res || []); - }); - }; - - this.projectTimeout = setTimeout(fake, 300); + fetchProject() { + /*...*/ } - handleProjectSearch(value) { - if (value) { - this.fetchProject(value, (projects) => { - this.setState({ - projects, - }); - }); - } else { - this.setState({ - projects: [], - }); - } + handleProjectSearch() { + /*...*/ } handleProjectChange(id) { @@ -285,49 +129,12 @@ class Test$$Page extends React.Component { }); } - fetchUser(value, callback) { - if (this.userTimeout) { - clearTimeout(this.userTimeout); - this.userTimeout = null; - } - - this.currentUser = value; - - const fake = () => { - this.$ds - .resolve("BUC_USER", { - params: { - q: value, - }, - }) - .then((res) => { - if (this.currentUser !== value) { - return; - } - - const data = res.slice(0, 8).map((r) => ({ - label: `${r.id} / ${r.label}`, - value: r.id, - })); - callback(data); - }); - }; - - this.userTimeout = setTimeout(fake, 300); + fetchUser() { + /*...*/ } - handleUserSearch(value) { - if (value) { - this.fetchUser(value, (userOptions) => { - this.setState({ - userOptions, - }); - }); - } else { - this.setState({ - userOptions: [], - }); - } + handleUserSearch() { + /*...*/ } handleUserChange(user) { @@ -338,20 +145,7 @@ class Test$$Page extends React.Component { } fetchPkgs() { - const { pageIndex, pageSize } = this.pageParams; - this.$ds - .resolve("PKG_LIST", { - params: { ...this.searchParams, page: pageIndex, size: pageSize }, - }) - .then((res) => { - const { result, page } = res.data; - const { count } = page; - this.setState({ - isSearch: true, - pkgs: result, - total: count, - }); - }); + /*...*/ } onPageChange(pageIndex, pageSize) { @@ -370,115 +164,32 @@ class Test$$Page extends React.Component { return user.user_name; } - reload(id) { - if (!confirm("确实要重新执行?")) { - return; - } - - this.$ds - .resolve("RELOAD", { - params: { - build_id: id, - }, - }) - .then((res) => { - const { code, message } = res.data.status; - - if (code == 0) { - this.$utils.message.error(message); - } else { - const { pageIndex, pageSize } = this.pageParams; - this.onPageChange(pageIndex, pageSize); - } - }) - .catch((err) => { - this.$utils.message.error(err.message); - }); + reload() { + /*...*/ } - handleResult(e) { - // e.persist(); - e.preventDefault(); - e.stopPropagation(); - let href; - let tagName; - let target = e.target; - - do { - tagName = target.tagName.toUpperCase(); - href = target.getAttribute("href"); - target = target.parentNode; - } while (!href && tagName !== "TD"); - - if (!href) { - return; - } - - this.$ds - .resolve("BUILD_RESULT", { - params: { - build_id: href, - }, - }) - .then((res) => { - this.setState({ - resultVisible: true, - }); - }) - .catch((err) => { - this.$utils.message.error(`打包结果获取失败: ${err.message}`); - }); + handleResult() { + /*...*/ } handleDetail() { - // 跳转详情页面 TODO + /*...*/ } onResultCancel() { - this.setState({ - resultVisible: false, - }); + /*...*/ } - formatResult(item) { - if (!item) { - return "暂无结果"; - } - - const { channel, plat, version, status } = item; - return [channel, plat, version, status].join("-"); + formatResult() { + /*...*/ } handleDownload() { - const { results } = this.state; - - if (!results || results.length < 1) { - return; - } - - let link = document.createElement("a"); - link.style.display = "none"; - document.body.appendChild(link); - results.forEach((r) => { - link.href = r.download_link; - link.click(); - }); - document.body.removeChild(link); - link = null; + /*...*/ } - onFinish(f) { - const params = Object.keys(f).reduce((pre, key) => { - const value = f[key]; - - if (value === undefined) { - return pre; - } - - return { ...pre, [key]: value }; - }, {}); - this.searchParams = params; - this.fetchPkgs(); + onFinish() { + /*...*/ } componentDidMount() { diff --git a/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/schema.json5 b/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/schema.json5 index 6773910a2..2bd00adda 100644 --- a/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/schema.json5 +++ b/modules/code-generator/test-cases/react-app/demo_11-jsslot-2/schema.json5 @@ -191,39 +191,39 @@ methods: { __jp__init: { type: 'JSFunction', - value: 'function() {\n this.__jp__initEnv && this.__jp__initEnv();\n this.__jp__initConfig && this.__jp__initConfig();\n this.__jp__initDataSource && this.__jp__initDataSource();\n this.__jp__initRouter && this.__jp__initRouter();\n this.__jp__initUtils && this.__jp__initUtils();\n}', + value: 'function() { /*...*/ }', }, __jp__initRouter: { type: 'JSFunction', - value: 'function() {\n if (window.arsenal) {\n this.$router = new window.jianpin.ArsenalRouter({\n app: this.props.microApp,\n });\n } else {\n this.$router = new window.jianpin.ArsenalRouter();\n }\n}', + value: 'function() { /*...*/ }', }, __jp__initDataSource: { type: 'JSFunction', - value: "function() {\n this.$apis = {\n PKG_LIST: {\n name: '打包列表',\n code: 'PKG_LIST',\n url: 'https://auto-nvwa.amap.com/ws/nvwa/cpp5x/packages/',\n method: 'GET',\n dataHandler: res => res.data,\n },\n PROJECTS: {\n name: '项目名称/渠道号',\n code: 'PROJECTS',\n url:\n 'http://auto-nvwa-staging.alibaba.com/ws/nvwa/cpp/select_projects/',\n method: 'GET',\n state: 'projects',\n params: {\n size: 5000,\n },\n dataHandler: res => {\n return res.data.data.result.map(d => {\n const { id, channelId, project_name } = d;\n return {\n label: `${project_name} / ${channelId}`,\n value: id,\n };\n });\n },\n },\n RELOAD: {\n name: '重新执行',\n code: 'RELOAD',\n url: 'https://auto-nvwa.amap.com/cpp/configbuild/rebuild/',\n method: 'GET',\n },\n BUILD_RESULT: {\n name: '打包结果',\n code: 'BUILD_RESULT',\n url:\n 'https://auto-nvwa.amap.com/cpp/api/configbuild/get_build_result/',\n method: 'GET',\n state: 'results',\n dataHandler: res => {\n return res.data.result;\n },\n },\n BUC_USER: {\n name: '搜索用户',\n code: 'BUC_USER',\n url: 'https://auto-nvwa.amap.com/ws/nvwa/sso_users/',\n method: 'GET',\n dataHandler: res => res.data.items,\n },\n};\n this.$ds = new window.jianpin.DataSource(this, {});\n}", + value: 'function() { /*...*/ }', }, __jp__initEnv: { type: 'JSFunction', - value: "function() {\n const hostname = window.location.hostname;\n let env = 'prod';\n\n if (window.jianpin && window.jianpin.env === 'dev') {\n env = 'dev';\n } else if (window.arsenalConfig) {\n env = window.arsenalConfig.env;\n }\n\n const urlSearchParams = new URLSearchParams(window.location.search);\n const searchParams = {};\n for (const [key, value] of urlSearchParams) {\n searchParams[key] = value;\n }\n this.$env = env;\n this.$searchParams = searchParams;\n\n if (window.arsenal && window.arsenal.store) {\n this.$user = window.arsenal.store.getState('user');\n this.$store = window.arsenal.store;\n window.arsenal.store.subscribe('user', () => {\n this.$user = window.arsenal.store.getState('user');\n });\n } else {\n this.$store = {\n subscribe: () => {},\n getState: () => {},\n };\n this.$user = this.__jp__mockUser || {};\n }\n}", + value: 'function() { /*...*/ }', }, __jp__initConfig: { type: 'JSFunction', - value: 'function() {\n const __config = {\n "default": {},\n "dev": {},\n "daily": {},\n "pre": {},\n "prod": {}\n};\n\n this.$config = window.jianpin.utils.extend(true, {}, __config.default, __config[this.$env]);\n}', + value: 'function() { /*...*/ }', }, __jp__initUtils: { type: 'JSFunction', - value: 'function() {\n this.$utils = {\n message: window.jianpin.utils.message,\n axios: window.jianpin.utils.axios,\n moment: window.jianpin.utils.moment,\n };\n}', + value: 'function() { /*...*/ }', }, setSearchItem: { type: 'JSFunction', - value: 'function(item) {\n const searchState = this.state.searchValues;\n const reducer = (pre, key) => {\n let value = searchState[key];\n if (item.hasOwnProperty(key)) {\n value = item[key];\n }\n return {\n ...pre,\n [key]: value || null,\n };\n };\n const searchValues = Object.keys(searchState).reduce(reducer, {});\n this.setState({\n searchValues,\n });\n }', + value: 'function() { /*...*/ }', }, fetchProject: { type: 'JSFunction', - value: "function(value, callback) {\n if (this.projectTimeout) {\n clearTimeout(this.projectTimeout);\n this.projectTimeout = null;\n }\n this.currentProject = value;\n\n const fake = () => {\n this.$ds\n .resolve('PROJECTS', {\n params: { search_param: value },\n })\n .then(res => {\n if (this.currentProject !== value) {\n return;\n }\n callback(res || []);\n });\n };\n this.projectTimeout = setTimeout(fake, 300);\n }", + value: 'function() { /*...*/ }', }, handleProjectSearch: { type: 'JSFunction', - value: 'function(value) {\n if (value) {\n this.fetchProject(value, projects => {\n this.setState({ projects });\n });\n } else {\n this.setState({ projects: [] });\n }\n }', + value: 'function() { /*...*/ }', }, handleProjectChange: { type: 'JSFunction', @@ -231,11 +231,11 @@ }, fetchUser: { type: 'JSFunction', - value: "function(value, callback) {\n if (this.userTimeout) {\n clearTimeout(this.userTimeout);\n this.userTimeout = null;\n }\n this.currentUser = value;\n\n const fake = () => {\n this.$ds\n .resolve('BUC_USER', {\n params: { q: value },\n })\n .then(res => {\n if (this.currentUser !== value) {\n return;\n }\n const data = res.slice(0, 8).map(r => ({\n label: `${r.id} / ${r.label}`,\n value: r.id,\n }));\n callback(data);\n });\n };\n this.userTimeout = setTimeout(fake, 300);\n }", + value: 'function() { /*...*/ }', }, handleUserSearch: { type: 'JSFunction', - value: 'function(value) {\n if (value) {\n this.fetchUser(value, userOptions => {\n this.setState({ userOptions });\n });\n } else {\n this.setState({ userOptions: [] });\n }\n }', + value: 'function() { /*...*/ }', }, handleUserChange: { type: 'JSFunction', @@ -243,7 +243,7 @@ }, fetchPkgs: { type: 'JSFunction', - value: "function() {\n const { pageIndex, pageSize } = this.pageParams;\n this.$ds\n .resolve('PKG_LIST', {\n params: {\n ...this.searchParams,\n page: pageIndex,\n size: pageSize,\n },\n })\n .then(res => {\n const { result, page } = res.data;\n const { count } = page;\n this.setState({\n isSearch: true,\n pkgs: result,\n total: count,\n });\n });\n }", + value: 'function() { /*...*/ }', }, onPageChange: { type: 'JSFunction', @@ -259,31 +259,31 @@ }, reload: { type: 'JSFunction', - value: "function(id) {\n if (!confirm('确实要重新执行?')) {\n return;\n }\n this.$ds\n .resolve('RELOAD', {\n params: {\n build_id: id,\n },\n })\n .then(res => {\n const { code, message } = res.data.status;\n if (code == 0) {\n this.$utils.message.error(message);\n } else {\n const { pageIndex, pageSize } = this.pageParams;\n this.onPageChange(pageIndex, pageSize);\n }\n })\n .catch(err => {\n this.$utils.message.error(err.message);\n });\n }", + value: 'function() { /*...*/ }', }, handleResult: { type: 'JSFunction', - value: "function(e) {\n // e.persist();\n e.preventDefault();\n e.stopPropagation();\n let href;\n let tagName;\n let target = e.target;\n do {\n tagName = target.tagName.toUpperCase();\n href = target.getAttribute('href');\n target = target.parentNode;\n } while (!href && tagName !== 'TD');\n if (!href) {\n return;\n }\n\n this.$ds\n .resolve('BUILD_RESULT', {\n params: {\n build_id: href,\n },\n })\n .then(res => {\n this.setState({\n resultVisible: true,\n });\n })\n .catch(err => {\n this.$utils.message.error(`打包结果获取失败: ${err.message}`);\n });\n }", + value: 'function() { /*...*/ }', }, handleDetail: { type: 'JSFunction', - value: 'function() {\n // 跳转详情页面 TODO\n }', + value: 'function() { /*...*/ }', }, onResultCancel: { type: 'JSFunction', - value: 'function() {\n this.setState({\n resultVisible: false,\n });\n }', + value: 'function() { /*...*/ }', }, formatResult: { type: 'JSFunction', - value: "function(item) {\n if (!item) {\n return '暂无结果';\n }\n const { channel, plat, version, status } = item;\n return [channel, plat, version, status].join('-');\n }", + value: 'function() { /*...*/ }', }, handleDownload: { type: 'JSFunction', - value: "function() {\n const { results } = this.state;\n if (!results || results.length < 1) {\n return;\n }\n let link = document.createElement('a');\n link.style.display = 'none';\n document.body.appendChild(link);\n results.forEach(r => {\n link.href = r.download_link;\n link.click();\n });\n document.body.removeChild(link);\n link = null;\n }", + value: 'function() { /*...*/ }', }, onFinish: { type: 'JSFunction', - value: 'function(f) {\n const params = Object.keys(f).reduce((pre, key) => {\n const value = f[key];\n if (value === undefined) {\n return pre;\n }\n return {\n ...pre,\n [key]: value,\n };\n }, {});\n this.searchParams = params;\n this.fetchPkgs();\n }', + value: 'function() { /*...*/ }', }, }, state: { diff --git a/modules/code-generator/test-cases/react-module/demo1/expected/demo-project/package.json b/modules/code-generator/test-cases/react-module/demo1/expected/demo-project/package.json index 70d3d123f..ebb17b143 100644 --- a/modules/code-generator/test-cases/react-module/demo1/expected/demo-project/package.json +++ b/modules/code-generator/test-cases/react-module/demo1/expected/demo-project/package.json @@ -30,7 +30,7 @@ "engines": { "node": ">=8.0.0" }, "repository": { "type": "git", - "url": "http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master" + "url": "http://gitlab.xxx.com/msd/leak-scan/tree/master" }, "private": true, "originTemplate": "@alifd/scaffold-lite-js" diff --git a/modules/code-generator/test-cases/react-module/demo1/expected/demo-project/src/constants.js b/modules/code-generator/test-cases/react-module/demo1/expected/demo-project/src/constants.js index 4742ed117..c4a5859ee 100644 --- a/modules/code-generator/test-cases/react-module/demo1/expected/demo-project/src/constants.js +++ b/modules/code-generator/test-cases/react-module/demo1/expected/demo-project/src/constants.js @@ -1,3 +1,3 @@ -const __$$constants = { ENV: "prod", DOMAIN: "xxx.alibaba-inc.com" }; +const __$$constants = { ENV: "prod", DOMAIN: "xxx.xxx.com" }; export default __$$constants; diff --git a/modules/code-generator/test-cases/react-module/demo1/schema.json5 b/modules/code-generator/test-cases/react-module/demo1/schema.json5 index 443220d34..ca276bd5c 100644 --- a/modules/code-generator/test-cases/react-module/demo1/schema.json5 +++ b/modules/code-generator/test-cases/react-module/demo1/schema.json5 @@ -81,13 +81,13 @@ id: 'urlParams', type: 'urlParams', }, - // 示例数据源:https://shs.alibaba-inc.com/mock/1458/demo/user + // 示例数据源:https://shs.xxx.com/mock/1458/demo/user { id: 'user', type: 'fetch', options: { method: 'GET', - uri: 'https://shs.alibaba-inc.com/mock/1458/demo/user', + uri: 'https://shs.xxx.com/mock/1458/demo/user', isSync: true, }, dataHandler: { @@ -95,7 +95,7 @@ value: 'function (response) {\nif (!response.success){\n throw new Error(response.message);\n }\n return response.data;\n}', }, }, - // 示例数据源:https://shs.alibaba-inc.com/mock/1458/demo/orders + // 示例数据源:https://shs.xxx.com/mock/1458/demo/orders { id: 'orders', type: 'fetch', @@ -255,7 +255,7 @@ ], "constants": { "ENV": "prod", - "DOMAIN": "xxx.alibaba-inc.com" + "DOMAIN": "xxx.xxx.com" }, "i18n": { "zh-CN": { diff --git a/modules/code-generator/tests/bugfix/icejs-js-function1.schema.json b/modules/code-generator/tests/bugfix/icejs-js-function1.schema.json index 2d15ad2fa..09a9be3ea 100644 --- a/modules/code-generator/tests/bugfix/icejs-js-function1.schema.json +++ b/modules/code-generator/tests/bugfix/icejs-js-function1.schema.json @@ -200,55 +200,55 @@ "methods": { "__jp__init": { "type": "JSFunction", - "value": "function() {\n window.jianpin.emitter.emit('rootIns', this);\n this.__jp__initEnv && this.__jp__initEnv();\n this.__jp__initConfig && this.__jp__initConfig();\n this.__jp__initDataSource && this.__jp__initDataSource();\n this.__jp__initRouter && this.__jp__initRouter();\n this.__jp__initUtils && this.__jp__initUtils();\n this.__jp__initUziModel && this.__jp__initUziModel();\n this.__jp__registerModel && this.__jp__registerModel();\n this.__jp__finishedFn && this.__jp__finishedFn();\n}" + "value": "function() { /*...*/ }" }, "__jp__initRouter": { "type": "JSFunction", - "value": "function() {\n if (window.arsenal) {\n this.$router = new window.jianpin.ArsenalRouter({\n app: this.props.microApp,\n });\n } else {\n this.$router = new window.jianpin.ArsenalRouter();\n }\n}" + "value": "function() { /*...*/ }" }, "__jp__initDataSource": { "type": "JSFunction", - "value": "function() {\n this.$apis = {\n BUILD_LIST: {\n name: '打包列表',\n code: 'BUILD_LIST',\n url: '/ws/nvwa/android/combuild/get_build/',\n method: 'GET',\n dataHandler: res => res.data,\n },\n BUC_USER: {\n name: '搜索用户',\n code: 'BUC_USER',\n url: '/ws/nvwa/sso_users/',\n method: 'GET',\n },\n CHANNELS: {\n name: '渠道列表',\n code: 'CHANNELS',\n url: '/ws/nvwa/android/adaptproject/search/',\n method: 'GET',\n },\n};\n this.$ds = new window.jianpin.DataSource(this, {});\n}" + "value": "function() { /*...*/ }" }, "__jp__initEnv": { "type": "JSFunction", - "value": "function() {\n let env = 'prod';\n\n if (window.jianpin && window.jianpin.env === 'dev') {\n env = 'dev';\n } else if (window.arsenalConfig) {\n env = window.arsenalConfig.env;\n }\n\n const urlSearchParams = new URLSearchParams(window.location.search);\n const searchParams = {};\n for (const [key, value] of urlSearchParams) {\n searchParams[key] = value;\n }\n this.$env = env === 'local' ? (window.$arsenalEnv || 'dev') : env;\n this.$searchParams = searchParams;\n\n if (window.arsenal && window.arsenal.store) {\n this.$user = window.arsenal.store.getState('user');\n this.$store = window.arsenal.store;\n window.arsenal.store.subscribe('user', () => {\n this.$user = window.arsenal.store.getState('user');\n });\n } else {\n this.$store = {\n subscribe: () => {},\n getState: () => {},\n };\n this.$user = {};\n if (window.jianpin && typeof window.jianpin.getUser === 'function') {\n this.$user = window.jianpin.getUser() || {};\n }\n }\n}" + "value": "function() { /*...*/ }" }, "__jp__initConfig": { "type": "JSFunction", - "value": "function() {\n const __config = {\n \"default\": {},\n \"dev\": {\n \"apiOptions\": {\n \"apiPrefix\": \"https://auto-nvwa-test.alibaba.net\"\n }\n },\n \"daily\": {},\n \"pre\": {},\n \"prod\": {}\n};\n\n this.$config = window.jianpin.utils.extend(true, {}, __config.default, __config[this.$env]);\n\n this.$totalConfig = __config;\n}" + "value": "function() { /*...*/ }" }, "__jp__initUtils": { "type": "JSFunction", - "value": "function() {\n this.$utils = window.jianpin.utils;\n}" + "value": "function() { /*...*/ }" }, "__jp__initUziModel": { "type": "JSFunction", - "value": "function () {\n const defModel = {\n apis: {},\n state: {},\n exposes: {},\n effects: {},\n reducers: {},\n};\n this.$uziModel = {\n ...defModel,\n };\n}" + "value": "function() { /*...*/ }" }, "__jp__registerModel": { "type": "JSFunction", - "value": "function () {\n if (this.props.microModel) {\n this.$uziModel = this.props.microModel;\n return;\n }\n const ns = \"jianpin-ns\";\n const uziContext = window.jianpin.uziCore.createUziContext();\n const { register, subscribe, getUzi, getState } = uziContext;\n const { extend, parseJSFunc } = window.jianpin.utils;\n const model = extend(true, {}, this.$uziModel);\n parseJSFunc(model);\n register(ns, model);\n\n const uzi = getUzi(ns);\n subscribe((state) => {\n this.$uziModel = {\n ...this.$uziModel,\n state,\n };\n this.forceUpdate();\n }, ns);\n\n this.$uziModel = {\n apis: uzi.apis,\n uzi,\n loading: {},\n state: getState(ns),\n };\n}" + "value": "function() { /*...*/ }" }, "__jp__finishedFn": { "type": "JSFunction", - "value": "function () {\n window.jianpin.utils.parseJSFunc(this.$config);\n}" + "value": "function() { /*...*/ }" }, "initUrl": { "type": "JSFunction", - "value": "function() {\n const apiOptions = this.$config.apiOptions;\n const apiPrefix = (apiOptions && apiOptions.apiPrefix) || '';\n this.userUrl = `${apiPrefix}${this.$apis.BUC_USER.url}`;\n this.channelUrl = `${apiPrefix}${this.$apis.CHANNELS.url}`;\n }" + "value": "function() { /*...*/ }" }, "initUserHeaders": { "type": "JSFunction", - "value": "function() {\n this.userHeaders = {};\n if (this.$user && this.$user.workid) {\n this.userHeaders = {\n headers: {\n 'buc-user': window.jianpin.utils.Base64.encode(\n JSON.stringify(this.$user)\n ),\n },\n };\n }\n }" + "value": "function() { /*...*/ }" }, "fetchBuilds": { "type": "JSFunction", - "value": "function() {\n this.$ds\n .resolve('BUILD_LIST', {\n params: this.searchParams,\n })\n .then(res => {\n const { page, builds } = res;\n const { num_pages, page_number, per_page } = page;\n this.setState({\n page: page_number,\n pageSize: per_page,\n total: num_pages * per_page,\n builds,\n });\n });\n }" + "value": "function() { /*...*/ }" }, "userHandler": { "type": "JSFunction", - "value": "function(res) {\n const data = res.data.items.map(item => {\n const { id, label } = item;\n return {\n label: `${id}/${label}`,\n value: id,\n };\n });\n return data;\n }" + "value": "function() { /*...*/ }" }, "channelHandler": { "type": "JSFunction", diff --git a/modules/code-generator/tests/bugfix/icejs-missing-imports-1.schema.json b/modules/code-generator/tests/bugfix/icejs-missing-imports-1.schema.json index fec3da9cd..52b3553b7 100644 --- a/modules/code-generator/tests/bugfix/icejs-missing-imports-1.schema.json +++ b/modules/code-generator/tests/bugfix/icejs-missing-imports-1.schema.json @@ -188,63 +188,63 @@ "methods": { "__jp__init": { "type": "JSFunction", - "value": "function() {\n window.jianpin.emitter.emit('rootIns', this);\n this.__jp__initEnv && this.__jp__initEnv();\n this.__jp__initConfig && this.__jp__initConfig();\n this.__jp__initDataSource && this.__jp__initDataSource();\n this.__jp__initRouter && this.__jp__initRouter();\n this.__jp__initUtils && this.__jp__initUtils();\n this.__jp__initUziModel && this.__jp__initUziModel();\n this.__jp__registerModel && this.__jp__registerModel();\n this.__jp__finishedFn && this.__jp__finishedFn();\n}" + "value": "function() { /* ... */ }" }, "__jp__initRouter": { "type": "JSFunction", - "value": "function() {\n if (window.arsenal) {\n this.$router = new window.jianpin.ArsenalRouter({\n app: this.props.microApp,\n });\n } else {\n this.$router = new window.jianpin.ArsenalRouter();\n }\n}" + "value": "function() { /* ... */ }" }, "__jp__initDataSource": { "type": "JSFunction", - "value": "function() {\n this.$apis = {\n PROJECTS: {\n name: '项目列表',\n code: 'PROJECTS',\n url: '/ws/nvwa/android/adaptproject/list/',\n method: 'GET',\n dataHandler: res => res.data,\n },\n CHANNEL: {\n name: '项目名称或渠道号',\n code: 'CHANNEL',\n url: '/ws/nvwa/cpp/select_projects/',\n method: 'GET',\n dataHandler: res => res.data.data,\n },\n};\n this.$ds = new window.jianpin.DataSource(this,{});\n}" + "value": "function() { /* ... */ }" }, "__jp__initEnv": { "type": "JSFunction", - "value": "function() {\n let env = 'prod';\n\n if (window.jianpin && window.jianpin.env === 'dev') {\n env = 'dev';\n } else if (window.arsenalConfig) {\n env = window.arsenalConfig.env;\n }\n\n const urlSearchParams = new URLSearchParams(window.location.search);\n const searchParams = {};\n for (const [key, value] of urlSearchParams) {\n searchParams[key] = value;\n }\n this.$env = env === 'local' ? (window.$arsenalEnv || 'dev') : env;\n this.$searchParams = searchParams;\n\n if (window.arsenal && window.arsenal.store) {\n this.$user = window.arsenal.store.getState('user');\n this.$store = window.arsenal.store;\n window.arsenal.store.subscribe('user', () => {\n this.$user = window.arsenal.store.getState('user');\n });\n } else {\n this.$store = {\n subscribe: () => {},\n getState: () => {},\n };\n this.$user = {};\n if (window.jianpin && typeof window.jianpin.getUser === 'function') {\n this.$user = window.jianpin.getUser() || {};\n }\n }\n}" + "value": "function() { /* ... */ }" }, "__jp__initConfig": { "type": "JSFunction", - "value": "function() {\n const __config = {\n \"default\": {\n \"mockUser\": {\n \"userid\": \"melon.lbw\",\n \"dep\": \"阿里集团-高德事业群-汽车业务中心-工程研发部-服务效率组\",\n \"cname\": \"永元\",\n \"lastName\": \"刘博文1222222\",\n \"workid\": \"166380\",\n \"siteLanguage\": \"ZH-CN\",\n \"bucid\": 111409615,\n \"login\": \"melon.lbw\",\n \"email\": \"melon.lbw@alibaba.net\",\n \"name\": \"永元\",\n \"html_url\": \"https://work.alibaba-inc.com/work/u/166380\",\n \"avatar_url\": \"https://work.alibaba-inc.com/photo/166380.220x220.jpg\",\n \"im_url\": \"https://work.alibaba-inc.com/new_amos_im_alisoft_com/msg.aw?v=2&uid=%E6%B0%B8%E5%85%83&site=cntaobao&charset=utf-8&s=1\",\n \"umid\": \"\",\n \"namespace\": \"buc\",\n \"realmId\": 10000,\n \"token\": \"d4526b5fa0f845a688055935b8962606a3f9cf00\",\n \"tokenDt\": 1639969093256\n }\n },\n \"dev\": {\n \"apiOptions\": {\n \"apiPrefix\": \"https://auto-nvwa.alibaba.net\"\n }\n },\n \"daily\": {},\n \"pre\": {},\n \"prod\": {}\n};\n\n this.$config = window.jianpin.utils.extend(true, {}, __config.default, __config[this.$env]);\n\n this.$totalConfig = __config;\n}" + "value": "function() { /* ... */ }" }, "__jp__initUtils": { "type": "JSFunction", - "value": "function() {\n this.$utils = window.jianpin.utils;\n}" + "value": "function() { /* ... */ }" }, "__jp__initUziModel": { "type": "JSFunction", - "value": "function () {\n const defModel = {\n \"apis\": {},\n \"state\": {\n \"channelId\": \"C04010264004\"\n },\n \"exposes\": {},\n \"effects\": {},\n \"reducers\": {}\n};\n this.$uziModel = {\n ...defModel,\n };\n}" + "value": "function() { /* ... */ }" }, "__jp__registerModel": { "type": "JSFunction", - "value": "function () {\n if (this.props.microModel) {\n this.$uziModel = this.props.microModel;\n return;\n }\n const ns = \"jianpin-ns\";\n const uziContext = window.jianpin.uziCore.createUziContext();\n const { register, subscribe, getUzi, getState } = uziContext;\n const { extend, parseJSFunc } = window.jianpin.utils;\n const model = extend(true, {}, this.$uziModel);\n parseJSFunc(model);\n register(ns, model);\n\n const uzi = getUzi(ns);\n subscribe((state) => {\n this.$uziModel = {\n ...this.$uziModel,\n state,\n };\n this.forceUpdate();\n }, ns);\n\n this.$uziModel = {\n apis: uzi.apis,\n uzi,\n loading: {},\n state: getState(ns),\n };\n}" + "value": "function() { /* ... */ }" }, "__jp__finishedFn": { "type": "JSFunction", - "value": "function () {\n window.jianpin.utils.parseJSFunc(this.$config);\n}" + "value": "function() { /* ... */ }" }, "initUrl": { "type": "JSFunction", - "value": "function() {\n const apiOptions = this.$config.apiOptions;\n const apiPrefix = (apiOptions && apiOptions.apiPrefix) || '';\n this.channelUrl = `${apiPrefix}${this.$apis.CHANNEL.url}?size=5000`;\n }" + "value": "function() { /* ... */ }" }, "channelHandler": { "type": "JSFunction", - "value": "function(res) {\n const data = res.data.data.result.map(item => {\n const { id, project_name } = item;\n return {\n label: project_name,\n value: id,\n };\n });\n return data;\n }" + "value": "function() { /* ... */ }" }, "fetchProjects": { "type": "JSFunction", - "value": "function() {\n this.$ds\n .resolve('PROJECTS', {\n params: this.searchParams,\n })\n .then(res => {\n const { project_list, page } = res;\n const { num_pages: total } = page;\n const projects = project_list.map(r => {\n const { dec_channels, ...rest } = r;\n const { id } = rest;\n let col = {};\n if (dec_channels && dec_channels.length > 0) {\n col = {\n children: dec_channels,\n };\n }\n return {\n key: id,\n ...rest,\n ...col,\n };\n });\n this.setState({\n projects,\n total,\n });\n });\n }" + "value": "function() { /* ... */ }" }, "setSearchParams": { "type": "JSFunction", - "value": "function(params) {\n this.searchParams = {\n ...this.searchParams,\n ...params,\n };\n }" + "value": "function() { /* ... */ }" }, "onPageChange": { "type": "JSFunction", - "value": "function(pageIndex, pageSize) {\n this.setSearchParams({\n page: pageIndex,\n page_size: pageSize,\n });\n this.fetchProjects();\n }" + "value": "function() { /* ... */ }" }, "renderName": { "type": "JSFunction", - "value": "function(col) {\n return col.name;\n }" + "value": "function() { /* ... */ }" }, "renderPlatform": { "type": "JSFunction", @@ -256,7 +256,7 @@ }, "onFinish": { "type": "JSFunction", - "value": "function(f) {\n const params = Object.keys(f).reduce((pre, key) => {\n const value = f[key];\n if (value === undefined) {\n return pre;\n }\n return {\n ...pre,\n [key]: value,\n };\n }, {});\n this.setSearchParams(params);\n this.fetchProjects();\n }" + "value": "function() { /* ... */ }" }, "onSearchChannel": { "type": "JSFunction", @@ -264,11 +264,11 @@ }, "toNewAddPage": { "type": "JSFunction", - "value": "function() {\n this.$router.push('/android/adapt_project/add');\n }" + "value": "function() { /* ... */ }" }, "handlerModify": { "type": "JSFunction", - "value": "function({ id }) {\n this.$router.push('/android/adapt_project/change?id=' + id);\n }" + "value": "function() { /* ... */ }" }, "infoTip": { "type": "JSFunction", @@ -276,7 +276,7 @@ }, "renderCreator": { "type": "JSFunction", - "value": "function(creator) {\n return creator ? creator.user_name : '暂无';\n }" + "value": "function() { /* ... */ }" } }, "hidden": false, diff --git a/modules/code-generator/tests/public/SchemaParser/data/schema-with-slot.json b/modules/code-generator/tests/public/SchemaParser/data/schema-with-slot.json index 07bd0db69..1519941cb 100644 --- a/modules/code-generator/tests/public/SchemaParser/data/schema-with-slot.json +++ b/modules/code-generator/tests/public/SchemaParser/data/schema-with-slot.json @@ -173,15 +173,15 @@ "lifeCycles": { "constructor": { "type": "JSFunction", - "value": "function() {\n this.__jp__init();\n this.statusDesc = {\n 0: '失败',\n 1: '成功',\n 2: '构建中',\n 3: '构建超时',\n };\n this.pageParams = {};\n this.searchParams = {};\n this.userTimeout = null;\n this.currentUser = null;\n this.notFoundContent = null;\n this.projectTimeout = null;\n this.currentProject = null;\n }" + "value": "function() { /*...*/ }" }, "componentDidMount": { "type": "JSFunction", - "value": "function() {\n this.$ds.resolve('PROJECTS');\n if (this.userTimeout) {\n clearTimeout(this.userTimeout);\n this.userTimeout = null;\n }\n if (this.projectTimeout) {\n clearTimeout(this.projectTimeout);\n this.projectTimeout = null;\n }\n }" + "value": "function() { /*...*/ }" }, "componentDidUpdate": { "type": "JSFunction", - "value": "function(prevProps, prevState, snapshot) {}" + "value": "function() { /*...*/ }" }, "componentWillUnmount": { "type": "JSFunction", @@ -191,99 +191,99 @@ "methods": { "__jp__init": { "type": "JSFunction", - "value": "function() {\n this.__jp__initEnv && this.__jp__initEnv();\n this.__jp__initConfig && this.__jp__initConfig();\n this.__jp__initDataSource && this.__jp__initDataSource();\n this.__jp__initRouter && this.__jp__initRouter();\n this.__jp__initUtils && this.__jp__initUtils();\n}" + "value": "function() { /*...*/ }" }, "__jp__initRouter": { "type": "JSFunction", - "value": "function() {\n if (window.arsenal) {\n this.$router = new window.jianpin.ArsenalRouter({\n app: this.props.microApp,\n });\n } else {\n this.$router = new window.jianpin.ArsenalRouter();\n }\n}" + "value": "function() { /*...*/ }" }, "__jp__initDataSource": { "type": "JSFunction", - "value": "function() {\n this.$apis = {\n PKG_LIST: {\n name: '打包列表',\n code: 'PKG_LIST',\n url: 'https://auto-nvwa.amap.com/ws/nvwa/cpp5x/packages/',\n method: 'GET',\n dataHandler: res => res.data,\n },\n PROJECTS: {\n name: '项目名称/渠道号',\n code: 'PROJECTS',\n url:\n 'http://auto-nvwa-staging.alibaba.com/ws/nvwa/cpp/select_projects/',\n method: 'GET',\n state: 'projects',\n params: {\n size: 5000,\n },\n dataHandler: res => {\n return res.data.data.result.map(d => {\n const { id, channelId, project_name } = d;\n return {\n label: `${project_name} / ${channelId}`,\n value: id,\n };\n });\n },\n },\n RELOAD: {\n name: '重新执行',\n code: 'RELOAD',\n url: 'https://auto-nvwa.amap.com/cpp/configbuild/rebuild/',\n method: 'GET',\n },\n BUILD_RESULT: {\n name: '打包结果',\n code: 'BUILD_RESULT',\n url:\n 'https://auto-nvwa.amap.com/cpp/api/configbuild/get_build_result/',\n method: 'GET',\n state: 'results',\n dataHandler: res => {\n return res.data.result;\n },\n },\n BUC_USER: {\n name: '搜索用户',\n code: 'BUC_USER',\n url: 'https://auto-nvwa.amap.com/ws/nvwa/sso_users/',\n method: 'GET',\n dataHandler: res => res.data.items,\n },\n};\n this.$ds = new window.jianpin.DataSource(this, {});\n}" + "value": "function() { /*...*/ }" }, "__jp__initEnv": { "type": "JSFunction", - "value": "function() {\n const hostname = window.location.hostname;\n let env = 'prod';\n\n if (window.jianpin && window.jianpin.env === 'dev') {\n env = 'dev';\n } else if (window.arsenalConfig) {\n env = window.arsenalConfig.env;\n }\n\n const urlSearchParams = new URLSearchParams(window.location.search);\n const searchParams = {};\n for (const [key, value] of urlSearchParams) {\n searchParams[key] = value;\n }\n this.$env = env;\n this.$searchParams = searchParams;\n\n if (window.arsenal && window.arsenal.store) {\n this.$user = window.arsenal.store.getState('user');\n this.$store = window.arsenal.store;\n window.arsenal.store.subscribe('user', () => {\n this.$user = window.arsenal.store.getState('user');\n });\n } else {\n this.$store = {\n subscribe: () => {},\n getState: () => {},\n };\n this.$user = this.__jp__mockUser || {};\n }\n}" + "value": "function() { /*...*/ }" }, "__jp__initConfig": { "type": "JSFunction", - "value": "function() {\n const __config = {\n \"default\": {},\n \"dev\": {},\n \"daily\": {},\n \"pre\": {},\n \"prod\": {}\n};\n\n this.$config = window.jianpin.utils.extend(true, {}, __config.default, __config[this.$env]);\n}" + "value": "function() { /*...*/ }" }, "__jp__initUtils": { "type": "JSFunction", - "value": "function() {\n this.$utils = {\n message: window.jianpin.utils.message,\n axios: window.jianpin.utils.axios,\n moment: window.jianpin.utils.moment,\n };\n}" + "value": "function() { /*...*/ }" }, "setSearchItem": { "type": "JSFunction", - "value": "function(item) {\n const searchState = this.state.searchValues;\n const reducer = (pre, key) => {\n let value = searchState[key];\n if (item.hasOwnProperty(key)) {\n value = item[key];\n }\n return {\n ...pre,\n [key]: value || null,\n };\n };\n const searchValues = Object.keys(searchState).reduce(reducer, {});\n this.setState({\n searchValues,\n });\n }" + "value": "function() { /*...*/ }" }, "fetchProject": { "type": "JSFunction", - "value": "function(value, callback) {\n if (this.projectTimeout) {\n clearTimeout(this.projectTimeout);\n this.projectTimeout = null;\n }\n this.currentProject = value;\n\n const fake = () => {\n this.$ds\n .resolve('PROJECTS', {\n params: { search_param: value },\n })\n .then(res => {\n if (this.currentProject !== value) {\n return;\n }\n callback(res || []);\n });\n };\n this.projectTimeout = setTimeout(fake, 300);\n }" + "value": "function() { /*...*/ }" }, "handleProjectSearch": { "type": "JSFunction", - "value": "function(value) {\n if (value) {\n this.fetchProject(value, projects => {\n this.setState({ projects });\n });\n } else {\n this.setState({ projects: [] });\n }\n }" + "value": "function() { /*...*/ }" }, "handleProjectChange": { "type": "JSFunction", - "value": "function(id) {\n this.setSearchItem({\n channel_id: id,\n });\n }" + "value": "function() { /*...*/ }" }, "fetchUser": { "type": "JSFunction", - "value": "function(value, callback) {\n if (this.userTimeout) {\n clearTimeout(this.userTimeout);\n this.userTimeout = null;\n }\n this.currentUser = value;\n\n const fake = () => {\n this.$ds\n .resolve('BUC_USER', {\n params: { q: value },\n })\n .then(res => {\n if (this.currentUser !== value) {\n return;\n }\n const data = res.slice(0, 8).map(r => ({\n label: `${r.id} / ${r.label}`,\n value: r.id,\n }));\n callback(data);\n });\n };\n this.userTimeout = setTimeout(fake, 300);\n }" + "value": "function() { /*...*/ }" }, "handleUserSearch": { "type": "JSFunction", - "value": "function(value) {\n if (value) {\n this.fetchUser(value, userOptions => {\n this.setState({ userOptions });\n });\n } else {\n this.setState({ userOptions: [] });\n }\n }" + "value": "function() { /*...*/ }" }, "handleUserChange": { "type": "JSFunction", - "value": "function(user) {\n console.log('debug user', user);\n this.setSearchItem({\n user_id: user,\n });\n }" + "value": "function() { /*...*/ }" }, "fetchPkgs": { "type": "JSFunction", - "value": "function() {\n const { pageIndex, pageSize } = this.pageParams;\n this.$ds\n .resolve('PKG_LIST', {\n params: {\n ...this.searchParams,\n page: pageIndex,\n size: pageSize,\n },\n })\n .then(res => {\n const { result, page } = res.data;\n const { count } = page;\n this.setState({\n isSearch: true,\n pkgs: result,\n total: count,\n });\n });\n }" + "value": "function() { /*...*/ }" }, "onPageChange": { "type": "JSFunction", - "value": "function(pageIndex, pageSize) {\n this.pageParams = {\n pageIndex,\n pageSize,\n };\n this.fetchPkgs();\n }" + "value": "function() { /*...*/ }" }, "renderTime": { "type": "JSFunction", - "value": "function(time) {\n return this.$utils.moment(time).format('YYYY-MM-DD HH:mm');\n }" + "value": "function() { /*...*/ }" }, "renderUserName": { "type": "JSFunction", - "value": "function(user) {\n return user.user_name;\n }" + "value": "function() { /*...*/ }" }, "reload": { "type": "JSFunction", - "value": "function(id) {\n if (!confirm('确实要重新执行?')) {\n return;\n }\n this.$ds\n .resolve('RELOAD', {\n params: {\n build_id: id,\n },\n })\n .then(res => {\n const { code, message } = res.data.status;\n if (code == 0) {\n this.$utils.message.error(message);\n } else {\n const { pageIndex, pageSize } = this.pageParams;\n this.onPageChange(pageIndex, pageSize);\n }\n })\n .catch(err => {\n this.$utils.message.error(err.message);\n });\n }" + "value": "function() { /*...*/ }" }, "handleResult": { "type": "JSFunction", - "value": "function(e) {\n // e.persist();\n e.preventDefault();\n e.stopPropagation();\n let href;\n let tagName;\n let target = e.target;\n do {\n tagName = target.tagName.toUpperCase();\n href = target.getAttribute('href');\n target = target.parentNode;\n } while (!href && tagName !== 'TD');\n if (!href) {\n return;\n }\n\n this.$ds\n .resolve('BUILD_RESULT', {\n params: {\n build_id: href,\n },\n })\n .then(res => {\n this.setState({\n resultVisible: true,\n });\n })\n .catch(err => {\n this.$utils.message.error(`打包结果获取失败: ${err.message}`);\n });\n }" + "value": "function() { /*...*/ }" }, "handleDetail": { "type": "JSFunction", - "value": "function() {\n // 跳转详情页面 TODO\n }" + "value": "function() { /*...*/ }" }, "onResultCancel": { "type": "JSFunction", - "value": "function() {\n this.setState({\n resultVisible: false,\n });\n }" + "value": "function() { /*...*/ }" }, "formatResult": { "type": "JSFunction", - "value": "function(item) {\n if (!item) {\n return '暂无结果';\n }\n const { channel, plat, version, status } = item;\n return [channel, plat, version, status].join('-');\n }" + "value": "function() { /*...*/ }" }, "handleDownload": { "type": "JSFunction", - "value": "function() {\n const { results } = this.state;\n if (!results || results.length < 1) {\n return;\n }\n let link = document.createElement('a');\n link.style.display = 'none';\n document.body.appendChild(link);\n results.forEach(r => {\n link.href = r.download_link;\n link.click();\n });\n document.body.removeChild(link);\n link = null;\n }" + "value": "function() { /*...*/ }" }, "onFinish": { "type": "JSFunction", - "value": "function(f) {\n const params = Object.keys(f).reduce((pre, key) => {\n const value = f[key];\n if (value === undefined) {\n return pre;\n }\n return {\n ...pre,\n [key]: value,\n };\n }, {});\n this.searchParams = params;\n this.fetchPkgs();\n }" + "value": "function() { /*...*/ }" } }, "state": { diff --git a/modules/code-generator/tests/utils/schema/data/schema-with-slot.json b/modules/code-generator/tests/utils/schema/data/schema-with-slot.json index 07bd0db69..e8f380b5f 100644 --- a/modules/code-generator/tests/utils/schema/data/schema-with-slot.json +++ b/modules/code-generator/tests/utils/schema/data/schema-with-slot.json @@ -173,11 +173,11 @@ "lifeCycles": { "constructor": { "type": "JSFunction", - "value": "function() {\n this.__jp__init();\n this.statusDesc = {\n 0: '失败',\n 1: '成功',\n 2: '构建中',\n 3: '构建超时',\n };\n this.pageParams = {};\n this.searchParams = {};\n this.userTimeout = null;\n this.currentUser = null;\n this.notFoundContent = null;\n this.projectTimeout = null;\n this.currentProject = null;\n }" + "value": "function() { /*...*/ }" }, "componentDidMount": { "type": "JSFunction", - "value": "function() {\n this.$ds.resolve('PROJECTS');\n if (this.userTimeout) {\n clearTimeout(this.userTimeout);\n this.userTimeout = null;\n }\n if (this.projectTimeout) {\n clearTimeout(this.projectTimeout);\n this.projectTimeout = null;\n }\n }" + "value": "function() { /*...*/ }" }, "componentDidUpdate": { "type": "JSFunction", @@ -191,99 +191,99 @@ "methods": { "__jp__init": { "type": "JSFunction", - "value": "function() {\n this.__jp__initEnv && this.__jp__initEnv();\n this.__jp__initConfig && this.__jp__initConfig();\n this.__jp__initDataSource && this.__jp__initDataSource();\n this.__jp__initRouter && this.__jp__initRouter();\n this.__jp__initUtils && this.__jp__initUtils();\n}" + "value": "function() { /*...*/ }" }, "__jp__initRouter": { "type": "JSFunction", - "value": "function() {\n if (window.arsenal) {\n this.$router = new window.jianpin.ArsenalRouter({\n app: this.props.microApp,\n });\n } else {\n this.$router = new window.jianpin.ArsenalRouter();\n }\n}" + "value": "function() { /*...*/ }" }, "__jp__initDataSource": { "type": "JSFunction", - "value": "function() {\n this.$apis = {\n PKG_LIST: {\n name: '打包列表',\n code: 'PKG_LIST',\n url: 'https://auto-nvwa.amap.com/ws/nvwa/cpp5x/packages/',\n method: 'GET',\n dataHandler: res => res.data,\n },\n PROJECTS: {\n name: '项目名称/渠道号',\n code: 'PROJECTS',\n url:\n 'http://auto-nvwa-staging.alibaba.com/ws/nvwa/cpp/select_projects/',\n method: 'GET',\n state: 'projects',\n params: {\n size: 5000,\n },\n dataHandler: res => {\n return res.data.data.result.map(d => {\n const { id, channelId, project_name } = d;\n return {\n label: `${project_name} / ${channelId}`,\n value: id,\n };\n });\n },\n },\n RELOAD: {\n name: '重新执行',\n code: 'RELOAD',\n url: 'https://auto-nvwa.amap.com/cpp/configbuild/rebuild/',\n method: 'GET',\n },\n BUILD_RESULT: {\n name: '打包结果',\n code: 'BUILD_RESULT',\n url:\n 'https://auto-nvwa.amap.com/cpp/api/configbuild/get_build_result/',\n method: 'GET',\n state: 'results',\n dataHandler: res => {\n return res.data.result;\n },\n },\n BUC_USER: {\n name: '搜索用户',\n code: 'BUC_USER',\n url: 'https://auto-nvwa.amap.com/ws/nvwa/sso_users/',\n method: 'GET',\n dataHandler: res => res.data.items,\n },\n};\n this.$ds = new window.jianpin.DataSource(this, {});\n}" + "value": "function() { /*...*/ }" }, "__jp__initEnv": { "type": "JSFunction", - "value": "function() {\n const hostname = window.location.hostname;\n let env = 'prod';\n\n if (window.jianpin && window.jianpin.env === 'dev') {\n env = 'dev';\n } else if (window.arsenalConfig) {\n env = window.arsenalConfig.env;\n }\n\n const urlSearchParams = new URLSearchParams(window.location.search);\n const searchParams = {};\n for (const [key, value] of urlSearchParams) {\n searchParams[key] = value;\n }\n this.$env = env;\n this.$searchParams = searchParams;\n\n if (window.arsenal && window.arsenal.store) {\n this.$user = window.arsenal.store.getState('user');\n this.$store = window.arsenal.store;\n window.arsenal.store.subscribe('user', () => {\n this.$user = window.arsenal.store.getState('user');\n });\n } else {\n this.$store = {\n subscribe: () => {},\n getState: () => {},\n };\n this.$user = this.__jp__mockUser || {};\n }\n}" + "value": "function() { /*...*/ }" }, "__jp__initConfig": { "type": "JSFunction", - "value": "function() {\n const __config = {\n \"default\": {},\n \"dev\": {},\n \"daily\": {},\n \"pre\": {},\n \"prod\": {}\n};\n\n this.$config = window.jianpin.utils.extend(true, {}, __config.default, __config[this.$env]);\n}" + "value": "function() { /*...*/ }" }, "__jp__initUtils": { "type": "JSFunction", - "value": "function() {\n this.$utils = {\n message: window.jianpin.utils.message,\n axios: window.jianpin.utils.axios,\n moment: window.jianpin.utils.moment,\n };\n}" + "value": "function() { /*...*/ }" }, "setSearchItem": { "type": "JSFunction", - "value": "function(item) {\n const searchState = this.state.searchValues;\n const reducer = (pre, key) => {\n let value = searchState[key];\n if (item.hasOwnProperty(key)) {\n value = item[key];\n }\n return {\n ...pre,\n [key]: value || null,\n };\n };\n const searchValues = Object.keys(searchState).reduce(reducer, {});\n this.setState({\n searchValues,\n });\n }" + "value": "function() { /*...*/ }" }, "fetchProject": { "type": "JSFunction", - "value": "function(value, callback) {\n if (this.projectTimeout) {\n clearTimeout(this.projectTimeout);\n this.projectTimeout = null;\n }\n this.currentProject = value;\n\n const fake = () => {\n this.$ds\n .resolve('PROJECTS', {\n params: { search_param: value },\n })\n .then(res => {\n if (this.currentProject !== value) {\n return;\n }\n callback(res || []);\n });\n };\n this.projectTimeout = setTimeout(fake, 300);\n }" + "value": "function() { /*...*/ }" }, "handleProjectSearch": { "type": "JSFunction", - "value": "function(value) {\n if (value) {\n this.fetchProject(value, projects => {\n this.setState({ projects });\n });\n } else {\n this.setState({ projects: [] });\n }\n }" + "value": "function() { /*...*/ }" }, "handleProjectChange": { "type": "JSFunction", - "value": "function(id) {\n this.setSearchItem({\n channel_id: id,\n });\n }" + "value": "function() { /*...*/ }" }, "fetchUser": { "type": "JSFunction", - "value": "function(value, callback) {\n if (this.userTimeout) {\n clearTimeout(this.userTimeout);\n this.userTimeout = null;\n }\n this.currentUser = value;\n\n const fake = () => {\n this.$ds\n .resolve('BUC_USER', {\n params: { q: value },\n })\n .then(res => {\n if (this.currentUser !== value) {\n return;\n }\n const data = res.slice(0, 8).map(r => ({\n label: `${r.id} / ${r.label}`,\n value: r.id,\n }));\n callback(data);\n });\n };\n this.userTimeout = setTimeout(fake, 300);\n }" + "value": "function() { /*...*/ }" }, "handleUserSearch": { "type": "JSFunction", - "value": "function(value) {\n if (value) {\n this.fetchUser(value, userOptions => {\n this.setState({ userOptions });\n });\n } else {\n this.setState({ userOptions: [] });\n }\n }" + "value": "function() { /*...*/ }" }, "handleUserChange": { "type": "JSFunction", - "value": "function(user) {\n console.log('debug user', user);\n this.setSearchItem({\n user_id: user,\n });\n }" + "value": "function() { /*...*/ }" }, "fetchPkgs": { "type": "JSFunction", - "value": "function() {\n const { pageIndex, pageSize } = this.pageParams;\n this.$ds\n .resolve('PKG_LIST', {\n params: {\n ...this.searchParams,\n page: pageIndex,\n size: pageSize,\n },\n })\n .then(res => {\n const { result, page } = res.data;\n const { count } = page;\n this.setState({\n isSearch: true,\n pkgs: result,\n total: count,\n });\n });\n }" + "value": "function() { /*...*/ }" }, "onPageChange": { "type": "JSFunction", - "value": "function(pageIndex, pageSize) {\n this.pageParams = {\n pageIndex,\n pageSize,\n };\n this.fetchPkgs();\n }" + "value": "function() { /*...*/ }" }, "renderTime": { "type": "JSFunction", - "value": "function(time) {\n return this.$utils.moment(time).format('YYYY-MM-DD HH:mm');\n }" + "value": "function() { /*...*/ }" }, "renderUserName": { "type": "JSFunction", - "value": "function(user) {\n return user.user_name;\n }" + "value": "function() { /*...*/ }" }, "reload": { "type": "JSFunction", - "value": "function(id) {\n if (!confirm('确实要重新执行?')) {\n return;\n }\n this.$ds\n .resolve('RELOAD', {\n params: {\n build_id: id,\n },\n })\n .then(res => {\n const { code, message } = res.data.status;\n if (code == 0) {\n this.$utils.message.error(message);\n } else {\n const { pageIndex, pageSize } = this.pageParams;\n this.onPageChange(pageIndex, pageSize);\n }\n })\n .catch(err => {\n this.$utils.message.error(err.message);\n });\n }" + "value": "function() { /*...*/ }" }, "handleResult": { "type": "JSFunction", - "value": "function(e) {\n // e.persist();\n e.preventDefault();\n e.stopPropagation();\n let href;\n let tagName;\n let target = e.target;\n do {\n tagName = target.tagName.toUpperCase();\n href = target.getAttribute('href');\n target = target.parentNode;\n } while (!href && tagName !== 'TD');\n if (!href) {\n return;\n }\n\n this.$ds\n .resolve('BUILD_RESULT', {\n params: {\n build_id: href,\n },\n })\n .then(res => {\n this.setState({\n resultVisible: true,\n });\n })\n .catch(err => {\n this.$utils.message.error(`打包结果获取失败: ${err.message}`);\n });\n }" + "value": "function() { /*...*/ }" }, "handleDetail": { "type": "JSFunction", - "value": "function() {\n // 跳转详情页面 TODO\n }" + "value": "function() { /*...*/ }" }, "onResultCancel": { "type": "JSFunction", - "value": "function() {\n this.setState({\n resultVisible: false,\n });\n }" + "value": "function() { /*...*/ }" }, "formatResult": { "type": "JSFunction", - "value": "function(item) {\n if (!item) {\n return '暂无结果';\n }\n const { channel, plat, version, status } = item;\n return [channel, plat, version, status].join('-');\n }" + "value": "function() { /*...*/ }" }, "handleDownload": { "type": "JSFunction", - "value": "function() {\n const { results } = this.state;\n if (!results || results.length < 1) {\n return;\n }\n let link = document.createElement('a');\n link.style.display = 'none';\n document.body.appendChild(link);\n results.forEach(r => {\n link.href = r.download_link;\n link.click();\n });\n document.body.removeChild(link);\n link = null;\n }" + "value": "function() { /*...*/ }" }, "onFinish": { "type": "JSFunction", - "value": "function(f) {\n const params = Object.keys(f).reduce((pre, key) => {\n const value = f[key];\n if (value === undefined) {\n return pre;\n }\n return {\n ...pre,\n [key]: value,\n };\n }, {});\n this.searchParams = params;\n this.fetchPkgs();\n }" + "value": "function() { /*...*/ }" } }, "state": {