lgsso-sdk 1.1.9 → 1.2.1
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/lgsso-sdk.cjs +58 -47
- package/dist/lgsso-sdk.esm.js +58 -47
- package/dist/lgsso-sdk.js +58 -47
- package/dist/lgsso-sdk.min.js +1 -1
- package/package.json +1 -1
- package/src/sso.js +46 -46
- package/src/utils.js +1 -1
package/dist/lgsso-sdk.cjs
CHANGED
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
12
|
* 检查是否在浏览器环境
|
|
13
13
|
*/
|
|
14
14
|
function isBrowser() {
|
|
15
|
-
return
|
|
15
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -22,6 +22,7 @@ function isBrowser() {
|
|
|
22
22
|
* @returns {string|null} 参数值
|
|
23
23
|
*/
|
|
24
24
|
function getQueryParam(name, url) {
|
|
25
|
+
if (!isBrowser()) return null;
|
|
25
26
|
|
|
26
27
|
const targetUrl = url || window.location.href;
|
|
27
28
|
const urlObj = new URL(targetUrl);
|
|
@@ -45,6 +46,7 @@ function getQueryParam(name, url) {
|
|
|
45
46
|
* @param {string} name - 参数名
|
|
46
47
|
*/
|
|
47
48
|
function removeQueryParam(name) {
|
|
49
|
+
if (!isBrowser()) return;
|
|
48
50
|
|
|
49
51
|
const url = new URL(window.location.href);
|
|
50
52
|
let params, newUrl;
|
|
@@ -82,6 +84,7 @@ function removeQueryParam(name) {
|
|
|
82
84
|
* @returns {string} 当前URL
|
|
83
85
|
*/
|
|
84
86
|
function getCurrentUrlWithParams() {
|
|
87
|
+
if (!isBrowser()) return '';
|
|
85
88
|
return window.location.href;
|
|
86
89
|
}
|
|
87
90
|
|
|
@@ -4020,6 +4023,13 @@ async function request(url, {
|
|
|
4020
4023
|
headers = {},
|
|
4021
4024
|
timeout = 5000
|
|
4022
4025
|
} = {}) {
|
|
4026
|
+
if (!isBrowser()) {
|
|
4027
|
+
return {
|
|
4028
|
+
code: -200,
|
|
4029
|
+
msg: 'request方法只能在浏览器环境使用',
|
|
4030
|
+
success: false
|
|
4031
|
+
};
|
|
4032
|
+
}
|
|
4023
4033
|
|
|
4024
4034
|
// 根据浏览器支持情况选择合适的请求方式
|
|
4025
4035
|
if (isFetchSupported()) {
|
|
@@ -4068,6 +4078,18 @@ function validateConfig(options) {
|
|
|
4068
4078
|
}
|
|
4069
4079
|
}
|
|
4070
4080
|
|
|
4081
|
+
/**
|
|
4082
|
+
* 判断是否是iOS移动端
|
|
4083
|
+
* @returns {boolean} 是否为iOS环境
|
|
4084
|
+
*/
|
|
4085
|
+
function isIOS() {
|
|
4086
|
+
// if (!isBrowser()) return false; // 非浏览器环境直接返回false
|
|
4087
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
4088
|
+
alert(userAgent);
|
|
4089
|
+
// 匹配iPhone/iPad/iPod,排除Windows Phone等兼容情况
|
|
4090
|
+
return /iphone|ipad|ipod/.test(userAgent) && !window.MSStream;
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4071
4093
|
/**
|
|
4072
4094
|
* 创建SSO实例
|
|
4073
4095
|
* @returns {Object} SSO实例
|
|
@@ -4140,7 +4162,6 @@ function createSSO() {
|
|
|
4140
4162
|
config.storage.removeItem(config.tokenKey);
|
|
4141
4163
|
},
|
|
4142
4164
|
|
|
4143
|
-
|
|
4144
4165
|
/**
|
|
4145
4166
|
* 退出登录
|
|
4146
4167
|
* @returns {Promise<Object>} 接口返回结果
|
|
@@ -4168,9 +4189,7 @@ function createSSO() {
|
|
|
4168
4189
|
this.removeToken();
|
|
4169
4190
|
|
|
4170
4191
|
if (isBrowser() && config.logOutUrl) {
|
|
4171
|
-
|
|
4172
|
-
// 使用兼容方法跳转
|
|
4173
|
-
this.openUrlCompat(redirectUrl, '_self'); // logout默认当前页跳转,若需新开可改_blank
|
|
4192
|
+
window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
|
|
4174
4193
|
}
|
|
4175
4194
|
return result;
|
|
4176
4195
|
} catch (error) {
|
|
@@ -4178,9 +4197,8 @@ function createSSO() {
|
|
|
4178
4197
|
}
|
|
4179
4198
|
} else {
|
|
4180
4199
|
this.removeToken();
|
|
4181
|
-
if (config.logOutUrl) {
|
|
4182
|
-
|
|
4183
|
-
this.openUrlCompat(redirectUrl, '_self');
|
|
4200
|
+
if (isBrowser() && config.logOutUrl) {
|
|
4201
|
+
window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
|
|
4184
4202
|
}
|
|
4185
4203
|
return { code: 0, msg: '已成功清除token', success: true };
|
|
4186
4204
|
}
|
|
@@ -4201,6 +4219,11 @@ function createSSO() {
|
|
|
4201
4219
|
return { code: -104, msg: '请提供跳转地址', success: false };
|
|
4202
4220
|
}
|
|
4203
4221
|
|
|
4222
|
+
// 核心修改:iOS移动端强制使用当前页面打开
|
|
4223
|
+
if (isIOS()) {
|
|
4224
|
+
target = '_self';
|
|
4225
|
+
}
|
|
4226
|
+
|
|
4204
4227
|
// 验证target参数有效性
|
|
4205
4228
|
if (!['_self', '_blank'].includes(target)) {
|
|
4206
4229
|
return { code: -108, msg: 'target参数必须是"_self"或"_blank"', success: false };
|
|
@@ -4212,10 +4235,15 @@ function createSSO() {
|
|
|
4212
4235
|
|
|
4213
4236
|
const token = this.getToken();
|
|
4214
4237
|
if (!token) {
|
|
4215
|
-
if (config.logOutUrl) {
|
|
4238
|
+
if (isBrowser() && config.logOutUrl) {
|
|
4216
4239
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4217
|
-
|
|
4218
|
-
|
|
4240
|
+
|
|
4241
|
+
// 根据target决定打开方式
|
|
4242
|
+
if (target === '_blank') {
|
|
4243
|
+
window.open(loginUrl, '_blank');
|
|
4244
|
+
} else {
|
|
4245
|
+
window.location.href = loginUrl;
|
|
4246
|
+
}
|
|
4219
4247
|
}
|
|
4220
4248
|
return { code: -106, msg: '未找到有效token', success: false };
|
|
4221
4249
|
}
|
|
@@ -4234,50 +4262,34 @@ function createSSO() {
|
|
|
4234
4262
|
const url = new URL(redirectUrl);
|
|
4235
4263
|
url.searchParams.set(config.accessCodeKey, result.data);
|
|
4236
4264
|
const targetUrl = url.toString();
|
|
4237
|
-
|
|
4265
|
+
|
|
4266
|
+
// 根据target参数决定跳转方式
|
|
4267
|
+
if (target === '_blank') {
|
|
4268
|
+
window.open(targetUrl, '_blank');
|
|
4269
|
+
} else {
|
|
4270
|
+
window.location.href = targetUrl;
|
|
4271
|
+
}
|
|
4238
4272
|
} else {
|
|
4239
4273
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4240
|
-
|
|
4274
|
+
if (target === '_blank') {
|
|
4275
|
+
window.open(loginUrl, '_blank');
|
|
4276
|
+
} else {
|
|
4277
|
+
window.location.href = loginUrl;
|
|
4278
|
+
}
|
|
4241
4279
|
}
|
|
4242
4280
|
|
|
4243
4281
|
return result;
|
|
4244
4282
|
} catch (error) {
|
|
4245
4283
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4246
|
-
|
|
4284
|
+
if (target === '_blank') {
|
|
4285
|
+
window.open(loginUrl, '_blank');
|
|
4286
|
+
} else {
|
|
4287
|
+
window.location.href = loginUrl;
|
|
4288
|
+
}
|
|
4247
4289
|
return { code: -107, msg: `跳转失败: ${error.message}`, success: false };
|
|
4248
4290
|
}
|
|
4249
4291
|
},
|
|
4250
|
-
// 封装兼容iOS的跳转工具函数
|
|
4251
|
-
openUrlCompat (url, target = '_self') {
|
|
4252
4292
|
|
|
4253
|
-
// 处理_self:直接跳转
|
|
4254
|
-
if (target === '_self') {
|
|
4255
|
-
window.location.href = url;
|
|
4256
|
-
return;
|
|
4257
|
-
}
|
|
4258
|
-
|
|
4259
|
-
// 处理_blank:iOS下用a标签模拟点击替代window.open
|
|
4260
|
-
try {
|
|
4261
|
-
// 创建a标签
|
|
4262
|
-
const link = document.createElement('a');
|
|
4263
|
-
link.href = url;
|
|
4264
|
-
link.target = '_blank';
|
|
4265
|
-
link.rel = 'noopener noreferrer'; // 安全属性,避免性能问题
|
|
4266
|
-
// 模拟用户点击(必须在交互回调中执行)
|
|
4267
|
-
document.body.appendChild(link);
|
|
4268
|
-
const event = new MouseEvent('click', {
|
|
4269
|
-
bubbles: true,
|
|
4270
|
-
cancelable: true,
|
|
4271
|
-
view: window
|
|
4272
|
-
});
|
|
4273
|
-
link.dispatchEvent(event);
|
|
4274
|
-
// 移除临时a标签
|
|
4275
|
-
document.body.removeChild(link);
|
|
4276
|
-
} catch (e) {
|
|
4277
|
-
// 降级方案:仍尝试window.open(部分场景可能生效)
|
|
4278
|
-
window.open(url, '_blank');
|
|
4279
|
-
}
|
|
4280
|
-
},
|
|
4281
4293
|
/**
|
|
4282
4294
|
* 获取accessCode(通过token换取)
|
|
4283
4295
|
* @returns {Promise<Object>} 接口返回结果(data为accessCode)
|
|
@@ -4337,8 +4349,10 @@ function createSSO() {
|
|
|
4337
4349
|
}
|
|
4338
4350
|
);
|
|
4339
4351
|
},
|
|
4352
|
+
|
|
4340
4353
|
async getPhoneCode() {
|
|
4341
4354
|
const token = this.getToken();
|
|
4355
|
+
// 修复笔误:sendCaptchaCode → sendCaptchaCodeApi
|
|
4342
4356
|
return request(
|
|
4343
4357
|
config.sendCaptchaCodeApi,
|
|
4344
4358
|
{
|
|
@@ -4348,12 +4362,9 @@ function createSSO() {
|
|
|
4348
4362
|
}
|
|
4349
4363
|
);
|
|
4350
4364
|
},
|
|
4351
|
-
|
|
4352
4365
|
};
|
|
4353
4366
|
}
|
|
4354
4367
|
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
4368
|
// 创建默认实例
|
|
4358
4369
|
const lgsso = createSSO();
|
|
4359
4370
|
|
package/dist/lgsso-sdk.esm.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 检查是否在浏览器环境
|
|
9
9
|
*/
|
|
10
10
|
function isBrowser() {
|
|
11
|
-
return
|
|
11
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -18,6 +18,7 @@ function isBrowser() {
|
|
|
18
18
|
* @returns {string|null} 参数值
|
|
19
19
|
*/
|
|
20
20
|
function getQueryParam(name, url) {
|
|
21
|
+
if (!isBrowser()) return null;
|
|
21
22
|
|
|
22
23
|
const targetUrl = url || window.location.href;
|
|
23
24
|
const urlObj = new URL(targetUrl);
|
|
@@ -41,6 +42,7 @@ function getQueryParam(name, url) {
|
|
|
41
42
|
* @param {string} name - 参数名
|
|
42
43
|
*/
|
|
43
44
|
function removeQueryParam(name) {
|
|
45
|
+
if (!isBrowser()) return;
|
|
44
46
|
|
|
45
47
|
const url = new URL(window.location.href);
|
|
46
48
|
let params, newUrl;
|
|
@@ -78,6 +80,7 @@ function removeQueryParam(name) {
|
|
|
78
80
|
* @returns {string} 当前URL
|
|
79
81
|
*/
|
|
80
82
|
function getCurrentUrlWithParams() {
|
|
83
|
+
if (!isBrowser()) return '';
|
|
81
84
|
return window.location.href;
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -4016,6 +4019,13 @@ async function request(url, {
|
|
|
4016
4019
|
headers = {},
|
|
4017
4020
|
timeout = 5000
|
|
4018
4021
|
} = {}) {
|
|
4022
|
+
if (!isBrowser()) {
|
|
4023
|
+
return {
|
|
4024
|
+
code: -200,
|
|
4025
|
+
msg: 'request方法只能在浏览器环境使用',
|
|
4026
|
+
success: false
|
|
4027
|
+
};
|
|
4028
|
+
}
|
|
4019
4029
|
|
|
4020
4030
|
// 根据浏览器支持情况选择合适的请求方式
|
|
4021
4031
|
if (isFetchSupported()) {
|
|
@@ -4064,6 +4074,18 @@ function validateConfig(options) {
|
|
|
4064
4074
|
}
|
|
4065
4075
|
}
|
|
4066
4076
|
|
|
4077
|
+
/**
|
|
4078
|
+
* 判断是否是iOS移动端
|
|
4079
|
+
* @returns {boolean} 是否为iOS环境
|
|
4080
|
+
*/
|
|
4081
|
+
function isIOS() {
|
|
4082
|
+
// if (!isBrowser()) return false; // 非浏览器环境直接返回false
|
|
4083
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
4084
|
+
alert(userAgent);
|
|
4085
|
+
// 匹配iPhone/iPad/iPod,排除Windows Phone等兼容情况
|
|
4086
|
+
return /iphone|ipad|ipod/.test(userAgent) && !window.MSStream;
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4067
4089
|
/**
|
|
4068
4090
|
* 创建SSO实例
|
|
4069
4091
|
* @returns {Object} SSO实例
|
|
@@ -4136,7 +4158,6 @@ function createSSO() {
|
|
|
4136
4158
|
config.storage.removeItem(config.tokenKey);
|
|
4137
4159
|
},
|
|
4138
4160
|
|
|
4139
|
-
|
|
4140
4161
|
/**
|
|
4141
4162
|
* 退出登录
|
|
4142
4163
|
* @returns {Promise<Object>} 接口返回结果
|
|
@@ -4164,9 +4185,7 @@ function createSSO() {
|
|
|
4164
4185
|
this.removeToken();
|
|
4165
4186
|
|
|
4166
4187
|
if (isBrowser() && config.logOutUrl) {
|
|
4167
|
-
|
|
4168
|
-
// 使用兼容方法跳转
|
|
4169
|
-
this.openUrlCompat(redirectUrl, '_self'); // logout默认当前页跳转,若需新开可改_blank
|
|
4188
|
+
window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
|
|
4170
4189
|
}
|
|
4171
4190
|
return result;
|
|
4172
4191
|
} catch (error) {
|
|
@@ -4174,9 +4193,8 @@ function createSSO() {
|
|
|
4174
4193
|
}
|
|
4175
4194
|
} else {
|
|
4176
4195
|
this.removeToken();
|
|
4177
|
-
if (config.logOutUrl) {
|
|
4178
|
-
|
|
4179
|
-
this.openUrlCompat(redirectUrl, '_self');
|
|
4196
|
+
if (isBrowser() && config.logOutUrl) {
|
|
4197
|
+
window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
|
|
4180
4198
|
}
|
|
4181
4199
|
return { code: 0, msg: '已成功清除token', success: true };
|
|
4182
4200
|
}
|
|
@@ -4197,6 +4215,11 @@ function createSSO() {
|
|
|
4197
4215
|
return { code: -104, msg: '请提供跳转地址', success: false };
|
|
4198
4216
|
}
|
|
4199
4217
|
|
|
4218
|
+
// 核心修改:iOS移动端强制使用当前页面打开
|
|
4219
|
+
if (isIOS()) {
|
|
4220
|
+
target = '_self';
|
|
4221
|
+
}
|
|
4222
|
+
|
|
4200
4223
|
// 验证target参数有效性
|
|
4201
4224
|
if (!['_self', '_blank'].includes(target)) {
|
|
4202
4225
|
return { code: -108, msg: 'target参数必须是"_self"或"_blank"', success: false };
|
|
@@ -4208,10 +4231,15 @@ function createSSO() {
|
|
|
4208
4231
|
|
|
4209
4232
|
const token = this.getToken();
|
|
4210
4233
|
if (!token) {
|
|
4211
|
-
if (config.logOutUrl) {
|
|
4234
|
+
if (isBrowser() && config.logOutUrl) {
|
|
4212
4235
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4213
|
-
|
|
4214
|
-
|
|
4236
|
+
|
|
4237
|
+
// 根据target决定打开方式
|
|
4238
|
+
if (target === '_blank') {
|
|
4239
|
+
window.open(loginUrl, '_blank');
|
|
4240
|
+
} else {
|
|
4241
|
+
window.location.href = loginUrl;
|
|
4242
|
+
}
|
|
4215
4243
|
}
|
|
4216
4244
|
return { code: -106, msg: '未找到有效token', success: false };
|
|
4217
4245
|
}
|
|
@@ -4230,50 +4258,34 @@ function createSSO() {
|
|
|
4230
4258
|
const url = new URL(redirectUrl);
|
|
4231
4259
|
url.searchParams.set(config.accessCodeKey, result.data);
|
|
4232
4260
|
const targetUrl = url.toString();
|
|
4233
|
-
|
|
4261
|
+
|
|
4262
|
+
// 根据target参数决定跳转方式
|
|
4263
|
+
if (target === '_blank') {
|
|
4264
|
+
window.open(targetUrl, '_blank');
|
|
4265
|
+
} else {
|
|
4266
|
+
window.location.href = targetUrl;
|
|
4267
|
+
}
|
|
4234
4268
|
} else {
|
|
4235
4269
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4236
|
-
|
|
4270
|
+
if (target === '_blank') {
|
|
4271
|
+
window.open(loginUrl, '_blank');
|
|
4272
|
+
} else {
|
|
4273
|
+
window.location.href = loginUrl;
|
|
4274
|
+
}
|
|
4237
4275
|
}
|
|
4238
4276
|
|
|
4239
4277
|
return result;
|
|
4240
4278
|
} catch (error) {
|
|
4241
4279
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4242
|
-
|
|
4280
|
+
if (target === '_blank') {
|
|
4281
|
+
window.open(loginUrl, '_blank');
|
|
4282
|
+
} else {
|
|
4283
|
+
window.location.href = loginUrl;
|
|
4284
|
+
}
|
|
4243
4285
|
return { code: -107, msg: `跳转失败: ${error.message}`, success: false };
|
|
4244
4286
|
}
|
|
4245
4287
|
},
|
|
4246
|
-
// 封装兼容iOS的跳转工具函数
|
|
4247
|
-
openUrlCompat (url, target = '_self') {
|
|
4248
4288
|
|
|
4249
|
-
// 处理_self:直接跳转
|
|
4250
|
-
if (target === '_self') {
|
|
4251
|
-
window.location.href = url;
|
|
4252
|
-
return;
|
|
4253
|
-
}
|
|
4254
|
-
|
|
4255
|
-
// 处理_blank:iOS下用a标签模拟点击替代window.open
|
|
4256
|
-
try {
|
|
4257
|
-
// 创建a标签
|
|
4258
|
-
const link = document.createElement('a');
|
|
4259
|
-
link.href = url;
|
|
4260
|
-
link.target = '_blank';
|
|
4261
|
-
link.rel = 'noopener noreferrer'; // 安全属性,避免性能问题
|
|
4262
|
-
// 模拟用户点击(必须在交互回调中执行)
|
|
4263
|
-
document.body.appendChild(link);
|
|
4264
|
-
const event = new MouseEvent('click', {
|
|
4265
|
-
bubbles: true,
|
|
4266
|
-
cancelable: true,
|
|
4267
|
-
view: window
|
|
4268
|
-
});
|
|
4269
|
-
link.dispatchEvent(event);
|
|
4270
|
-
// 移除临时a标签
|
|
4271
|
-
document.body.removeChild(link);
|
|
4272
|
-
} catch (e) {
|
|
4273
|
-
// 降级方案:仍尝试window.open(部分场景可能生效)
|
|
4274
|
-
window.open(url, '_blank');
|
|
4275
|
-
}
|
|
4276
|
-
},
|
|
4277
4289
|
/**
|
|
4278
4290
|
* 获取accessCode(通过token换取)
|
|
4279
4291
|
* @returns {Promise<Object>} 接口返回结果(data为accessCode)
|
|
@@ -4333,8 +4345,10 @@ function createSSO() {
|
|
|
4333
4345
|
}
|
|
4334
4346
|
);
|
|
4335
4347
|
},
|
|
4348
|
+
|
|
4336
4349
|
async getPhoneCode() {
|
|
4337
4350
|
const token = this.getToken();
|
|
4351
|
+
// 修复笔误:sendCaptchaCode → sendCaptchaCodeApi
|
|
4338
4352
|
return request(
|
|
4339
4353
|
config.sendCaptchaCodeApi,
|
|
4340
4354
|
{
|
|
@@ -4344,12 +4358,9 @@ function createSSO() {
|
|
|
4344
4358
|
}
|
|
4345
4359
|
);
|
|
4346
4360
|
},
|
|
4347
|
-
|
|
4348
4361
|
};
|
|
4349
4362
|
}
|
|
4350
4363
|
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
4364
|
// 创建默认实例
|
|
4354
4365
|
const lgsso = createSSO();
|
|
4355
4366
|
|
package/dist/lgsso-sdk.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* 检查是否在浏览器环境
|
|
15
15
|
*/
|
|
16
16
|
function isBrowser() {
|
|
17
|
-
return
|
|
17
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* @returns {string|null} 参数值
|
|
25
25
|
*/
|
|
26
26
|
function getQueryParam(name, url) {
|
|
27
|
+
if (!isBrowser()) return null;
|
|
27
28
|
|
|
28
29
|
const targetUrl = url || window.location.href;
|
|
29
30
|
const urlObj = new URL(targetUrl);
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
* @param {string} name - 参数名
|
|
48
49
|
*/
|
|
49
50
|
function removeQueryParam(name) {
|
|
51
|
+
if (!isBrowser()) return;
|
|
50
52
|
|
|
51
53
|
const url = new URL(window.location.href);
|
|
52
54
|
let params, newUrl;
|
|
@@ -84,6 +86,7 @@
|
|
|
84
86
|
* @returns {string} 当前URL
|
|
85
87
|
*/
|
|
86
88
|
function getCurrentUrlWithParams() {
|
|
89
|
+
if (!isBrowser()) return '';
|
|
87
90
|
return window.location.href;
|
|
88
91
|
}
|
|
89
92
|
|
|
@@ -4022,6 +4025,13 @@
|
|
|
4022
4025
|
headers = {},
|
|
4023
4026
|
timeout = 5000
|
|
4024
4027
|
} = {}) {
|
|
4028
|
+
if (!isBrowser()) {
|
|
4029
|
+
return {
|
|
4030
|
+
code: -200,
|
|
4031
|
+
msg: 'request方法只能在浏览器环境使用',
|
|
4032
|
+
success: false
|
|
4033
|
+
};
|
|
4034
|
+
}
|
|
4025
4035
|
|
|
4026
4036
|
// 根据浏览器支持情况选择合适的请求方式
|
|
4027
4037
|
if (isFetchSupported()) {
|
|
@@ -4070,6 +4080,18 @@
|
|
|
4070
4080
|
}
|
|
4071
4081
|
}
|
|
4072
4082
|
|
|
4083
|
+
/**
|
|
4084
|
+
* 判断是否是iOS移动端
|
|
4085
|
+
* @returns {boolean} 是否为iOS环境
|
|
4086
|
+
*/
|
|
4087
|
+
function isIOS() {
|
|
4088
|
+
// if (!isBrowser()) return false; // 非浏览器环境直接返回false
|
|
4089
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
4090
|
+
alert(userAgent);
|
|
4091
|
+
// 匹配iPhone/iPad/iPod,排除Windows Phone等兼容情况
|
|
4092
|
+
return /iphone|ipad|ipod/.test(userAgent) && !window.MSStream;
|
|
4093
|
+
}
|
|
4094
|
+
|
|
4073
4095
|
/**
|
|
4074
4096
|
* 创建SSO实例
|
|
4075
4097
|
* @returns {Object} SSO实例
|
|
@@ -4142,7 +4164,6 @@
|
|
|
4142
4164
|
config.storage.removeItem(config.tokenKey);
|
|
4143
4165
|
},
|
|
4144
4166
|
|
|
4145
|
-
|
|
4146
4167
|
/**
|
|
4147
4168
|
* 退出登录
|
|
4148
4169
|
* @returns {Promise<Object>} 接口返回结果
|
|
@@ -4170,9 +4191,7 @@
|
|
|
4170
4191
|
this.removeToken();
|
|
4171
4192
|
|
|
4172
4193
|
if (isBrowser() && config.logOutUrl) {
|
|
4173
|
-
|
|
4174
|
-
// 使用兼容方法跳转
|
|
4175
|
-
this.openUrlCompat(redirectUrl, '_self'); // logout默认当前页跳转,若需新开可改_blank
|
|
4194
|
+
window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
|
|
4176
4195
|
}
|
|
4177
4196
|
return result;
|
|
4178
4197
|
} catch (error) {
|
|
@@ -4180,9 +4199,8 @@
|
|
|
4180
4199
|
}
|
|
4181
4200
|
} else {
|
|
4182
4201
|
this.removeToken();
|
|
4183
|
-
if (config.logOutUrl) {
|
|
4184
|
-
|
|
4185
|
-
this.openUrlCompat(redirectUrl, '_self');
|
|
4202
|
+
if (isBrowser() && config.logOutUrl) {
|
|
4203
|
+
window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
|
|
4186
4204
|
}
|
|
4187
4205
|
return { code: 0, msg: '已成功清除token', success: true };
|
|
4188
4206
|
}
|
|
@@ -4203,6 +4221,11 @@
|
|
|
4203
4221
|
return { code: -104, msg: '请提供跳转地址', success: false };
|
|
4204
4222
|
}
|
|
4205
4223
|
|
|
4224
|
+
// 核心修改:iOS移动端强制使用当前页面打开
|
|
4225
|
+
if (isIOS()) {
|
|
4226
|
+
target = '_self';
|
|
4227
|
+
}
|
|
4228
|
+
|
|
4206
4229
|
// 验证target参数有效性
|
|
4207
4230
|
if (!['_self', '_blank'].includes(target)) {
|
|
4208
4231
|
return { code: -108, msg: 'target参数必须是"_self"或"_blank"', success: false };
|
|
@@ -4214,10 +4237,15 @@
|
|
|
4214
4237
|
|
|
4215
4238
|
const token = this.getToken();
|
|
4216
4239
|
if (!token) {
|
|
4217
|
-
if (config.logOutUrl) {
|
|
4240
|
+
if (isBrowser() && config.logOutUrl) {
|
|
4218
4241
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4219
|
-
|
|
4220
|
-
|
|
4242
|
+
|
|
4243
|
+
// 根据target决定打开方式
|
|
4244
|
+
if (target === '_blank') {
|
|
4245
|
+
window.open(loginUrl, '_blank');
|
|
4246
|
+
} else {
|
|
4247
|
+
window.location.href = loginUrl;
|
|
4248
|
+
}
|
|
4221
4249
|
}
|
|
4222
4250
|
return { code: -106, msg: '未找到有效token', success: false };
|
|
4223
4251
|
}
|
|
@@ -4236,50 +4264,34 @@
|
|
|
4236
4264
|
const url = new URL(redirectUrl);
|
|
4237
4265
|
url.searchParams.set(config.accessCodeKey, result.data);
|
|
4238
4266
|
const targetUrl = url.toString();
|
|
4239
|
-
|
|
4267
|
+
|
|
4268
|
+
// 根据target参数决定跳转方式
|
|
4269
|
+
if (target === '_blank') {
|
|
4270
|
+
window.open(targetUrl, '_blank');
|
|
4271
|
+
} else {
|
|
4272
|
+
window.location.href = targetUrl;
|
|
4273
|
+
}
|
|
4240
4274
|
} else {
|
|
4241
4275
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4242
|
-
|
|
4276
|
+
if (target === '_blank') {
|
|
4277
|
+
window.open(loginUrl, '_blank');
|
|
4278
|
+
} else {
|
|
4279
|
+
window.location.href = loginUrl;
|
|
4280
|
+
}
|
|
4243
4281
|
}
|
|
4244
4282
|
|
|
4245
4283
|
return result;
|
|
4246
4284
|
} catch (error) {
|
|
4247
4285
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
4248
|
-
|
|
4286
|
+
if (target === '_blank') {
|
|
4287
|
+
window.open(loginUrl, '_blank');
|
|
4288
|
+
} else {
|
|
4289
|
+
window.location.href = loginUrl;
|
|
4290
|
+
}
|
|
4249
4291
|
return { code: -107, msg: `跳转失败: ${error.message}`, success: false };
|
|
4250
4292
|
}
|
|
4251
4293
|
},
|
|
4252
|
-
// 封装兼容iOS的跳转工具函数
|
|
4253
|
-
openUrlCompat (url, target = '_self') {
|
|
4254
4294
|
|
|
4255
|
-
// 处理_self:直接跳转
|
|
4256
|
-
if (target === '_self') {
|
|
4257
|
-
window.location.href = url;
|
|
4258
|
-
return;
|
|
4259
|
-
}
|
|
4260
|
-
|
|
4261
|
-
// 处理_blank:iOS下用a标签模拟点击替代window.open
|
|
4262
|
-
try {
|
|
4263
|
-
// 创建a标签
|
|
4264
|
-
const link = document.createElement('a');
|
|
4265
|
-
link.href = url;
|
|
4266
|
-
link.target = '_blank';
|
|
4267
|
-
link.rel = 'noopener noreferrer'; // 安全属性,避免性能问题
|
|
4268
|
-
// 模拟用户点击(必须在交互回调中执行)
|
|
4269
|
-
document.body.appendChild(link);
|
|
4270
|
-
const event = new MouseEvent('click', {
|
|
4271
|
-
bubbles: true,
|
|
4272
|
-
cancelable: true,
|
|
4273
|
-
view: window
|
|
4274
|
-
});
|
|
4275
|
-
link.dispatchEvent(event);
|
|
4276
|
-
// 移除临时a标签
|
|
4277
|
-
document.body.removeChild(link);
|
|
4278
|
-
} catch (e) {
|
|
4279
|
-
// 降级方案:仍尝试window.open(部分场景可能生效)
|
|
4280
|
-
window.open(url, '_blank');
|
|
4281
|
-
}
|
|
4282
|
-
},
|
|
4283
4295
|
/**
|
|
4284
4296
|
* 获取accessCode(通过token换取)
|
|
4285
4297
|
* @returns {Promise<Object>} 接口返回结果(data为accessCode)
|
|
@@ -4339,8 +4351,10 @@
|
|
|
4339
4351
|
}
|
|
4340
4352
|
);
|
|
4341
4353
|
},
|
|
4354
|
+
|
|
4342
4355
|
async getPhoneCode() {
|
|
4343
4356
|
const token = this.getToken();
|
|
4357
|
+
// 修复笔误:sendCaptchaCode → sendCaptchaCodeApi
|
|
4344
4358
|
return request(
|
|
4345
4359
|
config.sendCaptchaCodeApi,
|
|
4346
4360
|
{
|
|
@@ -4350,12 +4364,9 @@
|
|
|
4350
4364
|
}
|
|
4351
4365
|
);
|
|
4352
4366
|
},
|
|
4353
|
-
|
|
4354
4367
|
};
|
|
4355
4368
|
}
|
|
4356
4369
|
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
4370
|
// 创建默认实例
|
|
4360
4371
|
const lgsso = createSSO();
|
|
4361
4372
|
|
package/dist/lgsso-sdk.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lgsso={})}(this,function(e){"use strict";function t(){return window.location.href}function n(e,t){return function(){return e.apply(t,arguments)}}const{toString:r}=Object.prototype,{getPrototypeOf:o}=Object,{iterator:s,toStringTag:i}=Symbol,a=(c=Object.create(null),e=>{const t=r.call(e);return c[t]||(c[t]=t.slice(8,-1).toLowerCase())});var c;const u=e=>(e=e.toLowerCase(),t=>a(t)===e),l=e=>t=>typeof t===e,{isArray:d}=Array,f=l("undefined");function h(e){return null!==e&&!f(e)&&null!==e.constructor&&!f(e.constructor)&&g(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const p=u("ArrayBuffer");const m=l("string"),g=l("function"),y=l("number"),w=e=>null!==e&&"object"==typeof e,b=e=>{if("object"!==a(e))return!1;const t=o(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||i in e||s in e)},E=u("Date"),O=u("File"),R=u("Blob"),S=u("FileList"),T=u("URLSearchParams"),[A,C,v,U]=["ReadableStream","Request","Response","Headers"].map(u);function P(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),d(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(h(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(r=0;r<s;r++)i=o[r],t.call(null,e[i],i,e)}}function k(e,t){if(h(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=e=>!f(e)&&e!==j;const _=(N="undefined"!=typeof Uint8Array&&o(Uint8Array),e=>N&&e instanceof N);var N;const L=u("HTMLFormElement"),F=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),B=u("RegExp"),D=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};P(n,(n,o)=>{let s;!1!==(s=t(n,o,e))&&(r[o]=s||n)}),Object.defineProperties(e,r)};const K=u("AsyncFunction"),q=(I="function"==typeof setImmediate,$=g(j.postMessage),I?setImmediate:$?(M=`axios@${Math.random()}`,z=[],j.addEventListener("message",({source:e,data:t})=>{e===j&&t===M&&z.length&&z.shift()()},!1),e=>{z.push(e),j.postMessage(M,"*")}):e=>setTimeout(e));var I,$,M,z;const H="undefined"!=typeof queueMicrotask?queueMicrotask.bind(j):"undefined"!=typeof process&&process.nextTick||q;var J={isArray:d,isArrayBuffer:p,isBuffer:h,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||g(e.append)&&("formdata"===(t=a(e))||"object"===t&&g(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&p(e.buffer),t},isString:m,isNumber:y,isBoolean:e=>!0===e||!1===e,isObject:w,isPlainObject:b,isEmptyObject:e=>{if(!w(e)||h(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:A,isRequest:C,isResponse:v,isHeaders:U,isUndefined:f,isDate:E,isFile:O,isBlob:R,isRegExp:B,isFunction:g,isStream:e=>w(e)&&g(e.pipe),isURLSearchParams:T,isTypedArray:_,isFileList:S,forEach:P,merge:function e(){const{caseless:t}=x(this)&&this||{},n={},r=(r,o)=>{const s=t&&k(n,o)||o;b(n[s])&&b(r)?n[s]=e(n[s],r):b(r)?n[s]=e({},r):d(r)?n[s]=r.slice():n[s]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&P(arguments[e],r);return n},extend:(e,t,r,{allOwnKeys:o}={})=>(P(t,(t,o)=>{r&&g(t)?e[o]=n(t,r):e[o]=t},{allOwnKeys:o}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let s,i,a;const c={};if(t=t||{},null==e)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)a=s[i],r&&!r(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&o(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:a,kindOfTest:u,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(d(e))return e;let t=e.length;if(!y(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[s]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:L,hasOwnProperty:F,hasOwnProp:F,reduceDescriptors:D,freezeMethods:e=>{D(e,(t,n)=>{if(g(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];g(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return d(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:k,global:j,isContextDefined:x,isSpecCompliantForm:function(e){return!!(e&&g(e.append)&&"FormData"===e[i]&&e[s])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(w(e)){if(t.indexOf(e)>=0)return;if(h(e))return e;if(!("toJSON"in e)){t[r]=e;const o=d(e)?[]:{};return P(e,(e,t)=>{const s=n(e,r+1);!f(s)&&(o[t]=s)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:K,isThenable:e=>e&&(w(e)||g(e))&&g(e.then)&&g(e.catch),setImmediate:q,asap:H,isIterable:e=>null!=e&&g(e[s])};function W(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}J.inherits(W,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:J.toJSONObject(this.config),code:this.code,status:this.status}}});const V=W.prototype,G={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{G[e]={value:e}}),Object.defineProperties(W,G),Object.defineProperty(V,"isAxiosError",{value:!0}),W.from=(e,t,n,r,o,s)=>{const i=Object.create(V);return J.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e),W.call(i,e.message,t,n,r,o),i.cause=e,i.name=e.name,s&&Object.assign(i,s),i};function X(e){return J.isPlainObject(e)||J.isArray(e)}function Q(e){return J.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,n){return e?e.concat(t).map(function(e,t){return e=Q(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const Y=J.toFlatObject(J,{},null,function(e){return/^is[A-Z]/.test(e)});function ee(e,t,n){if(!J.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=J.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!J.isUndefined(t[e])})).metaTokens,o=n.visitor||u,s=n.dots,i=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&J.isSpecCompliantForm(t);if(!J.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(J.isDate(e))return e.toISOString();if(J.isBoolean(e))return e.toString();if(!a&&J.isBlob(e))throw new W("Blob is not supported. Use a Buffer instead.");return J.isArrayBuffer(e)||J.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(J.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(J.isArray(e)&&function(e){return J.isArray(e)&&!e.some(X)}(e)||(J.isFileList(e)||J.endsWith(n,"[]"))&&(a=J.toArray(e)))return n=Q(n),a.forEach(function(e,r){!J.isUndefined(e)&&null!==e&&t.append(!0===i?Z([n],r,s):null===i?n:n+"[]",c(e))}),!1;return!!X(e)||(t.append(Z(o,n,s),c(e)),!1)}const l=[],d=Object.assign(Y,{defaultVisitor:u,convertValue:c,isVisitable:X});if(!J.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!J.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),J.forEach(n,function(n,s){!0===(!(J.isUndefined(n)||null===n)&&o.call(t,n,J.isString(s)?s.trim():s,r,d))&&e(n,r?r.concat(s):[s])}),l.pop()}}(e),t}function te(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ne(e,t){this._pairs=[],e&&ee(e,this,t)}const re=ne.prototype;function oe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function se(e,t,n){if(!t)return e;const r=n&&n.encode||oe;J.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(s=o?o(t,n):J.isURLSearchParams(t)?t.toString():new ne(t,n).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}re.append=function(e,t){this._pairs.push([e,t])},re.toString=function(e){const t=e?function(t){return e.call(this,t,te)}:te;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ie=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){J.forEach(this.handlers,function(t){null!==t&&e(t)})}},ae={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ce={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ne,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ue="undefined"!=typeof window&&"undefined"!=typeof document,le="object"==typeof navigator&&navigator||void 0,de=ue&&(!le||["ReactNative","NativeScript","NS"].indexOf(le.product)<0),fe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,he=ue&&window.location.href||"http://localhost";var pe={...Object.freeze({__proto__:null,hasBrowserEnv:ue,hasStandardBrowserEnv:de,hasStandardBrowserWebWorkerEnv:fe,navigator:le,origin:he}),...ce};function me(e){function t(e,n,r,o){let s=e[o++];if("__proto__"===s)return!0;const i=Number.isFinite(+s),a=o>=e.length;if(s=!s&&J.isArray(r)?r.length:s,a)return J.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!i;r[s]&&J.isObject(r[s])||(r[s]=[]);return t(e,n,r[s],o)&&J.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}(r[s])),!i}if(J.isFormData(e)&&J.isFunction(e.entries)){const n={};return J.forEachEntry(e,(e,r)=>{t(function(e){return J.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const ge={transitional:ae,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=J.isObject(e);o&&J.isHTMLForm(e)&&(e=new FormData(e));if(J.isFormData(e))return r?JSON.stringify(me(e)):e;if(J.isArrayBuffer(e)||J.isBuffer(e)||J.isStream(e)||J.isFile(e)||J.isBlob(e)||J.isReadableStream(e))return e;if(J.isArrayBufferView(e))return e.buffer;if(J.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ee(e,new pe.classes.URLSearchParams,{visitor:function(e,t,n,r){return pe.isNode&&J.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((s=J.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return ee(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(J.isString(e))try{return(t||JSON.parse)(e),J.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ge.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(J.isResponse(e)||J.isReadableStream(e))return e;if(e&&J.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw W.from(e,W.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:pe.classes.FormData,Blob:pe.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};J.forEach(["delete","get","head","post","put","patch"],e=>{ge.headers[e]={}});var ye=ge;const we=J.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const be=Symbol("internals");function Ee(e){return e&&String(e).trim().toLowerCase()}function Oe(e){return!1===e||null==e?e:J.isArray(e)?e.map(Oe):String(e)}function Re(e,t,n,r,o){return J.isFunction(r)?r.call(this,t,n):(o&&(t=n),J.isString(t)?J.isString(r)?-1!==t.indexOf(r):J.isRegExp(r)?r.test(t):void 0:void 0)}class Se{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Ee(t);if(!o)throw new Error("header name must be a non-empty string");const s=J.findKey(r,o);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=Oe(e))}const s=(e,t)=>J.forEach(e,(e,n)=>o(e,n,t));if(J.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(J.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&we[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(J.isObject(e)&&J.isIterable(e)){let n,r,o={};for(const t of e){if(!J.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?J.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}s(o,t)}else null!=e&&o(t,e,n);return this}get(e,t){if(e=Ee(e)){const n=J.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(J.isFunction(t))return t.call(this,e,n);if(J.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ee(e)){const n=J.findKey(this,e);return!(!n||void 0===this[n]||t&&!Re(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Ee(e)){const o=J.findKey(n,e);!o||t&&!Re(0,n[o],o,t)||(delete n[o],r=!0)}}return J.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Re(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return J.forEach(this,(r,o)=>{const s=J.findKey(n,o);if(s)return t[s]=Oe(r),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();i!==o&&delete t[o],t[i]=Oe(r),n[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return J.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&J.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[be]=this[be]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Ee(e);t[r]||(!function(e,t){const n=J.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return J.isArray(e)?e.forEach(r):r(e),this}}Se.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),J.reduceDescriptors(Se.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),J.freezeMethods(Se);var Te=Se;function Ae(e,t){const n=this||ye,r=t||n,o=Te.from(r.headers);let s=r.data;return J.forEach(e,function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ce(e){return!(!e||!e.__CANCEL__)}function ve(e,t,n){W.call(this,null==e?"canceled":e,W.ERR_CANCELED,t,n),this.name="CanceledError"}function Ue(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new W("Request failed with status code "+n.status,[W.ERR_BAD_REQUEST,W.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}J.inherits(ve,W,{__CANCEL__:!0});const Pe=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[i];o||(o=c),n[s]=a,r[s]=c;let l=i,d=0;for(;l!==s;)d+=n[l++],l%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const f=u&&c-u;return f?Math.round(1e3*d/f):void 0}}(50,250);return function(e,t){let n,r,o=0,s=1e3/t;const i=(t,s=Date.now())=>{o=s,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=s?i(e,t):(n=e,r||(r=setTimeout(()=>{r=null,i(n)},s-a)))},()=>n&&i(n)]}(n=>{const s=n.loaded,i=n.lengthComputable?n.total:void 0,a=s-r,c=o(a);r=s;e({loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0,event:n,lengthComputable:null!=i,[t?"download":"upload"]:!0})},n)},ke=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},je=e=>(...t)=>J.asap(()=>e(...t));var xe=pe.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,pe.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(pe.origin),pe.navigator&&/(msie|trident)/i.test(pe.navigator.userAgent)):()=>!0,_e=pe.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];J.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),J.isString(r)&&i.push("path="+r),J.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Ne(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Le=e=>e instanceof Te?{...e}:e;function Fe(e,t){t=t||{};const n={};function r(e,t,n,r){return J.isPlainObject(e)&&J.isPlainObject(t)?J.merge.call({caseless:r},e,t):J.isPlainObject(t)?J.merge({},t):J.isArray(t)?t.slice():t}function o(e,t,n,o){return J.isUndefined(t)?J.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function s(e,t){if(!J.isUndefined(t))return r(void 0,t)}function i(e,t){return J.isUndefined(t)?J.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,s){return s in t?r(n,o):s in e?r(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t,n)=>o(Le(e),Le(t),0,!0)};return J.forEach(Object.keys({...e,...t}),function(r){const s=c[r]||o,i=s(e[r],t[r],r);J.isUndefined(i)&&s!==a||(n[r]=i)}),n}var Be=e=>{const t=Fe({},e);let n,{data:r,withXSRFToken:o,xsrfHeaderName:s,xsrfCookieName:i,headers:a,auth:c}=t;if(t.headers=a=Te.from(a),t.url=se(Ne(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),J.isFormData(r))if(pe.hasStandardBrowserEnv||pe.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(n=a.getContentType())){const[e,...t]=n?n.split(";").map(e=>e.trim()).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(pe.hasStandardBrowserEnv&&(o&&J.isFunction(o)&&(o=o(t)),o||!1!==o&&xe(t.url))){const e=s&&i&&_e.read(i);e&&a.set(s,e)}return t};var De="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=Be(e);let o=r.data;const s=Te.from(r.headers).normalize();let i,a,c,u,l,{responseType:d,onUploadProgress:f,onDownloadProgress:h}=r;function p(){u&&u(),l&&l(),r.cancelToken&&r.cancelToken.unsubscribe(i),r.signal&&r.signal.removeEventListener("abort",i)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Te.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Ue(function(e){t(e),p()},function(e){n(e),p()},{data:d&&"text"!==d&&"json"!==d?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new W("Request aborted",W.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new W("Network Error",W.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||ae;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new W(t,o.clarifyTimeoutError?W.ETIMEDOUT:W.ECONNABORTED,e,m)),m=null},void 0===o&&s.setContentType(null),"setRequestHeader"in m&&J.forEach(s.toJSON(),function(e,t){m.setRequestHeader(t,e)}),J.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),d&&"json"!==d&&(m.responseType=r.responseType),h&&([c,l]=Pe(h,!0),m.addEventListener("progress",c)),f&&m.upload&&([a,u]=Pe(f),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(i=t=>{m&&(n(!t||t.type?new ve(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(i),r.signal&&(r.signal.aborted?i():r.signal.addEventListener("abort",i)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===pe.protocols.indexOf(y)?n(new W("Unsupported protocol "+y+":",W.ERR_BAD_REQUEST,e)):m.send(o||null)})};var Ke=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,i();const t=e instanceof Error?e:this.reason;r.abort(t instanceof W?t:new ve(t instanceof Error?t.message:t))}};let s=t&&setTimeout(()=>{s=null,o(new W(`timeout ${t} of ms exceeded`,W.ETIMEDOUT))},t);const i=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=()=>J.asap(i),a}};const qe=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},Ie=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},$e=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of Ie(e))yield*qe(n,t)}(e,t);let s,i=0,a=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let s=r.byteLength;if(n){let e=i+=s;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},Me="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,ze=Me&&"function"==typeof ReadableStream,He=Me&&("function"==typeof TextEncoder?(Je=new TextEncoder,e=>Je.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Je;const We=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ve=ze&&We(()=>{let e=!1;const t=new Request(pe.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Ge=ze&&We(()=>J.isReadableStream(new Response("").body)),Xe={stream:Ge&&(e=>e.body)};var Qe;Me&&(Qe=new Response,["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Xe[e]&&(Xe[e]=J.isFunction(Qe[e])?t=>t[e]():(t,n)=>{throw new W(`Response type '${e}' is not supported`,W.ERR_NOT_SUPPORT,n)})}));const Ze=async(e,t)=>{const n=J.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(J.isBlob(e))return e.size;if(J.isSpecCompliantForm(e)){const t=new Request(pe.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return J.isArrayBufferView(e)||J.isArrayBuffer(e)?e.byteLength:(J.isURLSearchParams(e)&&(e+=""),J.isString(e)?(await He(e)).byteLength:void 0)})(t):n};var Ye=Me&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:s,timeout:i,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:l,withCredentials:d="same-origin",fetchOptions:f}=Be(e);u=u?(u+"").toLowerCase():"text";let h,p=Ke([o,s&&s.toAbortSignal()],i);const m=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let g;try{if(c&&Ve&&"get"!==n&&"head"!==n&&0!==(g=await Ze(l,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(J.isFormData(r)&&(e=n.headers.get("content-type"))&&l.setContentType(e),n.body){const[e,t]=ke(g,Pe(je(c)));r=$e(n.body,65536,e,t)}}J.isString(d)||(d=d?"include":"omit");const o="credentials"in Request.prototype;h=new Request(t,{...f,signal:p,method:n.toUpperCase(),headers:l.normalize().toJSON(),body:r,duplex:"half",credentials:o?d:void 0});let s=await fetch(h,f);const i=Ge&&("stream"===u||"response"===u);if(Ge&&(a||i&&m)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=s[t]});const t=J.toFiniteNumber(s.headers.get("content-length")),[n,r]=a&&ke(t,Pe(je(a),!0))||[];s=new Response($e(s.body,65536,n,()=>{r&&r(),m&&m()}),e)}u=u||"text";let y=await Xe[J.findKey(Xe,u)||"text"](s,e);return!i&&m&&m(),await new Promise((t,n)=>{Ue(t,n,{data:y,headers:Te.from(s.headers),status:s.status,statusText:s.statusText,config:e,request:h})})}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new W("Network Error",W.ERR_NETWORK,e,h),{cause:t.cause||t});throw W.from(t,t&&t.code,e,h)}});const et={http:null,xhr:De,fetch:Ye};J.forEach(et,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const tt=e=>`- ${e}`,nt=e=>J.isFunction(e)||null===e||!1===e;var rt=e=>{e=J.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let s=0;s<t;s++){let t;if(n=e[s],r=n,!nt(n)&&(r=et[(t=String(n)).toLowerCase()],void 0===r))throw new W(`Unknown adapter '${t}'`);if(r)break;o[t||"#"+s]=r}if(!r){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new W("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(tt).join("\n"):" "+tt(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function ot(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ve(null,e)}function st(e){ot(e),e.headers=Te.from(e.headers),e.data=Ae.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return rt(e.adapter||ye.adapter)(e).then(function(t){return ot(e),t.data=Ae.call(e,e.transformResponse,t),t.headers=Te.from(t.headers),t},function(t){return Ce(t)||(ot(e),t&&t.response&&(t.response.data=Ae.call(e,e.transformResponse,t.response),t.response.headers=Te.from(t.response.headers))),Promise.reject(t)})}const it="1.11.0",at={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{at[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const ct={};at.transitional=function(e,t,n){function r(e,t){return"[Axios v"+it+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new W(r(o," has been removed"+(t?" in "+t:"")),W.ERR_DEPRECATED);return t&&!ct[o]&&(ct[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,s)}},at.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var ut={assertOptions:function(e,t,n){if("object"!=typeof e)throw new W("options must be an object",W.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new W("option "+s+" must be "+n,W.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new W("Unknown option "+s,W.ERR_BAD_OPTION)}},validators:at};const lt=ut.validators;class dt{constructor(e){this.defaults=e||{},this.interceptors={request:new ie,response:new ie}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Fe(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&ut.assertOptions(n,{silentJSONParsing:lt.transitional(lt.boolean),forcedJSONParsing:lt.transitional(lt.boolean),clarifyTimeoutError:lt.transitional(lt.boolean)},!1),null!=r&&(J.isFunction(r)?t.paramsSerializer={serialize:r}:ut.assertOptions(r,{encode:lt.function,serialize:lt.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),ut.assertOptions(t,{baseUrl:lt.spelling("baseURL"),withXsrfToken:lt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&J.merge(o.common,o[t.method]);o&&J.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=Te.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const c=[];let u;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,d=0;if(!a){const e=[st.bind(this),void 0];for(e.unshift(...i),e.push(...c),l=e.length,u=Promise.resolve(t);d<l;)u=u.then(e[d++],e[d++]);return u}l=i.length;let f=t;for(d=0;d<l;){const e=i[d++],t=i[d++];try{f=e(f)}catch(e){t.call(this,e);break}}try{u=st.call(this,f)}catch(e){return Promise.reject(e)}for(d=0,l=c.length;d<l;)u=u.then(c[d++],c[d++]);return u}getUri(e){return se(Ne((e=Fe(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}J.forEach(["delete","get","head","options"],function(e){dt.prototype[e]=function(t,n){return this.request(Fe(n||{},{method:e,url:t,data:(n||{}).data}))}}),J.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(Fe(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}dt.prototype[e]=t(),dt.prototype[e+"Form"]=t(!0)});var ft=dt;class ht{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new ve(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ht(function(t){e=t}),cancel:e}}}var pt=ht;const mt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(mt).forEach(([e,t])=>{mt[t]=e});var gt=mt;const yt=function e(t){const r=new ft(t),o=n(ft.prototype.request,r);return J.extend(o,ft.prototype,r,{allOwnKeys:!0}),J.extend(o,r,null,{allOwnKeys:!0}),o.create=function(n){return e(Fe(t,n))},o}(ye);yt.Axios=ft,yt.CanceledError=ve,yt.CancelToken=pt,yt.isCancel=Ce,yt.VERSION=it,yt.toFormData=ee,yt.AxiosError=W,yt.Cancel=yt.CanceledError,yt.all=function(e){return Promise.all(e)},yt.spread=function(e){return function(t){return e.apply(null,t)}},yt.isAxiosError=function(e){return J.isObject(e)&&!0===e.isAxiosError},yt.mergeConfig=Fe,yt.AxiosHeaders=Te,yt.formToJSON=e=>me(J.isHTMLForm(e)?new FormData(e):e),yt.getAdapter=rt,yt.HttpStatusCode=gt,yt.default=yt;var wt=yt;async function bt(e,{method:t="GET",data:n={},headers:r={},timeout:o=5e3}={}){return"fetch"in window&&"AbortController"in window?async function(e,t){const{method:n="GET",data:r={},headers:o={},timeout:s=5e3}=t,i=new AbortController,a=setTimeout(()=>i.abort(),s),c={method:n.toUpperCase(),headers:{"Content-Type":"application/json",...o},signal:i.signal};"GET"!==c.method&&r&&(c.body=JSON.stringify(r));try{const t=await fetch(e,c);if(clearTimeout(a),!t.ok)return{code:t.status,msg:`HTTP请求失败: ${t.statusText}`,success:!1};try{return await t.json()}catch(e){return{code:-201,msg:"响应数据不是有效的JSON格式",success:!1}}}catch(e){return clearTimeout(a),"AbortError"===e.name?{code:-202,msg:`请求超时(${s}ms)`,success:!1}:{code:-203,msg:`网络请求失败: ${e.message}`,success:!1}}}(e,{method:t,data:n,headers:r,timeout:o}):async function(e,t){const{method:n="GET",data:r={},headers:o={},timeout:s=5e3}=t,i={url:e,method:n.toUpperCase(),headers:{"Content-Type":"application/json",...o},timeout:s,["GET"===n.toUpperCase()?"params":"data"]:r};try{return(await wt(i)).data}catch(e){return"ECONNABORTED"===e.code?{code:-202,msg:`请求超时(${s}ms)`,success:!1}:e.response?{code:e.response.status,msg:`HTTP请求失败: ${e.response.statusText}`,success:!1}:{code:-203,msg:`网络请求失败: ${e.message}`,success:!1}}}(e,{method:t,data:n,headers:r,timeout:o})}const Et={accessCodeKey:"accessCode",tokenKey:"scm_token",timeout:5e3,headers:{},tokenApi:"",refreshCodeApi:"",logoutApi:"",logOutUrl:"",storage:localStorage,oldPwdKey:"oldPwd",newPwdKey:"newPwd",changePasswordApi:"",sendCaptchaCodeApi:"",typeKey:"type",codeKey:"code"};let Ot=null;function Rt(){return{async init(e={}){try{Ot=function(e,t){if(!t)return{...e};const n={...e};for(const e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}(Et,e),function(e){if("string"!=typeof e.accessCodeKey||""===e.accessCodeKey.trim())throw new Error("accessCodeKey必须是有效的字符串");if("string"!=typeof e.tokenKey||""===e.tokenKey.trim())throw new Error("tokenKey必须是有效的字符串");if(e.storage&&("function"!=typeof e.storage.setItem||"function"!=typeof e.storage.getItem))throw new Error("storage必须实现setItem和getItem方法")}(Ot);const n=function(e,t){const n=t||window.location.href,r=new URL(n);let o=r.searchParams.get(e);if(null!==o)return o;if(r.hash.includes("?")){const t=r.hash.split("?")[1];return new URLSearchParams(t).get(e)}return null}(Ot.accessCodeKey);if(!Ot.tokenApi)return{code:-100,msg:"缺少tokenApi配置",success:!1};if(n){const e=await bt(Ot.tokenApi,{method:"POST",data:{accessCode:n},headers:Ot.headers,timeout:Ot.timeout});return 0===e.code&&e.data&&(Ot.storage.setItem(Ot.tokenKey,e.data),function(e){const t=new URL(window.location.href);let n,r;if(t.hash.includes("?")){const[o,s]=t.hash.split("?");if(n=new URLSearchParams(s),n.has(e)){n.delete(e);const s=n.toString()?`${o}?${n.toString()}`:o;t.hash=s,r=t.toString()}}else n=new URLSearchParams(t.search),n.has(e)&&(n.delete(e),t.search=n.toString(),r=t.toString());r&&r!==window.location.href&&window.location.replace(r)}(Ot.accessCodeKey)),e}return this.getToken()||Ot.logOutUrl&&(window.location.href=`${Ot.logOutUrl}?redirect_uri=${encodeURIComponent(t())}`),{code:0,msg:"初始化成功",success:!0}}catch(e){return{code:-100,msg:`初始化失败: ${e.message}`,success:!1}}},getToken:()=>Ot?Ot.storage.getItem(Ot.tokenKey):null,removeToken(){Ot&&Ot.storage.removeItem(Ot.tokenKey)},async logout(){if(!Ot)return{code:-101,msg:"请先调用init方法初始化",success:!1};if(!Ot.logoutApi)return{code:-102,msg:"未配置logoutApi",success:!1};const e=this.getToken();if(!e){if(this.removeToken(),Ot.logOutUrl){const e=`${Ot.logOutUrl}?redirect_uri=${encodeURIComponent(t())}`;this.openUrlCompat(e,"_self")}return{code:0,msg:"已成功清除token",success:!0}}try{const n=await bt(Ot.logoutApi,{method:"POST",headers:{...Ot.headers,[Ot.tokenKey]:e},timeout:Ot.timeout});if(this.removeToken(),Ot.logOutUrl){const e=`${Ot.logOutUrl}?redirect_uri=${encodeURIComponent(t())}`;this.openUrlCompat(e,"_self")}return n}catch(e){return{code:-103,msg:`退出失败: ${e.message}`,success:!1}}},async toUrl(e,t="_self"){if(!Ot)return{code:-101,msg:"请先调用init方法初始化",success:!1};if(!e)return{code:-104,msg:"请提供跳转地址",success:!1};if(!["_self","_blank"].includes(t))return{code:-108,msg:'target参数必须是"_self"或"_blank"',success:!1};if(!Ot.refreshCodeApi)return{code:-105,msg:"未配置refreshCodeApi",success:!1};const n=this.getToken();if(!n){if(Ot.logOutUrl){const n=`${Ot.logOutUrl}?redirect_uri=${encodeURIComponent(e)}`;this.openUrlCompat(n,t)}return{code:-106,msg:"未找到有效token",success:!1}}try{const r=await bt(Ot.refreshCodeApi,{method:"POST",headers:{...Ot.headers,[Ot.tokenKey]:n},timeout:Ot.timeout});if(0===r.code&&r.data){const n=new URL(e);n.searchParams.set(Ot.accessCodeKey,r.data);const o=n.toString();this.openUrlCompat(o,t)}else{const n=`${Ot.logOutUrl}?redirect_uri=${encodeURIComponent(e)}`;this.openUrlCompat(n,t)}return r}catch(n){const r=`${Ot.logOutUrl}?redirect_uri=${encodeURIComponent(e)}`;return this.openUrlCompat(r,t),{code:-107,msg:`跳转失败: ${n.message}`,success:!1}}},openUrlCompat(e,t="_self"){if("_self"!==t)try{const t=document.createElement("a");t.href=e,t.target="_blank",t.rel="noopener noreferrer",document.body.appendChild(t);const n=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});t.dispatchEvent(n),document.body.removeChild(t)}catch(t){window.open(e,"_blank")}else window.location.href=e},async getAccessCode(){if(!Ot)return{code:-101,msg:"请先调用init方法初始化",success:!1};const e=this.getToken();return e?Ot.refreshCodeApi?bt(Ot.refreshCodeApi,{method:"POST",headers:{...Ot.headers,[Ot.tokenKey]:e},timeout:Ot.timeout}):{code:-105,msg:"未配置refreshCodeApi",success:!1}:{code:-106,msg:"未找到有效token",success:!1}},getConfig:()=>({...Ot}),async changePassword(e={}){if(!e[Ot.oldPwdKey]&&"CAPTCHA"!==e[Ot.typeKey])return{code:-1,msg:"请输入旧密码",success:!1};if(!e[Ot.newPwdKey])return{code:-1,msg:"请输入新密码",success:!1};if("CAPTCHA"===e[Ot.typeKey]&&!e[Ot.codeKey])return{code:-1,msg:"请输入验证码",success:!1};const t=this.getToken();return bt(Ot.changePasswordApi,{method:"POST",headers:{...Ot.headers,[Ot.tokenKey]:t},timeout:Ot.timeout,data:{[Ot.oldPwdKey]:e[Ot.oldPwdKey],[Ot.newPwdKey]:e[Ot.newPwdKey],...e}})},async getPhoneCode(){const e=this.getToken();return bt(Ot.sendCaptchaCodeApi,{method:"GET",headers:{...Ot.headers,[Ot.tokenKey]:e},timeout:Ot.timeout})}}}const St=Rt();e.createSSO=Rt,e.default=St,e.lgsso=St,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lgsso={})}(this,function(e){"use strict";function t(){return"undefined"!=typeof window&&"undefined"!=typeof document}function n(){return t()?window.location.href:""}function r(e,t){return function(){return e.apply(t,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:s}=Object,{iterator:i,toStringTag:a}=Symbol,c=(u=Object.create(null),e=>{const t=o.call(e);return u[t]||(u[t]=t.slice(8,-1).toLowerCase())});var u;const l=e=>(e=e.toLowerCase(),t=>c(t)===e),d=e=>t=>typeof t===e,{isArray:f}=Array,h=d("undefined");function p(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&y(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const m=l("ArrayBuffer");const g=d("string"),y=d("function"),w=d("number"),b=e=>null!==e&&"object"==typeof e,E=e=>{if("object"!==c(e))return!1;const t=s(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||a in e||i in e)},O=l("Date"),R=l("File"),S=l("Blob"),T=l("FileList"),A=l("URLSearchParams"),[C,v,P,k]=["ReadableStream","Request","Response","Headers"].map(l);function U(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),f(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(p(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(r=0;r<s;r++)i=o[r],t.call(null,e[i],i,e)}}function _(e,t){if(p(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=e=>!h(e)&&e!==j;const N=(L="undefined"!=typeof Uint8Array&&s(Uint8Array),e=>L&&e instanceof L);var L;const F=l("HTMLFormElement"),B=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),D=l("RegExp"),K=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};U(n,(n,o)=>{let s;!1!==(s=t(n,o,e))&&(r[o]=s||n)}),Object.defineProperties(e,r)};const q=l("AsyncFunction"),I=($="function"==typeof setImmediate,M=y(j.postMessage),$?setImmediate:M?(z=`axios@${Math.random()}`,H=[],j.addEventListener("message",({source:e,data:t})=>{e===j&&t===z&&H.length&&H.shift()()},!1),e=>{H.push(e),j.postMessage(z,"*")}):e=>setTimeout(e));var $,M,z,H;const J="undefined"!=typeof queueMicrotask?queueMicrotask.bind(j):"undefined"!=typeof process&&process.nextTick||I;var W={isArray:f,isArrayBuffer:m,isBuffer:p,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||y(e.append)&&("formdata"===(t=c(e))||"object"===t&&y(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&m(e.buffer),t},isString:g,isNumber:w,isBoolean:e=>!0===e||!1===e,isObject:b,isPlainObject:E,isEmptyObject:e=>{if(!b(e)||p(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:C,isRequest:v,isResponse:P,isHeaders:k,isUndefined:h,isDate:O,isFile:R,isBlob:S,isRegExp:D,isFunction:y,isStream:e=>b(e)&&y(e.pipe),isURLSearchParams:A,isTypedArray:N,isFileList:T,forEach:U,merge:function e(){const{caseless:t}=x(this)&&this||{},n={},r=(r,o)=>{const s=t&&_(n,o)||o;E(n[s])&&E(r)?n[s]=e(n[s],r):E(r)?n[s]=e({},r):f(r)?n[s]=r.slice():n[s]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&U(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:o}={})=>(U(t,(t,o)=>{n&&y(t)?e[o]=r(t,n):e[o]=t},{allOwnKeys:o}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,i,a;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)a=o[i],r&&!r(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&s(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:c,kindOfTest:l,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(f(e))return e;let t=e.length;if(!w(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[i]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:F,hasOwnProperty:B,hasOwnProp:B,reduceDescriptors:K,freezeMethods:e=>{K(e,(t,n)=>{if(y(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];y(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return f(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:_,global:j,isContextDefined:x,isSpecCompliantForm:function(e){return!!(e&&y(e.append)&&"FormData"===e[a]&&e[i])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(b(e)){if(t.indexOf(e)>=0)return;if(p(e))return e;if(!("toJSON"in e)){t[r]=e;const o=f(e)?[]:{};return U(e,(e,t)=>{const s=n(e,r+1);!h(s)&&(o[t]=s)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:q,isThenable:e=>e&&(b(e)||y(e))&&y(e.then)&&y(e.catch),setImmediate:I,asap:J,isIterable:e=>null!=e&&y(e[i])};function V(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}W.inherits(V,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:W.toJSONObject(this.config),code:this.code,status:this.status}}});const G=V.prototype,X={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{X[e]={value:e}}),Object.defineProperties(V,X),Object.defineProperty(G,"isAxiosError",{value:!0}),V.from=(e,t,n,r,o,s)=>{const i=Object.create(G);return W.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e),V.call(i,e.message,t,n,r,o),i.cause=e,i.name=e.name,s&&Object.assign(i,s),i};function Q(e){return W.isPlainObject(e)||W.isArray(e)}function Z(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function Y(e,t,n){return e?e.concat(t).map(function(e,t){return e=Z(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const ee=W.toFlatObject(W,{},null,function(e){return/^is[A-Z]/.test(e)});function te(e,t,n){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!W.isUndefined(t[e])})).metaTokens,o=n.visitor||u,s=n.dots,i=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(W.isDate(e))return e.toISOString();if(W.isBoolean(e))return e.toString();if(!a&&W.isBlob(e))throw new V("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(e)||W.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(W.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(W.isArray(e)&&function(e){return W.isArray(e)&&!e.some(Q)}(e)||(W.isFileList(e)||W.endsWith(n,"[]"))&&(a=W.toArray(e)))return n=Z(n),a.forEach(function(e,r){!W.isUndefined(e)&&null!==e&&t.append(!0===i?Y([n],r,s):null===i?n:n+"[]",c(e))}),!1;return!!Q(e)||(t.append(Y(o,n,s),c(e)),!1)}const l=[],d=Object.assign(ee,{defaultVisitor:u,convertValue:c,isVisitable:Q});if(!W.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!W.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),W.forEach(n,function(n,s){!0===(!(W.isUndefined(n)||null===n)&&o.call(t,n,W.isString(s)?s.trim():s,r,d))&&e(n,r?r.concat(s):[s])}),l.pop()}}(e),t}function ne(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function re(e,t){this._pairs=[],e&&te(e,this,t)}const oe=re.prototype;function se(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ie(e,t,n){if(!t)return e;const r=n&&n.encode||se;W.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(s=o?o(t,n):W.isURLSearchParams(t)?t.toString():new re(t,n).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}oe.append=function(e,t){this._pairs.push([e,t])},oe.toString=function(e){const t=e?function(t){return e.call(this,t,ne)}:ne;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ae=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){W.forEach(this.handlers,function(t){null!==t&&e(t)})}},ce={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ue={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:re,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const le="undefined"!=typeof window&&"undefined"!=typeof document,de="object"==typeof navigator&&navigator||void 0,fe=le&&(!de||["ReactNative","NativeScript","NS"].indexOf(de.product)<0),he="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,pe=le&&window.location.href||"http://localhost";var me={...Object.freeze({__proto__:null,hasBrowserEnv:le,hasStandardBrowserEnv:fe,hasStandardBrowserWebWorkerEnv:he,navigator:de,origin:pe}),...ue};function ge(e){function t(e,n,r,o){let s=e[o++];if("__proto__"===s)return!0;const i=Number.isFinite(+s),a=o>=e.length;if(s=!s&&W.isArray(r)?r.length:s,a)return W.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!i;r[s]&&W.isObject(r[s])||(r[s]=[]);return t(e,n,r[s],o)&&W.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}(r[s])),!i}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,(e,r)=>{t(function(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const ye={transitional:ce,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=W.isObject(e);o&&W.isHTMLForm(e)&&(e=new FormData(e));if(W.isFormData(e))return r?JSON.stringify(ge(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new me.classes.URLSearchParams,{visitor:function(e,t,n,r){return me.isNode&&W.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((s=W.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(W.isString(e))try{return(t||JSON.parse)(e),W.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ye.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw V.from(e,V.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:me.classes.FormData,Blob:me.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],e=>{ye.headers[e]={}});var we=ye;const be=W.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const Ee=Symbol("internals");function Oe(e){return e&&String(e).trim().toLowerCase()}function Re(e){return!1===e||null==e?e:W.isArray(e)?e.map(Re):String(e)}function Se(e,t,n,r,o){return W.isFunction(r)?r.call(this,t,n):(o&&(t=n),W.isString(t)?W.isString(r)?-1!==t.indexOf(r):W.isRegExp(r)?r.test(t):void 0:void 0)}class Te{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Oe(t);if(!o)throw new Error("header name must be a non-empty string");const s=W.findKey(r,o);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=Re(e))}const s=(e,t)=>W.forEach(e,(e,n)=>o(e,n,t));if(W.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(W.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&be[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(W.isObject(e)&&W.isIterable(e)){let n,r,o={};for(const t of e){if(!W.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?W.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}s(o,t)}else null!=e&&o(t,e,n);return this}get(e,t){if(e=Oe(e)){const n=W.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(W.isFunction(t))return t.call(this,e,n);if(W.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Oe(e)){const n=W.findKey(this,e);return!(!n||void 0===this[n]||t&&!Se(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Oe(e)){const o=W.findKey(n,e);!o||t&&!Se(0,n[o],o,t)||(delete n[o],r=!0)}}return W.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Se(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return W.forEach(this,(r,o)=>{const s=W.findKey(n,o);if(s)return t[s]=Re(r),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();i!==o&&delete t[o],t[i]=Re(r),n[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return W.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&W.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[Ee]=this[Ee]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Oe(e);t[r]||(!function(e,t){const n=W.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return W.isArray(e)?e.forEach(r):r(e),this}}Te.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Te.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),W.freezeMethods(Te);var Ae=Te;function Ce(e,t){const n=this||we,r=t||n,o=Ae.from(r.headers);let s=r.data;return W.forEach(e,function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function ve(e){return!(!e||!e.__CANCEL__)}function Pe(e,t,n){V.call(this,null==e?"canceled":e,V.ERR_CANCELED,t,n),this.name="CanceledError"}function ke(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new V("Request failed with status code "+n.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}W.inherits(Pe,V,{__CANCEL__:!0});const Ue=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[i];o||(o=c),n[s]=a,r[s]=c;let l=i,d=0;for(;l!==s;)d+=n[l++],l%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const f=u&&c-u;return f?Math.round(1e3*d/f):void 0}}(50,250);return function(e,t){let n,r,o=0,s=1e3/t;const i=(t,s=Date.now())=>{o=s,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=s?i(e,t):(n=e,r||(r=setTimeout(()=>{r=null,i(n)},s-a)))},()=>n&&i(n)]}(n=>{const s=n.loaded,i=n.lengthComputable?n.total:void 0,a=s-r,c=o(a);r=s;e({loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0,event:n,lengthComputable:null!=i,[t?"download":"upload"]:!0})},n)},_e=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},je=e=>(...t)=>W.asap(()=>e(...t));var xe=me.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,me.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(me.origin),me.navigator&&/(msie|trident)/i.test(me.navigator.userAgent)):()=>!0,Ne=me.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];W.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),W.isString(r)&&i.push("path="+r),W.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Le(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Fe=e=>e instanceof Ae?{...e}:e;function Be(e,t){t=t||{};const n={};function r(e,t,n,r){return W.isPlainObject(e)&&W.isPlainObject(t)?W.merge.call({caseless:r},e,t):W.isPlainObject(t)?W.merge({},t):W.isArray(t)?t.slice():t}function o(e,t,n,o){return W.isUndefined(t)?W.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function s(e,t){if(!W.isUndefined(t))return r(void 0,t)}function i(e,t){return W.isUndefined(t)?W.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,s){return s in t?r(n,o):s in e?r(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t,n)=>o(Fe(e),Fe(t),0,!0)};return W.forEach(Object.keys({...e,...t}),function(r){const s=c[r]||o,i=s(e[r],t[r],r);W.isUndefined(i)&&s!==a||(n[r]=i)}),n}var De=e=>{const t=Be({},e);let n,{data:r,withXSRFToken:o,xsrfHeaderName:s,xsrfCookieName:i,headers:a,auth:c}=t;if(t.headers=a=Ae.from(a),t.url=ie(Le(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),W.isFormData(r))if(me.hasStandardBrowserEnv||me.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(n=a.getContentType())){const[e,...t]=n?n.split(";").map(e=>e.trim()).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(me.hasStandardBrowserEnv&&(o&&W.isFunction(o)&&(o=o(t)),o||!1!==o&&xe(t.url))){const e=s&&i&&Ne.read(i);e&&a.set(s,e)}return t};var Ke="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=De(e);let o=r.data;const s=Ae.from(r.headers).normalize();let i,a,c,u,l,{responseType:d,onUploadProgress:f,onDownloadProgress:h}=r;function p(){u&&u(),l&&l(),r.cancelToken&&r.cancelToken.unsubscribe(i),r.signal&&r.signal.removeEventListener("abort",i)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Ae.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());ke(function(e){t(e),p()},function(e){n(e),p()},{data:d&&"text"!==d&&"json"!==d?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new V("Request aborted",V.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new V("Network Error",V.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||ce;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new V(t,o.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,e,m)),m=null},void 0===o&&s.setContentType(null),"setRequestHeader"in m&&W.forEach(s.toJSON(),function(e,t){m.setRequestHeader(t,e)}),W.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),d&&"json"!==d&&(m.responseType=r.responseType),h&&([c,l]=Ue(h,!0),m.addEventListener("progress",c)),f&&m.upload&&([a,u]=Ue(f),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(i=t=>{m&&(n(!t||t.type?new Pe(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(i),r.signal&&(r.signal.aborted?i():r.signal.addEventListener("abort",i)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===me.protocols.indexOf(y)?n(new V("Unsupported protocol "+y+":",V.ERR_BAD_REQUEST,e)):m.send(o||null)})};var qe=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,i();const t=e instanceof Error?e:this.reason;r.abort(t instanceof V?t:new Pe(t instanceof Error?t.message:t))}};let s=t&&setTimeout(()=>{s=null,o(new V(`timeout ${t} of ms exceeded`,V.ETIMEDOUT))},t);const i=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=()=>W.asap(i),a}};const Ie=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},$e=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Me=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of $e(e))yield*Ie(n,t)}(e,t);let s,i=0,a=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let s=r.byteLength;if(n){let e=i+=s;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},ze="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,He=ze&&"function"==typeof ReadableStream,Je=ze&&("function"==typeof TextEncoder?(We=new TextEncoder,e=>We.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var We;const Ve=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ge=He&&Ve(()=>{let e=!1;const t=new Request(me.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Xe=He&&Ve(()=>W.isReadableStream(new Response("").body)),Qe={stream:Xe&&(e=>e.body)};var Ze;ze&&(Ze=new Response,["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Qe[e]&&(Qe[e]=W.isFunction(Ze[e])?t=>t[e]():(t,n)=>{throw new V(`Response type '${e}' is not supported`,V.ERR_NOT_SUPPORT,n)})}));const Ye=async(e,t)=>{const n=W.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(W.isBlob(e))return e.size;if(W.isSpecCompliantForm(e)){const t=new Request(me.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return W.isArrayBufferView(e)||W.isArrayBuffer(e)?e.byteLength:(W.isURLSearchParams(e)&&(e+=""),W.isString(e)?(await Je(e)).byteLength:void 0)})(t):n};var et=ze&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:s,timeout:i,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:l,withCredentials:d="same-origin",fetchOptions:f}=De(e);u=u?(u+"").toLowerCase():"text";let h,p=qe([o,s&&s.toAbortSignal()],i);const m=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let g;try{if(c&&Ge&&"get"!==n&&"head"!==n&&0!==(g=await Ye(l,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(W.isFormData(r)&&(e=n.headers.get("content-type"))&&l.setContentType(e),n.body){const[e,t]=_e(g,Ue(je(c)));r=Me(n.body,65536,e,t)}}W.isString(d)||(d=d?"include":"omit");const o="credentials"in Request.prototype;h=new Request(t,{...f,signal:p,method:n.toUpperCase(),headers:l.normalize().toJSON(),body:r,duplex:"half",credentials:o?d:void 0});let s=await fetch(h,f);const i=Xe&&("stream"===u||"response"===u);if(Xe&&(a||i&&m)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=s[t]});const t=W.toFiniteNumber(s.headers.get("content-length")),[n,r]=a&&_e(t,Ue(je(a),!0))||[];s=new Response(Me(s.body,65536,n,()=>{r&&r(),m&&m()}),e)}u=u||"text";let y=await Qe[W.findKey(Qe,u)||"text"](s,e);return!i&&m&&m(),await new Promise((t,n)=>{ke(t,n,{data:y,headers:Ae.from(s.headers),status:s.status,statusText:s.statusText,config:e,request:h})})}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new V("Network Error",V.ERR_NETWORK,e,h),{cause:t.cause||t});throw V.from(t,t&&t.code,e,h)}});const tt={http:null,xhr:Ke,fetch:et};W.forEach(tt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const nt=e=>`- ${e}`,rt=e=>W.isFunction(e)||null===e||!1===e;var ot=e=>{e=W.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let s=0;s<t;s++){let t;if(n=e[s],r=n,!rt(n)&&(r=tt[(t=String(n)).toLowerCase()],void 0===r))throw new V(`Unknown adapter '${t}'`);if(r)break;o[t||"#"+s]=r}if(!r){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new V("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(nt).join("\n"):" "+nt(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function st(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Pe(null,e)}function it(e){st(e),e.headers=Ae.from(e.headers),e.data=Ce.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ot(e.adapter||we.adapter)(e).then(function(t){return st(e),t.data=Ce.call(e,e.transformResponse,t),t.headers=Ae.from(t.headers),t},function(t){return ve(t)||(st(e),t&&t.response&&(t.response.data=Ce.call(e,e.transformResponse,t.response),t.response.headers=Ae.from(t.response.headers))),Promise.reject(t)})}const at="1.11.0",ct={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ct[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const ut={};ct.transitional=function(e,t,n){function r(e,t){return"[Axios v"+at+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new V(r(o," has been removed"+(t?" in "+t:"")),V.ERR_DEPRECATED);return t&&!ut[o]&&(ut[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,s)}},ct.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var lt={assertOptions:function(e,t,n){if("object"!=typeof e)throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new V("option "+s+" must be "+n,V.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new V("Unknown option "+s,V.ERR_BAD_OPTION)}},validators:ct};const dt=lt.validators;class ft{constructor(e){this.defaults=e||{},this.interceptors={request:new ae,response:new ae}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Be(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&<.assertOptions(n,{silentJSONParsing:dt.transitional(dt.boolean),forcedJSONParsing:dt.transitional(dt.boolean),clarifyTimeoutError:dt.transitional(dt.boolean)},!1),null!=r&&(W.isFunction(r)?t.paramsSerializer={serialize:r}:lt.assertOptions(r,{encode:dt.function,serialize:dt.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),lt.assertOptions(t,{baseUrl:dt.spelling("baseURL"),withXsrfToken:dt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&W.merge(o.common,o[t.method]);o&&W.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=Ae.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const c=[];let u;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,d=0;if(!a){const e=[it.bind(this),void 0];for(e.unshift(...i),e.push(...c),l=e.length,u=Promise.resolve(t);d<l;)u=u.then(e[d++],e[d++]);return u}l=i.length;let f=t;for(d=0;d<l;){const e=i[d++],t=i[d++];try{f=e(f)}catch(e){t.call(this,e);break}}try{u=it.call(this,f)}catch(e){return Promise.reject(e)}for(d=0,l=c.length;d<l;)u=u.then(c[d++],c[d++]);return u}getUri(e){return ie(Le((e=Be(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}W.forEach(["delete","get","head","options"],function(e){ft.prototype[e]=function(t,n){return this.request(Be(n||{},{method:e,url:t,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(Be(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}ft.prototype[e]=t(),ft.prototype[e+"Form"]=t(!0)});var ht=ft;class pt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new Pe(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new pt(function(t){e=t}),cancel:e}}}var mt=pt;const gt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(gt).forEach(([e,t])=>{gt[t]=e});var yt=gt;const wt=function e(t){const n=new ht(t),o=r(ht.prototype.request,n);return W.extend(o,ht.prototype,n,{allOwnKeys:!0}),W.extend(o,n,null,{allOwnKeys:!0}),o.create=function(n){return e(Be(t,n))},o}(we);wt.Axios=ht,wt.CanceledError=Pe,wt.CancelToken=mt,wt.isCancel=ve,wt.VERSION=at,wt.toFormData=te,wt.AxiosError=V,wt.Cancel=wt.CanceledError,wt.all=function(e){return Promise.all(e)},wt.spread=function(e){return function(t){return e.apply(null,t)}},wt.isAxiosError=function(e){return W.isObject(e)&&!0===e.isAxiosError},wt.mergeConfig=Be,wt.AxiosHeaders=Ae,wt.formToJSON=e=>ge(W.isHTMLForm(e)?new FormData(e):e),wt.getAdapter=ot,wt.HttpStatusCode=yt,wt.default=wt;var bt=wt;async function Et(e,{method:n="GET",data:r={},headers:o={},timeout:s=5e3}={}){return t()?"fetch"in window&&"AbortController"in window?async function(e,t){const{method:n="GET",data:r={},headers:o={},timeout:s=5e3}=t,i=new AbortController,a=setTimeout(()=>i.abort(),s),c={method:n.toUpperCase(),headers:{"Content-Type":"application/json",...o},signal:i.signal};"GET"!==c.method&&r&&(c.body=JSON.stringify(r));try{const t=await fetch(e,c);if(clearTimeout(a),!t.ok)return{code:t.status,msg:`HTTP请求失败: ${t.statusText}`,success:!1};try{return await t.json()}catch(e){return{code:-201,msg:"响应数据不是有效的JSON格式",success:!1}}}catch(e){return clearTimeout(a),"AbortError"===e.name?{code:-202,msg:`请求超时(${s}ms)`,success:!1}:{code:-203,msg:`网络请求失败: ${e.message}`,success:!1}}}(e,{method:n,data:r,headers:o,timeout:s}):async function(e,t){const{method:n="GET",data:r={},headers:o={},timeout:s=5e3}=t,i={url:e,method:n.toUpperCase(),headers:{"Content-Type":"application/json",...o},timeout:s,["GET"===n.toUpperCase()?"params":"data"]:r};try{return(await bt(i)).data}catch(e){return"ECONNABORTED"===e.code?{code:-202,msg:`请求超时(${s}ms)`,success:!1}:e.response?{code:e.response.status,msg:`HTTP请求失败: ${e.response.statusText}`,success:!1}:{code:-203,msg:`网络请求失败: ${e.message}`,success:!1}}}(e,{method:n,data:r,headers:o,timeout:s}):{code:-200,msg:"request方法只能在浏览器环境使用",success:!1}}const Ot={accessCodeKey:"accessCode",tokenKey:"scm_token",timeout:5e3,headers:{},tokenApi:"",refreshCodeApi:"",logoutApi:"",logOutUrl:"",storage:localStorage,oldPwdKey:"oldPwd",newPwdKey:"newPwd",changePasswordApi:"",sendCaptchaCodeApi:"",typeKey:"type",codeKey:"code"};let Rt=null;function St(){return{async init(e={}){try{Rt=function(e,t){if(!t)return{...e};const n={...e};for(const e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}(Ot,e),function(e){if("string"!=typeof e.accessCodeKey||""===e.accessCodeKey.trim())throw new Error("accessCodeKey必须是有效的字符串");if("string"!=typeof e.tokenKey||""===e.tokenKey.trim())throw new Error("tokenKey必须是有效的字符串");if(e.storage&&("function"!=typeof e.storage.setItem||"function"!=typeof e.storage.getItem))throw new Error("storage必须实现setItem和getItem方法")}(Rt);const r=function(e,n){if(!t())return null;const r=n||window.location.href,o=new URL(r);let s=o.searchParams.get(e);if(null!==s)return s;if(o.hash.includes("?")){const t=o.hash.split("?")[1];return new URLSearchParams(t).get(e)}return null}(Rt.accessCodeKey);if(!Rt.tokenApi)return{code:-100,msg:"缺少tokenApi配置",success:!1};if(r){const e=await Et(Rt.tokenApi,{method:"POST",data:{accessCode:r},headers:Rt.headers,timeout:Rt.timeout});return 0===e.code&&e.data&&(Rt.storage.setItem(Rt.tokenKey,e.data),function(e){if(!t())return;const n=new URL(window.location.href);let r,o;if(n.hash.includes("?")){const[t,s]=n.hash.split("?");if(r=new URLSearchParams(s),r.has(e)){r.delete(e);const s=r.toString()?`${t}?${r.toString()}`:t;n.hash=s,o=n.toString()}}else r=new URLSearchParams(n.search),r.has(e)&&(r.delete(e),n.search=r.toString(),o=n.toString());o&&o!==window.location.href&&window.location.replace(o)}(Rt.accessCodeKey)),e}return this.getToken()||t()&&Rt.logOutUrl&&(window.location.href=`${Rt.logOutUrl}?redirect_uri=${encodeURIComponent(n())}`),{code:0,msg:"初始化成功",success:!0}}catch(e){return{code:-100,msg:`初始化失败: ${e.message}`,success:!1}}},getToken:()=>Rt&&t()?Rt.storage.getItem(Rt.tokenKey):null,removeToken(){Rt&&t()&&Rt.storage.removeItem(Rt.tokenKey)},async logout(){if(!Rt)return{code:-101,msg:"请先调用init方法初始化",success:!1};if(!Rt.logoutApi)return{code:-102,msg:"未配置logoutApi",success:!1};const e=this.getToken();if(!e)return this.removeToken(),t()&&Rt.logOutUrl&&(window.location.href=`${Rt.logOutUrl}?redirect_uri=${encodeURIComponent(n())}`),{code:0,msg:"已成功清除token",success:!0};try{const r=await Et(Rt.logoutApi,{method:"POST",headers:{...Rt.headers,[Rt.tokenKey]:e},timeout:Rt.timeout});return this.removeToken(),t()&&Rt.logOutUrl&&(window.location.href=`${Rt.logOutUrl}?redirect_uri=${encodeURIComponent(n())}`),r}catch(e){return{code:-103,msg:`退出失败: ${e.message}`,success:!1}}},async toUrl(e,n="_self"){if(!Rt)return{code:-101,msg:"请先调用init方法初始化",success:!1};if(!e)return{code:-104,msg:"请提供跳转地址",success:!1};if(function(){const e=navigator.userAgent.toLowerCase();return alert(e),/iphone|ipad|ipod/.test(e)&&!window.MSStream}()&&(n="_self"),!["_self","_blank"].includes(n))return{code:-108,msg:'target参数必须是"_self"或"_blank"',success:!1};if(!Rt.refreshCodeApi)return{code:-105,msg:"未配置refreshCodeApi",success:!1};const r=this.getToken();if(!r){if(t()&&Rt.logOutUrl){const t=`${Rt.logOutUrl}?redirect_uri=${encodeURIComponent(e)}`;"_blank"===n?window.open(t,"_blank"):window.location.href=t}return{code:-106,msg:"未找到有效token",success:!1}}try{const o=await Et(Rt.refreshCodeApi,{method:"POST",headers:{...Rt.headers,[Rt.tokenKey]:r},timeout:Rt.timeout});if(0===o.code&&o.data&&t()){const t=new URL(e);t.searchParams.set(Rt.accessCodeKey,o.data);const r=t.toString();"_blank"===n?window.open(r,"_blank"):window.location.href=r}else{const t=`${Rt.logOutUrl}?redirect_uri=${encodeURIComponent(e)}`;"_blank"===n?window.open(t,"_blank"):window.location.href=t}return o}catch(t){const r=`${Rt.logOutUrl}?redirect_uri=${encodeURIComponent(e)}`;return"_blank"===n?window.open(r,"_blank"):window.location.href=r,{code:-107,msg:`跳转失败: ${t.message}`,success:!1}}},async getAccessCode(){if(!Rt)return{code:-101,msg:"请先调用init方法初始化",success:!1};const e=this.getToken();return e?Rt.refreshCodeApi?Et(Rt.refreshCodeApi,{method:"POST",headers:{...Rt.headers,[Rt.tokenKey]:e},timeout:Rt.timeout}):{code:-105,msg:"未配置refreshCodeApi",success:!1}:{code:-106,msg:"未找到有效token",success:!1}},getConfig:()=>({...Rt}),async changePassword(e={}){if(!e[Rt.oldPwdKey]&&"CAPTCHA"!==e[Rt.typeKey])return{code:-1,msg:"请输入旧密码",success:!1};if(!e[Rt.newPwdKey])return{code:-1,msg:"请输入新密码",success:!1};if("CAPTCHA"===e[Rt.typeKey]&&!e[Rt.codeKey])return{code:-1,msg:"请输入验证码",success:!1};const t=this.getToken();return Et(Rt.changePasswordApi,{method:"POST",headers:{...Rt.headers,[Rt.tokenKey]:t},timeout:Rt.timeout,data:{[Rt.oldPwdKey]:e[Rt.oldPwdKey],[Rt.newPwdKey]:e[Rt.newPwdKey],...e}})},async getPhoneCode(){const e=this.getToken();return Et(Rt.sendCaptchaCodeApi,{method:"GET",headers:{...Rt.headers,[Rt.tokenKey]:e},timeout:Rt.timeout})}}}const Tt=St();e.createSSO=St,e.default=Tt,e.lgsso=Tt,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=lgsso-sdk.min.js.map
|
package/package.json
CHANGED
package/src/sso.js
CHANGED
|
@@ -39,6 +39,18 @@ function validateConfig(options) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* 判断是否是iOS移动端
|
|
44
|
+
* @returns {boolean} 是否为iOS环境
|
|
45
|
+
*/
|
|
46
|
+
function isIOS() {
|
|
47
|
+
// if (!isBrowser()) return false; // 非浏览器环境直接返回false
|
|
48
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
49
|
+
alert(userAgent);
|
|
50
|
+
// 匹配iPhone/iPad/iPod,排除Windows Phone等兼容情况
|
|
51
|
+
return /iphone|ipad|ipod/.test(userAgent) && !window.MSStream;
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
/**
|
|
43
55
|
* 创建SSO实例
|
|
44
56
|
* @returns {Object} SSO实例
|
|
@@ -111,7 +123,6 @@ export function createSSO() {
|
|
|
111
123
|
config.storage.removeItem(config.tokenKey);
|
|
112
124
|
},
|
|
113
125
|
|
|
114
|
-
|
|
115
126
|
/**
|
|
116
127
|
* 退出登录
|
|
117
128
|
* @returns {Promise<Object>} 接口返回结果
|
|
@@ -139,9 +150,7 @@ export function createSSO() {
|
|
|
139
150
|
this.removeToken();
|
|
140
151
|
|
|
141
152
|
if (isBrowser() && config.logOutUrl) {
|
|
142
|
-
|
|
143
|
-
// 使用兼容方法跳转
|
|
144
|
-
this.openUrlCompat(redirectUrl, '_self'); // logout默认当前页跳转,若需新开可改_blank
|
|
153
|
+
window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
|
|
145
154
|
}
|
|
146
155
|
return result;
|
|
147
156
|
} catch (error) {
|
|
@@ -150,8 +159,7 @@ export function createSSO() {
|
|
|
150
159
|
} else {
|
|
151
160
|
this.removeToken();
|
|
152
161
|
if (isBrowser() && config.logOutUrl) {
|
|
153
|
-
|
|
154
|
-
this.openUrlCompat(redirectUrl, '_self');
|
|
162
|
+
window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
|
|
155
163
|
}
|
|
156
164
|
return { code: 0, msg: '已成功清除token', success: true };
|
|
157
165
|
}
|
|
@@ -172,6 +180,11 @@ export function createSSO() {
|
|
|
172
180
|
return { code: -104, msg: '请提供跳转地址', success: false };
|
|
173
181
|
}
|
|
174
182
|
|
|
183
|
+
// 核心修改:iOS移动端强制使用当前页面打开
|
|
184
|
+
if (isIOS()) {
|
|
185
|
+
target = '_self';
|
|
186
|
+
}
|
|
187
|
+
|
|
175
188
|
// 验证target参数有效性
|
|
176
189
|
if (!['_self', '_blank'].includes(target)) {
|
|
177
190
|
return { code: -108, msg: 'target参数必须是"_self"或"_blank"', success: false };
|
|
@@ -185,8 +198,13 @@ export function createSSO() {
|
|
|
185
198
|
if (!token) {
|
|
186
199
|
if (isBrowser() && config.logOutUrl) {
|
|
187
200
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
188
|
-
|
|
189
|
-
|
|
201
|
+
|
|
202
|
+
// 根据target决定打开方式
|
|
203
|
+
if (target === '_blank') {
|
|
204
|
+
window.open(loginUrl, '_blank');
|
|
205
|
+
} else {
|
|
206
|
+
window.location.href = loginUrl;
|
|
207
|
+
}
|
|
190
208
|
}
|
|
191
209
|
return { code: -106, msg: '未找到有效token', success: false };
|
|
192
210
|
}
|
|
@@ -205,51 +223,34 @@ export function createSSO() {
|
|
|
205
223
|
const url = new URL(redirectUrl);
|
|
206
224
|
url.searchParams.set(config.accessCodeKey, result.data);
|
|
207
225
|
const targetUrl = url.toString();
|
|
208
|
-
|
|
226
|
+
|
|
227
|
+
// 根据target参数决定跳转方式
|
|
228
|
+
if (target === '_blank') {
|
|
229
|
+
window.open(targetUrl, '_blank');
|
|
230
|
+
} else {
|
|
231
|
+
window.location.href = targetUrl;
|
|
232
|
+
}
|
|
209
233
|
} else {
|
|
210
234
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
211
|
-
|
|
235
|
+
if (target === '_blank') {
|
|
236
|
+
window.open(loginUrl, '_blank');
|
|
237
|
+
} else {
|
|
238
|
+
window.location.href = loginUrl;
|
|
239
|
+
}
|
|
212
240
|
}
|
|
213
241
|
|
|
214
242
|
return result;
|
|
215
243
|
} catch (error) {
|
|
216
244
|
const loginUrl = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(redirectUrl)}`;
|
|
217
|
-
|
|
245
|
+
if (target === '_blank') {
|
|
246
|
+
window.open(loginUrl, '_blank');
|
|
247
|
+
} else {
|
|
248
|
+
window.location.href = loginUrl;
|
|
249
|
+
}
|
|
218
250
|
return { code: -107, msg: `跳转失败: ${error.message}`, success: false };
|
|
219
251
|
}
|
|
220
252
|
},
|
|
221
|
-
// 封装兼容iOS的跳转工具函数
|
|
222
|
-
openUrlCompat (url, target = '_self') {
|
|
223
|
-
if (!isBrowser()) return;
|
|
224
|
-
|
|
225
|
-
// 处理_self:直接跳转
|
|
226
|
-
if (target === '_self') {
|
|
227
|
-
window.location.href = url;
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
253
|
|
|
231
|
-
// 处理_blank:iOS下用a标签模拟点击替代window.open
|
|
232
|
-
try {
|
|
233
|
-
// 创建a标签
|
|
234
|
-
const link = document.createElement('a');
|
|
235
|
-
link.href = url;
|
|
236
|
-
link.target = '_blank';
|
|
237
|
-
link.rel = 'noopener noreferrer'; // 安全属性,避免性能问题
|
|
238
|
-
// 模拟用户点击(必须在交互回调中执行)
|
|
239
|
-
document.body.appendChild(link);
|
|
240
|
-
const event = new MouseEvent('click', {
|
|
241
|
-
bubbles: true,
|
|
242
|
-
cancelable: true,
|
|
243
|
-
view: window
|
|
244
|
-
});
|
|
245
|
-
link.dispatchEvent(event);
|
|
246
|
-
// 移除临时a标签
|
|
247
|
-
document.body.removeChild(link);
|
|
248
|
-
} catch (e) {
|
|
249
|
-
// 降级方案:仍尝试window.open(部分场景可能生效)
|
|
250
|
-
window.open(url, '_blank');
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
254
|
/**
|
|
254
255
|
* 获取accessCode(通过token换取)
|
|
255
256
|
* @returns {Promise<Object>} 接口返回结果(data为accessCode)
|
|
@@ -309,8 +310,10 @@ export function createSSO() {
|
|
|
309
310
|
}
|
|
310
311
|
);
|
|
311
312
|
},
|
|
313
|
+
|
|
312
314
|
async getPhoneCode() {
|
|
313
315
|
const token = this.getToken();
|
|
316
|
+
// 修复笔误:sendCaptchaCode → sendCaptchaCodeApi
|
|
314
317
|
return request(
|
|
315
318
|
config.sendCaptchaCodeApi,
|
|
316
319
|
{
|
|
@@ -320,11 +323,8 @@ export function createSSO() {
|
|
|
320
323
|
}
|
|
321
324
|
);
|
|
322
325
|
},
|
|
323
|
-
|
|
324
326
|
};
|
|
325
327
|
}
|
|
326
328
|
|
|
327
|
-
|
|
328
|
-
|
|
329
329
|
// 创建默认实例
|
|
330
|
-
export const lgsso = createSSO();
|
|
330
|
+
export const lgsso = createSSO();
|