UNPKG

vite-uni-dev-tool

Version:

vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试

127 lines (126 loc) 3.58 kB
function m() { let e = getCurrentPages(), t = e[e.length - 1]; return t && t.route ? t.route : ""; } function d() { var r; if (!plus || !plus.nativeObj || !plus.nativeObj.Bitmap) return; let e = getCurrentPages(), t = e[e.length - 1], n = (r = t.$getAppWebview) == null ? void 0 : r.call(t), i = new plus.nativeObj.Bitmap("drawScreen"); n == null || n.draw( i, () => { i.save( `pictures/${Date.now()}.jpg`, { overwrite: !0 }, (o) => { console.log("res.target" + o.target), uni.showToast({ title: "截图成功:" + o.target, icon: "none", duration: 60 * 1e3 }), i.clear(); }, (o) => { console.log("[DevTool] 截图失败:" + JSON.stringify(o)), uni.showToast({ title: "[DevTool] 截图失败:" + JSON.stringify(o), icon: "none", duration: 60 * 1e3 }), i.clear(); } ); }, (o) => { console.log("[DevTool] 绘制失败:" + JSON.stringify(o)), uni.showToast({ title: "绘制失败:" + JSON.stringify(o), icon: "none", duration: 60 * 1e3 }); }, { check: !0 // 设置为检测白屏 } ); } function y(e) { const t = uni.createCanvasContext("fullscreenCanvas"), { windowWidth: n, windowHeight: i } = uni.getWindowInfo(); t.setFillStyle("#ffffff"), t.fillRect(0, 0, n, i), t.setFillStyle("#000000"), t.setFontSize(20), t.fillText("这是截屏内容", 100, 100), t.draw(!1, () => { uni.canvasToTempFilePath({ canvasId: "fullscreenCanvas", width: n, height: i, destWidth: n * 2, // 提高清晰度 destHeight: i * 2, fileType: "png", success: (r) => { console.log("res: ", r), console.log("全屏截屏成功:", r.tempFilePath); }, fail: (r) => { console.error("全屏截屏失败:", r); } }); }); } function g(e) { return e === null || typeof e != "object" && typeof e != "function"; } function h(e, t, n = { maxDepth: 10 }) { const { maxDepth: i = 10 } = n, r = /* @__PURE__ */ new WeakMap(); let o = 1; return p(e, t, r, () => o++, 1, i); } function p(e, t, n, i, r, o) { if (r > o) return !1; if (g(e) || g(t)) return typeof e == "number" && typeof t == "number" && isNaN(e) && isNaN(t) ? !0 : e === t; if (e instanceof Date && t instanceof Date) return e.getTime() === t.getTime(); if (e instanceof RegExp && t instanceof RegExp) return e.toString() === t.toString(); if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1; const u = n.get(e), l = n.get(t); if (u !== void 0 || l !== void 0) return u === l; const f = i(); n.set(e, f), n.set(t, f); const c = Object.getOwnPropertyNames(e), a = Object.getOwnPropertyNames(t); if (c.length !== a.length) return !1; for (const s of c) if (!a.includes(s) || !p( e == null ? void 0 : e[s], t == null ? void 0 : t[s], n, i, r + 1, o )) return !1; return !0; } function w() { if (!uni.getWindowInfo) { const { uniPlatform: e } = uni.getSystemInfoSync(); return e; } if (uni != null && uni.getAuthCode) return "mp-alipay"; if (uni != null && uni.getMenuButtonBoundingClientRect) return "mp-weixin"; { const { uniPlatform: e } = uni.getSystemInfoSync(); return e; } } export { y as captureScreen, h as deepEqual, m as getCurrentPagePath, w as getPlatform, d as screenshot };