diff --git a/frontend/src/components/window/IframeFile.vue b/frontend/src/components/window/IframeFile.vue
index 417277b..d951031 100644
--- a/frontend/src/components/window/IframeFile.vue
+++ b/frontend/src/components/window/IframeFile.vue
@@ -1,13 +1,13 @@
-
+
diff --git a/frontend/src/system/core/FileOs.ts b/frontend/src/system/core/FileOs.ts
index 8104550..ce971f4 100644
--- a/frontend/src/system/core/FileOs.ts
+++ b/frontend/src/system/core/FileOs.ts
@@ -13,16 +13,6 @@ export async function handleReadDir(path: any): Promise {
}
return await res.json();
}
-// 查看分享文件
-export async function handleReadShareDir(path: string): Promise {
- // const url = path.indexOf('/F/myshare') !== -1 ? 'sharemylist' : 'sharelist'
- const url = 'sharelist'
- const res = await fetchGet(`${API_BASE_URL}/${url}`);
- if (!res.ok) {
- return false;
- }
- return await res.json();
-}
export async function handleStat(path: string): Promise {
const res = await fetchGet(`${API_BASE_URL}/stat?path=${encodeURIComponent(path)}`);
if (!res.ok) {
@@ -74,7 +64,7 @@ export async function handleReadFile(path: string, header?: any): Promise {
pwd: header.pwd !== '' ? md5(header.pwd) : ''
}
}
-
+
const res = await fetchGet(`${API_BASE_URL}/readfile?path=${encodeURIComponent(path)}`, head);
if (!res.ok) {
return false;
@@ -99,17 +89,8 @@ export async function handleClear(): Promise {
}
export async function handleRename(oldPath: string, newPath: string): Promise {
- const url = isShareFile(oldPath) ? 'sharerename' : 'rename'
- let params = ''
- if (isShareFile(oldPath)) {
- const optionID = oldPath.indexOf('/F/myshare') === 0 ? 0 : 1
- oldPath = turnServePath(oldPath)
- newPath = turnServePath(newPath)
- params = `oldpath=${encodeURIComponent(oldPath)}&newpath=${encodeURIComponent(newPath)}&userID=${getSystemConfig()?.userInfo.id}&optionID=${optionID}`
- } else {
- params = `oldPath=${encodeURIComponent(oldPath)}&newPath=${encodeURIComponent(newPath)}`
- }
- const res = await fetchGet(`${API_BASE_URL}/${url}?${params}`);
+ let params = `oldPath=${encodeURIComponent(oldPath)}&newPath=${encodeURIComponent(newPath)}`
+ const res = await fetchGet(`${API_BASE_URL}/rename?${params}`);
if (!res.ok) {
return false;
}
@@ -170,8 +151,8 @@ export function getFormData(content: any) {
export async function handleWriteFile(filePath: string, content: any, header?: { [key: string]: any }): Promise {
//console.log(content)
const formData = getFormData(content);
- const head:any = header ? { ...header } : {}
- if(head.pwd && head.pwd !== ''){
+ const head: any = header ? { ...header } : {}
+ if (head.pwd && head.pwd !== '') {
head.pwd = md5(head.pwd)
}
const url = `${API_BASE_URL}/writefile?path=${encodeURIComponent(filePath)}`;
@@ -228,22 +209,6 @@ export async function handleUnZip(path: string): Promise {
}
export const useOsFile = () => {
return {
- // 分享
- async sharedir(path: string) {
- // const fun = isRootShare(path) ? handleReadShareDir : handleShareDir
- const response = await handleReadShareDir(path);
- if (response && response.data) {
- const result = response.data.map((item: { [key: string]: OsFile }) => {
- item.fi.isShare = true
- item.fi.parentPath = turnLocalPath(item.fi.parentPath, path)
- item.fi.path = turnLocalPath(item.fi.path, path)
- //item.fi.titleName = turnLocalPath(item.fi.titleName, path)
- return item.fi
- })
- return result
- }
- return [];
- },
async readdir(path: string) {
const response = await handleReadDir(path);
@@ -253,8 +218,6 @@ export const useOsFile = () => {
return [];
},
async stat(path: string) {
- path.indexOf('/F/myshare') == 0 ? (path = turnServePath(path)) : ''
-
const response = await handleStat(path);
if (response && response.data) {
return response.data;
@@ -281,8 +244,8 @@ export const useOsFile = () => {
const response = await handleReadFile(path, header);
if (response && response.code === 0) {
return response.data;
- }
- if (response && response.code == -1 && response.message == '加密文件,需要密码') {
+ }
+ if (response && response.code == -1) {
return response
}
return false;
@@ -325,22 +288,11 @@ export const useOsFile = () => {
return false;
},
async writeFile(path: string, content: string | Blob, header?: { [key: string]: any }) {
- let head = {}
-
- if (header) {
- head = { ...header }
- } else {
- const filePwd = getSystemConfig().fileInputPwd
- const pos = filePwd.findIndex((item: any) => item.path == path)
- //console.log('路径:', path, pos, filePwd);
- const userType = getSystemConfig().userType
- if (pos !== -1) {
- head = {
- pwd: userType == 'person' ? md5(filePwd[pos].pwd) : filePwd[pos].pwd
- }
- }
- }
- const response = await handleWriteFile(path, content, head);
+ // const head: any = header ? { ...header } : {}
+ // if (head.pwd && head.pwd !== '') {
+ // head.pwd = md5(head.pwd)
+ // }
+ const response = await handleWriteFile(path, content, header);
if (response) {
return response;
}
diff --git a/frontend/src/system/index.ts b/frontend/src/system/index.ts
index 67c9aff..d9f8e7b 100644
--- a/frontend/src/system/index.ts
+++ b/frontend/src/system/index.ts
@@ -454,6 +454,7 @@ export class System {
/**打开os 文件系统的文件 */
async openFile(path: string) {
const fileStat = await this.fs.stat(path)
+ //console.log(fileStat)
if (!fileStat) {
throw new Error('文件不存在');
}
@@ -469,36 +470,24 @@ export class System {
// 读取文件内容
let fileContent = await this.fs.readFile(path, header);
// 改文件需要输入密码
- if (fileContent && fileContent.code == -1 && fileContent.message == '加密文件,需要密码') {
+ if (fileContent && fileContent.code == -1 && fileContent.error == 'needPwd') {
const temp = await Dialog.showInputBox()
if (temp.response !== 1) {
return
}
- // header.salt = filePwd.file.salt || 'vIf_wIUedciAd0nTm6qjJA=='
header.pwd = temp?.inputPwd ? temp?.inputPwd : ''
const reOpen = await this.fs.readFile(path, header);
- if (reOpen == false) {
+ //console.log(reOpen)
+ if (reOpen === false || reOpen.code === -1) {
notifyError("文件密码错误")
return
}
fileContent = reOpen
}
- //用户文件加密密码存储
- if (fileStat.isPwd) {
- let fileInputPwd = getSystemConfig().fileInputPwd
- const pos = fileInputPwd.findIndex((item: any) => item.path == path)
- if (pos !== -1) {
- fileInputPwd[pos].pwd = header.pwd
- } else {
- fileInputPwd.push({
- path: path,
- pwd: header.pwd
- })
- }
- setSystemKey('fileInputPwd', fileInputPwd)
- }
+ //console.log(fileStat)
// 从_fileOpenerMap中获取文件扩展名对应的函数并调用
const fileName = extname(fileStat?.name || '') || 'link'
+ //console.log(fileName,fileContent)
this._flieOpenerMap
.get(fileName)
?.func.call(this, path, fileContent || '');