feat(web): add yamlExport function

This commit is contained in:
zhaoying
2026-01-20 15:57:44 +08:00
parent cb62608dbd
commit c6030bbec8

View File

@@ -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);
};