lgsso-sdk 1.2.6 → 1.2.9

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.js CHANGED
@@ -7,8 +7,8 @@
7
7
  /*
8
8
  * @Author: Robin LEI
9
9
  * @Date: 2025-08-21 15:09:15
10
- * @LastEditTime: 2025-08-21 15:22:11
11
- * @FilePath: \lg-wms-admind:\业务代码\中联钢信\五服一管\lg-ssosdk\src\utils.js
10
+ * @LastEditTime: 2026-01-23 11:28:26
11
+ * @FilePath: \lims-frontd:\业务代码\中联钢信\五服一管\lg-ssosdk\src\utils.js
12
12
  */
13
13
  /**
14
14
  * 检查是否在浏览器环境
@@ -44,38 +44,58 @@
44
44
  }
45
45
 
46
46
  /**
47
- * 移除URL中的指定参数
48
- * @param {string} name - 参数名
47
+ * 移除URL中的指定参数(支持单个或多个)
48
+ * @param {string|string[]} names - 要删除的参数名(单个字符串或字符串数组)
49
49
  */
50
- function removeQueryParam(name) {
50
+ function removeQueryParam(names) {
51
51
  if (!isBrowser()) return;
52
52
 
53
+ // 统一转为数组,兼容单个参数的调用方式
54
+ const paramNames = Array.isArray(names) ? names : [names];
55
+ if (paramNames.length === 0) return; // 无参数需删除时直接返回
56
+
53
57
  const url = new URL(window.location.href);
54
- let params, newUrl;
58
+ let newUrl;
55
59
 
56
60
  // 处理hash模式(参数在#之后)
57
61
  if (url.hash.includes('?')) {
58
62
  const [hashPath, hashQuery] = url.hash.split('?');
59
- params = new URLSearchParams(hashQuery);
63
+ const params = new URLSearchParams(hashQuery);
64
+
65
+ // 批量删除参数
66
+ paramNames.forEach(name => {
67
+ if (params.has(name)) {
68
+ params.delete(name);
69
+ }
70
+ });
60
71
 
61
- if (params.has(name)) {
62
- params.delete(name);
63
- const newHash = params.toString() ? `${hashPath}?${params.toString()}` : hashPath;
72
+ // 重构hash部分
73
+ const newHash = params.toString() ? `${hashPath}?${params.toString()}` : hashPath;
74
+ if (newHash !== url.hash) { // 只有hash变化时才更新URL
64
75
  url.hash = newHash;
65
76
  newUrl = url.toString();
66
77
  }
67
78
  }
68
79
  // 处理history模式(参数在?之后)
69
80
  else {
70
- params = new URLSearchParams(url.search);
71
- if (params.has(name)) {
72
- params.delete(name);
81
+ const params = new URLSearchParams(url.search);
82
+ let hasChanged = false;
83
+
84
+ // 批量删除参数
85
+ paramNames.forEach(name => {
86
+ if (params.has(name)) {
87
+ params.delete(name);
88
+ hasChanged = true;
89
+ }
90
+ });
91
+
92
+ // 只有参数变化时才更新URL
93
+ if (hasChanged) {
73
94
  url.search = params.toString();
74
95
  newUrl = url.toString();
75
96
  }
76
97
  }
77
-
78
- // 更新URL
98
+ // 更新URL(仅当URL有变化时)
79
99
  if (newUrl && newUrl !== window.location.href) {
80
100
  window.location.replace(newUrl);
81
101
  }
@@ -98,6 +118,7 @@
98
118
  */
99
119
  function mergeConfigs(defaults, options) {
100
120
  if (!options) return { ...defaults };
121
+
101
122
  const merged = { ...defaults };
102
123
  for (const key in options) {
103
124
  if (options.hasOwnProperty(key)) {
@@ -4042,6 +4063,66 @@
4042
4063
  }
4043
4064
  }
4044
4065
 
4066
+ // ===== Cookie操作工具函数 =====
4067
+ /**
4068
+ * 获取指定名称的Cookie值
4069
+ * @param {string} name Cookie名称
4070
+ * @returns {string|null} Cookie值
4071
+ */
4072
+ function getCookie(name) {
4073
+ if (!isBrowser()) return null;
4074
+ const match = document.cookie.match(new RegExp(`(^| )${name}=([^;]+)`));
4075
+ return match ? decodeURIComponent(match[2]) : null;
4076
+ }
4077
+
4078
+ /**
4079
+ * 设置Cookie
4080
+ * @param {string} name Cookie名称
4081
+ * @param {string} value Cookie值
4082
+ * @param {Object} options 配置(过期时间、路径等)
4083
+ */
4084
+ function setCookie(name, value, options = {}) {
4085
+ if (!isBrowser()) return;
4086
+ let cookieStr = `${name}=${encodeURIComponent(value)}`;
4087
+ cookieStr += `; path=${options.path || '/'}`; // 默认根路径
4088
+ if (options.expires) {
4089
+ const expires = typeof options.expires === 'number'
4090
+ ? new Date(Date.now() + options.expires * 86400000)
4091
+ : options.expires;
4092
+ cookieStr += `; expires=${expires.toUTCString()}`;
4093
+ }
4094
+ document.cookie = cookieStr;
4095
+ }
4096
+
4097
+ /**
4098
+ * 删除指定名称的Cookie
4099
+ * @param {string} name Cookie名称
4100
+ */
4101
+ function removeCookie(name) {
4102
+ if (!isBrowser()) return;
4103
+ setCookie(name, '', { expires: -1 });
4104
+ }
4105
+
4106
+ /**
4107
+ * 给重定向地址拼接platType参数
4108
+ * @param {string} redirectUrl 原始重定向地址
4109
+ * @param {string} platType platType值
4110
+ * @param {string} platTypeKey 参数名(默认platType)
4111
+ * @returns {string} 拼接后的重定向地址
4112
+ */
4113
+ function addPlatTypeToRedirectUrl(redirectUrl, platType, platTypeKey = 'platType') {
4114
+ if (!redirectUrl || !platType) return redirectUrl;
4115
+ try {
4116
+ const url = new URL(redirectUrl);
4117
+ url.searchParams.set(platTypeKey, platType);
4118
+ return url.toString();
4119
+ } catch (e) {
4120
+ // 兼容非标准URL的情况(比如相对路径)
4121
+ const separator = redirectUrl.includes('?') ? '&' : '?';
4122
+ return `${redirectUrl}${separator}${platTypeKey}=${platType}`;
4123
+ }
4124
+ }
4125
+
4045
4126
  // 默认配置
4046
4127
  const DEFAULT_CONFIG = {
4047
4128
  accessCodeKey: 'accessCode',
@@ -4052,13 +4133,14 @@
4052
4133
  refreshCodeApi: '',
4053
4134
  logoutApi: '',
4054
4135
  logOutUrl: '',
4055
- storage: localStorage, // 可替换为sessionStorage
4136
+ storage: localStorage,
4056
4137
  oldPwdKey: 'oldPwd',
4057
4138
  newPwdKey: 'newPwd',
4058
4139
  changePasswordApi: '',
4059
4140
  sendCaptchaCodeApi: '',
4060
4141
  typeKey: 'type',
4061
- codeKey: 'code'
4142
+ codeKey: 'code',
4143
+ platTypeKey: 'platType' // platType参数名配置
4062
4144
  };
4063
4145
 
4064
4146
  let config = null;
@@ -4081,46 +4163,35 @@
4081
4163
  }
4082
4164
 
4083
4165
  /**
4084
- * 判断是否是iOS移动端(精准适配iPad Air/所有iPad机型 + 全版本iPadOS)
4166
+ * 判断是否是iOS移动端
4085
4167
  * @returns {boolean} 是否为iOS环境
4086
4168
  */
4087
4169
  function isIOS() {
4088
- // 非浏览器环境直接返回false(如需保留请取消注释)
4089
- // if (!isBrowser()) return false;
4170
+ if (!isBrowser()) return false;
4090
4171
 
4091
4172
  const userAgent = navigator.userAgent.toLowerCase();
4092
- const platform = navigator.platform.toLowerCase(); // 统一转小写,避免大小写兼容问题
4173
+ const platform = navigator.platform.toLowerCase();
4093
4174
  const maxTouchPoints = navigator.maxTouchPoints || 0;
4094
- const screenRatio = screen.width / screen.height; // 屏幕宽高比(iPad核心特征:4:3左右)
4175
+ const screenRatio = screen.width / screen.height;
4095
4176
 
4096
- // ========== 核心检测规则 ==========
4097
- // 1. 基础规则:iPhone/iPod 直接命中(无兼容问题)
4098
4177
  const isIphoneIpod = /iphone|ipod/.test(userAgent) && !window.MSStream;
4099
-
4100
- // 2. iPad 专属检测(覆盖所有iPad机型,含iPad Air)
4101
4178
  const isIpad = (
4102
- // 场景1:老版本iPadOS/原生标识(platform含ipad)
4103
4179
  platform.includes('ipad') ||
4104
- // 场景2:iPadOS 13+ 伪装Mac(UA含macintosh + 触摸+ 非Mac平台)
4105
4180
  (
4106
- userAgent.includes('macintosh') &&
4107
- maxTouchPoints > 0 && // iPad Air 触摸点≥5,Mac几乎为0
4108
- !platform.includes('mac') && // 排除真Mac
4181
+ userAgent.includes('macintosh') &&
4182
+ maxTouchPoints > 0 &&
4183
+ !platform.includes('mac') &&
4109
4184
  !window.MSStream
4110
4185
  ) ||
4111
- // 场景3:新版本iPadOS(UA直接含ipados,如iPad Air搭载的iPadOS 15+)
4112
4186
  userAgent.includes('ipados') ||
4113
- // 场景4:极端场景(第三方浏览器如Chrome for iPad Air)
4114
4187
  (
4115
- maxTouchPoints >= 5 && // iPad Air 固定支持5点触摸
4116
- !platform.includes('android') && // 排除安卓平板
4117
- (screenRatio > 0.7 && screenRatio < 1.4) // iPad宽高比≈0.75(4:3),Mac多为1.78(16:9)
4188
+ maxTouchPoints >= 5 &&
4189
+ !platform.includes('android') &&
4190
+ (screenRatio > 0.7 && screenRatio < 1.4)
4118
4191
  )
4119
4192
  );
4120
4193
 
4121
- // ========== 最终判定 ==========
4122
- const result = isIphoneIpod || isIpad;
4123
- return result;
4194
+ return isIphoneIpod || isIpad;
4124
4195
  }
4125
4196
 
4126
4197
  /**
@@ -4140,9 +4211,17 @@
4140
4211
  config = mergeConfigs(DEFAULT_CONFIG, options);
4141
4212
  validateConfig(config);
4142
4213
 
4214
+ // 初始化时检测URL中的platType并存入Cookie
4215
+ if (isBrowser()) {
4216
+ const platTypeFromUrl = getQueryParam(config.platTypeKey);
4217
+ if (platTypeFromUrl) {
4218
+ setCookie(config.platTypeKey, platTypeFromUrl);
4219
+ // 可选:移除URL中的platType(避免重复显示)
4220
+ }
4221
+ }
4222
+
4143
4223
  const accessCode = getQueryParam(config.accessCodeKey);
4144
4224
 
4145
- // 验证必要的API配置
4146
4225
  if (!config.tokenApi) {
4147
4226
  return { code: -100, msg: '缺少tokenApi配置', success: false };
4148
4227
  }
@@ -4161,14 +4240,25 @@
4161
4240
 
4162
4241
  if (result.code === 0 && result.data) {
4163
4242
  config.storage.setItem(config.tokenKey, result.data);
4164
- removeQueryParam(config.accessCodeKey);
4243
+ removeQueryParam([config.accessCodeKey,config.platTypeKey]);
4165
4244
  }
4166
4245
  return result;
4167
4246
  }
4168
4247
  // 如果没有token,跳转到登录页
4169
4248
  else if (!this.getToken()) {
4170
4249
  if (isBrowser() && config.logOutUrl) {
4171
- window.location.href = `${config.logOutUrl}?redirect_uri=${encodeURIComponent(getCurrentUrlWithParams())}`;
4250
+ // ===== 核心修正:platType拼到redirect_uri里 =====
4251
+ const platTypeFromCookie = getCookie(config.platTypeKey);
4252
+ // 1. 获取原始重定向地址
4253
+ let redirectUri = getCurrentUrlWithParams();
4254
+ // 2. 给重定向地址加platType参数
4255
+ if (platTypeFromCookie) {
4256
+ redirectUri = addPlatTypeToRedirectUrl(redirectUri, platTypeFromCookie, config.platTypeKey);
4257
+ }
4258
+ // 3. 构建登录页URL(仅带redirect_uri参数)
4259
+ let loginUrl = new URL(config.logOutUrl);
4260
+ loginUrl.searchParams.set('redirect_uri', encodeURIComponent(redirectUri));
4261
+ window.location.href = loginUrl.toString();
4172
4262
  }
4173
4263
  }
4174
4264
 
@@ -4200,33 +4290,21 @@
4200
4290
  * @returns {Promise<Object>} 接口返回结果
4201
4291
  */
4202
4292
  async logout() {
4203
- // 1. 前置校验:初始化状态
4204
4293
  if (!config) {
4205
4294
  return { code: -101, msg: '请先调用init方法初始化', success: false };
4206
4295
  }
4207
4296
 
4208
- // 2. 工具函数:统一构建登录跳转URL(确保完整编码当前URL的所有参数/hash)
4209
- const buildLoginUrl = () => {
4210
- if (!config.logOutUrl || !isBrowser()) return '';
4211
- // 关键:获取当前完整URL(含query、hash)并完整编码,避免参数丢失
4212
- const currentFullUrl = window.location.href;
4213
- const encodedRedirectUri = encodeURIComponent(currentFullUrl);
4214
- return `${config.logOutUrl}?redirect_uri=${encodedRedirectUri}`;
4215
- };
4216
-
4217
- // 3. 校验logoutApi配置(仅接口调用时需要,跳转登录页不受此影响)
4218
- if (!config.logOutApi) {
4219
- // 无logoutApi时仍清除token并跳转登录页,保证基础退出逻辑
4220
- this.removeToken();
4221
- const loginUrl = buildLoginUrl();
4222
- if (loginUrl) window.location.href = loginUrl;
4297
+ if (!config.logoutApi) {
4223
4298
  return { code: -102, msg: '未配置logoutApi', success: false };
4224
4299
  }
4225
4300
 
4301
+ // 获取并删除Cookie中的platType
4302
+ const platType = getCookie(config.platTypeKey);
4303
+ removeCookie(config.platTypeKey);
4304
+
4226
4305
  const token = this.getToken();
4227
4306
  if (token) {
4228
4307
  try {
4229
- // 调用退出接口
4230
4308
  const result = await request(
4231
4309
  config.logoutApi,
4232
4310
  {
@@ -4235,37 +4313,48 @@
4235
4313
  timeout: config.timeout
4236
4314
  }
4237
4315
  );
4238
- // 无论接口返回结果如何,都清除token
4239
4316
  this.removeToken();
4240
4317
 
4241
- // 跳转登录页(携带完整的当前URL)
4242
- const loginUrl = buildLoginUrl();
4243
- if (loginUrl) window.location.href = loginUrl;
4318
+ if (isBrowser() && config.logOutUrl) {
4319
+ // ===== 核心修正:platType拼到redirect_uri里 =====
4320
+ // 1. 获取原始重定向地址
4321
+ let redirectUri = getCurrentUrlWithParams();
4322
+ // 2. 给重定向地址加platType参数
4323
+ if (platType) {
4324
+ redirectUri = addPlatTypeToRedirectUrl(redirectUri, platType, config.platTypeKey);
4325
+ }
4326
+ // 3. 构建登录页URL
4327
+ let logoutUrl = new URL(config.logOutUrl);
4328
+ logoutUrl.searchParams.set('redirect_uri', encodeURIComponent(redirectUri));
4329
+ window.location.href = logoutUrl.toString();
4330
+ }
4244
4331
  return result;
4245
4332
  } catch (error) {
4246
- // 接口调用失败,仍清除token并跳转登录页
4247
- this.removeToken();
4248
- const loginUrl = buildLoginUrl();
4249
- if (loginUrl) window.location.href = loginUrl;
4250
4333
  return { code: -103, msg: `退出失败: ${error.message}`, success: false };
4251
4334
  }
4252
4335
  } else {
4253
- // 无token时直接清除(兜底)并跳转登录页
4254
4336
  this.removeToken();
4255
- const loginUrl = buildLoginUrl();
4256
- if (loginUrl) window.location.href = loginUrl;
4337
+ if (isBrowser() && config.logOutUrl) {
4338
+ // ===== 核心修正:platType拼到redirect_uri里 =====
4339
+ let redirectUri = getCurrentUrlWithParams();
4340
+ if (platType) {
4341
+ redirectUri = addPlatTypeToRedirectUrl(redirectUri, platType, config.platTypeKey);
4342
+ }
4343
+ let logoutUrl = new URL(config.logOutUrl);
4344
+ logoutUrl.searchParams.set('redirect_uri', encodeURIComponent(redirectUri));
4345
+ window.location.href = logoutUrl.toString();
4346
+ }
4257
4347
  return { code: 0, msg: '已成功清除token', success: true };
4258
4348
  }
4259
4349
  },
4260
4350
 
4261
4351
  /**
4262
4352
  * 用token换取新accessCode并跳转到指定URL
4263
- * @param {string} redirectUrl - 目标跳转地址(支持带query/hash参数)
4353
+ * @param {string} redirectUrl - 目标跳转地址
4264
4354
  * @param {string} target - 当前页面:_self、新页面打开:_blank,默认当前页_self
4265
4355
  * @returns {Promise<Object>} 接口返回结果
4266
4356
  */
4267
4357
  async toUrl(redirectUrl, target = '_self') {
4268
- // 1. 前置校验:初始化状态、参数合法性
4269
4358
  if (!config) {
4270
4359
  return { code: -101, msg: '请先调用init方法初始化', success: false };
4271
4360
  }
@@ -4274,45 +4363,49 @@
4274
4363
  return { code: -104, msg: '请提供跳转地址', success: false };
4275
4364
  }
4276
4365
 
4277
- // ========== 新增:获取当前页面的platType参数 ==========
4278
- const currentPlatType = isBrowser() ? getQueryParam('platType') : '';
4279
-
4280
- // ========== 保留:platType=screen强制_self逻辑 ==========
4281
- const isPlatTypeScreen = currentPlatType === 'screen';
4282
-
4283
- // 2. 处理target参数:platType=screen > iOS > 传入的target
4284
- const finalTarget = isPlatTypeScreen
4285
- ? '_self' // platType=screen时强制_self
4286
- : (isIOS() ? '_self' : target); // 否则沿用原iOS判断逻辑
4287
-
4288
- if (!['_self', '_blank'].includes(finalTarget)) {
4289
- return { code: -108, msg: 'target参数必须是"_self"或"_blank"', success: false };
4366
+ // iOS强制_self
4367
+ if (isIOS()) {
4368
+ target = '_self';
4290
4369
  }
4291
4370
 
4292
- // 3. 工具函数:统一构建登录跳转URL(避免重复代码,确保参数完整编码)
4293
- const buildLoginUrl = (redirectUrl) => {
4294
- if (!config.logOutUrl) return '';
4295
- // 关键:encodeURIComponent 会完整编码redirectUrl的所有部分(query/hash),避免参数丢失
4296
- const encodedRedirectUri = encodeURIComponent(redirectUrl);
4297
- return `${config.logOutUrl}?redirect_uri=${encodedRedirectUri}`;
4298
- };
4371
+ // platType=screen时强制_self
4372
+ const platType = getCookie(config.platTypeKey);
4373
+ if (platType === 'screen') {
4374
+ target = '_self';
4375
+ }
4376
+
4377
+ // 验证target参数
4378
+ if (!['_self', '_blank'].includes(target)) {
4379
+ return { code: -108, msg: 'target参数必须是"_self"或"_blank"', success: false };
4380
+ }
4299
4381
 
4300
- // 4. 校验refreshCodeApi配置
4301
4382
  if (!config.refreshCodeApi) {
4302
4383
  return { code: -105, msg: '未配置refreshCodeApi', success: false };
4303
4384
  }
4304
4385
 
4305
- // 5. 获取token,无token则直接跳登录页
4306
4386
  const token = this.getToken();
4307
4387
  if (!token) {
4308
4388
  if (isBrowser() && config.logOutUrl) {
4309
- const loginUrl = buildLoginUrl(redirectUrl);
4310
- finalTarget === '_blank' ? window.open(loginUrl, '_blank') : window.location.href = loginUrl;
4389
+ // ===== 核心修正:platType拼到redirect_uri里 =====
4390
+ // 1. 给目标跳转地址加platType
4391
+ let newRedirectUrl = redirectUrl;
4392
+ if (platType) {
4393
+ newRedirectUrl = addPlatTypeToRedirectUrl(newRedirectUrl, platType, config.platTypeKey);
4394
+ }
4395
+ // 2. 构建登录页URL
4396
+ let loginUrl = new URL(config.logOutUrl);
4397
+ loginUrl.searchParams.set('redirect_uri', encodeURIComponent(newRedirectUrl));
4398
+ const loginUrlStr = loginUrl.toString();
4399
+
4400
+ if (target === '_blank') {
4401
+ window.open(loginUrlStr, '_blank');
4402
+ } else {
4403
+ window.location.href = loginUrlStr;
4404
+ }
4311
4405
  }
4312
4406
  return { code: -106, msg: '未找到有效token', success: false };
4313
4407
  }
4314
4408
 
4315
- // 6. 有token则尝试换取accessCode并跳转
4316
4409
  try {
4317
4410
  const result = await request(
4318
4411
  config.refreshCodeApi,
@@ -4324,31 +4417,48 @@
4324
4417
  );
4325
4418
 
4326
4419
  if (result.code === 0 && result.data && isBrowser()) {
4327
- // ========== 核心优化:拼接platType到目标URL ==========
4420
+ // toUrl跳转目标地址时,仅携带accessCode,不携带platType
4328
4421
  const url = new URL(redirectUrl);
4329
- // 1. 如果当前页面有platType,拼接到目标URL(覆盖原有platType)
4330
- if (currentPlatType) {
4331
- url.searchParams.set('platType', currentPlatType);
4332
- }
4333
- // 2. 拼接accessCode(保留原有逻辑)
4334
4422
  url.searchParams.set(config.accessCodeKey, result.data);
4335
4423
  const targetUrl = url.toString();
4336
4424
 
4337
- finalTarget === '_blank' ? window.open(targetUrl, '_blank') : window.location.href = targetUrl;
4425
+ if (target === '_blank') {
4426
+ window.open(targetUrl, '_blank');
4427
+ } else {
4428
+ window.location.href = targetUrl;
4429
+ }
4338
4430
  } else {
4339
- // 接口返回失败,跳登录页(复用统一的登录URL构建逻辑)
4340
- if (isBrowser() && config.logOutUrl) {
4341
- const loginUrl = buildLoginUrl(redirectUrl);
4342
- finalTarget === '_blank' ? window.open(loginUrl, '_blank') : window.location.href = loginUrl;
4431
+ // ===== 核心修正:platType拼到redirect_uri里 =====
4432
+ let newRedirectUrl = redirectUrl;
4433
+ if (platType) {
4434
+ newRedirectUrl = addPlatTypeToRedirectUrl(newRedirectUrl, platType, config.platTypeKey);
4435
+ }
4436
+ let loginUrl = new URL(config.logOutUrl);
4437
+ loginUrl.searchParams.set('redirect_uri', encodeURIComponent(newRedirectUrl));
4438
+ const loginUrlStr = loginUrl.toString();
4439
+
4440
+ if (target === '_blank') {
4441
+ window.open(loginUrlStr, '_blank');
4442
+ } else {
4443
+ window.location.href = loginUrlStr;
4343
4444
  }
4344
4445
  }
4345
4446
 
4346
4447
  return result;
4347
4448
  } catch (error) {
4348
- // 接口异常,跳登录页(复用统一的登录URL构建逻辑)
4349
- if (isBrowser() && config.logOutUrl) {
4350
- const loginUrl = buildLoginUrl(redirectUrl);
4351
- finalTarget === '_blank' ? window.open(loginUrl, '_blank') : window.location.href = loginUrl;
4449
+ // ===== 核心修正:platType拼到redirect_uri里 =====
4450
+ let newRedirectUrl = redirectUrl;
4451
+ if (platType) {
4452
+ newRedirectUrl = addPlatTypeToRedirectUrl(newRedirectUrl, platType, config.platTypeKey);
4453
+ }
4454
+ let loginUrl = new URL(config.logOutUrl);
4455
+ loginUrl.searchParams.set('redirect_uri', encodeURIComponent(newRedirectUrl));
4456
+ const loginUrlStr = loginUrl.toString();
4457
+
4458
+ if (target === '_blank') {
4459
+ window.open(loginUrlStr, '_blank');
4460
+ } else {
4461
+ window.location.href = loginUrlStr;
4352
4462
  }
4353
4463
  return { code: -107, msg: `跳转失败: ${error.message}`, success: false };
4354
4464
  }
@@ -4387,7 +4497,7 @@
4387
4497
  * @returns {Object|null} 当前配置
4388
4498
  */
4389
4499
  getConfig() {
4390
- return { ...config }; // 返回配置的副本,防止外部修改
4500
+ return { ...config };
4391
4501
  },
4392
4502
 
4393
4503
  async changePassword(fromData = {}) {
@@ -4416,7 +4526,6 @@
4416
4526
 
4417
4527
  async getPhoneCode() {
4418
4528
  const token = this.getToken();
4419
- // 修复笔误:sendCaptchaCode → sendCaptchaCodeApi
4420
4529
  return request(
4421
4530
  config.sendCaptchaCodeApi,
4422
4531
  {