ff-dist/dist/common/main-BFbUcNYO.js

955 lines
72 KiB
JavaScript
Raw Normal View History

2024-12-02 10:43:52 +08:00
var $a = Object.defineProperty;
var Bt = (e) => {
2024-11-19 15:49:56 +08:00
throw TypeError(e);
};
2024-12-02 10:43:52 +08:00
var xa = (e, t, a) => t in e ? $a(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
var k = (e, t, a) => xa(e, typeof t != "symbol" ? t + "" : t, a), Dt = (e, t, a) => t.has(e) || Bt("Cannot " + a);
var g = (e, t, a) => (Dt(e, t, "read from private field"), a ? a.call(e) : t.get(e)), $ = (e, t, a) => t.has(e) ? Bt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, a), D = (e, t, a, n) => (Dt(e, t, "write to private field"), n ? n.call(e, a) : t.set(e, a), a);
var qt = (e, t, a, n) => ({
2024-11-19 15:49:56 +08:00
set _(r) {
2024-12-02 10:26:53 +08:00
D(e, t, r, a);
2024-11-19 15:49:56 +08:00
},
get _() {
return g(e, t, n);
}
});
2024-12-02 10:43:52 +08:00
import { jsx as d, jsxs as x } from "react/jsx-runtime";
import w, { useEffect as E, useState as N, useCallback as me, useMemo as ie, useContext as Xe, useId as rt, useRef as Y, useLayoutEffect as Ea } from "react";
2024-11-19 15:49:56 +08:00
import p from "lodash";
2024-12-02 10:43:52 +08:00
import R from "classnames";
import { Form as at, Input as Ta, Button as ft, Breadcrumb as Fa, Tree as Ra, Pagination as La, Table as Oa, Empty as Va, Popconfirm as Aa, Tooltip as ja, Popover as Ia } from "antd";
import { useMergedState as Ma } from "rc-util";
import ee, { FieldContext as za, Field as ra } from "rc-field-form";
import { useParams as Wa, generatePath as Ua, createBrowserRouter as Ba, useInRouterContext as Da, Navigate as qa } from "react-router-dom";
import O from "prop-types";
import * as Ht from "react-is";
import { useNotification as Ha } from "rc-notification";
import { N as Ue, a as Be, T as yt, S as Ja } from "./vender-DMK1apIA.js";
2024-11-28 14:24:31 +08:00
import "rc-util/lib/hooks/useMergedState";
2024-12-02 10:43:52 +08:00
import Jt from "immutability-helper";
import Ka from "rc-drawer";
import _a from "rc-dialog";
2024-12-02 10:26:53 +08:00
var Ae, He, je, ue, Fe, Re;
2024-12-02 10:43:52 +08:00
class sa {
2024-11-19 15:49:56 +08:00
constructor(t, a) {
2024-12-02 10:43:52 +08:00
$(this, Ae, /* @__PURE__ */ new Map());
$(this, He, !0);
$(this, je, []);
$(this, ue);
$(this, Fe, () => g(this, ue));
$(this, Re, () => Promise.resolve());
2024-11-19 15:49:56 +08:00
k(this, "get", (...t) => new Promise((a, n) => {
const r = JSON.stringify(t);
2024-12-02 10:26:53 +08:00
if (g(this, Ae).has(r)) return a(g(this, Re).call(this, g(this, ue), ...t));
if (g(this, ue) === void 0) g(this, je).push([t, a, n]), g(this, He) && (D(this, He, !1), Promise.resolve(typeof g(this, Fe) == "function" ? g(this, Fe).call(this) : g(this, Fe)).then((s) => D(this, ue, s || null)).finally(() => {
2024-11-20 15:00:20 +08:00
g(this, je).forEach(([s, i, o]) => {
2024-11-19 15:49:56 +08:00
try {
2024-11-20 15:00:20 +08:00
const l = g(this, Re).call(this, g(this, ue), ...s);
2024-12-02 10:26:53 +08:00
g(this, Ae).set(JSON.stringify(s), l), i(l);
2024-11-19 15:49:56 +08:00
} catch (l) {
o(l);
}
2024-11-20 15:00:20 +08:00
}), g(this, je).length = 0;
2024-11-19 15:49:56 +08:00
}));
else {
2024-11-20 15:00:20 +08:00
const s = g(this, Re).call(this, g(this, ue), ...t);
2024-12-02 10:26:53 +08:00
g(this, Ae).set(r, s), a(s);
2024-11-19 15:49:56 +08:00
}
}));
2024-12-02 10:26:53 +08:00
D(this, Re, a), D(this, Fe, t);
2024-11-19 15:49:56 +08:00
}
}
2024-12-02 10:26:53 +08:00
Ae = new WeakMap(), He = new WeakMap(), je = new WeakMap(), ue = new WeakMap(), Fe = new WeakMap(), Re = new WeakMap();
2024-12-02 10:43:52 +08:00
const tr = () => d("div", { children: "Empty" }), Qe = w.createContext({ ele: {}, mount: () => {
2024-11-19 15:49:56 +08:00
}, unmount: () => {
} }), K = ({ rootClassName: e, className: t, children: a, actions: n, title: r, subTitle: s, extras: i, style: o = {} }) => {
2024-12-02 10:26:53 +08:00
const { mount: l, unmount: u } = w.useContext(Qe);
2024-12-02 10:43:52 +08:00
return n && K.Action({ children: n }), r && K.Title({ children: r }), s && K.SubTitle({ children: s }), i && K.Extra({ children: i }), E(() => (l("rootClassName", e), () => u(e)), [e]), d("div", { className: R("ff-container", t), style: o, children: a });
2024-11-19 15:49:56 +08:00
}, tt = (e) => ({ children: t, className: a }) => {
2024-12-02 10:26:53 +08:00
const { mount: n, unmount: r } = w.useContext(Qe);
2024-12-02 10:43:52 +08:00
return E(() => (n(e, w.createElement("div", { key: `ff-${e}`, className: R(`ff-popup-${e}`, a) }, t)), () => r(e)), [a, t]), null;
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:43:52 +08:00
K.Action = tt("actions"), K.Title = tt("title"), K.SubTitle = tt("sub-title"), K.Extra = tt("extras"), K.propTypes = { className: O.string, style: O.object, title: O.any, subTitle: O.any, actions: O.any, extras: O.any };
const ar = () => d(K, { className: "ff-loading", children: x("div", { className: "loader", children: [x("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), x("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), x("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), x("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] })] }) }), nr = () => d("div", { children: "NotFound" }), ia = ({ children: e }) => {
const [t, a] = N({}), n = me((s, i) => a((o) => ({ ...o, [s]: i })), []), r = me((s) => a((i) => ({ ...i, [s]: void 0 })), []);
2024-12-02 10:26:53 +08:00
return typeof (e == null ? void 0 : e.type) == "string" ? e : d(Qe.Provider, { value: { ele: t, mount: n, unmount: r }, children: w.cloneElement(e, { className: t.rootClassName, title: t.title, subTitle: t["sub-title"], actions: t.actions, extras: t.extras }) });
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:43:52 +08:00
ia.propTypes = { children: O.element.isRequired };
const Kt = { close: ["M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"], check: ["M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474c-6.1-7.7-15.3-12.2-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"], info: ["M512 224m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z", "M544 392h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V400c0-4.4-3.6-8-8-8z"] }, Tt = ({ type: e, props: t }) => d("i", { ...t, children: d("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Kt[e] || Kt.info).map((a, n) => d("path", { d: a }, n)) }) }), oa = ({ className: e, content: t, icon: a, $close: n }) => x(w.Fragment, { children: [a && d("div", { className: R("ff-notification-icon", e), children: d(Tt, { type: a }) }), t] }), Ga = ({}) => d(K, { children: "Confirm" });
2024-12-02 10:26:53 +08:00
var ye, Ie;
2024-11-20 14:11:37 +08:00
const te = class te {
2024-11-19 15:49:56 +08:00
constructor() {
2024-12-02 10:43:52 +08:00
$(this, Ie, null);
2024-12-02 10:26:53 +08:00
k(this, "init", (t) => D(this, Ie, new Map(t)));
k(this, "check", (t) => !g(this, Ie).has(t) || g(this, Ie).get(t));
2024-11-20 14:11:37 +08:00
if (g(te, ye)) return g(te, ye);
2024-11-19 15:49:56 +08:00
}
};
2024-12-02 10:43:52 +08:00
ye = new WeakMap(), Ie = new WeakMap(), $(te, ye, null), k(te, "getInstance", () => (g(te, ye) || D(te, ye, new te()), g(te, ye)));
2024-12-02 10:26:53 +08:00
let wt = te;
2024-12-02 10:43:52 +08:00
const Ya = wt.getInstance();
2024-11-19 15:49:56 +08:00
var we, Je;
2024-11-20 14:11:37 +08:00
const ae = class ae {
2024-11-19 15:49:56 +08:00
constructor() {
2024-12-02 10:43:52 +08:00
$(this, Je, null);
2024-12-02 10:26:53 +08:00
k(this, "init", (t) => D(this, Je, t));
2024-11-19 15:49:56 +08:00
k(this, "get", (t, a) => p.get(g(this, Je), t, a));
2024-11-20 14:11:37 +08:00
if (g(ae, we)) return g(ae, we);
2024-11-19 15:49:56 +08:00
}
};
2024-12-02 10:43:52 +08:00
we = new WeakMap(), Je = new WeakMap(), $(ae, we, null), k(ae, "getInstance", () => (g(ae, we) || D(ae, we, new ae()), g(ae, we)));
2024-12-02 10:26:53 +08:00
let Ct = ae;
2024-12-02 10:43:52 +08:00
const De = Ct.getInstance(), _t = { null2json: (e) => Object.create(), null2array: (e) => [], null2number: (e) => 0, null2bool: (e) => !1, null2string: (e) => "", null2integer: (e) => 0, null2float: (e) => 0, string2json: (e) => e ? JSON.parse(e) : "{}", string2array: (e) => e.substr(0, 1) === "[" && e.substr(-1) === "]" ? JSON.parse(e) : e.split(","), string2number: (e) => e == "" ? 0 : +e, string2integer: (e) => e == "" ? 0 : +e, string2float: (e) => e == "" ? 0 : +e, string2bool: (e) => {
2024-11-19 15:49:56 +08:00
switch (`${e}`.toLowerCase()) {
case "0":
case "false":
case "[]":
case "{}":
return !1;
}
return !!e;
}, string2string: (e) => e, json2json: (e) => e, json2array: (e) => e ? Object.values(e) : [], json2number: (e) => Object.keys(e).length, json2integer: (e) => Object.keys(e).length, json2float: (e) => Object.keys(e).length, json2bool: (e) => Object.keys(e).length > 0, json2string: (e) => e ? JSON.stringify(e) : "", array2json: (e) => ({ ...e }), array2array: (e) => e, array2number: (e) => e.length, array2integer: (e) => e.length, array2float: (e) => e.length, array2bool: (e) => e.length > 0, array2string: (e) => JSON.stringify(e), number2json: (e) => ({}), number2array: (e) => [e], number2number: (e) => e, number2integer: (e) => e, number2float: (e) => e, number2bool: (e) => !!e, number2string: (e) => e.toString(), boolean2json: (e) => ({}), boolean2array: (e) => [], boolean2number: (e) => +e, boolean2integer: (e) => +e, boolean2float: (e) => +e, boolean2bool: (e) => e, boolean2string: (e) => e ? "true" : "false" }, Z = (e, t) => {
let a = "string";
a = Array.isArray(e) ? "array" : typeof e, p.isObject(e) && (a = "json");
const n = `${a}2${t}`;
2024-12-02 10:43:52 +08:00
return Reflect.has(_t, n) ? _t[n](e) : e;
}, la = (e = {}, t = {}, a = {}, n = "") => ca(e, (r, s) => s === "type" && r === "code") ? da(e, t, a, n) : ua(e, t, n), ca = (e, t = () => !1) => p.some(e, (a) => !!p.some(a, t) || (p.isEmpty(a) || !p.isPlainObject(a) && !p.isArray(a) ? void 0 : ca(a, t))), da = async (e = {}, t = {}, a = {}, n = "") => {
2024-11-19 15:49:56 +08:00
let r = /* @__PURE__ */ Object.create(null);
for (let s in e) {
let i;
if (Reflect.has(e[s], "type") && ["code", "field", "router", "query", "string"].includes(e[s].type)) {
const { type: o, value: l = "", default: u = n } = e[s];
switch (o) {
case "code":
2024-11-20 15:00:20 +08:00
i = await Ne.exec(l, t, a);
2024-11-19 15:49:56 +08:00
break;
case "field":
i = p.get(t, l) ?? p.get(t, l.substring(l.indexOf(".") + 1));
break;
case "router":
case "query":
2024-11-20 15:00:20 +08:00
i = pe.getPageParams(l);
2024-11-19 15:49:56 +08:00
break;
case "string":
i = l;
}
i ?? (i = u);
2024-12-02 10:43:52 +08:00
} else i = await da(e[s], t, a, n);
2024-11-19 15:49:56 +08:00
p.set(r, s, i);
}
return r;
2024-12-02 10:43:52 +08:00
}, ua = (e = {}, t = {}, a = "") => Object.keys(e || {}).reduce((n, r) => {
2024-11-19 15:49:56 +08:00
if (p.isPlainObject(e[r])) {
let s;
if (Reflect.has(e[r], "type") && ["field", "router", "query", "string"].includes(e[r].type)) {
const { type: i, value: o = "", default: l = a } = e[r];
switch (i) {
case "field":
s = p.get(t, o) ?? p.get(t, o.substring(o.indexOf(".") + 1));
break;
case "router":
case "query":
2024-11-20 15:00:20 +08:00
s = pe.getPageParams(o);
2024-11-19 15:49:56 +08:00
break;
case "string":
s = o;
}
s ?? (s = l);
2024-12-02 10:43:52 +08:00
} else s = ua(e[r], t, a);
2024-11-19 15:49:56 +08:00
p.set(n, r, s);
}
return n;
2024-12-02 10:26:53 +08:00
}, {}), pt = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((a) => pt(a, t)) : Object.keys(e).reduce((a, n) => (t[n] ? a[t[n]] = pt(e[n], t) : a[n] = pt(e[n], t), a), {}) : e;
var st, Ke, _e, it;
const ot = class ot {
2024-11-19 15:49:56 +08:00
constructor(...t) {
2024-12-02 10:43:52 +08:00
$(this, Ke, []);
$(this, _e, (t) => {
2024-11-19 15:49:56 +08:00
var a;
2024-12-02 10:26:53 +08:00
for (let n of t) Array.isArray(n[0]) ? g(this, _e).call(this, n) : g(this, Ke).push(g(a = ot, st).call(a, n[0], n[1]));
2024-11-19 15:49:56 +08:00
});
k(this, "toValue", async (t, a = null) => {
const n = { getValue: () => t, getRecord: () => a };
return await g(this, Ke).reduce(async (r, s) => {
try {
const i = await r;
return (await s).call(n, i);
} catch (i) {
return console.error(i), r;
}
}, t);
});
2024-12-02 10:26:53 +08:00
k(this, "toRender", (t, a, n = null) => w.createElement(g(this, it), { value: t, record: a }, n));
2024-12-02 10:43:52 +08:00
$(this, it, ({ value: t, record: a, children: n }) => {
const [r, s] = N(n);
2024-12-02 10:26:53 +08:00
return Lt(() => {
2024-11-19 15:49:56 +08:00
let i = !1;
return s(n), this.toValue(t, a).then((o) => Z(o, "string")).then((o) => !i && s(o)).catch((o) => !i && s(`${o}`)), () => i = !0;
}, [t, a]), r;
});
2024-11-20 15:00:20 +08:00
g(this, _e).call(this, t);
2024-11-19 15:49:56 +08:00
}
};
2024-12-02 10:43:52 +08:00
st = new WeakMap(), Ke = new WeakMap(), _e = new WeakMap(), it = new WeakMap(), $(ot, st, p.memoize((t, a) => X.getWidgetComponent(t).then((n) => {
2024-11-19 15:49:56 +08:00
var r;
return ((r = n.default) == null ? void 0 : r.call(n, a)) || ((s) => s);
}), (t, a) => `${t}::${Z(a, "string")}`));
2024-12-02 10:26:53 +08:00
let bt = ot;
2024-12-02 10:43:52 +08:00
const Xa = (e, t = {}) => ie(() => e == null ? void 0 : e.map(({ widgetByJs: a, widgetByJsSetting: n, ...r }, s) => a ? { ...r, render: (i, o) => new bt([a, n]).toRender(i, o, "-") } : r), [e, t]), rr = (e) => {
const [t, a] = N({});
return E(() => {
2024-11-19 15:49:56 +08:00
let n = !1;
2024-12-02 10:43:52 +08:00
return e && F.get(`/api/_/${e}`).then((r) => p.pick(r, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig"])).then((r) => !n && a(r)), () => n = !0;
2024-11-19 15:49:56 +08:00
}, [e]), t;
2024-12-02 10:43:52 +08:00
}, sr = (e, t = {}) => {
const [a, n] = N({ dataSource: [] });
2024-11-19 15:49:56 +08:00
return Ze(() => {
let r = !1;
2024-12-02 10:43:52 +08:00
return e && F.get(`/api/${e}/${F.encode({ page: 1, ...t })}`).then((s) => !r && n(s)), () => r = !0;
2024-11-19 15:49:56 +08:00
}, [e, t]), a;
2024-12-02 10:26:53 +08:00
}, kt = (e, t = null, a = null, n = "id") => ie(() => {
2024-12-02 10:43:52 +08:00
if (p.isEmpty(e) || !e.some(({ uuid: s }) => Ya.check(s))) return !1;
2024-11-19 15:49:56 +08:00
if (p.isEmpty(a) || p.isEmpty(t)) return !0;
const r = t.map((s) => `${s == null ? void 0 : s[n]}`);
return e.some(({ uuid: s }) => !s || !a.has(s) || a.get(s).some((i) => r.includes(`${i}`)));
2024-12-02 10:43:52 +08:00
}, [e, t, a, n]), Qa = ({ className: e, itemClassName: t, classNames: a = {}, dataSource: n, isPaginate: r, isItemOperations: s, isBatchOperations: i, batchOperations: o, itemOperations: l, itemOperationsAccess: u, resource: c, primaryKey: m, title: h, itemGridLayout: f, $setting: y, tabs: b, isConditionFormLayout: C, isTreeSider: T, treeSiderConfig: z }) => {
const { getBase62params: U, onClickCallback: B, onTabChange: q } = Xe(Oe), { total: S, page: I, pageSize: L, tab: W } = (U == null ? void 0 : U()) || {}, _ = me((A, v, oe) => d(Za, { className: R("ff-data-list-framework-item", t), operations: s && v ? l == null ? void 0 : l.filter((V) => !(m && V.uuid && u.has(V.uuid)) || u.get(V.uuid).includes(v == null ? void 0 : v[m])) : [], data: c ? { [c]: v } : v, children: A, onClickCallback: B }), [c, m, s, B, l, u]);
return x("div", { className: R("ff-data-list-framework", e), children: [d(ha, { className: a == null ? void 0 : a.sider, isTreeSider: T, ...z }), x("div", { className: R("ff-data-list-container", a == null ? void 0 : a.container), children: [d(Rt, { className: a == null ? void 0 : a.filter, isConditionFormLayout: C }), d(ma, { title: h, className: a == null ? void 0 : a.toolbar, tabs: b, tab: W, onTabChange: q }), d(dn, { ...f, className: a == null ? void 0 : a.content, style: { "--col-num": (y == null ? void 0 : y.colNum) || 1 }, primaryKey: m, itemRender: _, dataSource: n }), d(fa, { className: a == null ? void 0 : a.footer, isPaginate: r, isOperations: i, operations: o, total: S, page: I, pageSize: L })] })] });
}, Za = ({ className: e, operations: t, children: a, data: n, onClickCallback: r }) => x("div", { className: R("data-list-grid-layout-item-container", e), children: [a, !!(t != null && t.length) && d("div", { className: "data-list-grid-layout-item-actions", children: t.map((s) => d("span", { className: "data-list-grid-layout-item-action", children: d(P.Link, { uuid: s.uuid, type: s.type, name: s.name, widget: s.widget, widgetType: s.widgetType, widgetProps: s.widgetProps, widgetSetting: s.widgetSetting, widgetContainerProps: s.widgetContainerSetting, data: n, onAfterClick: (i) => i !== !1 && (r == null ? void 0 : r(s.isRefresh, n)) }, s.uuid || rt()) }, (s == null ? void 0 : s.uuid) || rt())) })] }), en = ({ listCode: e, className: t, classNames: a = {}, itemClassName: n, dataSource: r, columns: s, isItemOperations: i, isBatchOperations: o, batchOperations: l, itemOperations: u, itemOperationsAccess: c, resource: m, primaryKey: h, title: f, tabs: y, isPaginate: b, isTreeSider: C, treeSiderConfig: T, isConditionFormLayout: z, ...U }) => {
const { getBase62params: B, onClickCallback: q, onTabChange: S } = Xe(Oe), { total: I, page: L, tab: W, pageSize: _ } = (B == null ? void 0 : B()) || {}, A = kt(u, r, c, h);
return x("div", { className: R("ff-data-table-framework", t), children: [d(ha, { className: a == null ? void 0 : a.sider, isTreeSider: C, ...T }), x("div", { className: R("ff-data-table-container", a == null ? void 0 : a.container), children: [d(Rt, { listCode: e, isConditionFormLayout: z }), d(ma, { title: f, className: a == null ? void 0 : a.toolbar, tabs: y, tab: W, onTabChange: S }), d(rn, { ...U, primaryKey: h, className: "ff-data-table-content", columns: s, dataSource: r, operationRender: A ? (v) => d("div", { className: "ff-data-table-actions", children: u == null ? void 0 : u.reduce((oe, V, he) => [...oe, d(P.Link, { size: "small", uuid: V.uuid, type: V.type, name: V.name, widget: V.widget, widgetType: V.widgetType, widgetProps: V.widgetProps, widgetData: V.widgetData, widgetSetting: V.widgetSetting, widgetContainerProps: V.widgetContainerSetting, data: v, onAfterClick: ($e) => $e !== !1 && (q == null ? void 0 : q(V.isRefresh, data)) }, V.uuid || he)], []) }) : null }), d(fa, { isPaginate: b, isOperations: o, operations: l, total: I, page: L, pageSize: _ })] })] });
2024-12-02 10:26:53 +08:00
}, Oe = w.createContext({ listCode: "", getBase62params: (e, t) => {
2024-11-19 15:49:56 +08:00
}, onReload: () => {
}, onClickCallback: () => {
2024-12-02 10:26:53 +08:00
}, onConditionChange: () => {
2024-11-19 15:49:56 +08:00
}, onTabChange: () => {
}, onSiderChange: () => {
}, onKeywordChange: () => {
}, onPageChange: () => {
}, onPageSizeChange: () => {
2024-12-02 10:43:52 +08:00
} }), tn = ({ isItemGridLayout: e, theme: t, themeProps: a, onClickCallback: n, onReload: r, listCode: s, total: i = 0, page: o = 0, onPageChange: l, pageSize: u = 30, onPageSizeChange: c, tab: m, onTabChange: h, keyword: f, onKeywordChange: y, condition: b, onConditionChange: C, sider: T, onSiderChange: z, ...U }) => {
const [B, q] = N();
return E(() => {
t ? X.getWidgetComponent(t).then((S) => {
if (!S) throw `${t} not found`;
return S;
}).catch((S) => ({ default: () => `${S}` })).then((S) => q(w.createElement(S.default, { ...U, $setting: a }))) : q(d(e ? Qa : en, { ...U, $setting: a }));
}, [t, a]), d(Oe.Provider, { value: { listCode: s, onClickCallback: n, onReload: r, getBase62params: (S, I) => {
const L = { tab: m, page: o, pageSize: u, keyword: f, sider: T, condition: b, total: i };
return S && S != "init" ? L[S] ?? I : L;
}, onPageChange: l, onPageSizeChange: c, onTabChange: h, onSiderChange: z, onKeywordChange: y, onConditionChange: C }, children: B && w.cloneElement(B, U) });
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:26:53 +08:00
var Ce, ge, Le, lt;
2024-11-20 14:11:37 +08:00
const ne = class ne {
2024-11-19 15:49:56 +08:00
constructor() {
2024-12-02 10:43:52 +08:00
$(this, ge, null);
$(this, Le, /* @__PURE__ */ new Map());
$(this, lt, () => {
2024-11-20 15:00:20 +08:00
if (g(this, ge)) return g(this, ge).port.postMessage({ command: "status", data: [] });
2024-12-02 10:26:53 +08:00
D(this, ge, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), g(this, ge).port.onmessage = (t) => {
2024-11-19 15:49:56 +08:00
var a, n;
(a = t.data) != null && a.uuid ? g(this, Le).forEach((r, s) => {
var i;
(r == "*" || (i = r == null ? void 0 : r.includes) != null && i.call(r, t.data.uuid)) && s(t.data);
2024-12-02 10:43:52 +08:00
}) : ((n = t.data) == null ? void 0 : n.readyState) == WebSocket.CLOSED && F.get("/api/user-api-token").then(({ token: r, expire_at: s }) => {
g(this, ge).port.postMessage({ command: "initWs", data: [`ws${p.trimStart(F.appUrl, "http")}api/user-resource-status-ws?token=${r}`] });
2024-11-19 15:49:56 +08:00
});
2024-11-20 15:00:20 +08:00
}, g(this, ge).port.postMessage({ command: "status", data: [] });
2024-11-19 15:49:56 +08:00
});
2024-12-02 10:26:53 +08:00
k(this, "subscribe", (t, a = []) => (a ? Array.isArray(a) && a.length == 0 ? a = "*" : Array.isArray(a) || (a = [a].flat()) : a = "*", g(this, Le).set(t, a), g(this, Le).size == 1 && g(this, lt).call(this), () => this.unsubscribe(t)));
2024-11-19 15:49:56 +08:00
k(this, "unsubscribe", (t) => g(this, Le).delete(t));
2024-11-20 14:11:37 +08:00
if (g(ne, Ce)) return g(ne, Ce);
2024-11-19 15:49:56 +08:00
}
};
2024-12-02 10:43:52 +08:00
Ce = new WeakMap(), ge = new WeakMap(), Le = new WeakMap(), lt = new WeakMap(), $(ne, Ce, null), k(ne, "getInstance", () => (g(ne, Ce) || D(ne, Ce, new ne()), g(ne, Ce)));
2024-12-02 10:26:53 +08:00
let vt = ne;
2024-12-02 10:43:52 +08:00
const ga = vt.getInstance(), Ft = w.forwardRef(({ listCode: e, base62params: t, className: a, itemClassName: n, theme: r, themeProps: s, classNames: i }, o) => {
var ut, jt, It, Mt, zt, Wt, Ut;
const l = ka(), u = Y(t), c = Y(/* @__PURE__ */ new Map()), m = Y([]), [{ resource: h, primaryKey: f, batchOperations: y = [], itemOperations: b = [], columns: C = [], themeConfig: T, theme: z, isConditionFormLayout: U = !1, isTreeSider: B, treeSiderConfig: q, isItemGridLayout: S, itemGridLayout: I, title: L, isPaginate: W, tabs: _ }, A] = N({ isItemGridLayout: !1, itemGridLayout: {} }), v = p.throttle((M) => {
m.current = [], F.list(e, p.pick({ ...u.current, ...M }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: H, condition: We, total: xe, tab: fe, sider: Ee, page: le, pageSize: ce, operationsAccess: de, dataSource: Te }) => {
2024-12-02 10:26:53 +08:00
u.current = { tab: fe, condition: We, sider: Ee, keyword: H, total: xe, pageSize: ce, page: Te != null && Te.length ? le : 1 }, m.current = Te, c.current = new Map(de), l();
2024-11-19 15:49:56 +08:00
});
2024-12-02 10:26:53 +08:00
}, 380, { leading: !1, trailing: !0 }), oe = kt(b, m.current, c.current, f), V = kt(y);
2024-12-02 10:43:52 +08:00
E(() => {
let M = null;
return e && F.get(`/api/_/${e}`).resp(({ data: H, res: We }) => {
H != null && H.isDynamicRefresh && (M = ga.subscribe(() => v(), We)), u.current.pageSize = H.pageSize, A(H);
}).catch(() => A({})), m.current = [], () => M == null ? void 0 : M();
2024-12-02 10:26:53 +08:00
}, [e]), Lt(() => {
2024-11-19 15:49:56 +08:00
e && v(t);
}, [e, t]);
const he = () => {
v();
2024-12-02 10:43:52 +08:00
}, $e = (M = 0, H = null) => {
if (M === 2) {
2024-12-02 10:26:53 +08:00
const We = p.get(H, "__PARENT_ID__", ""), xe = p.get(H, f, p.get(H, [h, f], "")), fe = p.findIndex(m.current, ["__PARENT_ID__", We]), Ee = p.findIndex(fe > -1 ? p.get(m.current, [fe, "children"]) : m.current, [f, xe]);
2024-12-02 10:43:52 +08:00
Ee > -1 ? (F.get(`/api/${e}/detail/${xe}`).then((le) => {
2024-11-20 15:00:20 +08:00
const ce = p.get(m.current, fe > -1 ? [fe, "children", Ee, "children"] : [Ee, "children"]);
2024-12-02 10:43:52 +08:00
m.current = Jt(m.current, fe > -1 ? { [fe]: { children: { $splice: [[Ee, 1, { ...le, children: ce }]] } } } : { $splice: [[Ee, 1, { ...le, children: ce }]] }), l();
}), F.post(`/api/${e}/list-operations-access`, { ids: xe }).then((le) => new Map(le)).then((le) => {
2024-11-20 15:00:20 +08:00
c.current.forEach((ce, de) => {
2024-11-19 15:49:56 +08:00
var Te;
2024-12-02 10:26:53 +08:00
(Te = le.get(de)) != null && Te.some((gt) => gt == xe) || c.current.set(de, ce.filter((gt) => gt !== xe));
2024-11-20 15:00:20 +08:00
}), le.forEach((ce, de) => {
c.current.has(de) ? c.current.set(de, p.uniq([...c.current.get(de) || [], ...ce])) : c.current.set(de, ce);
2024-11-19 15:49:56 +08:00
}), l();
})) : he();
2024-12-02 10:43:52 +08:00
} else M === 1 && he();
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:26:53 +08:00
w.useImperativeHandle(o, () => ({ onReload: he, onClickCallback: $e }));
2024-12-02 10:43:52 +08:00
const dt = { listCode: e, title: L, itemClassName: n, classNames: i, resource: h, primaryKey: f, theme: r || z, themeProps: s || T, isTreeSider: B, treeSiderConfig: q, isPaginate: W, tabs: _, isItemOperations: oe, isBatchOperations: V, batchOperations: y, itemOperations: b, isItemGridLayout: S, columns: C, itemGridLayout: I, isConditionFormLayout: U, itemOperationsAccess: c.current, dataSource: m.current };
return d(tn, { ...dt, className: R("ff-data-list-helper", a), onReload: he, onClickCallback: $e, condition: (ut = u.current) == null ? void 0 : ut.condition, onConditionChange: (M, H) => v({ keyword: H, condition: Jt(u.current.condition || {}, { $merge: M || {} }), page: 1 }), tab: (jt = u.current) == null ? void 0 : jt.tab, onTabChange: (M) => v({ tab: M, page: 1 }), sider: (It = u.current) == null ? void 0 : It.sider, onSiderChange: (M) => v({ sider: M, page: 1 }), keyword: (Mt = u.current) == null ? void 0 : Mt.keyword, onKeywordChange: (M) => v({ keyword: M, page: 1 }), page: (zt = u.current) == null ? void 0 : zt.page, onPageChange: (M, H) => v({ page: M, pageSize: H }), total: (Wt = u.current) == null ? void 0 : Wt.total, pageSize: (Ut = u.current) == null ? void 0 : Ut.pageSize, onPageSizeChange: (M) => v({ pageSize: M, page: 1 }) });
}), pa = (e, t, a, n, r = {}, s = 0) => {
2024-11-19 15:49:56 +08:00
const i = { "--grid-layout-h": `${n}`, "--grid-layout-w": `${a}`, "--grid-layout-x": `${e}`, "--grid-layout-y": `${t}`, "--grid-layout-row-height-offset": "0px" };
2024-12-02 10:43:52 +08:00
return r != null && r.autoHeight ? i.height = "fit-content" : i["--grid-layout-row"] = `${n}`, i["--grid-layout-box-margin"] = Gt(r == null ? void 0 : r.marginTop, r == null ? void 0 : r.marginRight, r == null ? void 0 : r.marginBottom, r == null ? void 0 : r.marginLeft), i["--grid-layout-box-padding"] = Gt(r == null ? void 0 : r.paddingTop, r == null ? void 0 : r.paddingRight, r == null ? void 0 : r.paddingBottom, r == null ? void 0 : r.paddingLeft), s && (i.height = `${s}px`), i;
}, Gt = (e, t, a, n) => `${e || 0}px ${t || 0}px ${a || 0}px ${n || 0}px`, Rt = ({ className: e, isConditionFormLayout: t }) => {
2024-11-19 15:49:56 +08:00
var m, h;
2024-12-02 10:43:52 +08:00
const [a, n] = N({}), { listCode: r, onKeywordChange: s, onConditionChange: i, getBase62params: o } = w.useContext(Oe), { keyword: l, condition: u } = (o == null ? void 0 : o()) || {}, [c] = at.useForm();
return E(() => {
r && t && F.get(`/api/_/${r}/list-condition-form-layout`).then(({ resource: f, marginX: y, marginY: b, rowHeight: C, cols: T, fields: z }) => {
n({ resource: f, itemMargin: [y, b], rowHeight: C, cols: T, fields: z });
2024-11-19 15:49:56 +08:00
}).catch(() => n({}));
2024-12-02 10:43:52 +08:00
}, [r, t]), E(() => {
2024-11-19 15:49:56 +08:00
c.setFieldsValue({ keyword: l, ...u });
2024-12-02 10:43:52 +08:00
}, [JSON.stringify([l, u])]), d("div", { className: R("ff-data-list-filter", e), children: d(at, { form: c, layout: "vertical", autoComplete: "off", onFinish: ((m = a.fields) == null ? void 0 : m.length) > 1 ? (f) => i({ [a.resource]: f[a.resource] }, f.keyword) : () => {
2024-11-19 15:49:56 +08:00
}, onValuesChange: (f) => {
p.isEmpty(p.omit(f, ["keyword"])) || c.submit();
2024-12-02 10:43:52 +08:00
}, children: ((h = a.fields) == null ? void 0 : h.length) > 1 ? d(Ot, { ...a, children: d(an, { onReset: () => {
2024-11-19 15:49:56 +08:00
const { keyword: f, condition: y } = o("init") || {};
c.setFieldsValue({ keyword: f, ...y });
2024-12-02 10:43:52 +08:00
} }) }) : d("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: d("div", { className: "grid-layout-item", style: pa(20, 0, 5, 2), children: d(at.Item, { name: ["keyword"], children: d(Ta.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (f) => s(f) }) }) }) }) }) });
}, an = ({ cols: e, fields: t, onReset: a }) => {
const [n, r] = N(!1), s = ie(() => t == null ? void 0 : t.toReversed().some((i) => i.y > 1 || i.x + i.w >= e - 5), [e, t]);
return x(at.Item, { label: " ", style: { "--item-span": 5 }, className: R("ff-data-list-filter-actions", { expanded: n }), children: [d(ft, { onClick: a, children: "重置" }), d(ft, { type: "primary", htmlType: "submit", children: "查询" }), s && d(P.Link, { className: "ff-data-list-filter-expanded-button", widget: () => r((i) => !i), type: "primary", name: n ? "关闭" : "展开", icon: n ? "icon-up" : "icon-down", iconPosition: "end" })] });
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:26:53 +08:00
Rt.reservedFields = [{ x: 0, y: 0, h: 3, w: 5, field: { isVirtual: !0, widgetPrefix: "@pkg/ff/grid-layout-forms", widget: "Input", code: "keyword", label: "关键字", placeholder: "多关键字 | 分割", extras: { prefix: "icon-search" } } }];
2024-12-02 10:43:52 +08:00
const ma = ({ className: e, title: t, tabs: a, tab: n, onTabChange: r }) => {
const [s, i] = Ma(a == null ? void 0 : a[0].value, { value: n, onChange: r });
return x("div", { className: R("ff-data-list-toolbar", e), children: [d("div", { className: "ff-data-list-title", children: t }), d(Fa, { className: "ff-data-list-tabs", itemRender: ({ label: o, code: l }) => d("span", { onClick: () => i(l), className: R("ff-data-list-tab", { active: l == s }), children: o }), items: a }), x("div", { className: "ff-data-list-actions", children: [d(P.Link, { icon: "icon-reload" }), d(P.Link, { icon: "icon-setting" })] })] });
}, nn = [{ title: "parent 1", key: "0-0", children: [{ title: "parent 1-0", key: "0-0-0", disabled: !0, children: [{ title: "leaf", key: "0-0-0-0", disableCheckbox: !0 }, { title: "leaf", key: "0-0-0-1" }] }, { title: "parent 1-1", key: "0-0-1", children: [{ title: d("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], ha = ({ className: e, width: t = 280, isTreeSider: a }) => a ? d(Ra.DirectoryTree, { className: R("ff-data-list-sider", e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: nn }) : null, fa = ({ className: e, operations: t, isOperations: a, isPaginate: n, total: r, page: s, pageSize: i }) => {
2024-12-02 10:26:53 +08:00
const { onPageChange: o, onPageSizeChange: l, onClickCallback: u } = w.useContext(Oe);
2024-12-02 10:43:52 +08:00
return a && !p.isEmpty(t) || n ? x("div", { className: R("ff-data-list-footer", e), children: [d("div", { className: "ff-data-list-actions", children: t == null ? void 0 : t.map((c, m) => d(P, { uuid: c.uuid, type: c.type, name: c.name, widget: c.widget, widgetType: c.widgetType, widgetProps: c.widgetProps, widgetData: c.widgetData, widgetSetting: c.widgetSetting, widgetContainerProps: c.widgetContainerSetting, onAfterClick: (h) => h !== !1 && (u == null ? void 0 : u(c.isRefresh, null)) }, c.uuid || m)) }), n && d(La, { size: "small", total: r, pageSize: i, showSizeChanger: !1, showTotal: (c) => `${s} 页 / 总共 ${c}`, onChange: o, onShowSizeChange: l })] }) : null;
}, ya = (e, t, a = !0) => a !== !0 && a-- <= 0 ? [] : p.isArray(e) && !p.isEmpty(e) ? e.reduce((n, r) => (Reflect.has(r, t) && Reflect.has(r, "children") && n.push(r[t]), Reflect.has(r, "children") && !p.isEmpty(r.children) ? n.concat(ya(r.children, t, a)) : n), []) : [], rn = ({ className: e, primaryKey: t, columns: a = [], dataSource: n = [], operationRender: r, operationWidth: s = 180, ...i }) => {
2024-12-02 10:26:53 +08:00
rt();
2024-12-02 10:43:52 +08:00
const o = Y(null), l = Y(null), [u, c] = N([]), [m, h] = N({ width: 0, height: 0 });
E(() => {
c(ya(n, t));
}, [n, t]), Ea(() => {
2024-11-19 15:49:56 +08:00
const y = new ResizeObserver(() => {
var b;
h({ width: ((b = o.current) == null ? void 0 : b.nativeElement.querySelector(".ant-table-body").scrollWidth) || l.current.offsetWidth, height: l.current.offsetHeight });
});
return l.current && y.observe(l.current), () => {
l.current && y.unobserve(l.current);
};
}, []);
2024-12-02 10:43:52 +08:00
const f = Xa(a);
return d("div", { ref: l, className: R("ff-data-list-table", e), children: m.height ? d(Oa, { ...i, ref: o, rowKey: (y) => (y == null ? void 0 : y[t]) ?? Math.random(), columns: f == null ? void 0 : f.concat(r ? [{ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(s / m.width * 100).toFixed(2)}%`, render: (y, b, C) => r(b, C) }] : []), dataSource: n, size: "middle", scroll: { x: "max-content", y: m.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: c, expandedRowKeys: u } }) : null });
}, sn = "RC_FORM_INTERNAL_HOOKS", wa = (e, { initialValue: t, initialValueLanguage: a, convertJs: n, convertJsSetting: r, type: s = "string" }, i = null) => {
const o = Y(!1), l = Xe(za), [u, c] = N(), [m, h] = N(a != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: f } = l.getInternalHooks(sn) || {};
return E(() => f == null ? void 0 : f((y, b, C) => {
2024-11-19 15:49:56 +08:00
if (!o.current) return;
2024-12-02 10:43:52 +08:00
const T = p.get(b, e);
p.isEqual(T, m) || h(Z(T, s));
}), [m]), E(() => {
2024-11-20 15:00:20 +08:00
a == "javascript" && t ? Ne.exec(t, {}, { getFieldValueForBasicForm: (y) => i ? i.getFieldValue(y) : l.getFieldValue(y), getFieldValue: (y) => l.getFieldValue(y) }).then((y) => h(Z(y, s))).catch((y) => notification.error({ message: `布局数据错误: ${JSON.stringify(y)}` })).finally(() => o.current = !0) : (t && h(Z(t ?? l.getFieldValue(e), s)), o.current = !0);
2024-11-19 15:49:56 +08:00
}, [t, a]), Ze(() => {
o.current && n && X.getWidgetComponent(n).then(({ default: y }) => y({ value: m, record: l.getFieldsValue(!0), $setting: r })).then(c).catch((y) => console.error("布局数据转换错误: ", y, n));
}, [m, n, r]), [u || m, m];
2024-12-02 10:43:52 +08:00
}, Ca = (e, t, a = "@pkg/ff/grid-layouts", n = null) => ie(() => {
2024-11-19 15:49:56 +08:00
var r;
2024-12-02 10:43:52 +08:00
return (r = p.sortBy(e, ["y", "x"])) == null ? void 0 : r.map(({ i: s, x: i, y: o, w: l, h: u, field: { boxStyle: c, widgetPrefix: m = a, widget: h, ...f } }, y) => d("div", { className: "grid-layout-item", style: pa(i, o, l, u, c, h === "Height" && (f == null ? void 0 : f.initialValue)), children: d(on, { ...f, basicForm: n, itemWidget: h != null && h.startsWith("@") || h != null && h.startsWith("blob:") ? h : `${m}/${h}`, itemWidgetRender: t }) }, s || y));
}, [e]), on = ({ itemWidget: e, itemWidgetRender: t, basicForm: a, ...n }) => {
const [r, s] = N();
return E(() => {
2024-11-19 15:49:56 +08:00
X.getWidgetComponent(e).then(({ defaultProps: i = {}, default: o }) => {
2024-12-02 10:26:53 +08:00
s(w.createElement(t(o, i, a), n));
2024-11-19 15:49:56 +08:00
}).catch((i) => {
console.error(i), s(e);
});
}, [e]), r;
2024-12-02 10:43:52 +08:00
}, ba = ({ cols: e = 12, rowHeight: t = 21, fields: a = [], data: n, containerPadding: r = [0, 0], itemMargin: s = [4, 0], formProps: i = {}, className: o, ...l }) => {
const [u] = ee.useForm(), c = Ca(a, ln, "@pkg/ff/grid-layouts"), m = ie(() => [{ name: "__PROPS__", value: i }], [i]);
2024-11-19 15:49:56 +08:00
return Ze(() => {
u.setFieldsValue(n);
2024-12-02 10:43:52 +08:00
}, [n]), d(ee, { fields: m, form: u, component: !1, children: d("div", { ...l, className: R("ff-grid-layout", o), style: { "--grid-layout-item-margin-y": `${(s == null ? void 0 : s[0]) || 0}px`, "--grid-layout-item-margin-x": `${(s == null ? void 0 : s[1]) || 0}px`, "--grid-layout-container-padding-y": `${(r == null ? void 0 : r[0]) || 0}px`, "--grid-layout-container-padding-x": `${(r == null ? void 0 : r[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: c }) });
}, ln = (e, t = {}, a = null) => (n) => {
const { code: r, label: s, extras: i, isVirtual: o, initialValue: l, initialValueLanguage: u, convertJs: c, convertJsSetting: m, ...h } = p.merge({}, t, n), [f, y] = wa(o ? null : r, { initialValue: l, initialValueLanguage: u, convertJs: c, convertJsSetting: m, type: (h == null ? void 0 : h.type) || "string" }, a);
2024-11-19 15:49:56 +08:00
return d(e, { ...h, value: f, rawValue: y, $setting: i || {} });
2024-12-02 10:43:52 +08:00
}, ir = (Yt = ba, function({ code: e, data: t, ...a }) {
const [n, r] = N({ resource: null, cols: 12, rowHeight: 21, fields: [] });
return E(() => {
e && F.get(`/api/_/${e}`).then((s) => r(p.pick(s, ["resource", "cols", "rowHeight", "fields"])));
}, [e]), (n == null ? void 0 : n.resource) && d(Yt, { ...a, rowHeight: n.rowHeight, cols: n.cols, fields: n.fields, data: n != null && n.resource ? { [n == null ? void 0 : n.resource]: t } : {} });
2024-11-19 15:49:56 +08:00
});
2024-12-02 10:43:52 +08:00
var Yt;
const or = ({ widget: e, widgetPrefix: t = "@pkg/ff/grid-layouts", basicForm: a, ...n }) => {
const r = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [s, i] = N();
return E(() => {
r && X.getWidgetComponent(r).then(({ defaultProps: o = {}, default: l }) => ({ default: cn(l, o, a) })).catch((o) => ({ default: () => `${o}` })).then((o) => i(w.createElement(o.default, n)));
2024-11-19 15:49:56 +08:00
}, [r]), s;
2024-12-02 10:43:52 +08:00
}, cn = (e, t = {}, a = null) => (n) => {
const { code: r, label: s, extras: i, isVirtual: o, initialValue: l, initialValueLanguage: u, convertJs: c, convertJsSetting: m, value: h, ...f } = p.merge({}, t, n), [y, b] = wa(o ? null : r, { initialValue: l, initialValueLanguage: u, convertJs: c, convertJsSetting: m, type: (f == null ? void 0 : f.type) || "string" }, a);
2024-11-19 15:49:56 +08:00
return d(e, { ...f, value: y, rawValue: b, $setting: i || {} });
2024-12-02 10:43:52 +08:00
}, dn = ({ cols: e, rowHeight: t, itemMargin: a, fields: n, primaryKey: r, dataSource: s, itemClassName: i, itemRender: o = (m, h, f) => m, empty: l = d(Va, { description: null }), className: u, style: c = {} }) => {
const m = rt(), h = ie(() => d(ba, { cols: e, rowHeight: t, itemMargin: a, fields: n, className: i }), [n, e, t, a]);
return d("div", { className: R("ff-data-list-content", u), style: c, children: p.isEmpty(s) ? l : s == null ? void 0 : s.map((f, y) => d(w.Fragment, { children: o(w.cloneElement(h, { data: f }), f, y) }, `${m}-${(f == null ? void 0 : f[r]) || y}`)) });
}, un = ({ component: e }) => {
const { base62params: t } = Wa();
return d(K, { children: d(Ft, { listCode: e, base62params: F.decode(t) }) });
}, gn = () => "Empty", pn = ({ component: e, $setting: t }) => {
const [a, n] = N();
E(() => {
if (!e) return n(d(gn, { description: null }));
2024-12-02 10:26:53 +08:00
X.getWidgetComponent(e).catch((s) => ({ default: () => `${s}` })).then((s) => w.createElement(s.default, { $setting: t })).then(n);
2024-11-19 15:49:56 +08:00
}, [e]);
2024-11-20 15:00:20 +08:00
const r = pe.getPageParams() || {};
2024-12-02 10:26:53 +08:00
return a ? w.cloneElement(a, r) : null;
2024-11-19 15:49:56 +08:00
};
2024-11-20 15:00:20 +08:00
var be, Q, ke, ve, Ge, Ye;
2024-11-20 14:11:37 +08:00
const re = class re {
2024-11-19 15:49:56 +08:00
constructor() {
2024-12-02 10:43:52 +08:00
$(this, Q, /* @__PURE__ */ new Map());
$(this, ke, {});
$(this, ve, null);
2024-11-19 15:49:56 +08:00
k(this, "init", (t, a) => {
2024-12-02 10:26:53 +08:00
D(this, Q, t), D(this, ke, a);
2024-11-19 15:49:56 +08:00
});
k(this, "get", (t) => (g(this, Q).has(t) || (t = Array.from(g(this, Q).keys()).find((a) => g(this, Q).get(a).uri === t)), g(this, Q).get(t) || {}));
k(this, "redirect", (t, a, n = {}) => {
const { uri: r, type: s, widgetProps: i } = this.get(t) || {};
2024-12-02 10:43:52 +08:00
let o = Ua(r || t, s != "list" ? a : p.mapValues(a, (u) => F.encode(u)));
2024-11-19 15:49:56 +08:00
const l = new URLSearchParams();
for (const u in i || {}) (i == null ? void 0 : i.type) == "query" && l.append(u, a[u]);
return l.size > 0 && (o = `${o}?${l.toString()}`), g(this, ve).navigate(o, n);
});
k(this, "getMenus", (t) => {
var a;
return ((a = g(this, ke)) == null ? void 0 : a[t]) || [];
});
k(this, "findMenuPathByUuid", (t) => {
let a = [];
2024-11-20 15:00:20 +08:00
for (const n in g(this, ke)) if (a = g(this, Ge).call(this, g(this, ke)[n], t, [n]), a.length > 1) return a;
2024-11-19 15:49:56 +08:00
return a;
});
2024-11-20 14:11:37 +08:00
k(this, "getMenusByRouteUuid", (t) => g(this, Ye).call(this, t, Object.values(g(this, ke)).flat()));
2024-12-02 10:43:52 +08:00
$(this, Ge, (t, a, n = []) => {
2024-11-19 15:49:56 +08:00
if (p.isEmpty(t)) return n;
for (const { uuid: r, children: s } of t) {
if (r == a) return n.concat(r);
2024-11-20 15:00:20 +08:00
if (!p.isEmpty(s)) return n.concat(r, g(this, Ge).call(this, s, a));
2024-11-19 15:49:56 +08:00
}
return n;
});
2024-12-02 10:43:52 +08:00
$(this, Ye, (t, a) => {
2024-11-19 15:49:56 +08:00
var r;
let n = [];
2024-11-20 14:11:37 +08:00
for (const s of a) s.widgetType == "redirect" && (s.uuid == t || s.widget == t ? n.push(s) : (r = s.children) != null && r.length && (n = n.concat(g(this, Ye).call(this, t, s.children))));
2024-11-19 15:49:56 +08:00
return n;
});
k(this, "getCurrentMenu", () => {
const { uuid: t } = this.getCurrentRoute() || {};
if (!t) return;
const a = this.getMenusByRouteUuid(t);
return p.isEmpty(a) ? void 0 : a[0];
});
k(this, "getCurrentRoute", (t = 0) => {
var n;
const a = (n = g(this, ve).state.matches[g(this, ve).state.matches.length - 1 - t]) == null ? void 0 : n.route;
if (!a) return null;
for (let [r, s] of g(this, Q)) if (s.uri === a.path) return s;
return null;
});
k(this, "getPageParams", (t) => {
var s;
const { location: a, matches: n } = g(this, ve).state, r = ((s = n[n.length - 1]) == null ? void 0 : s.params) || {};
return a.search && new URLSearchParams(a.search).forEach((i, o) => {
r[o] = i;
}), t ? p.get(r, t) : r;
});
k(this, "createBrowserRouter", (t = {}) => {
if (g(this, Q).size == 0) return null;
const a = De.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/BasicLayout"), n = De.get(X.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), r = { [a]: 0 }, s = (o, l) => () => X.getWidgetComponent(o).then((u) => u.default || function() {
return `${o}`;
2024-12-02 10:43:52 +08:00
}).then((u) => ({ Component: () => w.createElement(ia, {}, w.createElement(u, l)) })), i = Array.from(g(this, Q).values()).reduce((o, { uuid: l, uri: u, name: c, type: m, component: h, widgetSetting: f, isLogin: y, isLayout: b, extra: C }) => {
let T = {}, z = 0;
2024-11-19 15:49:56 +08:00
switch (m) {
case "list":
2024-12-02 10:43:52 +08:00
T.element = w.createElement(un, { component: h });
2024-11-19 15:49:56 +08:00
break;
case "fsdpf-component":
2024-12-02 10:43:52 +08:00
T.element = w.createElement(pn, { key: h, component: h, $setting: f });
2024-11-19 15:49:56 +08:00
}
2024-12-02 10:26:53 +08:00
if (C != null && C.layout) {
2024-12-02 10:43:52 +08:00
if (!r[C == null ? void 0 : C.layout]) return r[C == null ? void 0 : C.layout] = o.length, [...o, { path: "/", lazy: s(C == null ? void 0 : C.layout, {}), children: [{ path: u, ...T }] }];
z = r[C == null ? void 0 : C.layout];
2024-11-19 15:49:56 +08:00
}
2024-12-02 10:43:52 +08:00
return b && z > -1 ? (o[z].children.push({ path: u, ...T }), o) : [...o, { path: u, ...T }];
2024-11-19 15:49:56 +08:00
}, [{ path: "/", lazy: s(a, {}), children: [] }]);
2024-12-02 10:43:52 +08:00
return i.push({ index: !0, element: w.createElement(mn, { to: n, replace: !0 }) }), D(this, ve, Ba(i, t));
2024-11-19 15:49:56 +08:00
});
2024-11-20 14:11:37 +08:00
if (g(re, be)) return g(re, be);
2024-11-19 15:49:56 +08:00
}
};
2024-12-02 10:43:52 +08:00
be = new WeakMap(), Q = new WeakMap(), ke = new WeakMap(), ve = new WeakMap(), Ge = new WeakMap(), Ye = new WeakMap(), $(re, be, null), k(re, "getInstance", () => (g(re, be) || D(re, be, new re()), g(re, be)));
2024-12-02 10:26:53 +08:00
let St = re;
2024-12-02 10:43:52 +08:00
const mn = ({ to: e, replace: t }) => Da() ? w.createElement(qa, { to: e, replace: t }) : (window.document.location = e, "redirect"), pe = St.getInstance(), Ve = new Worker(new URL("/ff-worker/index.js", self.location)), Xt = { getConfigure: (e) => De.get(e), route: { redirect: (...e) => pe.redirect(...e), getPageParams: (...e) => pe.getPageParams(...e), getCurrentRoute: () => pe.getCurrentRoute() }, popup: { notification: (...e) => G.notification(...e), success: (...e) => G.success(...e), error: (...e) => G.error(...e), form: (...e) => G.form(...e), modal: (...e) => G.modal(...e), confirm: (...e) => G.confirm(...e) } };
2024-12-02 10:26:53 +08:00
var ct, Me, Se;
2024-12-02 10:43:52 +08:00
const j = class j {
2024-11-19 15:49:56 +08:00
constructor() {
k(this, "exec", (t, a = {}, n = {}, r = "") => new Promise((s, i) => {
2024-12-02 10:43:52 +08:00
const o = qt(j, ct)._++;
g(j, Me).set(o, n), j.mQueue.set(o, [s, i]), Ve.postMessage({ id: o, session: r, category: "eval", method: t, args: a });
2024-11-19 15:49:56 +08:00
}));
2024-12-02 10:26:53 +08:00
k(this, "clear", (t) => Ve.postMessage({ session: t, category: "clear" }));
2024-12-02 10:43:52 +08:00
if (g(j, Se)) return g(j, Se);
Promise.resolve().then(() => In).then((t) => {
Xt.http = t.http;
2024-12-02 10:26:53 +08:00
}), Ve.addEventListener("message", ({ data: { id: t, task_id: a, method: n, args: r, category: s, data: i, error: o, session: l } }) => {
2024-12-02 10:43:52 +08:00
if (s === "eval" && j.mQueue.has(t)) o !== null ? j.mQueue.get(t)[1](o) : j.mQueue.get(t)[0](i), g(j, Me).delete(t), j.mQueue.delete(t);
2024-11-19 15:49:56 +08:00
else if (s === "util") try {
2024-12-02 10:43:52 +08:00
const u = p.get(Xt, n.split("/")) || p.get(g(j, Me).get(a), n.split("/"));
2024-11-19 15:49:56 +08:00
if (!p.isFunction(u)) throw `${n} not found`;
Promise.resolve(Reflect.apply(u, void 0, r)).then((c) => {
2024-12-02 10:26:53 +08:00
Ve.postMessage({ id: t, task_id: a, category: s, method: n, args: r, session: l, data: c, error: null });
2024-11-19 15:49:56 +08:00
}).catch((c) => {
2024-12-02 10:26:53 +08:00
Ve.postMessage({ id: t, task_id: a, category: s, method: n, args: r, session: l, data: null, error: c });
2024-11-19 15:49:56 +08:00
});
} catch (u) {
2024-12-02 10:26:53 +08:00
Ve.postMessage({ id: t, task_id: a, category: s, method: n, args: r, session: l, data: null, error: u });
2024-11-19 15:49:56 +08:00
}
}, !1);
}
};
2024-12-02 10:43:52 +08:00
ct = new WeakMap(), Me = new WeakMap(), Se = new WeakMap(), k(j, "mQueue", /* @__PURE__ */ new Map()), $(j, ct, 0), $(j, Me, /* @__PURE__ */ new Map()), $(j, Se, null), k(j, "getInstance", () => (g(j, Se) || D(j, Se, new j()), g(j, Se)));
let Pt = j;
const Ne = Pt.getInstance(), ka = () => {
2024-12-02 10:26:53 +08:00
const e = Y(!0), [, t] = w.useReducer((a) => a + 1, 0);
2024-12-02 10:43:52 +08:00
return E(() => () => e.current = !1, []), () => e.current && t();
}, lr = (e) => {
2024-11-20 14:11:37 +08:00
const t = Y();
2024-12-02 10:43:52 +08:00
return E(() => {
2024-11-19 15:49:56 +08:00
t.current = e;
}, [e]), t.current;
2024-12-02 10:43:52 +08:00
}, cr = (e) => {
const [t, a] = N(e), n = Y(null), r = me((s, i) => {
2024-11-19 15:49:56 +08:00
n.current = i, a(s);
}, []);
2024-12-02 10:43:52 +08:00
return E(() => {
2024-11-19 15:49:56 +08:00
n.current && (n.current(t), n.current = null);
}, [t]), [t, r];
}, Ze = (e = (n) => {
}, t, a = p.isEqual) => {
2024-12-02 10:26:53 +08:00
const n = w.useRef();
a(t, n.current) || (n.current = p.cloneDeep(t)), w.useEffect(e, [n.current]);
2024-12-02 10:43:52 +08:00
}, Lt = Ze, va = (e, t = "string") => {
2024-11-19 15:49:56 +08:00
var a;
if (!Array.isArray(e)) return e;
2024-12-02 10:43:52 +08:00
for (let n = 0; n < e.length; n++) e[n].value = Z((a = e[n]) == null ? void 0 : a.value, t), e[n] && Reflect.has(e[n], "children") && (e[n].children = va(e[n].children, t));
2024-11-19 15:49:56 +08:00
return e;
2024-12-02 10:43:52 +08:00
}, dr = (e, t = "json", a = "string", n, r = null) => {
const [s] = ee.useForm(n), [i, o] = N([{ label: "无", value: "", disabled: !0 }]), l = Y([]), u = ee.useWatch((c) => l.current.length === 0 ? null : p.pick(c, l.current), s) || null;
return E(() => {
2024-11-20 15:00:20 +08:00
Array.isArray(e) ? o(e) : t === "javascript" && e ? Ne.exec(e, {}, { getFieldValue: (c) => (l.current.includes(c) || l.current.push(c), s.getFieldValue(c)), getFieldValueForBasicForm: (c) => (l.current.includes(c) || l.current.push(c), r ? r.getFieldValue(c) : s.getFieldValue(c)) }).then((c) => {
2024-11-19 15:49:56 +08:00
o(Z(c, "array"));
}) : e && o(Z(e, "array"));
2024-12-02 10:43:52 +08:00
}, [e, t, u]), va(i, a);
}, ur = (e) => {
const [t, a] = N(), n = { type: "GET" };
2024-11-19 15:49:56 +08:00
if (typeof e == "string" ? n.url = e : p.isPlainObject(e) && Object.assign(n, e), !(n != null && n.url)) throw "url is required";
2024-12-02 10:43:52 +08:00
const r = (s) => F.request(n, !1).resp((i) => (console.log("useSubscribeRequest", s), a(i), i));
2024-11-19 15:49:56 +08:00
return Ze(() => {
let s = null;
return r().then((i) => {
2024-12-02 10:43:52 +08:00
s = ga.subscribe(p.throttle(r, 180, { leading: !1, trailing: !0 }), i.res);
2024-11-19 15:49:56 +08:00
}), () => s == null ? void 0 : s();
}, n), t;
2024-12-02 10:43:52 +08:00
}, hn = (e) => {
2024-12-02 10:26:53 +08:00
const [t, a] = w.useState({ gridItems: [], hideItems: [] });
return w.useEffect(() => {
2024-12-02 10:43:52 +08:00
e && F.get(`/api/_/${e}`).then(({ pk: n, uuid: r, code: s, resource: i, align: o, cols: l, rowHeight: u, marginX: c, marginY: m, listenChangeFields: h, listenChangeFieldsFunc: f, fields: y }) => ({ pk: n, uuid: r, code: s, resource: i, align: o, cols: l, rowHeight: u, marginX: c, marginY: m, listenChangeFields: h, listenChangeFieldsFunc: f, ...y.reduce((b, C) => {
var T;
return (T = C == null ? void 0 : C.field) != null && T.hidden ? b.hides.push(C == null ? void 0 : C.field) : b.items.push(C), b;
2024-11-19 15:49:56 +08:00
}, { items: [], hides: [] }) })).then(a);
}, [e]), t;
2024-12-02 10:43:52 +08:00
}, fn = ({ max: e = 0, min: t = 0, type: a = "", message: n, pattern: r, required: s = !1, validator: i } = {}, o, l) => {
const [u, c] = N([]);
return E(() => {
2024-11-19 15:49:56 +08:00
const m = [];
if (s) {
let h = l;
switch (l) {
case "number":
case "string":
case "array":
break;
case "bool":
h = "boolean";
break;
case "json":
h = "object";
}
m.push({ type: h, required: !0, whitespace: !0, message: "该项必填" });
}
switch (a) {
case "string":
m.push({ type: a, max: e, min: t, message: n || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) });
break;
case "pattern":
m.push({ type: "string", pattern: r, message: n });
break;
case "validator":
i && m.push(({ getFieldValue: h }) => ({ validator: async (f, y) => {
2024-11-20 15:00:20 +08:00
const b = await Ne.exec(i, { value: y, fieldName: o }, { getFieldValue: h });
2024-11-19 15:49:56 +08:00
return p.isString(b) && b ? Promise.reject(b) : p.isBoolean(b) && !b ? Promise.reject(n) : Promise.resolve();
} }));
}
c(m);
}, [e, t, a, n, r, s, i]), u;
2024-12-02 10:43:52 +08:00
}, yn = (e, t, a) => {
const [n, r] = N(null);
return E(() => {
2024-11-19 15:49:56 +08:00
const { initDataUri: s = `/api/${e}`, initDataMethod: i = "GET" } = a || {};
2024-12-02 10:43:52 +08:00
t && F.request({ method: i, url: p.trimEnd(`${s}/${t}`, "/") }).then((o) => {
2024-11-19 15:49:56 +08:00
r(o);
});
}, [e, t, a]), n;
2024-12-02 10:43:52 +08:00
}, wn = (e, t, a, n = {}) => {
const r = ka(), s = Y(!0), i = Y([]), [o, l] = N(a), u = ee.useWatch((c) => JSON.stringify(p.pick(c, i.current)), t) || "{}";
return E(() => {
2024-11-20 15:00:20 +08:00
e && Ne.exec(e, n, { getFieldValue: p.wrap(t.getFieldValue, (c, m) => (i.current.some((h) => p.isEqual(h, m)) || (i.current.push(m), r()), c(m))), isFieldTouched: t.isFieldTouched, isFieldsTouched: t.isFieldsTouched }).then((c) => s.current && l(c));
2024-12-02 10:43:52 +08:00
}, [e, u, t, n]), E(() => () => s.current = !1, []), o;
}, gr = ({ value: e, onChange: t }, a = null) => {
2024-11-20 15:00:20 +08:00
const n = Y(), [r] = ee.useForm(a);
2024-12-02 10:26:53 +08:00
return Lt(() => {
2024-11-20 14:11:37 +08:00
p.isEqual(n.current, e) || r.setFieldsValue(e);
2024-12-02 10:43:52 +08:00
}, [e]), E(() => () => r.resetFields(), []), [ie(() => r.__INTERNAL__ ? r : { ...r, __INTERNAL__: {} }, [r]), (s, i) => {
2024-11-20 14:11:37 +08:00
n.current = i, t(i);
}];
2024-12-02 10:43:52 +08:00
}, Cn = ({ type: e, initialValue: t, initialValueLanguage: a, onChange: n, form: r }) => {
const s = wn(a == "javascript" && t, r, a == "javascript" ? void 0 : t, {});
return E(() => {
2024-11-19 15:49:56 +08:00
a == "javascript" ? n(Z(s, e)) : t && n(Z(t, e));
}, [e, t, s]), null;
2024-12-02 10:43:52 +08:00
}, bn = ({ widget: e = "Input", widgetPrefix: t = "@pkg/ff/grid-layout-forms", widgetDecorator: a, subWidgets: n, basicForm: r, ...s }) => {
const i = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [o, l] = N();
return E(() => {
i && X.getWidgetComponent(i).then(({ defaultProps: u = {}, default: c }) => ({ default: Sa(c, u, r) })).catch((u) => ({ default: () => `${u}` })).then((u) => l(w.createElement(u.default, s)));
2024-12-02 10:26:53 +08:00
}, [i]), o && w.cloneElement(o, s);
2024-12-02 10:43:52 +08:00
}, Sa = (e, t = {}, a = null) => (n) => {
const { type: r, code: s, label: i, noStyle: o, placeholder: l, extras: u, validators: c, help: m, isVirtual: h, $isReserved: f, initialValue: y, initialValueLanguage: b, convertJs: C, convertJsSetting: T, widgetPerfix: z, boxStyle: U, widgetDecorator: B, subWidgets: q, ...S } = { ...t, ...n }, I = fn(c || {}, s, r), L = { label: i, noStyle: o, colon: !1, layout: "vertical" }, W = { placeholder: l, ...S }, _ = me((A) => A == null ? void 0 : Z(A, r), [r]);
return d(ra, { name: s, rules: I, initialValue: _(y), normalize: _, children: (A, v, oe) => {
2024-12-02 10:26:53 +08:00
var V;
2024-12-02 10:43:52 +08:00
return d(e, { type: r, rcform: oe, itemProps: { validateStatus: v.errors.length > 0 ? "error" : "success", tooltip: m, help: v.errors.length > 0 ? v.errors.join("、") : null, required: ((V = I == null ? void 0 : I[0]) == null ? void 0 : V.required) || !1, ...L }, fieldProps: { ...W, ...A }, $setting: u || {} });
2024-11-19 15:49:56 +08:00
} });
2024-12-02 10:26:53 +08:00
}, Ot = ({ cols: e = 24, rowHeight: t = 16, itemMargin: a = [8, 16], containerPadding: n = [0, 0], fields: r = [], children: s, basicForm: i = null }) => {
2024-12-02 10:43:52 +08:00
const o = Ca(r, Sa, "@pkg/ff/grid-layout-forms");
return x("div", { className: "ff-grid-layout-form", style: { "--grid-layout-item-margin-x": `${(a == null ? void 0 : a[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(a == null ? void 0 : a[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(n == null ? void 0 : n[0]) || 0}px`, "--grid-layout-container-padding-x": `${(n == null ? void 0 : n[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: [o, s && w.cloneElement(s, { cols: e, rowHeight: t, itemMargin: a, containerPadding: n, fields: r })] });
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:43:52 +08:00
Ot.propTypes = { fields: O.array };
const kn = (Qt = Ot, ({ code: e, layout: t, name: a, primaryKey: n = 0, style: r = {}, formProps: s = {}, form: i, isPreview: o = !1, className: l, onFinish: u, onValuesChange: c = () => {
2024-11-19 15:49:56 +08:00
}, ...m }) => {
2024-12-02 10:43:52 +08:00
const { align: h, autoComplete: f, resource: y, items: b, hides: C, rowHeight: T, marginX: z, marginY: U, cols: B, listenChangeFields: q, listenChangeFieldsFunc: S, pk: I, uuid: L } = hn(e), [W] = ee.useForm(i), _ = ie(() => [{ name: "__PK__", value: I }, { name: "__PROPS__", value: s }, { name: "__RESOURCE__", value: y }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: L }, { name: "__PRIMARY_KEY__", value: n }], [I, e, L, y, n, s]);
return x(ee, { className: l, name: a || e, layout: t || h, fields: _, form: W, autoComplete: f, style: { ...r, position: "relative" }, onFinish: u, onValuesChange: (A, v) => (({ changedValues: oe, allValues: V, listenChangeFields: he, listenChangeFieldsFunc: $e, onValuesChange: dt, code: ut }) => {
dt(oe, V), $e && Array.isArray(he) && Ne.exec($e, { changedValues: oe, allValues: V }, { getFieldValue: W.getFieldValue, setFieldValue: W.setFieldValue, setFieldsValue: W.setFieldsValue, isFieldTouched: W.isFieldTouched, isFieldsTouched: W.isFieldsTouched });
})({ changedValues: A, allValues: v, listenChangeFields: q, listenChangeFieldsFunc: S, onValuesChange: c, code: e }), children: [d(Qt, { ...m, form: W, code: e, fields: b, cols: B, rowHeight: T, itemMargin: [z, U] }), C == null ? void 0 : C.map((A) => {
2024-11-19 15:49:56 +08:00
var v;
2024-12-02 10:43:52 +08:00
return d(ra, { name: A.code, children: d(Cn, { form: W, name: A.code, type: A.type, initialValue: A.initialValue, initialValueLanguage: (v = A.extras) == null ? void 0 : v.initialValueLanguage }) }, JSON.stringify(A.code));
2024-11-19 15:49:56 +08:00
})] }, e);
});
2024-12-02 10:43:52 +08:00
var Qt;
const Pa = ({ $setting: e, $close: t, extras: a, code: n, primaryKey: r, ...s }) => {
const [i] = ee.useForm(), o = yn(n, r, e);
return E(() => {
2024-11-19 15:49:56 +08:00
o && i.setFieldsValue(o);
2024-12-02 10:43:52 +08:00
}, [o]), d(K, { actions: x(w.Fragment, { children: [d(P, { name: "保存", type: "primary", widget: () => {
2024-11-19 15:49:56 +08:00
const l = i.getFieldValue("__RESOURCE__"), { initDataUri: u = `/api/${n}` } = e || {};
2024-12-02 10:43:52 +08:00
i.validateFields(!0).then((c) => l ? p.pick(c, [l]) : c).then((c) => F.post(r ? `${u}/${r}` : `${u}`, c).msg(t)).catch(() => G.error("请先完善表单信息", { duration: 2e3 }));
} }), d(P, { name: "取消", widget: () => t(!1) })] }), extras: a, children: d(kn, { form: i, code: n, primaryKey: r, ...s }) });
}, vn = (e, t, a, { isReplaceRouteHistory: n = !1 } = {}) => pe.redirect(a, t, { replace: n }), Zt = (e, t, a, { status: { loading: n, disabled: r }, setStatus: s }) => {
2024-11-19 15:49:56 +08:00
const i = { loading: (o) => o === void 0 ? n : s((l) => ({ ...l, loading: o })), disabled: (o) => o === void 0 ? r : s((l) => ({ ...l, disabled: o })) };
2024-11-20 15:00:20 +08:00
return p.isFunction(a) ? a.call(null, { ...t, ...i }) : p.isString(a) && a ? Ne.exec(a, t, i) : null;
2024-12-02 10:43:52 +08:00
}, ea = (e, t, a, n, r) => p.isString(a) && a ? X.getWidgetComponent(a).then(({ default: s }) => G.modal(s, { ...t, $setting: n }, r != null && r.title ? { ...r, title: p.template(r.title)(e) } : r)).catch((s) => {
2024-11-20 15:00:20 +08:00
G.error(a, { content: s.toString() });
2024-12-02 10:43:52 +08:00
}) : G.modal(a, { ...t, $setting: n }, r != null && r.title ? { ...r, title: p.template(r.title)(e) } : r), Sn = (e, t, a, n, r) => G.modal(Pa, { ...t, $setting: n, code: a }, r != null && r.title ? { ...r, title: p.template(r.title)(e) } : r), Pn = (e, t, a, n, r) => G.modal(Ft, { base62params: t, $setting: n, listCode: a }, r != null && r.title ? { ...r, title: p.template(r.title)(e) } : r), Nn = ({ widget: e, widgetType: t, widgetData: a, widgetProps: n, widgetSetting: r, widgetContainerProps: s }, { onAfterClick: i, onBeforeClick: o }) => {
const l = Xe(Oe), [u, c] = N({ leading: !0, trailing: !1 }), m = ie(() => {
2024-11-19 15:49:56 +08:00
switch (t) {
case "redirect":
2024-12-02 10:43:52 +08:00
return p.partialRight(vn, e, r);
2024-11-19 15:49:56 +08:00
case "func":
2024-12-02 10:43:52 +08:00
return p.partialRight(Zt, (r == null ? void 0 : r.code) ?? e, { status: u, setStatus: c });
2024-11-19 15:49:56 +08:00
case "fsdpf-component":
2024-12-02 10:43:52 +08:00
return p.partialRight(ea, e, r, s);
2024-11-19 15:49:56 +08:00
case "grid-layout-form":
2024-12-02 10:26:53 +08:00
return p.partialRight(Sn, e, r, s);
2024-12-02 10:43:52 +08:00
case "data-list":
return p.partialRight(Pn, e, r, s);
2024-11-19 15:49:56 +08:00
default:
2024-12-02 10:43:52 +08:00
if (At(e) || w.isValidElement(e)) return p.partialRight(ea, e, r, s);
if (p.isFunction(e)) return p.partialRight(Zt, (r == null ? void 0 : r.code) || e, { status: u, setStatus: c });
2024-11-19 15:49:56 +08:00
}
return (...h) => console.error("useButton unknown widgetType", t, ...h);
}, [e, t]);
2024-12-02 10:43:52 +08:00
return [p.debounce((h) => (o == null || o(h), Promise.resolve(la(n, h, { list: l })).then((f) => m(h, { ...a, ...f })).then((f) => i == null ? void 0 : i(f)).catch(console.error)), 300, { leading: !0, trailing: !1 }), u];
}, ta = /* @__PURE__ */ new Set(), Nt = (e = [], t = 0) => {
2024-11-19 15:49:56 +08:00
const a = e[t];
2024-12-02 10:43:52 +08:00
if (a.length && !ta.has(a)) {
2024-11-19 15:49:56 +08:00
const n = document.createElement("script");
n.setAttribute("src", a), n.setAttribute("data-namespace", a), e.length > t + 1 && (n.onload = () => {
2024-12-02 10:26:53 +08:00
Nt(e, t + 1);
2024-11-19 15:49:56 +08:00
}, n.onerror = () => {
2024-12-02 10:26:53 +08:00
Nt(e, t + 1);
2024-12-02 10:43:52 +08:00
}), ta.add(a), document.body.appendChild(n);
2024-11-19 15:49:56 +08:00
}
2024-12-02 10:43:52 +08:00
}, $t = ({ className: e, type: t, style: a = {}, ...n }) => d("span", { role: "img", className: R("ff-iconfont", e), style: a, ...n, children: d("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: d("use", { xlinkHref: `#${t}` }) }) });
$t.propTypes = { className: O.string, type: O.string.isRequired, style: O.object }, $t.init = Nt;
const et = (e) => function({ className: t, children: a, name: n, icon: r, type: s = "default", iconPosition: i = "start", noAuthType: o, onAfterClick: l, onBeforeClick: u, data: c, loading: m, disabled: h, tooltip: f, popConfirm: y, widget: b, widgetType: C, widgetData: T, widgetProps: z, widgetSetting: U, widgetContainerProps: B, ...q }) {
const S = { type: "primary", className: R("ff-button", t), iconPosition: i };
s === "danger" ? S.danger = !0 : s === "default" && (S.type = s), e === "link" || e === "dashed" ? (S.type = e, s === "default" && (S.className = R(S.className, "ff-default"))) : e !== "circle" && e !== "round" || (S.shape = e), r && (S.icon = d($t, { type: r }));
const [I, L] = N(!1), [W, { disabled: _, loading: A }] = Nn({ widget: b, widgetType: C, widgetData: T, widgetProps: z, widgetSetting: U, widgetContainerProps: B }, { onAfterClick: l, onBeforeClick: u });
return d(Aa, { okText: "确定", cancelText: "取消", ...y || {}, disabled: _ || h, open: I, onOpenChange: (v) => {
if (!v) return L(v);
y ? L(v) : W(c);
2024-11-19 15:49:56 +08:00
}, onConfirm: () => {
2024-12-02 10:43:52 +08:00
W(c);
2024-11-19 15:49:56 +08:00
}, onClick: (v) => {
v.stopPropagation();
2024-12-02 10:43:52 +08:00
}, children: d(ja, { ...f, title: I ? null : f == null ? void 0 : f.title, trigger: ["hover", "click"], children: d(ft, { loading: A || m, disabled: _ || h, ...S, ...q, children: a || n }) }) });
}, P = et("default"), $n = et("link"), xn = et("circle"), En = et("round"), Tn = et("dashed"), aa = ({ data: e, widget: t, widgetType: a = "fsdpf-component", children: n, widgetData: r, widgetProps: s, widgetSetting: i, widgetContainerProps: o }) => {
const l = Xe(Oe), [u, c] = N(!1), [m, h] = N("hover"), [f, y] = N({}), [b, C] = N(), { placement: T, align: z, arrow: U = { pointAtCenter: !0 }, getPopupContainer: B, ...q } = o || {};
E(() => {
a == "grid-layout-form" ? C(w.createElement(Pa, { ...r, $setting: i, code: t })) : a == "data-list" ? C(w.createElement(Ft, { base62params: e, $setting: i, listCode: t })) : p.isString(t) ? X.getWidgetComponent(t).then(({ default: L }) => {
C(w.createElement(L, { ...r, $setting: i }));
}).catch((L) => C(L.toString())) : At(t) ? C(w.createElement(t, { ...r, $setting: i })) : w.isValidElement(t) && C(w.cloneElement(t, { ...r, $setting: i }));
}, [t, a, r]), E(() => {
Promise.resolve(la(s, e, { list: l })).then(y);
2024-11-19 15:49:56 +08:00
}, [s, e]);
2024-12-02 10:43:52 +08:00
const S = (L) => {
c(L), !L && h("hover");
}, I = (L) => {
2024-11-19 15:49:56 +08:00
c(!0), h("click");
};
2024-12-02 10:43:52 +08:00
return d(Ia, { zIndex: 1080, placement: T, onPopupClick: I, onClick: I, open: u, align: z, arrow: U, trigger: m, getPopupContainer: B, content: d(Fn, { ...q, children: b && w.cloneElement(b, { ...f, $close: () => S(!1) }) }), children: n, onOpenChange: S });
}, Fn = ({ title: e, className: t, children: a, width: n, height: r, ...s }) => {
const [i, o] = N({}), l = me((m, h) => o((f) => ({ ...f, [m]: h })), []), u = me((m) => o((h) => ({ ...h, [m]: void 0 })), []), c = e ? w.createElement("div", { className: "ff-popup-title" }, e) : i == null ? void 0 : i.title;
return d(Qe.Provider, { value: { ele: i, mount: l, unmount: u }, children: x("div", { className: R("ff-popup ff-popover", t), style: { width: n, height: r }, ...s, children: [x("div", { className: "ff-popup-header", children: [c, i == null ? void 0 : i["sub-title"]] }), a, x("div", { className: "ff-popup-footer", children: [i == null ? void 0 : i.extras, i == null ? void 0 : i.actions] })] }) });
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:43:52 +08:00
aa.propTypes = { widgetType: O.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }, P.propTypes = { type: O.oneOf(["primary", "default", "danger", ""]), name: O.string, icon: O.string, iconPosition: O.oneOf(["start", "end"]), data: O.any, widget: O.any, widgetType: O.oneOf(["destroy", "redirect", "func", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: O.object, widgetProps: O.object, widgetSetting: O.object, widgetContainerProps: O.object }, P.Link = $n, P.Link.defaultProps = P.defaultProps, P.Link.propTypes = P.propTypes, P.Circle = xn, P.Circle.defaultProps = P.defaultProps, P.Circle.propTypes = P.propTypes, P.Round = En, P.Round.defaultProps = P.defaultProps, P.Round.propTypes = P.propTypes, P.Dashed = Tn, P.Dashed.defaultProps = P.defaultProps, P.Dashed.propTypes = P.propTypes, P.Popover = aa;
const Rn = ({ fields: e, formProps: t, $close: a }) => {
2024-11-20 15:00:20 +08:00
const [n] = ee.useForm(), r = ie(() => [{ name: "__PROPS__", value: t }], [t]);
2024-12-02 10:43:52 +08:00
return d(K, { actions: x(w.Fragment, { children: [d(P, { name: "取消", widget: () => a(!1) }), d(P, { name: "确定", type: "primary", widget: () => n.validateFields(!0).then(a) })] }), children: d(ee, { fields: r, form: n, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: s, ...i }) => d(bn, { code: s, ...i }, s)) }) });
}, Ln = ({ className: e, $close: t, children: a, title: n, subTitle: r, actions: s, extras: i, zIndex: o, ...l }) => x(Ka, { ...l, prefixCls: "ff-drawer", className: R("ff-popup", e), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (u) => ({ motionAppear: !0, motionName: `panel-motion-${u}` }), children: [x("div", { className: "ff-popup-header", children: [d("button", { "aria-label": "Close", className: "ff-popup-close", onClick: l.onClose, children: d(Tt, { type: "close" }) }), n, r] }), d("div", { className: "ff-popup-body", children: a }), x("div", { className: "ff-popup-footer", children: [i, s] })] }), On = ({ className: e, $close: t, $event: a, children: n, title: r, subTitle: s, actions: i, extras: o, zIndex: l, placement: u, ...c }) => {
2024-11-19 15:49:56 +08:00
const m = (a == null ? void 0 : a.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: a == null ? void 0 : a.pageX, y: a == null ? void 0 : a.pageY } };
2024-12-02 10:43:52 +08:00
return d(_a, { ...c, ...m, prefixCls: "ff-modal", modalRender: () => x("div", { className: R("ff-modal-content ff-popup", e), children: [x("div", { className: "ff-popup-header", children: [d("button", { "aria-label": "Close", className: "ff-popup-close", onClick: c.onClose, children: d(Tt, { type: "close" }) }), r, s] }), d("div", { className: "ff-popup-body", children: n }), x("div", { className: "ff-popup-footer", children: [o, i] })] }) });
}, Na = ({ placement: e, $close: t, $event: a, children: n, title: r, ...s }) => {
const [i, o] = N({}), [l, u] = N(!0), c = me((y, b) => o((C) => ({ ...C, [y]: b })), []), m = me((y) => o((b) => ({ ...b, [y]: void 0 })), []);
let h = { ...s, className: i.rootClassName, title: i.title || r && w.createElement("div", { className: R("ff-popup-title") }, r), subTitle: i["sub-title"], actions: i.actions, extras: i.extras, children: n, $close: t, $event: a, onClose: () => u(!1) };
2024-11-19 15:49:56 +08:00
const f = () => {
t(!1);
};
2024-12-02 10:43:52 +08:00
return d(Qe.Provider, { value: { ele: i, mount: c, unmount: m }, children: e && e !== "center" ? d(Ln, { ...h, placement: e, open: l, afterOpenChange: (y) => !y && f() }) : d(On, { ...h, visible: l, afterClose: f }) });
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:43:52 +08:00
Na.propTypes = { placement: O.oneOf(["center", "left", "top", "right", "bottom"]) };
2024-11-19 15:49:56 +08:00
const J = () => {
2024-12-02 10:43:52 +08:00
const [e, t] = Ha({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (s) => {
2024-11-19 15:49:56 +08:00
const { offsetHeight: i } = s;
return { height: i };
2024-12-02 10:26:53 +08:00
}, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, a] = w.useReducer((s) => s + 1, 0);
2024-12-02 10:43:52 +08:00
E(() => {
2024-11-19 15:49:56 +08:00
J.$onClick = n, J.$queue.forEach(([s, i, o], l, u) => {
r([i, o], ...s), delete u[l];
});
}, []);
const n = (s, i = {}, o = {}) => new Promise((l, u) => r([l, u], s, i, o)), r = ([s, i], o, l = {}, u = {}) => {
const c = J.$index++, m = (h) => ((f, y) => (J.$popups.delete(f), a(), y == null ? void 0 : y()))(c, () => s(h));
2024-12-02 10:43:52 +08:00
if (o === oa) return e.open({ ...u, key: c, content: w.createElement(o, { ...l, $close: () => e.close(c) }) });
J.$popups.set(c, w.createElement(Na, { zIndex: c, maskClosable: !1, $event: l == null ? void 0 : l.$event, ...u, key: c, $close: m }, w.isValidElement(o) ? w.cloneElement(o, { ...l, $close: m }) : o != null && o.name || Ht.isForwardRef(o) || (o == null ? void 0 : o.$$typeof) === Ht.ForwardRef ? w.createElement(o, { ...l, $close: m }) : o)), a();
2024-11-19 15:49:56 +08:00
};
2024-12-02 10:43:52 +08:00
return x(w.Fragment, { children: [Array.from(J.$popups).map(([s, i]) => i), t] });
2024-11-19 15:49:56 +08:00
};
J.$popups = /* @__PURE__ */ new Map(), J.$index = 0, J.$queue = [], J.$onClick = (...e) => new Promise((t, a) => {
J.$queue.push([e, t, a]);
});
2024-12-02 10:43:52 +08:00
const na = (e, t, a = {}) => J.$onClick(e, t, a), mt = (e, { showProgress: t, duration: a, ...n } = { duration: 1.5 }) => J.$onClick(oa, { content: e, ...n }, { showProgress: t, duration: a }), G = { modal: na, confirm: (e, t = {}) => J.$onClick(Ga, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, a = {}) => na(Rn, { formProps: a, fields: e }, { placement: "center", ...t }).then((n) => {
2024-11-19 15:49:56 +08:00
if (n === !1) throw !1;
return n;
2024-12-02 10:26:53 +08:00
}), notification: mt, success: (e, t = { duration: 1.5 }) => mt(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => mt(e, { ...t, className: "ff-notification-error", icon: "close" }) };
Ue.configure({ showSpinner: !1 }), Be.interceptors.request.use((e) => {
2024-11-19 15:49:56 +08:00
e.headers.Platform = "web", e.headers.SaaS = window.localStorage.getItem("SaaS");
const t = window.localStorage.getItem(nt);
2024-12-02 10:26:53 +08:00
return e.headers.Authorization = t ? `Bearer ${t} ` : void 0, Ue.inc(), e;
}, (e) => (Ue.done(), Promise.reject({ code: -1, msg: e }))), Be.interceptors.response.use(({ data: e, headers: t }) => (Ue.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) {
return Ue.done(), Promise.reject(e.message);
}), window.addEventListener("unhandledrejection", yt.onUnhandledRejection), yt.onMsg = (e, t) => G[[0, 1].includes(e) ? "success" : "error"](t).then(() => e === 20300 && pe.redirect(De.get("Common.WEBSITE_LOGIN_PAGE")));
const xt = { appUrl: "", init: (e, t, a) => {
xt.appUrl = a, Be.defaults.baseURL = a, Be.defaults.timeout = 15e3, Object.assign(xt, new yt(e, t, Be));
2024-12-02 10:43:52 +08:00
} }, F = xt;
2024-12-02 10:26:53 +08:00
class Vt extends Error {
2024-11-19 15:49:56 +08:00
constructor(t, a) {
2024-12-02 10:26:53 +08:00
super(a), Error.captureStackTrace && Error.captureStackTrace(this, Vt), !a instanceof qe && (this.name = `${t} Error Runtime`);
2024-11-19 15:49:56 +08:00
}
}
class qe extends Error {
constructor(t, ...a) {
super(...a), Error.captureStackTrace && Error.captureStackTrace(this, qe), this.name = `${t} Not Found`;
}
}
2024-12-02 10:26:53 +08:00
const ht = "mine", nt = "token";
var Pe, ze;
2024-11-20 14:11:37 +08:00
const se = class se {
2024-11-19 15:49:56 +08:00
constructor() {
2024-12-02 10:43:52 +08:00
$(this, ze, /* @__PURE__ */ new Map());
k(this, "setVendor", (t, a) => g(this, ze).set(t, new sa(a, async (n, r) => {
2024-11-19 15:49:56 +08:00
var i, o;
if (!(n != null && n.default)) throw "@pkg not found";
let s = () => r;
switch ("function") {
case typeof (s = (i = n.default) == null ? void 0 : i[`./${r}/index.jsx`]):
case typeof (s = (o = n.default) == null ? void 0 : o[`./${r}/index.js`]):
return s();
}
throw new qe(r);
})));
k(this, "getWidgetComponent", async (t) => {
if (!t) throw "getWidgetComponent widget is required";
if (t != null && t.startsWith("blob:") || t != null && t.startsWith("http:") || t != null && t.startsWith("https:")) return await import(t);
const [, a] = t == null ? void 0 : t.split("@pkg/");
if (!a) throw new qe(t);
try {
2024-12-02 10:43:52 +08:00
return g(this, ze).has("pkg") ? await g(this, ze).get("pkg").get(a) : await import(`${F.appUrl}/api/pkg-import/web?name=${t}`);
2024-11-19 15:49:56 +08:00
} catch (n) {
2024-12-02 10:26:53 +08:00
throw new Vt(t, n);
2024-11-19 15:49:56 +08:00
}
});
2024-12-02 10:43:52 +08:00
k(this, "getRoutes", () => F.get("/api/my-router").then((t) => [...t, { uuid: "data-list-setting", isLayout: !0, uri: "/data-list-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/DataListSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-setting", isLayout: !0, uri: "/grid-layout-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-form-setting", isLayout: !0, uri: "/grid-layout-form-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutFormSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "resource-api-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ResourceApiSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "charts-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ChartsSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "fsm-setting", isLayout: !0, uri: "/fsm-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/FsmSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "component-setting", isLayout: !0, uri: "/component-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ComponentSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "login", uri: "/login", name: "登录", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/Login" }, { uuid: "not-found", uri: "*", name: "Not Found", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/NotFound" }].map(({ uuid: a, ...n }) => [a, { uuid: a, ...n }])).then((t) => new Map(t)));
k(this, "getMenus", () => F.get("/api/my-menu"));
k(this, "getConfigure", () => F.get("api/init-configure"));
k(this, "getWidgetOperationAuth", () => F.get("/api/init-widget-operation-auth").then((t) => t.reduce((a, { uuid: n, auth: r }) => [...a, [n, r]], [])));
k(this, "getPhoneNumber", (t) => F.get(`/api/user-wx-phone-number/${t}`));
2024-11-19 15:49:56 +08:00
k(this, "getUserToken", () => {
const t = window.localStorage.getItem(nt);
if (!t) return "";
const a = t.split(".");
if (!Array.isArray(a) || a.length !== 3) throw "登录令牌无效!";
const { iat: n } = JSON.parse(window.atob(a[1]));
if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - n > 2592e3) throw "登录令牌已过期, 请重新登录!";
return t;
});
k(this, "checkUserToken", () => {
try {
return !!this.getUserToken();
} catch {
return !1;
}
});
k(this, "getUserInfo", (t = !0) => {
var a;
try {
const n = this.getUserToken();
if (!n) return Promise.resolve(null);
2024-12-02 10:43:52 +08:00
const { iat: r } = JSON.parse(window.atob((a = n == null ? void 0 : n.split(".")) == null ? void 0 : a[1])), { iat: s, ...i } = F.decode(window.localStorage.getItem(ht) || "", {});
return s === r ? Promise.resolve(i) : F.get("/api/mine-info").then(({ User: o = null }) => (window.localStorage.setItem(ht, F.encode({ ...o, iat: r })), o));
2024-11-19 15:49:56 +08:00
} catch (n) {
console.error(n), t && Popup.error("请登录").then(logout);
}
return Promise.resolve(null);
});
2024-12-02 10:43:52 +08:00
k(this, "login", (t, a, n = {}) => F.post("/api/user-token", { username: t, passwd: Ja.hash(a), platform: "web", ...n }).then(({ token: r }) => (window.localStorage.setItem(nt, r), r)));
2024-11-19 15:49:56 +08:00
k(this, "logout", () => {
2024-12-02 10:26:53 +08:00
window.localStorage.removeItem(ht), window.localStorage.removeItem(nt);
2024-11-19 15:49:56 +08:00
});
2024-11-20 15:00:20 +08:00
if (g(se, Pe)) return g(se, Pe);
2024-11-19 15:49:56 +08:00
}
};
2024-12-02 10:43:52 +08:00
Pe = new WeakMap(), ze = new WeakMap(), $(se, Pe, null), k(se, "getInstance", () => (g(se, Pe) || D(se, Pe, new se()), g(se, Pe)));
2024-12-02 10:26:53 +08:00
let Et = se;
2024-12-02 10:43:52 +08:00
const X = Et.getInstance(), Vn = w.createContext({ user: {}, initUser: () => {
}, initUserComplete: !1 }), An = w.createContext({ set: () => {
2024-11-19 15:49:56 +08:00
}, get: () => {
}, assign: () => {
}, currentRoute: () => {
2024-12-02 10:43:52 +08:00
} }), At = (e) => !!(e != null && e.name) && (e.prototype instanceof w.Component || /^[A-Z]/.test(e.name)), jn = (e, t) => {
2024-11-19 15:49:56 +08:00
if (!e || typeof window > "u") return;
let a = document.querySelector(`style[ff-style-token="${t}"]`);
return a ? (a.innerHTML = e, e) : (a = document.createElement("style"), a.setAttribute("ff-style-token", t), a.setAttribute("type", "text/css"), a.innerHTML = e, document.head.appendChild(a), e);
2024-12-02 10:43:52 +08:00
}, In = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: Vn, AppGlobalParamsContext: An, cache: sa, configure: De, default: X, func: Ne, http: F, insertStyle: jn, isReactComponent: At, route: pe }, Symbol.toStringTag, { value: "Module" })), Mn = (e, t, a = "children") => {
2024-11-19 15:49:56 +08:00
if (p.isEmpty(e)) return {};
const n = p.find(e, ["value", t]);
if (!p.isEmpty(n)) return n;
const r = e.length;
for (let s = 0; s < r; s++) {
2024-12-02 10:43:52 +08:00
const { [a]: i } = e[s], o = Mn(i, t, a);
2024-11-19 15:49:56 +08:00
if (!p.isEmpty(o)) return o;
}
return {};
};
export {
2024-12-02 10:43:52 +08:00
tr as $,
cr as A,
2024-11-19 15:49:56 +08:00
Ze as B,
2024-12-02 10:26:53 +08:00
Lt as C,
bt as D,
2024-12-02 10:43:52 +08:00
dr as E,
ur as F,
ir as G,
sn as H,
kn as I,
2024-12-02 10:26:53 +08:00
Ot as J,
2024-12-02 10:43:52 +08:00
bn as K,
Pa as L,
hn as M,
fn as N,
yn as O,
wn as P,
gr as Q,
ga as R,
2024-12-02 10:26:53 +08:00
$t as S,
2024-12-02 10:43:52 +08:00
P as T,
Ya as U,
Nn as V,
2024-11-20 14:11:37 +08:00
K as W,
Qe as X,
2024-12-02 10:43:52 +08:00
ia as Y,
2024-11-20 14:11:37 +08:00
J as Z,
2024-11-20 15:00:20 +08:00
G as _,
2024-12-02 10:43:52 +08:00
pa as a,
ar as a0,
nr as a1,
2024-11-20 14:11:37 +08:00
X as a2,
2024-12-02 10:26:53 +08:00
At as a3,
2024-12-02 10:43:52 +08:00
jn as a4,
F as a5,
sa as a6,
2024-11-20 14:11:37 +08:00
De as a7,
2024-11-20 15:00:20 +08:00
Ne as a8,
pe as a9,
2024-12-02 10:43:52 +08:00
Vn as aa,
An as ab,
Mn as ac,
ya as b,
ba as c,
or as d,
Ca as e,
tn as f,
la as g,
2024-12-02 10:26:53 +08:00
Rt as h,
2024-12-02 10:43:52 +08:00
ma as i,
ha as j,
fa as k,
2024-12-02 10:26:53 +08:00
Ft as l,
2024-11-19 15:49:56 +08:00
Oe as m,
2024-12-02 10:43:52 +08:00
rn as n,
dn as o,
Qa as p,
en as q,
2024-12-02 10:26:53 +08:00
pt as r,
2024-12-02 10:43:52 +08:00
Xa as s,
2024-11-19 15:49:56 +08:00
Z as t,
2024-12-02 10:43:52 +08:00
wa as u,
rr as v,
sr as w,
2024-12-02 10:26:53 +08:00
kt as x,
2024-12-02 10:43:52 +08:00
ka as y,
lr as z
2024-11-19 15:49:56 +08:00
};