neo-cmp-cli 1.7.5-beta.2 → 1.7.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.7.5-beta.2",
3
+ "version": "1.7.6",
4
4
  "description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -249,11 +249,31 @@ class NeoLoginService {
249
249
  res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
250
250
  res.end(`
251
251
  <html>
252
- <head><title>授权成功</title></head>
252
+ <head>
253
+ <title>授权成功</title>
254
+ <style>
255
+ container {
256
+ margin: 30px auto;
257
+ padding-top: 30px;
258
+ text-align: center;
259
+
260
+ .success-title {
261
+ color: green;
262
+ }
263
+
264
+ h1, p {
265
+ text-align: center;
266
+ margin-top: 10px;
267
+ }
268
+ }
269
+ </style>
270
+ </head>
253
271
  <body>
254
- <h1>授权成功!</h1>
255
- <p>已获取授权码</p>
256
- <p>您可以关闭此窗口</p>
272
+ <div class="container">
273
+ <h1 class="success-title">授权成功!</h1>
274
+ <img src="https://custom-widgets.bj.bcebos.com/neocrmlogin.png" alt="授权成功" />
275
+ <p>您已成功授权开发账户,请关闭此页面。</p>
276
+ </div>
257
277
  </body>
258
278
  </html>
259
279
  `);
