From 7653864bd73145a41cb473361c5f5c265cdddc35 Mon Sep 17 00:00:00 2001 From: gavingaozhangmin Date: Fri, 4 Aug 2023 19:11:24 +0800 Subject: [PATCH] Support ResourcePan and BackupPan --- src/aliapi/dirfilelist.ts | 9 +- src/aliapi/user.ts | 5 +- src/aliapi/utils.ts | 4 +- src/down/DownUploaded.vue | 12 +- src/layout/MyModal.vue | 117 +- src/layout/PageMain.vue | 40 +- src/layout/PageVideo.vue | 12 +- src/pan/PanLeft.vue | 37 +- src/pan/PanRight.vue | 14 +- src/pan/menus/DirLeftMenu.vue | 12 +- src/pan/menus/FileRightMenu.vue | 12 +- src/pan/menus/FileTopbtn.vue | 6 +- src/pan/menus/PanTopbtn.vue | 2 +- src/pan/topbtns/ArchiveModal.vue | 2 +- src/pan/topbtns/ArchivePasswordModal.vue | 2 +- src/pan/topbtns/RenameModal.vue | 2 +- src/pan/topbtns/SelectPanDirModal.vue | 4 +- src/pan/topbtns/topbtn.ts | 16 +- src/resPan/ResPanLeft.vue | 442 ++++++ src/resPan/ResPanRight.vue | 1216 +++++++++++++++++ src/resPan/index.vue | 22 + src/resPan/menus/ResDirLeftMenu.vue | 99 ++ src/resPan/menus/ResDirTopPath.vue | 111 ++ src/resPan/menus/ResFileRightMenu.vue | 179 +++ src/resPan/menus/ResFileTopbtn.vue | 119 ++ src/resPan/menus/ResPanTopbtn.vue | 59 + src/resPan/menus/ResTrashRightMenu.vue | 36 + src/resPan/menus/ResTrashTopbtn.vue | 35 + src/resPan/pandal.ts | 325 +++++ src/resPan/panfilestore.ts | 422 ++++++ src/resPan/pantreestore.ts | 204 +++ src/resPan/topbtns/AlphaModal.vue | 85 ++ src/resPan/topbtns/ArchiveModal.vue | 354 +++++ src/resPan/topbtns/ArchivePasswordModal.vue | 130 ++ src/resPan/topbtns/CopyFileTreeModal.vue | 372 +++++ src/resPan/topbtns/CreatNewAlbumModal.vue | 113 ++ src/resPan/topbtns/CreatNewDirModal.vue | 167 +++ src/resPan/topbtns/CreatNewDirMultiModal.vue | 47 + src/resPan/topbtns/CreatNewFileModal.vue | 135 ++ src/resPan/topbtns/CreatNewShareLinkModal.vue | 217 +++ src/resPan/topbtns/DLNAPlayerModal.vue | 162 +++ src/resPan/topbtns/DaoRuShareLinkModal.vue | 164 +++ .../topbtns/DaoRuShareLinkMultiModal.vue | 143 ++ src/resPan/topbtns/DownloadModal.vue | 96 ++ src/resPan/topbtns/M3U8DownloadModal.vue | 232 ++++ src/resPan/topbtns/MoveToAlbumModal.vue | 129 ++ src/resPan/topbtns/RenameModal.vue | 172 +++ src/resPan/topbtns/RenameMultiModal.vue | 1194 ++++++++++++++++ src/resPan/topbtns/ResTopbtn.ts | 709 ++++++++++ src/resPan/topbtns/SearchPanModal.vue | 219 +++ src/resPan/topbtns/SelectPanDirModal.vue | 418 ++++++ src/resPan/topbtns/ShuXingModal.vue | 395 ++++++ src/resPan/topbtns/ShuXingMultiModal.vue | 47 + src/resPan/topbtns/UploadModal.vue | 131 ++ src/resPan/topbtns/renamemulti.ts | 605 ++++++++ src/resource/searchIndex.vue | 4 +- src/rss/appsame/AppSame.vue | 4 +- src/rss/rssdrivecopy/RssDriveCopy.vue | 4 +- src/rss/rssscanclean/RssScanClean.vue | 4 +- src/rss/rssscanenmpty/RssScanEnmpty.vue | 6 +- src/rss/rssscanpunish/RssScanPunish.vue | 8 +- src/rss/rssscansame/RssScanSame.vue | 4 +- src/rss/rssusercopy/RssUserCopy.vue | 4 +- src/setting/settingstore.ts | 10 +- src/share/share/ShowShareLinkModal.vue | 2 +- src/store/appstore.ts | 12 +- src/store/index.ts | 4 + src/user/UserLogin.vue | 2 +- src/user/userdal.ts | 9 +- src/user/userstore.ts | 6 +- src/utils/keyboardhelper.ts | 4 +- src/utils/modal.ts | 113 +- src/utils/openfile.ts | 37 +- 73 files changed, 10050 insertions(+), 200 deletions(-) create mode 100644 src/resPan/ResPanLeft.vue create mode 100644 src/resPan/ResPanRight.vue create mode 100644 src/resPan/index.vue create mode 100644 src/resPan/menus/ResDirLeftMenu.vue create mode 100644 src/resPan/menus/ResDirTopPath.vue create mode 100644 src/resPan/menus/ResFileRightMenu.vue create mode 100644 src/resPan/menus/ResFileTopbtn.vue create mode 100644 src/resPan/menus/ResPanTopbtn.vue create mode 100644 src/resPan/menus/ResTrashRightMenu.vue create mode 100644 src/resPan/menus/ResTrashTopbtn.vue create mode 100644 src/resPan/pandal.ts create mode 100644 src/resPan/panfilestore.ts create mode 100644 src/resPan/pantreestore.ts create mode 100644 src/resPan/topbtns/AlphaModal.vue create mode 100644 src/resPan/topbtns/ArchiveModal.vue create mode 100644 src/resPan/topbtns/ArchivePasswordModal.vue create mode 100644 src/resPan/topbtns/CopyFileTreeModal.vue create mode 100644 src/resPan/topbtns/CreatNewAlbumModal.vue create mode 100644 src/resPan/topbtns/CreatNewDirModal.vue create mode 100644 src/resPan/topbtns/CreatNewDirMultiModal.vue create mode 100644 src/resPan/topbtns/CreatNewFileModal.vue create mode 100644 src/resPan/topbtns/CreatNewShareLinkModal.vue create mode 100644 src/resPan/topbtns/DLNAPlayerModal.vue create mode 100644 src/resPan/topbtns/DaoRuShareLinkModal.vue create mode 100644 src/resPan/topbtns/DaoRuShareLinkMultiModal.vue create mode 100644 src/resPan/topbtns/DownloadModal.vue create mode 100644 src/resPan/topbtns/M3U8DownloadModal.vue create mode 100644 src/resPan/topbtns/MoveToAlbumModal.vue create mode 100644 src/resPan/topbtns/RenameModal.vue create mode 100644 src/resPan/topbtns/RenameMultiModal.vue create mode 100644 src/resPan/topbtns/ResTopbtn.ts create mode 100644 src/resPan/topbtns/SearchPanModal.vue create mode 100644 src/resPan/topbtns/SelectPanDirModal.vue create mode 100644 src/resPan/topbtns/ShuXingModal.vue create mode 100644 src/resPan/topbtns/ShuXingMultiModal.vue create mode 100644 src/resPan/topbtns/UploadModal.vue create mode 100644 src/resPan/topbtns/renamemulti.ts diff --git a/src/aliapi/dirfilelist.ts b/src/aliapi/dirfilelist.ts index 28d58e6..bae3c5c 100644 --- a/src/aliapi/dirfilelist.ts +++ b/src/aliapi/dirfilelist.ts @@ -1,4 +1,4 @@ -import { usePanFileStore, useSettingStore } from '../store' +import { usePanFileStore, useResPanFileStore, useSettingStore } from '../store' import TreeStore from '../store/treestore' import DebugLog from '../utils/debuglog' import { OrderDir, OrderFile } from '../utils/filenameorder' @@ -639,7 +639,12 @@ export default class AliDirFileList { if (pageIndex >= 0 && type == '') { const pan = usePanFileStore() - if (pan.DriveID == dir.m_drive_id) pan.mSaveDirFileLoadingPart(pageIndex, dirPart, dir.itemsTotal || 0) + if (pan.DriveID == dir.m_drive_id) { + pan.mSaveDirFileLoadingPart(pageIndex, dirPart, dir.itemsTotal || 0) + } else { + const resPan = useResPanFileStore(); + resPan.mSaveDirFileLoadingPart(pageIndex, dirPart, dir.itemsTotal || 0) + } } if (dirPart.next_marker == 'cancel') dir.next_marker = 'cancel' if (isVideo && dir.items.length >= 500) dir.next_marker = '' diff --git a/src/aliapi/user.ts b/src/aliapi/user.ts index 1b7eac4..f100006 100644 --- a/src/aliapi/user.ts +++ b/src/aliapi/user.ts @@ -163,7 +163,6 @@ export default class AliUser { token.user_name = resp.body.user_name token.avatar = resp.body.avatar token.nick_name = resp.body.nick_name - token.default_drive_id = resp.body.default_drive_id token.default_sbox_drive_id = resp.body.default_sbox_drive_id token.role = resp.body.role token.status = resp.body.status @@ -213,7 +212,7 @@ export default class AliUser { if (AliHttp.IsSuccess(resp.code)) { token.spu_id = '' token.phone = resp.body.phone - token.default_drive_id = resp.body.backup_drive_id; + token.backup_drive_id = resp.body.backup_drive_id; token.resource_drive_id = resp.body.resource_drive_id; token.is_expires = resp.body.status === 'enabled' token.name = resp.body.nick_name===''?resp.body.phone:resp.body.nick_name @@ -370,7 +369,7 @@ export default class AliUser { if (!token) return 0 const url = 'adrive/v1.0/openFile/search' const postData = { - drive_id: token?.default_drive_id, + drive_id: token?.backup_drive_id, marker: '', limit: 1, all: false, diff --git a/src/aliapi/utils.ts b/src/aliapi/utils.ts index de70c69..4e62b79 100644 --- a/src/aliapi/utils.ts +++ b/src/aliapi/utils.ts @@ -18,7 +18,7 @@ export function GetDriveID(user_id: string, drive: Drive): string { if (token) { switch (drive) { case 'pan': - return token.default_drive_id + return token.backup_drive_id case 'pic': return token.pic_drive_id case 'safe': @@ -33,7 +33,7 @@ export function GetDriveID2(token: ITokenInfo, driveName: string): string { if (token) { switch (driveName) { case 'pan': - return token.default_drive_id + return token.backup_drive_id case 'pic': return token.pic_drive_id case 'safe': diff --git a/src/down/DownUploaded.vue b/src/down/DownUploaded.vue index 89bd89f..006dcc8 100644 --- a/src/down/DownUploaded.vue +++ b/src/down/DownUploaded.vue @@ -1,5 +1,5 @@ + + + + diff --git a/src/resPan/ResPanRight.vue b/src/resPan/ResPanRight.vue new file mode 100644 index 0000000..43afd40 --- /dev/null +++ b/src/resPan/ResPanRight.vue @@ -0,0 +1,1216 @@ + + + + + + diff --git a/src/resPan/index.vue b/src/resPan/index.vue new file mode 100644 index 0000000..67ee443 --- /dev/null +++ b/src/resPan/index.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/src/resPan/menus/ResDirLeftMenu.vue b/src/resPan/menus/ResDirLeftMenu.vue new file mode 100644 index 0000000..a2af206 --- /dev/null +++ b/src/resPan/menus/ResDirLeftMenu.vue @@ -0,0 +1,99 @@ + + + + diff --git a/src/resPan/menus/ResDirTopPath.vue b/src/resPan/menus/ResDirTopPath.vue new file mode 100644 index 0000000..3bce3cb --- /dev/null +++ b/src/resPan/menus/ResDirTopPath.vue @@ -0,0 +1,111 @@ + + + + diff --git a/src/resPan/menus/ResFileRightMenu.vue b/src/resPan/menus/ResFileRightMenu.vue new file mode 100644 index 0000000..f9eb2c4 --- /dev/null +++ b/src/resPan/menus/ResFileRightMenu.vue @@ -0,0 +1,179 @@ + + + + diff --git a/src/resPan/menus/ResFileTopbtn.vue b/src/resPan/menus/ResFileTopbtn.vue new file mode 100644 index 0000000..23316c8 --- /dev/null +++ b/src/resPan/menus/ResFileTopbtn.vue @@ -0,0 +1,119 @@ + + + + diff --git a/src/resPan/menus/ResPanTopbtn.vue b/src/resPan/menus/ResPanTopbtn.vue new file mode 100644 index 0000000..1b2c8db --- /dev/null +++ b/src/resPan/menus/ResPanTopbtn.vue @@ -0,0 +1,59 @@ + + + + diff --git a/src/resPan/menus/ResTrashRightMenu.vue b/src/resPan/menus/ResTrashRightMenu.vue new file mode 100644 index 0000000..b3332fb --- /dev/null +++ b/src/resPan/menus/ResTrashRightMenu.vue @@ -0,0 +1,36 @@ + + + + diff --git a/src/resPan/menus/ResTrashTopbtn.vue b/src/resPan/menus/ResTrashTopbtn.vue new file mode 100644 index 0000000..f69d83e --- /dev/null +++ b/src/resPan/menus/ResTrashTopbtn.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/src/resPan/pandal.ts b/src/resPan/pandal.ts new file mode 100644 index 0000000..d97458b --- /dev/null +++ b/src/resPan/pandal.ts @@ -0,0 +1,325 @@ +import { IAliGetDirModel } from '../aliapi/alimodels' +import AliFile from '../aliapi/file' +import AliDirFileList from '../aliapi/dirfilelist' +import { useFootStore, useResPanFileStore } from '../store' +import TreeStore, { IDriverModel, TreeNodeData } from '../store/treestore' +import DB from '../utils/db' +import DebugLog from '../utils/debuglog' +import message from '../utils/message' +import useResPanTreeStore from './pantreestore' + +export interface PanSelectedData { + isError: boolean + isErrorSelected: boolean + user_id: string + drive_id: string + dirID: string + parentDirID: string + selectedKeys: string[] + selectedParentKeys: string[] +} + +const RefreshLock = new Set() + +export default class PanDAL { + + static async aReLoadDrive(user_id: string, drive_id: string): Promise { + const pantreeStore = useResPanTreeStore() + pantreeStore.mSaveUser(user_id, drive_id) + if (!user_id || !drive_id) return + + const cache = await DB.getValueObject('AllDir_' + drive_id) + if (cache) { + console.log('aReLoadDrive cache') + await TreeStore.ConvertToOneDriver(drive_id, cache as IAliGetDirModel[], false, true) + // PanDAL.RefreshPanTreeAllNode(drive_id) + } + await PanDAL.aReLoadOneDirToShow(drive_id, 'root', true) + if (cache) { + const dt = await DB.getValueNumber('AllDir_' + drive_id) + if (Date.now() - dt < 1000 * 60 * 60) { + return + } + } + + useFootStore().mSaveLoading('加载全部文件夹...') + window.WinMsgToUpload({ cmd: 'AllDirList', user_id, drive_id }) + } + + static async aReLoadDriveSave(OneDriver: IDriverModel, error: string): Promise { + if (error == 'time') return + if (!error) { + TreeStore.SaveOneDriver(OneDriver) + PanDAL.RefreshPanTreeAllNode(OneDriver.drive_id) + } else { + message.error('列出全盘文件夹失败' + error) + } + useFootStore().mSaveLoading('') + } + + + static RefreshPanTreeAllNode(drive_id: string) { + const OneDriver = TreeStore.GetDriver(drive_id) + if (!OneDriver) return + console.log('RefreshPanTreeAllNode') + const pantreeStore = useResPanTreeStore() + const expandedKeys = new Set(pantreeStore.treeExpandedKeys) + + const dir: TreeNodeData = { __v_skip: true, title: '根目录', namesearch: '', key: 'root', children: [] } + const map = new Map() + TreeStore.GetTreeDataToShow(OneDriver, dir, expandedKeys, map, true) + map.set(dir.key, dir) + pantreeStore.mSaveTreeAllNode(OneDriver.drive_id, dir, map) + } + + static GetPanTreeAllNode(drive_id: string, treeExpandedKeys: string[], getChildren: boolean = true, isLeafForce: boolean = false): TreeNodeData[] { + const OneDriver = TreeStore.GetDriver(drive_id) + if (!OneDriver) return [] + console.log('GetPanTreeAllNode') + const expandedKeys = new Set(treeExpandedKeys) + const dir: TreeNodeData = { __v_skip: true, title: '根目录', namesearch: '', key: 'root', children: [] } + const map = new Map() + TreeStore.GetTreeDataToShow(OneDriver, dir, expandedKeys, map, getChildren, '', isLeafForce) + map.set(dir.key, dir) + return [dir] + } + + + static aTreeScrollToDir(dirID: string) { + useResPanTreeStore().mSaveTreeScrollTo(dirID) + } + + + static async aReLoadOneDirToShow(drive_id: string, file_id: string, selfExpand: boolean): Promise { + const pantreeStore = useResPanTreeStore() + if (!drive_id) drive_id = pantreeStore.drive_id + if (!drive_id) return false + if (file_id == 'refresh') file_id = pantreeStore.selectDir.file_id + const isBack = file_id == 'back' + if (isBack) { + if (pantreeStore.History.length > 0) { + pantreeStore.History.splice(0, 1) + if (pantreeStore.History.length > 0) { + drive_id = pantreeStore.History[0].drive_id + file_id = pantreeStore.History[0].file_id + } + } + if (file_id == 'back') { + pantreeStore.History = [] + file_id = 'root' + } + } + + let dir = TreeStore.GetDir(drive_id, file_id) + let dirPath = TreeStore.GetDirPath(drive_id, file_id) + if (!dir || (dirPath.length == 0 && file_id != 'root')) { + const findPath = await AliFile.ApiFileGetPath(pantreeStore.user_id, drive_id, file_id) + if (findPath.length > 0) { + dirPath = findPath + dir = { ...dirPath[dirPath.length - 1] } + } + } + + if (!dir || (dirPath.length == 0 && file_id != 'root')) { + message.error('出错,找不到指定的文件夹 ' + file_id) + return false + } + + // 记录跳转历史 + if (!isBack && pantreeStore.selectDir.file_id != dir.file_id) { + const history: IAliGetDirModel[] = [dir] + for (let i = 0, maxi = pantreeStore.History.length; i < maxi; i++) { + const his = pantreeStore.History[i] + history.push(his) + if (history.length >= 50) break + } + pantreeStore.History = history + } + + const treeExpandedKeys = new Set(pantreeStore.treeExpandedKeys) + treeExpandedKeys.add('root') + for (let i = 0, maxi = dirPath.length - 1; i < maxi; i++) { + treeExpandedKeys.add(dirPath[i].file_id) + } + if (selfExpand) treeExpandedKeys.add(dir.file_id) + pantreeStore.mShowDir(dir, dirPath, [dir.file_id], Array.from(treeExpandedKeys)) + PanDAL.RefreshPanTreeAllNode(drive_id) + const panfileStore = useResPanFileStore() + if (panfileStore.ListLoading && panfileStore.DriveID == drive_id && panfileStore.DirID == dir.file_id) return false + panfileStore.mSaveDirFileLoading(drive_id, dir.file_id, dir.name) + return PanDAL.GetDirFileList(pantreeStore.user_id, dir.drive_id, dir.file_id, dir.name) + } + + + static GetDirFileList(user_id: string, drive_id: string, dirID: string, dirName: string, hasFiles: boolean = true): Promise { + return new Promise((resolve) => { + if (dirID == 'search') { + if (hasFiles) useResPanFileStore().mSaveDirFileLoadingFinish(drive_id, dirID, []) + resolve(true) + return + } + + const order = TreeStore.GetDirOrder(drive_id, dirID).replace('ext ', 'updated_at ') + AliDirFileList.ApiDirFileList(user_id, drive_id, dirID, dirName, order, hasFiles ? '' : 'folder') + .then((dir) => { + if (!dir.next_marker) { + TreeStore.SaveOneDirFileList(dir, hasFiles).then(() => { + if (hasFiles) useResPanFileStore().mSaveDirFileLoadingFinish(drive_id, dirID, dir.items, dir.itemsTotal || 0) + PanDAL.RefreshPanTreeAllNode(drive_id) + resolve(true) + }) + } else if (dir.next_marker == 'cancel') { + resolve(false) + } else { + message.warning('列出文件夹失败 ' + dir.next_marker) + if (hasFiles) useResPanFileStore().mSaveDirFileLoadingFinish(drive_id, dirID, []) + resolve(false) + } + }) + .catch((err: any) => { + if (hasFiles) useResPanFileStore().mSaveDirFileLoadingFinish(drive_id, dirID, []) + message.warning('列出文件夹失败 ' + (err.message || '')) + DebugLog.mSaveWarning('列出文件夹失败file_id=' + dirID, err) + resolve(false) + }) + }) + } + + + static aReLoadOneDirToRefreshTree(user_id: string, drive_id: string, dirID: string): Promise { + return new Promise((resolve) => { + if (dirID == 'favorite' || dirID.startsWith('color') || dirID.startsWith('search') || dirID.startsWith('video')) { + resolve(true) + return + } + if (RefreshLock.has(dirID)) { + resolve(true) + return + } + RefreshLock.add(dirID) + const order = TreeStore.GetDirOrder(drive_id, dirID).replace('ext ', 'updated_at ') + AliDirFileList.ApiDirFileList(user_id, drive_id, dirID, '', order, 'folder') + .then((dir) => { + if (!dir.next_marker) { + TreeStore.SaveOneDirFileList(dir, false).then(() => { + + PanDAL.RefreshPanTreeAllNode(drive_id) + + const pantreeStore = useResPanTreeStore() + if (pantreeStore.selectDir.drive_id == drive_id && pantreeStore.selectDir.file_id == dirID) { + PanDAL.aReLoadOneDirToShow(drive_id, dirID, false).then(() => { + RefreshLock.delete(dirID) + resolve(true) + }) + } else { + RefreshLock.delete(dirID) + resolve(true) + } + }) + } else if (dir.next_marker == 'cancel') { + RefreshLock.delete(dirID) + resolve(false) + } else { + RefreshLock.delete(dirID) + resolve(false) + } + }) + .catch((err: any) => { + DebugLog.mSaveWarning('列出文件夹失败file_id=' + dirID, err) + RefreshLock.delete(dirID) + resolve(false) + }) + }) + } + + static GetPanSelectedData(istree: boolean): PanSelectedData { + const pantreeStore = useResPanTreeStore() + const data: PanSelectedData = { + isError: false, + isErrorSelected: false, + user_id: pantreeStore.user_id, + drive_id: pantreeStore.drive_id, + dirID: pantreeStore.selectDir.file_id, + parentDirID: pantreeStore.selectDir.parent_file_id, + selectedKeys: istree ? [pantreeStore.selectDir.file_id] : useResPanFileStore().GetSelectedID(), + selectedParentKeys: istree ? [pantreeStore.selectDir.parent_file_id] : useResPanFileStore().GetSelectedParentDirID() + } + + data.isError = !data.user_id || !data.drive_id || !data.dirID + data.isErrorSelected = data.selectedKeys.length == 0 + return data + } + + static updateQuickFile(list: { key: string; title: string }[]) { + if (list.length == 0) return + const pantreeStore = useResPanTreeStore() + const jsonstr = localStorage.getItem('FileQuick-' + pantreeStore.user_id) + const arr = jsonstr ? JSON.parse(jsonstr) : [] + list.map((t) => { + let find = false + for (let i = 0; i < arr.length; i++) { + if (arr[i].key == t.key) { + arr[i].title = t.title + find = true + } + } + if (find == false) arr.push({ key: t.key, title: t.title }) + return true + }) + localStorage.setItem('FileQuick-' + pantreeStore.user_id, JSON.stringify(arr)) + pantreeStore.mSaveQuick(arr) + } + + + static deleteQuickFile(key: string) { + if (!key) return + const pantreeStore = useResPanTreeStore() + const jsonstr = localStorage.getItem('FileQuick-' + pantreeStore.user_id) + const arr = jsonstr ? JSON.parse(jsonstr) : [] + const newArray: { key: string; title: string }[] = [] + for (let i = 0; i < arr.length; i++) { + if (arr[i].key != key) newArray.push(arr[i]) + } + localStorage.setItem('FileQuick-' + pantreeStore.user_id, JSON.stringify(newArray)) + pantreeStore.mSaveQuick(newArray) + } + + + static getQuickFileList() { + const pantreeStore = useResPanTreeStore() + const jsonstr = localStorage.getItem('FileQuick-' + pantreeStore.user_id) + const arr = jsonstr ? JSON.parse(jsonstr) : [] + return arr + } + + + static aReLoadQuickFile(user_id: string) { + const jsonstr = localStorage.getItem('FileQuick-' + user_id) + const arr = jsonstr ? JSON.parse(jsonstr) : [] + useResPanTreeStore().mSaveQuick(arr) + } + + + static async aUpdateDirFileSize(): Promise { + const pantreeStore = useResPanTreeStore() + const user_id = pantreeStore.user_id + const drive_id = pantreeStore.drive_id + + const diridList = TreeStore.GetDirSizeNeedRefresh(drive_id, 604800) + const partList: string[] = [] + for (let i = 0, maxi = diridList.length; i < maxi; i++) { + partList.push(diridList[i]) + if (partList.length >= 30) { + const partResult = await AliDirFileList.ApiDirFileSize(user_id, drive_id, partList) + if (!partResult) return + if (partResult) TreeStore.SaveDirSizeNeedRefresh(drive_id, partResult) + partList.length = 0 + } + } + if (partList.length > 0) { + const partResult = await AliDirFileList.ApiDirFileSize(user_id, drive_id, partList) + if (partResult) TreeStore.SaveDirSizeNeedRefresh(drive_id, partResult) + partList.length = 0 + } + } +} diff --git a/src/resPan/panfilestore.ts b/src/resPan/panfilestore.ts new file mode 100644 index 0000000..8ed637e --- /dev/null +++ b/src/resPan/panfilestore.ts @@ -0,0 +1,422 @@ +import { defineStore } from 'pinia' +import { IAliGetFileModel } from '../aliapi/alimodels' +import { ArrayToMap } from '../utils/utils' +import fuzzysort from 'fuzzysort' +import { + GetFocusNext, + GetSelectedList, + GetSelectedListID, + KeyboardSelectOne, + MouseSelectOne, + SelectAll +} from '../utils/selecthelper' +import { IAliFileResp } from '../aliapi/dirfilelist' +import PanDAL from './pandal' +import TreeStore from '../store/treestore' +import { useFootStore } from '../store' + +type Item = IAliGetFileModel + +export interface GridItem { + file_id: string + files: IAliGetFileModel[] +} + +export interface PanFileState { + DriveID: string + DirID: string + DirName: string + + ListLoading: boolean + ListLoadingIndex: number + + ListDataRaw: Item[] + + ListDataShow: Item[] + ListDataGrid: GridItem[] + + + ListSelected: Set + + ListOrderKey: string + + ListFocusKey: string + + ListSelectKey: string + + ListSearchKey: string + + ListShowMode: string + ListShowColumn: number + + + scrollToFile: string +} + +type State = PanFileState +const KEY = 'file_id' + +const useResPanFileStore = defineStore('respanfile', { + state: (): State => ({ + DriveID: '', + DirID: '', + DirName: '', + + ListLoading: false, + ListLoadingIndex: 0, + ListDataRaw: [], + ListDataShow: [], + ListDataGrid: [], + ListSelected: new Set(), + ListOrderKey: 'name asc', + ListFocusKey: '', + ListSelectKey: '', + ListSearchKey: '', + ListShowMode: 'list', + ListShowColumn: 1, + scrollToFile: '' + }), + + getters: { + ListDataCount(state: State): number { + return state.ListDataShow.length + }, + + IsListSelected(state: State): boolean { + return state.ListSelected.size > 0 + }, + + IsListSelectedMulti(state: State): boolean { + return state.ListSelected.size > 1 + }, + ListSelectedCount(state: State): number { + return state.ListSelected.size + }, + ListDataSelectCountInfo(state: State): string { + return '已选中 ' + state.ListSelected.size + ' / ' + state.ListDataShow.length + ' 个' + }, + + IsListSelectedAll(state: State): boolean { + return state.ListSelected.size > 0 && state.ListSelected.size == state.ListDataShow.length + }, + + IsListSelectedFavAll(state: State): boolean { + const list = state.ListDataShow + const len = list.length + let isAllFav = true + + for (let i = 0, maxi = len; i < maxi; i++) { + if (state.ListSelected.has(list[i].file_id)) { + if (!list[i].starred) { + isAllFav = false + break + } + } + } + + return isAllFav + }, + SelectDirType(state: State): string { + const file_id = state.DirID + if (file_id == 'recover') return 'recover' + if (file_id == 'trash') return 'trash' + if (file_id == 'favorite') return 'favorite' + if (file_id.startsWith('search')) return 'search' + if (file_id.startsWith('color')) return 'color' + if (file_id.startsWith('video')) return 'video' + return 'pan' + }, + FileOrderDesc(state: State): string { + switch (state.ListOrderKey) { + case 'name desc': + return '名称 · 降' + case 'name asc': + return '名称 · 升' + case 'updated_at desc': + return '时间 · 降' + case 'updated_at asc': + return '时间 · 升' + case 'size desc': + return '大小 · 降' + case 'size asc': + return '大小 · 升' + } + return '选择文件排序' + } + }, + + actions: { + + mSaveDirFileLoading(drive_id: string, dirID: string, dirName: string) { + const order = TreeStore.GetDirOrder(drive_id, dirID) + if (this.DirID != dirID || this.DriveID != drive_id) { + this.$patch({ + DriveID: drive_id, + DirID: dirID, + DirName: dirName, + ListOrderKey: order, + ListLoading: true, + ListLoadingIndex: 0, + ListSearchKey: '', + ListDataRaw: [], + ListDataShow: [], + ListDataGrid: [], + ListSelected: new Set(), + ListFocusKey: '', + ListSelectKey: '' + }) + } else { + this.$patch({ + DriveID: drive_id, + DirID: dirID, + DirName: dirName, + ListOrderKey: order, + ListLoading: true, + ListLoadingIndex: 0, + ListSearchKey: '', + ListDataRaw: [], + ListDataShow: [], + ListDataGrid: [] + }) + } + useFootStore().mSaveDirInfo('pan', '文件列表加载中...') + }, + + mSaveDirFileLoadingPart(pageIndex: number, partDir: IAliFileResp, itemsTotal: number = 0) { + if (pageIndex != this.ListLoadingIndex || partDir.m_drive_id != this.DriveID || partDir.dirID != this.DirID) { + partDir.next_marker = 'cancel' + } else { + this.ListLoadingIndex++ + this.ListDataRaw = this.ListDataRaw.concat(partDir.items) + this.mRefreshListDataShow(true) + if (itemsTotal > 0) useFootStore().mSaveDirInfo('pan', '文件列表加载中... 总:' + itemsTotal) + } + }, + + mSaveDirFileLoadingFinish(drive_id: string, dirID: string, list: Item[], itemsTotal: number = 0) { + if (this.DirID && (drive_id != this.DriveID || dirID != this.DirID)) return + if (list.length == 0) { + this.ListDataRaw = [] + this.mRefreshListDataShow(true) + } + + this.$patch({ ListLoading: false, ListLoadingIndex: 0 }) + this.mRefreshListDataShow(true) + let panInfo = '' + if (itemsTotal == -1) panInfo = '' + else if (list.length == 0 && itemsTotal == 0) panInfo = '空文件夹' + else { + let dirCount = 0 + let fileCount = 0 + list.map((t) => { + if (t.isDir) dirCount++ + else fileCount++ + return true + }) + panInfo = '文件夹:' + dirCount + ' 文件:' + fileCount + ' 总:' + itemsTotal + } + useFootStore().mSaveDirInfo('pan', panInfo) + }, + + mSearchListData(value: string) { + this.$patch({ ListSelected: new Set(), ListFocusKey: '', ListSelectKey: '', ListSearchKey: value }) + this.mRefreshListDataShow(true) + }, + + mOrderListData(value: string) { + if (!value || value == this.ListOrderKey) return + TreeStore.SaveDirOrder(this.DriveID, this.DirID, value) + this.$patch({ ListOrderKey: value, ListSelected: new Set(), ListFocusKey: '', ListSelectKey: '' }) + PanDAL.aReLoadOneDirToShow('', 'refresh', false) + }, + + mGridListData(value: string, column: number) { + if (this.ListShowMode == value && this.ListShowColumn == column) return + this.$patch({ ListShowMode: value == 'list' ? 'list' : 'grid', ListShowColumn: value == 'list' ? 1 : column }) + this.mRefreshListDataShow(true) + }, + + mRefreshListDataShow(refreshRaw: boolean) { + if (!refreshRaw) { + const listDataShow = this.ListDataShow.concat() + Object.freeze(listDataShow) + const listDataGrid = this.ListDataGrid.concat() + Object.freeze(listDataGrid) + this.$patch({ ListDataShow: listDataShow, ListDataGrid: listDataGrid }) + return + } + let showList: Item[] = [] + if (this.ListSearchKey) { + const results = fuzzysort.go(this.ListSearchKey, this.ListDataRaw, { + threshold: -200000, + keys: ['name', 'namesearch'], + scoreFn: (a) => Math.max(a[0] ? a[0].score : -200000, a[1] ? a[1].score : -200000) + }) + for (let i = 0, maxi = results.length; i < maxi; i++) { + if (results[i].score > -200000) showList.push(results[i].obj) + } + } else { + showList = this.ListDataRaw.concat() + } + Object.freeze(showList) + const gridList: GridItem[] = [] + const column = this.ListShowColumn + for (let i = 0, maxi = showList.length; i < maxi; i += column) { + const grid: GridItem = { + file_id: showList[i].file_id, + files: [showList[i]] + } + for (let j = 1; j < column && i + j < maxi; j++) { + grid.files.push(showList[i + j]) + } + gridList.push(grid) + } + Object.freeze(gridList) + const oldSelected = this.ListSelected + const newSelected = new Set() + let key = '' + for (let i = 0, maxi = showList.length; i < maxi; i++) { + key = showList[i][KEY] + if (oldSelected.has(key)) newSelected.add(key) + } + this.$patch({ ListDataShow: showList, ListDataGrid: gridList, ListSelected: newSelected }) + }, + + mSelectAll() { + let selectKey = this.ListDataShow[0].file_id + let ListSelected = SelectAll(this.ListDataShow, KEY, this.ListSelected) + if (this.ListDataShow.length === this.ListSelected.size) selectKey = '' + this.$patch({ ListSelected: ListSelected, ListFocusKey: selectKey, ListSelectKey: selectKey }) + this.mRefreshListDataShow(false) + }, + + mMouseSelect(key: string, Ctrl: boolean, Shift: boolean) { + if (this.ListDataShow.length == 0) return + const data = MouseSelectOne(this.ListDataShow, KEY, this.ListSelected, this.ListFocusKey, this.ListSelectKey, key, Ctrl, Shift, '') + this.$patch({ ListSelected: data.selectedNew, ListFocusKey: data.focusLast, ListSelectKey: data.selectedLast }) + this.mRefreshListDataShow(false) + }, + + mKeyboardSelect(key: string, Ctrl: boolean, Shift: boolean) { + if (this.ListDataShow.length == 0) return + const data = KeyboardSelectOne(this.ListDataShow, KEY, this.ListSelected, this.ListFocusKey, this.ListSelectKey, key, Ctrl, Shift, '') + this.$patch({ ListSelected: data.selectedNew, ListFocusKey: data.focusLast, ListSelectKey: data.selectedLast }) + this.mRefreshListDataShow(false) + }, + mRangSelect(lastkey: string, file_idList: string[]) { + if (this.ListDataShow.length == 0) return + const selectedNew = new Set(this.ListSelected) + for (let i = 0, maxi = file_idList.length; i < maxi; i++) { + selectedNew.add(file_idList[i]) + } + this.$patch({ ListSelected: selectedNew, ListFocusKey: lastkey, ListSelectKey: lastkey }) + this.mRefreshListDataShow(false) + }, + + GetSelected() { + return GetSelectedList(this.ListDataShow, KEY, this.ListSelected) + }, + + GetSelectedID() { + return GetSelectedListID(this.ListDataShow, KEY, this.ListSelected) + }, + + GetSelectedParentDirID() { + return GetSelectedListID(this.ListDataShow, 'parent_file_id', this.ListSelected) + }, + + GetSelectedFirst(): Item | undefined { + const list = GetSelectedList(this.ListDataShow, KEY, this.ListSelected) + if (list.length > 0) return list[0] + return undefined + }, + mSetFocus(key: string) { + this.ListFocusKey = key + this.mRefreshListDataShow(false) + }, + + mGetFocus(): string { + if (!this.ListFocusKey && this.ListDataShow.length > 0) return this.ListDataShow[0][KEY] + return this.ListFocusKey + }, + + mGetFocusNext(position: string): string { + return GetFocusNext(this.ListDataShow, KEY, this.ListFocusKey, position, '') + }, + + mDeleteFiles(dirID: string, file_idList: string[], needDelDir: boolean) { + if (this.DirID == dirID || dirID == 'any') { + const fileMap = new Set(file_idList) + const listDataRaw = this.ListDataRaw + const newDataList: Item[] = [] + const diridList: string[] = [] + let deleteCount = 0 + for (let i = 0, maxi = listDataRaw.length; i < maxi; i++) { + const item = listDataRaw[i] + if (fileMap.has(item.file_id)) { + + deleteCount++ + if (item.isDir) diridList.push(item.file_id) + } else { + newDataList.push(item) + } + } + if (deleteCount > 0) { + this.ListDataRaw = newDataList + this.mRefreshListDataShow(true) + } + } + if (needDelDir) { + + TreeStore.DeleteDirs(this.DriveID, file_idList) + + PanDAL.RefreshPanTreeAllNode(this.DriveID) + } + }, + mFavorFiles(isfavor: boolean, file_idList: string[]) { + const listDataRaw = this.ListDataRaw + let isChange = false + const fileMap = new Set(file_idList) + for (let i = 0, maxi = listDataRaw.length; i < maxi; i++) { + const item = listDataRaw[i] + if (fileMap.has(item.file_id)) { + item.starred = isfavor + isChange = true + } + } + if (isChange) this.mRefreshListDataShow(false) + }, + mColorFiles(color: string, file_idList: string[]) { + const listDataRaw = this.ListDataRaw + let isChange = false + const fileMap = new Set(file_idList) + for (let i = 0, maxi = listDataRaw.length; i < maxi; i++) { + const item = listDataRaw[i] + if (fileMap.has(item.file_id)) { + item.description = color + isChange = true + } + } + if (isChange) this.mRefreshListDataShow(false) + }, + mRenameFiles(fileList: { file_id: string; parent_file_id: string; name: string; isDir: boolean }[]) { + const listDataRaw = this.ListDataRaw + let isChange = false + const fileMap = ArrayToMap('file_id', fileList) + for (let i = 0, maxi = listDataRaw.length; i < maxi; i++) { + const item = listDataRaw[i] + const newFile = fileMap.get(item.file_id) + if (newFile) { + item.name = newFile.name + isChange = true + } + } + if (isChange) this.mRefreshListDataShow(false) + }, + mSaveFileScrollTo(file_id: string) { + this.scrollToFile = file_id + } + } +}) + +export default useResPanFileStore diff --git a/src/resPan/pantreestore.ts b/src/resPan/pantreestore.ts new file mode 100644 index 0000000..e57bbca --- /dev/null +++ b/src/resPan/pantreestore.ts @@ -0,0 +1,204 @@ +import { defineStore } from 'pinia' +import { IAliGetDirModel } from '../aliapi/alimodels' +import { h } from 'vue' +import PanDAL from './pandal' +import TreeStore, { TreeNodeData } from '../store/treestore' + +export interface PanTreeState { + user_id: string + drive_id: string + + History: IAliGetDirModel[] + + selectDir: IAliGetDirModel + + selectDirPath: IAliGetDirModel[] + + treeData: TreeNodeData[] + + treeExpandedKeys: string[] + + treeSelectedKeys: string[] + + quickData: TreeNodeData[] + + scrollToDir: string +} + +let treeDataMap = new Map() +type State = PanTreeState + +export const fileiconfn = (icon: string) => h('i', { class: 'iconfont ' + icon }) + +const useResPanTreeStore = defineStore('respantree', { + state: (): State => ({ + user_id: '', + drive_id: '', + History: [], + selectDir: { + __v_skip: true, + drive_id: '', + file_id: '', + parent_file_id: '', + name: '', + namesearch: '', + size: 0, + time: 0, + description: '' + }, + selectDirPath: [], + treeData: [ + { __v_skip: true, title: '文件恢复', namesearch: '', key: 'recover', icon: () => fileiconfn('iconrecover'), isLeaf: true, children: [] }, + { __v_skip: true, title: '回收站', namesearch: '', key: 'trash', icon: () => fileiconfn('icondelete'), isLeaf: true, children: [] }, + { __v_skip: true, title: '收藏夹', namesearch: '', key: 'favorite', icon: () => fileiconfn('iconcrown'), isLeaf: true, children: [] }, + { __v_skip: true, title: '全盘搜索', namesearch: '', key: 'search', icon: () => fileiconfn('iconsearch'), isLeaf: true, children: [] }, + { __v_skip: true, title: '放映室', namesearch: '', key: 'video', icon: () => fileiconfn('iconhistory'), isLeaf: true, children: [] }, + { __v_skip: true, title: '根目录', namesearch: '', key: 'root', children: [] } + ], + treeExpandedKeys: ['root'], + treeSelectedKeys: [], + quickData: [], + scrollToDir: '' + }), + getters: { + PanHistoryCount(state: State): number { + return state.History.length + }, + }, + actions: { + mTreeSelected(key: string) { + console.log('mTreeSelected', key) + PanDAL.aReLoadOneDirToShow('', key, true) + }, + + mTreeExpand(key: string) { + console.log('mTreeExpand', key) + const arr = this.treeExpandedKeys + if (arr.includes(key)) { + const dirPath = TreeStore.GetDirPath(this.drive_id, this.selectDir.file_id) + const needSelectNew = dirPath.filter((t) => t.parent_file_id == key).length > 0 + this.treeExpandedKeys = arr.filter((t) => t != key) + if (needSelectNew) PanDAL.aReLoadOneDirToShow('', key, false) + } else { + this.treeExpandedKeys = arr.concat([key]) + PanDAL.RefreshPanTreeAllNode(this.drive_id) + } + }, + + mTreeExpandAll(keyList: string[], isExpaned: boolean) { + const arr = new Set(this.treeExpandedKeys) + if (isExpaned) { + for (let i = 0, maxi = keyList.length; i < maxi; i++) { + arr.add(keyList[i]) + } + } else { + for (let i = 0, maxi = keyList.length; i < maxi; i++) { + arr.delete(keyList[i]) + } + } + this.treeExpandedKeys = Array.from(arr) + if (isExpaned) PanDAL.RefreshPanTreeAllNode(this.drive_id) + }, + + mSaveUser(user_id: string, drive_id: string) { + this.$reset() + this.$patch({ user_id, drive_id }) + }, + + mShowDir(dir: IAliGetDirModel, dirPath: IAliGetDirModel[], treeSelectedKeys: string[], treeExpandedKeys: string[]) { + this.$patch({ + selectDir: dir, + selectDirPath: dirPath, + treeSelectedKeys: treeSelectedKeys, + treeExpandedKeys: treeExpandedKeys + }) + }, + + mSaveTreeAllNode(drive_id: string, root: TreeNodeData, rootMap: Map) { + if (this.drive_id !== drive_id) return + + const list: TreeNodeData[] = [] + for (let i = 0, maxi = this.treeData.length; i < maxi; i++) { + if (this.treeData[i].key == root.key) { + list.push(root) + } else list.push(this.treeData[i]) + } + + this.treeData = list + treeDataMap = rootMap + }, + + mSaveTreeOneDirNode(drive_id: string, dirID: string, dirNode: TreeNodeData, dirMap: Map) { + console.log('刷新Tree', dirNode) + if (this.drive_id !== drive_id) return + + + const findDir = treeDataMap.get(dirID) + if (findDir) { + findDir.children = dirNode.children + const keys = dirMap.entries() + for (let i = 0, maxi = dirMap.size; i < maxi; i++) { + const key = keys.next().value + treeDataMap.set(key[0], key[1]) + } + this.treeData = this.treeData.concat() + } + }, + + mRenameFiles(fileList: { file_id: string; parent_file_id: string; name: string; isDir: boolean }[]) { + let isChange = false + let isPath = false + + const diridList: string[] = [] + for (let i = 0, maxi = fileList.length; i < maxi; i++) { + const item = fileList[i] + if (!item.isDir) continue + diridList.push(item.file_id) + const findNode = treeDataMap.get(item.file_id) + if (findNode) { + findNode.title = item.name + isChange = true + } + if (this.selectDir.file_id == item.file_id) { + this.selectDir = Object.assign({}, this.selectDir, { name: item.name }) as IAliGetDirModel + isChange = true + } + + this.selectDirPath.map((t) => { + if (t.file_id == item.file_id) { + t.name = item.name + isPath = true + } + return true + }) + } + + if (isChange) this.treeData = this.treeData.concat() + if (isPath) this.selectDirPath = this.selectDirPath.concat() + + + TreeStore.RenameDirs(this.drive_id, fileList) + }, + mSaveQuick(list: { key: string; title: string }[]) { + const nodeList: TreeNodeData[] = [] + for (let i = 0; i < list.length; i++) { + nodeList.push({ + __v_skip: true, + key: list[i].key, + title: list[i].title || list[i].key, + namesearch: i < 9 ? '快捷键 Ctrl+' + (i + 1) : '', + children: [], + isLeaf: true + } as TreeNodeData) + } + Object.freeze(nodeList) + this.quickData = nodeList + }, + mSaveTreeScrollTo(dirID: string) { + if (dirID == 'refresh') dirID = this.selectDir.file_id + this.scrollToDir = dirID + } + } +}) + +export default useResPanTreeStore diff --git a/src/resPan/topbtns/AlphaModal.vue b/src/resPan/topbtns/AlphaModal.vue new file mode 100644 index 0000000..bfcde5a --- /dev/null +++ b/src/resPan/topbtns/AlphaModal.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/src/resPan/topbtns/ArchiveModal.vue b/src/resPan/topbtns/ArchiveModal.vue new file mode 100644 index 0000000..f4c0251 --- /dev/null +++ b/src/resPan/topbtns/ArchiveModal.vue @@ -0,0 +1,354 @@ + + + + diff --git a/src/resPan/topbtns/ArchivePasswordModal.vue b/src/resPan/topbtns/ArchivePasswordModal.vue new file mode 100644 index 0000000..e3f0bb5 --- /dev/null +++ b/src/resPan/topbtns/ArchivePasswordModal.vue @@ -0,0 +1,130 @@ + + + + + diff --git a/src/resPan/topbtns/CopyFileTreeModal.vue b/src/resPan/topbtns/CopyFileTreeModal.vue new file mode 100644 index 0000000..cc3bbf0 --- /dev/null +++ b/src/resPan/topbtns/CopyFileTreeModal.vue @@ -0,0 +1,372 @@ + + + + + diff --git a/src/resPan/topbtns/CreatNewAlbumModal.vue b/src/resPan/topbtns/CreatNewAlbumModal.vue new file mode 100644 index 0000000..95b8436 --- /dev/null +++ b/src/resPan/topbtns/CreatNewAlbumModal.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/src/resPan/topbtns/CreatNewDirModal.vue b/src/resPan/topbtns/CreatNewDirModal.vue new file mode 100644 index 0000000..be603af --- /dev/null +++ b/src/resPan/topbtns/CreatNewDirModal.vue @@ -0,0 +1,167 @@ + + + + + diff --git a/src/resPan/topbtns/CreatNewDirMultiModal.vue b/src/resPan/topbtns/CreatNewDirMultiModal.vue new file mode 100644 index 0000000..11a7099 --- /dev/null +++ b/src/resPan/topbtns/CreatNewDirMultiModal.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/resPan/topbtns/CreatNewFileModal.vue b/src/resPan/topbtns/CreatNewFileModal.vue new file mode 100644 index 0000000..6036852 --- /dev/null +++ b/src/resPan/topbtns/CreatNewFileModal.vue @@ -0,0 +1,135 @@ + + + + + diff --git a/src/resPan/topbtns/CreatNewShareLinkModal.vue b/src/resPan/topbtns/CreatNewShareLinkModal.vue new file mode 100644 index 0000000..600b5b6 --- /dev/null +++ b/src/resPan/topbtns/CreatNewShareLinkModal.vue @@ -0,0 +1,217 @@ + + + + + diff --git a/src/resPan/topbtns/DLNAPlayerModal.vue b/src/resPan/topbtns/DLNAPlayerModal.vue new file mode 100644 index 0000000..7bb0a07 --- /dev/null +++ b/src/resPan/topbtns/DLNAPlayerModal.vue @@ -0,0 +1,162 @@ + + + + + diff --git a/src/resPan/topbtns/DaoRuShareLinkModal.vue b/src/resPan/topbtns/DaoRuShareLinkModal.vue new file mode 100644 index 0000000..ba7827d --- /dev/null +++ b/src/resPan/topbtns/DaoRuShareLinkModal.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/src/resPan/topbtns/DaoRuShareLinkMultiModal.vue b/src/resPan/topbtns/DaoRuShareLinkMultiModal.vue new file mode 100644 index 0000000..6167e57 --- /dev/null +++ b/src/resPan/topbtns/DaoRuShareLinkMultiModal.vue @@ -0,0 +1,143 @@ + + + + + diff --git a/src/resPan/topbtns/DownloadModal.vue b/src/resPan/topbtns/DownloadModal.vue new file mode 100644 index 0000000..8eda247 --- /dev/null +++ b/src/resPan/topbtns/DownloadModal.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/src/resPan/topbtns/M3U8DownloadModal.vue b/src/resPan/topbtns/M3U8DownloadModal.vue new file mode 100644 index 0000000..819342f --- /dev/null +++ b/src/resPan/topbtns/M3U8DownloadModal.vue @@ -0,0 +1,232 @@ + + + + + diff --git a/src/resPan/topbtns/MoveToAlbumModal.vue b/src/resPan/topbtns/MoveToAlbumModal.vue new file mode 100644 index 0000000..589955e --- /dev/null +++ b/src/resPan/topbtns/MoveToAlbumModal.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/src/resPan/topbtns/RenameModal.vue b/src/resPan/topbtns/RenameModal.vue new file mode 100644 index 0000000..ab23d1f --- /dev/null +++ b/src/resPan/topbtns/RenameModal.vue @@ -0,0 +1,172 @@ + + + + + diff --git a/src/resPan/topbtns/RenameMultiModal.vue b/src/resPan/topbtns/RenameMultiModal.vue new file mode 100644 index 0000000..738cab4 --- /dev/null +++ b/src/resPan/topbtns/RenameMultiModal.vue @@ -0,0 +1,1194 @@ + + + + + diff --git a/src/resPan/topbtns/ResTopbtn.ts b/src/resPan/topbtns/ResTopbtn.ts new file mode 100644 index 0000000..af96696 --- /dev/null +++ b/src/resPan/topbtns/ResTopbtn.ts @@ -0,0 +1,709 @@ +import { IAliGetFileModel } from '../../aliapi/alimodels' +import AliFile from '../../aliapi/file' +import AliFileCmd from '../../aliapi/filecmd' +import { IAliFileResp, NewIAliFileResp } from '../../aliapi/dirfilelist' +import AliTrash from '../../aliapi/trash' +import { IPageVideoXBT } from '../../store/appstore' +import DebugLog from '../../utils/debuglog' +import message from '../../utils/message' +import { + modalCopyFileTree, + modalCreatNewShareLink, + modalDLNAPlayer, + modalDownload, + modalM3U8Download, + modalSearchPan, + modalSelectPanDir, + modalUpload +} from '../../utils/modal' +import { ArrayKeyList } from '../../utils/utils' +import PanDAL from '../pandal' +import useResPanFileStore from '../panfilestore' +import useResPanTreeStore from '../pantreestore' +import { useSettingStore, useUserStore } from '../../store' +import { Sleep } from '../../utils/format' +import TreeStore from '../../store/treestore' +import { copyToClipboard } from '../../utils/electronhelper' +import DownDAL from '../../down/DownDAL' +import UploadingDAL from '../../transfer/uploadingdal' +import { GetDriveID } from '../../aliapi/utils' +import {isEmpty} from "lodash"; + +const topbtnLock = new Set() + + +export function handleUpload(uploadType: string, album_id?:string) { + const pantreeStore = useResPanTreeStore() + if (uploadType !== 'pic' && (!pantreeStore.user_id || !pantreeStore.drive_id || !pantreeStore.selectDir.file_id)) { + message.error('上传操作失败 父文件夹错误') + return + } + + if (uploadType == 'file') { + window.WebShowOpenDialogSync({ title: '选择多个文件上传到网盘', buttonLabel: '上传选中的文件', properties: ['openFile', 'multiSelections', 'showHiddenFiles', 'noResolveAliases', 'treatPackageAsDirectory', 'dontAddToRecent'] }, (files: string[] | undefined) => { + if (files && files.length > 0) { + modalUpload('resourcePan', pantreeStore.selectDir.file_id, files) + } + }) + } else if (uploadType == 'pic' && album_id !== undefined) { + const driver_id = GetDriveID(useUserStore().user_id, 'pic') + const userId = useUserStore().user_id + console.log("album_id", album_id) + window.WebShowOpenDialogSync({ title: '选择多张照片上传到相册', buttonLabel: '上传选中的照片', properties: ['openFile', 'multiSelections', 'showHiddenFiles', 'noResolveAliases', 'treatPackageAsDirectory', 'dontAddToRecent'] }, (files: string[] | undefined) => { + if (files && files.length > 0) { + files.forEach((file) => { + file+='album_id='+album_id + }) + UploadingDAL.aUploadLocalFiles(userId, driver_id, "root", files, useSettingStore().downUploadWhatExist, true) + } + }) + } else { + window.WebShowOpenDialogSync({ title: '选择多个文件夹上传到网盘', buttonLabel: '上传文件夹', properties: ['openDirectory', 'multiSelections', 'showHiddenFiles', 'noResolveAliases', 'treatPackageAsDirectory', 'dontAddToRecent'] }, (files: string[] | undefined) => { + if (files && files.length > 0) { + modalUpload('resourcePan', pantreeStore.selectDir.file_id, files) + } + }) + } +} + + +export function menuDownload(istree: boolean, tips: boolean = true) { + const selectedData = PanDAL.GetPanSelectedData(istree) + if (selectedData.isError) { + message.error('下载操作失败 父文件夹错误') + return + } + if (selectedData.isErrorSelected) { + message.error('没有可以下载的文件') + return + } + const settingStore = useSettingStore() + const savePath = settingStore.AriaIsLocal ? settingStore.downSavePath : settingStore.ariaSavePath + const savePathFull = settingStore.downSavePathFull + const downSavePathDefault = settingStore.downSavePathDefault + if (isEmpty(savePath)) { + message.error('未设置保存路径') + modalDownload('resourcePan', istree) + return + } + if (topbtnLock.has('menuDownload')) return + topbtnLock.add('menuDownload') + let files: IAliGetFileModel[] = [] + if (istree) { + files = [{ + ...useResPanTreeStore().selectDir, + isDir: true, + ext: '', + category: '', + icon: '', + sizeStr: '', + timeStr: '', + starred: false, + thumbnail: '' + }] + } else { + files = useResPanFileStore().GetSelected() + } + try { + if (downSavePathDefault || !tips) { + DownDAL.aAddDownload(files, savePath, savePathFull) + } else { + modalDownload('resourcePan', istree) + } + } catch (err: any) { + message.error(err.message) + DebugLog.mSaveDanger('menuDownload', err) + } + topbtnLock.delete('menuDownload') +} + +export async function menuFavSelectFile(istree: boolean, isFavor: boolean) { + const selectedData = PanDAL.GetPanSelectedData(istree) + if (selectedData.isError) { + message.error('收藏操作失败 父文件夹错误') + return + } + if (selectedData.isErrorSelected) { + message.error('没有可以收藏的文件') + return + } + + if (topbtnLock.has('menuFavSelectFile')) return + topbtnLock.add('menuFavSelectFile') + try { + const successList = await AliFileCmd.ApiFavorBatch(selectedData.user_id, selectedData.drive_id, isFavor, true, selectedData.selectedKeys) + if (isFavor) { + + if (useResPanTreeStore().selectDir.file_id == 'favorite') { + PanDAL.aReLoadOneDirToShow('', 'refresh', false) + } else { + useResPanFileStore().mFavorFiles(isFavor, successList) + } + } else { + + if (useResPanTreeStore().selectDir.file_id == 'favorite') { + useResPanFileStore().mDeleteFiles('favorite', successList, false) + } else { + useResPanFileStore().mFavorFiles(isFavor, successList) + } + } + } catch (err: any) { + message.error(err.message) + DebugLog.mSaveDanger('menuFavSelectFile', err) + } + topbtnLock.delete('menuFavSelectFile') +} + + +export async function menuTrashSelectFile(istree: boolean, isDelete: boolean) { + const selectedData = PanDAL.GetPanSelectedData(istree) + if (selectedData.isError) { + message.error('删除操作失败 父文件夹错误') + return + } + if (selectedData.isErrorSelected) { + message.error('没有可以删除的文件') + return + } + if (selectedData.dirID.startsWith('video')) { + message.error('请不要在放映室里删除文件') + return + } + + if (topbtnLock.has('menuTrashSelectFile')) return + topbtnLock.add('menuTrashSelectFile') + try { + let successList: string[] + if (isDelete) { + successList = await AliFileCmd.ApiDeleteBatch(selectedData.user_id, selectedData.drive_id, selectedData.selectedKeys) + } else { + successList = await AliFileCmd.ApiTrashBatch(selectedData.user_id, selectedData.drive_id, selectedData.selectedKeys) + } + + if (istree) { + + PanDAL.aReLoadOneDirToShow(selectedData.drive_id, selectedData.parentDirID, false) + } else { + + useResPanFileStore().mDeleteFiles(selectedData.dirID, successList, selectedData.dirID !== 'trash') + + if (selectedData.dirID !== 'trash') { + // PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, selectedData.dirID) + TreeStore.ClearDirSize(selectedData.drive_id, selectedData.selectedParentKeys) + } + } + } catch (err: any) { + message.error(err.message) + DebugLog.mSaveDanger('menuTrashSelectFile', err) + } + topbtnLock.delete('menuTrashSelectFile') +} + +export async function topRestoreSelectedFile() { + const selectedData = PanDAL.GetPanSelectedData(false) + if (selectedData.isError) { + message.error('还原文件操作失败 父文件夹错误') + return + } + if (selectedData.isErrorSelected) { + message.error('没有可以还原的文件') + return + } + + const panfileStore = useResPanFileStore() + const diridList: string[] = [] + panfileStore + .GetSelected() + .filter((t) => t.isDir) + .map((t) => diridList.push(t.file_id)) + + if (topbtnLock.has('topRestoreSelectedFile')) return + topbtnLock.add('topRestoreSelectedFile') + try { + await AliFileCmd.ApiTrashRestoreBatch(selectedData.user_id, selectedData.drive_id, true, selectedData.selectedKeys) + if (useResPanTreeStore().selectDir.file_id == 'trash') { + + useResPanFileStore().mDeleteFiles('trash', selectedData.selectedKeys, false) + } else { + + PanDAL.aReLoadOneDirToShow('', 'refresh', false) + } + await Sleep(2000) + const dirList = await AliFileCmd.ApiGetFileBatchOpenApi(selectedData.user_id, selectedData.drive_id, diridList) + console.log(diridList, dirList) + + const pset = new Set() + for (let i = 0, maxi = dirList.length; i < maxi; i++) { + const parent_file_id = dirList[i].parent_file_id + if (pset.has(parent_file_id)) continue + pset.add(parent_file_id) + await PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, parent_file_id) + } + TreeStore.ClearDirSize(selectedData.drive_id, Array.from(pset)) + } catch (err: any) { + message.error(err.message) + DebugLog.mSaveDanger('topRestoreSelectedFile', err) + } + topbtnLock.delete('topRestoreSelectedFile') +} + + +export function menuCopySelectedFile(istree: boolean, copyby: string, copyToBackup=false) { + const selectedData = PanDAL.GetPanSelectedData(istree) + if (selectedData.isError) { + message.error('复制移动操作失败 父文件夹错误') + return + } + if (selectedData.dirID.startsWith('video')) { + message.error('请不要在放映室里移动文件文件') + return + } + + let files: IAliGetFileModel[] = [] + if (istree) { + files = [{ + ...useResPanTreeStore().selectDir, + isDir: true, + ext: '', + category: '', + icon: '', + sizeStr: '', + timeStr: '', + starred: false, + thumbnail: '' + } as IAliGetFileModel] + } else { + files = useResPanFileStore().GetSelected() + } + if (files.length == 0) { + message.error('没有选择要复制移动的文件!') + return + } + const parent_file_id = files[0].parent_file_id + + const file_idList: string[] = [] + const diridList: string[] = [] + for (let i = 0, maxi = files.length; i < maxi; i++) { + if (files[i].isDir && !diridList.includes(files[i].parent_file_id)) diridList.push(files[i].parent_file_id) + file_idList.push(files[i].file_id) + } + + if (file_idList.length == 0) { + message.error('没有可以复制移动的文件') + return + } + if (copyToBackup) { + modalSelectPanDir('backupPan', copyby, parent_file_id, async function (user_id: string, drive_id: string, dirID: string) { + if (!drive_id || !dirID) return + + let successList: string[] + if (copyby == 'copy') { + successList = await AliFileCmd.ApiCopyBatch(user_id, selectedData.drive_id, file_idList, drive_id, dirID) + PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, dirID) + TreeStore.ClearDirSize(drive_id, [dirID]) + } else { + successList = await AliFileCmd.ApiMoveBatch(user_id, selectedData.drive_id, file_idList, drive_id, dirID) + if (istree) { + PanDAL.aReLoadOneDirToShow(selectedData.drive_id, selectedData.parentDirID, false) + PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, dirID) + } else { + useResPanFileStore().mDeleteFiles(selectedData.dirID, successList, true) + PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, dirID) + } + TreeStore.ClearDirSize(drive_id, [dirID, ...selectedData.selectedParentKeys]) + } + }) + } else { + modalSelectPanDir('resourcePan', copyby, parent_file_id, async function (user_id: string, drive_id: string, dirID: string) { + if (!drive_id || !dirID) return + + if (parent_file_id == dirID) { + message.error('不能移动复制到原位置!') + return + } + + let successList: string[] + if (copyby == 'copy') { + successList = await AliFileCmd.ApiCopyBatch(user_id, drive_id, file_idList, drive_id, dirID) + PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, dirID) + TreeStore.ClearDirSize(drive_id, [dirID]) + } else { + successList = await AliFileCmd.ApiMoveBatch(user_id, drive_id, file_idList, drive_id, dirID) + if (istree) { + PanDAL.aReLoadOneDirToShow(selectedData.drive_id, selectedData.parentDirID, false) + PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, dirID) + } else { + useResPanFileStore().mDeleteFiles(selectedData.dirID, successList, true) + PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, dirID) + } + TreeStore.ClearDirSize(drive_id, [dirID, ...selectedData.selectedParentKeys]) + } + }) + } + +} + + +export function dropMoveSelectedFile(movetodirid: string) { + const selectedData = PanDAL.GetPanSelectedData(false) + if (selectedData.isErrorSelected) return + if (selectedData.isError) { + message.error('复制移动操作失败 父文件夹错误!') + return + } + + if (selectedData.dirID == 'trash') { + message.error('回收站内文件不支持移动!') + return + } + if (!movetodirid) { + message.error('没有选择要移动到的位置!') + return + } + if (movetodirid == selectedData.dirID) { + message.error('不能移动到原位置!') + return + } + + const file_idList: string[] = [] + const filenameList: string[] = [] + const selectedFile = useResPanFileStore().GetSelected() + if (selectedFile.length == 0) { + message.error('没有选择要拖放移动的文件!') + return + } + for (let i = 0, maxi = selectedFile.length; i < maxi; i++) { + file_idList.push(selectedFile[i].file_id) + filenameList.push(selectedFile[i].name) + } + + if (file_idList.includes(movetodirid)) { + + if (file_idList.length == 1) message.info('用户取消移动') + else message.error('不能移动到原位置!') + return + } + + AliFileCmd.ApiMoveBatch(selectedData.user_id, selectedData.drive_id, file_idList, selectedData.drive_id, movetodirid).then((success: string[]) => { + + + useResPanFileStore().mDeleteFiles(selectedData.dirID, success, true) + + PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, movetodirid) + TreeStore.ClearDirSize(selectedData.drive_id, [movetodirid, ...selectedData.selectedParentKeys]) + }) +} + + +export async function menuFileColorChange(istree: boolean, color: string) { + const selectedData = PanDAL.GetPanSelectedData(istree) + if (selectedData.isError) { + message.error('标记文件操作失败 父文件夹错误') + return + } + if (selectedData.isErrorSelected) { + message.error('没有可以标记的文件') + return + } + + color = color.toLowerCase().replace('#', 'c') + + if (topbtnLock.has('menuFileColorChange')) return + topbtnLock.add('menuFileColorChange') + try { + const successList = await AliFileCmd.ApiFileColorBatch(selectedData.user_id, selectedData.drive_id, color, selectedData.selectedKeys) + useResPanFileStore().mColorFiles(color, successList) + } catch (err: any) { + message.error(err.message) + DebugLog.mSaveDanger('menuFileColorChange', err) + } + topbtnLock.delete('menuFileColorChange') +} + + +export function menuCreatShare(istree: boolean, shareby: string) { + const selectedData = PanDAL.GetPanSelectedData(istree) + if (selectedData.isError) { + message.error('创建分享操作失败 父文件夹错误') + return + } + + let list: IAliGetFileModel[] = [] + if (istree) { + const dir = useResPanTreeStore().selectDir + list = [ + { + __v_skip: true, + drive_id: dir.drive_id, + file_id: dir.file_id, + parent_file_id: dir.parent_file_id, + name: dir.name, + namesearch: dir.namesearch, + ext: '', + category: '', + icon: 'iconfile-folder', + size: 0, + sizeStr: '', + time: 0, + timeStr: '', + starred: false, + isDir: true, + thumbnail: '', + description: '' + } + ] + } else { + list = useResPanFileStore().GetSelected() + } + if (list.length == 0) { + message.error('没有可以分享的文件!') + return + } + modalCreatNewShareLink(shareby, list) +} + + +export async function topFavorDeleteAll() { + const selectedData = PanDAL.GetPanSelectedData(false) + if (selectedData.isError) { + message.error('清空收藏夹操作失败 父文件夹错误') + return + } + if (topbtnLock.has('topFavorDeleteAll')) return + topbtnLock.add('topFavorDeleteAll') + try { + const loadingKey = 'cleartrash_' + Date.now().toString() + message.loading('清空收藏夹执行中...', 60, loadingKey) + let count = 0 + while (true) { + + const resp: IAliFileResp = NewIAliFileResp(selectedData.user_id, selectedData.drive_id, 'favorite', '收藏夹') + await AliTrash.ApiFavorFileListOnePageForClean('updated_at', 'DESC', resp) + if (resp.items.length > 0) { + + const selectkeys = ArrayKeyList('file_id', resp.items) + const successList = await AliFileCmd.ApiFavorBatch(selectedData.user_id, selectedData.drive_id, false, false, selectkeys) + count += successList.length + + message.loading('清空收藏夹执行中...(' + count.toString() + ')', 60, loadingKey) + } else { + break + } + } + message.success('清空收藏夹 成功!', 3, loadingKey) + if (useResPanTreeStore().selectDir.file_id == 'favorite') PanDAL.aReLoadOneDirToShow('', 'refresh', false) + } catch (err: any) { + message.error(err.message) + DebugLog.mSaveDanger('topFavorDeleteAll', err) + } + topbtnLock.delete('topFavorDeleteAll') +} + + +export async function topTrashDeleteAll() { + const selectedData = PanDAL.GetPanSelectedData(false) + if (selectedData.isError) { + message.error('清空回收站操作失败 父文件夹错误') + return + } + + if (topbtnLock.has('topTrashDeleteAll')) return + topbtnLock.add('topTrashDeleteAll') + const loadingKey = 'cleartrash_' + Date.now().toString() + try { + message.loading('清空回收站执行中...', 60, loadingKey) + let count = 0 + while (true) { + + const resp: IAliFileResp = NewIAliFileResp(selectedData.user_id, selectedData.drive_id, 'trash', '回收站') + await AliTrash.ApiTrashFileListOnePageForClean('updated_at', 'DESC', resp) + if (resp.items.length > 0) { + + const selectkeys = ArrayKeyList('file_id', resp.items) + const successList = await AliFileCmd.ApiTrashCleanBatch(selectedData.user_id, selectedData.drive_id, false, selectkeys) + count += successList.length + + message.loading('清空回收站执行中...(' + count.toString() + ')', 0, loadingKey) + } else { + break + } + } + message.success('清空回收站 成功!', 3, loadingKey) + if (useResPanTreeStore().selectDir.file_id == 'trash') PanDAL.aReLoadOneDirToShow('', 'refresh', false) + } catch (err: any) { + message.error(err.message, 3, loadingKey) + DebugLog.mSaveDanger('topTrashDeleteAll', err) + } + topbtnLock.delete('topTrashDeleteAll') +} + + +export async function topRecoverSelectedFile() { + const selectedData = PanDAL.GetPanSelectedData(false) + if (selectedData.isError) { + message.error('恢复文件操作失败 父文件夹错误') + return + } + + + const files = useResPanFileStore().GetSelected() + if (files.length == 0) { + message.error('没有选择要恢复的文件!') + return + } + + const resumeList: { drive_id: string; file_id: string; content_hash: string; size: number; name: string }[] = [] + const selectParentKeys: string[] = ['root', 'recover'] + for (let i = 0, maxi = files.length; i < maxi; i++) { + const file = files[i] + resumeList.push({ + drive_id: file.drive_id, + file_id: file.file_id, + content_hash: file.description, + size: file.size, + name: file.name + }) + if (!selectParentKeys.includes(files[i].parent_file_id)) selectParentKeys.push(files[i].parent_file_id) + } + + if (resumeList.length == 0) { + message.error('没有可以恢复的文件') + return + } + + if (topbtnLock.has('topRecoverSelectedFile')) return + topbtnLock.add('topRecoverSelectedFile') + + const loadingKey = 'recover_' + Date.now().toString() + try { + message.loading('文件恢复执行中...', 60, loadingKey) + let successList: string[] = [] + const oneTimeList: { drive_id: string; file_id: string; content_hash: string; size: number; name: string }[] = [] + for (let i = 0, maxi = resumeList.length; i < maxi; i++) { + oneTimeList.push(resumeList[i]) + if (oneTimeList.length > 99) { + const data = await AliFileCmd.ApiRecoverBatch(selectedData.user_id, oneTimeList) + successList = successList.concat(data) + oneTimeList.length = 0 + message.loading('文件恢复执行中...(' + i.toString() + ')', 60, loadingKey) + } + } + if (oneTimeList.length > 0) { + const data = await AliFileCmd.ApiRecoverBatch(selectedData.user_id, oneTimeList) + successList = successList.concat(data) + oneTimeList.length = 0 + } + message.success('文件恢复(' + successList.length + ') 成功!', 3, loadingKey) + + PanDAL.aReLoadOneDirToRefreshTree(selectedData.user_id, selectedData.drive_id, 'root') + + useResPanFileStore().mDeleteFiles('recover', successList, false) + } catch (err: any) { + message.error(err.message, 3, loadingKey) + DebugLog.mSaveDanger('topRecoverSelectedFile', err) + } + topbtnLock.delete('topRecoverSelectedFile') +} + + +export async function topSearchAll(word: string) { + + if (word == 'topSearchAll高级搜索') { + modalSearchPan("resourcePan") + return + } + + const pantreeStore = useResPanTreeStore() + if (!pantreeStore.user_id || !pantreeStore.drive_id || !pantreeStore.selectDir.file_id) { + message.error('搜索文件操作失败 父文件夹错误') + return + } + const searchid = 'search' + word + PanDAL.aReLoadOneDirToShow('', searchid, false) +} + + +export async function menuJumpToDir() { + let first = useResPanFileStore().GetSelectedFirst() + if (first && !first.parent_file_id) first = await AliFile.ApiGetFile(useResPanTreeStore().user_id, first.drive_id, first.file_id) + if (!first) { + message.error('没有选中任何文件') + return + } + + PanDAL.aReLoadOneDirToShow('', first.parent_file_id, true).then(() => { + useResPanFileStore().mKeyboardSelect(first!.file_id, false, false) + useResPanFileStore().mSaveFileScrollTo(first!.file_id) + }) +} + +export function menuVideoXBT() { + const first = useResPanFileStore().GetSelectedFirst() + if (!first) { + message.error('没有选中任何文件') + return + } + + if (first.icon == 'iconweifa') { + message.error('违规视频无法预览') + return + } + const pageVideoXBT: IPageVideoXBT = { + user_id: useResPanTreeStore().user_id, + drive_id: first.drive_id, + file_id: first.file_id, + file_name: first.name + } + window.WebOpenWindow({ page: 'PageVideoXBT', data: pageVideoXBT, theme: 'dark' }) +} + +export function menuDLNA() { + const first = useResPanFileStore().GetSelectedFirst() + if (!first) { + message.error('没有选中任何文件') + return + } + modalDLNAPlayer() +} + +export function menuM3U8Download() { + const first = useResPanFileStore().GetSelectedFirst() + if (!first) { + message.error('没有选中任何文件') + return + } + modalM3U8Download("resourcePan") +} + +export function menuCopyFileName() { + const list: IAliGetFileModel[] = useResPanFileStore().GetSelected() + if (list.length == 0) { + message.error('没有选择要复制文件名的文件!') + return + } + + if (topbtnLock.has('menuCopyFileName')) return + topbtnLock.add('menuCopyFileName') + try { + const nameList: string[] = [] + for (let i = 0, maxi = list.length; i < maxi; i++) { + nameList.push(list[i].name) + } + const fullStr = nameList.join('\r\n') + copyToClipboard(fullStr) + message.success('选中文件的文件名已复制到剪切板') + } catch (err: any) { + message.error(err.message) + DebugLog.mSaveDanger('menuCopyFileName', err) + } + topbtnLock.delete('menuCopyFileName') +} + +export function menuCopyFileTree() { + const list: IAliGetFileModel[] = useResPanFileStore().GetSelected() + if (list.length == 0) { + message.error('没有选中任何文件!') + return + } + modalCopyFileTree('resourcePan',list) +} diff --git a/src/resPan/topbtns/SearchPanModal.vue b/src/resPan/topbtns/SearchPanModal.vue new file mode 100644 index 0000000..c150272 --- /dev/null +++ b/src/resPan/topbtns/SearchPanModal.vue @@ -0,0 +1,219 @@ + + + + + diff --git a/src/resPan/topbtns/SelectPanDirModal.vue b/src/resPan/topbtns/SelectPanDirModal.vue new file mode 100644 index 0000000..43f44b0 --- /dev/null +++ b/src/resPan/topbtns/SelectPanDirModal.vue @@ -0,0 +1,418 @@ + + + + + diff --git a/src/resPan/topbtns/ShuXingModal.vue b/src/resPan/topbtns/ShuXingModal.vue new file mode 100644 index 0000000..3441f13 --- /dev/null +++ b/src/resPan/topbtns/ShuXingModal.vue @@ -0,0 +1,395 @@ + + + + + diff --git a/src/resPan/topbtns/ShuXingMultiModal.vue b/src/resPan/topbtns/ShuXingMultiModal.vue new file mode 100644 index 0000000..dbe6312 --- /dev/null +++ b/src/resPan/topbtns/ShuXingMultiModal.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/resPan/topbtns/UploadModal.vue b/src/resPan/topbtns/UploadModal.vue new file mode 100644 index 0000000..ab32842 --- /dev/null +++ b/src/resPan/topbtns/UploadModal.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/src/resPan/topbtns/renamemulti.ts b/src/resPan/topbtns/renamemulti.ts new file mode 100644 index 0000000..5f5f056 --- /dev/null +++ b/src/resPan/topbtns/renamemulti.ts @@ -0,0 +1,605 @@ +export interface TreeNodeData { + key: string + title: string + rawtitle: string + newtitle: string + isLeaf: boolean + children: TreeNodeData[] + icon: any + isDir: boolean + + isMatch: boolean +} + +export function NewRenameConfigData() { + return { + + show: false, + + replace: { enable: true, search: '', newword: '', chkCase: true, chkAll: true, chkReg: false, applyto: 'name' }, + + delete: { enable: false, type: 'search', search: '', chkCase: true, chkAll: true, chkReg: false, applyto: 'name', beginlen: 0, endlen: 0, beginword: '', endword: '' }, + + add: { enable: false, type: 'position', search: '', before: '', after: '', beginword: '', endword: '', applyto: 'name' }, + + index: { enable: false, type: 'begin', format: '', minlen: 1, beginindex: 1, minnum: 1 }, + + others: { enable: false, nameformat: '', extformat: '', randomformat: '', randomlen: 4 } + } +} + + +export function RunAllNode(nodeList: TreeNodeData[], func: (node: TreeNodeData) => boolean) { + for (let i = 0, maxi = nodeList.length; i < maxi; i++) { + const node = nodeList[i] + if (!func(node)) return false + + if (node.children && node.children.length > 0) { + if (!RunAllNode(node.children, func)) return false + } + } + return true +} + + +function Split(text: string, search: string) { + const textLow = text.toLowerCase() + search = search.toLowerCase() + const listLow = textLow.split(search) + const searchLen = search.length + let pos = 0 + const list: string[] = [] + for (let i = 0, maxi = listLow.length; i < maxi; i++) { + const low = listLow[i] + if (low) { + list.push(text.substring(pos, pos + low.length)) + pos = pos + searchLen + low.length + } else { + list.push('') + pos = pos + searchLen + } + } + return list +} + +function Replace(text: string, search: string, newtext: string) { + const textLow = text.toLowerCase() + search = search.toLowerCase() + const index = textLow.indexOf(search) + if (index >= 0) { + return text.substring(0, index) + newtext + text.substring(index + search.length) + } else return text +} + +function fixext(ext: string) { + return ext ? '.' + ext : '' +} + +function RunReplace(isDir: boolean, title: string, config: any) { + const search = config.search as string + if (!search) return [title, title] + + let name = title + let ext = '' + const exti = name.lastIndexOf('.') + if (!isDir && exti >= 0) { + ext = name.substring(exti + 1) + name = name.substring(0, exti) + } + + if (config.chkReg) { + + let reg: RegExp + try { + reg = RegExp(search) + } catch { + return [title, title] + } + reg = RegExp(search) + if (config.chkCase) reg = RegExp(search, 'i') + if (config.chkAll) reg = RegExp(search, 'g') + if (config.chkCase && config.chkAll) reg = RegExp(search, 'ig') + if (config.applyto == 'full') { + + return [title.replace(reg, config.newword), title.replace(reg, '' + config.newword + '')] + } + if (config.applyto == 'name') { + return [name.replace(reg, config.newword) + fixext(ext), name.replace(reg, '' + config.newword + '') + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(ext.replace(reg, config.newword)), name + fixext(ext.replace(reg, '' + config.newword + ''))] + } + } else if (config.chkCase) { + + if (config.chkAll) { + if (config.applyto == 'full') { + const slist = Split(title, search) + return [slist.join(config.newword), slist.join('' + config.newword + '')] + } + if (config.applyto == 'name') { + const slist = Split(name, search) + return [slist.join(config.newword) + fixext(ext), slist.join('' + config.newword + '') + fixext(ext)] + } + if (config.applyto == 'ext') { + const slist = Split(ext, search) + return [name + fixext(slist.join(config.newword)), name + fixext(slist.join('' + config.newword + ''))] + } + } else { + if (config.applyto == 'full') { + return [Replace(title, search, config.newword), Replace(title, search, '' + config.newword + '')] + } + if (config.applyto == 'name') { + return [Replace(name, search, config.newword) + fixext(ext), Replace(name, search, '' + config.newword + '') + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(Replace(ext, search, config.newword)), name + fixext(Replace(ext, search, '' + config.newword + ''))] + } + } + } else { + + if (config.chkAll) { + if (config.applyto == 'full') { + return [title.replaceAll(search, config.newword), title.replaceAll(search, '' + config.newword + '')] + } + if (config.applyto == 'name') { + return [name.replaceAll(search, config.newword) + fixext(ext), name.replaceAll(search, '' + config.newword + '') + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(ext.replaceAll(search, config.newword)), name + fixext(ext.replaceAll(search, '' + config.newword + ''))] + } + } else { + if (config.applyto == 'full') { + return [title.replace(search, config.newword), title.replace(search, '' + config.newword + '')] + } + if (config.applyto == 'name') { + return [name.replace(search, config.newword) + fixext(ext), name.replace(search, '' + config.newword + '') + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(ext.replace(search, config.newword)), name + fixext(ext.replace(search, '' + config.newword + ''))] + } + } + } + return [title, title] +} +function RunDelete(isDir: boolean, title: string, config: any) { + let name = title + let ext = '' + const exti = name.lastIndexOf('.') + if (!isDir && exti >= 0) { + ext = name.substring(exti + 1) + name = name.substring(0, exti) + } + + if (config.type == 'search' && config.search) { + const search = config.search as string + if (config.chkReg) { + + let reg: RegExp + try { + reg = RegExp(search) + } catch { + return [title, title] + } + reg = RegExp(search) + + if (config.chkCase) reg = RegExp(search, 'i') + if (config.chkAll) reg = RegExp(search, 'g') + if (config.chkCase && config.chkAll) reg = RegExp(search, 'ig') + if (config.applyto == 'full') { + + return [title.replace(reg, ''), title.replace(reg, (L) => (L ? '' + L + '' : ''))] + } + if (config.applyto == 'name') { + return [name.replace(reg, '') + fixext(ext), name.replace(reg, (L) => (L ? '' + L + '' : '')) + fixext(ext)] + } + if (config.applyto === 'ext') { + return [name + fixext(ext.replace(reg, '')), name + fixext(ext.replace(reg, (L) => (L ? '' + L + '' : '')))] + } + } else if (config.chkCase) { + + if (config.chkAll) { + if (config.applyto == 'full') { + const slist = Split(title, search) + return [slist.join(''), slist.join('' + search + '')] + } + if (config.applyto == 'name') { + const slist = Split(name, search) + return [slist.join('') + fixext(ext), slist.join('' + search + '') + fixext(ext)] + } + if (config.applyto == 'ext') { + const slist = Split(ext, search) + return [name + fixext(slist.join('')), name + fixext(slist.join('' + search + ''))] + } + } else { + if (config.applyto == 'full') { + return [Replace(title, search, ''), Replace(title, search, '' + search + '')] + } + if (config.applyto == 'name') { + return [Replace(name, search, '') + fixext(ext), Replace(name, search, '' + search + '') + fixext(ext)] + } + if (config.applyto === 'ext') { + return [name + fixext(Replace(ext, search, '')), name + fixext(Replace(ext, search, '' + search + ''))] + } + } + } else { + + if (config.chkAll) { + if (config.applyto == 'full') { + return [title.replaceAll(search, ''), title.replaceAll(search, '' + search + '')] + } + if (config.applyto == 'name') { + return [name.replaceAll(search, '') + fixext(ext), name.replaceAll(search, '' + search + '') + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(ext.replaceAll(search, '')), name + fixext(ext.replaceAll(search, '' + search + ''))] + } + } else { + if (config.applyto == 'full') { + return [title.replace(search, ''), title.replace(search, '' + search + '')] + } + if (config.applyto == 'name') { + return [name.replace(search, '') + fixext(ext), name.replace(search, '' + search + '') + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(ext.replace(search, '')), name + fixext(ext.replace(search, '' + search + ''))] + } + } + } + } + + if (config.type == 'position' && config.beginlen >= 0 && config.endlen >= 0) { + let title1 = title + let title2 = title + if (config.applyto == 'full') { + title1 = title + title2 = title + } else if (config.applyto == 'name') { + title1 = name + title2 = name + } else if (config.applyto == 'ext') { + title1 = ext + title2 = ext + } + + if (config.applyto == 'ext' && (config.beginlen > title1.length || config.endlen > title1.length || config.beginlen + config.endlen > title1.length)) return [title, title] + if (config.applyto !== 'ext' && (config.beginlen >= title1.length || config.endlen >= title1.length || config.beginlen + config.endlen >= title1.length)) return [title, title] + + if (config.beginlen > 0 && config.endlen > 0) { + + const del1 = title1.substring(0, config.beginlen) + const del2 = title1.substring(title1.length - config.endlen) + let str = title1.substring(config.beginlen) + str = str.substring(0, str.length - config.endlen) + + title1 = str + title2 = '' + del1 + '' + str + '' + del2 + '' + } else if (config.beginlen > 0) { + + const del = title1.substring(0, config.beginlen) + const str = title1.substring(config.beginlen) + title1 = str + title2 = '' + del + '' + str + } else if (config.endlen > 0) { + + const str1 = title1.substring(0, title1.length - config.endlen) + const str2 = title1.substring(0, title1.length - config.endlen) + const del = title1.substring(title1.length - config.endlen) + title1 = str1 + title2 = str2 + '' + del + '' + } else { + + return [title, title] + } + + if (config.applyto == 'full') { + return [title1, title2] + } + if (config.applyto == 'name') { + return [title1 + fixext(ext), title2 + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(title1), name + fixext(title2)] + } + } + + if (config.type == 'range' && config.beginword && config.endword) { + if (config.applyto == 'full') { + const start = title.indexOf(config.beginword) + const end = title.indexOf(config.endword, start + 1) + if (start >= 0 && end >= 0 && start < end - 1) { + const title1 = title.substring(0, start + 1) + title.substring(end) + const title2 = title.substring(0, start + 1) + '' + title.substring(start + 1, end) + '' + title.substring(end) + return [title1, title2] + } + } else if (config.applyto == 'name') { + const start = name.indexOf(config.beginword) + const end = name.indexOf(config.endword, start + 1) + if (start >= 0 && end >= 0 && start < end - 1) { + const name1 = name.substring(0, start + 1) + name.substring(end) + const name2 = name.substring(0, start + 1) + '' + name.substring(start + 1, end) + '' + name.substring(end) + return [name1 + fixext(ext), name2 + fixext(ext)] + } + } else if (config.applyto == 'ext') { + const start = ext.indexOf(config.beginword) + const end = ext.indexOf(config.endword, start + 1) + if (start >= 0 && end >= 0 && start < end - 1) { + const ext1 = ext.substring(0, start + 1) + ext.substring(end) + const ext2 = ext.substring(0, start + 1) + '' + ext.substring(start + 1, end) + '' + ext.substring(end) + return [name + fixext(ext1), name + fixext(ext2)] + } + } + } + + return [title, title] +} +function RunAdd(isDir: boolean, title: string, config: any) { + let name = title + let ext = '' + const exti = name.lastIndexOf('.') + if (!isDir && exti >= 0) { + ext = name.substring(exti + 1) + name = name.substring(0, exti) + } + + let title1 = title + + if (config.applyto == 'full') { + title1 = title + } else if (config.applyto == 'name') { + title1 = name + } else if (config.applyto == 'ext') { + title1 = ext + } + + if (config.type == 'search' && config.search) { + const index = title1.indexOf(config.search) + if (index >= 0) { + let title2 = '' + const start = title1.substring(0, index) + const mid = title1.substring(index, index + config.search.length) + const end = title1.substring(index + config.search.length) + + if (config.before && config.after) { + title1 = start + config.before + mid + config.after + end + title2 = start + '' + config.before + '' + mid + '' + config.after + '' + end + } else if (config.before) { + title1 = start + config.before + mid + end + title2 = start + '' + config.before + '' + mid + end + } else if (config.after) { + title1 = start + mid + config.after + end + title2 = start + mid + '' + config.after + '' + end + } else { + return [title, title] + } + + if (config.applyto == 'full') { + return [title1, title2] + } + if (config.applyto == 'name') { + return [title1 + fixext(ext), title2 + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(title1), name + fixext(title2)] + } + } + } + + if (config.type == 'position' && (config.beginword || config.endword)) { + if (title1) { + let title2 = title1 + if (config.beginword) { + title1 = config.beginword + title1 + title2 = '' + config.beginword + '' + title2 + } + if (config.endword) { + title1 = title1 + config.endword + title2 = title2 + '' + config.endword + '' + } + if (config.applyto == 'full') { + return [title1, title2] + } + if (config.applyto == 'name') { + return [title1 + fixext(ext), title2 + fixext(ext)] + } + if (config.applyto == 'ext') { + return [name + fixext(title1), name + fixext(title2)] + } + } + } + + return [title, title] +} +function RunIndex(isDir: boolean, title: string, config: any, nodeIndex: number) { + if (!config.format) return [title, title] + let name = title + let ext = '' + const exti = name.lastIndexOf('.') + if (!isDir && exti >= 0) { + ext = name.substring(exti) + name = name.substring(0, exti) + } + + const bianhao = config.beginindex + config.minnum * nodeIndex + const formate = config.format.replace('#', bianhao.toString().padStart(config.minlen, '0')) + if (config.type == 'begin') { + const title1 = formate + name + const title2 = '' + formate + '' + name + return [title1 + ext, title2 + ext] + } else if (config.type == 'end') { + const title1 = name + formate + const title2 = name + '' + formate + '' + return [title1 + ext, title2 + ext] + } + + return [title, title] +} +function RunOthers(isDir: boolean, title: string, config: any, sj1Base: string) { + let name = title + let ext = '' + const exti = name.lastIndexOf('.') + if (!isDir && exti >= 0) { + ext = name.substring(exti) + name = name.substring(0, exti) + } + + if (config.nameformat == 'AA') { + const title1 = name.replace(/[a-zA-Z]+/g, (L) => L.toUpperCase()) + const title2 = name.replace(/[a-zA-Z]+/g, (L) => (L == L.toUpperCase() ? L : '' + L.toUpperCase() + '')) + + if (title1 + ext == title) return [title, title] + return [title1 + ext, title2 + ext] + } + if (config.nameformat == 'aa') { + const title1 = name.replace(/[a-zA-Z]+/g, (L) => L.toLowerCase()) + const title2 = name.replace(/[a-zA-Z]+/g, (L) => (L == L.toLowerCase() ? L : '' + L.toLowerCase() + '')) + + if (title1 + ext == title) return [title, title] + return [title1 + ext, title2 + ext] + } + if (config.nameformat == 'Aa') { + name = name.toLowerCase() + const title1 = name.replace(/[a-z]+/, (L) => (L.length > 1 ? L.substring(0, 1).toUpperCase() + L.substring(1) : L.toUpperCase())) + const title2 = name.replace(/[a-z]+/, (L) => (L.length > 1 ? '' + L.substring(0, 1).toUpperCase() + '' + L.substring(1) : '' + L.toUpperCase() + '')) + + if (title1 + ext == title) return [title, title] + return [title1 + ext, title2 + ext] + } + if (config.nameformat == 'Aa Aa') { + name = name.toLowerCase() + const title1 = name.replace(/[a-z]+/g, (L) => (L.length > 1 ? L.substring(0, 1).toUpperCase() + L.substring(1) : L.toUpperCase())) + const title2 = name.replace(/[a-z]+/g, (L) => (L.length > 1 ? '' + L.substring(0, 1).toUpperCase() + '' + L.substring(1) : '' + L.toUpperCase() + '')) + if (title1 + ext == title) return [title, title] + return [title1 + ext, title2 + ext] + } + + if (config.extformat == 'AA') { + if (ext && ext != ext.toUpperCase()) { + return [name + ext.toUpperCase(), name + '' + ext.toUpperCase() + ''] + } else { + return [title, title] + } + } + if (config.extformat == 'aa') { + if (ext && ext != ext.toLowerCase()) { + return [name + ext.toLowerCase(), name + '' + ext.toLowerCase() + ''] + } else { + return [title, title] + } + } + + + const randomLen = config.randomlen + if (sj1Base && randomLen > 0) { + let ranname = '' + let ran = Math.random().toString() + ran = ran + ran + ran + ran + ran + let pos = name.length + for (let i = 0; i < randomLen; i++) { + pos = (pos ^ ran.charCodeAt(i)) % 300 + ranname += sj1Base[pos] + } + return [ranname + ext, '' + ranname + '' + ext] + } + return [title, title] +} + +export function RunReplaceName(renameConfig: any, treeData: TreeNodeData[], checkedKeys: string[]) { + const show = renameConfig.show + const replace = renameConfig.replace + const checked = new Set(checkedKeys || []) + if (replace.enable) { + RunAllNode(treeData, (node) => { + if (checked.has(node.key)) { + const title = RunReplace(node.isDir, node.rawtitle, replace) + node.newtitle = title[0] + node.title = show ? title[0] : title[1] + node.isMatch = node.newtitle != node.rawtitle + } else { + node.newtitle = node.rawtitle + node.title = node.rawtitle + node.isMatch = false + } + return true + }) + return + } + const tdelete = renameConfig.delete + if (tdelete.enable) { + RunAllNode(treeData, (node) => { + if (checked.has(node.key)) { + const title = RunDelete(node.isDir, node.rawtitle, tdelete) + node.newtitle = title[0] + node.title = show ? title[0] : title[1] + node.isMatch = node.newtitle != node.rawtitle && node.newtitle != '' + } else { + node.newtitle = node.rawtitle + node.title = node.rawtitle + node.isMatch = false + } + return true + }) + return + } + const add = renameConfig.add + if (add.enable) { + RunAllNode(treeData, (node) => { + if (checked.has(node.key)) { + const title = RunAdd(node.isDir, node.rawtitle, add) + node.newtitle = title[0] + node.title = show ? title[0] : title[1] + node.isMatch = node.newtitle != node.rawtitle + } else { + node.newtitle = node.rawtitle + node.title = node.rawtitle + node.isMatch = false + } + return true + }) + return + } + const index = renameConfig.index + if (index.enable) { + let nodeindex = 0 + // const checkmap = new Set(checkedKeys || []) + RunAllNode(treeData, (node) => { + if (checked.has(node.key)) { + const title = RunIndex(node.isDir, node.rawtitle, index, nodeindex) + node.newtitle = title[0] + node.title = show ? title[0] : title[1] + node.isMatch = node.newtitle != node.rawtitle + nodeindex++ + } else { + node.newtitle = node.rawtitle + node.title = node.rawtitle + node.isMatch = false + } + return true + }) + return + } + const others = renameConfig.others + if (others.enable) { + let sj1Base = '' + if (others.randomformat == '0-9') sj1Base = '01234567899876543210012345678998765432100123456789987654321001' + if (others.randomformat == 'a-z') sj1Base = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij' + if (others.randomformat == 'A-Z') sj1Base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ' + if (others.randomformat == 'a-zA-Z') sj1Base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZtuvwxABCDE' + if (others.randomformat == '0-9a-z') sj1Base = '0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnop' + if (others.randomformat == '0-9A-Z') sj1Base = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOP' + if (others.randomformat == '0-9a-zA-Z') sj1Base = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + if (sj1Base) sj1Base = sj1Base + sj1Base + sj1Base + sj1Base + sj1Base + RunAllNode(treeData, (node) => { + if (checked.has(node.key)) { + const title = RunOthers(node.isDir, node.rawtitle, others, sj1Base) + node.newtitle = title[0] + node.title = show ? title[0] : title[1] + node.isMatch = node.newtitle != node.rawtitle + } else { + node.newtitle = node.rawtitle + node.title = node.rawtitle + node.isMatch = false + } + return true + }) + } +} diff --git a/src/resource/searchIndex.vue b/src/resource/searchIndex.vue index f7d5ce6..59125ff 100644 --- a/src/resource/searchIndex.vue +++ b/src/resource/searchIndex.vue @@ -59,12 +59,10 @@ export default { iframeDocument.addEventListener('click', (event: any) => { const target = event.target; const url = target.href || ''; + event.preventDefault(); if (url.includes('aliyundrive')) { - event.preventDefault(); modalDaoRuShareLink(url); - } else { - event.preventDefault(); } }) }) diff --git a/src/rss/appsame/AppSame.vue b/src/rss/appsame/AppSame.vue index 37d4bcf..f0bfae7 100644 --- a/src/rss/appsame/AppSame.vue +++ b/src/rss/appsame/AppSame.vue @@ -93,7 +93,7 @@ const handleDelete = () => { } delLoading.value = true const idList = Array.from(checkedKeys) - AliFileCmd.ApiTrashBatch(user.user_id, user.default_drive_id, idList).then((success: string[]) => { + AliFileCmd.ApiTrashBatch(user.user_id, user.backup_drive_id, idList).then((success: string[]) => { delLoading.value = false handleScan() }) @@ -124,7 +124,7 @@ const handleScan = () => { } setTimeout(refresh, 3000) - LoadScanDir(user.user_id, user.default_drive_id, totalDirCount, Processing, ScanPanData) + LoadScanDir(user.user_id, user.backup_drive_id, totalDirCount, Processing, ScanPanData) .then(() => { return GetSameFile(user.user_id, ScanPanData, Processing, scanCount, totalFileCount, scanType.value) }) diff --git a/src/rss/rssdrivecopy/RssDriveCopy.vue b/src/rss/rssdrivecopy/RssDriveCopy.vue index b43e376..24913e7 100644 --- a/src/rss/rssdrivecopy/RssDriveCopy.vue +++ b/src/rss/rssdrivecopy/RssDriveCopy.vue @@ -102,7 +102,7 @@ const handleLeftUser = (driveType: any) => { if (!userToken) return TreeState.LeftInfo.user_id = userToken.user_id TreeState.LeftInfo.driveType = driveType - if (driveType == 'pan') TreeState.LeftInfo.drive_id = userToken.default_drive_id + if (driveType == 'pan') TreeState.LeftInfo.drive_id = userToken.backup_drive_id if (driveType == 'pic') TreeState.LeftInfo.drive_id = userToken.pic_drive_id if (driveType == 'safe') TreeState.LeftInfo.drive_id = userToken.default_sbox_drive_id TreeState.LeftCheckedKeys = [] @@ -114,7 +114,7 @@ const handleRightUser = (driveType: any) => { if (!userToken) return TreeState.RightInfo.user_id = userToken.user_id TreeState.RightInfo.driveType = driveType - if (driveType == 'pan') TreeState.RightInfo.drive_id = userToken.default_drive_id + if (driveType == 'pan') TreeState.RightInfo.drive_id = userToken.backup_drive_id if (driveType == 'pic') TreeState.RightInfo.drive_id = userToken.pic_drive_id if (driveType == 'safe') TreeState.RightInfo.drive_id = userToken.default_sbox_drive_id LoadDir('root', TreeState.RightInfo, TreeState.RightTreeData, true) diff --git a/src/rss/rssscanclean/RssScanClean.vue b/src/rss/rssscanclean/RssScanClean.vue index 1c3693b..31b2780 100644 --- a/src/rss/rssscanclean/RssScanClean.vue +++ b/src/rss/rssscanclean/RssScanClean.vue @@ -103,7 +103,7 @@ const handleDelete = () => { return } delLoading.value = true - AliFileCmd.ApiTrashBatch(user.user_id, user.default_drive_id, checkedKeys.value).then((success: string[]) => { + AliFileCmd.ApiTrashBatch(user.user_id, user.backup_drive_id, checkedKeys.value).then((success: string[]) => { delLoading.value = false DeleteFromScanClean(ScanPanData, checkedKeys.value) checkedKeys.value = [] @@ -137,7 +137,7 @@ const handleScan = () => { } setTimeout(refresh, 3000) - LoadScanDir(user.user_id, user.default_drive_id, totalDirCount, Processing, ScanPanData) + LoadScanDir(user.user_id, user.backup_drive_id, totalDirCount, Processing, ScanPanData) .then(() => { return GetCleanFile(user.user_id, ScanPanData, Processing, scanCount, totalFileCount, scanType.value, fileSize.value) }) diff --git a/src/rss/rssscanenmpty/RssScanEnmpty.vue b/src/rss/rssscanenmpty/RssScanEnmpty.vue index adf9231..998802e 100644 --- a/src/rss/rssscanenmpty/RssScanEnmpty.vue +++ b/src/rss/rssscanenmpty/RssScanEnmpty.vue @@ -90,9 +90,9 @@ const handleDelete = () => { return } delLoading.value = true - AliFileCmd.ApiTrashBatch(user.user_id, user.default_drive_id, checkedKeys.value).then((success: string[]) => { + AliFileCmd.ApiTrashBatch(user.user_id, user.backup_drive_id, checkedKeys.value).then((success: string[]) => { delLoading.value = false - DB.saveValueNumber('AllDir_' + user.default_drive_id, 0) + DB.saveValueNumber('AllDir_' + user.backup_drive_id, 0) RefreshTree() }) } @@ -123,7 +123,7 @@ const handleScan = () => { } setTimeout(refresh, 3000) - LoadScanDir(user.user_id, user.default_drive_id, totalDirCount, Processing, ScanPanData) + LoadScanDir(user.user_id, user.backup_drive_id, totalDirCount, Processing, ScanPanData) .then(() => { return GetEnmptyDir(user.user_id, ScanPanData, Processing, scanCount) diff --git a/src/rss/rssscanpunish/RssScanPunish.vue b/src/rss/rssscanpunish/RssScanPunish.vue index 9ed084e..8d8e33e 100644 --- a/src/rss/rssscanpunish/RssScanPunish.vue +++ b/src/rss/rssscanpunish/RssScanPunish.vue @@ -103,7 +103,7 @@ const handleDelete = () => { return } delLoading.value = true - AliFileCmd.ApiTrashBatch(user.user_id, user.default_drive_id, checkedKeys.value).then((success: string[]) => { + AliFileCmd.ApiTrashBatch(user.user_id, user.backup_drive_id, checkedKeys.value).then((success: string[]) => { delLoading.value = false if (checkedKeys.value.length == checkedKeysBak.length) { handleReset() @@ -123,10 +123,10 @@ const handleMove = () => { message.error('账号错误') return } - modalSelectPanDir('cut', '', function (user_id: string, drive_id: string, dirID: string) { + modalSelectPanDir('resourcePan','cut', '', function (user_id: string, drive_id: string, dirID: string) { if (!drive_id || !dirID) return delLoading.value = true - AliFileCmd.ApiMoveBatch(user.user_id, user.default_drive_id, checkedKeys.value, drive_id, dirID).then((success: string[]) => { + AliFileCmd.ApiMoveBatch(user.user_id, user.resource_drive_id, checkedKeys.value, drive_id, dirID).then((success: string[]) => { delLoading.value = false if (checkedKeys.value.length == checkedKeysBak.length) { handleReset() @@ -167,7 +167,7 @@ const handleScan = () => { } setTimeout(refresh, 3000) - LoadScanDir(user.user_id, user.default_drive_id, totalDirCount, Processing, ScanPanData) + LoadScanDir(user.user_id, user.resource_drive_id, totalDirCount, Processing, ScanPanData) .then(() => { return GetWeiGuiFile(user.user_id, ScanPanData, Processing, scanCount, totalFileCount, scanType.value) diff --git a/src/rss/rssscansame/RssScanSame.vue b/src/rss/rssscansame/RssScanSame.vue index ed27260..ea8969d 100644 --- a/src/rss/rssscansame/RssScanSame.vue +++ b/src/rss/rssscansame/RssScanSame.vue @@ -129,7 +129,7 @@ const handleDelete = () => { } delLoading.value = true const idList = Array.from(checkedKeys.value) - AliFileCmd.ApiTrashBatch(user.user_id, user.default_drive_id, idList).then((success: string[]) => { + AliFileCmd.ApiTrashBatch(user.user_id, user.backup_drive_id, idList).then((success: string[]) => { delLoading.value = false DeleteFromSameData(ScanPanData, idList) checkedKeys.value.clear() @@ -165,7 +165,7 @@ const handleScan = () => { } setTimeout(refresh, 3000) - LoadScanDir(user.user_id, user.default_drive_id, totalDirCount, Processing, ScanPanData) + LoadScanDir(user.user_id, user.backup_drive_id, totalDirCount, Processing, ScanPanData) .then(() => { return GetSameFile(user.user_id, ScanPanData, Processing, scanCount, totalFileCount, scanType.value) diff --git a/src/rss/rssusercopy/RssUserCopy.vue b/src/rss/rssusercopy/RssUserCopy.vue index 7a9069b..f7d6833 100644 --- a/src/rss/rssusercopy/RssUserCopy.vue +++ b/src/rss/rssusercopy/RssUserCopy.vue @@ -104,7 +104,7 @@ const handleLeftUser = (user_id: any) => { const userToken = UserTokenMap.get(user_id) if (!userToken) return LeftData.user_id = userToken.user_id - LeftData.drive_id = userToken.default_drive_id + LeftData.drive_id = userToken.backup_drive_id LeftCheckedKeys.value = [] LoadDir('root', LeftData, LeftTreeData) } @@ -118,7 +118,7 @@ const handleRightUser = (user_id: any) => { const userToken = UserTokenMap.get(user_id) if (!userToken) return RightData.user_id = userToken.user_id - RightData.drive_id = userToken.default_drive_id + RightData.drive_id = userToken.backup_drive_id LoadDir('root', RightData, RightTreeData) } diff --git a/src/setting/settingstore.ts b/src/setting/settingstore.ts index 86e21c1..66cdd99 100644 --- a/src/setting/settingstore.ts +++ b/src/setting/settingstore.ts @@ -1,11 +1,10 @@ import { defineStore } from 'pinia' import DebugLog from '../utils/debuglog' -import {getResourcesPath, getUserData, getUserDataPath} from '../utils/electronhelper' +import {getUserDataPath} from '../utils/electronhelper' import {useAppStore, useUserStore} from '../store' import PanDAL from '../pan/pandal' -import { existsSync, readFileSync, writeFileSync } from 'fs' +import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs' import UserDAL from "../user/userdal" -import message from "../utils/message" declare type ProxyType = 'none' | 'http' | 'https' | 'socks4' | 'socks4a' | 'socks5' | 'socks5h' @@ -341,7 +340,10 @@ function LoadSetting() { const val = JSON.parse(settingstr) _loadSetting(val) useAppStore().toggleTheme(setting.uiTheme) - if (setting.appUserDataPath !== '') { + if (setting.appUserDataPath !== '' ) { + if (!existsSync(setting.appUserDataPath)) { + mkdirSync(setting.appUserDataPath) + } window.WebToElectron({ cmd: { appUserDataPath: setting.appUserDataPath} }) } } else { diff --git a/src/share/share/ShowShareLinkModal.vue b/src/share/share/ShowShareLinkModal.vue index 8b55219..42ca99b 100644 --- a/src/share/share/ShowShareLinkModal.vue +++ b/src/share/share/ShowShareLinkModal.vue @@ -251,7 +251,7 @@ export default defineComponent({ console.log('selectNodes', selectNodes) const share_id = this.share_id const share_token = this.shareToken - modalSelectPanDir('share', '', async function(user_id: string, drive_id: string, dirID: string) { + modalSelectPanDir('resourcePan','share', '', async function(user_id: string, drive_id: string, dirID: string) { if (!drive_id || !dirID) return const result = await SaveLink(saveType, share_id, share_token, user_id, drive_id, dirID, selectNodes) if (result) message.error('保存文件出错,' + result) diff --git a/src/store/appstore.ts b/src/store/appstore.ts index 18ea99b..c39e32c 100644 --- a/src/store/appstore.ts +++ b/src/store/appstore.ts @@ -80,6 +80,7 @@ const useAppStore = defineStore('app', { isVip: true, appTabMenuMap: new Map([ ['pan', 'backupPan'], + ['resPan', 'resourcePan'], ['pic', 'allpic'], ['down', 'DowningRight'], ['share', 'OtherShareRight'], @@ -131,6 +132,7 @@ const useAppStore = defineStore('app', { appTab: 'pan', appTabMenuMap: new Map([ ['pan', 'backupPan'], + ['resPan', 'resourcePan'], ['pic', 'allpic'], ['down', 'DowningRight'], ['share', 'OtherShareRight'], @@ -177,6 +179,10 @@ const useAppStore = defineStore('app', { toggleTabNext() { switch (this.appTab) { case 'pan': { + this.appTab = 'resPan' + break + } + case 'resPan': { this.appTab = 'pic' break } @@ -223,7 +229,11 @@ const useAppStore = defineStore('app', { switch (this.appTab) { case 'pan': { - next(this.appTabMenuMap, this.appTab, ['backupPan','resourcePan', 'kuaijie']) + next(this.appTabMenuMap, this.appTab, ['backupPan', 'kuaijie', 'fangying']) + break + } + case 'resPan': { + next(this.appTabMenuMap, this.appTab, ['resourcePan', 'resKuaijie']) break } case 'pic': { diff --git a/src/store/index.ts b/src/store/index.ts index 928d81d..008e1ed 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -14,6 +14,8 @@ import useUserStore from '../user/userstore' import type { ITokenInfo } from '../user/userstore' import usePanTreeStore from '../pan/pantreestore' import usePanFileStore from '../pan/panfilestore' +import useResPanTreeStore from '../resPan/pantreestore' +import useResPanFileStore from '../resPan/panfilestore' import useServerStore from './serverstore' import type { IOtherShareLinkModel } from '../share/share/OtherShareStore' @@ -51,6 +53,8 @@ export { ITokenInfo, usePanTreeStore, usePanFileStore, + useResPanTreeStore, + useResPanFileStore, useServerStore, IOtherShareLinkModel, IShareSiteModel, diff --git a/src/user/UserLogin.vue b/src/user/UserLogin.vue index e6eb0d2..8b88657 100644 --- a/src/user/UserLogin.vue +++ b/src/user/UserLogin.vue @@ -274,7 +274,7 @@ export default defineComponent({ user_name: result.userName, avatar: result.avatar, nick_name: result.nickName, - default_drive_id: '', + backup_drive_id: '', resource_drive_id:'', default_sbox_drive_id: '', viplevel:'', diff --git a/src/user/userdal.ts b/src/user/userdal.ts index c70f383..11789c8 100644 --- a/src/user/userdal.ts +++ b/src/user/userdal.ts @@ -13,6 +13,7 @@ import { useSettingStore } from '../store' import PanDAL from '../pan/pandal' +import ResPanDAL from '../resPan/pandal' import DebugLog from '../utils/debuglog' export const UserTokenMap = new Map() @@ -79,7 +80,7 @@ export default class UserDAL { user_name: '', avatar: '', nick_name: '', - default_drive_id: '', + backup_drive_id: '', resource_drive_id: '', default_sbox_drive_id: '', role: '', @@ -181,9 +182,11 @@ export default class UserDAL { useOtherFollowingStore().$reset() useFootStore().mSaveUserInfo(token) // 刷新数据 - PanDAL.aReLoadDrive(token.user_id, token.default_drive_id) - PanDAL.aReLoadDrive(token.user_id, token.resource_drive_id) + PanDAL.aReLoadDrive(token.user_id, token.backup_drive_id) PanDAL.aReLoadQuickFile(token.user_id) + + ResPanDAL.aReLoadDrive(token.user_id, token.resource_drive_id) + ResPanDAL.aReLoadQuickFile(token.user_id) message.success('加载用户成功!', 2, loadingKey) } diff --git a/src/user/userstore.ts b/src/user/userstore.ts index 739f7bd..14cb580 100644 --- a/src/user/userstore.ts +++ b/src/user/userstore.ts @@ -4,8 +4,6 @@ import UserDAL from './userdal' export interface ITokenInfo { tokenfrom: 'token' | 'account' - - access_token: string refresh_token: string expires_in: number @@ -22,7 +20,7 @@ export interface ITokenInfo { user_name: string avatar: string nick_name: string - default_drive_id: string + backup_drive_id: string resource_drive_id: string default_sbox_drive_id: string role: string @@ -84,4 +82,4 @@ const useUserStore = defineStore('user', { } }) -export default useUserStore +export default useUserStore \ No newline at end of file diff --git a/src/utils/keyboardhelper.ts b/src/utils/keyboardhelper.ts index 7f6b9ad..f59d4ab 100644 --- a/src/utils/keyboardhelper.ts +++ b/src/utils/keyboardhelper.ts @@ -185,8 +185,8 @@ export function RefreshScrollTo(element: any, top: number) { } } -const menulist = ['leftpansubmove', 'leftpansubzhankai', 'leftpanmenu', 'rightpansubmove', 'rightpansubbiaoji', - 'rightpansubmore', 'rightpanmenu', 'rightpantrashmenu', 'rightmysharemenu', 'rightothersharemenu', +const menulist = ['leftpansubmove', 'leftrespansubmove','leftpansubzhankai', 'leftrespansubzhankai', 'leftpanmenu','leftrespanmenu', 'rightpansubmove', 'rightrespansubmove', 'rightpansubbiaoji', + 'rightrespansubbiaoji', 'rightpansubmore', 'rightpanmenu', 'rightpantrashmenu', 'rightrespansubmore', 'rightrespanmenu', 'rightrespantrashmenu', 'rightmysharemenu', 'rightothersharemenu', 'uploadingrightmenu', 'uploadedrightmenu', 'downingrightmenu', 'downedrightmenu', 'rightuploadedmenu', 'rightuploadingmenu'] const menuliststate = new Set() diff --git a/src/utils/modal.ts b/src/utils/modal.ts index a0d3a5f..afc3687 100644 --- a/src/utils/modal.ts +++ b/src/utils/modal.ts @@ -8,11 +8,20 @@ export function modalCloseAll() { export function modalUserSpace() { useModalStore().showModal('userspace', {}) } -export function modalCreatNewFile() { - useModalStore().showModal('creatfile', {}) +export function modalCreatNewFile(panType: string) { + if (panType == 'backupPan') { + useModalStore().showModal('createBackupPanFile', {}) + } else if (panType == 'resourcePan') { + useModalStore().showModal('createResourcePanFile', {}) + } + } -export function modalCreatNewDir(dirtype: string, parentdirid: string = '', callback: any = undefined) { - useModalStore().showModal('creatdir', { dirtype, parentdirid, callback }) +export function modalCreatNewDir(panType: string, dirtype: string, parentdirid: string = '', callback: any = undefined) { + if (panType == 'backupPan') { + useModalStore().showModal('creatBackupPanDir', { dirtype, parentdirid, callback }) + } else { + useModalStore().showModal('creatResourcePanDir', { dirtype, parentdirid, callback }) + } } export function modalCreatNewAlbum() { @@ -24,18 +33,23 @@ export function modalMoveToAlbum(photos_file_id:string[]) { } export function modalCreatNewShareLink(sharetype: string, filelist: IAliGetFileModel[]) { - useModalStore().showModal('creatshare', { sharetype, filelist }) + useModalStore().showModal('createShare', { sharetype, filelist }) } export function modalDaoRuShareLink(shareUrl='', sharePwd='') { - useModalStore().showModal('daorushare', {shareUrl, sharePwd}) + useModalStore().showModal('importShare', {shareUrl, sharePwd}) } export function modalDaoRuShareLinkMulti() { - useModalStore().showModal('daorusharemulti', {}) + useModalStore().showModal('importMultipleShare', {}) } -export function modalRename(istree: boolean, ismulti: boolean) { - useModalStore().showModal(ismulti ? 'renamemulti' : 'rename', { istree }) +export function modalRename(panType: string, istree: boolean, ismulti: boolean) { + if (panType == 'backupPan') { + useModalStore().showModal(ismulti ? 'renameBackupPanMultiple' : 'renameBackupPan', { istree }) + } else { + useModalStore().showModal(ismulti ? 'renameResourcePanMultiple' : 'renameResourcePan', { istree }) + } + } export function modalEditShareLink(sharelist: IAliShareItem[]) { @@ -46,45 +60,90 @@ export function modalShowShareLink(share_id: string, share_pwd: string, share_to useModalStore().showModal('showshare', { share_id, share_pwd, share_token, withsave, file_id_list }) } -export function modalSelectPanDir(selecttype: string, selectid: string, +export function modalSelectPanDir(panType: string, selecttype: string, selectid: string, callback: (user_id: string, drive_id: string, dirID: string, dirName: string) => void, category?: string, extFilter?: RegExp) { - useModalStore().showModal('selectpandir', { selecttype, selectid, category, extFilter, callback }) + if (panType == 'backupPan') { + useModalStore().showModal('selectBackupPanDir', { selecttype, selectid, category, extFilter, callback }) + } else { + useModalStore().showModal('selectResourcePanDir', { selecttype, selectid, category, extFilter, callback }) + } + } -export function modalShuXing(istree: boolean, ismulti: boolean) { +export function modalShuXing(panType: string, istree: boolean, ismulti: boolean) { ismulti = false - useModalStore().showModal(ismulti ? 'shuxingmulti' : 'shuxing', { istree }) + if (panType == 'backupPan') { + useModalStore().showModal(ismulti ? 'backupPanMultipleAttribute' : 'backupPanAttribute', { istree }) + } else { + useModalStore().showModal(ismulti ? 'resourcePanMultipleAttribute' : 'resourcePanAttribute', { istree }) + } + } -export function modalSearchPan() { - useModalStore().showModal('searchpan', {}) +export function modalSearchPan(panType: string) { + if (panType == 'backupPan') { + useModalStore().showModal('searchBackupPan', {}) + } else { + useModalStore().showModal('searchResourcePan', {}) + } + } export function modalDLNAPlayer() { useModalStore().showModal('dlna', {}) } -export function modalM3U8Download() { - useModalStore().showModal('m3u8download', {}) +export function modalM3U8Download(panType: string) { + if (panType == 'backupPan') { + useModalStore().showModal('backupPanM3u8download', {}) + } else { + useModalStore().showModal('resourcePanM3u8download', {}) + } + } -export function modalCopyFileTree(filelist: IAliGetFileModel[]) { - useModalStore().showModal('copyfiletree', { filelist }) +export function modalCopyFileTree(panType: string, filelist: IAliGetFileModel[]) { + if (panType == 'backupPan') { + useModalStore().showModal('copyBackupPanFileTree', { filelist }) + } else { + useModalStore().showModal('copyResourcePanFileTree', { filelist }) + } + } -export function modalArchive(user_id: string, drive_id: string, file_id: string, file_name: string, parent_file_id: string, password: string) { - useModalStore().showModal('archive', { user_id, drive_id, file_id, file_name, parent_file_id, password }) +export function modalArchive(panType: string, user_id: string, drive_id: string, file_id: string, file_name: string, parent_file_id: string, password: string) { + if (panType == 'backupPan') { + useModalStore().showModal('archiveBackupPan', { user_id, drive_id, file_id, file_name, parent_file_id, password }) + } else { + useModalStore().showModal('archiveResourcePan', { user_id, drive_id, file_id, file_name, parent_file_id, password }) + } + } -export function modalArchivePassword(user_id: string, drive_id: string, file_id: string, file_name: string, parent_file_id: string, domain_id: string, ext: string) { - useModalStore().showModal('archivepassword', { user_id, drive_id, file_id, file_name, parent_file_id, domain_id, ext }) +export function modalArchivePassword(panType: string, user_id: string, drive_id: string, file_id: string, file_name: string, parent_file_id: string, domain_id: string, ext: string) { + if (panType == 'backupPan') { + useModalStore().showModal('archiveBackupPanPassword', { user_id, drive_id, file_id, file_name, parent_file_id, domain_id, ext }) + } else { + useModalStore().showModal('archiveResourcePanPassword', { user_id, drive_id, file_id, file_name, parent_file_id, domain_id, ext }) + + } } -export function modalUpload(file_id: string, filelist: string[]) { - useModalStore().showModal('upload', { file_id, filelist }) +export function modalUpload(panType: string, file_id: string, filelist: string[]) { + if (panType == 'backupPan') { + useModalStore().showModal('uploadBackupPan', { file_id, filelist }) + } else { + useModalStore().showModal('uploadResourcePan', { file_id, filelist }) + } + } -export function modalDownload(istree: boolean) { - useModalStore().showModal('download', { istree }) +export function modalDownload(panType: string, istree: boolean) { + if (panType == 'backupPan') { + useModalStore().showModal('downloadBackupPan', { istree }) + } else { + useModalStore().showModal('downloadResourcePan', { istree }) + } + } diff --git a/src/utils/openfile.ts b/src/utils/openfile.ts index e512e8d..cde038f 100644 --- a/src/utils/openfile.ts +++ b/src/utils/openfile.ts @@ -3,7 +3,7 @@ import AliArchive from '../aliapi/archive' import AliFile from '../aliapi/file' import AliFileCmd from '../aliapi/filecmd' import ServerHttp from '../aliapi/server' -import { ITokenInfo, useFootStore, usePanFileStore, useSettingStore, useUserStore } from '../store' +import { ITokenInfo, useFootStore, usePanFileStore, useResPanFileStore, useSettingStore, useUserStore } from '../store' import { IPageCode, IPageImage, IPageOffice, IPageVideo } from '../store/appstore' import UserDAL from '../user/userdal' import { clickWait } from './debounce' @@ -75,10 +75,18 @@ export async function menuOpenFile(file: IAliGetFileModel): Promise { }, { distance: Infinity, index: -1 }) subTitleFileId = (similarity.index !== -1) ? subTitlesList[similarity.index].file_id : '' } else if (uiVideoSubtitleMode === 'select') { - modalSelectPanDir('select', parent_file_id, async (_user_id: string, _drive_id: string, dirID: string, _dirName: string) => { - Video(token, drive_id, file_id, parent_file_id, file.name, isViolation, file.description, dirID) - }, '', /srt|vtt|ass/) - return + if (drive_id === token.backup_drive_id) { + modalSelectPanDir('backupPan','select', parent_file_id, async (_user_id: string, _drive_id: string, dirID: string, _dirName: string) => { + Video(token, drive_id, file_id, parent_file_id, file.name, isViolation, file.description, dirID) + }, '', /srt|vtt|ass/) + return + } else { + modalSelectPanDir('resourcePan','select', parent_file_id, async (_user_id: string, _drive_id: string, dirID: string, _dirName: string) => { + Video(token, drive_id, file_id, parent_file_id, file.name, isViolation, file.description, dirID) + }, '', /srt|vtt|ass/) + return + } + } Video(token, drive_id, file_id, parent_file_id, file.name, isViolation, file.description, subTitleFileId) return @@ -138,9 +146,18 @@ async function Archive(drive_id: string, file_id: string, file_name: string, par } if (resp.state == '密码错误') { - modalArchivePassword(user_id, drive_id, file_id, file_name, parent_file_id, info.domain_id, info.file_extension || '') + if (drive_id === token.resource_drive_id) { + modalArchivePassword('resourcePan', user_id, drive_id, file_id, file_name, parent_file_id, info.domain_id, info.file_extension || '') + } else { + modalArchivePassword('backupPan', user_id, drive_id, file_id, file_name, parent_file_id, info.domain_id, info.file_extension || '') + } } else if (resp.state == 'Succeed' || resp.state == 'Running') { - modalArchive(user_id, drive_id, file_id, file_name, parent_file_id, password) + if (drive_id === token.resource_drive_id) { + modalArchive('resourcePan', user_id, drive_id, file_id, file_name, parent_file_id, password) + } else { + modalArchive('backupPan', user_id, drive_id, file_id, file_name, parent_file_id, password) + } + } else { message.error('在线解压失败 ' + resp.state + ',操作取消') DebugLog.mSaveDanger('在线解压失败 ' + resp.state, drive_id + ' ' + file_id) @@ -168,7 +185,11 @@ async function Video(token: ITokenInfo, drive_id: string, file_id: string, paren if (settingStore.uiAutoColorVideo && !dec) { AliFileCmd.ApiFileColorBatch(token.user_id, drive_id, 'c5b89b8', [file_id]) .then((success) => { - usePanFileStore().mColorFiles('c5b89b8', success) + if (drive_id == usePanFileStore().DriveID) { + usePanFileStore().mColorFiles('c5b89b8', success) + } else { + useResPanFileStore().mColorFiles('c5b89b8', success) + } }) }