From bbe978f0a8904f5af60b51741532dcefcf4e01cf Mon Sep 17 00:00:00 2001 From: jbwfu <75001777+jbwfu@users.noreply.github.com> Date: Tue, 12 Nov 2024 00:49:42 +0800 Subject: [PATCH 1/2] Update plugin-sync-configuration-webdav.js --- plugins/Generic/plugin-sync-configuration-webdav.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/Generic/plugin-sync-configuration-webdav.js b/plugins/Generic/plugin-sync-configuration-webdav.js index 38a1409..4c54dcd 100644 --- a/plugins/Generic/plugin-sync-configuration-webdav.js +++ b/plugins/Generic/plugin-sync-configuration-webdav.js @@ -39,14 +39,19 @@ const Sync = async () => { const files = JSON.parse(content) let failed = false + + const isWindows = navigator.userAgent.indexOf('Windows') !== -1 + const separator = isWindows ? '\\' : '/' const _files = Object.keys(files) for (let i = 0; i < _files.length; i++) { const file = _files[i] const encrypted = files[file].content + const processedFile = file.replaceAll(/\//g, separator) + .replaceAll(/\\/g, separator) update(`正在恢复文件...[ ${i + 1}/${_files.length} ]`, 'info') try { - await Plugins.Writefile(file, decrypt(encrypted)) + await Plugins.Writefile(processedFile, decrypt(encrypted)) } catch (error) { if (error === '解密失败') { failed = true @@ -102,7 +107,7 @@ const Backup = async () => { try { const text = await Plugins.ignoredError(Plugins.Readfile, file) if (text) { - filesMap[file.replaceAll('/', '\\')] = { content: encrypt(text) } + filesMap[file] = { content: encrypt(text) } } } catch (error) { console.log(error) From 5464f4809f1975694fff39f3ac905fc673fc560d Mon Sep 17 00:00:00 2001 From: jbwfu <75001777+jbwfu@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:53:56 +0800 Subject: [PATCH 2/2] Update plugin-sync-configuration-webdav.js use Plugins.useEnvStore() --- plugins/Generic/plugin-sync-configuration-webdav.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Generic/plugin-sync-configuration-webdav.js b/plugins/Generic/plugin-sync-configuration-webdav.js index 4c54dcd..15b72a9 100644 --- a/plugins/Generic/plugin-sync-configuration-webdav.js +++ b/plugins/Generic/plugin-sync-configuration-webdav.js @@ -40,7 +40,7 @@ const Sync = async () => { let failed = false - const isWindows = navigator.userAgent.indexOf('Windows') !== -1 + const isWindows = Plugins.useEnvStore().env.os == 'windows' const separator = isWindows ? '\\' : '/' const _files = Object.keys(files)