@rxflow/base
Version:
BaseFlow - 核心 Flow 组件库
52 lines (49 loc) • 2.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.exportPlugin = void 0;
var yaml = _interopRequireWildcard(require("yaml"));
var _snapdom = require("@zumer/snapdom");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
/**
* @author: yanxianliang
* @date: 2025-08-26 14:29
* @modified:2025/8/26 14:29 by yanxianliang
* @desc: 导出
*
* 支持导出 yaml、PNG、PDF
*
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
*/
/**
* 导出插件,暂时不好处理,先 pending
*/
const exportPlugin = exports.exportPlugin = {
// 导出 yaml配置文件
exportYaml: (data, fileName = 'config') => {
const yamlStr = yaml.stringify(data);
const blob = new Blob([yamlStr], {
type: 'text/yaml'
});
// 生成临时URL并触发下载
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${fileName}.yaml`; // 设置文件名
a.click(); // 模拟点击下载
},
// 导出 png文件
exportPng: async (container, scale = 2) => {
// 虚拟渲染的,导出会有问题
const result = await (0, _snapdom.snapdom)(container, {
scale
});
await result.download({
format: 'png',
type: 'png',
quality: 1
});
}
};