Browse Source

fix:文件加密修复

master
prr 6 months ago
parent
commit
61eb09f798
  1. 5
      frontend/src/components/oa/FilePwd.vue
  2. 1
      frontend/src/components/window/IframeFile.vue
  3. 8
      frontend/src/system/core/FileOs.ts
  4. 25
      frontend/src/system/index.ts

5
frontend/src/components/oa/FilePwd.vue

@ -23,7 +23,7 @@
<script lang="ts" setup>
import { BrowserWindow, useSystem } from "@/system";
import { notifyError, notifySuccess } from "@/util/msg";
import { md5 } from "js-md5";
// import { md5 } from "js-md5";
import { ref } from "vue";
import { getSystemConfig, setSystemKey } from "@/system/config";
const window: BrowserWindow | undefined = inject("browserWindow");
@ -37,7 +37,8 @@ async function setFilePwd() {
) {
const path = window?.config.path || "";
const header = {
pwd: getSystemConfig().userType == 'person' ? md5(filePwd.value) : filePwd.value
pwd: filePwd.value
// pwd: getSystemConfig().userType == 'person' ? md5(filePwd.value) : filePwd.value
};
const file = await sys.fs.readFile(path);
if (file === false) return;

1
frontend/src/components/window/IframeFile.vue

@ -9,7 +9,6 @@ import { base64ToBuffer, isBase64 } from "@/util/file";
import { isShareFile } from "@/util/sharePath.ts";
import { inject, onMounted, onUnmounted, ref, toRaw } from "vue";
import { askAi } from "@/hook/useAi";
import { md5 } from "js-md5";
const SP = getSplit();
const sys: any = inject<System>("system");

8
frontend/src/system/core/FileOs.ts

@ -116,15 +116,13 @@ export async function handleExists(path: string): Promise<any> {
export async function handleReadFile(path: string, header?: { [key: string]: string }): Promise<any> {
const userType = getSystemConfig().userType
let head = {}
//console.log('read header:', header);
if (userType == 'member') {
head = {
pwd: header?.pwd || ''
}
} else if (header) {
head = {
pwd: header?.pwd === '' ? '' : md5(header?.pwd),
pwd: header?.pwd !== '' ? md5(header?.pwd) : ''
}
}
const res = await fetchGet(`${API_BASE_URL}/readfile?path=${encodeURIComponent(path)}`, head);
@ -360,7 +358,7 @@ export const useOsFile = () => {
if (response && response.code === 0) {
return response.data;
}
if (response && response.Error == 'needPwd') {
if (response && response.error == 'needPwd') {
return response
}
return false;
@ -418,8 +416,6 @@ export const useOsFile = () => {
}
}
}
console.log('请求头:', head);
const response = await handleWriteFile(path, content, head);
if (response) {
return response;

25
frontend/src/system/index.ts

@ -460,29 +460,22 @@ export class System {
const header = {
pwd: ''
}
//判断文件是否需要输入密码
if (fileStat.isPwd && path.indexOf('.exe') === -1) {
// 读取文件内容
let fileContent = await this.fs.readFile(path, header);
// 改文件需要输入密码
if (fileContent && fileContent.error == 'needPwd') {
const temp = await Dialog.showInputBox()
if (temp.response !== 1) {
return
}
// header.salt = filePwd.file.salt || 'vIf_wIUedciAd0nTm6qjJA=='
header.pwd = temp?.inputPwd || ''
}
// 读取文件内容
const fileContent = await this.fs.readFile(path, header);
// if (fileContent === false && fileStat.isPwd) {
// notifyError('密码错误')
// return
// }
if (fileContent && fileContent.error == 'neepPwd') {
const temp = await Dialog.showInputBox()
if (temp.response !== 1) {
header.pwd = temp?.inputPwd ? temp?.inputPwd : ''
const reOpen = await this.fs.readFile(path, header);
if (reOpen && reOpen.error == 'needPwd') {
notifyError(reOpen.message)
return
}
// header.salt = filePwd.file.salt || 'vIf_wIUedciAd0nTm6qjJA=='
header.pwd = temp?.inputPwd ? md5(temp?.inputPwd) : ''
//const reOpen = await this.fs.readFile(path, header);
fileContent = reOpen
}
//用户文件加密密码存储
if (fileStat.isPwd) {

Loading…
Cancel
Save