Browse Source

add choose pwd

master
godo 6 months ago
parent
commit
4eb32ee93c
  1. 1
      README.md
  2. 13
      frontend/components.d.ts
  3. 60
      frontend/src/components/builtin/FileList.vue
  4. 28
      frontend/src/components/computer/Computer.vue
  5. 193
      frontend/src/components/oa/ShareFiles.vue
  6. 9
      frontend/src/hook/useComputer.ts
  7. 7
      frontend/src/system/core/FileOs.ts
  8. 2
      frontend/src/system/index.ts

1
README.md

@ -29,6 +29,7 @@
- 内网聊天新增ai对话,可保存对话历史,可更换模型和prompt - 内网聊天新增ai对话,可保存对话历史,可更换模型和prompt
- 新增可定义端口和访问路径,支持web端系统重启 - 新增可定义端口和访问路径,支持web端系统重启
- 新增企业端gitee登录和github登录 - 新增企业端gitee登录和github登录
- 新增每个文件可独立设置密码,支持不可逆加密文件(加密文件后不可更改密码)
## 🏭 第三阶段目标(十二月底发布) ## 🏭 第三阶段目标(十二月底发布)
1. **文档处理与Markdown智能升级** 1. **文档处理与Markdown智能升级**

13
frontend/components.d.ts

@ -74,24 +74,16 @@ declare module 'vue' {
ElCol: typeof import('element-plus/es')['ElCol'] ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse'] ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
ElContainer: typeof import('element-plus/es')['ElContainer'] ElContainer: typeof import('element-plus/es')['ElContainer']
ElDialog: typeof import('element-plus/es')['ElDialog'] ElDialog: typeof import('element-plus/es')['ElDialog']
ElDrawer: typeof import('element-plus/es')['ElDrawer'] ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
ElEmpty: typeof import('element-plus/es')['ElEmpty'] ElEmpty: typeof import('element-plus/es')['ElEmpty']
ElFooter: typeof import('element-plus/es')['ElFooter']
ElForm: typeof import('element-plus/es')['ElForm'] ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem'] ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader'] ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon'] ElIcon: typeof import('element-plus/es')['ElIcon']
ElImage: typeof import('element-plus/es')['ElImage'] ElImage: typeof import('element-plus/es')['ElImage']
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption'] ElOption: typeof import('element-plus/es')['ElOption']
ElPageHeader: typeof import('element-plus/es')['ElPageHeader'] ElPageHeader: typeof import('element-plus/es')['ElPageHeader']
ElPagination: typeof import('element-plus/es')['ElPagination'] ElPagination: typeof import('element-plus/es')['ElPagination']
@ -100,18 +92,15 @@ declare module 'vue' {
ElRow: typeof import('element-plus/es')['ElRow'] ElRow: typeof import('element-plus/es')['ElRow']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSelect: typeof import('element-plus/es')['ElSelect'] ElSelect: typeof import('element-plus/es')['ElSelect']
ElSelectV2: typeof import('element-plus/es')['ElSelectV2']
ElSlider: typeof import('element-plus/es')['ElSlider'] ElSlider: typeof import('element-plus/es')['ElSlider']
ElSpace: typeof import('element-plus/es')['ElSpace'] ElSpace: typeof import('element-plus/es')['ElSpace']
ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs'] ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']
ElText: typeof import('element-plus/es')['ElText'] ElText: typeof import('element-plus/es')['ElText']
ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTransfer: typeof import('element-plus/es')['ElTransfer']
ElTree: typeof import('element-plus/es')['ElTree']
Error: typeof import('./src/components/taskbar/Error.vue')['default'] Error: typeof import('./src/components/taskbar/Error.vue')['default']
FileIcon: typeof import('./src/components/builtin/FileIcon.vue')['default'] FileIcon: typeof import('./src/components/builtin/FileIcon.vue')['default']
FileIconImg: typeof import('./src/components/builtin/FileIconImg.vue')['default'] FileIconImg: typeof import('./src/components/builtin/FileIconImg.vue')['default']

60
frontend/src/components/builtin/FileList.vue

