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. 94
      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']
ElAside: typeof import('element-plus/es')['ElAside']
ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElBadge: typeof import('element-plus/es')['ElBadge']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCarousel: typeof import('element-plus/es')['ElCarousel']
ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCol: typeof import('element-plus/es')['ElCol']
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDialog: typeof import('element-plus/es')['ElDialog']
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']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElImage: typeof import('element-plus/es')['ElImage']
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']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElProgress: typeof import('element-plus/es')['ElProgress']
ElRow: typeof import('element-plus/es')['ElRow']
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']
ElTransfer: typeof import('element-plus/es')['ElTransfer']
ElTree: typeof import('element-plus/es')['ElTree']
ElUpload: typeof import('element-plus/es')['ElUpload']
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({
label: t('delete'),
click: async () => {
@ -385,7 +385,7 @@ function handleRightClick(mouse: MouseEvent, item: OsFileWithoutContent, index:
})
}
const userType = sys.getConfig('userType');
if (userType == 'member' && !item.isShare) {
if (userType == 'member' && !item.isShare && !item.isDirectory) {
menuArr.push(
{

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

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

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

@ -2,7 +2,8 @@
import { t } from '@/i18n';
import { ref, onMounted } from "vue";
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 form = ref({
nickname: '',
@ -10,37 +11,49 @@ const form = ref({
const userInfo = getSystemConfig().userInfo
const dialogShow = ref(false)
let imgList = reactive([])
let pos = ref(0)
const showChange = (val) =>{
dialogShow.value = val
}
const toChangeHead = ()=>{
console.log('换头像');
const toChangeHead = async ()=>{
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 res = await fetchGet(`${userInfo.url}/files/avatarlist`)
const getHeadList = async () => {
let res = await fetchGet (`${userInfo.url}/files/avatarlist`)
// const apiUrl = getSystemConfig().apiUrl + '/upload/avatar/';
const apiUrl = userInfo.url + '/upload/avatar/';
if (res.ok) {
imgList = await res.json()
imgList = imgList.data.map(item => {
item.isChoose = false
return item
})
imgList[0].isChoose = true
res = await res.json()
for (const item of res.data) {
imgList.push({
url: apiUrl + item,
name: item
})
}
}
console.log('imgList:' , imgList);
}
let pos = ref(0)
//
const chooseImg = (index) => {
imgList.forEach(item => item.isChoose = false)
imgList[index].isChoose = true
pos.value = index
}
const onSubmit = () => {
console.log('submit!')
const onSubmit = async () => {
console.log('提交');
}
onMounted(()=>{
getHeadList()
store.userInfo.avatar = userInfo.url + '/upload/avatar/' + userInfo.avatar
})
</script>
<template>
@ -67,13 +80,20 @@ onMounted(()=>{
</el-form>
<el-dialog v-model="dialogShow" title="修改头像" width="500px" draggable>
<div>
<el-avatar
<span
v-for="(item, index) in imgList"
:key="item.name"
:size="90"
:src="item.url"
:class="{'is-active': item.isChoose}"
@click="chooseImg(index)"/>
class="img-box"
>
<el-avatar
: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>
<template #footer>
<div class="dialog-footer">
@ -89,12 +109,28 @@ onMounted(()=>{
</template>
<style scoped lang="scss">
.el-avatar {
margin: 10px;
}
.is-active {
width: 100px;
height: 100px;
border: 2px solid red;
.img-box {
position: relative;
.el-avatar {
margin: 10px;
}
.is-active {
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>

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

@ -175,7 +175,16 @@ const { refersh, createFolder, backFolder, openFolder, onComputerMount } = useCo
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)
},
notify(title, content) {

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

@ -21,14 +21,14 @@
</template>
<script lang="ts" setup>
import { ref, inject } from 'vue';
import { ref, inject, onMounted } from 'vue';
import { useSystem, BrowserWindow } from '@/system';
import { getSystemConfig, fetchPost } from "@/system/config";
import { notifySuccess, notifyError } from "@/util/msg";
const window: BrowserWindow | undefined = inject("browserWindow");
const sys = useSystem()
const userInfo: any = sys.getConfig('userInfo')
const userList = ref(userInfo.user_shares)
let userList = ref(userInfo.user_shares)
const checkAll = ref(false)
const form: any = ref({
senderid: '',
@ -68,6 +68,11 @@ const onSubmit = async () => {
notifyError("分享文件失败")
}
}
onMounted(() => {
userList.value = userList.value.filter((item: any)=> {
return item?.id !== config.value.userInfo.id
})
})
</script>
<style scoped>
.btn-group{

38
frontend/src/hook/useComputer.ts

@ -33,6 +33,8 @@ export const useComputer = (adpater: {
};
const refersh = async () => {
const currentPath = adpater.getRouter();
//console.log('refresh:', currentPath);
if (!currentPath) return;
if (currentPath.startsWith('search:')) {
const keyword = currentPath.substr(7);
@ -41,16 +43,37 @@ export const useComputer = (adpater: {
return;
}
if (!(await isVia(currentPath))) return;
// console.log('use computer refresh:', currentPath);
let result
if (currentPath === '/F/myshare' || currentPath === '/F/othershare') {
result = await adpater.sharedir(currentPath)
} else if (currentPath.indexOf('/F') === 0) {
// result = await adpater.readShareDir(file?.path || currentPath)
result = await adpater.readShareDir(currentPath)
} else {
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);
};
const createFolder = (path: RouterPath) => {
@ -72,9 +95,10 @@ export const useComputer = (adpater: {
};
const openFolder = (file: OsFileWithoutContent) => {
if (adpater.isDirectory(file)) {
// const path = file?.isShare ? file.titleName : file.path
const path = file.path
adpater.setRouter(path);
// console.log('文件:',file);
// const path = file?.isShare ? turnLocalPath(file.titleName, file.root) : file.path
// console.log('路径:', path);
adpater.setRouter(file.path);
refersh();
} else {
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 {
// 分享
async sharedir(id: number, path: string) {
// console.log('是否是根:', isRootShare(path),path);
const fun = isRootShare(path) ? handleReadShareDir : handleShareDir
const response = await fun(id, path);
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.parentPath = turnLocalPath(item.fi.parentPath ,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 result
}
return [];
},
@ -273,16 +274,26 @@ export const useOsFile = () => {
}
return [];
},
//分享文件夹取消
async readShareFileDir(id: number, path: string) {
const response = await handleShareDir(id,path);
const response = await handleShareDir(id, path)
if (response && response.data) {
return response.data.map((item: {[key: string]: OsFile}) => {
item.fi.isShare = true
item.fi.path = turnLocalPath(item.fi.path ,path,1)
return item.fi
})
return response.data
}
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) {
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; // 文件是否是系统文件(可选)
isShare?: boolean; // 文件是否为共享文件
isPwd?: boolean; //文件是否上锁
// root?: string; //分享文件的根目录
titleName?: string; // 文件原本路径
/**

5
frontend/src/util/sharePath.ts

@ -25,3 +25,8 @@ export function turnFilePath(file: OsFileWithoutContent) : string {
const arr = file.path.split('/')
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