WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2021-01-14 337526cd5eb6b3ea05a924bfd65368ff6b1a8231
删除无用代码
2 files modified
66 ■■■■ changed files
bases/Fetcher.js 11 ●●●●● patch | view | raw | blame | history
common/Tools.js 55 ●●●●● patch | view | raw | blame | history
bases/Fetcher.js
@@ -534,16 +534,19 @@
    static inDevMod = (() => {
        // 网页
        if (process.env.TARO_ENV === 'h5') {
            const reg = new RegExp('(^|&)query=([^&]*)(&|$)', 'i');
            const match = window.location.search.substr(1).match(reg);
            const param = match !== null ? decodeURIComponent(match[2]) : null;
            // 当处于 mock 请求模式,视为本地开发
            if (Tools.getUrlParam('query') === 'mock') {
            if (param === 'mock') {
                return true;
            }
            // 强制 real 请求,可在本地使用真实请求
            if (Tools.getUrlParam('query') === 'real') {
            if (param === 'real') {
                return false;
            }
            // 当没有 url 指定时,只有内网 ip 和 33** 的端口号,视为本地开发模式
            return /^(192|127|localhost).*?:33\d{2}$/i.test(window.location.host);
            // 当没有 url 指定时,只有内网 ip 和 33**/35** 的端口号,视为本地开发模式
            return /^(192|127|localhost).*?:3[35]\d{2}$/i.test(window.location.host);
        }
        // 小程序
        else if (process.env.TARO_ENV === 'weapp') {
common/Tools.js
@@ -10,22 +10,6 @@
export class Tools {
    /**
     * URL参数解析
     * @param {String} name
     * @param {String} [search]
     * @return {String|Null}
     */
    static getUrlParam(name, search = window.location.search) {
        const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        const r = search.substr(1).match(reg);
        if (r !== null) {
            return decodeURIComponent(r[2]);
        } else {
            return null;
        }
    }
    /**
     * 显示消息
     * @param msg
     */
@@ -180,33 +164,6 @@
        return true;
    }
    // static getObjDataByPath(obj, path) {
    //     const arr = path.split('.');
    //     const reg2 = /\[(.*)]/g;
    //     const reg4 = /\w+(?=\[)|(?<=\[)(.*?)(?=])/g;
    //     let stack = [];
    //     let temp;
    //     arr.forEach(item => {
    //         if (reg2.test(item)) {
    //             while ((temp = reg4.exec(item))) {
    //                 stack.push(temp[0]);
    //             }
    //         } else {
    //             stack.push(item);
    //         }
    //     });
    //     stack = stack.map(item => {
    //         return item.replace(/^['"`]|['"`]$/g, '');
    //     });
    //     try {
    //         return stack.reduce((pre, next) => {
    //             return pre[next];
    //         }, obj);
    //     } catch (err) {
    //         return undefined;
    //     }
    // }
    /**
     * 统计字符串占位宽度
     * @param {String} string
@@ -330,18 +287,6 @@
            }
        }
        return target;
    }
    /**
     * 数组元素交换位置
     * @param {array} arr 数组
     * @param {number} index1 要交换项目的位置
     * @param {number} index2 被交换项目的位置
     * @tutorial 例如:1,5就是数组中下标为1和5的两个元素交换位置
     */
    static swapArray(arr, index1, index2) {
        arr[index1] = arr.splice(index2, 1, arr[index1])[0];
        return arr;
    }
    /**