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