Authored by 鲁尚清

【无】vue页面给ajax请求增加headers的参数(当前页面的title的值,window.top.location.hash)

@@ -6,6 +6,7 @@ Promise.all([ @@ -6,6 +6,7 @@ Promise.all([
6 import('./app.js' + ver), 6 import('./app.js' + ver),
7 import('./script/global.js' + ver), 7 import('./script/global.js' + ver),
8 import('./script/http.js' + ver), 8 import('./script/http.js' + ver),
  9 + import('./script/mixin.js' + ver),
9 ]).then((res) => { 10 ]).then((res) => {
10 // element plus 切换语言 11 // element plus 切换语言
11 // https://element-plus.org/zh-CN/guide/i18n.html#configprovider 12 // https://element-plus.org/zh-CN/guide/i18n.html#configprovider
@@ -71,8 +72,33 @@ Promise.all([ @@ -71,8 +72,33 @@ Promise.all([
71 // } 72 // }
72 // } 73 // }
73 // }) 74 // })
  75 + //start lsq 设置ajax请求增加headers参数 2022-09-20
  76 + let setAjaxData=(val)=>{
  77 + let p = window.top.location.hash;
  78 + if (p) {
  79 + let arr = p.split('#/');
  80 + if(arr && arr.length>1){
  81 + let menuPath=arr[1];
  82 + //title的值
  83 + let nameText=$(window.top.document).find("[lay-id='/"+menuPath+"'] span").text();
  84 + if(val){
  85 + nameText=val;
  86 + }
  87 + let name=encodeURIComponent(nameText)
  88 + $.ajaxSetup({
  89 + headers:{
  90 + menuPath:menuPath,
  91 + elementName:name
  92 + }
74 93
  94 + });
  95 + }
  96 +
  97 + }
  98 + }
  99 + setAjaxData();
  100 + //end lsq 2022-09-20
75 app.config.globalProperties.$global = res[3].default 101 app.config.globalProperties.$global = res[3].default
76 app.config.globalProperties.$http = res[4].default 102 app.config.globalProperties.$http = res[4].default
77 app.mount('#app'); // 挂载Vue的app实例 103 app.mount('#app'); // 挂载Vue的app实例
78 -}) 104 +})