detail
This commit is contained in:
parent
f1cf77ef34
commit
403ea83de2
|
|
@ -8,10 +8,12 @@ export const Detail: FC<{
|
||||||
detail: (
|
detail: (
|
||||||
item: any
|
item: any
|
||||||
) => Record<string, [string, string, string | (() => void)]>;
|
) => Record<string, [string, string, string | (() => void)]>;
|
||||||
on_load: (arg: {
|
on_load:
|
||||||
params: any;
|
| Record<string, any>
|
||||||
bind: (fn: (on_load: any) => void) => void;
|
| ((arg: {
|
||||||
}) => Promise<any>;
|
params: any;
|
||||||
|
bind: (fn: (on_load: any) => void) => void;
|
||||||
|
}) => Promise<any>);
|
||||||
mode: "standard" | "compact" | "inline";
|
mode: "standard" | "compact" | "inline";
|
||||||
}> = ({ detail, mode, on_load }) => {
|
}> = ({ detail, mode, on_load }) => {
|
||||||
const local = useLocal({
|
const local = useLocal({
|
||||||
|
|
@ -34,6 +36,11 @@ export const Detail: FC<{
|
||||||
local.mode = mode;
|
local.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof on_load === "object") {
|
||||||
|
local.detail = detail(on_load);
|
||||||
|
local.status = "ready";
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (local.status === "init" && typeof on_load === "function") {
|
if (local.status === "init" && typeof on_load === "function") {
|
||||||
local.status = "loading";
|
local.status = "loading";
|
||||||
|
|
@ -79,7 +86,7 @@ export const Detail: FC<{
|
||||||
}
|
}
|
||||||
let values = {};
|
let values = {};
|
||||||
|
|
||||||
if (!isEditor && typeof on_load === "function") {
|
if (!isEditor) {
|
||||||
values = local.detail || {};
|
values = local.detail || {};
|
||||||
} else {
|
} else {
|
||||||
values = detail(null);
|
values = detail(null);
|
||||||
|
|
@ -133,9 +140,13 @@ export const Detail: FC<{
|
||||||
(typeof data === "object" && !Array.isArray(data))
|
(typeof data === "object" && !Array.isArray(data))
|
||||||
)
|
)
|
||||||
return null;
|
return null;
|
||||||
const [label, sample, link] = data;
|
let [label, sample, link] = data;
|
||||||
|
|
||||||
if (typeof link === 'string') {
|
if (typeof on_load === "object" && on_load[name]) {
|
||||||
|
sample = on_load[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof link === "string") {
|
||||||
preload(link);
|
preload(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue