加解密修改

This commit is contained in:
cwchen 2025-09-28 13:23:25 +08:00
parent 403e4b6335
commit 155bc1e5c6
8 changed files with 60 additions and 78 deletions

View File

@ -1,9 +1,9 @@
import request from '@/utils/request'
// 档案移交申请列表
export function getTransferApplyListApi(params) {
export function getTransferRecordListApi(params) {
return request({
url: '/smartArchives/transferApply/getTransferApplyList',
url: '/smartArchives/transferRecord/getTransferRecordList',
method: 'GET',
params: params,
})
@ -17,66 +17,3 @@ export function saveTransferApplyApi(data) {
data
})
}
// 编辑档案移交申请
export function editTransferApplyApi(data) {
return request({
url: '/smartArchives/transferApply/editTransferApply',
method: 'POST',
data
})
}
// 档案移交申请详情
export function getTransferApplyApi(params) {
return request({
url: '/smartArchives/transferApply/getTransferApply',
method: 'GET',
params: params
})
}
// 档案移交申请-列表详情
export function getTransferApplyFilesByApplyIdApi(params) {
return request({
url: '/smartArchives/transferApply/getTransferApplyFilesByApplyId',
method: 'GET',
params: params
})
}
// 删除档案移交申请
export function delTransferApplyApi(data) {
return request({
url: '/smartArchives/transferApply/delTransferApply',
method: 'POST',
data
})
}
// 已移交确认工程下拉选
export async function getProSelectApi(data) {
return await request({
url: '/smartArchives/transferApply/getProSelect',
method: 'GET',
data
})
}
// 获取档案目录树
export function getFileManageTreeApi(params) {
return request({
url: '/smartArchives/fileManage/getFileManageTree',
method: 'get',
params:params,
})
}
// 获取移交档案文件
export function getTransferApplyFilesApi(params) {
return request({
url: '/smartArchives/transferApply/getTransferApplyFiles',
method: 'get',
params:params,
})
}

View File

@ -35,3 +35,14 @@ export function getListAPI(data) {
params: data,
})
}
export function getNoAuthConfig(data) {
return request({
url: '/smartArchives/sys/config/getConfig',
method: 'GET',
params: data,
headers: {
skipReplayProtection: true
},
})
}

View File

@ -36,7 +36,7 @@ $base-sub-menu-background:#000c17;
$base-sub-menu-hover:#001528;
*/
$base-sidebar-width: 320px;
$base-sidebar-width: 300px;
// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass

View File

@ -103,6 +103,7 @@ export default {
}).then(() => {
this.$store.dispatch('LogOut').then(() => {
location.href = process.env.VUE_APP_ENV === 'production'? '/smart-archiving/index': '/index'
sessionStorage.removeItem('systemConfig')
})
}).catch(() => {})
}

View File

@ -17,7 +17,6 @@ import { download } from '@/utils/request'
import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data"
import { getConfigKey } from "@/api/system/config"
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/bonus"
// 分页组件
import Pagination from "@/components/Pagination"
@ -55,7 +54,7 @@ Vue.component('Editor', Editor)
Vue.component('FileUpload', FileUpload)
Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview)
import { getConfigKey } from '@/utils/systemConfig' // 引入get方法
Vue.use(directive)
Vue.use(plugins)
DictData.install()

View File

@ -9,14 +9,34 @@ import { saveAs } from 'file-saver'
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' ? true : true,
checkIntegrity: process.env.VUE_APP_ENV === 'production' ? true : true,
encryptResponse: process.env.VUE_APP_ENV === 'production' ? true : true,
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);
return result.useStatus === '0';
}else{
return false;
}
}
let downloadLoadingInstance
export let isRelogin = { show: false }
@ -41,9 +61,9 @@ service.interceptors.request.use(
const headers = config.headers || {}
const {
isToken = true,
encryptRequest = process.env.NODE_ENV === 'development' ? true : true,
checkIntegrity = process.env.NODE_ENV === 'development' ? true : true,
encryptResponse = process.env.NODE_ENV === 'development' ? true : 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,
repeatSubmit = false,
skipReplayProtection = false
} = headers
@ -61,7 +81,7 @@ service.interceptors.request.use(
}
// 添加防重放签名头(如果不是跳过重放保护的请求)
if (!skipReplayProtection) {
if (!skipReplayProtection && replayAttackFlag) {
try {
const userId = getUserId()
const userSecret = getSecretKey()
@ -243,7 +263,6 @@ service.interceptors.response.use(
) {
return res.data
}
console.log(msg);
// 账号在其他设备登录的安全提示(基于后端返回信息关键词识别)
const otherDeviceLogin = /multipleDeviceLogin/.test(String(msg || ''))

10
src/utils/systemConfig.js Normal file
View File

@ -0,0 +1,10 @@
import { getNoAuthConfig } from '@/api/system/setting';
import {encryptWithSM4} from '@/utils/sm';
export function getSystemConfigApi() {
getNoAuthConfig().then(res => {
sessionStorage.setItem('systemConfig', encryptWithSM4(JSON.stringify(res.data)));
}).catch(error => {
console.error('Failed to fetch config:', error);
});
}

View File

@ -67,6 +67,7 @@
import { getCodeImg } from "@/api/login"
import Cookies from "js-cookie"
import { encrypt, decrypt } from '@/utils/jsencrypt'
import { getSystemConfigApi } from '@/utils/systemConfig'
export default {
name: "Login",
@ -107,12 +108,16 @@ export default {
}
},
created() {
this.getSystemConfig()
this.getCode()
this.getCookie()
},
methods: {
getCode() {
getCodeImg().then(res => {
async getSystemConfig(){
await getSystemConfigApi();
},
async getCode() {
await getCodeImg().then(res => {
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
if (this.captchaEnabled) {
this.codeUrl = "data:image/gif;base64," + res.img