lgsso-sdk 1.0.96 → 1.0.98
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/README.md +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,11 +7,11 @@ LG-SSO SDK 是一个无框架依赖的单点登录(SSO)JavaScript 库,提
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
|
|
10
|
+
# 使用 npm 安装
|
|
11
11
|
|
|
12
12
|
npm install lg-ssosdk
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
# 使用 yarn 安装
|
|
15
15
|
|
|
16
16
|
yarn add lg-ssosdk
|
|
17
17
|
```
|
|
@@ -43,7 +43,7 @@ lgsso.init({
|
|
|
43
43
|
|
|
44
44
|
accessCodeKey: 'accessCode', // accessCode 在 URL 中的参数名
|
|
45
45
|
|
|
46
|
-
tokenKey: '
|
|
46
|
+
tokenKey: 'scm_token', // token 在存储中的键名
|
|
47
47
|
|
|
48
48
|
timeout: 5000, // 请求超时时间(毫秒)
|
|
49
49
|
|
|
@@ -75,7 +75,7 @@ lgsso.init({
|
|
|
75
75
|
| 参数名 | 类型 | 默认值 | 说明 |
|
|
76
76
|
| -------------- | ------ | ------------ | ----------------------------------- |
|
|
77
77
|
| accessCodeKey | String | 'accessCode' | accessCode 在 URL 中的参数名 |
|
|
78
|
-
| tokenKey | String | '
|
|
78
|
+
| tokenKey | String | 'scm_token' | token 在 storage 中的存储键名 |
|
|
79
79
|
| timeout | Number | 5000 | 请求超时时间(ms) |
|
|
80
80
|
| headers | Object | {} | 自定义请求头 |
|
|
81
81
|
| tokenApi | String | '' | 通过 accessCode 获取 token 的 API 地址(必填) |
|
|
@@ -159,7 +159,7 @@ lgsso.logout()
|
|
|
159
159
|
```
|
|
160
160
|
// 在当前页面打开(默认)
|
|
161
161
|
|
|
162
|
-
lgsso.toUrl('https://example.com/target', '
|
|
162
|
+
lgsso.toUrl('https://example.com/target', ' _self')
|
|
163
163
|
|
|
164
164
|
.then(result => {
|
|
165
165
|
|
|
@@ -169,7 +169,7 @@ lgsso.toUrl('https://example.com/target', '\_self')
|
|
|
169
169
|
|
|
170
170
|
// 在新页面打开
|
|
171
171
|
|
|
172
|
-
lgsso.toUrl('https://example.com/target', '
|
|
172
|
+
lgsso.toUrl('https://example.com/target', ' _blank');
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
### getAccessCode()
|
|
@@ -208,7 +208,7 @@ lgsso.getAccessCode()
|
|
|
208
208
|
| -105 | 未配置 refreshCodeApi |
|
|
209
209
|
| -106 | 未找到有效 token |
|
|
210
210
|
| -107 | 跳转失败 |
|
|
211
|
-
| -108 | target 参数无效(必须是 '
|
|
211
|
+
| -108 | target 参数无效(必须是 '_self' 或 '_blank') |
|
|
212
212
|
| -200 | 非浏览器环境使用 request 方法 |
|
|
213
213
|
| -201 | 响应数据不是有效的 JSON 格式 |
|
|
214
214
|
| -202 | 请求超时 |
|
|
@@ -251,7 +251,7 @@ lgsso.init({
|
|
|
251
251
|
|
|
252
252
|
document.getElementById('gotoCurrent').addEventListener('click', () => {
|
|
253
253
|
|
|
254
|
-
lgsso.toUrl('https://other-app.example.com', '
|
|
254
|
+
lgsso.toUrl('https://other-app.example.com', '_self')
|
|
255
255
|
|
|
256
256
|
.catch(err => console.error('跳转失败:', err));
|
|
257
257
|
|
|
@@ -263,7 +263,7 @@ lgsso.init({
|
|
|
263
263
|
|
|
264
264
|
document.getElementById('gotoNew').addEventListener('click', () => {
|
|
265
265
|
|
|
266
|
-
lgsso.toUrl('https://other-app.example.com', '
|
|
266
|
+
lgsso.toUrl('https://other-app.example.com', ' _blank')
|
|
267
267
|
|
|
268
268
|
.catch(err => console.error('跳转失败:', err));
|
|
269
269
|
|