qiutianhong 7 months ago
parent
commit
3f2b59c388
  1. 16
      frontend/components.d.ts
  2. 4
      frontend/src/components/builtin/FileList.vue
  3. 1
      frontend/src/components/builtin/FileProps.vue
  4. 98
      frontend/src/components/chat/ChatUserSetting.vue
  5. 11
      frontend/src/components/computer/Computer.vue
  6. 9
      frontend/src/components/oa/ShareFiles.vue
  7. 38
      frontend/src/hook/useComputer.ts
  8. 36
      frontend/src/stores/file.ts
  9. 31
      frontend/src/system/core/FileOs.ts
  10. 1
      frontend/src/system/core/FileSystem.ts
  11. 5
      frontend/src/util/sharePath.ts

16
frontend/components.d.ts

@ -50,43 +50,29 @@ declare module 'vue' {
EditType: typeof import('./src/components/builtin/EditType.vue')['default'] EditType: typeof import('./src/components/builtin/EditType.vue')['default']
ElAside: typeof import('element-plus/es')['ElAside'] ElAside: typeof import('element-plus/es')['ElAside']
ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElBadge: typeof import('element-plus/es')['ElBadge']
ElButton: typeof import('element-plus/es')['ElButton'] ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard'] ElCard: typeof import('element-plus/es')['ElCard']
ElCarousel: typeof import('element-plus/es')['ElCarousel'] ElCarousel: typeof import('element-plus/es')['ElCarousel']
ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem'] ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCol: typeof import('element-plus/es')['ElCol'] ElCol: typeof import('element-plus/es')['ElCol']
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']
ElFooter: typeof import('element-plus/es')['ElFooter'] 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']
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElMain: typeof import('element-plus/es')['ElMain'] ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination'] ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElProgress: typeof import('element-plus/es')['ElProgress'] ElProgress: typeof import('element-plus/es')['ElProgress']
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']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
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'] ElTree: typeof import('element-plus/es')['ElTree']
ElUpload: typeof import('element-plus/es')['ElUpload'] ElUpload: typeof import('element-plus/es')['ElUpload']
Error: typeof import('./src/components/taskbar/Error.vue')['default'] Error: typeof import('./src/components/taskbar/Error.vue')['default']

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

@ -369,7 +369,7 @@ function handleRightClick(mouse: MouseEvent, item: OsFileWithoutContent, index:
}, },
]; ];
if (item.isShare && item.path.indexOf('/F/othershare') !== 0) { if (!item.isShare || item.path.indexOf('/F/othershare') !== 0) {
fileMenus.push({ fileMenus.push({
label: t('delete'), label: t('delete'),
click: async () => { click: async () => {
@ -385,7 +385,7 @@ function handleRightClick(mouse: MouseEvent, item: OsFileWithoutContent, index:
}) })
} }
const userType = sys.getConfig('userType'); const userType = sys.getConfig('userType');
if (userType == 'member' && !item.isShare) { if (userType == 'member' && !item.isShare && !item.isDirectory) {
menuArr.push( menuArr.push(
{ {

1
frontend/src/components/builtin/FileProps.vue

@ -79,6 +79,7 @@ const file = ref<OsFileWithoutContent | null>();
const path = window?.config.content const path = window?.config.content
if(path.indexOf('/F') === 0) { if(path.indexOf('/F') === 0) {
file.value = (await useSystem()?.fs.getShareInfo(path)).fi file.value = (await useSystem()?.fs.getShareInfo(path)).fi
// file.value.path = file.value.titleName || file.value.path
} else { } else {
file.value = await useSystem()?.fs.stat(path); file.value = await useSystem()?.fs.stat(path);
} }

98
frontend/src/components/chat/ChatUserSetting.vue

@ -2,7 +2,8 @@
import { t } from '@/i18n'; import { t } from '@/i18n';
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
import { useChatStore } from "@/stores/chat"; import { useChatStore } from "@/stores/chat";
import { fetchGet, getSystemConfig } from "@/system/config"; import { notifyError, notifySuccess } from "@/util/msg";
import { fetchGet, getSystemConfig, setSystemKey } from "@/system/config";
const store = useChatStore() const store = useChatStore()
const form = ref({ const form = ref({
nickname: '', nickname: '',
@ -10,37 +11,49 @@ const form = ref({
const userInfo = getSystemConfig().userInfo const userInfo = getSystemConfig().userInfo
const dialogShow = ref(false) const dialogShow = ref(false)
let imgList = reactive([]) let imgList = reactive([])
let pos = ref(0)
const showChange = (val) =>{ const showChange = (val) =>{
dialogShow.value = val dialogShow.value = val
} }
const toChangeHead = ()=>{ const toChangeHead = async ()=>{
console.log('换头像'); let res = await fetchGet(`${userInfo.url}/files/saveavatar?id=${userInfo.id}&name=${imgList[pos.value].name}`)
console.log('submit!:',res)
if (!res.ok) {
notifyError("头像换取失败")
} else {
res = await res.json()
notifySuccess(res.message)
userInfo.avatar = imgList[pos.value].name
store.userInfo.avatar = userInfo.url + '/upload/avatar/' + userInfo.avatar
setSystemKey('userInfo', userInfo)
}
showChange(false)
} }
// //
const getHeadList = async() => { const getHeadList = async () => {
const res = await fetchGet(`${userInfo.url}/files/avatarlist`) let res = await fetchGet (`${userInfo.url}/files/avatarlist`)
// const apiUrl = getSystemConfig().apiUrl + '/upload/avatar/';
const apiUrl = userInfo.url + '/upload/avatar/';
if (res.ok) { if (res.ok) {
imgList = await res.json() res = await res.json()
imgList = imgList.data.map(item => { for (const item of res.data) {
item.isChoose = false imgList.push({
return item url: apiUrl + item,
}) name: item
imgList[0].isChoose = true })
}
} }
console.log('imgList:' , imgList);
} }
let pos = ref(0)
// //
const chooseImg = (index) => { const chooseImg = (index) => {
imgList.forEach(item => item.isChoose = false)
imgList[index].isChoose = true
pos.value = index pos.value = index
} }
const onSubmit = () => { const onSubmit = async () => {
console.log('submit!') console.log('提交');
} }
onMounted(()=>{ onMounted(()=>{
getHeadList() getHeadList()
store.userInfo.avatar = userInfo.url + '/upload/avatar/' + userInfo.avatar
}) })
</script> </script>
<template> <template>
@ -67,13 +80,20 @@ onMounted(()=>{
</el-form> </el-form>
<el-dialog v-model="dialogShow" title="修改头像" width="500px" draggable> <el-dialog v-model="dialogShow" title="修改头像" width="500px" draggable>
<div> <div>
<el-avatar <span
v-for="(item, index) in imgList" v-for="(item, index) in imgList"
:key="item.name" :key="item.name"
:size="90" class="img-box"
:src="item.url" >
:class="{'is-active': item.isChoose}" <el-avatar
@click="chooseImg(index)"/> :size="80"
:src="item.url"
@click="chooseImg(index)"
:class="{'is-active': pos == index}"
>
</el-avatar>
<el-icon v-show="pos == index"><Select /></el-icon>
</span>
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -89,12 +109,28 @@ onMounted(()=>{
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.el-avatar { .img-box {
margin: 10px; position: relative;
} .el-avatar {
.is-active { margin: 10px;
width: 100px; }
height: 100px; .is-active {
border: 2px solid red; width: 90px;
height: 90px;
border: 2px solid green;
box-sizing: border-box;
}
.el-icon {
position: absolute;
bottom: 0;
left: 50%;
width: 25px;
height: 25px;
border-radius: 50%;
color: white;
background-color: green;
transform: translate(-50%,0)
}
} }
</style> </style>

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

@ -175,7 +175,16 @@ const { refersh, createFolder, backFolder, openFolder, onComputerMount } = useCo
return file.isDirectory; return file.isDirectory;
}, },
// //
readShareDir(path){ 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) return system.fs.readShareFileDir(getSystemConfig().userInfo.id, path)
}, },
notify(title, content) { notify(title, content) {

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

@ -21,14 +21,14 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, inject } from 'vue'; import { ref, inject, onMounted } from 'vue';
import { useSystem, BrowserWindow } from '@/system'; import { useSystem, BrowserWindow } from '@/system';
import { getSystemConfig, fetchPost } from "@/system/config"; import { getSystemConfig, fetchPost } from "@/system/config";
import { notifySuccess, notifyError } from "@/util/msg"; import { notifySuccess, notifyError } from "@/util/msg";
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')
const userList = ref(userInfo.user_shares) let userList = ref(userInfo.user_shares)
const checkAll = ref(false) const checkAll = ref(false)
const form: any = ref({ const form: any = ref({
senderid: '', senderid: '',
@ -68,6 +68,11 @@ const onSubmit = async () => {
notifyError("分享文件失败") notifyError("分享文件失败")
} }
} }
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{

38
frontend/src/hook/useComputer.ts

@ -33,6 +33,8 @@ export const useComputer = (adpater: {
}; };
const refersh = async () => { const refersh = async () => {
const currentPath = adpater.getRouter(); const currentPath = adpater.getRouter();
//console.log('refresh:', currentPath);
if (!currentPath) return; if (!currentPath) return;
if (currentPath.startsWith('search:')) { if (currentPath.startsWith('search:')) {
const keyword = currentPath.substr(7); const keyword = currentPath.substr(7);
@ -41,16 +43,37 @@ export const useComputer = (adpater: {
return; return;
} }
if (!(await isVia(currentPath))) return; if (!(await isVia(currentPath))) return;
// console.log('use computer refresh:', currentPath);
let result let result
if (currentPath === '/F/myshare' || currentPath === '/F/othershare') { if (currentPath === '/F/myshare' || currentPath === '/F/othershare') {
result = await adpater.sharedir(currentPath) result = await adpater.sharedir(currentPath)
} else if (currentPath.indexOf('/F') === 0) {
// result = await adpater.readShareDir(file?.path || currentPath)
result = await adpater.readShareDir(currentPath)
} else { } else {
result = await adpater.readdir(currentPath); result = await adpater.readdir(currentPath);
} }
// else if (currentPath.indexOf('/F') === 0) {
// //判断是否是回退
// // console.log('currentPath:', currentPath);
// if (offset && offset === -1) {
// const parentPath = useShareFile().CurrentFile?.parentPath
// //console.log('回退:',parentPath);
// result = await adpater.readShareDir('path', parentPath, currentPath)
// } else {
// result = await adpater.readShareDir('file',file)
// }
// // 查找文件回退的路径
// // const arr = useShareFile().getShareFile()
// // file = arr?.find(item => {
// // return item.titleName === currentPath
// // })
// // console.log('file:',arr,currentPath, file);
// // if (!file) {
// // const parentPath = useShareFile().CurrentFile?.parentPath
// // console.log('回退:',parentPath);
// // result = await adpater.readShareDir('path', parentPath, currentPath)
// // } else {
// // result = await adpater.readShareDir('file',file)
// // }
// }
if (result) adpater.setFileList(result); if (result) adpater.setFileList(result);
}; };
const createFolder = (path: RouterPath) => { const createFolder = (path: RouterPath) => {
@ -72,9 +95,10 @@ export const useComputer = (adpater: {
}; };
const openFolder = (file: OsFileWithoutContent) => { const openFolder = (file: OsFileWithoutContent) => {
if (adpater.isDirectory(file)) { if (adpater.isDirectory(file)) {
// const path = file?.isShare ? file.titleName : file.path // console.log('文件:',file);
const path = file.path // const path = file?.isShare ? turnLocalPath(file.titleName, file.root) : file.path
adpater.setRouter(path); // console.log('路径:', path);
adpater.setRouter(file.path);
refersh(); refersh();
} else { } else {
adpater.openFile(file.path); adpater.openFile(file.path);

36
frontend/src/stores/file.ts

@ -0,0 +1,36 @@
import { defineStore } from 'pinia'
import { OsFileWithoutContent } from '@/system/core/FileSystem';
export const useShareFile = defineStore('shareFile', () =>{
const currentShareFile = ref<OsFileWithoutContent[]>([]);
let CurrentFile = ref<OsFileWithoutContent>();
const setShareFile = (file: OsFileWithoutContent[]) => {
currentShareFile.value = file
//console.log('存储文件:', currentShareFile);
}
const setCurrentFile = (file: OsFileWithoutContent) => {
CurrentFile.value = file
//console.log('当前文件:', CurrentFile.value);
}
const getShareFile = (): OsFileWithoutContent[] | null =>{
return currentShareFile.value
}
const findServerPath = (titleName: string): OsFileWithoutContent | string => {
//console.log('查找文件:',getShareFile());
let result = currentShareFile.value.find(item =>{
return item.titleName === titleName
})
if (!result) {
//console.log('回退茶砸后:',currentShareFile.value[0]);
return currentShareFile.value[0].parentPath
}
return result
}
return {
setShareFile,
setCurrentFile,
getShareFile,
findServerPath,
currentShareFile,
CurrentFile
}
})

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

@ -253,16 +253,17 @@ export const useOsFile = () => {
return { return {
// 分享 // 分享
async sharedir(id: number, path: string) { async sharedir(id: number, path: string) {
// console.log('是否是根:', isRootShare(path),path);
const fun = isRootShare(path) ? handleReadShareDir : handleShareDir const fun = isRootShare(path) ? handleReadShareDir : handleShareDir
const response = await fun(id, path); const response = await fun(id, path);
if (response && response.data) { if (response && response.data) {
return response.data.map((item: {[key: string]: OsFile}) => { const result = response.data.map((item: {[key: string]: OsFile}) => {
item.fi.isShare = true item.fi.isShare = true
item.fi.parentPath = turnLocalPath(item.fi.parentPath ,path)
item.fi.path = turnLocalPath(item.fi.path ,path) item.fi.path = turnLocalPath(item.fi.path ,path)
// item.fi.titleName = turnLocalPath(item.fi.titleName, path) //item.fi.titleName = turnLocalPath(item.fi.titleName, path)
return item.fi return item.fi
}) })
return result
} }
return []; return [];
}, },
@ -273,16 +274,26 @@ export const useOsFile = () => {
} }
return []; return [];
}, },
//分享文件夹取消
async readShareFileDir(id: number, path: string) { async readShareFileDir(id: number, path: string) {
const response = await handleShareDir(id,path); const response = await handleShareDir(id, path)
if (response && response.data) { if (response && response.data) {
return response.data.map((item: {[key: string]: OsFile}) => { return response.data
item.fi.isShare = true
item.fi.path = turnLocalPath(item.fi.path ,path,1)
return item.fi
})
} }
return []; return []
// const response = await handleShareDir(id, file.path);
// useShareFile().setCurrentFile(file)
// if (response && response.data) {
// const result = response.data.map((item: {[key: string]: OsFile}) => {
// item.fi.isShare = true
// item.fi.parentPath = turnLocalPath(item.fi.parentPath ,file.path,1)
// item.fi.path = turnLocalPath(item.fi.path ,file.path,1)
// // item.fi.titleName = turnLocalPath(item.fi.titleName, file.path, 1)
// return item.fi
// })
// return result
// }
// return [];
}, },
async getShareInfo(path: string) { async getShareInfo(path: string) {
const response = await handleShareDetail(path, getSystemConfig().userInfo.id); const response = await handleShareDetail(path, getSystemConfig().userInfo.id);

1
frontend/src/system/core/FileSystem.ts

@ -103,6 +103,7 @@ class OsFile extends OsFileInfo {
isSys?: number; // 文件是否是系统文件(可选) isSys?: number; // 文件是否是系统文件(可选)
isShare?: boolean; // 文件是否为共享文件 isShare?: boolean; // 文件是否为共享文件
isPwd?: boolean; //文件是否上锁 isPwd?: boolean; //文件是否上锁
// root?: string; //分享文件的根目录
titleName?: string; // 文件原本路径 titleName?: string; // 文件原本路径
/** /**

5
frontend/src/util/sharePath.ts

@ -24,4 +24,9 @@ export function isRootShare(path: string) : boolean {
export function turnFilePath(file: OsFileWithoutContent) : string { export function turnFilePath(file: OsFileWithoutContent) : string {
const arr = file.path.split('/') const arr = file.path.split('/')
return `/${arr[1]}/${arr[2]}/${arr[arr.length - 1]}` return `/${arr[1]}/${arr[2]}/${arr[arr.length - 1]}`
}
//返回是我的分享还是接收分享的文件路径
export function getFileRootPath(path: string) : string {
const rootPath = path.indexOf('/F/myshare') === 0 ? '/F/myshare' : '/F/othershare'
return rootPath
} }
Loading…
Cancel
Save