From 939565dddd52562a151b1b3115da2fb6e3c06792 Mon Sep 17 00:00:00 2001
From: prr <3099672575@qq.com>
Date: Tue, 29 Oct 2024 18:05:46 +0800
Subject: [PATCH] =?UTF-8?q?test:=E6=96=87=E4=BB=B6=E5=88=86=E4=BA=AB?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frontend/components.d.ts | 3 +-
frontend/src/components/builtin/FileList.vue | 4 +-
frontend/src/components/builtin/FileProps.vue | 19 +-
frontend/src/components/builtin/FileTree.vue | 29 ++-
.../src/components/builtin/ShareFileTree.vue | 239 ------------------
frontend/src/components/computer/Computer.vue | 11 +-
frontend/src/components/oa/ShareFiles.vue | 4 +-
.../src/components/setting/SetFilePwd.vue | 30 +++
frontend/src/components/setting/SetSystem.vue | 1 +
frontend/src/hook/useComputer.ts | 4 +-
frontend/src/hook/useContextMenu.ts | 4 -
frontend/src/i18n/lang/zh.json | 1 +
frontend/src/system/core/FileOs.ts | 51 ++--
frontend/src/system/core/FileSystem.ts | 1 +
frontend/src/system/index.ts | 4 +-
frontend/src/util/sharePath.ts | 11 +
16 files changed, 120 insertions(+), 296 deletions(-)
delete mode 100644 frontend/src/components/builtin/ShareFileTree.vue
create mode 100644 frontend/src/components/setting/SetFilePwd.vue
create mode 100644 frontend/src/util/sharePath.ts
diff --git a/frontend/components.d.ts b/frontend/components.d.ts
index 35ff343..f3875bb 100644
--- a/frontend/components.d.ts
+++ b/frontend/components.d.ts
@@ -55,7 +55,6 @@ declare module 'vue' {
ElCarousel: typeof import('element-plus/es')['ElCarousel']
ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
- ElCion: typeof import('element-plus/es')['ElCion']
ElCol: typeof import('element-plus/es')['ElCol']
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
ElContainer: typeof import('element-plus/es')['ElContainer']
@@ -130,12 +129,12 @@ declare module 'vue' {
Screenshort: typeof import('./src/components/taskbar/Screenshort.vue')['default']
SetAccount: typeof import('./src/components/setting/SetAccount.vue')['default']
SetCustom: typeof import('./src/components/setting/SetCustom.vue')['default']
+ SetFilePwd: typeof import('./src/components/setting/SetFilePwd.vue')['default']
SetLang: typeof import('./src/components/setting/SetLang.vue')['default']
SetSystem: typeof import('./src/components/setting/SetSystem.vue')['default']
Setting: typeof import('./src/components/setting/Setting.vue')['default']
SetUpdate: typeof import('./src/components/setting/SetUpdate.vue')['default']
ShareFiles: typeof import('./src/components/oa/ShareFiles.vue')['default']
- ShareFileTree: typeof import('./src/components/builtin/ShareFileTree.vue')['default']
ShowNews: typeof import('./src/components/taskbar/ShowNews.vue')['default']
StartMenu: typeof import('./src/components/taskbar/StartMenu.vue')['default']
StartOption: typeof import('./src/components/taskbar/StartOption.vue')['default']
diff --git a/frontend/src/components/builtin/FileList.vue b/frontend/src/components/builtin/FileList.vue
index ca6f374..94e02a5 100644
--- a/frontend/src/components/builtin/FileList.vue
+++ b/frontend/src/components/builtin/FileList.vue
@@ -34,7 +34,7 @@
@dragleave="handleDragLeave()" @dragstart.stop="startDragApp($event, item)" @click="handleClick(index)"
@mousedown.stop :ref="(ref: any) => {
if (ref) {
- appPositions[indeíx] = markRaw(ref as Element);
+ appPositions[index] = markRaw(ref as Element);
}
}
">
@@ -196,8 +196,6 @@ function handleClick(index: number) {
chosenIndexs.value = [index];
}
onMounted(() => {
- console.log('filelist:',props.fileList)
-
chosenIndexs.value = [];
props.onChosen(
throttle((rect: Rect) => {
diff --git a/frontend/src/components/builtin/FileProps.vue b/frontend/src/components/builtin/FileProps.vue
index f6393a1..47799c1 100644
--- a/frontend/src/components/builtin/FileProps.vue
+++ b/frontend/src/components/builtin/FileProps.vue
@@ -29,7 +29,7 @@
{{ t("location") }}:
-
{{ file?.path }}
+
{{ localName(file?.path) }}
{{ t("size") }}:
@@ -72,10 +72,25 @@ import {
t,
} from "@/system";
import { dealSize } from "@/util/file";
+import { isShareFile } from "@/util/sharePath";
const window: BrowserWindow | undefined = inject("browserWindow");
const file = ref
();
-file.value = await useSystem()?.fs.stat(window?.config.content);
+const path = window?.config.content
+if(path.indexOf('/F') === 0) {
+ file.value = (await useSystem()?.fs.getShareInfo(path)).fi
+} else {
+ file.value = await useSystem()?.fs.stat(path);
+}
+// file.value = await useSystem()?.fs.stat(window?.config.content);
+function localName(currentPath:T){
+ if(isShareFile(path)) {
+ const arr = path.split('/')
+ const url = '/' + arr[1] + '/' + arr[2] + '/' + arr[arr.length-1]
+ return arr.length >3 ? url : currentPath
+ }
+ return currentPath
+}
function confirm() {
window?.close();
}
diff --git a/frontend/src/components/builtin/FileTree.vue b/frontend/src/components/builtin/FileTree.vue
index 21c2994..1f6ce98 100644
--- a/frontend/src/components/builtin/FileTree.vue
+++ b/frontend/src/components/builtin/FileTree.vue
@@ -51,9 +51,8 @@
import { useSystem,OsFileWithoutContent,basename } from '@/system/index.ts';
import { onMounted, ref } from 'vue';
import { dealSystemName } from '@/i18n';
-// 分享
-// import { getSystemConfig } from "@/system/config";
-// const config = ref(getSystemConfig())
+import { getSystemConfig } from "@/system/config";
+import { isShareFile } from '@/util/sharePath';
const sys = useSystem();
type FileWithOpen = OsFileWithoutContent & {
@@ -113,9 +112,15 @@ function onSubOpen(path: string) {
}
async function onSubRefresh(item: FileWithOpen) {
- item.subFileList = (await sys.fs.readdir(item.path)).filter((file:any) => {
- return file.isDirectory;
- });
+ if(isShareFile(item.path)) {
+ item.subFileList = (await sys.fs.sharedir(getSystemConfig().userInfo.id, item?.path)).filter((file:any) => {
+ return file.isDirectory;
+ });
+ } else {
+ item.subFileList = (await sys.fs.readdir(item.path)).filter((file:any) => {
+ return file.isDirectory;
+ });
+ }
}
async function onOpenArrow(item: FileWithOpen) {
@@ -123,9 +128,15 @@ async function onOpenArrow(item: FileWithOpen) {
return;
}
item.isOpen = !item.isOpen;
- item.subFileList = (await sys.fs.readdir(item.path)).filter((file:any) => {
- return file.isDirectory;
- });
+ if(isShareFile(item.path)) {
+ item.subFileList = (await sys.fs.sharedir(getSystemConfig().userInfo.id, item?.path)).filter((file:any) => {
+ return file.isDirectory;
+ });
+ } else {
+ item.subFileList = (await sys.fs.readdir(item.path)).filter((file:any) => {
+ return file.isDirectory;
+ });
+ }
}
diff --git a/frontend/src/components/computer/Computer.vue b/frontend/src/components/computer/Computer.vue
index d39c5b8..557e257 100644
--- a/frontend/src/components/computer/Computer.vue
+++ b/frontend/src/components/computer/Computer.vue
@@ -43,7 +43,7 @@
>
{{ t("share") }}
-
-
+
@@ -105,6 +105,7 @@ import { emitEvent, mountEvent } from "@/system/event";
import { useFileDrag } from "@/hook/useFileDrag";
import { useComputer } from "@/hook/useComputer";
import { Rect, useRectChosen } from "@/hook/useRectChosen";
+import { getSystemConfig } from "@/system/config";
const { choseStart, chosing, choseEnd, getRect, Chosen } = useRectChosen();
@@ -136,7 +137,7 @@ const { refersh, createFolder, backFolder, openFolder, onComputerMount } = useCo
return router_url.value;
},
setFileList(list) {
- console.log('list:',list)
+ // console.log('list:',list)
//currentList.value = list;
if(config.ext && config.ext instanceof Array && config.ext.length > 0) {
const res:any = []
@@ -164,7 +165,7 @@ const { refersh, createFolder, backFolder, openFolder, onComputerMount } = useCo
return system.fs.readdir(path);
},
sharedir(path) {
- const val:number = system.getConfig('userInfo')?.id
+ const val:number = getSystemConfig().userInfo.id
return system.fs.sharedir(val,path)
},
exists(path) {
@@ -269,6 +270,8 @@ onMounted(() => {
}
});
shareShow.value = system.getConfig('userType') === 'member' ? true : false
+ // console.log('配置信息:', system.getConfig('userInfo').id);
+
});
function handleOuterClick() {
diff --git a/frontend/src/components/oa/ShareFiles.vue b/frontend/src/components/oa/ShareFiles.vue
index a201488..d4888cc 100644
--- a/frontend/src/components/oa/ShareFiles.vue
+++ b/frontend/src/components/oa/ShareFiles.vue
@@ -61,9 +61,7 @@ const onSubmit = async () => {
const temp = {...form.value}
temp.senderid = temp.senderid.toString()
temp.receverid = temp.receverid.map((item:any) => item.toString())
- const res = await fetchPost(apiUrl, new URLSearchParams(temp))
- console.log('分享文件:',res)
-
+ await fetchPost(apiUrl, new URLSearchParams(temp))
}
diff --git a/frontend/src/components/setting/SetSystem.vue b/frontend/src/components/setting/SetSystem.vue
index 02caffa..34cf6a4 100644
--- a/frontend/src/components/setting/SetSystem.vue
+++ b/frontend/src/components/setting/SetSystem.vue
@@ -47,6 +47,7 @@
{{ t("confirm") }}
+
diff --git a/frontend/src/hook/useComputer.ts b/frontend/src/hook/useComputer.ts
index 82dbacf..1eef71e 100644
--- a/frontend/src/hook/useComputer.ts
+++ b/frontend/src/hook/useComputer.ts
@@ -40,7 +40,7 @@ export const useComputer = (adpater: {
}
if (!(await isVia(currentPath))) return;
- console.log('use computer refresh:', currentPath);
+ // console.log('use computer refresh:', currentPath);
let result
if (currentPath.substring(0,2) == '/F') {
result = await adpater.sharedir(currentPath)
@@ -67,8 +67,6 @@ export const useComputer = (adpater: {
refersh();
};
const openFolder = (file: OsFileWithoutContent) => {
- console.log('use computer openFolder 打开:', file);
-
if (adpater.isDirectory(file)) {
adpater.setRouter(file.path);
refersh();
diff --git a/frontend/src/hook/useContextMenu.ts b/frontend/src/hook/useContextMenu.ts
index f988547..ec22b8f 100644
--- a/frontend/src/hook/useContextMenu.ts
+++ b/frontend/src/hook/useContextMenu.ts
@@ -268,8 +268,6 @@ function useContextMenu() {
if (file.isDirectory) {
return system?.fs.rmdir(file.path);
} else {
- console.log('删除文件:',file);
-
return system?.fs.unlink(file.path);
}
}
@@ -277,8 +275,6 @@ function useContextMenu() {
if (file.isDirectory) {
return system?.fs.rmdir(file.path);
} else {
- console.log('删除文件:',file);
-
return system?.fs.unlink(file.path);
}
}
diff --git a/frontend/src/i18n/lang/zh.json b/frontend/src/i18n/lang/zh.json
index 36afe6e..18293ed 100644
--- a/frontend/src/i18n/lang/zh.json
+++ b/frontend/src/i18n/lang/zh.json
@@ -10,6 +10,7 @@
"share": "分享",
"myshare": "我的分享",
"othershare": "接收的分享",
+ "setFilePwd": "设置文件密码",
"favorite": "我的收藏",
"desktop": "桌面",
"personalization": "个性化",
diff --git a/frontend/src/system/core/FileOs.ts b/frontend/src/system/core/FileOs.ts
index 6a5320c..df14e27 100644
--- a/frontend/src/system/core/FileOs.ts
+++ b/frontend/src/system/core/FileOs.ts
@@ -1,7 +1,9 @@
import { getFileUrl,fetchGet,fetchPost } from "../config.ts";
const API_BASE_URL = getFileUrl()
import { OsFileMode } from '../core/FileMode';
-// import { getSystemConfig } from "@/system/config";
+import { getSystemConfig } from "@/system/config";
+import { turnServePath, turnLocalPath } from "@/util/sharePath.ts";
+import { OsFile } from "./FileSystem.ts";
export async function handleReadDir(path: any): Promise
{
const res = await fetchGet(`${API_BASE_URL}/read?path=${encodeURIComponent(path)}`);
@@ -11,9 +13,9 @@ export async function handleReadDir(path: any): Promise {
return await res.json();
}
// 查看分享文件
-export async function handleReadShareDir(val: number,path: string): Promise {
+export async function handleReadShareDir(id: number,path: string): Promise {
const url = path.indexOf('/F/myshare') !== -1 ? 'sharemylist' : 'sharelist'
- const res = await fetchGet(`${API_BASE_URL}/${url}?id=${val}`);
+ const res = await fetchGet(`${API_BASE_URL}/${url}?id=${id}`);
if (!res.ok) {
return false;
}
@@ -21,6 +23,7 @@ export async function handleReadShareDir(val: number,path: string): Promise
}
// 查看分享文件
export async function handleReadShareFile(path: string): Promise {
+ path = turnServePath(path)
const res = await fetchGet(`${API_BASE_URL}/shareread?path=${path}`);
if (!res.ok) {
return false;
@@ -29,18 +32,21 @@ export async function handleReadShareFile(path: string): Promise {
}
// 删除分享文件
export async function handleShareUnlink(path: string): Promise {
- const file = await handleShareDetail(path)
- const res = await fetchGet(`${API_BASE_URL}/sharedelete?path=${path}`);
+ const config = getSystemConfig()
+ const file = await handleShareDetail(path,config.userInfo.id)
+ path = turnServePath(path)
+ const res = await fetchGet(`${API_BASE_URL}/sharedelete?senderid=${file.data.fs.sender}&path=${path}&receverid=${file.data.fs.recever}`);
if (!res.ok) {
return false;
}
return await res.json();
}
// 查看文件信息
-export async function handleShareDetail(path: string): Promise {
- const res = await fetchGet(`${API_BASE_URL}/shareinfo?path=${path}`);
- console.log('文件详情:', res);
+export async function handleShareDetail(path: string, id: number): Promise {
+ const sig = path.indexOf('/F/myshare') === 0 ? 0 : 1
+ path = turnServePath(path)
+ const res = await fetchGet(`${API_BASE_URL}/shareinfo?path=${path}&id=${id}&sig=${sig}`);
if (!res.ok) {
return false;
}
@@ -137,7 +143,6 @@ export async function handleRmdir(dirPath: string): Promise {
return await res.json();
}
-
export async function handleCopyFile(srcPath: string, dstPath: string): Promise {
const res = await fetchGet(`${API_BASE_URL}/copyfile?srcPath=${encodeURIComponent(srcPath)}&dstPath=${encodeURIComponent(dstPath)}`);
if (!res.ok) {
@@ -230,14 +235,12 @@ export async function handleUnZip(path: string): Promise {
export const useOsFile = () => {
return {
// 分享
- async sharedir(val: number, path: string) {
- const response = await handleReadShareDir(val, path);
+ async sharedir(id: number, path: string) {
+ const response = await handleReadShareDir(id, path);
if (response && response.data) {
- // return response.data;
- console.log('文件列表:',response.data.map(item => item.fi));
-
- return response.data.map(item => {
+ return response.data.map((item: {[key: string]: OsFile}) => {
item.fi.isShare = true
+ item.fi.path = turnLocalPath(item.fi.path ,path)
return item.fi
})
}
@@ -250,11 +253,14 @@ export const useOsFile = () => {
}
return [];
},
+ async getShareInfo(path: string) {
+ const response = await handleShareDetail(path, getSystemConfig().userInfo.id);
+ if (response && response.data) {
+ return response.data;
+ }
+ return [];
+ },
async readdir(path: string) {
- // console.log('raeddir path:',path,path.substring(0,2))
- // const api = path.substring(0,2) == '/F' ? handleReadShareDir : handleReadDir
- // const temp = path.substring(0,2) == '/F' ? getSystemConfig().userInfo.id : path
- // const response = await api(temp);
const response = await handleReadDir(path);
if (response && response.data) {
return response.data;
@@ -282,12 +288,8 @@ export const useOsFile = () => {
return response.data;
}
return false;
- //分享
- // return true
},
async readFile(path: string) {
- console.log('读文件:',path);
-
// 注意:handleReadFile返回的是JSON,但通常readFile期望返回Buffer或字符串
const response = await handleReadFile(path);
if (response && response.data) {
@@ -296,8 +298,7 @@ export const useOsFile = () => {
return false;
},
async unlink(path: string) {
- const fun = path.indexOf('data/userData') === 0 ? handleShareUnlink : handleUnlink
- console.log('删除路径:',path,fun);
+ const fun = path.indexOf('/F') === 0 ? handleShareUnlink : handleUnlink
const response = await fun(path);
if (response) {
return response;
diff --git a/frontend/src/system/core/FileSystem.ts b/frontend/src/system/core/FileSystem.ts
index 37abc7f..b09f684 100644
--- a/frontend/src/system/core/FileSystem.ts
+++ b/frontend/src/system/core/FileSystem.ts
@@ -101,6 +101,7 @@ class OsFile extends OsFileInfo {
title?: string; // 文件名(不包含扩展名)
id?: number; // 文件ID(可选)
isSys?: number; // 文件是否是系统文件(可选)
+ isShare?: boolean; // 文件是否为共享文件
/**
* OsFile 类的构造函数。
diff --git a/frontend/src/system/index.ts b/frontend/src/system/index.ts
index 367c96f..7901ea0 100644
--- a/frontend/src/system/index.ts
+++ b/frontend/src/system/index.ts
@@ -27,6 +27,7 @@ import { useUpgradeStore } from '@/stores/upgrade';
import { useMessageStore } from '@/stores/message';
import { RestartApp } from '@/util/goutil';
import { notifyError } from '@/util/msg';
+import { isShareFile } from '@/util/sharePath';
export type OsPlugin = (system: System) => void;
export type FileOpener = {
@@ -427,8 +428,7 @@ export class System {
/**打开os 文件系统的文件 */
async openFile(path: string) {
//判断是否是共享文件
- const pos = path.indexOf('data/userData')
- if (pos !== -1) {
+ if (isShareFile(path)) {
const arr = path.split('/')
const fileContent = await this.fs.readShareFile(path)
const fileName = extname(arr[arr.length-1] || '') || 'link'
diff --git a/frontend/src/util/sharePath.ts b/frontend/src/util/sharePath.ts
new file mode 100644
index 0000000..6e4ad79
--- /dev/null
+++ b/frontend/src/util/sharePath.ts
@@ -0,0 +1,11 @@
+export function turnServePath(path: string): string {
+ const replaceUrl = path.indexOf('/F/myshare') === 0 ? '/F/myshare' : '/F/othershare'
+ return path.replace(replaceUrl, 'data/userData')
+}
+export function turnLocalPath(path: string, newTemp: string): string {
+ return path.replace('data/userData', newTemp)
+}
+export function isShareFile(path: string) : boolean {
+ // console.log('是否是共享文件:',path,path.indexOf('/F/myshare') === 0 || path.indexOf('/F/othershare') === 0);
+ return path.indexOf('/F/myshare') === 0 || path.indexOf('/F/othershare') === 0
+}
\ No newline at end of file