import { setJJBCommonAntdMessage } from "@cqsjjb/jjb-common-lib";
import { setup } from "@cqsjjb/jjb-dva-runtime";
import { ConfigProvider, message } from "antd";
import dayjs from "dayjs";
import { getFileUrlFromServer } from "zy-react-library/utils";
import "dayjs/locale/zh-cn";
import "../blessed_by_buddha";

require("antd/dist/reset.css");
require("zy-react-library/css/common.less");

const ANT_PREFIX = process.env.app.antd?.["ant-prefix"] || "ant";

ConfigProvider.config({
  prefixCls: ANT_PREFIX,
});

dayjs.locale("zh-cn");
setJJBCommonAntdMessage(message);
window.mapLongitude = "119.69457721306945";
window.mapLatitude = "39.940504336846665";
window.mapBaiDuKey = "OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr";

const app = setup();
getFileUrlFromServer();
// 非底座环境运行
if (!window.__POWERED_BY_QIANKUN__) {
  // 云组件默认依赖
  window.__coreLib = {};
  window.__coreLib.React = require("react");
  window.__coreLib.ReactDOM = require("react-dom");
  window.__coreLib.jjbCommonLib = require("@cqsjjb/jjb-common-lib");
}

/**
 * @description 挂载
 * @param props {{ setGlobalState: ({ rendered: boolean }) => void }}
 * @returns {Promise<*>} ''
 */
export const mount = async (props) => {
  // 云组件默认依赖
  window.__coreLib.React = require("react");
  window.__coreLib.ReactDOM = require("react-dom");
  window.__coreLib.jjbCommonLib = require("@cqsjjb/jjb-common-lib");
  app.mount(props);
};

/**
 * @description 卸载
 * @param props {object}
 * @returns {Promise<*>} ''
 */
export const unmount = async props => app.unmount(props);
/**
 * @description 启动
 * @param props
 */
export const bootstrap = async props => app.bootstrap(props);
