This commit is contained in:
parent
0e295b74ea
commit
79a2663f71
|
|
@ -102,9 +102,10 @@ export default {
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
getSystemConfigApi();
|
||||||
this.$store.dispatch('LogOut').then(() => {
|
this.$store.dispatch('LogOut').then(() => {
|
||||||
location.href = process.env.VUE_APP_ENV === 'production'? '/smart-archiving/index': '/index'
|
location.href = process.env.VUE_APP_ENV === 'production'? '/smart-archiving/index': '/index'
|
||||||
// getSystemConfigApi();
|
|
||||||
})
|
})
|
||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,36 +10,29 @@ import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
||||||
import { generateRequestSignature } from '@/utils/crypto-js'
|
import { generateRequestSignature } from '@/utils/crypto-js'
|
||||||
|
|
||||||
|
|
||||||
const encryptRequestFlag = getConfig('encryptRequest')
|
// 动态读取配置:每次从 sessionStorage 解密,保证实时性
|
||||||
const encryptResponseFlag = getConfig('encryptResponse')
|
function getConfigFlag(code) {
|
||||||
const checkIntegrityFlag = getConfig('checkIntegrity')
|
const enc = sessionStorage.getItem('systemConfig')
|
||||||
const replayAttackFlag = getConfig('replayAttack')
|
if (!enc) return false
|
||||||
console.error(encryptRequestFlag);
|
try {
|
||||||
console.error(encryptResponseFlag);
|
const arr = JSON.parse(decryptWithSM4(enc))
|
||||||
console.error(checkIntegrityFlag);
|
const item = arr.find(x => x.configCode === code)
|
||||||
console.error(replayAttackFlag);
|
return item ? item.useStatus === '0' : false
|
||||||
|
} catch (e) {
|
||||||
const systemConfig = {
|
return false
|
||||||
requestConfig: {
|
|
||||||
encryptRequest: process.env.VUE_APP_ENV === 'production' ? encryptRequestFlag : encryptRequestFlag,
|
|
||||||
checkIntegrity: process.env.VUE_APP_ENV === 'production' ? checkIntegrityFlag : checkIntegrityFlag,
|
|
||||||
encryptResponse: process.env.VUE_APP_ENV === 'production' ? encryptResponseFlag : encryptResponseFlag,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
function getConfig(value) {
|
|
||||||
|
|
||||||
let config = sessionStorage.getItem('systemConfig');
|
|
||||||
if(config){
|
|
||||||
const decryptArr = JSON.parse(decryptWithSM4(config));
|
|
||||||
const result = decryptArr.find(item => item.configCode === value);
|
|
||||||
console.error(result);
|
|
||||||
return result.useStatus === '0';
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSecurityFlags() {
|
||||||
|
return {
|
||||||
|
encryptRequest: getConfigFlag('encryptRequest'),
|
||||||
|
checkIntegrity: getConfigFlag('checkIntegrity'),
|
||||||
|
encryptResponse: getConfigFlag('encryptResponse'),
|
||||||
|
replayAttack: getConfigFlag('replayAttack'),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let downloadLoadingInstance
|
let downloadLoadingInstance
|
||||||
export let isRelogin = { show: false }
|
export let isRelogin = { show: false }
|
||||||
|
|
@ -65,17 +58,23 @@ service.interceptors.request.use(
|
||||||
const headers = config.headers || {}
|
const headers = config.headers || {}
|
||||||
const {
|
const {
|
||||||
isToken = true,
|
isToken = true,
|
||||||
encryptRequest = process.env.NODE_ENV === 'development' ? encryptRequestFlag : encryptRequestFlag,
|
encryptRequest = true,
|
||||||
checkIntegrity = process.env.NODE_ENV === 'development' ? checkIntegrityFlag : checkIntegrityFlag,
|
checkIntegrity = true,
|
||||||
encryptResponse = process.env.NODE_ENV === 'development' ? encryptResponseFlag : encryptResponseFlag,
|
encryptResponse = true,
|
||||||
repeatSubmit = false,
|
repeatSubmit = false,
|
||||||
skipReplayProtection = false
|
skipReplayProtection = false
|
||||||
} = headers
|
} = headers
|
||||||
|
|
||||||
|
// 读取全局安全开关(动态)并与请求头开关进行“与”组合
|
||||||
|
const flags = getSecurityFlags()
|
||||||
|
const useEncryptRequest = flags.encryptRequest && encryptRequest
|
||||||
|
const useCheckIntegrity = flags.checkIntegrity && checkIntegrity
|
||||||
|
const useEncryptResponse = flags.encryptResponse && encryptResponse
|
||||||
|
|
||||||
// 设置请求头
|
// 设置请求头
|
||||||
config.headers['encryptRequest'] = systemConfig.requestConfig.encryptRequest && encryptRequest ? 'true' : 'false'
|
config.headers['encryptRequest'] = useEncryptRequest ? 'true' : 'false'
|
||||||
config.headers['checkIntegrity'] = systemConfig.requestConfig.checkIntegrity && checkIntegrity ? 'true' : 'false'
|
config.headers['checkIntegrity'] = useCheckIntegrity ? 'true' : 'false'
|
||||||
config.headers['encryptResponse'] = systemConfig.requestConfig.encryptResponse && encryptResponse ? 'true' : 'false'
|
config.headers['encryptResponse'] = useEncryptResponse ? 'true' : 'false'
|
||||||
|
|
||||||
const isRepeatSubmit = repeatSubmit
|
const isRepeatSubmit = repeatSubmit
|
||||||
|
|
||||||
|
|
@ -85,7 +84,7 @@ service.interceptors.request.use(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加防重放签名头(如果不是跳过重放保护的请求)
|
// 添加防重放签名头(如果不是跳过重放保护的请求)
|
||||||
if (!skipReplayProtection && replayAttackFlag) {
|
if (!skipReplayProtection && flags.replayAttack) {
|
||||||
try {
|
try {
|
||||||
const userId = getUserId()
|
const userId = getUserId()
|
||||||
const userSecret = getSecretKey()
|
const userSecret = getSecretKey()
|
||||||
|
|
@ -131,7 +130,7 @@ service.interceptors.request.use(
|
||||||
// GET 请求处理 - 统一处理加密逻辑
|
// GET 请求处理 - 统一处理加密逻辑
|
||||||
if (config.method === 'get' && config.params) {
|
if (config.method === 'get' && config.params) {
|
||||||
// 如果需要加密 GET 请求
|
// 如果需要加密 GET 请求
|
||||||
if (systemConfig.requestConfig.encryptRequest && encryptRequest) {
|
if (useEncryptRequest) {
|
||||||
// 将参数转换为查询字符串
|
// 将参数转换为查询字符串
|
||||||
let paramsString = tansParams(config.params)
|
let paramsString = tansParams(config.params)
|
||||||
|
|
||||||
|
|
@ -176,7 +175,7 @@ service.interceptors.request.use(
|
||||||
// 处理 multipart/form-data: 仅加密非二进制字段(如 params),忽略文件本身
|
// 处理 multipart/form-data: 仅加密非二进制字段(如 params),忽略文件本身
|
||||||
const isFormData = (typeof FormData !== 'undefined') && (config.data instanceof FormData)
|
const isFormData = (typeof FormData !== 'undefined') && (config.data instanceof FormData)
|
||||||
if (isFormData) {
|
if (isFormData) {
|
||||||
if (systemConfig.requestConfig.encryptRequest && encryptRequest) {
|
if (useEncryptRequest) {
|
||||||
const newForm = new FormData()
|
const newForm = new FormData()
|
||||||
// 遍历原始 FormData,二进制原样,文本字段进行加密
|
// 遍历原始 FormData,二进制原样,文本字段进行加密
|
||||||
for (const [key, value] of config.data.entries()) {
|
for (const [key, value] of config.data.entries()) {
|
||||||
|
|
@ -207,7 +206,7 @@ service.interceptors.request.use(
|
||||||
let data = typeof config.data === 'object' ? JSON.stringify(config.data) : config.data
|
let data = typeof config.data === 'object' ? JSON.stringify(config.data) : config.data
|
||||||
if (contentType && contentType.includes('application/json') && typeof data !== 'undefined') {
|
if (contentType && contentType.includes('application/json') && typeof data !== 'undefined') {
|
||||||
// 加密数据
|
// 加密数据
|
||||||
if (systemConfig.requestConfig.encryptRequest && encryptRequest) {
|
if (useEncryptRequest) {
|
||||||
config.data = encryptWithSM4(data + '|' + hashWithSM3AndSalt(data))
|
config.data = encryptWithSM4(data + '|' + hashWithSM3AndSalt(data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ export default {
|
||||||
},
|
},
|
||||||
// 获取选中的节点
|
// 获取选中的节点
|
||||||
async getTreeData(nodeId) {
|
async getTreeData(nodeId) {
|
||||||
this.checkTreeData = [];
|
// this.checkTreeData = [];
|
||||||
const res = await getTransferApplyFilesApi({ proId: this.form.proId, id: nodeId });
|
const res = await getTransferApplyFilesApi({ proId: this.form.proId, id: nodeId });
|
||||||
if (Array.isArray(res.data) && res.data.length > 0) {
|
if (Array.isArray(res.data) && res.data.length > 0) {
|
||||||
res.data.map(item => {
|
res.data.map(item => {
|
||||||
|
|
@ -314,7 +314,10 @@ export default {
|
||||||
fileSourceId: item.fileId,
|
fileSourceId: item.fileId,
|
||||||
filePath: item.filePath
|
filePath: item.filePath
|
||||||
};
|
};
|
||||||
|
const exists = this.checkTreeData.some(f => f.proFilesContentsId === newFile.proFilesContentsId);
|
||||||
|
if (!exists) {
|
||||||
this.checkTreeData.push(newFile);
|
this.checkTreeData.push(newFile);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue