neo-cmp-cli 1.3.10 → 1.5.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +52 -15
  2. package/package.json +4 -1
  3. package/src/cmpUtils/createCmpByTemplate.js +50 -0
  4. package/src/cmpUtils/createCommonModulesCode.js +15 -15
  5. package/src/cmpUtils/{getCmpModelRegister.js → getCmpModelRegisterCode.js} +2 -2
  6. package/src/cmpUtils/{getCmpPreview.js → getCmpPreviewCode.js} +2 -2
  7. package/src/cmpUtils/{getCmpRegister.js → getCmpRegisterCode.js} +2 -2
  8. package/src/cmpUtils/getCmpTypeByDir.js +41 -0
  9. package/src/cmpUtils/hasCmpTypeByDir.js +11 -0
  10. package/src/{module → cmpUtils}/previewCmp.js +2 -2
  11. package/src/cmpUtils/pushCmp.js +232 -0
  12. package/src/config/default.config.js +14 -2
  13. package/src/module/index.js +174 -11
  14. package/src/module/main.js +96 -3
  15. package/src/module/neoInit.js +3 -0
  16. package/src/module/neoInitByCopy.js +3 -0
  17. package/src/neo/NeoUMDContent.js +29 -0
  18. package/src/neo/neoRequire.js +7 -7
  19. package/src/neo/neoService.js +525 -0
  20. package/src/neo/wrapperContent.js +2 -1
  21. package/src/oss/publish2oss.js +96 -96
  22. package/src/plugins/AddNeoRequirePlugin.js +5 -2
  23. package/src/projectUtils/createCmpProjectByTemplate.js +49 -0
  24. package/src/{cmpUtils → projectUtils}/getEntriesWithAutoRegister.js +4 -4
  25. package/src/template/antd-custom-cmp-template/README.md +2 -2
  26. package/src/template/antd-custom-cmp-template/neo.config.js +22 -14
  27. package/src/template/antd-custom-cmp-template/package.json +2 -2
  28. package/src/template/develop/neo-custom-cmp-template/neo.config.js +1 -1
  29. package/src/template/echarts-custom-cmp-template/README.md +2 -2
  30. package/src/template/echarts-custom-cmp-template/neo.config.js +19 -13
  31. package/src/template/echarts-custom-cmp-template/package.json +2 -2
  32. package/src/template/empty-cmp/index.tsx +51 -0
  33. package/src/template/empty-cmp/model.ts +77 -0
  34. package/src/template/empty-cmp/style.scss +72 -0
  35. package/src/template/empty-custom-cmp-template/.prettierrc.js +12 -0
  36. package/src/template/empty-custom-cmp-template/README.md +45 -0
  37. package/src/template/empty-custom-cmp-template/commitlint.config.js +59 -0
  38. package/src/template/empty-custom-cmp-template/neo.config.js +126 -0
  39. package/src/template/empty-custom-cmp-template/package.json +57 -0
  40. package/src/template/empty-custom-cmp-template/public/css/base.css +283 -0
  41. package/src/template/empty-custom-cmp-template/public/scripts/app/bluebird.js +6679 -0
  42. package/src/template/empty-custom-cmp-template/public/template.html +13 -0
  43. package/src/template/empty-custom-cmp-template/src/assets/css/common.scss +127 -0
  44. package/src/template/empty-custom-cmp-template/src/assets/css/mixin.scss +47 -0
  45. package/src/template/empty-custom-cmp-template/src/assets/img/NeoCRM.jpg +0 -0
  46. package/src/template/empty-custom-cmp-template/src/assets/img/custom-widget.svg +1 -0
  47. package/src/template/empty-custom-cmp-template/src/assets/img/favicon.png +0 -0
  48. package/src/template/empty-custom-cmp-template/src/assets/img/map.svg +1 -0
  49. package/src/template/empty-custom-cmp-template/src/components/README.md +3 -0
  50. package/src/template/empty-custom-cmp-template/tsconfig.json +68 -0
  51. package/src/template/neo-custom-cmp-template/README.md +5 -5
  52. package/src/template/neo-custom-cmp-template/neo.config.js +18 -29
  53. package/src/template/neo-custom-cmp-template/package.json +3 -4
  54. package/src/template/react-custom-cmp-template/.prettierrc.js +1 -1
  55. package/src/template/react-custom-cmp-template/README.md +2 -2
  56. package/src/template/react-custom-cmp-template/neo.config.js +20 -15
  57. package/src/template/react-custom-cmp-template/package.json +2 -2
  58. package/src/template/react-ts-custom-cmp-template/README.md +2 -2
  59. package/src/template/react-ts-custom-cmp-template/neo.config.js +19 -14
  60. package/src/template/react-ts-custom-cmp-template/package.json +2 -2
  61. package/src/template/vue2-custom-cmp-template/README.md +2 -2
  62. package/src/template/vue2-custom-cmp-template/neo.config.js +20 -15
  63. package/src/template/vue2-custom-cmp-template/package.json +2 -2
  64. package/src/utils/autoEntryRootDir.js +42 -0
  65. package/src/utils/replaceInFilesByMap.js +54 -0
  66. package/test/demo.js +2 -2
  67. /package/src/{cmpUtils → projectUtils}/getEntries.js +0 -0
  68. /package/src/{cmpUtils → projectUtils}/updatePublishLog.js +0 -0
