neo-cmp-cli 1.10.12 → 1.10.13
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.
- package/dist/main2.js +1 -1
- package/dist/package.json.js +1 -1
- package/dist/utils/cmpUtils/createCommonModulesCode.js +1 -1
- package/package.json +1 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/neo-bi-cmps/neo.config.js +20 -0
- package/template/neo-bi-cmps/package.json +5 -4
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/configSchema.ts +7 -7
- package/template/neo-custom-cmp-template/package.json +1 -1
- package/template/neo-custom-cmp-template/src/components/simpleCmp__c/index.tsx +2 -1
- package/template/neo-custom-cmp-template/src/components/simpleCmp__c/model.ts +1 -1
- package/template/neo-h5-cmps/README.md +8 -64
- package/template/neo-h5-cmps/package.json +1 -2
- package/template/neo-order-cmps/package.json +1 -1
- package/template/react-custom-cmp-template/package.json +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
package/dist/main2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun");require("lodash");const r=require("./module/neoInit.js"),i=require("./module/neoInitByCopy.js"),s=require("./module/inspect.js"),t=require("./utils/neoConfigInit.js"),o=require("./utils/neoParams.js"),u=require("./config/index.js"),l=require("./oss/publish2oss.js"),p=require("./neo/pushCmp.js"),n=require("./neo/pullCmp.js"),c=require("./neo/deleteCmp.js"),d=require("./utils/cmpUtils/previewCmp.js"),b=require("./utils/generateEntries.js"),m=require("./utils/cmpUtils/createCmpByTemplate.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun");require("lodash");const r=require("./module/neoInit.js"),i=require("./module/neoInitByCopy.js"),s=require("./module/inspect.js"),t=require("./utils/neoConfigInit.js"),o=require("./utils/neoParams.js"),u=require("./config/index.js"),l=require("./oss/publish2oss.js"),p=require("./neo/pushCmp.js"),n=require("./neo/pullCmp.js"),c=require("./neo/deleteCmp.js"),d=require("./utils/cmpUtils/previewCmp.js"),b=require("./utils/generateEntries.js"),m=require("./utils/cmpUtils/createCmpByTemplate.js"),a=require("./utils/projectUtils/createCmpProjectByTemplate.js"),q=require("./utils/projectUtils/openProject.js"),y=require("./utils/configureNeoBuild.js"),_=require("./utils/common.js"),g=require("./utils/projectNameValidator.js"),j=require("./utils/cmpUtils/getCmpTypeByDir.js"),v=require("./neo/neoService.js"),T=require("./neo/neoLogin.js"),f=require("./utils/projectUtils/hasNeoProject.js");var C,x;exports.__require=function(){if(x)return C;x=1;const E=e,N=r.__require(),h=i.__require(),w=s.__require(),B=t.__require(),{consoleTag:D}=o.__require(),P=u.__require(),k=l.__require(),M=p.__require(),I=n.__require(),L=c.__require(),U=d.__require(),O=b.__require(),S=m.__require(),R=a.__require(),A=q.__require(),{configureNeoBuild:V}=y.__require(),{errorLog:z,successLog:F}=_.__require(),{validateProjectName:G}=g.__require(),H=j.__require(),J=v.__require(),K=T.__require(),Q=f.__require();function W(e,r){const{entryType:i,cmpType:s}=r;let t=[],o={};try{const{entries:r,cmpTypes:u,defaultExports:l}=O({configEntry:e.entry,disableAutoRegister:e.disableAutoRegister,componentsDir:P.componentsDir,entryType:i,cmpType:s});r&&Object.keys(r).length>0&&(e.entry=r,t=u,console.info("已自动生成 entry 入口配置:",r)),o=l}catch(e){z(e.message||e.msg),process.exit(1)}return{cmpTypes:t,defaultExports:o}}function X(e){return Object.assign(P.build2lib,e)}return C={neoInit:N,neoInitByCopy:h,inspect:w,neoConfigInit:B,projectConfig:P,consoleTag:D,errorLog:z,successLog:F,validateProjectName:G,getCmpTypeByDir:H,NeoService:J,NeoLoginService:K,hasNeoProject:Q,createCmpProjectByTemplate:R,createCmpByTemplate:S,dev:()=>{P.dev||(z("未找到 dev 相关配置。"),process.exit(1)),E.dev(P,D)},previewCmp:e=>{e||(z("请输入要预览的组件名称。"),process.exit(1)),P.preview||(z("未找到 preview 相关配置。"),process.exit(1)),P.dev=Object.assign(P.dev,P.preview),delete P.preview,U(P,e)},linkDebug:()=>{P.linkDebug||(z("未找到 debug 相关配置。"),process.exit(1)),P.dev=Object.assign(P.dev,P.linkDebug),delete P.linkDebug,delete P.dev.ignoreNodeModules,P.webpack.ignoreNodeModules=!1;const{cmpTypes:e,defaultExports:r}=W(P.dev,{entryType:"linkDebug"});V(P,P.dev,{cmpTypes:e,defaultExports:r,verbose:!0,excludeModel:!1}),E.dev(P,D)},build:()=>E.build("build",P,D),build2lib:()=>{W(P.build2lib,{entryType:"widget"}),P.build2lib.removeNeoCommonModules&&V(P,P.build2lib,{cmpTypes:[],defaultExports:[],verbose:!1,excludeModel:!0}),E.build("lib",P,D)},publish2oss:e=>{const r=P.publish2oss;P.build2lib=X(r);const{cmpTypes:i,defaultExports:s}=W(P.build2lib,{entryType:"widget",cmpType:e});V(P,P.build2lib,{cmpTypes:i,defaultExports:s,verbose:!0,excludeModel:!0}),E.build("lib",P,D,()=>{k(r.ossType,r.ossConfig,r.assetsRoot)})},pushCmp:e=>{const{pushCmp:r}=P;P.build2lib=X(r);const{cmpTypes:i,defaultExports:s}=W(P.build2lib,{entryType:"widget",cmpType:e});V(P,P.build2lib,{cmpTypes:i,defaultExports:s,verbose:!1,excludeModel:!0}),E.build("lib",P,D,()=>{M(r,e)})},pullCmp:(e,r)=>{I(e,r)},deleteCmp:(e,r)=>{L(e,r)},build2esm:()=>E.build2esm(P,D),openEditor:A},C};
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.10.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.10.13";const o={version:e};exports.default=o,exports.version=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("node:fs"),e=require("lodash"),n=require("../common.js"),s=require("../pathUtils.js");var d,m;exports.__require=function(){if(m)return d;m=1;const r=o,{isPlainObject:u}=e,{getRelativePathForWebpack:t}=n.__require(),{resolveToCurrentRoot:l}=s.__require();return d=(o,e)=>{const{exports:n,remoteDeps:s}=o;if(!n&&!s)return"";const d={},m={};Array.isArray(n)&&n.length>0?n.forEach(o=>{d[o]=require(o)}):u(n)&&Object.keys(n).length>0?Object.keys(n).forEach(o=>{const e=t(n[o]);d[o]=`require('${e}')`}):n&&(console.error("exports 格式不正确,请检查 neo.config.js 文件中的 neoCommonModule / exports 配置"),process.exit(1)),Array.isArray(s)&&s.length>0&&e.forEach(o=>{m[o]=s});let i="{\n";const c=Object.entries(d);c.forEach(([o,e],n)=>{const s=n===c.length-1;i+=` "${o}": ${e}${s?"":","}\n`}),i+="}";const _=`\n/**\n * 自定义组件 共享出来的依赖模块\n * 备注:可在其他模块中通过 neoRequire 中使用\n */\nimport { isPlainObject } from 'lodash';\nconst CustomCmpCommonModules = ${i};\nconst CustomCmpRemoteDeps = ${JSON.stringify(m)};\n\n// 用于添加共享的依赖模块\nconst addNeoCommonModules = (modules) => {\n if (!window.__NeoCommonModules) {\n window.__NeoCommonModules = {}\n }\n if (isPlainObject(modules)) {\n const moduleIds = Object.keys(modules)\n moduleIds.forEach((moduleId) => {\n const curModule = modules[moduleId];\n const curCommonModule = window.__NeoCommonModules[moduleId];\n \n if (!Object.isFrozen(curCommonModule) && curCommonModule && Object.keys(curCommonModule).length < 3) {\n try {\n // 如果是默认模块对象,则覆盖式合并(保持引用关联)\n window.__NeoCommonModules[moduleId] = Object.assign(curCommonModule, curModule);\n\n // 处理模块中的特殊属性\n if (curModule.__esModule !== undefined) {\n window.__NeoCommonModules[moduleId].__esModule = curModule.__esModule;\n }\n if (curModule.default !== undefined) {\n window.__NeoCommonModules[moduleId].default = curModule.default;\n }\n } catch (error) {\n console.warn('window.__NeoCommonModules[moduleId] Object.assign error:', error);\n window.__NeoCommonModules[moduleId] = curModule;\n }\n } else {\n window.__NeoCommonModules[moduleId] = curModule;\n }\n })\n }\n}\n\n// 用于添加自定义组件的远程依赖组件(关联使用)\nconst addNeoRemoteDeps = (remoteDeps) => {\n if (!window.__NeoCommonModules) {\n window.__NeoCommonModules = {}\n }\n if (!window.__NeoCommonModules.__neoRemoteDeps) {\n window.__NeoCommonModules.__neoRemoteDeps = {}\n }\n if (isPlainObject(remoteDeps)) {\n window.__NeoCommonModules.__neoRemoteDeps = Object.assign(window.__NeoCommonModules.__neoRemoteDeps, remoteDeps)\n }\n}\n\naddNeoCommonModules(CustomCmpCommonModules);\naddNeoRemoteDeps(CustomCmpRemoteDeps);\n `,M=l("./.neo-cli");r.existsSync(M)||r.mkdirSync(M);const a=`${M}/commonModules.js`;return r.writeFileSync(a,_),a}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("node:fs"),e=require("lodash"),n=require("../common.js"),s=require("../pathUtils.js");var d,m;exports.__require=function(){if(m)return d;m=1;const r=o,{isPlainObject:u}=e,{getRelativePathForWebpack:t}=n.__require(),{resolveToCurrentRoot:l}=s.__require();return d=(o,e=[])=>{const{exports:n,remoteDeps:s}=o;if(!n&&!s)return"";const d={},m={};Array.isArray(n)&&n.length>0?n.forEach(o=>{d[o]=require(o)}):u(n)&&Object.keys(n).length>0?Object.keys(n).forEach(o=>{const e=t(n[o]);d[o]=`require('${e}')`}):n&&(console.error("exports 格式不正确,请检查 neo.config.js 文件中的 neoCommonModule / exports 配置"),process.exit(1)),Array.isArray(s)&&s.length>0&&e.forEach(o=>{m[o]=s});let i="{\n";const c=Object.entries(d);c.forEach(([o,e],n)=>{const s=n===c.length-1;i+=` "${o}": ${e}${s?"":","}\n`}),i+="}";const _=`\n/**\n * 自定义组件 共享出来的依赖模块\n * 备注:可在其他模块中通过 neoRequire 中使用\n */\nimport { isPlainObject } from 'lodash';\nconst CustomCmpCommonModules = ${i};\nconst CustomCmpRemoteDeps = ${JSON.stringify(m)};\n\n// 用于添加共享的依赖模块\nconst addNeoCommonModules = (modules) => {\n if (!window.__NeoCommonModules) {\n window.__NeoCommonModules = {}\n }\n if (isPlainObject(modules)) {\n const moduleIds = Object.keys(modules)\n moduleIds.forEach((moduleId) => {\n const curModule = modules[moduleId];\n const curCommonModule = window.__NeoCommonModules[moduleId];\n \n if (!Object.isFrozen(curCommonModule) && curCommonModule && Object.keys(curCommonModule).length < 3) {\n try {\n // 如果是默认模块对象,则覆盖式合并(保持引用关联)\n window.__NeoCommonModules[moduleId] = Object.assign(curCommonModule, curModule);\n\n // 处理模块中的特殊属性\n if (curModule.__esModule !== undefined) {\n window.__NeoCommonModules[moduleId].__esModule = curModule.__esModule;\n }\n if (curModule.default !== undefined) {\n window.__NeoCommonModules[moduleId].default = curModule.default;\n }\n } catch (error) {\n console.warn('window.__NeoCommonModules[moduleId] Object.assign error:', error);\n window.__NeoCommonModules[moduleId] = curModule;\n }\n } else {\n window.__NeoCommonModules[moduleId] = curModule;\n }\n })\n }\n}\n\n// 用于添加自定义组件的远程依赖组件(关联使用)\nconst addNeoRemoteDeps = (remoteDeps) => {\n if (!window.__NeoCommonModules) {\n window.__NeoCommonModules = {}\n }\n if (!window.__NeoCommonModules.__neoRemoteDeps) {\n window.__NeoCommonModules.__neoRemoteDeps = {}\n }\n if (isPlainObject(remoteDeps)) {\n window.__NeoCommonModules.__neoRemoteDeps = Object.assign(window.__NeoCommonModules.__neoRemoteDeps, remoteDeps)\n }\n}\n\naddNeoCommonModules(CustomCmpCommonModules);\naddNeoRemoteDeps(CustomCmpRemoteDeps);\n `,M=l("./.neo-cli");r.existsSync(M)||r.mkdirSync(M);const a=`${M}/commonModules.js`;return r.writeFileSync(a,_),a}};
|
package/package.json
CHANGED
|
@@ -119,4 +119,24 @@ module.exports = {
|
|
|
119
119
|
assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
|
|
120
120
|
*/
|
|
121
121
|
},
|
|
122
|
+
build2lib: {
|
|
123
|
+
entry: {
|
|
124
|
+
targetNumber: './src/components/targetNumber__c/index.tsx',
|
|
125
|
+
targetNumberModel: './src/components/targetNumber__c/model.ts',
|
|
126
|
+
},
|
|
127
|
+
output: {
|
|
128
|
+
filename: '[name].js',
|
|
129
|
+
},
|
|
130
|
+
removeNeoCommonModules: true, // 是否移除 Neo 共享的依赖模块,默认不移除
|
|
131
|
+
NODE_ENV: 'production', // development、production
|
|
132
|
+
libraryName: 'NeoBIComponent', // 构建第三方功能包时最后导出的引用变量名
|
|
133
|
+
assetsRoot: resolve('./lib'), // 打包后的文件绝对路径(物理路径)
|
|
134
|
+
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
|
|
135
|
+
assetsSubDirectory: '', // 资源引用二级路径
|
|
136
|
+
ignoreNodeModules: true,
|
|
137
|
+
productionSourceMap: false,
|
|
138
|
+
productionGzip: false,
|
|
139
|
+
productionGzipExtensions: ['js', 'css', 'json'],
|
|
140
|
+
bundleAnalyzerReport: false,
|
|
141
|
+
},
|
|
122
142
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo-bi-cmps",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "neo自定义组件(react&ts技术栈)",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "neo BI 自定义组件(react&ts技术栈)",
|
|
5
5
|
"framework": "react-ts",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react&ts技术栈",
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
"pushCmp": "neo push cmp",
|
|
17
17
|
"pullCmp": "neo pull cmp",
|
|
18
18
|
"deleteCmp": "neo delete cmp",
|
|
19
|
+
"build2lib": "neo build2lib",
|
|
19
20
|
"format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
|
|
20
21
|
},
|
|
21
22
|
"files": [
|
|
22
|
-
"
|
|
23
|
+
"lib/*"
|
|
23
24
|
],
|
|
24
25
|
"husky": {
|
|
25
26
|
"hooks": {
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"@types/react": "^16.9.11",
|
|
49
50
|
"@types/react-dom": "^16.9.15",
|
|
50
51
|
"@types/axios": "^0.14.0",
|
|
51
|
-
"neo-cmp-cli": "^1.10.
|
|
52
|
+
"neo-cmp-cli": "^1.10.13",
|
|
52
53
|
"husky": "^4.2.5",
|
|
53
54
|
"lint-staged": "^10.2.9",
|
|
54
55
|
"prettier": "^2.0.5"
|
package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/configSchema.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const configSchema = {
|
|
|
11
11
|
"baseStyle": {
|
|
12
12
|
"type": "object",
|
|
13
13
|
"title": "基础样式",
|
|
14
|
-
"isFixed":
|
|
14
|
+
"isFixed": false,
|
|
15
15
|
"properties": {
|
|
16
16
|
"backgroundColor": {
|
|
17
17
|
"type": "color",
|
|
@@ -76,7 +76,7 @@ export const configSchema = {
|
|
|
76
76
|
"layoutStyle": {
|
|
77
77
|
"type": "object",
|
|
78
78
|
"title": "布局配置",
|
|
79
|
-
"isFixed":
|
|
79
|
+
"isFixed": false,
|
|
80
80
|
"properties": {
|
|
81
81
|
"legendOrient": {
|
|
82
82
|
"type": "radio",
|
|
@@ -153,7 +153,7 @@ export const configSchema = {
|
|
|
153
153
|
},
|
|
154
154
|
"fontWeight": {
|
|
155
155
|
"type": "number",
|
|
156
|
-
"title": "
|
|
156
|
+
"title": "标题字重",
|
|
157
157
|
"default": 400,
|
|
158
158
|
"minimum": 0,
|
|
159
159
|
"maximum": 1000,
|
|
@@ -179,7 +179,7 @@ export const configSchema = {
|
|
|
179
179
|
"numberStyle": {
|
|
180
180
|
"type": "object",
|
|
181
181
|
"title": "数值样式",
|
|
182
|
-
"isFixed":
|
|
182
|
+
"isFixed": false,
|
|
183
183
|
"properties": {
|
|
184
184
|
"fontSize": {
|
|
185
185
|
"type": "number",
|
|
@@ -192,7 +192,7 @@ export const configSchema = {
|
|
|
192
192
|
},
|
|
193
193
|
"fontWeight": {
|
|
194
194
|
"type": "number",
|
|
195
|
-
"title": "
|
|
195
|
+
"title": "标题字重",
|
|
196
196
|
"default": 800,
|
|
197
197
|
"minimum": 0,
|
|
198
198
|
"maximum": 1000,
|
|
@@ -224,7 +224,7 @@ export const configSchema = {
|
|
|
224
224
|
"numberTitleStyle": {
|
|
225
225
|
"type": "object",
|
|
226
226
|
"title": "数值标题样式",
|
|
227
|
-
"isFixed":
|
|
227
|
+
"isFixed": false,
|
|
228
228
|
"properties": {
|
|
229
229
|
"fontSize": {
|
|
230
230
|
"type": "number",
|
|
@@ -237,7 +237,7 @@ export const configSchema = {
|
|
|
237
237
|
},
|
|
238
238
|
"fontWeight": {
|
|
239
239
|
"type": "number",
|
|
240
|
-
"title": "
|
|
240
|
+
"title": "标题字重",
|
|
241
241
|
"default": 400,
|
|
242
242
|
"minimum": 0,
|
|
243
243
|
"maximum": 1000,
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
// 引入 neo-ui-common / BaseCmp
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import { BaseCmp } from 'neo-ui-common';
|
|
5
|
+
|
|
5
6
|
import './style.scss'; // 组件内容样式
|
|
6
7
|
|
|
7
8
|
interface CustomCmpProps {
|
|
@@ -21,7 +22,7 @@ export default class CustomCmp extends BaseCmp<CustomCmpProps, CustomCmpStates>
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
render() {
|
|
24
|
-
const { description, className, env } = this.props;
|
|
25
|
+
const { description, className, env, ...restProps } = this.props;
|
|
25
26
|
const ctx = (env || {}).ctx;
|
|
26
27
|
let languageCode = 'zh-CN'; // 默认中文
|
|
27
28
|
// 从上下文中 获取系统语言
|
|
@@ -26,34 +26,22 @@
|
|
|
26
26
|
$ npm i 或者 yarn
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
2. **
|
|
30
|
-
> preview模式:用于预览自定义组件内容。
|
|
31
|
-
```bash
|
|
32
|
-
$ npm run preview
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
3. **linkDebug: 外链调试(在线上页面设计器端预览自定义组件)**
|
|
29
|
+
2. **linkDebug: 外链调试(在线上页面设计器端预览自定义组件)**
|
|
36
30
|
> linkDebug模式:用于在线上页面设计器中预览和调试自定义组件。
|
|
37
31
|
```bash
|
|
38
32
|
$ npm run linkDebug
|
|
39
33
|
```
|
|
40
34
|
|
|
41
|
-
|
|
35
|
+
3. **发布到 NeoCRM 平台**
|
|
42
36
|
> 需要确保 package.json 中的 name 值唯一,version 值不重复。
|
|
43
37
|
```bash
|
|
44
38
|
$ npm run pushCmp
|
|
45
39
|
```
|
|
46
40
|
|
|
41
|
+
### OAuth2 登录授权
|
|
42
|
+
使用 `neo push cmp`、`neo pull cmp`、`neo delete cmp` 等命令与 NeoCRM 平台交互时,需要进行授权登录。
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
使用 `neo push cmp`、`neo pull cmp`、`neo delete cmp` 等命令与 NeoCRM 平台交互时,需要配置授权信息。
|
|
51
|
-
|
|
52
|
-
#### 方式一:OAuth2 登录授权(推荐)
|
|
53
|
-
|
|
54
|
-
OAuth2 授权码模式更加安全可靠,无需用户配置账户名和密码。
|
|
55
|
-
|
|
56
|
-
##### 使用步骤
|
|
44
|
+
#### 使用步骤
|
|
57
45
|
|
|
58
46
|
1. **登录 NeoCRM 平台**
|
|
59
47
|
```bash
|
|
@@ -73,7 +61,7 @@ OAuth2 授权码模式更加安全可靠,无需用户配置账户名和密码
|
|
|
73
61
|
|
|
74
62
|
功能:清除本地保存的 token 文件,下次使用需要重新登录。
|
|
75
63
|
|
|
76
|
-
|
|
64
|
+
#### neo login 选择「自定义环境」时的授权配置示例
|
|
77
65
|
|
|
78
66
|
```javascript
|
|
79
67
|
// neo.config.js
|
|
@@ -87,14 +75,14 @@ module.exports = {
|
|
|
87
75
|
}
|
|
88
76
|
```
|
|
89
77
|
|
|
90
|
-
|
|
78
|
+
#### Token 有效期
|
|
91
79
|
|
|
92
80
|
- **access_token**:默认有效期 2 小时
|
|
93
81
|
- **refresh_token**:默认有效期 30 天
|
|
94
82
|
- 系统会在 access_token 过期前 5 分钟自动刷新
|
|
95
83
|
- 如果 refresh_token 也过期,需要重新执行 `neo login`
|
|
96
84
|
|
|
97
|
-
|
|
85
|
+
#### 常见问题
|
|
98
86
|
|
|
99
87
|
**Q1: 浏览器无法自动打开怎么办?**
|
|
100
88
|
A: 命令行会输出授权 URL,手动复制到浏览器中打开即可。
|
|
@@ -105,50 +93,6 @@ A: 如果 refresh_token 也过期(默认 30 天),需要重新执行 `neo l
|
|
|
105
93
|
**Q3: 授权登录后没有正常跳回 redirect_uri**
|
|
106
94
|
A: 可能被浏览器安装的插件影响,目前已知会影响授权登录的浏览器插件有:Neo UI Extension,请关闭插件后重试。
|
|
107
95
|
|
|
108
|
-
#### 方式二:密码授权配置
|
|
109
|
-
|
|
110
|
-
在项目根目录的 `neo.config.js` 文件中添加 NeoCRM 平台授权配置:
|
|
111
|
-
|
|
112
|
-
```javascript
|
|
113
|
-
module.exports = {
|
|
114
|
-
neoConfig: {
|
|
115
|
-
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
116
|
-
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址
|
|
117
|
-
// NeoCRM 授权配置
|
|
118
|
-
auth: {
|
|
119
|
-
client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
120
|
-
client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
121
|
-
username: 'xx', // 用户在销售易系统中的用户名
|
|
122
|
-
/**
|
|
123
|
-
* password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
|
|
124
|
-
* 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
125
|
-
*/
|
|
126
|
-
password: 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
##### 授权配置获取方式
|
|
133
|
-
|
|
134
|
-
1. **客户端 ID 和客户端秘钥**:需通过创建连接器获取
|
|
135
|
-
- 访问 [销售易文档中心](https://doc.xiaoshouyi.com) / 创建连接器
|
|
136
|
-
- 创建连接器后,从客户端信息中获取 `Client_Id` 和 `Client_Secret`
|
|
137
|
-
|
|
138
|
-
2. **安全令牌**:如何获取安全令牌
|
|
139
|
-
- 访问 [销售易文档中心](https://doc.xiaoshouyi.com) / OAuth安全认证 / 密码模式 / 获取令牌
|
|
140
|
-
- 按照文档说明获取 8 位安全令牌
|
|
141
|
-
- `password` 字段 = 用户账户密码 + 8 位安全令牌(直接拼接,无空格或分隔符)
|
|
142
|
-
|
|
143
|
-
#### OAuth2 模式 vs 密码模式
|
|
144
|
-
|
|
145
|
-
| 特性 | OAuth2 授权码模式 | 密码模式 |
|
|
146
|
-
|------|------------------|---------|
|
|
147
|
-
| 安全性 | ✅ 高(无需在配置文件中存储密码) | ⚠️ 较低(需要配置密码和安全令牌) |
|
|
148
|
-
| Token 刷新 | ✅ 自动刷新 | ✅ 自动刷新 |
|
|
149
|
-
| 有效期 | 2 小时(可自动刷新) | 永不过期 |
|
|
150
|
-
| 推荐程度 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
|
|
151
|
-
|
|
152
96
|
---
|
|
153
97
|
|
|
154
98
|
### 配置项说明(neo-cmp-cli)
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"author": "wibetter",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"preview": "neo preview",
|
|
14
13
|
"linkDebug": "neo linkDebug",
|
|
15
14
|
"neoLogin": "neo login",
|
|
16
15
|
"pushCmp": "neo push cmp",
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
"@types/react": "^16.9.11",
|
|
48
47
|
"@types/react-dom": "^16.9.15",
|
|
49
48
|
"@types/axios": "^0.14.0",
|
|
50
|
-
"neo-cmp-cli": "^1.10.
|
|
49
|
+
"neo-cmp-cli": "^1.10.13",
|
|
51
50
|
"husky": "^4.2.5",
|
|
52
51
|
"lint-staged": "^10.2.9",
|
|
53
52
|
"prettier": "^2.0.5"
|