From c6030bbec89b80a7573b6f29a2a0baf8e120f07d Mon Sep 17 00:00:00 2001 From: zhaoying Date: Tue, 20 Jan 2026 15:57:44 +0800 Subject: [PATCH] feat(web): add yamlExport function --- web/src/utils/yamlExport.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 web/src/utils/yamlExport.ts diff --git a/web/src/utils/yamlExport.ts b/web/src/utils/yamlExport.ts new file mode 100644 index 00000000..9a8c0c41 --- /dev/null +++ b/web/src/utils/yamlExport.ts @@ -0,0 +1,13 @@ +import yaml from 'js-yaml'; + + +export const exportToYaml = (data: unknown, filename: string = 'export.yaml') => { + const yamlStr = yaml.dump(data); + const blob = new Blob([yamlStr], { type: 'text/yaml' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = filename; + a.click(); + URL.revokeObjectURL(url); +};