@@ -4,107 +4,12 @@ const path = require('path');
4
4
  const _ = require('lodash');
5
5
  const { catchCurPackageJson } = require('../utils/pathUtils');
6
6
  const getConfigObj = require('../utils/getConfigObj');
7
- const updatePublishLog = require('../cmpUtils/updatePublishLog');
7
+ const updatePublishLog = require('../projectUtils/updatePublishLog');
8
8
 
9
9
  // 获取当前项目的package文件
10
10
  const currentPackageJsonDir = catchCurPackageJson();
11
11
  const currentPackageJson = getConfigObj(currentPackageJsonDir);
12
12
 
13
- /**
14
- * 将构建产物上传到指定 oss 存储桶
15
- *
16
- * @param {string} ossType oss 类型:baidu、ali
17
- * @param {object} ossConfig oss 配置
18
- * @param {string} assetsRoot 构建产物的目录
19
- * @param {array} fileExtensions 需要上传的文件类型,默认 ['.js', '.css']
20
- */
21
- const publish2oss = (ossType, ossConfig, assetsRoot, fileExtensions = ['.js', '.css']) => {
22
- if (ossType !== 'baidu' && ossType !== 'ali') {
23
- console.error(`不支持的oss类型: ${ossType}`);
24
- return;
25
- }
26
- const bosClient = getBosClient(ossType, ossConfig);
27
- if (!assetsRoot) {
28
- console.error('assetsRoot 不能为空');
29
- return;
30
- }
31
- if (!fs.existsSync(assetsRoot)) {
32
- console.error(`assetsRoot 不存在: ${assetsRoot}`);
33
- return;
34
- }
35
- const files = fs.readdirSync(assetsRoot); // 读取构建目录下的所有文件
36
-
37
- // 并行上传所有指定类型的文件
38
- const uploadPromises = files.map(async (file) => {
39
- const filePath = path.join(assetsRoot, file);
40
- // 获取文件状态
41
- const fileStat = fs.statSync(filePath);
42
- // 检查文件扩展名
43
- // const fileExt = path.extname(file);
44
- const fileInfo = path.parse(filePath);
45
- if (fileStat.isFile() && fileExtensions.includes(fileInfo.ext)) {
46
- const objectKey = addVersionToFilename(file);
47
- try {
48
- // 判断线上是否存在重名文件,避免被覆盖
49
- const historyResult = await bosClient.get(objectKey);
50
- if (historyResult && historyResult.url) {
51
- return {
52
- success: false,
53
- status: '文件上传失败',
54
- widgetName: fileInfo.name,
55
- fileName: file,
56
- filepath: filePath,
57
- ossPath: historyResult.url,
58
- error: '线上存在重名文件。'
59
- };
60
- }
61
- // 上传文件
62
- const result = await bosClient.upload(objectKey, filePath);
63
- return {
64
- success: true,
65
- status: '文件上传成功',
66
- fileName: file,
67
- widgetName: fileInfo.name,
68
- filepath: filePath,
69
- ossPath: getFilePath(ossType, ossConfig.bucket, objectKey),
70
- resultMsg: result
71
- };
72
- } catch (error) {
73
- return {
74
- success: false,
75
- status: '文件上传失败',
76
- widgetName: fileInfo.name,
77
- fileName: file,
78
- filepath: filePath,
79
- error: error.message
80
- };
81
- }
82
- }
83
- });
84
-
85
- Promise.all(uploadPromises)
86
- .then((results) => {
87
- /*
88
- const { succeedFiles, errorFiles } = getResultFiles(results);
89
- if (succeedFiles.length > 0) {
90
- console.info('已成功上传如下文件:\n', succeedFiles);
91
- }
92
- if (errorFiles.length > 0) {
93
- console.info('上传失败的文件有:\n', errorFiles);
94
- }
95
- */
96
- const widgetFilesMap = getResultFilesByWidgetName(results);
97
- if (widgetFilesMap) {
98
- console.info('上传至 OSS 的文件信息:\n', widgetFilesMap);
99
- // 更新发布日志
100
- updatePublishLog(widgetFilesMap);
101
- }
102
- })
103
- .catch((error) => {
104
- console.error('批量上传文件异常:\n', error);
105
- });
106
- };
107
-
108
13
  // 根据 ossType 获取对应的 BosClient
