mirror of
https://gitee.com/270580156/weiyu.git
synced 2025-12-30 10:52:26 +00:00
update
This commit is contained in:
@@ -1,31 +1,32 @@
|
||||
var N = Object.create;
|
||||
var P = Object.create;
|
||||
var h = Object.defineProperty;
|
||||
var P = Object.getOwnPropertyDescriptor;
|
||||
var E = (e, t) => (t = Symbol[e]) ? t : Symbol.for("Symbol." + e), p = (e) => {
|
||||
var Q = Object.getOwnPropertyDescriptor;
|
||||
var E = (e, t) => (t = Symbol[e]) ? t : Symbol.for("Symbol." + e), b = (e) => {
|
||||
throw TypeError(e);
|
||||
};
|
||||
var F = (e, t, n) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
||||
var j = (e, t) => h(e, "name", { value: t, configurable: !0 });
|
||||
var G = (e) => [, , , N((e == null ? void 0 : e[E("metadata")]) ?? null)], H = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], m = (e) => e !== void 0 && typeof e != "function" ? p("Function expected") : e, Q = (e, t, n, r, s) => ({ kind: H[e], name: t, metadata: r, addInitializer: (l) => n._ ? p("Already initialized") : s.push(m(l || null)) }), O = (e, t) => F(t, E("metadata"), e[3]), v = (e, t, n, r) => {
|
||||
for (var s = 0, l = e[t >> 1], g = l && l.length; s < g; s++) t & 1 ? l[s].call(n) : r = l[s].call(n, r);
|
||||
var G = (e) => [, , , P((e == null ? void 0 : e[E("metadata")]) ?? null)], H = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], p = (e) => e !== void 0 && typeof e != "function" ? b("Function expected") : e, R = (e, t, n, r, s) => ({ kind: H[e], name: t, metadata: r, addInitializer: (l) => n._ ? b("Already initialized") : s.push(p(l || null)) }), O = (e, t) => F(t, E("metadata"), e[3]), v = (e, t, n, r) => {
|
||||
for (var s = 0, l = e[t >> 1], u = l && l.length; s < u; s++) t & 1 ? l[s].call(n) : r = l[s].call(n, r);
|
||||
return r;
|
||||
}, J = (e, t, n, r, s, l) => {
|
||||
var g, d, D, k, b, o = t & 7, B = !!(t & 8), a = !!(t & 16), A = o > 3 ? e.length + 1 : o ? B ? 1 : 2 : 0, T = H[o + 5], W = o > 3 && (e[A - 1] = []), M = e[A] || (e[A] = []), y = o && (!a && !B && (s = s.prototype), o < 5 && (o > 3 || !a) && P(o < 4 ? s : { get [n]() {
|
||||
var u, d, D, k, w, o = t & 7, B = !!(t & 8), y = !!(t & 16), A = o > 3 ? e.length + 1 : o ? B ? 1 : 2 : 0, T = H[o + 5], W = o > 3 && (e[A - 1] = []), N = e[A] || (e[A] = []), g = o && (!y && !B && (s = s.prototype), o < 5 && (o > 3 || !y) && Q(o < 4 ? s : { get [n]() {
|
||||
return q(this, l);
|
||||
}, set [n](i) {
|
||||
return z(this, l, i);
|
||||
} }, n));
|
||||
o ? a && o < 4 && j(l, (o > 2 ? "set " : o > 1 ? "get " : "") + n) : j(s, n);
|
||||
o ? y && o < 4 && j(l, (o > 2 ? "set " : o > 1 ? "get " : "") + n) : j(s, n);
|
||||
for (var C = r.length - 1; C >= 0; C--)
|
||||
k = Q(o, n, D = {}, e[3], M), o && (k.static = B, k.private = a, b = k.access = { has: a ? (i) => R(s, i) : (i) => n in i }, o ^ 3 && (b.get = a ? (i) => (o ^ 1 ? q : S)(i, s, o ^ 4 ? l : y.get) : (i) => i[n]), o > 2 && (b.set = a ? (i, I) => z(i, s, I, o ^ 4 ? l : y.set) : (i, I) => i[n] = I)), d = (0, r[C])(o ? o < 4 ? a ? l : y[T] : o > 4 ? void 0 : { get: y.get, set: y.set } : s, k), D._ = 1, o ^ 4 || d === void 0 ? m(d) && (o > 4 ? W.unshift(d) : o ? a ? l = d : y[T] = d : s = d) : typeof d != "object" || d === null ? p("Object expected") : (m(g = d.get) && (y.get = g), m(g = d.set) && (y.set = g), m(g = d.init) && W.unshift(g));
|
||||
return o || O(e, s), y && h(s, n, y), a ? o ^ 4 ? l : y : s;
|
||||
}, K = (e, t, n) => F(e, typeof t != "symbol" ? t + "" : t, n), x = (e, t, n) => t.has(e) || p("Cannot " + n), R = (e, t) => Object(t) !== t ? p('Cannot use the "in" operator on this value') : e.has(t), q = (e, t, n) => (x(e, t, "read from private field"), n ? n.call(e) : t.get(e));
|
||||
var z = (e, t, n, r) => (x(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n), S = (e, t, n) => (x(e, t, "access private method"), n);
|
||||
import { Component as U, Input as V } from "@angular/core";
|
||||
import X from "../core/BytedeskWeb/index.js";
|
||||
let u = null, c = 0;
|
||||
var L, f, w;
|
||||
const $ = U({
|
||||
k = R(o, n, D = {}, e[3], N), o && (k.static = B, k.private = y, w = k.access = { has: y ? (i) => S(s, i) : (i) => n in i }, o ^ 3 && (w.get = y ? (i) => (o ^ 1 ? q : U)(i, s, o ^ 4 ? l : g.get) : (i) => i[n]), o > 2 && (w.set = y ? (i, I) => z(i, s, I, o ^ 4 ? l : g.set) : (i, I) => i[n] = I)), d = (0, r[C])(o ? o < 4 ? y ? l : g[T] : o > 4 ? void 0 : { get: g.get, set: g.set } : s, k), D._ = 1, o ^ 4 || d === void 0 ? p(d) && (o > 4 ? W.unshift(d) : o ? y ? l = d : g[T] = d : s = d) : typeof d != "object" || d === null ? b("Object expected") : (p(u = d.get) && (g.get = u), p(u = d.set) && (g.set = u), p(u = d.init) && W.unshift(u));
|
||||
return o || O(e, s), g && h(s, n, g), y ? o ^ 4 ? l : g : s;
|
||||
}, K = (e, t, n) => F(e, typeof t != "symbol" ? t + "" : t, n), x = (e, t, n) => t.has(e) || b("Cannot " + n), S = (e, t) => Object(t) !== t ? b('Cannot use the "in" operator on this value') : e.has(t), q = (e, t, n) => (x(e, t, "read from private field"), n ? n.call(e) : t.get(e));
|
||||
var z = (e, t, n, r) => (x(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n), U = (e, t, n) => (x(e, t, "access private method"), n);
|
||||
import { Component as V, Input as X } from "@angular/core";
|
||||
import Y from "../core/BytedeskWeb/index.js";
|
||||
import L from "../utils/logger/index.js";
|
||||
let a = null, m = 0;
|
||||
var M, f, c;
|
||||
const te = V({
|
||||
selector: "bytedesk-angular",
|
||||
template: "",
|
||||
styles: [`
|
||||
@@ -33,23 +34,23 @@ const $ = U({
|
||||
display: none;
|
||||
}
|
||||
`]
|
||||
})((L = [V()], w = class {
|
||||
})((M = [X()], c = class {
|
||||
constructor() {
|
||||
K(this, "config", v(f, 8, this)), v(f, 11, this);
|
||||
}
|
||||
ngOnInit() {
|
||||
if (c++, u) {
|
||||
window.bytedesk = u;
|
||||
if (m++, a) {
|
||||
window.bytedesk = a;
|
||||
return;
|
||||
}
|
||||
u = new X(this.config), u.init(), window.bytedesk = u;
|
||||
a = new Y(this.config), a.init(), window.bytedesk = a;
|
||||
}
|
||||
ngOnDestroy() {
|
||||
c--, console.log("BytedeskAngular: 组件卸载,当前活跃组件数:", c), c <= 0 && (console.log("BytedeskAngular: 没有活跃组件,清理全局实例"), setTimeout(() => {
|
||||
u && c <= 0 && (u.destroy(), u = null, delete window.bytedesk, c = 0);
|
||||
m--, L.debug("BytedeskAngular: 组件卸载,当前活跃组件数:", m), m <= 0 && (L.debug("BytedeskAngular: 没有活跃组件,清理全局实例"), setTimeout(() => {
|
||||
a && m <= 0 && (a.destroy(), a = null, delete window.bytedesk, m = 0);
|
||||
}, 100));
|
||||
}
|
||||
}, f = G(null), J(f, 5, "config", L, w), O(f, w), w));
|
||||
}, f = G(null), J(f, 5, "config", M, c), O(f, c), c));
|
||||
export {
|
||||
$ as BytedeskAngular
|
||||
te as BytedeskAngular
|
||||
};
|
||||
|
||||
@@ -1,54 +1,55 @@
|
||||
import "../../node_modules/.pnpm/axios@1.10.0/node_modules/axios/index/index.js";
|
||||
import { ACCESS_TOKEN as u, ANONYMOUS as n, EVENT_BUS_HTTP_ERROR as s, EVENT_BUS_SERVER_ERROR_500 as l } from "../../utils/constants/index.js";
|
||||
import { ACCESS_TOKEN as c, ANONYMOUS as a, EVENT_BUS_HTTP_ERROR as s, EVENT_BUS_SERVER_ERROR_500 as m } from "../../utils/constants/index.js";
|
||||
import t from "../../utils/eventsEmitter/index.js";
|
||||
import p from "../../node_modules/.pnpm/axios@1.10.0/node_modules/axios/lib/axios/index.js";
|
||||
import r from "../../utils/logger/index.js";
|
||||
import l from "../../node_modules/.pnpm/axios@1.10.0/node_modules/axios/lib/axios/index.js";
|
||||
let o = "";
|
||||
function a() {
|
||||
function u() {
|
||||
return o || "https://api.weiyuai.cn";
|
||||
}
|
||||
function R(e) {
|
||||
return e && e.trim() !== "" ? (o = e, console.log("API URL已设置为:", o)) : console.warn("尝试设置无效的API URL"), o;
|
||||
function d(e) {
|
||||
return e && e.trim() !== "" ? (o = e, r.info("API URL已设置为:", o)) : r.warn("尝试设置无效的API URL"), o;
|
||||
}
|
||||
const c = p.create({
|
||||
const p = l.create({
|
||||
timeout: 2e4,
|
||||
// 初始化时设置一个默认值,后续会通过request拦截器动态获取
|
||||
baseURL: a()
|
||||
baseURL: u()
|
||||
});
|
||||
c.interceptors.request.use(
|
||||
p.interceptors.request.use(
|
||||
(e) => {
|
||||
e.baseURL = a();
|
||||
const r = localStorage.getItem(u);
|
||||
return r && r.length > 10 && e.url && e.url.startsWith("/api") && (e.headers.Authorization = `Bearer ${r}`), !r && e.url && e.url.startsWith("/api") ? Promise.reject(m) : e;
|
||||
e.baseURL = u();
|
||||
const i = localStorage.getItem(c);
|
||||
return i && i.length > 10 && e.url && e.url.startsWith("/api") && (e.headers.Authorization = `Bearer ${i}`), !i && e.url && e.url.startsWith("/api") ? Promise.reject(h) : e;
|
||||
},
|
||||
(e) => (console.log("request error", e), e.response.status === 403 && t.emit(s, "403"), e.response.status === 401 && t.emit(s, "401"), Promise.reject(e))
|
||||
(e) => (r.error("request error", e), e.response.status === 403 && t.emit(s, "403"), e.response.status === 401 && t.emit(s, "401"), Promise.reject(e))
|
||||
);
|
||||
c.interceptors.response.use(
|
||||
p.interceptors.response.use(
|
||||
(e) => e,
|
||||
(e) => {
|
||||
if (console.log("response error", e), e.response)
|
||||
if (r.error("response error", e), e.response)
|
||||
switch (e.response.status) {
|
||||
case 400:
|
||||
console.log("axios interception error 400"), t.emit(s, "400");
|
||||
r.error("axios interception error 400"), t.emit(s, "400");
|
||||
break;
|
||||
case 401:
|
||||
console.log("axios interception error 401"), t.emit(s, "401");
|
||||
r.error("axios interception error 401"), t.emit(s, "401");
|
||||
break;
|
||||
case 403:
|
||||
console.log("axios interception error 403"), t.emit(s, "403");
|
||||
r.error("axios interception error 403"), t.emit(s, "403");
|
||||
break;
|
||||
case 500:
|
||||
console.log("axios interception error 500"), t.emit(l, "500");
|
||||
r.error("axios interception error 500"), t.emit(m, "500");
|
||||
break;
|
||||
}
|
||||
return "return axios interception error";
|
||||
}
|
||||
);
|
||||
const i = {
|
||||
const n = {
|
||||
data: null,
|
||||
// 通常错误时不会有数据
|
||||
status: 601,
|
||||
// 自定义HTTP状态码,用于表示匿名状态
|
||||
statusText: n,
|
||||
statusText: a,
|
||||
// HTTP 状态文本
|
||||
headers: {},
|
||||
// 响应头
|
||||
@@ -58,18 +59,18 @@ const i = {
|
||||
// 请求配置
|
||||
request: null
|
||||
// 原始请求对象
|
||||
}, m = {
|
||||
}, h = {
|
||||
message: "匿名用户,无需访问服务器接口",
|
||||
// 错误消息
|
||||
name: n,
|
||||
name: a,
|
||||
// 错误名称
|
||||
code: "601",
|
||||
// 自定义的错误代码
|
||||
config: i.config,
|
||||
config: n.config,
|
||||
// 请求配置
|
||||
request: i.request,
|
||||
request: n.request,
|
||||
// 原始请求对象
|
||||
response: i,
|
||||
response: n,
|
||||
// 响应对象
|
||||
isAxiosError: !0,
|
||||
// 标记这是一个 AxiosError 对象
|
||||
@@ -85,7 +86,7 @@ const i = {
|
||||
}
|
||||
};
|
||||
export {
|
||||
c as default,
|
||||
a as getApiUrl,
|
||||
R as setApiUrl
|
||||
p as default,
|
||||
u as getApiUrl,
|
||||
d as setApiUrl
|
||||
};
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { getApiUrl as b } from "../request/index.js";
|
||||
async function n(a, l, d, e) {
|
||||
import { getApiUrl as U } from "../request/index.js";
|
||||
import l from "../../utils/logger/index.js";
|
||||
async function h(a, d, m, e) {
|
||||
try {
|
||||
const r = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T.]/g, "").slice(0, 14), s = l || `${r}_${a.name}`, m = d || a.type || "image/jpeg", t = new FormData();
|
||||
t.append("file", a), t.append("fileName", s), t.append("fileType", m), t.append("isAvatar", (e == null ? void 0 : e.isAvatar) || "false"), t.append("kbType", (e == null ? void 0 : e.kbType) || "feedback");
|
||||
const i = (e == null ? void 0 : e.visitorUid) || localStorage.getItem("bytedesk_uid") || localStorage.getItem("bytedesk_visitor_uid") || "", u = (e == null ? void 0 : e.visitorNickname) || localStorage.getItem("bytedesk_nickname") || "", v = (e == null ? void 0 : e.visitorAvatar) || localStorage.getItem("bytedesk_avatar") || "", k = (e == null ? void 0 : e.orgUid) || "";
|
||||
t.append("visitorUid", i), t.append("visitorNickname", u), t.append("visitorAvatar", v), t.append("orgUid", k), t.append("client", (e == null ? void 0 : e.client) || "web"), e != null && e.isDebug && console.log("handleUpload formData", t);
|
||||
const y = `${b()}/visitor/api/upload/file`, p = await fetch(y, {
|
||||
const r = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T.]/g, "").slice(0, 14), s = d || `${r}_${a.name}`, i = m || a.type || "image/jpeg", t = new FormData();
|
||||
t.append("file", a), t.append("fileName", s), t.append("fileType", i), t.append("isAvatar", (e == null ? void 0 : e.isAvatar) || "false"), t.append("kbType", (e == null ? void 0 : e.kbType) || "feedback");
|
||||
const u = (e == null ? void 0 : e.visitorUid) || localStorage.getItem("bytedesk_uid") || localStorage.getItem("bytedesk_visitor_uid") || "", b = (e == null ? void 0 : e.visitorNickname) || localStorage.getItem("bytedesk_nickname") || "", v = (e == null ? void 0 : e.visitorAvatar) || localStorage.getItem("bytedesk_avatar") || "", k = (e == null ? void 0 : e.orgUid) || "";
|
||||
t.append("visitorUid", u), t.append("visitorNickname", b), t.append("visitorAvatar", v), t.append("orgUid", k), t.append("client", (e == null ? void 0 : e.client) || "web"), e != null && e.isDebug && l.debug("handleUpload formData", t);
|
||||
const y = `${U()}/visitor/api/upload/file`, p = await fetch(y, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
// Authorization: "Bearer ", // + localStorage.getItem(ACCESS_TOKEN),
|
||||
@@ -15,20 +16,20 @@ async function n(a, l, d, e) {
|
||||
if (!p.ok)
|
||||
throw new Error(`上传失败: ${p.status} ${p.statusText}`);
|
||||
const o = await p.json();
|
||||
return e != null && e.isDebug && console.log("upload data:", o), o;
|
||||
return e != null && e.isDebug && l.debug("upload data:", o), o;
|
||||
} catch (r) {
|
||||
throw console.error("文件上传失败:", r), r;
|
||||
throw l.error("文件上传失败:", r), r;
|
||||
}
|
||||
}
|
||||
async function w(a, l) {
|
||||
async function T(a, d) {
|
||||
var s;
|
||||
const e = `screenshot_${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:T.]/g, "").slice(0, 14)}.jpg`;
|
||||
return ((s = (await n(a, e, "image/jpeg", {
|
||||
...l,
|
||||
return ((s = (await h(a, e, "image/jpeg", {
|
||||
...d,
|
||||
kbType: "feedback"
|
||||
})).data) == null ? void 0 : s.fileUrl) || "";
|
||||
}
|
||||
export {
|
||||
n as handleUpload,
|
||||
w as uploadScreenshot
|
||||
h as handleUpload,
|
||||
T as uploadScreenshot
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,35 +1,36 @@
|
||||
import { jsx as l } from "react/jsx-runtime";
|
||||
import { useRef as d, useEffect as m } from "react";
|
||||
import u from "../node_modules/.pnpm/next@14.2.28_@babel_core@7.26.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dynamic/index.js";
|
||||
import { IntlProvider as f } from "react-intl";
|
||||
import { messages as c } from "../locales/index/index.js";
|
||||
import { jsx as d } from "react/jsx-runtime";
|
||||
import { useRef as u, useEffect as l } from "react";
|
||||
import f from "../node_modules/.pnpm/next@14.2.28_@babel_core@7.26.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dynamic/index.js";
|
||||
import { IntlProvider as c } from "react-intl";
|
||||
import { messages as y } from "../locales/index/index.js";
|
||||
import s from "../utils/logger/index.js";
|
||||
let t = null, n = 0;
|
||||
const x = u(() => Promise.resolve(({ locale: e = "zh-cn", ...o }) => /* @__PURE__ */ l(
|
||||
f,
|
||||
const h = f(() => Promise.resolve(({ locale: e = "zh-cn", ...r }) => /* @__PURE__ */ d(
|
||||
c,
|
||||
{
|
||||
messages: c[e],
|
||||
messages: y[e],
|
||||
locale: e,
|
||||
defaultLocale: "zh-cn",
|
||||
children: /* @__PURE__ */ l(y, { ...o, locale: e })
|
||||
children: /* @__PURE__ */ d(k, { ...r, locale: e })
|
||||
}
|
||||
)), {
|
||||
ssr: !1
|
||||
// 禁用服务端渲染
|
||||
}), y = (e) => {
|
||||
const o = d(null);
|
||||
return m(() => (n++, import("../index/index.js").then(({ default: r }) => {
|
||||
var s, i;
|
||||
}), k = (e) => {
|
||||
const r = u(null);
|
||||
return l(() => (n++, import("../index/index.js").then(({ default: m }) => {
|
||||
var i, o;
|
||||
if (t) {
|
||||
o.current = t, window.bytedesk = t, (s = e.onInit) == null || s.call(e);
|
||||
r.current = t, window.bytedesk = t, (i = e.onInit) == null || i.call(e);
|
||||
return;
|
||||
}
|
||||
t = new r(e), o.current = t, t.init(), (i = e.onInit) == null || i.call(e), window.bytedesk = t;
|
||||
t = new m(e), r.current = t, t.init(), (o = e.onInit) == null || o.call(e), window.bytedesk = t;
|
||||
}), () => {
|
||||
n--, console.log("BytedeskNextjs: 组件卸载,当前活跃组件数:", n), o.current = null, n <= 0 && (console.log("BytedeskNextjs: 没有活跃组件,清理全局实例"), setTimeout(() => {
|
||||
n--, s.debug("BytedeskNextjs: 组件卸载,当前活跃组件数:", n), r.current = null, n <= 0 && (s.debug("BytedeskNextjs: 没有活跃组件,清理全局实例"), setTimeout(() => {
|
||||
t && n <= 0 && (t.destroy(), t = null, delete window.bytedesk, n = 0);
|
||||
}, 100));
|
||||
}), [e]), null;
|
||||
};
|
||||
export {
|
||||
x as BytedeskNextjs
|
||||
h as BytedeskNextjs
|
||||
};
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
import { onMount as i, onDestroy as s } from "svelte";
|
||||
import { addMessages as a, init as c, getLocaleFromNavigator as n } from "svelte-i18n";
|
||||
import m from "../core/BytedeskWeb/index.js";
|
||||
import { onMount as i, onDestroy as a } from "svelte";
|
||||
import { addMessages as s, init as m, getLocaleFromNavigator as l } from "svelte-i18n";
|
||||
import c from "../core/BytedeskWeb/index.js";
|
||||
import { messages as f } from "../locales/index/index.js";
|
||||
Object.entries(f).forEach(([l, o]) => {
|
||||
a(l, o);
|
||||
import u from "../utils/logger/index.js";
|
||||
Object.entries(f).forEach(([r, o]) => {
|
||||
s(r, o);
|
||||
});
|
||||
c({
|
||||
m({
|
||||
fallbackLocale: "en",
|
||||
initialLocale: n()
|
||||
initialLocale: l()
|
||||
});
|
||||
let e = null, t = 0;
|
||||
const y = (l, o) => (console.log("config", o, l), i(() => {
|
||||
const k = (r, o) => (u.debug("config", o, r), i(() => {
|
||||
t++;
|
||||
const r = {
|
||||
const n = {
|
||||
...o,
|
||||
locale: o.locale || n() || "zh-cn"
|
||||
locale: o.locale || l() || "zh-cn"
|
||||
};
|
||||
e || (e = new m(r), e.init());
|
||||
}), s(() => {
|
||||
e || (e = new c(n), e.init());
|
||||
}), a(() => {
|
||||
t--, t <= 0 && setTimeout(() => {
|
||||
e && t <= 0 && (e.destroy(), e = null, t = 0);
|
||||
}, 100);
|
||||
@@ -26,5 +27,5 @@ const y = (l, o) => (console.log("config", o, l), i(() => {
|
||||
}
|
||||
});
|
||||
export {
|
||||
y as BytedeskSvelte
|
||||
k as BytedeskSvelte
|
||||
};
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
const E = "ANONYMOUS", _ = "EVENT_BUS_SERVER_ERROR_500", S = "EVENT_BUS_HTTP_ERROR", I = "ACCESS_TOKEN", T = "WEB_FLOAT", O = "CLOSE_CHAT_WINDOW", R = "MAXIMIZE_WINDOW", A = "MINIMIZE_WINDOW", N = "RECEIVE_MESSAGE", M = "INVITE_VISITOR", V = "INVITE_VISITOR_ACCEPT", C = "INVITE_VISITOR_REJECT", D = "LOCALSTORAGE_RESPONSE", o = "BYTEDESK_UID", t = "BYTEDESK_VISITOR_UID", P = "BYTEDESK_BROWSE_FAILED_TIMESTAMP";
|
||||
const E = "ANONYMOUS", _ = "EVENT_BUS_SERVER_ERROR_500", S = "EVENT_BUS_HTTP_ERROR", I = "ACCESS_TOKEN", T = "WEB_FLOAT", O = "CLOSE_CHAT_WINDOW", R = "MAXIMIZE_WINDOW", A = "MINIMIZE_WINDOW", N = "RECEIVE_MESSAGE", M = "INVITE_VISITOR", V = "INVITE_VISITOR_ACCEPT", C = "INVITE_VISITOR_REJECT", D = "LOCALSTORAGE_RESPONSE", o = "BYTEDESK_UID", t = "BYTEDESK_VISITOR_UID", c = "BYTEDESK_BROWSE_FAILED_TIMESTAMP", n = "BYTEDESK_LOG_ENABLE";
|
||||
export {
|
||||
I as ACCESS_TOKEN,
|
||||
E as ANONYMOUS,
|
||||
P as BYTEDESK_BROWSE_FAILED_TIMESTAMP,
|
||||
c as BYTEDESK_BROWSE_FAILED_TIMESTAMP,
|
||||
o as BYTEDESK_UID,
|
||||
t as BYTEDESK_VISITOR_UID,
|
||||
S as EVENT_BUS_HTTP_ERROR,
|
||||
_ as EVENT_BUS_SERVER_ERROR_500,
|
||||
T as HTTP_CLIENT,
|
||||
n as LOG_ENABLE,
|
||||
O as POST_MESSAGE_CLOSE_CHAT_WINDOW,
|
||||
M as POST_MESSAGE_INVITE_VISITOR,
|
||||
V as POST_MESSAGE_INVITE_VISITOR_ACCEPT,
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import { LOG_ENABLE as f } from "../constants/index.js";
|
||||
let s = null;
|
||||
const L = (t) => {
|
||||
s = t;
|
||||
}, n = () => {
|
||||
const t = localStorage.getItem(f);
|
||||
return t === null ? (s == null ? void 0 : s.isDebug) ?? !1 : t === "true";
|
||||
}, a = () => {
|
||||
const t = (s == null ? void 0 : s.isDebug) ?? !1;
|
||||
return t && process.env.NODE_ENV === "production" ? 1 : t ? 0 : 1;
|
||||
}, c = a(), l = /* @__PURE__ */ new Map(), d = 1e3, p = (t) => {
|
||||
const e = Date.now(), o = l.get(t);
|
||||
return !o || e - o > d ? (l.set(t, e), !0) : !1;
|
||||
}, r = () => {
|
||||
const t = /* @__PURE__ */ new Date(), e = t.getFullYear(), o = String(t.getMonth() + 1).padStart(2, "0"), i = String(t.getDate()).padStart(2, "0"), u = String(t.getHours()).padStart(2, "0"), g = String(t.getMinutes()).padStart(2, "0"), $ = String(t.getSeconds()).padStart(2, "0");
|
||||
return `${e}-${o}-${i} ${u}:${g}:${$}`;
|
||||
}, E = {
|
||||
debug: (t, ...e) => {
|
||||
if (n() && c <= 0) {
|
||||
if (!p(t))
|
||||
return;
|
||||
const o = r();
|
||||
e.length ? console.debug(`${o} [DEBUG]: ${t}`, ...e) : console.debug(`${o} [DEBUG]: ${t}`);
|
||||
}
|
||||
},
|
||||
info: (t, ...e) => {
|
||||
if (n() && c <= 1) {
|
||||
const o = r();
|
||||
e.length ? console.info(`${o} [INFO]: ${t}`, ...e) : console.info(`${o} [INFO]: ${t}`);
|
||||
}
|
||||
},
|
||||
warn: (t, ...e) => {
|
||||
if (n() && c <= 2) {
|
||||
const o = r();
|
||||
e.length ? console.warn(`${o} [WARN]: ${t}`, ...e) : console.warn(`${o} [WARN]: ${t}`);
|
||||
}
|
||||
},
|
||||
error: (t, ...e) => {
|
||||
const o = r();
|
||||
e.length ? console.error(`${o} [ERROR]: ${t}`, ...e) : console.error(`${o} [ERROR]: ${t}`);
|
||||
},
|
||||
// 输出日志的快捷方法
|
||||
debugIf: (t, ...e) => {
|
||||
n() && E.debug(t, ...e);
|
||||
},
|
||||
// 新增的日志方法
|
||||
log: (t, ...e) => {
|
||||
if (n()) {
|
||||
const o = r();
|
||||
e.length ? console.log(`${o} [LOG]: ${t}`, ...e) : console.log(`${o} [LOG]: ${t}`);
|
||||
}
|
||||
},
|
||||
// 分组日志
|
||||
group: (t) => {
|
||||
n() && console.group(`[ByteDesk] ${t}`);
|
||||
},
|
||||
groupEnd: () => {
|
||||
n() && console.groupEnd();
|
||||
},
|
||||
// 表格日志
|
||||
table: (t) => {
|
||||
n() && console.table(t);
|
||||
},
|
||||
// 时间日志
|
||||
time: (t) => {
|
||||
n() && console.time(`[ByteDesk] ${t}`);
|
||||
},
|
||||
timeEnd: (t) => {
|
||||
n() && console.timeEnd(`[ByteDesk] ${t}`);
|
||||
}
|
||||
};
|
||||
export {
|
||||
E as default,
|
||||
L as setGlobalConfig
|
||||
};
|
||||
@@ -1 +1 @@
|
||||
import e from"./request-B-nt-2Xo.js";import"./index-DQCLjMjN.js";function o(t){return e({url:"/visitor/api/feedback/submit",method:"post",data:t})}export{o as submitFeedback};
|
||||
import e from"./request-BKznmH0u.js";import"./index-DgW5OQds.js";function o(t){return e({url:"/visitor/api/feedback/submit",method:"post",data:t})}export{o as submitFeedback};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
import{H as n}from"./index-DQCLjMjN.js";import a from"./request-B-nt-2Xo.js";async function t(e){if(!(e==null||e===""))return a("/visitor/api/v1/ping",{method:"GET",params:{uid:e,client:n}})}async function i(e){return a("/visitor/api/v1/message/unread",{method:"GET",params:{...e,client:n}})}async function o(e){return a("/visitor/api/v1/message/unread/count",{method:"GET",params:{...e,client:n}})}async function c(e){return a("/visitor/api/v1/message/unread/clear",{method:"POST",data:{...e,client:n}})}export{c as clearUnreadMessages,o as getUnreadMessageCount,i as getUnreadMessages,t as sendPingMessage};
|
||||
import{H as n}from"./index-DgW5OQds.js";import a from"./request-BKznmH0u.js";async function t(e){if(!(e==null||e===""))return a("/visitor/api/v1/ping",{method:"GET",params:{uid:e,client:n}})}async function i(e){return a("/visitor/api/v1/message/unread",{method:"GET",params:{...e,client:n}})}async function o(e){return a("/visitor/api/v1/message/unread/count",{method:"GET",params:{...e,client:n}})}async function c(e){return a("/visitor/api/v1/message/unread/clear",{method:"POST",data:{...e,client:n}})}export{c as clearUnreadMessages,o as getUnreadMessageCount,i as getUnreadMessages,t as sendPingMessage};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
import{getApiUrl as b}from"./request-B-nt-2Xo.js";import"./index-DQCLjMjN.js";async function n(a,l,d,e){try{const r=new Date().toISOString().replace(/[-:T.]/g,"").slice(0,14),s=l||`${r}_${a.name}`,m=d||a.type||"image/jpeg",t=new FormData;t.append("file",a),t.append("fileName",s),t.append("fileType",m),t.append("isAvatar",(e==null?void 0:e.isAvatar)||"false"),t.append("kbType",(e==null?void 0:e.kbType)||"feedback");const i=(e==null?void 0:e.visitorUid)||localStorage.getItem("bytedesk_uid")||localStorage.getItem("bytedesk_visitor_uid")||"",u=(e==null?void 0:e.visitorNickname)||localStorage.getItem("bytedesk_nickname")||"",v=(e==null?void 0:e.visitorAvatar)||localStorage.getItem("bytedesk_avatar")||"",k=(e==null?void 0:e.orgUid)||"";t.append("visitorUid",i),t.append("visitorNickname",u),t.append("visitorAvatar",v),t.append("orgUid",k),t.append("client",(e==null?void 0:e.client)||"web"),e!=null&&e.isDebug&&console.log("handleUpload formData",t);const y=`${b()}/visitor/api/upload/file`,p=await fetch(y,{method:"POST",headers:{},body:t});if(!p.ok)throw new Error(`上传失败: ${p.status} ${p.statusText}`);const o=await p.json();return e!=null&&e.isDebug&&console.log("upload data:",o),o}catch(r){throw console.error("文件上传失败:",r),r}}async function S(a,l){var s;const e=`screenshot_${new Date().toISOString().replace(/[-:T.]/g,"").slice(0,14)}.jpg`;return((s=(await n(a,e,"image/jpeg",{...l,kbType:"feedback"})).data)==null?void 0:s.fileUrl)||""}export{n as handleUpload,S as uploadScreenshot};
|
||||
@@ -0,0 +1 @@
|
||||
import{getApiUrl as U}from"./request-BKznmH0u.js";import{l}from"./index-DgW5OQds.js";async function h(a,d,m,e){try{const r=new Date().toISOString().replace(/[-:T.]/g,"").slice(0,14),s=d||`${r}_${a.name}`,i=m||a.type||"image/jpeg",t=new FormData;t.append("file",a),t.append("fileName",s),t.append("fileType",i),t.append("isAvatar",(e==null?void 0:e.isAvatar)||"false"),t.append("kbType",(e==null?void 0:e.kbType)||"feedback");const u=(e==null?void 0:e.visitorUid)||localStorage.getItem("bytedesk_uid")||localStorage.getItem("bytedesk_visitor_uid")||"",b=(e==null?void 0:e.visitorNickname)||localStorage.getItem("bytedesk_nickname")||"",v=(e==null?void 0:e.visitorAvatar)||localStorage.getItem("bytedesk_avatar")||"",k=(e==null?void 0:e.orgUid)||"";t.append("visitorUid",u),t.append("visitorNickname",b),t.append("visitorAvatar",v),t.append("orgUid",k),t.append("client",(e==null?void 0:e.client)||"web"),e!=null&&e.isDebug&&l.debug("handleUpload formData",t);const y=`${U()}/visitor/api/upload/file`,p=await fetch(y,{method:"POST",headers:{},body:t});if(!p.ok)throw new Error(`上传失败: ${p.status} ${p.statusText}`);const o=await p.json();return e!=null&&e.isDebug&&l.debug("upload data:",o),o}catch(r){throw l.error("文件上传失败:",r),r}}async function T(a,d){var s;const e=`screenshot_${new Date().toISOString().replace(/[-:T.]/g,"").slice(0,14)}.jpg`;return((s=(await h(a,e,"image/jpeg",{...d,kbType:"feedback"})).data)==null?void 0:s.fileUrl)||""}export{h as handleUpload,T as uploadScreenshot};
|
||||
@@ -1 +1 @@
|
||||
import{H as i}from"./index-DQCLjMjN.js";import r from"./request-B-nt-2Xo.js";async function o(t){return r("/visitor/api/v1/init",{method:"POST",data:{...t,client:i}})}async function a(t){return r("/visitor/api/v1/thread",{method:"POST",data:{...t,client:i}})}async function s(t){return r("/visitor/api/v1/browse",{method:"POST",data:{...t,client:i}})}export{s as browse,o as initVisitor,a as requestThread};
|
||||
import{H as i}from"./index-DgW5OQds.js";import r from"./request-BKznmH0u.js";async function o(t){return r("/visitor/api/v1/init",{method:"POST",data:{...t,client:i}})}async function a(t){return r("/visitor/api/v1/thread",{method:"POST",data:{...t,client:i}})}async function s(t){return r("/visitor/api/v1/browse",{method:"POST",data:{...t,client:i}})}export{s as browse,o as initVisitor,a as requestThread};
|
||||
@@ -19,7 +19,7 @@
|
||||
<link rel="icon" type="image/x-icon" href="/reactdemo/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Bytedesk React Demo</title>
|
||||
<script type="module" crossorigin src="/reactdemo/assets/index-DQCLjMjN.js"></script>
|
||||
<script type="module" crossorigin src="/reactdemo/assets/index-DgW5OQds.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
Reference in New Issue
Block a user