Skip to content

Commit

Permalink
update: support download yaml
Browse files Browse the repository at this point in the history
Signed-off-by: Arvin Huang <[email protected]>
  • Loading branch information
idwenwen committed Feb 27, 2024
1 parent 07cccc6 commit 4fb2bae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown> {
ConsolePrinting?: boolean;
Expand Down Expand Up @@ -149,7 +150,12 @@ export default function HTTPRequest<B extends BasicConfigForParameter>(
const fileReader: FileReader = new FileReader();

fileReader.addEventListener('loadend', function () {
const result = JSON.parse(<string>fileReader.result);
let result
if (filename.match(/json/i)) {
result = JSON.parse(<string>fileReader.result);
} else {
result = JSYmal.load(fileReader.result)
}
if (result.code !== undefined) {
resolve(<unknown>bodyExplain(result));
} else {
Expand Down
1 change: 1 addition & 0 deletions resources-front-end/packages/fate-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"dependencies": {
"axios": "^1.6.4",
"js-yaml": "^4.1.0",
"encryptlong": "^3.1.4",
"file-saver": "^2.0.5"
},
Expand Down
1 change: 1 addition & 0 deletions resources-front-end/packages/fate-tools/shims.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
declare module 'encryptlong';
declare module 'file-saver';
declare module 'lodash-es';
declare module 'js-yaml';

0 comments on commit 4fb2bae

Please sign in to comment.