109
14
  const getBosClient = (ossType, ossConfig) => {
110
15
  if (ossType === 'baidu') {
@@ -241,4 +146,99 @@ function addVersionToFilename(
241
146
  return `${projectName}/${baseName}-${version}${extension}`;
242
147
  }
243
148
 
149
+ /**
150
+ * 将构建产物上传到指定 oss 存储桶
151
+ *
152
+ * @param {string} ossType oss 类型:baidu、ali
153
+ * @param {object} ossConfig oss 配置
154
+ * @param {string} assetsRoot 构建产物的目录
155
+ * @param {array} fileExtensions 需要上传的文件类型,默认 ['.js', '.css']
156
+ */
157
+ const publish2oss = (ossType, ossConfig, assetsRoot, fileExtensions = ['.js', '.css']) => {
158
+ if (ossType !== 'baidu' && ossType !== 'ali') {
159
+ console.error(`不支持的oss类型: ${ossType}`);
160
+ return;
161
+ }
162
+ const bosClient = getBosClient(ossType, ossConfig);
163
+ if (!assetsRoot) {
164
+ console.error('assetsRoot 不能为空');
165
+ return;
166
+ }
167
+ if (!fs.existsSync(assetsRoot)) {
168
+ console.error(`assetsRoot 不存在: ${assetsRoot}`);
169
+ return;
170
+ }
171
+ const files = fs.readdirSync(assetsRoot); // 读取构建目录下的所有文件
172
+
173
+ // 并行上传所有指定类型的文件
174
+ const uploadPromises = files.map(async (file) => {
175
+ const filePath = path.join(assetsRoot, file);
176
+ // 获取文件状态
177
+ const fileStat = fs.statSync(filePath);
178
+ // 检查文件扩展名
179
+ // const fileExt = path.extname(file);
180
+ const fileInfo = path.parse(filePath);
181
+ if (fileStat.isFile() && fileExtensions.includes(fileInfo.ext)) {
182
+ const objectKey = addVersionToFilename(file);
183
+ try {
184
+ // 判断线上是否存在重名文件,避免被覆盖
185
+ const historyResult = await bosClient.get(objectKey);
186
+ if (historyResult && historyResult.url) {
187
+ return {
188
+ success: false,
189
+ status: '文件上传失败',
190
+ widgetName: fileInfo.name,
191
+ fileName: file,
192
+ filepath: filePath,
193
+ ossPath: historyResult.url,
194
+ error: '线上存在重名文件。'
195
+ };
196
+ }
197
+ // 上传文件
198
+ const result = await bosClient.upload(objectKey, filePath);
199
+ return {
200
+ success: true,
201
+ status: '文件上传成功',
202
+ fileName: file,
203
+ widgetName: fileInfo.name,
204
+ filepath: filePath,
205
+ ossPath: getFilePath(ossType, ossConfig.bucket, objectKey),
206
+ resultMsg: result
207
+ };
208
+ } catch (error) {
209
+ return {
210
+ success: false,
211
+ status: '文件上传失败',
212
+ widgetName: fileInfo.name,
213
+ fileName: file,
214
+ filepath: filePath,
215
+ error: error.message
216
+ };
217
+ }
218
+ }
219
+ });
220
+
221
+ Promise.all(uploadPromises)
222
+ .then((results) => {
223
+ /*
224
+ const { succeedFiles, errorFiles } = getResultFiles(results);
225
+ if (succeedFiles.length > 0) {
226
+ console.info('已成功上传如下文件:\n', succeedFiles);
227
+ }
228
+ if (errorFiles.length > 0) {
229
+ console.info('上传失败的文件有:\n', errorFiles);
230
+ }
231
+ */
232
+ const widgetFilesMap = getResultFilesByWidgetName(results);
233
+ if (widgetFilesMap) {
234
+ console.info('上传至 OSS 的文件信息:\n', widgetFilesMap);
235
+ // 更新发布日志
236
+ updatePublishLog(widgetFilesMap);
237
+ }
238
+ })
239
+ .catch((error) => {
240
+ console.error('批量上传文件异常:\n', error);
241
+ });
242
+ };
243
+
244
244
  module.exports = publish2oss;
@@ -1,5 +1,6 @@
1
1
  const { ConcatSource } = require('webpack-sources');
2
-
2
+ const fs = require('fs');
3
+ const path = require('path');
3
4
  /**
4
5
  * 注入 neoRequire 函数
5
6
  * 备注:用于实现和 Neo 平台共享依赖
@@ -163,7 +164,9 @@ class AddNeoRequirePlugin {
163
164
  })(function(require) {
164
165
  `;
165
166
 
166
- const Footer = `})`;
167
+ // const NeoUMDContent = fs.readFileSync(path.join(__dirname, '../neo/NeoUMDContent.js'), 'utf8');
168
+ // const Footer = `}); \n${NeoUMDContent}`;
169
+ const Footer = `});`;
167
170
 
168
171
  // 创建新的资源
169
172
  const newSource = new ConcatSource(Header, content, Footer);
@@ -0,0 +1,49 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+ const { consoleTag } = require('../utils/neoParams'); // 输出标记
4
+ const { replaceInPackage } = require('../utils/replaceInPackage');
5
+ const { resetPackageVersion } = require('../utils/resetPackageVersion');
6
+ const autoEntryRootDir = require('../utils/autoEntryRootDir');
7
+
8
+ const cmpTemplateList = {
9
+ 'react-ts': {
10
+ projectName: 'empty-custom-cmp-template',
11
+ dir: path.resolve(__dirname, '../template/empty-custom-cmp-template')
12
+ }
13
+ };
14
+
15
+ /**
16
+ * 通过拷贝模板创建自定义组件
17
+ * @param {*} projectName 自定义组件项目名称
18
+ * @param {*} type 自定义组件类型
19
+ */
20
+ module.exports = function (projectName, type = 'react-ts') {
21
+ const finalProjectPath = path.resolve(process.cwd(), projectName);
22
+
23
+ if (fs.existsSync(finalProjectPath)) {
24
+ console.error(`${consoleTag}创建自定义组件失败,当前已存在(${projectName})项目,请勿创建重名项目。`);
25
+ process.exit(1);
26
+ }
27
+
28
+ const curCmpTemplate = cmpTemplateList[type];
29
+ if (!curCmpTemplate) {
30
+ console.error(`${consoleTag}创建自定义组件失败,当前不支持${type}类型。`);
31
+ process.exit(1);
32
+ }
33
+
34
+ const currentTemplateDir = curCmpTemplate.dir;
35
+ const finalProjectName = projectName || 'neoCustomCmp';
36
+
37
+ fs.copy(currentTemplateDir, finalProjectPath)
38
+ .then(() => {
39
+ replaceInPackage(finalProjectPath, curCmpTemplate.projectName, finalProjectName);
40
+ replaceInPackage(finalProjectPath, 'wibetter', 'xxx');
41
+ replaceInPackage(finalProjectPath, 'neo自定义组件模板', 'neo自定义组件');
42
+ resetPackageVersion(finalProjectPath);
43
+
44
+ console.log(`${consoleTag}已创建自定义组件(${finalProjectName})!`);
45
+ // 自动切换到项目根目录
46
+ autoEntryRootDir(finalProjectPath);
47
+ })
48
+ .catch((err) => console.error(`${consoleTag}自定义组件模板下载失败:`, err));
49
+ };
@@ -2,8 +2,8 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const _ = require('lodash');
4
4
  const { resolveToCurrentRoot } = require('../utils/pathUtils');
5
- const getCmpRegister = require('./getCmpRegister');
6
- const getCmpModelRegister = require('./getCmpModelRegister');
5
+ const getCmpRegisterCode = require('../cmpUtils/getCmpRegisterCode');
6
+ const getCmpModelRegisterCode = require('../cmpUtils/getCmpModelRegisterCode');
7
7
  /**
8
8
  * 从指定目录获取组件入口文件,并自动创建对应的注册文件
9
9
  * @param {*} defaultComponentsDir 默认组件目录
@@ -68,7 +68,7 @@ module.exports = (defaultComponentsDir = './src/components', cmpType) => {
68
68
  .forEach((filePath) => {
69
69
  if (filePath.match(/index\.[tj]sx?$/)) {
70
70
  // 自动创建对应的注册文件
71
- const registerContent = getCmpRegister(componentsBaseDir, curCmpName);
71
+ const registerContent = getCmpRegisterCode(componentsBaseDir, curCmpName);
72
72
  const registerDir = `${cmpTempDir}/register.js`;
73
73
 
74
74
  // 写入注册文件
@@ -78,7 +78,7 @@ module.exports = (defaultComponentsDir = './src/components', cmpType) => {
78
78
  linkDebugEntries.index.push(registerDir);
79
79
  } else if (filePath.match(/model\.[tj]sx?$/)) {
80
80
  // 自动创建对应的模型注册文件
81
- const modelRegisterContent = getCmpModelRegister(componentsBaseDir, curCmpName);
81
+ const modelRegisterContent = getCmpModelRegisterCode(componentsBaseDir, curCmpName);
82
82
  const modelRegisterDir = `${cmpTempDir}/model.js`;
83
83
 
84
84
  // 写入模型注册文件
@@ -37,10 +37,10 @@ $ npm run preview
37
37
  $ npm run linkDebug
38
38
  ```
39
39
 
40
- 4. **发布到对象存储服务中**
40
+ 4. **发布到 NeoCRM 平台**
41
41
  > 需要确保 package.json 中的 name 值唯一,version 值不重复。
42
42
  ```bash
43
- $ npm run publish2oss
43
+ $ npm run pushCmp
44
44
  ```
45
45
 
46
46
  ### 配置项说明(neo-cmp-cli)
@@ -41,10 +41,12 @@ module.exports = {
41
41
  // 用于添加 Neo 共享依赖模块和剔除模块
42
42
  /*
43
43
  neoCommonModule: {
44
- remotes: ['chart-widget'], // 远程自定义组件,表示当前自定义组件会用到的远程组件
45
- neoExternals: ['chart-widget'], // 自定义组件中需要剔除的模块,仅支持数组写法,需要和 remotes 配合使用
46
44
  // neoExports: ['xxModule'], // 自定义组件 共享出来的模块,支持数组和对象形式
47
- // neoExports: { 'xxModule': path.resolve('./src/components/xxModule') }, // 对象写法
45
+ neoExports: { // 对象写法
46
+ 'xx-module': path.resolve('./src/components/xx-module'), // 导出 xx组件 或 xx模块
47
+ },
48
+ // remoteDeps: ['xxCmpType'], // 远程依赖组件,表示当前自定义组件会用到的依赖组件,需要和 neoExternals 配合使用
49
+ // neoExternals: ['xxModule'], // 自定义组件中需要剔除的模块(仅支持数组写法)
48
50
  },
49
51
  */
50
52
  preview: {
@@ -95,23 +97,29 @@ module.exports = {
95
97
  }
96
98
  */
97
99
  },
98
- publish2oss: {
99
- // 用于构建并发布至 OSS 的相关配置
100
+ pushCmp: {
101
+ // 用于构建并发布至 NeoCRM 的相关配置
102
+ neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
103
+ tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
104
+ // NeoCRM 授权配置
105
+ authConfig: {
106
+ client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
107
+ client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
108
+ username: 'xx', // 用户在销售易系统中的用户名
109
+ /**
110
+ * password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
111
+ * 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
112
+ */
113
+ password: 'xx xx' // 用户账户密码 + 8 位安全令牌
114
+ },
100
115
  /*
101
116
  【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
102
117
  NODE_ENV: 'production',
103
118
  entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
104
- InfoCardModel: './src/components/info-card/model.ts',
105
- infoCard: './src/components/info-card/register.ts'
119
+ InfoCardModel: './src/components/entity-form/model.ts',
120
+ infoCard: './src/components/entity-form/register.ts'
106
121
  },
107
122
  cssExtract: false, // 不额外提取css文件
108
- ossType: 'ali', // oss类型:ali、baidu
109
- ossConfig: {
110
- endpoint: 'https://oss-cn-beijing.aliyuncs.com',
111
- AccessKeyId: 'xxx',
112
- AccessKeySecret: 'xx',
113
- bucket: 'neo-widgets' // 存储桶名称
114
- },
115
123
  assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
116
124
  */
117
125
  },
@@ -10,9 +10,9 @@
10
10
  "author": "wibetter",
11
11
  "license": "MIT",
12
12
  "scripts": {
13
- "preview": "neo preview --cmpType=data-dashboard",
13
+ "preview": "neo preview",
14
14
  "linkDebug": "neo linkDebug",
15
- "publish2oss": "neo publish2oss",
15
+ "pushCmp": "neo pushCmp",
16
16
  "format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
17
17
  },
18
18
  "files": [
@@ -46,8 +46,8 @@ module.exports = {
46
46
  'chart-widget': path.resolve('./src/components/chart-widget'), // 导出图表自定义组件
47
47
  'neo-register': 'neo-register', // 导出 Neo 注册模块
48
48
  },
49
+ // remoteDeps: ['xxModule'], // 远程依赖组件,表示当前自定义组件会用到的远程依赖组件,需要和 neoExternals 配合使用
49
50
  // neoExternals: ['xxModule'], // 自定义组件中需要剔除的模块,仅支持数组写法
50
- // remotes: ['xxModule'], // 远程组件,表示当前自定义组件会用到的远程组件,需要和 neoExternals 配合使用
51
51
  },
52
52
  */
53
53
  preview: {
@@ -81,10 +81,10 @@ $ npm run preview
81
81
  $ npm run linkDebug
82
82
  ```
83
83
 
84
- 4. **发布到对象存储服务中**
84
+ 4. **发布到 NeoCRM 平台**
85
85
  > 需要确保 package.json 中的 name 值唯一,version 值不重复。
86
86
  ```bash
87
- $ npm run publish2oss
87
+ $ npm run pushCmp
88
88
  ```
89
89
 
90
90
  ### 配置项说明(neo-cmp-cli)
@@ -46,8 +46,8 @@ module.exports = {
46
46
  'chart-widget': path.resolve('./src/components/chart-widget'), // 导出图表自定义组件
47
47
  'neo-register': 'neo-register', // 导出 Neo 注册模块
48
48
  },
49
- // remotes: ['xxModule'], // 远程组件,表示当前自定义组件会用到的远程组件
50
- // neoExternals: ['xxModule'], // 自定义组件中需要剔除的模块,仅支持数组写法,需要和 remotes 配合使用
49
+ // remoteDeps: ['xxCmpType'], // 远程依赖组件,表示当前自定义组件会用到的依赖组件,需要和 neoExternals 配合使用
50
+ // neoExternals: ['xxModule'], // 自定义组件中需要剔除的模块,仅支持数组写法
51
51
  },
52
52
  //*/
53
53
  preview: {
@@ -98,23 +98,29 @@ module.exports = {
98
98
  }
99
99
  */
100
100
  },
101
- publish2oss: {
102
- // 用于构建并发布至 OSS 的相关配置
101
+ pushCmp: {
102
+ // 用于构建并发布至 NeoCRM 的相关配置
103
+ neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
104
+ tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
105
+ // NeoCRM 授权配置
106
+ authConfig: {
107
+ client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
108
+ client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
109
+ username: 'xx', // 用户在销售易系统中的用户名
110
+ /**
111
+ * password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
112
+ * 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
113
+ */
114
+ password: 'xx xx' // 用户账户密码 + 8 位安全令牌
115
+ },
103
116
  /*
104
117
  【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
105
118
  NODE_ENV: 'production',
106
119
  entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
107
- InfoCardModel: './src/components/info-card/model.ts',
108
- infoCard: './src/components/info-card/register.ts'
120
+ InfoCardModel: './src/components/entity-form/model.ts',
121
+ infoCard: './src/components/entity-form/register.ts'
109
122
  },
110
123
  cssExtract: false, // 不额外提取css文件
111
- ossType: 'ali', // oss类型:ali、baidu
112
- ossConfig: {
113
- endpoint: 'https://oss-cn-beijing.aliyuncs.com',
114
- AccessKeyId: 'xxx',
115
- AccessKeySecret: 'xx',
116
- bucket: 'neo-widgets' // 存储桶名称
117
- },
118
124
  assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
119
125
  */
120
126
  },
@@ -10,9 +10,9 @@
10
10
  "author": "wibetter",
11
11
  "license": "MIT",
12
12
  "scripts": {
13
- "preview": "neo preview --cmpType=chart-widget",
13
+ "preview": "neo preview",
14
14
  "linkDebug": "neo linkDebug",
15
- "publish2oss": "neo publish2oss",
15
+ "pushCmp": "neo pushCmp",
16
16
  "format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
17
17
  },
18
18
  "files": [
@@ -0,0 +1,51 @@
1
+ import * as React from 'react';
2
+ import './style.scss'; // 组件内容样式
3
+
4
+ interface CustomCmpProps {
5
+ title: string;
6
+ backgroundImage: string;
7
+ imgCount: number;
8
+ commentCount: number;
9
+ data?: any;
10
+ }
11
+
12
+ export default class CustomCmp extends React.PureComponent<CustomCmpProps> {
13
+ constructor(props: CustomCmpProps) {
14
+ super(props);
15
+ this.agreeDataFormat = this.agreeDataFormat.bind(this);
16
+ }
17
+
18
+ agreeDataFormat(agreeData: number) {
19
+ if (agreeData && agreeData <= 9999) {
20
+ return agreeData;
21
+ }
22
+ if (agreeData && agreeData > 9999) {
23
+ return `${Math.floor(agreeData / 1000) / 10}w`;
24
+ }
25
+ return '';
26
+ }
27
+
28
+ render() {
29
+ const { title, backgroundImage, imgCount, commentCount } = this.props;
30
+ console.log('当前自定义组件:', this.props, this);
31
+
32
+ const curBackgroundImage =
33
+ backgroundImage || 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg';
34
+ return (
35
+ <div className="custom-cmp-container">
36
+ <div className="news-title">
37
+ {title ||
38
+ '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。'}
39
+ </div>
40
+ <div className="news-info">
41
+ <div className="left media-mark">NeoCRM · 低代码平台</div>
42
+ {commentCount && commentCount > 0 && (
43
+ <div className="cmt-num right">
44
+ {this.agreeDataFormat(commentCount)}评
45
+ </div>
46
+ )}
47
+ </div>
48
+ </div>
49
+ );
50
+ }
51
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @file 自定义组件对接编辑器的描述文件
3
+ */
4
+ export class CustomCmpModel {
5
+ /**
6
+ * cmpType 为自定义组件名称,用于标识组件的唯一性
7
+ * 在构建时根据当前组件目录名称自动生成
8
+ */
9
+ // cmpType: string = 'xx-custom-cmp';
10
+
11
+ // 组件名称,用于设置在编辑器左侧组件面板中展示的名称
12
+ label: string = 'xx组件';
13
+
14
+ // 组件描述,用于设置在编辑器左侧组件面板中展示的描述
15
+ description: string = 'xx自定义组件详细描述';
16
+
17
+ // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
+ tags: string[] = ['自定义组件'];
19
+
20
+ // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
+ iconSrc: string = 'https://neo-widgets.bj.bcebos.com/custom-widget.svg';
22
+
23
+ // 初次插入页面的默认属性数据
24
+ defaultComProps = {
25
+ title:
26
+ '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。',
27
+ label: '信息卡片',
28
+ backgroundImage: 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg',
29
+ imgCount: 3,
30
+ commentCount: 2025,
31
+ };
32
+
33
+ // 设计器端预览时展示的默认数据
34
+ previewComProps = {
35
+ label: '信息卡片',
36
+ };
37
+
38
+ /**
39
+ * 组件面板配置,用于生成编辑器右侧属性配置面板内容
40
+ */
41
+ propsSchema = [
42
+ {
43
+ type: 'textarea',
44
+ name: 'title',
45
+ label: '卡片title',
46
+ value:
47
+ '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。',
48
+ },
49
+ {
50
+ type: 'text',
51
+ name: 'backgroundImage',
52
+ label: '展示图片',
53
+ value: 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg',
54
+ },
55
+ {
56
+ type: 'number',
57
+ name: 'imgCount',
58
+ label: '图片数量',
59
+ value: 3,
60
+ },
61
+ {
62
+ type: 'number',
63
+ name: 'commentCount',
64
+ label: '评论数',
65
+ value: 2025,
66
+ },
67
+ ];
68
+
69
+ // 支持 函数式写法:propsSchemaCreator,com 为组件实例。优先级比 propsSchema 高
70
+ /*
71
+ propsSchemaCreator = (com: any) => {
72
+ return [];
73
+ };
74
+ */
75
+ }
76
+
77
+ export default CustomCmpModel;