From 19f2b18a6ae7e3946ebf2060510847c04ed70e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E8=90=8C=E5=93=92=E8=B5=AB=E8=90=9D?= Date: Mon, 21 Aug 2023 01:38:52 -0700 Subject: [PATCH] :sparkles: Feature: add notification for single rename of manage page --- public/i18n/en.yml | 1 + public/i18n/zh-CN.yml | 1 + public/i18n/zh-TW.yml | 1 + src/main/events/picgoCoreIPC.ts | 1 - src/main/manage/apis/sftp.ts | 11 +++++------ src/main/utils/sshClient.ts | 2 +- src/renderer/manage/pages/bucketPage.vue | 6 +++--- src/universal/types/i18n.d.ts | 1 + 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/public/i18n/en.yml b/public/i18n/en.yml index c24dbb6..232317b 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -842,6 +842,7 @@ MANAGE_BUCKET_DELETE_SUCCESS: Deletion successful MANAGE_BUCKET_DELETE_FAIL: Deletion failed MANAGE_BUCKET_DELETE_CANCEL: Deletion has been cancelled MANAGE_BUCKET_RENAME_INFO_MSG: The new file name is the same as the original file name, no need to rename +MANAGE_BUCKET_RENAME_SUCCESS: Rename successful MANAGE_BUCKET_RENAME_ERROR_MSG: Rename failed MANAGE_BUCKET_DOWNLOAD_COLUMN_FILENAME: File name MANAGE_BUCKET_DOWNLOAD_COLUMN_FINISHTIME: Completion time diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index f286923..88b8bc2 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -846,6 +846,7 @@ MANAGE_BUCKET_DELETE_SUCCESS: 删除成功 MANAGE_BUCKET_DELETE_FAIL: 删除失败 MANAGE_BUCKET_DELETE_CANCEL: 已取消删除 MANAGE_BUCKET_RENAME_INFO_MSG: 新文件名与原文件名相同,无需重命名 +MANAGE_BUCKET_RENAME_SUCCESS: 重命名成功 MANAGE_BUCKET_RENAME_ERROR_MSG: 重命名失败 MANAGE_BUCKET_DOWNLOAD_COLUMN_FILENAME: 文件名 MANAGE_BUCKET_DOWNLOAD_COLUMN_FINISHTIME: 完成时间 diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index 553151a..0ad0e8e 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -842,6 +842,7 @@ MANAGE_BUCKET_DELETE_SUCCESS: 刪除成功 MANAGE_BUCKET_DELETE_FAIL: 刪除失敗 MANAGE_BUCKET_DELETE_CANCEL: 已取消删除 MANAGE_BUCKET_RENAME_INFO_MSG: 新文件名和原文件名相同,無需重命名 +MANAGE_BUCKET_RENAME_SUCCESS: 重命名成功 MANAGE_BUCKET_RENAME_ERROR_MSG: 重命名失敗 MANAGE_BUCKET_DOWNLOAD_COLUMN_FILENAME: 文件名 MANAGE_BUCKET_DOWNLOAD_COLUMN_FINISHTIME: 完成時間 diff --git a/src/main/events/picgoCoreIPC.ts b/src/main/events/picgoCoreIPC.ts index 43f45f1..837dd43 100644 --- a/src/main/events/picgoCoreIPC.ts +++ b/src/main/events/picgoCoreIPC.ts @@ -214,7 +214,6 @@ const handlePluginUpdate = async (fullName: string | string[]) => { const handleUpdateAllPlugin = () => { ipcMain.on('updateAllPlugin', async (event: IpcMainEvent, list: string[]) => { - console.log(list) handlePluginUpdate(list) }) } diff --git a/src/main/manage/apis/sftp.ts b/src/main/manage/apis/sftp.ts index 17896ed..6d33cc1 100644 --- a/src/main/manage/apis/sftp.ts +++ b/src/main/manage/apis/sftp.ts @@ -262,10 +262,9 @@ class SftpApi { this.ctx.close() if (this.isRequestSuccess(res.code)) { const formatedLSRes = this.formatLSResult(res.stdout, prefix) - console.log(formatedLSRes) if (formatedLSRes.length) { formatedLSRes.forEach((item: listDirResult) => { - const relativePath = path.relative(baseDir, item.key) + const relativePath = path.relative(baseDir, item.key.startsWith('/') ? item.key : `/${item.key}`) const relative = webPath && urlPrefix + `/${path.join(webPath, relativePath)}`.replace(/\\/g, '/').replace(/\/+/g, '/') if (item.isDir) { result.fullList.push(this.formatFolder(item, webPath ? relative : urlPrefix, !!webPath)) @@ -298,7 +297,7 @@ class SftpApi { let result = false try { await this.connectClient() - const res = await this.ctx.execCommand(`mv -f ${oldKey} ${newKey}`) + const res = await this.ctx.execCommand(`mv -f "/${oldKey.replace(/^\/+/, '')}" "/${newKey.replace(/^\/+/, '')}"`) this.ctx.close() result = this.isRequestSuccess(res.code) } catch (error) { @@ -312,7 +311,7 @@ class SftpApi { let result = false try { await this.connectClient() - const res = await this.ctx.execCommand(`rm -f ${key}`) + const res = await this.ctx.execCommand(`rm -f "/${key.replace(/^\/+/, '')}"`) this.ctx.close() result = this.isRequestSuccess(res.code) } catch (error) { @@ -326,7 +325,7 @@ class SftpApi { let result = false try { await this.connectClient() - const res = await this.ctx.execCommand(`rm -rf ${key}`) + const res = await this.ctx.execCommand(`rm -rf "/${key.replace(/^\/+/, '')}"`) this.ctx.close() result = this.isRequestSuccess(res.code) } catch (error) { @@ -370,7 +369,7 @@ class SftpApi { let result = false try { await this.connectClient() - const res = await this.ctx.execCommand(`mkdir -p ${key}`) + const res = await this.ctx.execCommand(`mkdir -p "/${key.replace(/^\/+/, '')}"`) this.ctx.close() result = this.isRequestSuccess(res.code) } catch (error) { diff --git a/src/main/utils/sshClient.ts b/src/main/utils/sshClient.ts index e1dad08..005275d 100644 --- a/src/main/utils/sshClient.ts +++ b/src/main/utils/sshClient.ts @@ -43,7 +43,7 @@ class SSHClient { } try { remote = this.changeWinStylePathToUnix(remote) - const script = `rm -f ${remote}` + const script = `rm -f "${remote}"` return await this.exec(script) } catch (err: any) { return false diff --git a/src/renderer/manage/pages/bucketPage.vue b/src/renderer/manage/pages/bucketPage.vue index 8eb2685..f33aa5f 100644 --- a/src/renderer/manage/pages/bucketPage.vue +++ b/src/renderer/manage/pages/bucketPage.vue @@ -1616,7 +1616,7 @@ const isIgnoreCase = computed(() => manageStore.config.settings.isIgnoreCase ?? // 新建文件夹相关 const isShowCreateNewFolder = computed(() => ['aliyun', 'github', 'local', 'qiniu', 'tcyun', 's3plist', 'upyun', 'webdavplist', 'sftp'].includes(currentPicBedName.value)) -const isShowPresignedUrl = computed(() => ['aliyun', 'github', 'qiniu', 's3plist', 'tcyun', 'webdavplist', 'sftp'].includes(currentPicBedName.value)) +const isShowPresignedUrl = computed(() => ['aliyun', 'github', 'qiniu', 's3plist', 'tcyun', 'webdavplist'].includes(currentPicBedName.value)) // 上传相关函数 @@ -3047,11 +3047,11 @@ function singleRename () { }) }) } + ElMessage.success($T('MANAGE_BUCKET_RENAME_SUCCESS')) } else { ElMessage.error($T('MANAGE_BUCKET_RENAME_ERROR_MSG')) } - } - ) + }) } async function getPreSignedUrl (item: any) { diff --git a/src/universal/types/i18n.d.ts b/src/universal/types/i18n.d.ts index 3790b8b..e86ffcd 100644 --- a/src/universal/types/i18n.d.ts +++ b/src/universal/types/i18n.d.ts @@ -800,6 +800,7 @@ interface ILocales { MANAGE_BUCKET_DELETE_FAIL: string MANAGE_BUCKET_DELETE_CANCEL: string MANAGE_BUCKET_RENAME_INFO_MSG: string + MANAGE_BUCKET_RENAME_SUCCESS: string MANAGE_BUCKET_RENAME_ERROR_MSG: string MANAGE_BUCKET_DOWNLOAD_COLUMN_FILENAME: string MANAGE_BUCKET_DOWNLOAD_COLUMN_FINISHTIME: string