Authored by wangtao

chore: 请求参数优化

@@ -1258,21 +1258,21 @@ layui.define(['xmSelect', 'md5'], function (exports) { @@ -1258,21 +1258,21 @@ layui.define(['xmSelect', 'md5'], function (exports) {
1258 } 1258 }
1259 // End Wang 2021/12/13 19:43 权限列表,如果能从缓存中加载到数据,则获取缓存中的数据 1259 // End Wang 2021/12/13 19:43 权限列表,如果能从缓存中加载到数据,则获取缓存中的数据
1260 var pers = []; 1260 var pers = [];
1261 - $.ajax({  
1262 - type: 'get',  
1263 - url: obj.domainName + '/api-u/users/current?access_token=' + access_token,  
1264 - contentType: "application/json; charset=utf-8",  
1265 - async: false,  
1266 - success: function (data) {  
1267 - pers = data.permissions;  
1268 - $("[permission]").each(function () {  
1269 - var per = $(this).attr("permission");  
1270 - if ($.inArray(per, pers) < 0) {  
1271 - $(this).hide();  
1272 - }  
1273 - });  
1274 - }  
1275 - }); 1261 + // $.ajax({
  1262 + // type: 'get',
  1263 + // url: obj.domainName + '/api-u/users/current?access_token=' + access_token,
  1264 + // contentType: "application/json; charset=utf-8",
  1265 + // async: false,
  1266 + // success: function (data) {
  1267 + // pers = data.permissions;
  1268 + // $("[permission]").each(function () {
  1269 + // var per = $(this).attr("permission");
  1270 + // if ($.inArray(per, pers) < 0) {
  1271 + // $(this).hide();
  1272 + // }
  1273 + // });
  1274 + // }
  1275 + // });
1276 return pers; 1276 return pers;
1277 }, 1277 },
1278 /* pid转children形式 */ 1278 /* pid转children形式 */
@@ -52,20 +52,20 @@ layui.define(['sessions', 'form', 'common'], function (exports) { @@ -52,20 +52,20 @@ layui.define(['sessions', 'form', 'common'], function (exports) {
52 if (localStorage.layuiAdmin) { 52 if (localStorage.layuiAdmin) {
53 var access_token = JSON.parse(localStorage.layuiAdmin).access_token; 53 var access_token = JSON.parse(localStorage.layuiAdmin).access_token;
54 if (access_token != null && access_token.trim().length != 0) { 54 if (access_token != null && access_token.trim().length != 0) {
55 - $.ajax({  
56 - type: 'get',  
57 - url: common.domainName + '/api-u/users/current?access_token=' + access_token,  
58 - dataType: 'jsonp', // 处理Ajax跨域问题  
59 - success: function (data) {  
60 - location.hash = search.redirect ? decodeURIComponent(search.redirect) : '/';  
61 - },  
62 - error: function (xhr, textStatus, errorThrown) {  
63 - if (xhr.status == 401) {  
64 - localStorage.removeItem("access_token");  
65 - localStorage.removeItem("initTips");  
66 - }  
67 - }  
68 - }); 55 + // $.ajax({
  56 + // type: 'get',
  57 + // url: common.domainName + '/api-u/users/current?access_token=' + access_token,
  58 + // dataType: 'jsonp', // 处理Ajax跨域问题
  59 + // success: function (data) {
  60 + // location.hash = search.redirect ? decodeURIComponent(search.redirect) : '/';
  61 + // },
  62 + // error: function (xhr, textStatus, errorThrown) {
  63 + // if (xhr.status == 401) {
  64 + // localStorage.removeItem("access_token");
  65 + // localStorage.removeItem("initTips");
  66 + // }
  67 + // }
  68 + // });
69 } 69 }
70 } 70 }
71 71
@@ -18,7 +18,7 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun @@ -18,7 +18,7 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
18 //对外暴露的接口 18 //对外暴露的接口
19 exports('mxgraphView', function () { 19 exports('mxgraphView', function () {
20 var sessions = layui.sessions; 20 var sessions = layui.sessions;
21 - var accessToken = sessions.getToken().access_token; 21 + var accessToken = common.getMjToken();
22 var router = layui.router(); 22 var router = layui.router();
23 var topoId = router.search.id; 23 var topoId = router.search.id;
24 var from = router.search.from; 24 var from = router.search.from;
@@ -300,7 +300,7 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun @@ -300,7 +300,7 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
300 if (topoId) { 300 if (topoId) {
301 //编辑拓扑 301 //编辑拓扑
302 $("#gotoedittopo").unbind('click').on("click", function () { 302 $("#gotoedittopo").unbind('click').on("click", function () {
303 - $(this).attr("lay-href", "/mxgraph/setting/id=" + topoId) 303 + $(this).attr("lay-href", "/grapheditor-web/mxgraph/setting/id=" + topoId)
304 }); 304 });
305 } 305 }
306 } else if (res.object && res.object.xmlInfo && (new Date(res.object.createTime) > new Date('2021-03-23 17:28'))) { 306 } 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 @@ -312,11 +312,11 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
312 //xwx 2021-10-29 拓扑视图下拉选择框默认回填 --end 312 //xwx 2021-10-29 拓扑视图下拉选择框默认回填 --end
313 // $("#mxgraph-topoTitle").text(" - " + res.object.topoName); 313 // $("#mxgraph-topoTitle").text(" - " + res.object.topoName);
314 } 314 }
315 - $('#newViewGraphContainer iframe').attr('src', `${common.graphEditorOrigin}/jgraph/grapheditor/viewer.html?access_token=${accessToken}&id=${topoId}`); 315 + $('#newViewGraphContainer iframe').attr('src', `/grapheditor-web/jgraph/grapheditor/viewer.html?access_token=${accessToken}&id=${topoId}`);
316 if (topoId) { 316 if (topoId) {
317 //编辑拓扑 317 //编辑拓扑
318 $("#gotoedittopo").unbind('click').on("click", function () { 318 $("#gotoedittopo").unbind('click').on("click", function () {
319 - var url = common.graphEditorOrigin + "/jgraph/grapheditor/index.html?access_token=" + accessToken + '&id=' + topoId; 319 + var url = "/grapheditor-web/jgraph/grapheditor/index.html?access_token=" + accessToken + '&id=' + topoId;
320 window.open(url); 320 window.open(url);
321 }); 321 });
322 } 322 }
@@ -715,30 +715,28 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun @@ -715,30 +715,28 @@ layui.define(['common', 'sessions', 'commonDetail', 'mxClient', 'cascader'], fun
715 } 715 }
716 } 716 }
717 717
718 - //拓扑树组件渲染  
719 - $.ajax({ 718 + admin.req({
720 url: common.domainName + '/api-web/mxgraph/getPageByTree?isDefault=1&access_token=' + accessToken, 719 url: common.domainName + '/api-web/mxgraph/getPageByTree?isDefault=1&access_token=' + accessToken,
721 - type: 'get',  
722 - success: function (res) {  
723 - if (res && res.data) {  
724 - var data = res.data  
725 - var JtopoIds = res.str.split(',');  
726 - cascader({  
727 - elem: "#mxgraph_topoTree",  
728 - data: data,  
729 - triggerType: "change",  
730 - showLastLevels: true,  
731 - success: function (valData, labelData) {  
732 - console.log(valData, labelData);  
733 - var topoId = valData[valData.length - 1]  
734 - if (JtopoIds.indexOf(topoId) !== -1) {  
735 - renderMxgraphView(topoId)  
736 - } 720 + data: {
  721 + }
  722 + }).done(function (res) {
  723 + if (res && res.data) {
  724 + var data = res.data
  725 + var JtopoIds = res.str.split(',');
  726 + cascader({
  727 + elem: "#mxgraph_topoTree",
  728 + data: data,
  729 + triggerType: "change",
  730 + showLastLevels: true,
  731 + success: function (valData, labelData) {
  732 + console.log(valData, labelData);
  733 + var topoId = valData[valData.length - 1]
  734 + if (JtopoIds.indexOf(topoId) !== -1) {
  735 + renderMxgraphView(topoId)
737 } 736 }
738 - });  
739 - } 737 + }
  738 + });
740 } 739 }
741 - })  
742 - 740 + });
743 }); 741 });
744 }); 742 });
@@ -58,7 +58,8 @@ layui.define(['sessions', 'form', 'common'], function (exports) { @@ -58,7 +58,8 @@ layui.define(['sessions', 'form', 'common'], function (exports) {
58 var authKey = getUrlParam("AuthKey"); 58 var authKey = getUrlParam("AuthKey");
59 var authVal = getUrlParam("AuthVal"); 59 var authVal = getUrlParam("AuthVal");
60 60
61 - 61 + localStorage.setItem("AuthKey",authKey);
  62 + localStorage.setItem("AuthVal",authVal);
62 layer.getTokenInfo(setter,sessions,authKey,authVal); 63 layer.getTokenInfo(setter,sessions,authKey,authVal);
63 64
64 // 跳转地址 65 // 跳转地址
@@ -350,4 +350,4 @@ layui.define(["jquery", "laytpl", "layer"], function (exports) { @@ -350,4 +350,4 @@ layui.define(["jquery", "laytpl", "layer"], function (exports) {
350 return thisCas.call(ins); 350 return thisCas.call(ins);
351 }); 351 });
352 }) 352 })
353 -layui.link('../../src/style/css/cascader.css') 353 +layui.link('/monitor-web/src/style/css/cascader.css')
@@ -445,7 +445,6 @@ if (typeof (mxBasePath) != 'undefined' && mxBasePath.length > 0) { @@ -445,7 +445,6 @@ if (typeof (mxBasePath) != 'undefined' && mxBasePath.length > 0) {
445 if (mxBasePath.substring(mxBasePath.length - 1) == '/') { 445 if (mxBasePath.substring(mxBasePath.length - 1) == '/') {
446 mxBasePath = mxBasePath.substring(0, mxBasePath.length - 1); 446 mxBasePath = mxBasePath.substring(0, mxBasePath.length - 1);
447 } 447 }
448 -debugger  
449 mxClient.basePath = mxBasePath; 448 mxClient.basePath = mxBasePath;
450 } else { 449 } else {
451 mxClient.basePath = '.'; 450 mxClient.basePath = '.';
@@ -7,7 +7,8 @@ @@ -7,7 +7,8 @@
7 7
8 */ 8 */
9 9
10 -layui.define(['laytpl', 'layer'], function (exports) { 10 +layui.define(['laytpl', 'layer','common'], function (exports) {
  11 + var common = layui.common;
11 var $ = layui.jquery 12 var $ = layui.jquery
12 , laytpl = layui.laytpl 13 , laytpl = layui.laytpl
13 , layer = layui.layer 14 , layer = layui.layer
@@ -116,8 +117,12 @@ layui.define(['laytpl', 'layer'], function (exports) { @@ -116,8 +117,12 @@ layui.define(['laytpl', 'layer'], function (exports) {
116 // // ? options.headers[request.tokenName] 117 // // ? options.headers[request.tokenName]
117 // // : (layui.data(setter.tableName)[request.tokenName] || ''); 118 // // : (layui.data(setter.tableName)[request.tokenName] || '');
118 // } 119 // }
  120 + let tokenVal = common.getMjToken();
  121 + let tokenKey = common.getMjTokenKey();
119 122
120 - if (request.tokenName) { 123 + if(options.type == 'post'){
  124 + options.headers[tokenKey] = tokenVal;
  125 + } else if (request.tokenName) {
121 let tokenVal = options.data[request.tokenName]; 126 let tokenVal = options.data[request.tokenName];
122 if(!tokenVal || tokenVal == ''){ 127 if(!tokenVal || tokenVal == ''){
123 options.data[request.tokenName] = localStorage.getItem(request.tokenName); 128 options.data[request.tokenName] = localStorage.getItem(request.tokenName);
@@ -33,6 +33,17 @@ layui.define(['xmSelect', 'md5'], function (exports) { @@ -33,6 +33,17 @@ layui.define(['xmSelect', 'md5'], function (exports) {
33 alarmTimer: null,//首页告警刷新定时器 33 alarmTimer: null,//首页告警刷新定时器
34 limit: 50,//全局分页条目数 34 limit: 50,//全局分页条目数
35 limits: [50, 100, 150, 200],//全局分页条目数组 35 limits: [50, 100, 150, 200],//全局分页条目数组
  36 +
  37 + /**
  38 + * 获取墨镜平台的token
  39 + * @returns {string}
  40 + */
  41 + getMjToken : () =>{
  42 + return localStorage.getItem("AuthVal")
  43 + },
  44 + getMjTokenKey : () =>{
  45 + return localStorage.getItem("AuthKey")
  46 + },
36 //base64加密 47 //base64加密
37 Base64: { 48 Base64: {
38 _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 49 _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
@@ -1265,21 +1276,21 @@ layui.define(['xmSelect', 'md5'], function (exports) { @@ -1265,21 +1276,21 @@ layui.define(['xmSelect', 'md5'], function (exports) {
1265 } 1276 }
1266 // End Wang 2021/12/13 19:43 权限列表,如果能从缓存中加载到数据,则获取缓存中的数据 1277 // End Wang 2021/12/13 19:43 权限列表,如果能从缓存中加载到数据,则获取缓存中的数据
1267 var pers = []; 1278 var pers = [];
1268 - $.ajax({  
1269 - type: 'get',  
1270 - url: obj.domainName + '/api-u/users/current?access_token=' + access_token,  
1271 - contentType: "application/json; charset=utf-8",  
1272 - async: false,  
1273 - success: function (data) {  
1274 - pers = data.permissions;  
1275 - $("[permission]").each(function () {  
1276 - var per = $(this).attr("permission");  
1277 - if ($.inArray(per, pers) < 0) {  
1278 - $(this).hide();  
1279 - }  
1280 - });  
1281 - }  
1282 - }); 1279 + // $.ajax({
  1280 + // type: 'get',
  1281 + // url: obj.domainName + '/api-u/users/current?access_token=' + access_token,
  1282 + // contentType: "application/json; charset=utf-8",
  1283 + // async: false,
  1284 + // success: function (data) {
  1285 + // pers = data.permissions;
  1286 + // $("[permission]").each(function () {
  1287 + // var per = $(this).attr("permission");
  1288 + // if ($.inArray(per, pers) < 0) {
  1289 + // $(this).hide();
  1290 + // }
  1291 + // });
  1292 + // }
  1293 + // });
1283 return pers; 1294 return pers;
1284 }, 1295 },
1285 /* pid转children形式 */ 1296 /* pid转children形式 */