@deppon/deppon-request 1.15.11 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@deppon/deppon-request`
2
2
 
3
- 德邦前端 http 请求包
3
+ 前端 http 请求封装包
4
4
 
5
5
  ## 安装
6
6
 
package/es/index.js CHANGED
@@ -1,8 +1,5 @@
1
1
  import './_virtual/_rollup-plugin-inject-process-env.js';
2
2
  import DepponRquest from './request/request.js';
3
+ export { default } from './request/request.js';
3
4
  export { default as VuePlugin } from './vue.js';
4
5
  export { useRequest } from './composable.js';
5
-
6
-
7
-
8
- export { DepponRquest as default };
@@ -1,11 +1,9 @@
1
1
  import '../_virtual/_rollup-plugin-inject-process-env.js';
2
- import { Loading } from '@deppon/deppon-ui';
3
2
 
4
3
  var isFuntion = function isFuntion(func) {
5
4
  return func && typeof func === 'function';
6
5
  };
7
6
  var DEFAULT_METHOD = 'POST';
8
- var whiteApiUrl = ['/gw/home/v6/goods/recommend.html'];
9
7
  function optionsAdapter(options, instance, resolveOptions) {
10
8
  // 适配method用法
11
9
  typeToMethod(options);
@@ -18,8 +16,9 @@ function optionsAdapter(options, instance, resolveOptions) {
18
16
  // // 兼容老的传参方式
19
17
  isFuntion(options.success) && options.success(res);
20
18
  isFuntion(options.complete) && options.complete();
21
- // return options.catchCode ? res : res ? res.data : null;
22
- return options.catchCode || whiteApiUrl.includes(options === null || options === void 0 ? void 0 : options.url) ? res : res ? res.data : null;
19
+ // 响应拦截器已经返回了数据对象(resData),所以直接返回 res
20
+ // 对于有 catchCode 或白名单 URL 的情况,也直接返回 res(响应拦截器已处理)
21
+ return res;
23
22
  })["catch"](function (e) {
24
23
  e.status === 'success' ? isFuntion(options.success) && options.success(e.data) : isFuntion(options.error) && options.error(e.data);
25
24
  isFuntion(options.complete) && options.complete();
@@ -59,17 +58,17 @@ function dataTypeForAxios(options) {
59
58
  }
60
59
  }
61
60
 
62
- /**
63
- * jquery中beforeSend有3个参数
64
- * callbackContext
65
- * jqXHR
66
- * s
67
- * return false 会终止请求
68
- * 对应axios有2个
69
- * data
70
- * headers
71
- *
72
- * return false的话不会终止请求。但是ajax会终止,不过目前没有人用这个规则
61
+ /**
62
+ * jquery中beforeSend有3个参数
63
+ * callbackContext
64
+ * jqXHR
65
+ * s
66
+ * return false 会终止请求
67
+ * 对应axios有2个
68
+ * data
69
+ * headers
70
+ *
71
+ * return false的话不会终止请求。但是ajax会终止,不过目前没有人用这个规则
73
72
  */
74
73
 
75
74
  function beforeSendForAxios(options) {
@@ -82,9 +81,6 @@ function beforeSendForAxios(options) {
82
81
  transformRequest = [transformRequest];
83
82
  }
84
83
  transformRequest.push(function (data) {
85
- if (!options.unload) {
86
- Loading.start();
87
- }
88
84
  beforeSend && typeof beforeSend === 'function' && beforeSend();
89
85
  return data;
90
86
  });
@@ -5,7 +5,7 @@ import md5 from 'md5';
5
5
  import { browser, queryCode } from '@deppon/deppon-utils';
6
6
 
7
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
9
 
10
10
  // 设置header信息
11
11
  function setHeaders(options) {
@@ -1,6 +1,3 @@
1
1
  import '../_virtual/_rollup-plugin-inject-process-env.js';
2
2
  import DepponRquest from './request.js';
3
-
4
-
5
-
6
- export { DepponRquest as default };
3
+ export { default } from './request.js';
@@ -1 +1 @@
1
- export default function appInstance(options: any): import("axios").AxiosPromise<any>;
1
+ export default function appInstance(options: any): Promise<import("axios").AxiosResponse<any, any, {}>>;
@@ -19,9 +19,9 @@ function appInstance(options) {
19
19
  return req(_req, options);
20
20
  }, reqErr);
21
21
  App.interceptors.response.use(function (_res) {
22
- return res(_res, options);
22
+ return res(_res);
23
23
  }, function (e) {
24
- return resErr(e, options);
24
+ return resErr(e);
25
25
  });
26
26
  return App(options);
27
27
  }
@@ -125,23 +125,137 @@ function RequestInterceptor(config, options) {
125
125
  data = config.data;
126
126
  var reqDataType = options.reqDataType;
127
127
  if (config.method === 'post') {
128
+ // 如果用户已经设置了 Content-Type,使用用户设置的
129
+ var hasCustomContentType = headers['Content-Type'];
128
130
  switch (reqDataType) {
129
- case 'json':
131
+ case 'application/json':
130
132
  if (options.jsonPrefix) {
131
133
  config.data = JSON.stringify(_defineProperty({}, options.jsonPrefix, data));
132
134
  } else {
133
135
  config.data = JSON.stringify(data);
134
136
  }
135
- config.headers['Content-Type'] = 'application/json; charset=UTF-8';
137
+ if (!hasCustomContentType) {
138
+ config.headers['Content-Type'] = 'application/json; charset=UTF-8';
139
+ }
136
140
  break;
137
- default:
138
- if (!headers['Content-Type']) {
141
+ case 'application/x-www-form-urlencoded':
142
+ // form-urlencoded 类型
143
+ if (!hasCustomContentType) {
139
144
  config.data = qs.stringify(data);
140
145
  config.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
146
+ } else {
147
+ // 如果用户设置了 Content-Type,根据 Content-Type 决定数据格式
148
+ if (headers['Content-Type'].includes('application/x-www-form-urlencoded')) {
149
+ config.data = qs.stringify(data);
150
+ } else if (headers['Content-Type'].includes('application/json')) {
151
+ config.data = JSON.stringify(data);
152
+ }
141
153
  }
142
154
  break;
155
+ default:
156
+ // 默认使用 application/json
157
+ if (!hasCustomContentType) {
158
+ config.data = JSON.stringify(data);
159
+ config.headers['Content-Type'] = 'application/json; charset=UTF-8';
160
+ } else {
161
+ // 如果用户设置了 Content-Type,根据 Content-Type 决定数据格式
162
+ if (headers['Content-Type'].includes('application/x-www-form-urlencoded')) {
163
+ config.data = qs.stringify(data);
164
+ } else if (headers['Content-Type'].includes('application/json')) {
165
+ config.data = JSON.stringify(data);
166
+ }
167
+ }
168
+ break;
169
+ }
170
+ }
171
+
172
+ // 保存完整的 headers 和 Cookie 信息到 config 中,以便在响应拦截器中可以获取
173
+ // 即使 Axios 在发送请求时修改或移除了某些 headers,我们也能在响应中获取到原始值
174
+ // 注意:headers 已经在上面声明过了,这里直接使用
175
+
176
+ // 保存完整的请求 headers(深拷贝,避免被后续修改影响)
177
+ var savedHeaders = JSON.parse(JSON.stringify(headers));
178
+
179
+ // 提取并保存 Cookie 信息
180
+ var cookieValue = '';
181
+
182
+ // 方法1: 从 headers 中查找(手动设置的 Cookie)
183
+ // 遍历所有 headers 键,不区分大小写查找 'cookie'
184
+ for (var key in headers) {
185
+ if (key && key.toLowerCase() === 'cookie') {
186
+ cookieValue = headers[key];
187
+ break;
143
188
  }
144
189
  }
190
+
191
+ // 如果还没找到,尝试直接访问
192
+ if (!cookieValue) {
193
+ cookieValue = headers.Cookie || headers.cookie || headers['Cookie'] || headers['cookie'] || '';
194
+ }
195
+
196
+ // 方法2: 如果 headers 中没有 Cookie,且 withCredentials 为 true(默认值),从 document.cookie 获取
197
+ // 因为浏览器会自动通过 withCredentials: true 发送 Cookie,但这些 Cookie 不会出现在 headers 中
198
+ // 注意:withCredentials 可能在 config 中显式设置,也可能继承自 defaults(默认为 true)
199
+ if (!cookieValue && typeof document !== 'undefined' && document.cookie) {
200
+ // 检查 withCredentials:如果显式设置为 false,则不获取;否则(true 或 undefined)都获取
201
+ // 因为 instance.js 中设置了 App.defaults.withCredentials = true
202
+ var shouldIncludeCookies = config.withCredentials !== false;
203
+ if (shouldIncludeCookies) {
204
+ cookieValue = document.cookie;
205
+ }
206
+ }
207
+
208
+ // 将 Cookie 保存到 config 的自定义属性中(方便单独使用)
209
+ if (cookieValue) {
210
+ config._requestCookie = cookieValue;
211
+ // 同时将 Cookie 添加到 _requestHeaders 中,键名为 'cookie'
212
+ savedHeaders['cookie'] = cookieValue;
213
+ }
214
+
215
+ // 添加浏览器自动添加的请求头(这些不会出现在 config.headers 中,但浏览器会自动发送)
216
+ if (typeof window !== 'undefined' && typeof location !== 'undefined') {
217
+ // Host(从请求 URL 中提取,浏览器会自动添加)
218
+ try {
219
+ // 优先从 config.url 或 config.baseURL 中提取 host
220
+ var requestUrl = config.url || config.baseURL || '';
221
+ if (requestUrl) {
222
+ // 如果是完整 URL,直接解析
223
+ if (requestUrl.startsWith('http://') || requestUrl.startsWith('https://')) {
224
+ var url = new URL(requestUrl);
225
+ if (url.host) {
226
+ savedHeaders['host'] = url.host;
227
+ }
228
+ } else {
229
+ // 如果是相对路径,需要结合 baseURL 或当前 location
230
+ var baseUrl = config.baseURL || location.origin;
231
+ var _url = new URL(requestUrl, baseUrl);
232
+ if (_url.host) {
233
+ savedHeaders['host'] = _url.host;
234
+ }
235
+ }
236
+ }
237
+ } catch (e) {
238
+ // URL 解析失败,忽略
239
+ }
240
+
241
+ // Origin(当前页面的源,浏览器会自动添加)
242
+ if (location.origin) {
243
+ savedHeaders['origin'] = location.origin;
244
+ }
245
+
246
+ // Referer(当前页面的 URL,浏览器会自动添加)
247
+ if (location.href) {
248
+ savedHeaders['referer'] = location.href;
249
+ }
250
+
251
+ // User-Agent(从 navigator 获取,浏览器会自动添加)
252
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
253
+ savedHeaders['user-agent'] = navigator.userAgent;
254
+ }
255
+ }
256
+
257
+ // 保存到 config 中
258
+ config._requestHeaders = savedHeaders;
145
259
  return config;
146
260
  }
147
261
  function RequestInterceptorError(e) {
@@ -1,2 +1,2 @@
1
- export default CBKRquest;
2
- declare function CBKRquest(options: any): any;
1
+ export default DepponRquest;
2
+ declare function DepponRquest(options: any): any;
@@ -6,7 +6,7 @@ import optionsAdapter from './adapterAjax.js';
6
6
  import cancelApi from './cancel.js';
7
7
 
8
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
10
  /**
11
11
  * deppon-request说明
12
12
  * @params options.url 请求的地址
@@ -1,6 +1,5 @@
1
1
  import '../_virtual/_rollup-plugin-inject-process-env.js';
2
- import { Loading } from '@deppon/deppon-ui';
3
- import { login } from '@deppon/deppon-utils';
2
+ import _typeof from '@babel/runtime/helpers/typeof';
4
3
 
5
4
  function ResponseInterceptor(res, options) {
6
5
  var resCode = res.status;
@@ -8,58 +7,90 @@ function ResponseInterceptor(res, options) {
8
7
  message: '请求异常'
9
8
  };
10
9
  var resSuccess = resCode >= 200 && resCode < 300 || resCode === 304; // jq
11
- // 控制loading的隐藏
12
- if (!options.unload) {
13
- Loading.end();
14
- }
15
10
  // 请求失败
16
11
  var requestError = function requestError() {
17
- return Promise.reject({
18
- status: 'error',
19
- // 这个表示整个请求都失败了
20
- data: resData
21
- });
22
- };
23
- if (resSuccess) {
24
- /**
25
- * 捕获code
26
- * 如果传true的话会捕获所有code
27
- * 传数组或者Number类型的code也可以捕获指定code
28
- * 但凡传了options.catchCode,就一定会捕获,并且不走默认校验流程
29
- */
30
- if (options.catchCode) {
31
- if (typeof options.catchCode === 'boolean' || Array.isArray(options.catchCode) && options.catchCode.indexOf(resData.code) >= 0 || options.catchCode === resData.code) {
32
- return Promise.resolve(resData);
12
+ var _res$config, _res$config2, _res$config3, _res$config4, _res$config5, _res$config6, _res$config7, _res$config8;
13
+ // 构建完整的错误对象,包含请求信息、响应信息和报错信息
14
+
15
+ // 获取完整的请求 headers(优先使用请求拦截器中保存的完整 headers)
16
+ // _requestHeaders 中已经包含了所有信息:手动设置的 headers、浏览器自动添加的 headers(host、origin、referer、user-agent)、以及 cookie
17
+ var requestHeaders = ((_res$config = res.config) === null || _res$config === void 0 ? void 0 : _res$config._requestHeaders) || ((_res$config2 = res.config) === null || _res$config2 === void 0 ? void 0 : _res$config2.headers) || {};
18
+
19
+ // 清理 requestHeaders,移除 Axios 内部使用的字段,只保留有用的请求头信息
20
+ var cleanedHeaders = {};
21
+ // 需要排除的 Axios 内部字段
22
+ var excludeKeys = ['common', 'delete', 'get', 'head', 'post', 'put', 'patch'];
23
+ for (var key in requestHeaders) {
24
+ // 排除 Axios 内部字段
25
+ if (!excludeKeys.includes(key)) {
26
+ cleanedHeaders[key] = requestHeaders[key];
33
27
  }
34
- return Promise.reject(resData);
35
28
  }
36
- // 如果传入了success回调,默认是使用了ajax,方便适配
37
- // code 没有办法统一处理除了201
38
- switch (resData.code) {
39
- case 201:
40
- login();
41
- return Promise.reject({
42
- status: 'success',
43
- // 这个表示请求成功了,但是返回信息失败了 因为在success回调里面需要在请求发送成功之后知道异常的code和data来处理信息
44
- data: resData
45
- });
46
- case 200:
47
- return Promise.resolve(resData);
48
- default:
49
- return Promise.reject({
50
- status: 'success',
51
- // 这个表示请求成功了,但是返回信息失败了 因为在success回调里面需要在请求发送成功之后知道异常的code和data来处理信息
52
- data: resData
53
- });
29
+
30
+ // 生成 statusText:优先从 response 中提取状态码和错误信息,如果 res.statusText 有值且不为空则使用它
31
+ var statusText = '';
32
+
33
+ // 优先从 response 中提取状态码和错误信息
34
+ if (resData && _typeof(resData) === 'object') {
35
+ // 从 response 中提取状态码和错误信息
36
+ var responseStatus = resData.status || res.status;
37
+ var responseError = resData.error || '';
38
+ var responseMessage = resData.message || '';
39
+
40
+ // 构建简短的错误信息:优先使用 error,如果没有则使用 message 的前50个字符
41
+ var shortMessage = '';
42
+ if (responseError) {
43
+ shortMessage = responseError;
44
+ } else if (responseMessage) {
45
+ // 截取 message 的前50个字符,避免过长
46
+ shortMessage = responseMessage.length > 50 ? responseMessage.substring(0, 50) + '...' : responseMessage;
47
+ }
48
+
49
+ // 拼接状态码和错误信息
50
+ if (responseStatus && shortMessage) {
51
+ statusText = "".concat(responseStatus, " ").concat(shortMessage);
52
+ } else if (responseStatus) {
53
+ statusText = String(responseStatus);
54
+ } else if (shortMessage) {
55
+ statusText = shortMessage;
56
+ }
57
+ }
58
+
59
+ // 如果从 response 中没有提取到,且 res.statusText 有值且不为空,则使用 res.statusText
60
+ if ((!statusText || statusText.trim() === '') && res.statusText && res.statusText.trim() !== '') {
61
+ statusText = res.statusText;
62
+ }
63
+
64
+ // 如果还是没有,使用默认值
65
+ if (!statusText || statusText.trim() === '') {
66
+ statusText = res.status ? "".concat(res.status, " \u8BF7\u6C42\u5931\u8D25") : '请求失败';
54
67
  }
68
+ var errorInfo = {
69
+ // 响应信息
70
+ status: res.status,
71
+ statusText: statusText,
72
+ response: res.data,
73
+ // 请求信息(从 config 中获取,包含完整的 headers,包括 cookie)
74
+ request: {
75
+ url: ((_res$config3 = res.config) === null || _res$config3 === void 0 ? void 0 : _res$config3.url) || ((_res$config4 = res.config) === null || _res$config4 === void 0 ? void 0 : _res$config4.baseURL) || '',
76
+ method: ((_res$config5 = res.config) === null || _res$config5 === void 0 || (_res$config5 = _res$config5.method) === null || _res$config5 === void 0 ? void 0 : _res$config5.toUpperCase()) || 'GET',
77
+ params: ((_res$config6 = res.config) === null || _res$config6 === void 0 ? void 0 : _res$config6.params) || {},
78
+ data: ((_res$config7 = res.config) === null || _res$config7 === void 0 ? void 0 : _res$config7.data) || {},
79
+ headers: cleanedHeaders,
80
+ // 使用清理后的请求 headers(包含所有有用的信息,包括 cookie)
81
+ timeout: (_res$config8 = res.config) === null || _res$config8 === void 0 ? void 0 : _res$config8.timeout
82
+ }
83
+ };
84
+ return Promise.reject(errorInfo);
85
+ };
86
+ if (resSuccess) {
87
+ // 如果没有 success 字段,直接返回数据(兼容没有 success 字段的接口)
88
+ return Promise.resolve(resData);
55
89
  } else {
56
90
  return requestError();
57
91
  }
58
92
  }
59
93
  function ResponseInterceptorError(res, options) {
60
- if (!options.unload) {
61
- Loading.end();
62
- }
63
94
  return Promise.reject(res);
64
95
  }
65
96
  var res = ResponseInterceptor;
package/es/vue.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import './_virtual/_rollup-plugin-inject-process-env.js';
2
- import DepponRquest from './request/request.js';
3
2
  import { setCookieDomain } from '@deppon/deppon-utils';
3
+ import DepponRquest from './request/request.js';
4
4
 
5
5
  /**
6
6
  * Vue 插件安装函数
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deppon/deppon-request",
3
- "version": "1.15.11",
3
+ "version": "2.1.3",
4
4
  "description": "德邦前端 http 请求包",
5
5
  "license": "MIT",
6
6
  "homepage": "",
@@ -20,11 +20,11 @@
20
20
  "typings": "es/index.d.ts",
21
21
  "sideEffects": false,
22
22
  "scripts": {
23
- "build": "ts-node build.ts"
23
+ "build": "ts-node build.ts",
24
+ "publish:auto": "npm publish"
24
25
  },
25
26
  "publishConfig": {
26
- "access": "public",
27
- "registry": "https://registry.npmjs.org"
27
+ "registry": "https://devrepo.devcloud.cn-east-3.huaweicloud.com/artgalaxy/api/npm/cn-east-3_8a2e1f0ee52d4adb9a0a6998d78d0dda_npm_1/"
28
28
  },
29
29
  "files": [
30
30
  "es"
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/runtime": "^7.17.7",
38
- "@deppon/deppon-bridge": "1.15.11",
39
- "@deppon/deppon-ui": "1.15.11",
40
- "@deppon/deppon-utils": "1.15.11",
38
+ "@deppon/deppon-bridge": "2.1.1",
39
+ "@deppon/deppon-ui": "2.1.1",
40
+ "@deppon/deppon-utils": "2.1.1",
41
41
  "axios": "^0.26.0",
42
42
  "md5": "^2.3.0",
43
43
  "qs": "^6.10.3"
@@ -45,5 +45,5 @@
45
45
  "peerDependencies": {
46
46
  "vue": "^3.0.0"
47
47
  },
48
- "gitHead": "77b874714bab56f83e6336762f87e9b13f234cc9"
48
+ "gitHead": "1f329a64567c2e22df7860b0918ebe3427718945"
49
49
  }
@@ -1,42 +0,0 @@
1
- import '../_virtual/_rollup-plugin-inject-process-env.js';
2
-
3
- /**
4
- * 设置 document.domain 以支持 cookie 跨域
5
- *
6
- * 参考 cmc-prefercenter-vue 项目中的实现:
7
- * - 如果 URL 包含 deppontest.com,设置 document.domain = 'deppontest.com'
8
- * - 如果 URL 包含 deppon.com,设置 document.domain = 'deppon.com'
9
- *
10
- * 注意:document.domain 只能在当前域或其父域上设置
11
- * 例如:如果当前域是 a.deppon.com,可以设置为 deppon.com,但不能设置为其他域
12
- */
13
- function setCookieDomain() {
14
- if (typeof window === 'undefined' || typeof document === 'undefined') {
15
- return;
16
- }
17
- try {
18
- var href = window.location.href;
19
-
20
- // 检查是否包含 deppontest.com
21
- if (href.indexOf('deppontest.com') !== -1) {
22
- // 检查当前域是否已经是 deppontest.com 或其子域
23
- var currentHost = window.location.hostname;
24
- if (currentHost === 'deppontest.com' || currentHost.endsWith('.deppontest.com')) {
25
- document.domain = 'deppontest.com';
26
- }
27
- }
28
-
29
- // 检查是否包含 deppon.com
30
- if (href.indexOf('deppon.com') !== -1) {
31
- // 检查当前域是否已经是 deppon.com 或其子域
32
- var _currentHost = window.location.hostname;
33
- if (_currentHost === 'deppon.com' || _currentHost.endsWith('.deppon.com')) {
34
- document.domain = 'deppon.com';
35
- }
36
- }
37
- } catch (error) {
38
- // 如果设置失败(例如跨域限制),静默失败
39
- }
40
- }
41
-
42
- export { setCookieDomain };