let currentPath = window.location.href; let accessToken = ''; if(currentPath.indexOf("accessToken") > -1) { let list = currentPath.split("&"); for(let i=0; i -1) { let index = list[i].indexOf('accessToken='); accessToken = list[i].substr(index + 12, list[i].length); break; } } localStorage.setItem("accessToken", accessToken); document.cookie = "accessToken=" + accessToken }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 } } localStorage.setItem("accessToken", accessToken) } /** * 以下是4.4stable的代码 * **/ // let pateName = window.document.location.pathname; // let contextPath = pateName.substring(1, pateName.substr(1).indexOf('/') + 1) // if (contextPath == "/") { // contextPath = "/kms"; // } else { // contextPath = "/" + contextPath; //trunk and 4.4stable // } // let kmsConfig = { // contextPath: contextPath, // kmsFilePath: contextPath, // statiContextPath: "", // accessToken:accessToken // } /** * 以下是5.0trunk的代码 * **/ let kmsConfig = { contextPath: "/kms/api", kmsFilePath: "/kms", statiContextPath: "/static", accessToken: accessToken }