fix logout
This commit is contained in:
parent
df8a394d55
commit
14be1eed8d
|
|
@ -0,0 +1,10 @@
|
|||
import { apiContext } from "service-srv";
|
||||
import { session } from "utils/session";
|
||||
|
||||
export const _ = {
|
||||
url: "/_logout",
|
||||
async api() {
|
||||
const { res } = apiContext(this);
|
||||
res.setHeader("set-cookie", `${session.cookieKey}=X`);
|
||||
},
|
||||
};
|
||||
|
|
@ -17,6 +17,7 @@ export const codeBuild = async (code: DBCode) => {
|
|||
absWorkingDir: dir.path(`${g.datadir}/site/code/${id_code}`),
|
||||
entryPoints: ["index.tsx"],
|
||||
bundle: true,
|
||||
format: "cjs",
|
||||
outfile: dir.path(`${g.datadir}/build/code/${id_code}/index.js`),
|
||||
minify: true,
|
||||
treeShaking: true,
|
||||
|
|
@ -52,7 +53,6 @@ export const codeBuild = async (code: DBCode) => {
|
|||
});
|
||||
});
|
||||
const result = await Code.build.ctx[id_code].rebuild();
|
||||
console.log("rebuilt");
|
||||
activity.site
|
||||
.room(code.id_site)
|
||||
.findAll({ site_js: code.name })
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { page, useGlobal } from "web-utils";
|
|||
import { EDGlobal } from "../../render/ed/logic/ed-global";
|
||||
import { edInitSync } from "../../render/ed/logic/ed-sync";
|
||||
import { Loading } from "../../utils/ui/loading";
|
||||
import { isLocalhost } from "../../utils/ui/is-localhost";
|
||||
|
||||
export default page({
|
||||
url: "**",
|
||||
|
|
@ -22,9 +23,13 @@ export default page({
|
|||
} else if (arr.length === 3) {
|
||||
navigate(location.pathname + "/");
|
||||
}
|
||||
} else {
|
||||
if (isLocalhost()) {
|
||||
navigate("/ed");
|
||||
} else {
|
||||
navigate("/editor/_/_");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
navigate("/login");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,13 +47,23 @@ export default page({
|
|||
form.render();
|
||||
alert(s.reason);
|
||||
} else {
|
||||
const rto = (window as any).redirectTo;
|
||||
let rto = (window as any).redirectTo;
|
||||
if (rto) {
|
||||
if (
|
||||
location.href.includes("localhost") &&
|
||||
rto.includes("/editor")
|
||||
) {
|
||||
rto = rto.replace("/editor", "/ed");
|
||||
}
|
||||
navigate(rto);
|
||||
} else {
|
||||
if (location.href.includes("localhost")) {
|
||||
navigate("/ed");
|
||||
} else {
|
||||
navigate("/editor");
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
className={cx("border-[3px] border-black", formStyle)}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -15,10 +15,12 @@ export default page({
|
|||
}
|
||||
(window as any).pathname = pathname;
|
||||
|
||||
if (navigator.serviceWorker) {
|
||||
navigator.serviceWorker.controller?.postMessage({
|
||||
type: "add-cache",
|
||||
url: location.href,
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<Live
|
||||
|
|
|
|||
|
|
@ -17,18 +17,21 @@ const start = async () => {
|
|||
};
|
||||
(window as any).mobile = registerMobile();
|
||||
|
||||
if (navigator.serviceWorker) {
|
||||
if (!isLocalhost()) {
|
||||
const sw = await registerServiceWorker();
|
||||
|
||||
const cacheCurrentPage = () => {
|
||||
const swController = navigator.serviceWorker.controller;
|
||||
if (swController) {
|
||||
[location.href, "", "/", "/ed", "/ed/_/_", "/login"].forEach((url) => {
|
||||
[location.href, "", "/", "/ed", "/ed/_/_", "/login"].forEach(
|
||||
(url) => {
|
||||
swController.postMessage({
|
||||
type: "add-cache",
|
||||
url: url,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
cacheCurrentPage();
|
||||
|
|
@ -139,12 +142,14 @@ const start = async () => {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
defineReact();
|
||||
await defineWindow(false);
|
||||
w.serverurl = base;
|
||||
await reloadDBAPI(base, "prod");
|
||||
|
||||
if (navigator.serviceWorker) {
|
||||
const swc = navigator.serviceWorker.controller;
|
||||
if (swc) {
|
||||
[location.href, "", "/", "/ed", "/ed/_/_", "/login"].forEach((url) => {
|
||||
|
|
@ -167,6 +172,7 @@ const start = async () => {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
w.api = createAPI(base);
|
||||
w.db = createDB(base);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { Loading } from "../../../../../utils/ui/loading";
|
|||
import { Modal } from "../../../../../utils/ui/modal";
|
||||
import { Tooltip } from "../../../../../utils/ui/tooltip";
|
||||
import { EDGlobal } from "../../../logic/ed-global";
|
||||
import { Popover } from "../../../../../utils/ui/popover";
|
||||
|
||||
export const EdPopCode = () => {
|
||||
const p = useGlobal(EDGlobal, "EDITOR");
|
||||
|
|
@ -50,23 +51,28 @@ export const EdPopCode = () => {
|
|||
)}
|
||||
>
|
||||
<div className="border-b flex h-[40px] items-stretch">
|
||||
<div
|
||||
<Popover
|
||||
placement="bottom"
|
||||
offset={0}
|
||||
arrow={false}
|
||||
content={<div className="w-[200px] border">Hellow</div>}
|
||||
autoFocus={false}
|
||||
popoverClassName="bg-white shadow-md"
|
||||
className={cx(
|
||||
"flex items-center px-2 w-[200px] overflow-ellipsis space-x-1",
|
||||
"cursor-pointer"
|
||||
"flex items-center px-2 w-[200px] hover:bg-blue-50 space-x-1",
|
||||
"cursor-pointer justify-between"
|
||||
)}
|
||||
>
|
||||
<div className="capitalize flex-1 flex items-center justify-between">
|
||||
<div>{p.ui.popup.code.name}</div>
|
||||
<div className="capitalize overflow-ellipsis flex-1 flex items-center ">
|
||||
{p.ui.popup.code.name}
|
||||
</div>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`,
|
||||
}}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
|
||||
<div className="flex items-center space-x-1 border-x px-2">
|
||||
{p.ui.popup.code.name !== "site" && (
|
||||
<div className="hover:bg-blue-100 flex items-center justify-center border w-[20px] h-[20px] flex">
|
||||
<div
|
||||
|
|
@ -76,24 +82,11 @@ export const EdPopCode = () => {
|
|||
></div>
|
||||
</div>
|
||||
)}
|
||||
<Tooltip
|
||||
content="New Project"
|
||||
placement="bottom"
|
||||
className="hover:bg-blue-100 flex items-center justify-center border w-[20px] h-[20px] flex cursor-pointer"
|
||||
>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 2.75C8 2.47386 7.77614 2.25 7.5 2.25C7.22386 2.25 7 2.47386 7 2.75V7H2.75C2.47386 7 2.25 7.22386 2.25 7.5C2.25 7.77614 2.47386 8 2.75 8H7V12.25C7 12.5261 7.22386 12.75 7.5 12.75C7.77614 12.75 8 12.5261 8 12.25V8H12.25C12.5261 8 12.75 7.77614 12.75 7.5C12.75 7.22386 12.5261 7 12.25 7H8V2.75Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`,
|
||||
}}
|
||||
></div>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
<Tooltip
|
||||
content="stdout log"
|
||||
delay={0}
|
||||
placement="bottom"
|
||||
className="flex items-stretch relative"
|
||||
className="flex items-stretch relative border-l"
|
||||
onClick={() => {
|
||||
p.ui.popup.code.show_log = !p.ui.popup.code.show_log;
|
||||
p.render();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
export const isLocalhost = () => {
|
||||
return ["localhost", "127.0.0.1", "trycloudflare.com", "ngrok"].find((e) =>
|
||||
location.hostname.includes(e)
|
||||
);
|
||||
return [
|
||||
"localhost",
|
||||
"127.0.0.1",
|
||||
"192.168",
|
||||
"trycloudflare.com",
|
||||
"ngrok",
|
||||
].find((e) => location.hostname.includes(e));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue