ecology_dev/常用信息.md

2.8 KiB
Raw Blame History

常用的数据信息

其他

维护人员: youhong.ai

  • 缓存地址: /commcache/cacheMonitor.jsp
  • 移动端流程模拟地址: /spa/workflow/static4mobile/index.html#/center/doing

常用代码

前端

获取用户信息

维护人员youhong.ai

const userInfo = JSON.parse(localStorage.getItem("theme-account"))

获取url参数

维护人员: youHong.ai

getQueryString = (name) => {
    let reg = new RegExp("(^|&|\/?)" + name + "=([^&]*)(&|$)", "i");
    let searchStr = window.location.href
    if (searchStr.startsWith('&')) {
        searchStr = searchStr.substr(1)
    }
    search = searchStr.match(reg)
    if (search != null) {
        return unescape(search[2]);
    }
    return null;
}

ajax请求

维护人员: youHong.ai

  class ApiUtils {
    static request = (url, type = "GET", data, isAsync = true, success = () => {
    }, error = () => {
    }, complete = () => {
    }, contentType = 'application/json', beforeSend = () => {
    }) => {
        let options = {
            url,
            type,
            dataType: "json",
            contentType,
            async: isAsync,
            data,
            beforeSend,
            success,
            error,
            complete,
        }
        if (contentType == 'application/json') {
            options.data = JSON.stringify(data)
        }
        return $.ajax(options)
    }

}

通过js获取react组件操作组件内部数据

function FindReact(dom, traverseUp = 0) {
    const key = Object.keys(dom).find(key => {
        return key.startsWith("__reactFiber$") // react 17+
            || key.startsWith("__reactInternalInstance$"); // react <17
    });
    const domFiber = dom[key];
    if (domFiber == null) return null;

    // react <16
    if (domFiber._currentElement) {
        let compFiber = domFiber._currentElement._owner;
        for (let i = 0; i < traverseUp; i++) {
            compFiber = compFiber._currentElement._owner;
        }
        return compFiber._instance;
    }

    // react 16+
    const GetCompFiber = fiber => {
        let parentFiber = fiber.return;
        while (typeof parentFiber.type == "string") {
            parentFiber = parentFiber.return;
        }
        return parentFiber;
    };
    let compFiber = GetCompFiber(domFiber);
    for (let i = 0; i < traverseUp; i++) {
        compFiber = GetCompFiber(compFiber);
    }
    return compFiber.stateNode;
}

// 用法
const someElement = document.getElementById("someElement");
const myComp = FindReact(someElement);
myComp.setState({test1: test2});

数据库

备份mysql数据库

维护人员: youHong.ai

mysqldump -uroot -p'passowrd' --single-transaction -R -E --databases ecology_dev> /tmp/ecology_dev_back.sql

后端