fix
This commit is contained in:
parent
af78d0459b
commit
073a8cc557
|
|
@ -20,10 +20,12 @@ import { EdPopScript } from "./panel/popup/script/pop-script";
|
||||||
import { EdPopSite } from "./panel/popup/site/site-popup";
|
import { EdPopSite } from "./panel/popup/site/site-popup";
|
||||||
import { iconVSCode } from "./panel/popup/code/icons";
|
import { iconVSCode } from "./panel/popup/code/icons";
|
||||||
import { isLocalhost } from "../../utils/ui/is-localhost";
|
import { isLocalhost } from "../../utils/ui/is-localhost";
|
||||||
|
import { w } from "../../utils/types/general";
|
||||||
|
|
||||||
export const EdBase = () => {
|
export const EdBase = () => {
|
||||||
const p = useGlobal(EDGlobal, "EDITOR");
|
const p = useGlobal(EDGlobal, "EDITOR");
|
||||||
|
|
||||||
|
w.editorRender = p.render;
|
||||||
edUndoManager(p);
|
edUndoManager(p);
|
||||||
|
|
||||||
if (p.status === "init") {
|
if (p.status === "init") {
|
||||||
|
|
@ -135,6 +137,26 @@ export const EdBase = () => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{w.offline && <div
|
||||||
|
className={cx(
|
||||||
|
css`
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
z-index: 999;
|
||||||
|
`,
|
||||||
|
"flex justify-center cursor-pointer"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="bg-red-500 text-white px-4 py-2 rounded-full text-sm"
|
||||||
|
>
|
||||||
|
Reconnecting, changes are not saved...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ export const EDGlobal = {
|
||||||
script: {
|
script: {
|
||||||
site_types: {} as Record<string, string>,
|
site_types: {} as Record<string, string>,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
do_edit: async (newval: string, all?: boolean) => {},
|
do_edit: async (newval: string, all?: boolean) => { },
|
||||||
db: null as any,
|
db: null as any,
|
||||||
api: null as any,
|
api: null as any,
|
||||||
init_local_effect: {} as Record<string, boolean>,
|
init_local_effect: {} as Record<string, boolean>,
|
||||||
|
|
@ -182,7 +182,7 @@ export const EDGlobal = {
|
||||||
meta: {} as Record<string, IMeta>,
|
meta: {} as Record<string, IMeta>,
|
||||||
entry: [] as string[],
|
entry: [] as string[],
|
||||||
tree: [] as NodeModel<IMeta>[],
|
tree: [] as NodeModel<IMeta>[],
|
||||||
render: () => {},
|
render: () => { },
|
||||||
},
|
},
|
||||||
comp: {
|
comp: {
|
||||||
doc: null as null | DComp,
|
doc: null as null | DComp,
|
||||||
|
|
@ -295,9 +295,9 @@ export const EDGlobal = {
|
||||||
type: "item" as "item" | "prop-master" | "prop-instance" | "comp-types",
|
type: "item" as "item" | "prop-master" | "prop-instance" | "comp-types",
|
||||||
prop_kind: "" as PropFieldKind,
|
prop_kind: "" as PropFieldKind,
|
||||||
prop_name: "",
|
prop_name: "",
|
||||||
on_close: () => {},
|
on_close: () => { },
|
||||||
typings: { status: "ok" as "ok" | "loading" | "error", err_msg: "" },
|
typings: { status: "ok" as "ok" | "loading" | "error", err_msg: "" },
|
||||||
wb_render: () => {},
|
wb_render: () => { },
|
||||||
},
|
},
|
||||||
site: null as null | ((site_id: string) => void | Promise<void>),
|
site: null as null | ((site_id: string) => void | Promise<void>),
|
||||||
site_form: null as null | {
|
site_form: null as null | {
|
||||||
|
|
|
||||||
|
|
@ -166,11 +166,17 @@ const connect = (
|
||||||
);
|
);
|
||||||
|
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
|
w.offline = false;
|
||||||
|
w.editorRender?.();
|
||||||
|
|
||||||
sendWs(ws, { type: SyncType.UserID, user_id, site_id, page_id });
|
sendWs(ws, { type: SyncType.UserID, user_id, site_id, page_id });
|
||||||
conf.ws = ws;
|
conf.ws = ws;
|
||||||
event.opened();
|
event.opened();
|
||||||
};
|
};
|
||||||
ws.onclose = async () => {
|
ws.onclose = async () => {
|
||||||
|
w.offline = true;
|
||||||
|
w.editorRender?.();
|
||||||
|
|
||||||
const res = event.disconnected();
|
const res = event.disconnected();
|
||||||
if (res.reconnect) {
|
if (res.reconnect) {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ export const w = window as unknown as {
|
||||||
_api: any;
|
_api: any;
|
||||||
_db: any;
|
_db: any;
|
||||||
offline: boolean;
|
offline: boolean;
|
||||||
|
editorRender?: () => void;
|
||||||
debug: {
|
debug: {
|
||||||
on: any;
|
on: any;
|
||||||
off: any;
|
off: any;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue