mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 11:08:13 -05:00
🔨 Refactor(custom): refactored manage page ipc
This commit is contained in:
parent
09bf847459
commit
a11ae31359
@ -10,6 +10,7 @@ import { systemRouter } from '~/events/rpc/routes/system'
|
|||||||
import { toolboxRouter } from '~/events/rpc/routes/toolbox'
|
import { toolboxRouter } from '~/events/rpc/routes/toolbox'
|
||||||
import { trayRouter } from '~/events/rpc/routes/tray'
|
import { trayRouter } from '~/events/rpc/routes/tray'
|
||||||
import { uploadRouter } from '~/events/rpc/routes/upload'
|
import { uploadRouter } from '~/events/rpc/routes/upload'
|
||||||
|
import { manageRouter } from '~/events/rpc/routes/manage'
|
||||||
|
|
||||||
import { IRPCActionType, IRPCType } from '#/types/enum'
|
import { IRPCActionType, IRPCType } from '#/types/enum'
|
||||||
import { RPC_ACTIONS, RPC_ACTIONS_INVOKE } from '#/events/constants'
|
import { RPC_ACTIONS, RPC_ACTIONS_INVOKE } from '#/events/constants'
|
||||||
@ -75,7 +76,8 @@ const routes = [
|
|||||||
systemRouter.routes(),
|
systemRouter.routes(),
|
||||||
toolboxRouter.routes(),
|
toolboxRouter.routes(),
|
||||||
trayRouter.routes(),
|
trayRouter.routes(),
|
||||||
uploadRouter.routes()
|
uploadRouter.routes(),
|
||||||
|
manageRouter.routes()
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const route of routes) {
|
for (const route of routes) {
|
||||||
|
100
src/main/events/rpc/routes/manage/bucket.ts
Normal file
100
src/main/events/rpc/routes/manage/bucket.ts
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
import { ManageApi } from '~/manage/manageApi'
|
||||||
|
|
||||||
|
import { IRPCActionType, IRPCType } from '#/types/enum'
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_BUCKET_LIST,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string]) => {
|
||||||
|
return new ManageApi(args[0]).getBucketList()
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_BACKSTAGE,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).getBucketListBackstage(args[1])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_RECURSIVELY,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).getBucketListRecursively(args[1])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_CREATE_BUCKET,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).createBucket(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_BUCKET_FILE_LIST,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).getBucketFileList(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_BUCKET_DOMAIN,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).getBucketDomain(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_SET_BUCKET_ACL_POLICY,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).setBucketAclPolicy(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_RENAME_BUCKET_FILE,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).renameBucketFile(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_DELETE_BUCKET_FILE,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).deleteBucketFile(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_DELETE_BUCKET_FOLDER,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).deleteBucketFolder(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_PRE_SIGNED_URL,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).getPreSignedUrl(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_UPLOAD_BUCKET_FILE,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).uploadBucketFile(args[1])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_DOWNLOAD_BUCKET_FILE,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).downloadBucketFile(args[1])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_CREATE_BUCKET_FOLDER,
|
||||||
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
|
return new ManageApi(args[0]).createBucketFolder(args[1])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
}
|
||||||
|
]
|
26
src/main/events/rpc/routes/manage/config.ts
Normal file
26
src/main/events/rpc/routes/manage/config.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { IRPCActionType, IRPCType } from '#/types/enum'
|
||||||
|
import getManageApi from '~/manage/Main'
|
||||||
|
|
||||||
|
const manageApi = getManageApi()
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_CONFIG,
|
||||||
|
handler: async (_: IIPCEvent, args: [key?: string]) => {
|
||||||
|
return manageApi.getConfig(args[0])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_SAVE_CONFIG,
|
||||||
|
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
||||||
|
manageApi.saveConfig(args[0])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_REMOVE_CONFIG,
|
||||||
|
handler: async (_: IIPCEvent, args: [key: string, propName: string]) => {
|
||||||
|
manageApi.removeConfig(args[0], args[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
13
src/main/events/rpc/routes/manage/index.ts
Normal file
13
src/main/events/rpc/routes/manage/index.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { RPCRouter } from '~/events/rpc/router'
|
||||||
|
|
||||||
|
import configRoutes from '~/events/rpc/routes/manage/config'
|
||||||
|
import bucketRoutes from '~/events/rpc/routes/manage/bucket'
|
||||||
|
import upDownLoadRoutes from '~/events/rpc/routes/manage/upDownload'
|
||||||
|
|
||||||
|
const manageRouter = new RPCRouter()
|
||||||
|
|
||||||
|
const manageRoutes = [...configRoutes, ...bucketRoutes, ...upDownLoadRoutes]
|
||||||
|
|
||||||
|
manageRouter.addBatch(manageRoutes)
|
||||||
|
|
||||||
|
export { manageRouter }
|
108
src/main/events/rpc/routes/manage/upDownload.ts
Normal file
108
src/main/events/rpc/routes/manage/upDownload.ts
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
import { app, dialog, shell } from 'electron'
|
||||||
|
import fs from 'fs-extra'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
import { IRPCActionType, IRPCType } from '#/types/enum'
|
||||||
|
|
||||||
|
import UpDownTaskQueue from '~/manage/datastore/upDownTaskQueue'
|
||||||
|
import { downloadFileFromUrl } from '~/manage/utils/common'
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_OPEN_FILE_SELECT_DIALOG,
|
||||||
|
handler: async () => {
|
||||||
|
const res = await dialog.showOpenDialog({
|
||||||
|
properties: ['openFile', 'multiSelections']
|
||||||
|
})
|
||||||
|
return res.canceled ? [] : res.filePaths
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_UPLOAD_TASK_LIST,
|
||||||
|
handler: async () => {
|
||||||
|
return UpDownTaskQueue.getInstance().getAllUploadTask()
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_DOWNLOAD_TASK_LIST,
|
||||||
|
handler: async () => {
|
||||||
|
return UpDownTaskQueue.getInstance().getAllDownloadTask()
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_DELETE_UPLOADED_TASK,
|
||||||
|
handler: async () => {
|
||||||
|
UpDownTaskQueue.getInstance().removeUploadedTask()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_DELETE_ALL_UPLOADED_TASK,
|
||||||
|
handler: async () => {
|
||||||
|
UpDownTaskQueue.getInstance().clearUploadTaskQueue()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_DELETE_DOWNLOADED_TASK,
|
||||||
|
handler: async () => {
|
||||||
|
UpDownTaskQueue.getInstance().removeDownloadedTask()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_DELETE_ALL_DOWNLOADED_TASK,
|
||||||
|
handler: async () => {
|
||||||
|
UpDownTaskQueue.getInstance().clearDownloadTaskQueue()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_SELECT_DOWNLOAD_FOLDER,
|
||||||
|
handler: async () => {
|
||||||
|
const res = await dialog.showOpenDialog({
|
||||||
|
properties: ['openDirectory']
|
||||||
|
})
|
||||||
|
return res.filePaths[0]
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER,
|
||||||
|
handler: async () => {
|
||||||
|
return app.getPath('downloads')
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_OPEN_DOWNLOADED_FOLDER,
|
||||||
|
handler: async (_: IIPCEvent, args: [path?: string]) => {
|
||||||
|
const path = args[0]
|
||||||
|
if (path) {
|
||||||
|
shell.showItemInFolder(path)
|
||||||
|
} else {
|
||||||
|
shell.openPath(app.getPath('downloads'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_OPEN_LOCAL_FILE,
|
||||||
|
handler: async (_: IIPCEvent, args: [fullPath: string]) => {
|
||||||
|
const fullPath = args[0]
|
||||||
|
fs.existsSync(fullPath) ? shell.showItemInFolder(fullPath) : shell.openPath(path.dirname(fullPath))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_DOWNLOAD_FILE_FROM_URL,
|
||||||
|
handler: async (_: IIPCEvent, args: [urls: string[]]) => {
|
||||||
|
return await downloadFileFromUrl(args[0])
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.MANAGE_CONVERT_PATH_TO_BASE64,
|
||||||
|
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
||||||
|
return fs.readFileSync(args[0], 'base64')
|
||||||
|
},
|
||||||
|
type: IRPCType.INVOKE
|
||||||
|
}
|
||||||
|
]
|
@ -22,7 +22,6 @@ import { T } from '~/i18n'
|
|||||||
import '~/lifeCycle/errorHandler'
|
import '~/lifeCycle/errorHandler'
|
||||||
import fixPath from '~/lifeCycle/fixPath'
|
import fixPath from '~/lifeCycle/fixPath'
|
||||||
import UpDownTaskQueue from '~/manage/datastore/upDownTaskQueue'
|
import UpDownTaskQueue from '~/manage/datastore/upDownTaskQueue'
|
||||||
import { manageIpcList } from '~/manage/events/ipcList'
|
|
||||||
import getManageApi from '~/manage/Main'
|
import getManageApi from '~/manage/Main'
|
||||||
import { clearTempFolder } from '~/manage/utils/common'
|
import { clearTempFolder } from '~/manage/utils/common'
|
||||||
import server from '~/server/index'
|
import server from '~/server/index'
|
||||||
@ -143,11 +142,10 @@ class LifeCycle {
|
|||||||
// fix the $PATH in macOS & linux
|
// fix the $PATH in macOS & linux
|
||||||
fixPath()
|
fixPath()
|
||||||
beforeOpen()
|
beforeOpen()
|
||||||
initI18n()
|
|
||||||
rpcServer.start()
|
|
||||||
getManageApi()
|
getManageApi()
|
||||||
UpDownTaskQueue.getInstance()
|
UpDownTaskQueue.getInstance()
|
||||||
manageIpcList.listen()
|
initI18n()
|
||||||
|
rpcServer.start()
|
||||||
busEventList.listen()
|
busEventList.listen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
export const PICLIST_MANAGE_GET_CONFIG = 'PICLIST_MANAGE_GET_CONFIG'
|
|
||||||
export const PICLIST_MANAGE_REMOVE_CONFIG = 'PICLIST_MANAGE_REMOVE_CONFIG'
|
|
||||||
export const PICLIST_MANAGE_SAVE_CONFIG = 'PICLIST_MANAGE_SAVE_CONFIG'
|
|
@ -1,158 +0,0 @@
|
|||||||
import { ipcMain, IpcMainInvokeEvent, dialog, app, shell } from 'electron'
|
|
||||||
import fs from 'fs-extra'
|
|
||||||
import path from 'path'
|
|
||||||
|
|
||||||
import UpDownTaskQueue from '~/manage/datastore/upDownTaskQueue'
|
|
||||||
import manageCoreIPC from '~/manage/events/manageCoreIPC'
|
|
||||||
import { ManageApi } from '~/manage/manageApi'
|
|
||||||
import { downloadFileFromUrl } from '~/manage/utils/common'
|
|
||||||
|
|
||||||
import { selectDownloadFolder } from '#/utils/static'
|
|
||||||
|
|
||||||
export const manageIpcList = {
|
|
||||||
listen() {
|
|
||||||
manageCoreIPC.listen()
|
|
||||||
|
|
||||||
ipcMain.handle('getBucketList', async (_: IpcMainInvokeEvent, currentPicBed: string) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.getBucketList()
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('createBucket', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.createBucket(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('getBucketFileList', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.getBucketFileList(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('getBucketDomain', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
const result = await manage.getBucketDomain(param)
|
|
||||||
return result
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('setBucketAclPolicy', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.setBucketAclPolicy(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('renameBucketFile', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.renameBucketFile(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('deleteBucketFile', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.deleteBucketFile(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('deleteBucketFolder', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.deleteBucketFolder(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('getBucketListBackstage', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.getBucketListBackstage(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on(
|
|
||||||
'getBucketListRecursively',
|
|
||||||
async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.getBucketListRecursively(param)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
ipcMain.handle('convertPathToBase64', async (_: IpcMainInvokeEvent, filePath: string) => {
|
|
||||||
const res = fs.readFileSync(filePath, 'base64')
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('openFileSelectDialog', async () => {
|
|
||||||
const res = await dialog.showOpenDialog({
|
|
||||||
properties: ['openFile', 'multiSelections']
|
|
||||||
})
|
|
||||||
if (res.canceled) {
|
|
||||||
return []
|
|
||||||
} else {
|
|
||||||
return res.filePaths
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('getPreSignedUrl', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.getPreSignedUrl(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('getUploadTaskList', async () => {
|
|
||||||
return UpDownTaskQueue.getInstance().getAllUploadTask()
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('getDownloadTaskList', async () => {
|
|
||||||
return UpDownTaskQueue.getInstance().getAllDownloadTask()
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('uploadBucketFile', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.uploadBucketFile(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('downloadBucketFile', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.downloadBucketFile(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('createBucketFolder', async (_: IpcMainInvokeEvent, currentPicBed: string, param: IStringKeyMap) => {
|
|
||||||
const manage = new ManageApi(currentPicBed)
|
|
||||||
return manage.createBucketFolder(param)
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('deleteUploadedTask', async () => {
|
|
||||||
UpDownTaskQueue.getInstance().removeUploadedTask()
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('deleteAllUploadedTask', async () => {
|
|
||||||
UpDownTaskQueue.getInstance().clearUploadTaskQueue()
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('deleteDownloadedTask', async () => {
|
|
||||||
UpDownTaskQueue.getInstance().removeDownloadedTask()
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('deleteAllDownloadedTask', async () => {
|
|
||||||
UpDownTaskQueue.getInstance().clearDownloadTaskQueue()
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle(selectDownloadFolder, async () => {
|
|
||||||
const res = await dialog.showOpenDialog({
|
|
||||||
properties: ['openDirectory']
|
|
||||||
})
|
|
||||||
return res.filePaths[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('getDefaultDownloadFolder', async () => {
|
|
||||||
return app.getPath('downloads')
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('OpenDownloadedFolder', async (_: IpcMainInvokeEvent, path: string | undefined) => {
|
|
||||||
if (path) {
|
|
||||||
shell.showItemInFolder(path)
|
|
||||||
} else {
|
|
||||||
shell.openPath(app.getPath('downloads'))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('OpenLocalFile', async (_: IpcMainInvokeEvent, fullPath: string) => {
|
|
||||||
fs.existsSync(fullPath) ? shell.showItemInFolder(fullPath) : shell.openPath(path.dirname(fullPath))
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.handle('downloadFileFromUrl', async (_: IpcMainInvokeEvent, urls: string[]) => {
|
|
||||||
const res = await downloadFileFromUrl(urls)
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
import { IpcMainEvent, IpcMainInvokeEvent, ipcMain } from 'electron'
|
|
||||||
|
|
||||||
import getManageApi from '~/manage/Main'
|
|
||||||
import {
|
|
||||||
PICLIST_MANAGE_GET_CONFIG,
|
|
||||||
PICLIST_MANAGE_SAVE_CONFIG,
|
|
||||||
PICLIST_MANAGE_REMOVE_CONFIG
|
|
||||||
} from '~/manage/events/constants'
|
|
||||||
|
|
||||||
const manageApi = getManageApi()
|
|
||||||
|
|
||||||
const handleManageGetConfig = () => {
|
|
||||||
ipcMain.handle(PICLIST_MANAGE_GET_CONFIG, (_: IpcMainInvokeEvent, key: string | undefined) => {
|
|
||||||
return manageApi.getConfig(key)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleManageSaveConfig = () => {
|
|
||||||
ipcMain.on(PICLIST_MANAGE_SAVE_CONFIG, (_: IpcMainEvent, data: any) => {
|
|
||||||
manageApi.saveConfig(data)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleManageRemoveConfig = () => {
|
|
||||||
ipcMain.on(PICLIST_MANAGE_REMOVE_CONFIG, (_: IpcMainEvent, key: string, propName: string) => {
|
|
||||||
manageApi.removeConfig(key, propName)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
listen() {
|
|
||||||
handleManageGetConfig()
|
|
||||||
handleManageSaveConfig()
|
|
||||||
handleManageRemoveConfig()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1230,6 +1230,8 @@ import { T as $T } from '@/i18n'
|
|||||||
import { getExtension, trimPath } from '#/utils/common'
|
import { getExtension, trimPath } from '#/utils/common'
|
||||||
import { cancelDownloadLoadingFileList, refreshDownloadFileTransferList } from '#/utils/static'
|
import { cancelDownloadLoadingFileList, refreshDownloadFileTransferList } from '#/utils/static'
|
||||||
import { IUploadTask, IDownloadTask } from '#/types/manage'
|
import { IUploadTask, IDownloadTask } from '#/types/manage'
|
||||||
|
import { sendRPC, triggerRPC } from '@/utils/common'
|
||||||
|
import { IRPCActionType } from 'root/src/universal/types/enum'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
configMap:{
|
configMap:{
|
||||||
@ -1416,7 +1418,7 @@ function showUploadDialog() {
|
|||||||
|
|
||||||
function startRefreshUploadTask() {
|
function startRefreshUploadTask() {
|
||||||
refreshUploadTaskId.value = setInterval(() => {
|
refreshUploadTaskId.value = setInterval(() => {
|
||||||
ipcRenderer.invoke('getUploadTaskList').then((res: any) => {
|
triggerRPC(IRPCActionType.MANAGE_GET_UPLOAD_TASK_LIST).then((res: any) => {
|
||||||
uploadTaskList.value = res
|
uploadTaskList.value = res
|
||||||
})
|
})
|
||||||
}, 300)
|
}, 300)
|
||||||
@ -1438,7 +1440,7 @@ function showDownloadDialog() {
|
|||||||
|
|
||||||
function startRefreshDownloadTask() {
|
function startRefreshDownloadTask() {
|
||||||
refreshDownloadTaskId.value = setInterval(() => {
|
refreshDownloadTaskId.value = setInterval(() => {
|
||||||
ipcRenderer.invoke('getDownloadTaskList').then((res: any) => {
|
triggerRPC(IRPCActionType.MANAGE_GET_DOWNLOAD_TASK_LIST).then((res: any) => {
|
||||||
downloadTaskList.value = res
|
downloadTaskList.value = res
|
||||||
})
|
})
|
||||||
}, 300)
|
}, 300)
|
||||||
@ -1458,7 +1460,7 @@ function handleViewChange(val: 'list' | 'grid') {
|
|||||||
// 上传文件选择相关
|
// 上传文件选择相关
|
||||||
|
|
||||||
function openFileSelectDialog() {
|
function openFileSelectDialog() {
|
||||||
ipcRenderer.invoke('openFileSelectDialog').then((res: any) => {
|
triggerRPC(IRPCActionType.MANAGE_OPEN_FILE_SELECT_DIALOG).then((res: any) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
res.forEach((item: any) => {
|
res.forEach((item: any) => {
|
||||||
tableData.push({
|
tableData.push({
|
||||||
@ -1664,7 +1666,7 @@ function uploadFiles() {
|
|||||||
aclForUpload: manageStore.config.picBed[configMap.alias].aclForUpload
|
aclForUpload: manageStore.config.picBed[configMap.alias].aclForUpload
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
ipcRenderer.send('uploadBucketFile', configMap.alias, param)
|
sendRPC(IRPCActionType.MANAGE_UPLOAD_BUCKET_FILE, configMap.alias, param)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCopyUploadingTaskInfo() {
|
function handleCopyUploadingTaskInfo() {
|
||||||
@ -1673,12 +1675,12 @@ function handleCopyUploadingTaskInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleDeleteUploadedTask() {
|
function handleDeleteUploadedTask() {
|
||||||
ipcRenderer.send('deleteUploadedTask')
|
sendRPC(IRPCActionType.MANAGE_DELETE_UPLOADED_TASK)
|
||||||
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDeleteAllUploadedTask() {
|
function handleDeleteAllUploadedTask() {
|
||||||
ipcRenderer.send('deleteAllUploadedTask')
|
sendRPC(IRPCActionType.MANAGE_DELETE_ALL_UPLOADED_TASK)
|
||||||
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1690,17 +1692,17 @@ function handleCopyDownloadingTaskInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleDeleteDownloadedTask() {
|
function handleDeleteDownloadedTask() {
|
||||||
ipcRenderer.send('deleteDownloadedTask')
|
sendRPC(IRPCActionType.MANAGE_DELETE_DOWNLOADED_TASK)
|
||||||
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDeleteAllDownloadedTask() {
|
function handleDeleteAllDownloadedTask() {
|
||||||
ipcRenderer.send('deleteAllDownloadedTask')
|
sendRPC(IRPCActionType.MANAGE_DELETE_ALL_DOWNLOADED_TASK)
|
||||||
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOpenDownloadedFolder() {
|
function handleOpenDownloadedFolder() {
|
||||||
ipcRenderer.send('OpenDownloadedFolder', manageStore.config.settings.downloadDir)
|
sendRPC(IRPCActionType.MANAGE_OPEN_DOWNLOADED_FOLDER, manageStore.config.settings.downloadDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 文件列表相关
|
// 文件列表相关
|
||||||
@ -1828,7 +1830,7 @@ async function initCustomDomainList() {
|
|||||||
} else if (currentPicBedName.value === 'github') {
|
} else if (currentPicBedName.value === 'github') {
|
||||||
defaultUrl = 'main'
|
defaultUrl = 'main'
|
||||||
}
|
}
|
||||||
const res = await ipcRenderer.invoke('getBucketDomain', configMap.alias, param)
|
const res = await triggerRPC<any>(IRPCActionType.MANAGE_GET_BUCKET_DOMAIN, configMap.alias, param)
|
||||||
if (res.length > 0) {
|
if (res.length > 0) {
|
||||||
customDomainList.value.length = 0
|
customDomainList.value.length = 0
|
||||||
res.forEach((item: any) => {
|
res.forEach((item: any) => {
|
||||||
@ -2165,7 +2167,7 @@ async function handleFolderBatchDownload(item: any) {
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const defaultDownloadPath = await ipcRenderer.invoke('getDefaultDownloadFolder')
|
const defaultDownloadPath = await triggerRPC<string>(IRPCActionType.MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER)
|
||||||
const param = {
|
const param = {
|
||||||
downloadPath: manageStore.config.settings.downloadDir ?? defaultDownloadPath,
|
downloadPath: manageStore.config.settings.downloadDir ?? defaultDownloadPath,
|
||||||
maxDownloadFileCount: manageStore.config.settings.maxDownloadFileCount
|
maxDownloadFileCount: manageStore.config.settings.maxDownloadFileCount
|
||||||
@ -2192,7 +2194,7 @@ async function handleFolderBatchDownload(item: any) {
|
|||||||
isLoadingDownloadData.value = true
|
isLoadingDownloadData.value = true
|
||||||
const downloadFileTransferStore = useDownloadFileTransferStore()
|
const downloadFileTransferStore = useDownloadFileTransferStore()
|
||||||
downloadFileTransferStore.resetDownloadFileTransferList()
|
downloadFileTransferStore.resetDownloadFileTransferList()
|
||||||
ipcRenderer.send('getBucketListRecursively', configMap.alias, paramGet)
|
sendRPC(IRPCActionType.MANAGE_GET_BUCKET_LIST_RECURSIVELY, configMap.alias, paramGet)
|
||||||
ipcRenderer.on(refreshDownloadFileTransferList, (_: IpcRendererEvent, data) => {
|
ipcRenderer.on(refreshDownloadFileTransferList, (_: IpcRendererEvent, data) => {
|
||||||
downloadFileTransferStore.refreshDownloadFileTransferList(data)
|
downloadFileTransferStore.refreshDownloadFileTransferList(data)
|
||||||
})
|
})
|
||||||
@ -2226,7 +2228,7 @@ async function handleFolderBatchDownload(item: any) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ipcRenderer.send('downloadBucketFile', configMap.alias, param)
|
sendRPC(IRPCActionType.MANAGE_DOWNLOAD_BUCKET_FILE, configMap.alias, param)
|
||||||
isShowDownloadPanel.value = true
|
isShowDownloadPanel.value = true
|
||||||
} else {
|
} else {
|
||||||
ElNotification.error({
|
ElNotification.error({
|
||||||
@ -2249,7 +2251,7 @@ async function handleFolderBatchDownload(item: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleBatchDownload() {
|
async function handleBatchDownload() {
|
||||||
const defaultDownloadPath = await ipcRenderer.invoke('getDefaultDownloadFolder')
|
const defaultDownloadPath = await triggerRPC<string>(IRPCActionType.MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER)
|
||||||
const param = {
|
const param = {
|
||||||
downloadPath: manageStore.config.settings.downloadDir ?? defaultDownloadPath,
|
downloadPath: manageStore.config.settings.downloadDir ?? defaultDownloadPath,
|
||||||
maxDownloadFileCount: manageStore.config.settings.maxDownloadFileCount
|
maxDownloadFileCount: manageStore.config.settings.maxDownloadFileCount
|
||||||
@ -2274,7 +2276,7 @@ async function handleBatchDownload() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ipcRenderer.send('downloadBucketFile', configMap.alias, param)
|
sendRPC(IRPCActionType.MANAGE_DOWNLOAD_BUCKET_FILE, configMap.alias, param)
|
||||||
handleCancelCheck()
|
handleCancelCheck()
|
||||||
isShowDownloadPanel.value = true
|
isShowDownloadPanel.value = true
|
||||||
}
|
}
|
||||||
@ -2303,7 +2305,7 @@ function handleCreateFolder() {
|
|||||||
key: currentPrefix.value.slice(1) + formatedPath + '/',
|
key: currentPrefix.value.slice(1) + formatedPath + '/',
|
||||||
githubBranch: currentCustomDomain.value
|
githubBranch: currentCustomDomain.value
|
||||||
}
|
}
|
||||||
const res = await ipcRenderer.invoke('createBucketFolder', configMap.alias, param)
|
const res = await triggerRPC<any>(IRPCActionType.MANAGE_CREATE_BUCKET_FOLDER, configMap.alias, param)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success($T('MANAGE_BUCKET_CREATE_FOLDER_SUCCESS'))
|
ElMessage.success($T('MANAGE_BUCKET_CREATE_FOLDER_SUCCESS'))
|
||||||
} else {
|
} else {
|
||||||
@ -2335,7 +2337,7 @@ async function handleUploadFromUrl() {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 1000
|
duration: 1000
|
||||||
})
|
})
|
||||||
const res = await ipcRenderer.invoke('downloadFileFromUrl', urlList)
|
const res = await triggerRPC<any>(IRPCActionType.MANAGE_DOWNLOAD_FILE_FROM_URL, urlList)
|
||||||
for (let i = 0; i < res.length; i++) {
|
for (let i = 0; i < res.length; i++) {
|
||||||
const fPath = res[i].replace(/\\/g, '/')
|
const fPath = res[i].replace(/\\/g, '/')
|
||||||
uploadPanelFilesList.value.push({
|
uploadPanelFilesList.value.push({
|
||||||
@ -2433,7 +2435,7 @@ async function BatchRename() {
|
|||||||
newKey: (item.key.slice(0, item.key.lastIndexOf('/') + 1) + item.newName).replaceAll('//', '/'),
|
newKey: (item.key.slice(0, item.key.lastIndexOf('/') + 1) + item.newName).replaceAll('//', '/'),
|
||||||
customUrl: currentCustomDomain.value
|
customUrl: currentCustomDomain.value
|
||||||
}
|
}
|
||||||
ipcRenderer.invoke('renameBucketFile', configMap.alias, param).then((res: any) => {
|
triggerRPC<any>(IRPCActionType.MANAGE_RENAME_BUCKET_FILE, configMap.alias, param).then((res: any) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
successCount++
|
successCount++
|
||||||
resolve(true)
|
resolve(true)
|
||||||
@ -2620,7 +2622,7 @@ async function getBucketFileListBackStage() {
|
|||||||
param.baseDir = configMap.baseDir
|
param.baseDir = configMap.baseDir
|
||||||
param.webPath = configMap.webPath
|
param.webPath = configMap.webPath
|
||||||
}
|
}
|
||||||
ipcRenderer.send('getBucketListBackstage', configMap.alias, param)
|
sendRPC(IRPCActionType.MANAGE_GET_BUCKET_LIST_BACKSTAGE, configMap.alias, param)
|
||||||
ipcRenderer.on('refreshFileTransferList', (_: IpcRendererEvent, data) => {
|
ipcRenderer.on('refreshFileTransferList', (_: IpcRendererEvent, data) => {
|
||||||
fileTransferStore.refreshFileTransferList(data)
|
fileTransferStore.refreshFileTransferList(data)
|
||||||
})
|
})
|
||||||
@ -2673,7 +2675,7 @@ async function getBucketFileList() {
|
|||||||
customUrl: currentCustomDomain.value,
|
customUrl: currentCustomDomain.value,
|
||||||
currentPage: currentPageNumber.value
|
currentPage: currentPageNumber.value
|
||||||
}
|
}
|
||||||
return await ipcRenderer.invoke('getBucketFileList', configMap.alias, param)
|
return await triggerRPC<any>(IRPCActionType.MANAGE_GET_BUCKET_FILE_LIST, configMap.alias, param)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleBatchDeleteInfo() {
|
function handleBatchDeleteInfo() {
|
||||||
@ -2699,8 +2701,8 @@ function handleBatchDeleteInfo() {
|
|||||||
githubBranch: currentCustomDomain.value
|
githubBranch: currentCustomDomain.value
|
||||||
}
|
}
|
||||||
const result = item.isDir
|
const result = item.isDir
|
||||||
? await ipcRenderer.invoke('deleteBucketFolder', configMap.alias, param)
|
? await triggerRPC<any>(IRPCActionType.MANAGE_DELETE_BUCKET_FOLDER, configMap.alias, param)
|
||||||
: await ipcRenderer.invoke('deleteBucketFile', configMap.alias, param)
|
: await triggerRPC<any>(IRPCActionType.MANAGE_DELETE_BUCKET_FILE, configMap.alias, param)
|
||||||
if (result) {
|
if (result) {
|
||||||
successCount++
|
successCount++
|
||||||
currentPageFilesInfo.splice(
|
currentPageFilesInfo.splice(
|
||||||
@ -2775,9 +2777,9 @@ function handleDeleteFile(item: any) {
|
|||||||
message: $T('MANAGE_BUCKET_DELETE_ERROR_MSG_MSG'),
|
message: $T('MANAGE_BUCKET_DELETE_ERROR_MSG_MSG'),
|
||||||
duration: 1000
|
duration: 1000
|
||||||
})
|
})
|
||||||
res = await ipcRenderer.invoke('deleteBucketFolder', configMap.alias, param)
|
res = await triggerRPC<any>(IRPCActionType.MANAGE_DELETE_BUCKET_FOLDER, configMap.alias, param)
|
||||||
} else {
|
} else {
|
||||||
res = await ipcRenderer.invoke('deleteBucketFile', configMap.alias, param)
|
res = await triggerRPC<any>(IRPCActionType.MANAGE_DELETE_BUCKET_FILE, configMap.alias, param)
|
||||||
}
|
}
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
ElMessage.success($T('MANAGE_BUCKET_DELETE_SUCCESS'))
|
||||||
@ -2845,7 +2847,7 @@ function singleRename() {
|
|||||||
newKey: (item.key.slice(0, item.key.lastIndexOf('/') + 1) + itemToBeRenamed.value.newName).replaceAll('//', '/'),
|
newKey: (item.key.slice(0, item.key.lastIndexOf('/') + 1) + itemToBeRenamed.value.newName).replaceAll('//', '/'),
|
||||||
customUrl: currentCustomDomain.value
|
customUrl: currentCustomDomain.value
|
||||||
}
|
}
|
||||||
ipcRenderer.invoke('renameBucketFile', configMap.alias, param).then((res: any) => {
|
triggerRPC<any>(IRPCActionType.MANAGE_RENAME_BUCKET_FILE, configMap.alias, param).then((res: any) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
const oldKey = currentPrefix.value + item.fileName
|
const oldKey = currentPrefix.value + item.fileName
|
||||||
if (pagingMarker.value === oldKey.slice(1)) {
|
if (pagingMarker.value === oldKey.slice(1)) {
|
||||||
@ -2910,8 +2912,7 @@ async function getPreSignedUrl(item: any) {
|
|||||||
githubPrivate: configMap.bucketConfig.private,
|
githubPrivate: configMap.bucketConfig.private,
|
||||||
rawUrl: item.url
|
rawUrl: item.url
|
||||||
}
|
}
|
||||||
const res = await ipcRenderer.invoke('getPreSignedUrl', configMap.alias, param)
|
return await triggerRPC<any>(IRPCActionType.MANAGE_GET_PRE_SIGNED_URL, configMap.alias, param)
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyToClipboard(text: string) {
|
function copyToClipboard(text: string) {
|
||||||
@ -2954,7 +2955,7 @@ const downloadedTaskColumns: Column<any>[] = [
|
|||||||
cellRenderer: ({ rowData: item }) => (
|
cellRenderer: ({ rowData: item }) => (
|
||||||
<div
|
<div
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
ipcRenderer.send('OpenLocalFile', item.targetFilePath)
|
sendRPC(IRPCActionType.MANAGE_OPEN_LOCAL_FILE, item.targetFilePath)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ElTooltip effect='dark' content={item.sourceFileName} placement='top'>
|
<ElTooltip effect='dark' content={item.sourceFileName} placement='top'>
|
||||||
|
@ -237,7 +237,8 @@ import { useManageStore } from '@/manage/store/manageStore'
|
|||||||
import { newBucketConfig } from '@/manage/utils/newBucketConfig'
|
import { newBucketConfig } from '@/manage/utils/newBucketConfig'
|
||||||
|
|
||||||
import { T as $T } from '@/i18n'
|
import { T as $T } from '@/i18n'
|
||||||
import { invokeToMain } from '@/utils/common'
|
import { triggerRPC } from '@/utils/common'
|
||||||
|
import { IRPCActionType } from 'root/src/universal/types/enum'
|
||||||
|
|
||||||
const manageStore = useManageStore() as any
|
const manageStore = useManageStore() as any
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -348,7 +349,7 @@ function createNewBucket(picBedName: string) {
|
|||||||
resultMap.BucketName = `${resultMap.BucketName}-${currentPagePicBedConfig.appId}`
|
resultMap.BucketName = `${resultMap.BucketName}-${currentPagePicBedConfig.appId}`
|
||||||
}
|
}
|
||||||
resultMap.endpoint = currentPagePicBedConfig.endpoint
|
resultMap.endpoint = currentPagePicBedConfig.endpoint
|
||||||
invokeToMain('createBucket', currentAlias, resultMap).then((result: any) => {
|
triggerRPC(IRPCActionType.MANAGE_CREATE_BUCKET, currentAlias, resultMap).then((result: any) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
ElNotification({
|
ElNotification({
|
||||||
title: $T('MANAGE_MAIN_PAGE_TIPS'),
|
title: $T('MANAGE_MAIN_PAGE_TIPS'),
|
||||||
@ -374,7 +375,7 @@ async function getBucketList() {
|
|||||||
bucketNameList.value = []
|
bucketNameList.value = []
|
||||||
isLoadingBucketList.value = true
|
isLoadingBucketList.value = true
|
||||||
|
|
||||||
const result = await invokeToMain('getBucketList', currentAlias.value)
|
const result = await triggerRPC<any>(IRPCActionType.MANAGE_GET_BUCKET_LIST, currentAlias.value)
|
||||||
isLoadingBucketList.value = false
|
isLoadingBucketList.value = false
|
||||||
|
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
|
@ -204,8 +204,8 @@ import { getConfig, saveConfig } from '@/manage/utils/dataSender'
|
|||||||
|
|
||||||
import { T as $T } from '@/i18n'
|
import { T as $T } from '@/i18n'
|
||||||
|
|
||||||
import { selectDownloadFolder } from '#/utils/static'
|
import { triggerRPC } from '@/utils/common'
|
||||||
import { invokeToMain } from '@/utils/common'
|
import { IRPCActionType } from 'root/src/universal/types/enum'
|
||||||
|
|
||||||
const form = ref<IStringKeyMap>({
|
const form = ref<IStringKeyMap>({
|
||||||
timestampRename: false,
|
timestampRename: false,
|
||||||
@ -321,7 +321,7 @@ async function initData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleDownloadDirClick() {
|
async function handleDownloadDirClick() {
|
||||||
const result = await invokeToMain(selectDownloadFolder)
|
const result = triggerRPC<any>(IRPCActionType.MANAGE_SELECT_DOWNLOAD_FOLDER)
|
||||||
if (result) {
|
if (result) {
|
||||||
form.value.downloadDir = result
|
form.value.downloadDir = result
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
import { ipcRenderer } from 'electron'
|
import { sendRPC, triggerRPC } from '@/utils/common'
|
||||||
|
|
||||||
import { getRawData } from '@/utils/common'
|
import { IRPCActionType } from '#/types/enum'
|
||||||
|
|
||||||
import {
|
|
||||||
PICLIST_MANAGE_GET_CONFIG,
|
|
||||||
PICLIST_MANAGE_SAVE_CONFIG,
|
|
||||||
PICLIST_MANAGE_REMOVE_CONFIG
|
|
||||||
} from '~/manage/events/constants'
|
|
||||||
|
|
||||||
export function saveConfig(config: IObj | string, value?: any) {
|
export function saveConfig(config: IObj | string, value?: any) {
|
||||||
const configObj = typeof config === 'string' ? { [config]: value } : getRawData(config)
|
const configObj = typeof config === 'string' ? { [config]: value } : config
|
||||||
ipcRenderer.send(PICLIST_MANAGE_SAVE_CONFIG, configObj)
|
sendRPC(IRPCActionType.MANAGE_SAVE_CONFIG, configObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getConfig<T>(key?: string): Promise<T | undefined> {
|
export async function getConfig<T>(key?: string): Promise<T | undefined> {
|
||||||
return await ipcRenderer.invoke(PICLIST_MANAGE_GET_CONFIG, key)
|
return await triggerRPC<T>(IRPCActionType.MANAGE_GET_CONFIG, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeConfig(key: string, propName: string) {
|
export function removeConfig(key: string, propName: string) {
|
||||||
ipcRenderer.send(PICLIST_MANAGE_REMOVE_CONFIG, key, propName)
|
sendRPC(IRPCActionType.MANAGE_REMOVE_CONFIG, key, propName)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import { IConfig } from 'piclist'
|
|||||||
import { onBeforeUnmount, onBeforeMount, ref, watch } from 'vue'
|
import { onBeforeUnmount, onBeforeMount, ref, watch } from 'vue'
|
||||||
|
|
||||||
import { T as $T } from '@/i18n/index'
|
import { T as $T } from '@/i18n/index'
|
||||||
import { invokeToMain, sendRPC } from '@/utils/common'
|
import { sendRPC, triggerRPC } from '@/utils/common'
|
||||||
import { getConfig } from '@/utils/dataSender'
|
import { getConfig } from '@/utils/dataSender'
|
||||||
import { osGlobal } from '@/utils/global'
|
import { osGlobal } from '@/utils/global'
|
||||||
|
|
||||||
@ -53,7 +53,8 @@ async function initLogoPath() {
|
|||||||
if (config) {
|
if (config) {
|
||||||
if (config.settings?.isCustomMiniIcon && config.settings?.customMiniIcon) {
|
if (config.settings?.isCustomMiniIcon && config.settings?.customMiniIcon) {
|
||||||
logoPath.value =
|
logoPath.value =
|
||||||
'data:image/jpg;base64,' + (await invokeToMain('convertPathToBase64', config.settings.customMiniIcon))
|
'data:image/jpg;base64,' +
|
||||||
|
(await triggerRPC(IRPCActionType.MANAGE_CONVERT_PATH_TO_BASE64, config.settings.customMiniIcon))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -947,7 +947,7 @@ import { configPaths, ISartModeValues } from '#/utils/configPaths'
|
|||||||
import { getLatestVersion } from '#/utils/getLatestVersion'
|
import { getLatestVersion } from '#/utils/getLatestVersion'
|
||||||
|
|
||||||
import pkg from 'root/package.json'
|
import pkg from 'root/package.json'
|
||||||
import { invokeToMain, sendRPC, triggerRPC } from '@/utils/common'
|
import { sendRPC, triggerRPC } from '@/utils/common'
|
||||||
|
|
||||||
const $router = useRouter()
|
const $router = useRouter()
|
||||||
const activeName = ref<'system' | 'syncAndConfigure' | 'upload' | 'advanced' | 'upadte'>('system')
|
const activeName = ref<'system' | 'syncAndConfigure' | 'upload' | 'advanced' | 'upadte'>('system')
|
||||||
@ -1420,7 +1420,7 @@ function handleMiniWindowOntop(val: ICheckBoxValueType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleMiniIconPath(_: Event) {
|
async function handleMiniIconPath(_: Event) {
|
||||||
const result = await invokeToMain('openFileSelectDialog')
|
const result = await triggerRPC<string[]>(IRPCActionType.MANAGE_OPEN_FILE_SELECT_DIALOG)
|
||||||
if (result && result[0]) {
|
if (result && result[0]) {
|
||||||
formOfSetting.value.customMiniIcon = result[0]
|
formOfSetting.value.customMiniIcon = result[0]
|
||||||
saveConfig(configPaths.settings.customMiniIcon, formOfSetting.value.customMiniIcon)
|
saveConfig(configPaths.settings.customMiniIcon, formOfSetting.value.customMiniIcon)
|
||||||
|
@ -56,11 +56,6 @@ export function sendRpcSync(action: IRPCActionType, ...args: any[]) {
|
|||||||
return ipcRenderer.sendSync(RPC_ACTIONS, action, data)
|
return ipcRenderer.sendSync(RPC_ACTIONS, action, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function invokeToMain(channel: string, ...args: any[]) {
|
|
||||||
const data = getRawData(args)
|
|
||||||
return ipcRenderer.invoke(channel, ...data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* trigger RPC action
|
* trigger RPC action
|
||||||
* TODO: create an isolate rpc handler
|
* TODO: create an isolate rpc handler
|
||||||
|
@ -173,7 +173,39 @@ export enum IRPCActionType {
|
|||||||
// tray rpc
|
// tray rpc
|
||||||
TRAY_SET_TOOL_TIP = 'TRAY_SET_TOOL_TIP',
|
TRAY_SET_TOOL_TIP = 'TRAY_SET_TOOL_TIP',
|
||||||
TRAY_GET_SHORT_URL = 'TRAY_GET_SHORT_URL',
|
TRAY_GET_SHORT_URL = 'TRAY_GET_SHORT_URL',
|
||||||
TRAY_UPLOAD_CLIPBOARD_FILES = 'TRAY_UPLOAD_CLIPBOARD_FILES'
|
TRAY_UPLOAD_CLIPBOARD_FILES = 'TRAY_UPLOAD_CLIPBOARD_FILES',
|
||||||
|
|
||||||
|
// manage rpc
|
||||||
|
MANAGE_GET_CONFIG = 'MANAGE_GET_CONFIG',
|
||||||
|
MANAGE_SAVE_CONFIG = 'MANAGE_SAVE_CONFIG',
|
||||||
|
MANAGE_REMOVE_CONFIG = 'MANAGE_REMOVE_CONFIG',
|
||||||
|
MANAGE_GET_BUCKET_LIST = 'MANAGE_GET_BUCKET_LIST',
|
||||||
|
MANAGE_GET_BUCKET_LIST_BACKSTAGE = 'MANAGE_GET_BUCKET_LIST_BACKSTAGE',
|
||||||
|
MANAGE_GET_BUCKET_LIST_RECURSIVELY = 'MANAGE_GET_BUCKET_LIST_RECURSIVELY',
|
||||||
|
MANAGE_CREATE_BUCKET = 'MANAGE_CREATE_BUCKET',
|
||||||
|
MANAGE_GET_BUCKET_FILE_LIST = 'MANAGE_GET_BUCKET_FILE_LIST',
|
||||||
|
MANAGE_GET_BUCKET_DOMAIN = 'MANAGE_GET_BUCKET_DOMAIN',
|
||||||
|
MANAGE_SET_BUCKET_ACL_POLICY = 'MANAGE_SET_BUCKET_ACL_POLICY',
|
||||||
|
MANAGE_RENAME_BUCKET_FILE = 'MANAGE_RENAME_BUCKET_FILE',
|
||||||
|
MANAGE_DELETE_BUCKET_FILE = 'MANAGE_DELETE_BUCKET_FILE',
|
||||||
|
MANAGE_DELETE_BUCKET_FOLDER = 'MANAGE_DELETE_BUCKET_FOLDER',
|
||||||
|
MANAGE_GET_PRE_SIGNED_URL = 'MANAGE_GET_PRE_SIGNED_URL',
|
||||||
|
MANAGE_UPLOAD_BUCKET_FILE = 'MANAGE_UPLOAD_BUCKET_FILE',
|
||||||
|
MANAGE_DOWNLOAD_BUCKET_FILE = 'MANAGE_DOWNLOAD_BUCKET_FILE',
|
||||||
|
MANAGE_CREATE_BUCKET_FOLDER = 'MANAGE_CREATE_BUCKET_FOLDER',
|
||||||
|
MANAGE_OPEN_FILE_SELECT_DIALOG = 'MANAGE_OPEN_FILE_SELECT_DIALOG',
|
||||||
|
MANAGE_GET_UPLOAD_TASK_LIST = 'MANAGE_GET_UPLOAD_TASK_LIST',
|
||||||
|
MANAGE_GET_DOWNLOAD_TASK_LIST = 'MANAGE_GET_DOWNLOAD_TASK_LIST',
|
||||||
|
MANAGE_DELETE_UPLOADED_TASK = 'MANAGE_DELETE_UPLOADED_TASK',
|
||||||
|
MANAGE_DELETE_ALL_UPLOADED_TASK = 'MANAGE_DELETE_ALL_UPLOADED_TASK',
|
||||||
|
MANAGE_DELETE_DOWNLOADED_TASK = 'MANAGE_DELETE_DOWNLOADED_TASK',
|
||||||
|
MANAGE_DELETE_ALL_DOWNLOADED_TASK = 'MANAGE_DELETE_ALL_DOWNLOADED_TASK',
|
||||||
|
MANAGE_SELECT_DOWNLOAD_FOLDER = 'MANAGE_SELECT_DOWNLOAD_FOLDER',
|
||||||
|
MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER = 'MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER',
|
||||||
|
MANAGE_OPEN_DOWNLOADED_FOLDER = 'MANAGE_OPEN_DOWNLOADED_FOLDER',
|
||||||
|
MANAGE_OPEN_LOCAL_FILE = 'MANAGE_OPEN_LOCAL_FILE',
|
||||||
|
MANAGE_DOWNLOAD_FILE_FROM_URL = 'MANAGE_DOWNLOAD_FILE_FROM_URL',
|
||||||
|
MANAGE_CONVERT_PATH_TO_BASE64 = 'MANAGE_CONVERT_PATH_TO_BASE64'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum IToolboxItemType {
|
export enum IToolboxItemType {
|
||||||
|
@ -7,7 +7,6 @@ export const DEFAULT_AES_PASSWORD = 'aesPassword'
|
|||||||
|
|
||||||
export const cancelDownloadLoadingFileList = 'cancelDownloadLoadingFileList'
|
export const cancelDownloadLoadingFileList = 'cancelDownloadLoadingFileList'
|
||||||
export const refreshDownloadFileTransferList = 'refreshDownloadFileTransferList'
|
export const refreshDownloadFileTransferList = 'refreshDownloadFileTransferList'
|
||||||
export const selectDownloadFolder = 'selectDownloadFolder'
|
|
||||||
|
|
||||||
export const picBedsCanbeDeleted = [
|
export const picBedsCanbeDeleted = [
|
||||||
'aliyun',
|
'aliyun',
|
||||||
|
Loading…
Reference in New Issue
Block a user