@ -291,7 +291,7 @@ function handleRightClick(
// }, // },
// }, // },
]; ];
if (item.isDirectory && !item.isShare) { if (item.isDirectory) {
if (getSystemKey("storeType") == "local") { if (getSystemKey("storeType") == "local") {
menuArr.push({ menuArr.push({
label: t("zip"), label: t("zip"),
@ -383,7 +383,7 @@ function handleRightClick(
}, },
}, },
]; ];
if (!item.isShare || item.path.indexOf("/F/othershare") !== 0) { if (item.path.indexOf("/F") < 0) {
fileMenus.push({ fileMenus.push({
label: t("delete"), label: t("delete"),
click: async () => { click: async () => {
@ -399,8 +399,6 @@ function handleRightClick(
} }
}, },
}); });
}
if (!item.isShare) {
fileMenus.push({ fileMenus.push({
label: t("create.shortcut"), label: t("create.shortcut"),
click: () => { click: () => {
@ -412,7 +410,7 @@ function handleRightClick(
}); });
} }
const userType = sys.getConfig("userType"); const userType = sys.getConfig("userType");
if (userType == "member" && !item.isShare && !item.isDirectory) { if (userType == "member") {
menuArr.push({ menuArr.push({
label: "分享给...", label: "分享给...",
click: () => { click: () => {
@ -429,40 +427,26 @@ function handleRightClick(
win.show(); win.show();
}, },
}); });
// menuArr.push({
// label: "",
// click: () => {
// const win = new BrowserWindow({
// title: "",
// content: "CommentsFiles",
// config: {
// path: item.path,
// },
// width: 350,
// height: 400,
// center: true,
// });
// win.show();
// },
// });
} }
menuArr.push({ if (!item.isDirectory) {
label: "文件加密", menuArr.push({
click: () => { label: "文件加密",
const win = new BrowserWindow({ click: () => {
title: "文件加密", const win = new BrowserWindow({
content: "FilePwd", title: "文件加密",
config: { content: "FilePwd",
path: item.path, config: {
}, path: item.path,
width: 400, },
height: 200, width: 400,
center: true, height: 200,
}); center: true,
win.show(); });
}, win.show();
}); },
});
}
menuArr.push.apply(menuArr, fileMenus); menuArr.push.apply(menuArr, fileMenus);
} }
const sysEndMenu = [ const sysEndMenu = [

28
frontend/src/components/computer/Computer.vue

@ -132,8 +132,6 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { inject, onMounted, ref } from "vue"; import { inject, onMounted, ref } from "vue";
//import foldericon from '@/assets/folder.png';
import { useComputer } from "@/hook/useComputer"; import { useComputer } from "@/hook/useComputer";
import { useContextMenu } from "@/hook/useContextMenu"; import { useContextMenu } from "@/hook/useContextMenu";
import { useFileDrag } from "@/hook/useFileDrag"; import { useFileDrag } from "@/hook/useFileDrag";
@ -148,11 +146,6 @@
t, t,
useSystem, useSystem,
} from "@/system/index.ts"; } from "@/system/index.ts";
import {
isRootShare,
isShareFile,
turnLocalPath,
} from "@/util/sharePath.ts";
import { useChooseStore } from "@/stores/choose"; import { useChooseStore } from "@/stores/choose";
@ -244,22 +237,7 @@
isDirectory(file) { isDirectory(file) {
return file.isDirectory; return file.isDirectory;
}, },
//
async readShareDir(path) {
// let file: OsFileWithoutContent
// if (type === 'path') {
// file = await system.fs.getShareInfo(params)
// file = file.fi
// file.path = turnLocalPath(file.path, currentPath, 1)
// } else {
// file = params
// }
// return system.fs.readShareFileDir(getSystemConfig().userInfo.id, file)
return system.fs.readShareFileDir(
getSystemConfig().userInfo.id,
path
);
},
notify(title, content) { notify(title, content) {
new Notify({ new Notify({
title, title,
@ -311,9 +289,9 @@
isSymlink: false, isSymlink: false,
mode: 2147484141, mode: 2147484141,
name: "myshare", name: "myshare",
oldPath: "/F/myshare", oldPath: "/F",
parentPath: "/F", parentPath: "/F",
path: "/F/myshare", path: "/F",
title: "myshare", title: "myshare",
size: 64, size: 64,
mtime: "", mtime: "",

193
frontend/src/components/oa/ShareFiles.vue

@ -1,114 +1,125 @@
<template> <template>
<el-form <el-form :model="form" label-width="auto" style="max-width: 560px; margin-top: 20px; padding: 20px">
:model="form"
label-width="auto"
style="max-width: 560px; margin-top: 20px; padding: 20px"
>
<el-form-item label="分享给"> <el-form-item label="分享给">
<el-select <el-select v-model="form.receiverId" remote :remote-method="handleSearch" filterable multiple clearable collapse-tags placeholder="选择人员"
v-model="form.receverid" popper-class="custom-header" :max-collapse-tags="1" value-key="id" style="width: 240px"
filterable @change="checkUsers">
multiple
clearable
collapse-tags
placeholder="选择人员"
popper-class="custom-header"
:max-collapse-tags="1"
value-key="id"
style="width: 240px"
@change="checkUsers"
>
<template #header> <template #header>
<el-checkbox <el-checkbox v-model="checkAll" @change="handleCheckAll">
v-model="checkAll"
@change="handleCheckAll"
>
全选 全选
</el-checkbox> </el-checkbox>
</template> </template>
<el-option <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id" />
v-for="item in userList" <template #footer v-if="total > 10">
:key="item.id" <el-pagination small background layout="prev, pager, next" :total="total"
:label="item.nickname" :page-size="pageSize" :current-page="currentPage" @current-change="handlePageChange"
:value="item.id" style="margin-top: 10px" />
/> </template>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="编辑权限"> <el-form-item label="编辑权限">
<el-switch <el-switch v-model="form.iswrite" active-value="1" inactive-value="0" />
v-model="form.iswrite"
active-value="1"
inactive-value="0"
/>
</el-form-item> </el-form-item>
<div class="btn-group"> <div class="btn-group">
<el-button <el-button type="primary" @click="onSubmit">发布分享</el-button>
type="primary"
@click="onSubmit"
>发布分享</el-button
>
</div> </div>
</el-form> </el-form>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { BrowserWindow, useSystem } from "@/system"; import { BrowserWindow } from "@/system";
import { fetchPost, getSystemConfig } from "@/system/config"; import { fetchPost, getSystemConfig, getUrl } from "@/system/config";
import { notifyError, notifySuccess } from "@/util/msg"; import { notifyError, notifySuccess } from "@/util/msg";
import { inject, onMounted, ref } from "vue"; import { inject, onMounted, ref } from "vue";
const window: BrowserWindow | undefined = inject("browserWindow"); const window: BrowserWindow | undefined = inject("browserWindow");
const sys = useSystem(); //const sys = useSystem();
const userInfo: any = sys.getConfig("userInfo"); //const userInfo: any = sys.getConfig("userInfo");
let userList = ref(userInfo.user_shares); const userList: any = ref([]);
const checkAll = ref(false); const checkAll = ref(false);
const form: any = ref({ const form: any = ref({
senderid: "", senderid: "",
receverid: [], receiverId: [],
path: "", path: "",
iswrite: "0", iswrite: "0",
}); });
const config = ref(getSystemConfig()); const currentPage = ref(1);
const pageSize = 10;
const handleCheckAll = (val: any) => { const total = ref(0);
if (val) { const config = ref(getSystemConfig());
form.value.receverid = userList.value.map((d: any) => d.value); const pageUrl = ref("")
} else { const getList = async() => {
form.value.receverid.value = []; const apiUrl = getUrl(pageUrl.value, true)
} //console.log(apiUrl)
}; const res: any = await fetch(apiUrl);
const checkUsers = (val: any) => { //console.log(res)
const res: any = []; if (res.ok) {
val.forEach((item: any) => { const rt = await res.json();
if (item) { //console.log(rt)
res.push(item); userList.value = rt.data.list;
} total.value = rt.data.total;
});
form.value.receverid = res;
};
const onSubmit = async () => {
const apiUrl = config.value.userInfo.url + "/files/share";
form.value.senderid = config.value.userInfo.id;
form.value.path = window?.config.path || "";
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));
const result = await res.json();
if (res.ok) {
notifySuccess(result.message || "分享文件成功");
} else {
notifyError(result.message || "分享文件失败");
}
};
onMounted(() => {
userList.value = userList.value.filter((item: any) => { userList.value = userList.value.filter((item: any) => {
return item?.id !== config.value.userInfo.id; return item?.id !== config.value.userInfo.id;
}); });
if(userList.value.length != rt.data.list.length){
total.value = total.value - 1;
}
}
}
onMounted(async () => {
pageUrl.value = '/user/sharelist?page='+currentPage.value
await getList()
});
const handleCheckAll = (val: any) => {
if (val) {
form.value.receiverId = userList.value.map((d: any) => d.value);
} else {
form.value.receiverId.value = [];
}
};
const checkUsers = (val: any) => {
const res: any = [];
val.forEach((item: any) => {
if (item) {
res.push(item);
}
}); });
form.value.receiverId = res;
};
const onSubmit = async () => {
const apiUrl = config.value.userInfo.url + "/files/share";
form.value.path = window?.config.path || "";
const temp = { ...form.value };
temp.receiverId = temp.receiverId.map((item: any) => item.toString());
const res = await fetchPost(apiUrl, new URLSearchParams(temp));
const result = await res.json();
if (res.ok && result.success) {
notifySuccess(result.message || "分享文件成功");
window?.close()
} else {
notifyError(result.message || "分享文件失败");
}
};
const handleSearch = async (val:any) => {
if(val !== ''){
pageUrl.value = '/user/sharelist?page=1&nickname='+val
}else{
pageUrl.value = '/user/sharelist?page=1'
}
await getList()
};
const handlePageChange = async (page: number) => {
currentPage.value = page;
await getList()
};
// onMounted(() => {
// userList.value = userList.value.filter((item: any) => {
// return item?.id !== config.value.userInfo.id;
// });
// });
</script> </script>
<style scoped> <style scoped>
.btn-group { .btn-group {
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
</style> </style>

9
frontend/src/hook/useComputer.ts

@ -15,7 +15,7 @@ export const useComputer = (adpater: {
isDirectory: (file: OsFileWithoutContent) => boolean; isDirectory: (file: OsFileWithoutContent) => boolean;
notify: (title: string, content: string) => void; notify: (title: string, content: string) => void;
search: (keyword: string) => Promise<OsFileWithoutContent[]>; search: (keyword: string) => Promise<OsFileWithoutContent[]>;
readShareDir: (path: RouterPath) => Promise<OsFileWithoutContent[]>; //readShareDir: (path: RouterPath) => Promise<OsFileWithoutContent[]>;
}) => { }) => {
const isVia = async (path: RouterPath) => { const isVia = async (path: RouterPath) => {
if (path === '') path = '/'; if (path === '') path = '/';
@ -43,12 +43,7 @@ export const useComputer = (adpater: {
return; return;
} }
if (!(await isVia(currentPath))) return; if (!(await isVia(currentPath))) return;
let result const result = await adpater.readdir(currentPath);
if (currentPath === '/F/myshare' || currentPath === '/F/othershare') {
result = await adpater.sharedir(currentPath)
} else {
result = await adpater.readdir(currentPath);
}
// else if (currentPath.indexOf('/F') === 0) { // else if (currentPath.indexOf('/F') === 0) {
// //判断是否是回退 // //判断是否是回退
// // console.log('currentPath:', currentPath); // // console.log('currentPath:', currentPath);

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

@ -1,9 +1,6 @@
import { getSystemConfig } from "@/system/config";
import { isShareFile, turnLocalPath, turnServePath } from "@/util/sharePath.ts";
import { md5 } from "js-md5"; import { md5 } from "js-md5";
import { fetchGet, fetchPost, getFileUrl } from "../config.ts"; import { fetchGet, fetchPost, getFileUrl } from "../config.ts";
import { OsFileMode } from '../core/FileMode'; import { OsFileMode } from '../core/FileMode';
import { OsFile } from "./FileSystem.ts";
const API_BASE_URL = getFileUrl() const API_BASE_URL = getFileUrl()
// import { notifyError } from "@/util/msg"; // import { notifyError } from "@/util/msg";
export async function handleReadDir(path: any): Promise<any> { export async function handleReadDir(path: any): Promise<any> {
@ -288,10 +285,6 @@ export const useOsFile = () => {
return false; return false;
}, },
async writeFile(path: string, content: string | Blob, header?: { [key: string]: any }) { async writeFile(path: string, content: string | Blob, header?: { [key: string]: any }) {
// const head: any = header ? { ...header } : {}
// if (head.pwd && head.pwd !== '') {
// head.pwd = md5(head.pwd)
// }
const response = await handleWriteFile(path, content, header); const response = await handleWriteFile(path, content, header);
if (response) { if (response) {
return response; return response;

2
frontend/src/system/index.ts

@ -19,7 +19,7 @@ import { useModelStore } from "@/stores/model.ts";
import { useUpgradeStore } from '@/stores/upgrade'; import { useUpgradeStore } from '@/stores/upgrade';
import { RestartApp } from '@/util/goutil'; import { RestartApp } from '@/util/goutil';
import { notifyError } from '@/util/msg'; import { notifyError } from '@/util/msg';
import { isShareFile } from '@/util/sharePath'; //import { isShareFile } from '@/util/sharePath';
import { pick } from '../util/modash'; import { pick } from '../util/modash';
import { clearSystemConfig, fetchGet, getClientId, getFileUrl, getSystemConfig, getSystemKey, setSystemConfig, setSystemKey } from './config'; import { clearSystemConfig, fetchGet, getClientId, getFileUrl, getSystemConfig, getSystemKey, setSystemConfig, setSystemKey } from './config';
import { OsFileInterface } from './core/FIleInterface'; import { OsFileInterface } from './core/FIleInterface';

Loading…
Cancel
Save