From afd15ef2c515dc335e8b81f2848e8786874e5ee3 Mon Sep 17 00:00:00 2001 From: josc146 Date: Fri, 27 Oct 2023 13:35:29 +0800 Subject: [PATCH] base64 preset support --- frontend/src/pages/PresetsManager/PresetsButton.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/pages/PresetsManager/PresetsButton.tsx b/frontend/src/pages/PresetsManager/PresetsButton.tsx index 5240579..f7e6dd4 100644 --- a/frontend/src/pages/PresetsManager/PresetsButton.tsx +++ b/frontend/src/pages/PresetsManager/PresetsButton.tsx @@ -168,8 +168,14 @@ export const ChatPresetEditor: FC<{ const importPreset = () => { ClipboardGetText().then((text) => { try { + if (!text.trim().startsWith('{')) + text = new TextDecoder().decode( + new Uint8Array(atob(text) + .split('') + .map((c) => c.charCodeAt(0)))); const preset = JSON.parse(text); setEditingPreset(preset); + setEditingMessages(false); toast(t('Imported successfully'), { type: 'success', autoClose: 1000