@pit-front-end/utils
Version:
湖南创智艾泰克科技有限公司
40 lines (39 loc) • 1.74 kB
JavaScript
import { useGlobalProperties as f } from "pit-element-plus";
import { getToken as m } from "./auth.js";
import { getAppConfig as p, ENABLE_PAGEOFFICE as l } from "./define.js";
const { MODE: u, VITE_APP_PAGEOFFICE_HOST: s, VITE_APP_PAGEOFFICE_PORT: E } = p(), d = f(), a = u === "development";
var I = /* @__PURE__ */ ((e) => (e.ReadDoc = "readDoc", e.EditDoc = "editDoc", e.WordCompare = "wordCompare", e))(I || {});
const P = (e, n, i) => {
e === "readDoc" && !l && (d == null || d.$openFilePreview(n.fileId));
let o;
console.log(s, "VITE_APP_PAGEOFFICE_HOST"), o = `${a ? `${s}` : `${location.protocol}//${location.hostname}:${E}`}/open?open=${e}&${C(
n
)}&channel=fffff&token=${m()}`;
const c = document.getElementById("wordView");
c && document.body.removeChild(c);
const r = document.createElement("iframe");
r.id = "wordView", r.style.display = "none", r.src = o, console.log(o), document.body.appendChild(r), i && i();
};
function C(e) {
if (!e || typeof e != "object" || Array.isArray(e)) return "";
const n = [], i = (o) => o === void 0 ? "" : o === null ? "null" : o instanceof Date ? encodeURIComponent(o.toISOString()) : encodeURIComponent(typeof o == "object" ? JSON.stringify(o) : String(o));
try {
for (const [o, t] of Object.entries(e)) {
if (t === void 0) {
n.push(`${encodeURIComponent(o)}=`);
continue;
}
t !== null && (Array.isArray(t) ? t.forEach((c) => {
const r = i(c);
n.push(`${encodeURIComponent(o)}=${r}`);
}) : n.push(`${encodeURIComponent(o)}=${i(t)}`));
}
} catch (o) {
return console.error("参数转换异常:", o), "";
}
return n.join("&");
}
export {
I as PageOfficeOperType,
P as openPageOffice
};