PageSourceSearch

https://www.gigadevice.com/js/request.js?v=20260902b

js gigadevice.com collected 2026-10-02 04:28:15 UTC 4,061 bytes, 92 lines download raw bytes

1let baseUrl = "https://wcweb.gigadevice.com";
2let bUrl = "https://wcweb.gigadevice.com";
3
4// 预发布环境
5// let baseUrl = "https://wcwebtest.gigadevice.com";
6// let bUrl = "https://wcwebtest.gigadevice.com";
7
8if(['adminui2en.bju-pro.com','zhaoyi.test3.yongsy.net','enzhaoyi.test3.yongsy.net'].includes(location.host)) {
9    baseUrl = "http://zycxweb.bju-pro.com"; //用于拼接之后请求的url
10    bUrl = "https://enzhaoyi.test3.yongsy.net"
11} else if (['test_subscription.gigadevice.com'].includes(location.host)) {
12    baseUrl = "https://wcwebtest.gigadevice.com";
13    bUrl = "https://wcwebtest.gigadevice.com";
14}
15export { baseUrl, bUrl };
16export default (params,header = {}) => {
17    const { url, data, method = 'GET', type='wc' } = params;
18    let requestData = data;
19    let headers = {
20        'X-TOKEN': $.cookie('token'), // 自定义请求头  
21        'X-LANG': 'en', // 中文zh,英文en  
22        "Content-Type": "application/json;charset=utf8",
23    };
24    let dataType = "json";
25    let newUrl = baseUrl+url;
26    if(type === 'wc') {
27        // 根据请求方法处理数据  
28        requestData = method === 'GET' ? data : JSON.stringify(data);
29    }
30    if(type === 'yongxi') {
31        newUrl = bUrl+url;
32        headers = {
33            "Content-Type": "application/x-www-form-urlencoded;charset=utf8",  
34        };
35        // 根据请求方法处理数据  
36        requestData = data;
37    } 
38    headers = {
39        ...headers,
40        ...header
41    }
42    
43    return new Promise((resolve, reject) => {
44        $.ajax({
45            url: newUrl,  
46            type: method,  
47            async: true, // 始终异步  
48            dataType,
49            data: requestData,  
50            headers,  
51            success: function (ret) {
52                if (ret.code === 200) {
53                    resolve(ret);
54                } else if(ret.code === 401 || ret.code === 40101) {
55                    // 处理未登录
56                    setTimeout(() => {
57                        $.removeCookie('token', { path: '/' }); 
58                        $.removeCookie('loginEmail', { path: '/' }); 
59                        $.removeCookie('userName', { path: '/' }); 
60                        $.removeCookie('token');
61                        $.removeCookie('loginEmail');
62                        var loginPath = location.pathname.indexOf('/EN/') === 0 ? '/EN/mygd/login.html' : '/mygd/login.html';
63                        window.location.href = loginPath + '?redirect=' + encodeURIComponent(location.pathname);
64                    }, 500);
65                    // reject(new Error('Please log in first!'));
66                } else {
67                    resolve(ret);
68                    // reject(new Error('服务器返回错误代码: ' + ret.code)); 
69                }
70            },
71            error: function (jqXHR, textStatus, errorThrown) {
72                // HTTP 401 未登录或 token 过期,跳转登录
73                if (jqXHR.status === 401) {
74                    setTimeout(() => {
75                        $.removeCookie('token', { path: '/' });
76                        $.removeCookie('loginEmail', { path: '/' });
77                        $.removeCookie('userName', { path: '/' });
78                        $.removeCookie('token');
79                        $.removeCookie('loginEmail');
80                        var loginPath = location.pathname.indexOf('/EN/') === 0 ? '/EN/mygd/login.html' : '/mygd/login.html';
81                        window.location.href = loginPath + '?redirect=' + encodeURIComponent(location.pathname);
82                    }, 300);
83                    reject(new Error('Not logged in or login expired, please log in again'));
84                } else if (jqXHR.status === 0) {
85                    reject(new Error('Network error or CORS issue'));
86                } else {
87                    reject(new Error('HTTP ERROR: ' + jqXHR.status + ' - ' + errorThrown));
88                }
89            },
90        });
91    });
92}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.