UNPKG

web-print-pdf

Version:

A powerful web HTML printing library that converts HTML to PDF and prints. Support multiple formats, batch printing, and WebSocket communication. Perfect for web applications needing print functionality.

82 lines 2.72 kB
export default class Utils { constructor(ins) { /* * 获取websocket连接状态 * Get websocket connection status */ this.getConnectStatus = async () => { return await this.ins._promiseWrapper((commonParams = {}) => { this.ins._ws.send({ ...commonParams, type: "getConnectStatus", }); }); }; /* * 设置客户端title * Set client title */ this.setTitle = async (title) => { return await this.ins._promiseWrapper((commonParams = {}) => { this.ins._ws.send({ ...commonParams, type: "setTitle", title, }); }); }; /* * 设置客户端主题色 * Set client theme color */ this.setThemeColor = async (themeColor) => { return await this.ins._promiseWrapper((commonParams = {}) => { this.ins._ws.send({ ...commonParams, type: "setThemeColor", themeColor, }); }); }; /* * 切换客户端Tabs的显隐 * Switch the visibility of client Tabs */ this.switchTabsVisibility = async (tabsVisibility) => { return await this.ins._promiseWrapper((commonParams = {}) => { this.ins._ws.send({ ...commonParams, type: "switchTabsVisibility", tabsVisibility, }); }); }; /* * 设置“联系我们”页面的html内容 * Set the HTML content for the 'Contact Us' page */ this.setContactUsTabInnerHtml = async (html) => { return await this.ins._promiseWrapper((commonParams = {}) => { this.ins._ws.send({ ...commonParams, type: "setContactUsTabInnerHtml", html, }); }); }; this.ins = ins; } onResponse(callback) { if (Object.prototype.toString.call(callback) !== "[object Function]") { throw new Error("onResponse's callback should be a function"); } this.ins._onResponseCallback = callback; } onError(callback) { if (Object.prototype.toString.call(callback) !== "[object Function]") { throw new Error("onError's callback should be a function"); } this.ins._onErrorCallback = callback; } } //# sourceMappingURL=Utils.js.map