// hiprint相关文件
import { hiprint } from "../../public/js/hiprint/hiprint.bundle.js";
// 调用浏览器打印js
import "../../public/js/hiprint/plugins/jquery.hiwprint.js";

require("../../public/js/hiprint/hiprint.config");
/**
 * 自动连接 / 连接
 * cb: 连接回调， (status, msg) {
 * status: true/false
 * msg: status == true 时 返回socket.connect回调 e
 * }
 */
const autoConnect = function (cb: any) {
  console.log("autoConnect");
  (window as any).autoConnect = true;
  (window as any).hiwebSocket && (window as any).hiwebSocket.hasIo() && (window as any).hiwebSocket.start(cb);
};

/**
 * 取消自动连接 / 断开连接
 */
const disAutoConnect = function () {
  console.log("disAutoConnect");
  (window as any).autoConnect = false;
  (window as any).hiwebSocket && (window as any).hiwebSocket.hasIo() && (window as any).hiwebSocket.stop();
};
(window as any).hiprint = hiprint;
export { autoConnect, disAutoConnect, hiprint };
