From 14b0e2affca5b5c5ea7d1f178f03a16a22acf11e Mon Sep 17 00:00:00 2001 From: han2015 <1019850453@qq.com> Date: Tue, 27 May 2025 15:12:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E6=88=90=E4=BA=91=E7=9B=98=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/doc/index.ts | 143 ++++++++++++++ src/api/doc/type.ts | 54 ++++++ src/utils/request.ts | 2 +- src/views/doc/manage.vue | 403 +++++++++++++++++++++++++++++++++++++++ src/views/doc/share.vue | 161 ++++++++++++++++ src/views/doc/tools.ts | 91 +++++++++ 6 files changed, 853 insertions(+), 1 deletion(-) create mode 100644 src/api/doc/index.ts create mode 100644 src/api/doc/type.ts create mode 100644 src/views/doc/manage.vue create mode 100644 src/views/doc/share.vue create mode 100644 src/views/doc/tools.ts diff --git a/src/api/doc/index.ts b/src/api/doc/index.ts new file mode 100644 index 0000000..43cb026 --- /dev/null +++ b/src/api/doc/index.ts @@ -0,0 +1,143 @@ +/** +* @ 作者: han2015 +* @ 时间: 2025-05-12 15:39:13 +* @ 备注: 文档管理API +*/ + +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { matterPage,matterResutList,createDir,createShare,respCreateShare} from './type'; + + +/** + * 获取分享列表 + */ +export function getShareList( uid:string,data?: matterPage): AxiosPromise { + return request({ + url: '/hxpan/api/share/page', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} + +/** + * share browse + */ +export function getShareBrowse( uid:string,data?: matterPage): AxiosPromise { + return request({ + url: '/hxpan/api/share/browse', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} + +/** + * share delete + */ +export function postShareDelete( uid:string,data?: matterPage): AxiosPromise { + return request({ + url: '/hxpan/api/share/delete', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} + +/** + * 获取目录文件 + */ +export function getMatterList( uid:string,data?: matterPage): AxiosPromise { + return request({ + url: '/hxpan/api/matter/page', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} +/** + * 新建目录 + */ +export function postCreateDir(uid:string,data?: createDir){ + return request({ + url: '/hxpan/api/matter/create/directory', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} + +/** + * 删除文件或目录 + */ +export function postDelMatter(uid:string,data?: any){ + return request({ + url: '/hxpan/api/matter/delete', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} +/** + * 批量删除文件或目录 + */ +export function postDelMatBatch(uid:string,data?: any){ + return request({ + url: '/hxpan/api/matter/delete/batch', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} + +/** + * 分享单个文件 + */ +export function postCreateShare(uid:string,data?: createShare): AxiosPromise{ + return request({ + url: '/hxpan/api/share/create', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} + +/** + * 更改文件名 + */ +export function postMatterRename(uid:string,data?: {uuid:string;name:string}){ + return request({ + url: '/hxpan/api/matter/rename', + method: 'post', + headers: { + 'User-Id':uid, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: data + }); +} \ No newline at end of file diff --git a/src/api/doc/type.ts b/src/api/doc/type.ts new file mode 100644 index 0000000..7304293 --- /dev/null +++ b/src/api/doc/type.ts @@ -0,0 +1,54 @@ +/** +* @ 作者: han2015 +* @ 时间: 2025-05-12 15:39:13 +* @ 备注: 文档管理api 结构定义 +*/ + +/** + * 拉去首页文件列表 + */ +export interface matterPage{ + page?:number; + pageSize?:number; + puuid?:string; + deleted?:boolean; + orderDir?:string; + name?:string; + orderCreateTime?:string; +} + +export interface matterInfo{ + name?:string; + updateTime?:string; + uuid:string; //文件uuid + userUuid?:string; //owner uuid + puuid?:string; // parent dir uuid + path?:string; + size?:number; + dir?:boolean; + deleted?:boolean; + expireInfinity?:boolean; + expireTime?:string; +} + +export type matterResutList = PageResult + +export interface createDir{ + userUuid:string; + puuid:string; + name:string; +} + +export interface createShare{ + matterUuids:string; + expireInfinity:boolean; + expireTime:string; +} + +export interface respCreateShare{ + code?:string; + shareType?:string; + expireTime?:string; + name?:string; + uuid?:string; +} \ No newline at end of file diff --git a/src/utils/request.ts b/src/utils/request.ts index 1c5a3a5..42d0e41 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -12,7 +12,7 @@ const service = axios.create({ service.interceptors.request.use( (config: InternalAxiosRequestConfig) => { const userStore = useUserStoreHook(); - config.headers["Content-Type"] = "application/json;charset=utf-8"; + //config.headers["Content-Type"] = "application/json;charset=utf-8"; if (userStore.tokenIng) { config.headers.Authorization = userStore.tokenIng; } diff --git a/src/views/doc/manage.vue b/src/views/doc/manage.vue new file mode 100644 index 0000000..38099e9 --- /dev/null +++ b/src/views/doc/manage.vue @@ -0,0 +1,403 @@ + + + + + + diff --git a/src/views/doc/share.vue b/src/views/doc/share.vue new file mode 100644 index 0000000..7bbe1c5 --- /dev/null +++ b/src/views/doc/share.vue @@ -0,0 +1,161 @@ + + + + + + diff --git a/src/views/doc/tools.ts b/src/views/doc/tools.ts new file mode 100644 index 0000000..a983a59 --- /dev/null +++ b/src/views/doc/tools.ts @@ -0,0 +1,91 @@ +import { + Document, + Picture, + VideoPlay, + Headset, + Files, + Tickets, + } from '@element-plus/icons-vue' + import { matterInfo } from "@/api/doc/type" + +export function getExpirTime(val:string){ + let now= Date.now() //haomiao + switch(val){ + case "sixhour": + now+=6*3600*1000 + break + case "oneday": + now+=24*3600*1000 + break + case "threeday": + now+=3*24*3600*1000 + break + case "oneweek": + now+=7*24*3600*1000 + break + case "onemonth": + now+=30*24*3600*1000 + break + case "threemonth": + now+=90*24*3600*1000 + break + default: + now+=6*3600*1000 + } + let nt=new Date(now) + + return nt.toISOString().slice(0,10)+" "+nt.toLocaleTimeString() + } +export function checkExpirTime(val:matterInfo){ + if (val.expireInfinity) return false + if (val.expireTime) { + let now = Date.now() //haomiao + let expireTime = new Date(val.expireTime).getTime() + if (expireTime > now) return false + } + return true +} + +export const getFileIcon = (fileName:string) => { + const extension = fileName?.split('.').pop()?.toLowerCase(); + + switch(extension) { + case 'pdf': + case 'doc': + case 'docx': + case 'xls': + case 'xlsx': + return Document; + case 'jpg': + case 'jpeg': + case 'png': + case 'gif': + case 'svg': + return Picture; + case 'mp4': + case 'mov': + case 'avi': + return VideoPlay; + case 'mp3': + case 'wav': + return Headset; + case 'zip': + case 'rar': + case '7z': + return Files; + default: + return Tickets; + } + } + + export function readableSize(val:matterInfo){ + if(val.size<1024) return "1 Kb" + //1024*1024 + if(val.size<1048576) return (val.size/1024).toFixed(1)+"Kb" + //1024*1024*1024 + if(val.size<1073741824) return (val.size/1048576).toFixed(1)+"Mb" + //1024*1024*1024*1024 + if(val.size<1099511627776) return (val.size/1073741824).toFixed(1)+"Gb" + + return "BIG" + } \ No newline at end of file