Authored by wangtao

chore: 请求参数优化

... ... @@ -1258,21 +1258,21 @@ layui.define(['xmSelect', 'md5'], function (exports) {
}
// End Wang 2021/12/13 19:43 权限列表,如果能从缓存中加载到数据,则获取缓存中的数据
var pers = [];
$.ajax({
type: 'get',
url: obj.domainName + '/api-u/users/current?access_token=' + access_token,
contentType: "application/json; charset=utf-8",
async: false,
success: function (data) {
pers = data.permissions;
$("[permission]").each(function () {
var per = $(this).attr("permission");
if ($.inArray(per, pers) < 0) {
$(this).hide();
}
});
}
});
// $.ajax({
// type: 'get',
// url: obj.domainName + '/api-u/users/current?access_token=' + access_token,
// contentType: "application/json; charset=utf-8",
// async: false,
// success: function (data) {
// pers = data.permissions;
// $("[permission]").each(function () {
// var per = $(this).attr("permission");
// if ($.inArray(per, pers) < 0) {
// $(this).hide();
// }
// });
// }
// });
return pers;
},
/* pid转children形式 */
... ...
... ... @@ -52,20 +52,20 @@ layui.define(['sessions', 'form', 'common'], function (exports) {
if (localStorage.layuiAdmin) {
var access_token = JSON.parse(localStorage.layuiAdmin).access_token;
if (access_token != null && access_token.trim().length != 0) {
$.ajax({
type: 'get',
url: common.domainName + '/api-u/users/current?access_token=' + access_token,
dataType: 'jsonp', // 处理Ajax跨域问题
success: function (data) {
location.hash = search.redirect ? decodeURIComponent(search.redirect) : '/';
},
error: function (xhr, textStatus, errorThrown) {
if (xhr.status == 401) {
localStorage.removeItem("access_token");
localStorage.removeItem("initTips");
}
}
});
// $.ajax({
// type: 'get',
// url: common.domainName + '/api-u/users/current?access_token=' + access_token,
// dataType: 'jsonp', // 处理Ajax跨域问题
// success: function (data) {
// location.hash = search.redirect ? decodeURIComponent(search.redirect) : '/';
// },
// error: function (xhr, textStatus, errorThrown) {
// if (xhr.status == 401) {
// localStorage.removeItem("access_token");
// localStorage.removeItem("initTips");
// }
// }
// });
}
}
... ...
... ... @@ -18,7 +18,7 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
//对外暴露的接口
exports('mxgraphView', function () {
var sessions = layui.sessions;
var accessToken = sessions.getToken().access_token;
var accessToken = common.getMjToken();
var router = layui.router();
var topoId = router.search.id;
var from = router.search.from;
... ... @@ -300,7 +300,7 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
if (topoId) {
//编辑拓扑
$("#gotoedittopo").unbind('click').on("click", function () {
$(this).attr("lay-href", "/mxgraph/setting/id=" + topoId)
$(this).attr("lay-href", "/grapheditor-web/mxgraph/setting/id=" + topoId)
});
}
} else if (res.object && res.object.xmlInfo && (new Date(res.object.createTime) > new Date('2021-03-23 17:28'))) {
... ... @@ -312,11 +312,11 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
//xwx 2021-10-29 拓扑视图下拉选择框默认回填 --end
// $("#mxgraph-topoTitle").text(" - " + res.object.topoName);
}
$('#newViewGraphContainer iframe').attr('src', `${common.graphEditorOrigin}/jgraph/grapheditor/viewer.html?access_token=${accessToken}&id=${topoId}`);
$('#newViewGraphContainer iframe').attr('src', `/grapheditor-web/jgraph/grapheditor/viewer.html?access_token=${accessToken}&id=${topoId}`);
if (topoId) {
//编辑拓扑
$("#gotoedittopo").unbind('click').on("click", function () {
var url = common.graphEditorOrigin + "/jgraph/grapheditor/index.html?access_token=" + accessToken + '&id=' + topoId;
var url = "/grapheditor-web/jgraph/grapheditor/index.html?access_token=" + accessToken + '&id=' + topoId;
window.open(url);
});
}
... ... @@ -715,11 +715,11 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
}
}
//拓扑树组件渲染
$.ajax({
admin.req({
url: common.domainName + '/api-web/mxgraph/getPageByTree?isDefault=1&access_token=' + accessToken,
type: 'get',
success: function (res) {
data: {
}
}).done(function (res) {
if (res && res.data) {
var data = res.data
var JtopoIds = res.str.split(',');
... ... @@ -737,8 +737,6 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
}
});
}
}
})
});
});
});
... ...
... ... @@ -58,7 +58,8 @@ layui.define(['sessions', 'form', 'common'], function (exports) {
var authKey = getUrlParam("AuthKey");
var authVal = getUrlParam("AuthVal");
localStorage.setItem("AuthKey",authKey);
localStorage.setItem("AuthVal",authVal);
layer.getTokenInfo(setter,sessions,authKey,authVal);
// 跳转地址
... ...
... ... @@ -350,4 +350,4 @@ layui.define(["jquery", "laytpl", "layer"], function (exports) {
return thisCas.call(ins);
});
})
layui.link('../../src/style/css/cascader.css')
layui.link('/monitor-web/src/style/css/cascader.css')
... ...
... ... @@ -445,7 +445,6 @@ if (typeof (mxBasePath) != 'undefined' && mxBasePath.length > 0) {
if (mxBasePath.substring(mxBasePath.length - 1) == '/') {
mxBasePath = mxBasePath.substring(0, mxBasePath.length - 1);
}
debugger
mxClient.basePath = mxBasePath;
} else {
mxClient.basePath = '.';
... ...
... ... @@ -7,7 +7,8 @@
*/
layui.define(['laytpl', 'layer'], function (exports) {
layui.define(['laytpl', 'layer','common'], function (exports) {
var common = layui.common;
var $ = layui.jquery
, laytpl = layui.laytpl
, layer = layui.layer
... ... @@ -116,8 +117,12 @@ layui.define(['laytpl', 'layer'], function (exports) {
// // ? options.headers[request.tokenName]
// // : (layui.data(setter.tableName)[request.tokenName] || '');
// }
let tokenVal = common.getMjToken();
let tokenKey = common.getMjTokenKey();
if (request.tokenName) {
if(options.type == 'post'){
options.headers[tokenKey] = tokenVal;
} else if (request.tokenName) {
let tokenVal = options.data[request.tokenName];
if(!tokenVal || tokenVal == ''){
options.data[request.tokenName] = localStorage.getItem(request.tokenName);
... ...
... ... @@ -33,6 +33,17 @@ layui.define(['xmSelect', 'md5'], function (exports) {
alarmTimer: null,//首页告警刷新定时器
limit: 50,//全局分页条目数
limits: [50, 100, 150, 200],//全局分页条目数组
/**
* 获取墨镜平台的token
* @returns {string}
*/
getMjToken : () =>{
return localStorage.getItem("AuthVal")
},
getMjTokenKey : () =>{
return localStorage.getItem("AuthKey")
},
//base64加密
Base64: {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
... ... @@ -1265,21 +1276,21 @@ layui.define(['xmSelect', 'md5'], function (exports) {
}
// End Wang 2021/12/13 19:43 权限列表,如果能从缓存中加载到数据,则获取缓存中的数据
var pers = [];
$.ajax({
type: 'get',
url: obj.domainName + '/api-u/users/current?access_token=' + access_token,
contentType: "application/json; charset=utf-8",
async: false,
success: function (data) {
pers = data.permissions;
$("[permission]").each(function () {
var per = $(this).attr("permission");
if ($.inArray(per, pers) < 0) {
$(this).hide();
}
});
}
});
// $.ajax({
// type: 'get',
// url: obj.domainName + '/api-u/users/current?access_token=' + access_token,
// contentType: "application/json; charset=utf-8",
// async: false,
// success: function (data) {
// pers = data.permissions;
// $("[permission]").each(function () {
// var per = $(this).attr("permission");
// if ($.inArray(per, pers) < 0) {
// $(this).hide();
// }
// });
// }
// });
return pers;
},
/* pid转children形式 */
... ...