From 4be4db48c5ae23f3166f8a740b0ae5234bec5701 Mon Sep 17 00:00:00 2001 From: xiaoyu Date: Thu, 17 Nov 2022 19:53:09 +0800 Subject: [PATCH] fix: change btoa func to encodeURI --- .../CodeEditor/TernSever/HintTooltip/index.tsx | 2 +- .../src/components/CodeEditor/TernSever/index.tsx | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/builder/src/components/CodeEditor/TernSever/HintTooltip/index.tsx b/apps/builder/src/components/CodeEditor/TernSever/HintTooltip/index.tsx index 4606710869..1d7c6b4c5a 100644 --- a/apps/builder/src/components/CodeEditor/TernSever/HintTooltip/index.tsx +++ b/apps/builder/src/components/CodeEditor/TernSever/HintTooltip/index.tsx @@ -69,7 +69,7 @@ const Evaluate: FC<{ type: string; data?: any }> = (props) => { const handleTernCompletions = (data: TypeQueryResult): TransQuery => { const result: TransQuery = data ?? {} - const doc = atob(data?.doc ?? "") + const doc = decodeURI(data?.doc ?? "") if (doc?.slice(0, 1) === "{") { const format = JSON.parse(doc) result["data"] = format.data diff --git a/apps/builder/src/components/CodeEditor/TernSever/index.tsx b/apps/builder/src/components/CodeEditor/TernSever/index.tsx index 95ddfe969e..28089a1ba0 100644 --- a/apps/builder/src/components/CodeEditor/TernSever/index.tsx +++ b/apps/builder/src/components/CodeEditor/TernSever/index.tsx @@ -75,7 +75,7 @@ const transDataToDefs = ( const def: Record = {} if (current) { path = path ? path + "." + current : current - def["!doc"] = btoa(JSON.stringify({ path, data })) + def["!doc"] = encodeURI(JSON.stringify({ path, data })) } for (const dataKey in data) { let newPath = path ? path + "." + dataKey : dataKey @@ -84,12 +84,16 @@ const transDataToDefs = ( def[dataKey] = { ...d, ...transDataToDefs(d), - "!doc": btoa(JSON.stringify({ path: newPath, data: data[dataKey] })), + "!doc": encodeURI( + JSON.stringify({ path: newPath, data: data[dataKey] }), + ), } } else { def[dataKey] = { "!type": transTernTypeName(data[dataKey]), - "!doc": btoa(JSON.stringify({ path: newPath, data: data[dataKey] })), + "!doc": encodeURI( + JSON.stringify({ path: newPath, data: data[dataKey] }), + ), } } }