let pateName = window.document.location.pathname;
let contextPath = pateName.substring(1,pateName.substr(1).indexOf('/')+1);
let kmsPath = pateName.substring(1,pateName.substr(1).indexOf('/')+1);
if(contextPath == "/"){
    contextPath = "obpm";
    kmsPath = "";
}else{
    contextPath = "../..";  //4.1and4.3stable 
    kmsPath = "../../../";
}
let currentPath =  window.location.href;
let accessToken = ''
let token = ''
if(currentPath.indexOf("accessToken") > -1) {
    let list = currentPath.split("&");
    for(let i=0; i<list.length; i++) {
        if(list[i].indexOf("accessToken") > -1) {
            let index = list[i].indexOf('accessToken=')
            accessToken = list[i].substr(index + 12, list[i].length)
            break
        }
    }
    localStorage.setItem("accessToken", accessToken)
}
if(currentPath.indexOf("v3token") > -1) {//url携带token，命名为v3token，防止跟态势大屏冲突
    let list = currentPath.split("&");
    for(let i=0; i<list.length; i++) {
        if(list[i].indexOf("v3token") > -1) {
            let index = list[i].indexOf('v3token=')
            token = list[i].substr(index + 8, list[i].length)
            break
        }
    }
    localStorage.setItem("token", token)
}
else {
    let tokenData = document.cookie
    let list = tokenData.split("; ")
     for (let i = 0; i < list.length; i++) {
        let pair = list[i].split("=")
        if (pair[0] == "accessToken") {
            accessToken = pair[1]
            break
        }
    }
}
export default {
    TEST_DATA: "testData",
    PermissionType_READONLY: 1,
    PermissionType_MODIFY: 2,
    PermissionType_HIDDEN: 3,
    PermissionType_DISABLED: 4,
    PermissionType_PRINT: 5,
    contextPath: contextPath,
    contextPathV3:'v3',
    accessToken: accessToken,
    kmsPath: kmsPath,
}