Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

624 B
Raw Blame
import {Constants} from "../../constants";
import {addScript} from "./addScript";

let pending: Promise<boolean> | undefined;

// 编辑器和设置页共用加载中的脚本,避免重复执行后丢失已有图表实例的注册信息。
export const loadECharts = (cdn = Constants.PROTYLE_CDN): Promise<boolean> => {
    if (window.echarts) {
        return Promise.resolve(true);
    }
    pending ??= addScript(`${cdn}/js/echarts/echarts.min.js?v=6.1.0`, "protyleEchartsScript")
        .then(() => Boolean(window.echarts))
        .finally(() => {
            pending = undefined;
        });
    return pending;
};