Commit 5ac17e91d2985e99ab7d6ee8f41b2d21ef73c009

Authored by zhangdaiscott
1 parent 152dbccd

VUEN-410【签名改造】 X-TIMESTAMP牵扯

ant-design-vue-jeecg/src/api/manage.js
... ... @@ -16,7 +16,9 @@ export default api
16 16 export function postAction(url,parameter) {
17 17 let sign = signMd5Utils.getSign(url, parameter);
18 18 //将签名和时间戳,添加在请求接口 Header
19   - let signHeader = {"X-Sign": sign,"X-TIMESTAMP": signMd5Utils.getDateTimeToString()};
  19 + // update-begin--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
  20 + let signHeader = {"X-Sign": sign,"X-TIMESTAMP": signMd5Utils.getTimestamp()};
  21 + // update-end--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
20 22  
21 23 return axios({
22 24 url: url,
... ... @@ -30,7 +32,9 @@ export function postAction(url,parameter) {
30 32 export function httpAction(url,parameter,method) {
31 33 let sign = signMd5Utils.getSign(url, parameter);
32 34 //将签名和时间戳,添加在请求接口 Header
33   - let signHeader = {"X-Sign": sign,"X-TIMESTAMP": signMd5Utils.getDateTimeToString()};
  35 + // update-begin--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
  36 + let signHeader = {"X-Sign": sign,"X-TIMESTAMP": signMd5Utils.getTimestamp()};
  37 + // update-end--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
34 38  
35 39 return axios({
36 40 url: url,
... ... @@ -53,7 +57,9 @@ export function putAction(url,parameter) {
53 57 export function getAction(url,parameter) {
54 58 let sign = signMd5Utils.getSign(url, parameter);
55 59 //将签名和时间戳,添加在请求接口 Header
56   - let signHeader = {"X-Sign": sign,"X-TIMESTAMP": signMd5Utils.getDateTimeToString()};
  60 + // update-begin--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
  61 + let signHeader = {"X-Sign": sign,"X-TIMESTAMP": signMd5Utils.getTimestamp()};
  62 + // update-end--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
57 63  
58 64 return axios({
59 65 url: url,
... ... @@ -120,13 +126,23 @@ export function saveService(parameter) {
120 126 * @param parameter
121 127 * @returns {*}
122 128 */
123   -export function downFile(url,parameter){
124   - return axios({
125   - url: url,
126   - params: parameter,
127   - method:'get' ,
128   - responseType: 'blob'
129   - })
  129 +export function downFile(url,parameter, method='get'){
  130 + if(method=='get'){
  131 + return axios({
  132 + url: url,
  133 + params: parameter,
  134 + method: method ,
  135 + responseType: 'blob'
  136 + })
  137 + }else{
  138 + return axios({
  139 + url: url,
  140 + method: method,
  141 + data: parameter,
  142 + responseType: 'blob'
  143 + })
  144 + }
  145 +
130 146 }
131 147  
132 148 /**
... ...
ant-design-vue-jeecg/src/utils/encryption/signMd5Utils.js
... ... @@ -104,23 +104,35 @@ export default class signMd5Utils {
104 104 return paramStr;
105 105 };
106 106  
107   - static getDateTimeToString() {
108   - const date_ = new Date()
109   - const year = date_.getFullYear()
110   - let month = date_.getMonth() + 1
111   - let day = date_.getDate()
112   - if (month < 10) month = '0' + month
113   - if (day < 10) day = '0' + day
114   - let hours = date_.getHours()
115   - let mins = date_.getMinutes()
116   - let secs = date_.getSeconds()
117   - const msecs = date_.getMilliseconds()
118   - if (hours < 10) hours = '0' + hours
119   - if (mins < 10) mins = '0' + mins
120   - if (secs < 10) secs = '0' + secs
121   - if (msecs < 10) secs = '0' + msecs
122   - return year + '' + month + '' + day + '' + hours + '' + mins + '' + secs
  107 + /**
  108 + * 接口签名用 生成header中的时间戳
  109 + * @returns {number}
  110 + */
  111 + static getTimestamp(){
  112 + return new Date().getTime()
123 113 }
  114 +
  115 + // /**
  116 + // * 获取客户端时间(签名参数 X_TIMESTAMP)
  117 + // * @returns {string}
  118 + // */
  119 + // static getDateTimeToString() {
  120 + // const date_ = new Date()
  121 + // const year = date_.getFullYear()
  122 + // let month = date_.getMonth() + 1
  123 + // let day = date_.getDate()
  124 + // if (month < 10) month = '0' + month
  125 + // if (day < 10) day = '0' + day
  126 + // let hours = date_.getHours()
  127 + // let mins = date_.getMinutes()
  128 + // let secs = date_.getSeconds()
  129 + // const msecs = date_.getMilliseconds()
  130 + // if (hours < 10) hours = '0' + hours
  131 + // if (mins < 10) mins = '0' + mins
  132 + // if (secs < 10) secs = '0' + secs
  133 + // if (msecs < 10) secs = '0' + msecs
  134 + // return year + '' + month + '' + day + '' + hours + '' + mins + '' + secs
  135 + // }
124 136 // true:数值型的,false:非数值型
125 137 static myIsNaN(value) {
126 138 return typeof value === 'number' && !isNaN(value);
... ...