@@ -265,11 +285,31 @@ class NeoLoginService {
265
285
  res.writeHead(400, { 'Content-Type': 'text/html; charset=utf-8' });
266
286
  res.end(`
267
287
  <html>
268
- <head><title>授权失败</title></head>
288
+ <head>
289
+ <title>授权失败</title>
290
+ <style>
291
+ .container {
292
+ margin: 30px auto;
293
+ padding-top: 30px;
294
+ text-align: center;
295
+
296
+ .error-title {
297
+ color: red;
298
+ }
299
+
300
+ h1, p {
301
+ text-align: center;
302
+ margin-top: 10px;
303
+ }
304
+ }
305
+ </style>
306
+ </head>
269
307
  <body>
270
- <h1>授权失败</h1>
271
- <p>未获取到授权码</p>
272
- <p>您可以关闭此窗口</p>
308
+ <div class="container">
309
+ <h1 class="error-title">授权失败</h1>
310
+ <img src="https://custom-widgets.bj.bcebos.com/neocrmlogin.png" alt="授权失败" />
311
+ <p>未获取到授权码。</p>
312
+ </div>
273
313
  </body>
274
314
  </html>
275
315
  `);
@@ -408,7 +448,7 @@ class NeoLoginService {
408
448
 
409
449
  // 4. 等待获取授权码
410
450
  const code = await codePromise;
411
- console.log('\n✓ 已获取授权码');
451
+ successLog('\n✓ 已获取授权码');
412
452
 
413
453
  // 5. 使用授权码获取 token
414
454
  const tokenData = await this.getTokenByCode(code, redirectUri);
@@ -426,7 +466,6 @@ class NeoLoginService {
426
466
  tokenData.refresh_token_expires_in || 2592000
427
467
  } 秒`
428
468
  );
429
- console.log('');
430
469
 
431
470
  return tokenData;
432
471
  } catch (error) {
@@ -107,7 +107,7 @@ module.exports = {
107
107
  neoConfig: {
108
108
  authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
109
109
  neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
110
- // 当 authType 为 oauth2 时,loginURL 配置项必填
110
+ // 当 authType 为 oauth2 时,loginURL 配置项必填
111
111
  loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
112
112
  tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
113
113
  },
@@ -103,7 +103,7 @@ module.exports = {
103
103
  neoConfig: {
104
104
  authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
105
105
  neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
106
- // 当 authType 为 oauth2 时,loginURL 配置项必填
106
+ // 当 authType 为 oauth2 时,loginURL 配置项必填
107
107
  loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
108
108
  tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
109
109
  },
@@ -101,7 +101,7 @@ module.exports = {
101
101
  neoConfig: {
102
102
  authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
103
103
  neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
104
- // 当 authType 为 oauth2 时,loginURL 配置项必填
104
+ // 当 authType 为 oauth2 时,loginURL 配置项必填
105
105
  loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
106
106
  tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
107
107
  },
@@ -109,7 +109,7 @@ module.exports = {
109
109
  neoConfig: {
110
110
  authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
111
111
  neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
112
- // 当 authType 为 oauth2 时,loginURL 配置项必填
112
+ // 当 authType 为 oauth2 时,loginURL 配置项必填
113
113
  loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
114
114
  tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
115
115
  },
@@ -100,7 +100,7 @@ module.exports = {
100
100
  neoConfig: {
101
101
  authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
102
102
  neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
103
- // 当 authType 为 oauth2 时,loginURL 配置项必填
103
+ // 当 authType 为 oauth2 时,loginURL 配置项必填
104
104
  loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
105
105
  tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
106
106
  },
@@ -101,7 +101,7 @@ module.exports = {
101
101
  neoConfig: {
102
102
  authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
103
103
  neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
104
- // 当 authType 为 oauth2 时,loginURL 配置项必填
104
+ // 当 authType 为 oauth2 时,loginURL 配置项必填
105
105
  loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
106
106
  tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
107
107
  },
@@ -43,12 +43,64 @@ $ npm run linkDebug
43
43
  $ npm run pushCmp
44
44
  ```
45
45
 
46
- ##### 需自行添加 NeoCRM 授权配置
46
+ ### 🔐 授权配置
47
+
48
+ 使用 `neo push cmp`、`neo pull cmp`、`neo delete cmp` 等命令与 NeoCRM 平台交互时,需要配置授权信息。
49
+
50
+ #### 方式一:OAuth2 登录授权(推荐)
51
+
52
+ OAuth2 授权码模式更加安全可靠,且支持 token 自动刷新。
53
+
54
+ ##### 使用步骤
55
+
56
+ 1. **登录 NeoCRM 平台**
57
+ ```bash
58
+ neo login
59
+ ```
60
+
61
+ 执行流程:
62
+ - 自动打开浏览器访问授权页面
63
+ - 在浏览器中输入 NeoCRM 账号密码进行登录
64
+ - 授权成功后自动跳转回本地
65
+ - Token 自动保存到项目的 `.neo-cli/token.json` 文件中
66
+
67
+ 2. **登出 NeoCRM 平台**
68
+ ```bash
69
+ neo logout
70
+ ```
71
+
72
+ 功能:清除本地保存的 token 文件,下次使用需要重新登录。
73
+
74
+ ##### 配置示例
75
+
76
+ ```javascript
77
+ // neo.config.js
78
+ module.exports = {
79
+ neoConfig: {
80
+ neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
81
+ // 登录授权 URL(用于获取 code)
82
+ loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth',
83
+ tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址
84
+ },
85
+ }
86
+ ```
87
+
88
+ ##### Token 有效期
89
+
90
+ - **access_token**:默认有效期 2 小时
91
+ - **refresh_token**:默认有效期 30 天
92
+ - 系统会在 access_token 过期前 5 分钟自动刷新
93
+ - 如果 refresh_token 也过期,需要重新执行 `neo login`
94
+
95
+ #### 方式二:密码授权配置
96
+
97
+ 在项目根目录的 `neo.config.js` 文件中添加 NeoCRM 平台授权配置:
98
+
47
99
  ```javascript
48
100
  module.exports = {
49
101
  neoConfig: {
50
102
  neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
51
- tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
103
+ tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址
52
104
  // NeoCRM 授权配置
53
105
  auth: {
54
106
  client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
@@ -63,9 +115,31 @@ module.exports = {
63
115
  },
64
116
  }
65
117
  ```
66
- 1、客户端 ID 和 客户端秘钥 需通过 创建连接器 获取,获取方式见:[https://doc.xiaoshouyi.com](https://doc.xiaoshouyi.com) / 创建连接器;
67
- 2、如何获取 安全令牌 见:[https://doc.xiaoshouyi.com](https://doc.xiaoshouyi.com) / OAuth安全认证 / 密码模式 / 获取令牌;
68
- 3、发布成功后即可在 NeoCRM 对应租户环境的页面设计器和表单设计器中使用此自定义组件。
118
+
119
+ ##### 授权配置获取方式
120
+
121
+ 1. **客户端 ID 和客户端秘钥**:需通过创建连接器获取
122
+ - 访问 [销售易文档中心](https://doc.xiaoshouyi.com) / 创建连接器
123
+ - 创建连接器后,从客户端信息中获取 `Client_Id` 和 `Client_Secret`
124
+
125
+ 2. **安全令牌**:如何获取安全令牌
126
+ - 访问 [销售易文档中心](https://doc.xiaoshouyi.com) / OAuth安全认证 / 密码模式 / 获取令牌
127
+ - 按照文档说明获取 8 位安全令牌
128
+ - `password` 字段 = 用户账户密码 + 8 位安全令牌(直接拼接,无空格或分隔符)
129
+
130
+ #### OAuth2 模式 vs 密码模式
131
+
132
+ | 特性 | OAuth2 授权码模式 | 密码模式 |
133
+ |------|------------------|---------|
134
+ | 安全性 | ✅ 高(无需在配置文件中存储密码) | ⚠️ 较低(需要配置密码和安全令牌) |
135
+ | Token 刷新 | ✅ 自动刷新 | ✅ 自动刷新 |
136
+ | 有效期 | 2 小时(可自动刷新) | 2 小时(可自动刷新) |
137
+ | 推荐程度 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
138
+
139
+ > **建议**:优先使用 OAuth2 授权码模式(`neo login`),更加安全便捷。
140
+
141
+ ---
142
+
69
143
 
70
144
  ### 配置项说明(neo-cmp-cli)
71
145
  [请查看neo-cmp-cli](https://github.com/wibetter/neo-cmp-cli)
@@ -109,7 +109,7 @@ module.exports = {
109
109
  neoConfig: {
110
110
  authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
111
111
  neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
112
- // 当 authType 为 oauth2 时,loginURL 配置项必填
112
+ // 当 authType 为 oauth2 时,loginURL 配置项必填
113
113
  loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
114
114
  tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
115
115
  },