fix(editor): Fix the issue that the content of json, html, csv, md, txt, and css files contained garbled Chinese characters when clicking the view button (#16118)

Co-authored-by: luka <zhoupf@seirobotics.net>
This commit is contained in:
luka
2025-06-11 15:36:54 +08:00
committed by GitHub
parent 0cfe6eeb5d
commit cdab4c1bc6
3 changed files with 28 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
import { ref, onMounted, computed } from 'vue';
import { useWorkflowsStore } from '@/stores/workflows.store';
import type { IBinaryData } from 'n8n-workflow';
import { jsonParse } from 'n8n-workflow';
import { jsonParse, base64DecodeUTF8 } from 'n8n-workflow';
import VueJsonPretty from 'vue-json-pretty';
import RunDataHtml from '@/components/RunDataHtml.vue';
import { useI18n } from '@n8n/i18n';
@@ -28,12 +28,13 @@ onMounted(async () => {
const { id, data: binaryData, fileName, fileType, mimeType } = props.binaryData;
const isJSONData = fileType === 'json';
const isHTMLData = fileType === 'html';
if (!id) {
if (isJSONData || isHTMLData) {
data.value = jsonParse(atob(binaryData));
data.value = isJSONData
? jsonParse(base64DecodeUTF8(binaryData))
: base64DecodeUTF8(binaryData);
} else {
embedSource.value = 'data:' + mimeType + ';base64,' + binaryData;
embedSource.value = `data:${mimeType};charset=utf-8;base64,${binaryData}`;
}
} else {
try {