diff --git a/resources-front-end/packages/fate-tools/lib/toRequest/service.ts b/resources-front-end/packages/fate-tools/lib/toRequest/service.ts index aab8dc927..d966ea217 100644 --- a/resources-front-end/packages/fate-tools/lib/toRequest/service.ts +++ b/resources-front-end/packages/fate-tools/lib/toRequest/service.ts @@ -7,6 +7,7 @@ import axios, { import { ElMessage } from 'element-plus'; import { isBoolean, isNull, isObject, isUndefined } from 'lodash'; import toFile from '../toFile'; +import JSYmal from 'js-yaml'; export interface BasicConfigForParameter extends CreateAxiosDefaults { ConsolePrinting?: boolean; @@ -149,7 +150,12 @@ export default function HTTPRequest( const fileReader: FileReader = new FileReader(); fileReader.addEventListener('loadend', function () { - const result = JSON.parse(fileReader.result); + let result + if (filename.match(/json/i)) { + result = JSON.parse(fileReader.result); + } else { + result = JSYmal.load(fileReader.result) + } if (result.code !== undefined) { resolve(bodyExplain(result)); } else { diff --git a/resources-front-end/packages/fate-tools/package.json b/resources-front-end/packages/fate-tools/package.json index c8824ea4e..c4f602e49 100644 --- a/resources-front-end/packages/fate-tools/package.json +++ b/resources-front-end/packages/fate-tools/package.json @@ -17,6 +17,7 @@ }, "dependencies": { "axios": "^1.6.4", + "js-yaml": "^4.1.0", "encryptlong": "^3.1.4", "file-saver": "^2.0.5" }, diff --git a/resources-front-end/packages/fate-tools/shims.d.ts b/resources-front-end/packages/fate-tools/shims.d.ts index f8844c97a..4043b705f 100644 --- a/resources-front-end/packages/fate-tools/shims.d.ts +++ b/resources-front-end/packages/fate-tools/shims.d.ts @@ -1,3 +1,4 @@ declare module 'encryptlong'; declare module 'file-saver'; declare module 'lodash-es'; +declare module 'js-yaml';