From 94c24ebf16ebbbe2374d3a59862a7b91522cb04b Mon Sep 17 00:00:00 2001 From: tickstep Date: Wed, 5 Mar 2025 20:47:56 +0800 Subject: [PATCH] add sample code for js plugin --- assets/plugin/js/download_handler.js.sample | 24 ++++++++++----------- assets/plugin/js/sync_handler.js.sample | 12 +++++++++++ internal/plugins/plugin_util.go | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/assets/plugin/js/download_handler.js.sample b/assets/plugin/js/download_handler.js.sample index 04d7332..1d5eb7e 100755 --- a/assets/plugin/js/download_handler.js.sample +++ b/assets/plugin/js/download_handler.js.sample @@ -127,16 +127,16 @@ function downloadFilePrepareCallback(context, params) { function downloadFileFinishCallback(context, params) { console.log(params) - // 云盘文件成功下载到本地后,删除云盘的文件 - if (params["downloadResult"] == "success") { - if (params["driveFileType"] == "file") { - // 文件下载成功,删除该云盘文件 - var userId = context["userId"] - var driveId = params["driveId"] - var driveFileId = params["driveFileId"] - if (PluginUtil.PanFS.deleteFile(userId, driveId, driveFileId)) { - console.log("插件删除云盘文件成功:" + params["driveFilePath"]) - } - } - } + // // 云盘文件成功下载到本地后,删除云盘的文件 + // if (params["downloadResult"] == "success") { + // if (params["driveFileType"] == "file") { + // // 文件下载成功,删除该云盘文件 + // var userId = context["userId"] + // var driveId = params["driveId"] + // var driveFileId = params["driveFileId"] + // if (PluginUtil.PanFS.deleteFile(userId, driveId, driveFileId)) { + // console.log("插件删除云盘文件成功:" + params["driveFilePath"]) + // } + // } + // } } \ No newline at end of file diff --git a/assets/plugin/js/sync_handler.js.sample b/assets/plugin/js/sync_handler.js.sample index 3d9d5c8..e274430 100644 --- a/assets/plugin/js/sync_handler.js.sample +++ b/assets/plugin/js/sync_handler.js.sample @@ -202,6 +202,18 @@ function syncScanPanFilePrepareCallback(context, params) { // ------------------------------------------------------------------------------------------ function syncFileFinishCallback(context, params) { console.log(params) + // 云盘文件成功下载到本地后,删除云盘的文件 + // if (params["action"] == "download") { + // if (params["actionResult"] == "success" && params["fileType"] == "file") { + // // 文件下载成功,删除该云盘文件 + // var userId = context["userId"] + // var driveId = params["driveId"] + // var driveFileId = params["driveFileId"] + // if (PluginUtil.PanFS.deleteFile(userId, driveId, driveFileId)) { + // console.println("插件删除云盘文件成功:" + params["filePath"]) + // } + // } + // } } // ------------------------------------------------------------------------------------------ diff --git a/internal/plugins/plugin_util.go b/internal/plugins/plugin_util.go index b8adc6c..f0c8703 100644 --- a/internal/plugins/plugin_util.go +++ b/internal/plugins/plugin_util.go @@ -84,8 +84,8 @@ func DeletePanFile(userId, driveId, panFileId string) bool { return false } else { logger.Verboseln("[Plugin] delete pan file success: ", panFileId) + return true } - return false } // SendTextMail 发送文本邮件