发布岗位提示
This commit is contained in:
@@ -35,17 +35,23 @@ const encryptPathPrefixes = [
|
||||
'/app/phoneLogin',
|
||||
];
|
||||
|
||||
const noEncryptSet = new Set([
|
||||
'DELETE:/app/job/applyJobCencal',
|
||||
]);
|
||||
|
||||
const isEncryptNeeded = (method, url) => {
|
||||
const key = `${method.toUpperCase()}:${url}`;
|
||||
const pureUrl = url.split('?')[0];
|
||||
const key = `${method.toUpperCase()}:${pureUrl}`;
|
||||
if (noEncryptSet.has(key)) return false;
|
||||
if (needToEncryptSet.has(key)) return true;
|
||||
for (const encryptKey of needToEncryptSet) {
|
||||
const [encryptMethod, encryptUrl] = encryptKey.split(':');
|
||||
if (encryptMethod === method.toUpperCase() && url.startsWith(encryptUrl.split('/{')[0])) {
|
||||
if (encryptMethod === method.toUpperCase() && pureUrl.startsWith(encryptUrl.split('/{')[0])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (const prefix of encryptPathPrefixes) {
|
||||
if (url.startsWith(prefix)) {
|
||||
if (pureUrl.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +61,7 @@ const isEncryptNeeded = (method, url) => {
|
||||
const encryptRequestData = (data) => {
|
||||
const jsonData = JSON.stringify(data);
|
||||
// const jsonData = JSON.stringify({a: '1'});
|
||||
// console.log('[请求] 加密前:', jsonData)
|
||||
console.log('[请求] 加密前:', jsonData)
|
||||
return {
|
||||
encrypted: true,
|
||||
encryptedData: sm4Encrypt(config.sm4Config.key, jsonData),
|
||||
@@ -175,6 +181,8 @@ export function createRequest(url, data = {}, method = 'GET', loading = false, h
|
||||
// 响应拦截
|
||||
if (resData.statusCode === 200) {
|
||||
const responseData = handleResponseData(resData.data)
|
||||
console.log('[请求] 接口地址:', config.baseUrl + url)
|
||||
console.log('[请求] 解密后数据:', responseData)
|
||||
const {
|
||||
code,
|
||||
msg
|
||||
|
||||
Reference in New Issue
Block a user