wip fix
This commit is contained in:
parent
ca7d469a8e
commit
cdd87addac
|
|
@ -225,6 +225,7 @@ export const EDGlobal = {
|
|||
name: "site",
|
||||
log: "",
|
||||
loading: false,
|
||||
startup_running: false,
|
||||
error: false,
|
||||
show_log: false,
|
||||
list: {} as Record<string, string>,
|
||||
|
|
|
|||
|
|
@ -23,48 +23,81 @@ export const edInitSync = (p: PG) => {
|
|||
localStorage.getItem("prasi-session") || "null"
|
||||
) as { data: { user: { id: string; username: string } } };
|
||||
if (!session && location.pathname.startsWith("/ed/")) {
|
||||
navigate("/login");
|
||||
location.href = "/login";
|
||||
return <Loading note="logging in" />;
|
||||
}
|
||||
p.user.id = session.data.user.id;
|
||||
p.user.username = session.data.user.username;
|
||||
|
||||
if (!params.page_id && location.pathname.startsWith("/vi/")) {
|
||||
p.preview.show_loading = false;
|
||||
if (page.list.length === 0) {
|
||||
db.page
|
||||
.findMany({
|
||||
where: {
|
||||
id_site: params.site_id,
|
||||
is_deleted: false,
|
||||
is_default_layout: false,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
url: true,
|
||||
},
|
||||
})
|
||||
.then((list) => {
|
||||
page.list = list;
|
||||
edInitSync(p);
|
||||
});
|
||||
if (!params.page_id) {
|
||||
if (location.pathname.startsWith("/vi/")) {
|
||||
p.preview.show_loading = false;
|
||||
if (page.list.length === 0) {
|
||||
db.page
|
||||
.findMany({
|
||||
where: {
|
||||
id_site: params.site_id,
|
||||
is_deleted: false,
|
||||
is_default_layout: false,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
url: true,
|
||||
},
|
||||
})
|
||||
.then((list) => {
|
||||
page.list = list;
|
||||
edInitSync(p);
|
||||
});
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (!page.route) {
|
||||
page.route = createRouter();
|
||||
for (const e of page.list) {
|
||||
page.route.insert(e.url, e);
|
||||
return;
|
||||
} else {
|
||||
if (!page.route) {
|
||||
page.route = createRouter();
|
||||
for (const e of page.list) {
|
||||
page.route.insert(e.url, e);
|
||||
}
|
||||
}
|
||||
|
||||
const arrpath = location.pathname.split("/");
|
||||
const pathname = "/" + arrpath.slice(3).join("/");
|
||||
|
||||
const res = page.route.lookup(pathname);
|
||||
if (res) {
|
||||
params.page_id = res.id;
|
||||
}
|
||||
}
|
||||
|
||||
const arrpath = location.pathname.split("/");
|
||||
const pathname = "/" + arrpath.slice(3).join("/");
|
||||
|
||||
const res = page.route.lookup(pathname);
|
||||
if (res) {
|
||||
params.page_id = res.id;
|
||||
} else if (location.pathname.startsWith("/ed")) {
|
||||
if (!params.site_id) {
|
||||
db.page
|
||||
.findFirst({
|
||||
where: {
|
||||
is_deleted: false,
|
||||
is_default_layout: false,
|
||||
site: {
|
||||
id_user: p.user.id,
|
||||
},
|
||||
},
|
||||
select: { id: true, id_site: true },
|
||||
})
|
||||
.then((e) => {
|
||||
if (e) location.href = `/ed/${e.id_site}/${e.id}`;
|
||||
});
|
||||
} else {
|
||||
db.page
|
||||
.findFirst({
|
||||
where: {
|
||||
is_deleted: false,
|
||||
is_default_layout: false,
|
||||
id_site: params.site_id,
|
||||
},
|
||||
select: { id: true, id_site: true },
|
||||
})
|
||||
.then((e) => {
|
||||
if (e) location.href = `/ed/${e.id_site}/${e.id}`;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +135,7 @@ export const edInitSync = (p: PG) => {
|
|||
select: { id: true },
|
||||
})
|
||||
.then((e) => {
|
||||
if (e) navigate(`/ed/${params.site_id}/${e.id}`);
|
||||
if (e) location.href = `/ed/${params.site_id}/${e.id}`;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
|
@ -149,7 +182,7 @@ export const edInitSync = (p: PG) => {
|
|||
p.site.id = e.site_id;
|
||||
p.page.cur.id = e.page_id;
|
||||
if (location.pathname.startsWith("/ed/")) {
|
||||
navigate(`/ed/${e.site_id}/${e.page_id}`);
|
||||
location.href = `/ed/${e.site_id}/${e.page_id}`;
|
||||
}
|
||||
} else {
|
||||
p.site.id = e.site_id;
|
||||
|
|
|
|||
|
|
@ -8,10 +8,14 @@ import { Tooltip } from "../../../../../utils/ui/tooltip";
|
|||
import { EDGlobal } from "../../../logic/ed-global";
|
||||
import {
|
||||
iconChevronDown,
|
||||
iconDownload,
|
||||
iconLoading,
|
||||
iconLog,
|
||||
iconNewTab,
|
||||
iconScrollOff,
|
||||
iconScrollOn,
|
||||
iconTrash,
|
||||
iconUpload,
|
||||
} from "./icons";
|
||||
import { CodeNameItem, CodeNameList, codeName } from "./name-list";
|
||||
|
||||
|
|
@ -141,7 +145,7 @@ const CodeBody = () => {
|
|||
></div>
|
||||
</Popover>
|
||||
|
||||
<Tooltip
|
||||
{/* <Tooltip
|
||||
content="STDOUT Log"
|
||||
delay={0}
|
||||
placement="bottom"
|
||||
|
|
@ -168,7 +172,75 @@ const CodeBody = () => {
|
|||
__html: p.ui.popup.code.loading ? iconLog : iconLoading,
|
||||
}}
|
||||
></div>
|
||||
</Tooltip> */}
|
||||
<Tooltip
|
||||
content={`Startup Script: ${
|
||||
!p.ui.popup.code.startup_running ? "OFF" : "Running"
|
||||
}`}
|
||||
className={cx("flex items-stretch relative border-l")}
|
||||
delay={0}
|
||||
placement="bottom"
|
||||
>
|
||||
<div
|
||||
className={cx(
|
||||
"border-r flex text-center items-center hover:bg-blue-50 cursor-pointer px-2 transition-all",
|
||||
p.ui.popup.code.startup_running
|
||||
? "border-b-2 border-b-green-700 bg-green-50"
|
||||
: "border-b-2 border-b-transparent"
|
||||
)}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: p.ui.popup.code.startup_running
|
||||
? iconScrollOn
|
||||
: iconScrollOff,
|
||||
}}
|
||||
onClick={() => {
|
||||
p.ui.popup.code.startup_running =
|
||||
!p.ui.popup.code.startup_running;
|
||||
p.render();
|
||||
}}
|
||||
></div>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip
|
||||
content={`Upload zip, will overwrite files.`}
|
||||
className={cx(
|
||||
"flex items-stretch relative cursor-pointer hover:bg-blue-50 "
|
||||
)}
|
||||
delay={0}
|
||||
placement="bottom"
|
||||
>
|
||||
<input
|
||||
type="file"
|
||||
className="w-full h-full absolute inset-0 opacity-0 cursor-pointer text-[0px]"
|
||||
></input>
|
||||
<div
|
||||
className={cx(
|
||||
"border-r flex text-center items-center cursor-pointer px-2 transition-all pointer-events-none"
|
||||
)}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: iconUpload,
|
||||
}}
|
||||
></div>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip
|
||||
content={`Download zip, excluding node_modules.`}
|
||||
className={cx(
|
||||
"flex items-stretch relative cursor-pointer hover:bg-blue-50 "
|
||||
)}
|
||||
delay={0}
|
||||
placement="bottom"
|
||||
>
|
||||
<div
|
||||
className={cx(
|
||||
"border-r flex text-center items-center cursor-pointer px-2 transition-all cursor-pointer"
|
||||
)}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: iconDownload,
|
||||
}}
|
||||
></div>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip
|
||||
content="Open in new tab"
|
||||
delay={0}
|
||||
|
|
|
|||
|
|
@ -17,3 +17,11 @@ export const iconTrash = `<svg width="15" height="15" viewBox="0 0 15 15" fill="
|
|||
export const iconModule = `<svg width="11" height="11" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.5C2 3.22386 2.22386 3 2.5 3H12.5C12.7761 3 13 3.22386 13 3.5V9.5C13 9.77614 12.7761 10 12.5 10H2.5C2.22386 10 2 9.77614 2 9.5V3.5ZM2 10.9146C1.4174 10.7087 1 10.1531 1 9.5V3.5C1 2.67157 1.67157 2 2.5 2H12.5C13.3284 2 14 2.67157 14 3.5V9.5C14 10.1531 13.5826 10.7087 13 10.9146V11.5C13 12.3284 12.3284 13 11.5 13H3.5C2.67157 13 2 12.3284 2 11.5V10.9146ZM12 11V11.5C12 11.7761 11.7761 12 11.5 12H3.5C3.22386 12 3 11.7761 3 11.5V11H12Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`;
|
||||
|
||||
export const iconNewTab = `<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 13C12.5523 13 13 12.5523 13 12V3C13 2.44771 12.5523 2 12 2H3C2.44771 2 2 2.44771 2 3V6.5C2 6.77614 2.22386 7 2.5 7C2.77614 7 3 6.77614 3 6.5V3H12V12H8.5C8.22386 12 8 12.2239 8 12.5C8 12.7761 8.22386 13 8.5 13H12ZM9 6.5C9 6.5001 9 6.50021 9 6.50031V6.50035V9.5C9 9.77614 8.77614 10 8.5 10C8.22386 10 8 9.77614 8 9.5V7.70711L2.85355 12.8536C2.65829 13.0488 2.34171 13.0488 2.14645 12.8536C1.95118 12.6583 1.95118 12.3417 2.14645 12.1464L7.29289 7H5.5C5.22386 7 5 6.77614 5 6.5C5 6.22386 5.22386 6 5.5 6H8.5C8.56779 6 8.63244 6.01349 8.69139 6.03794C8.74949 6.06198 8.80398 6.09744 8.85143 6.14433C8.94251 6.23434 8.9992 6.35909 8.99999 6.49708L8.99999 6.49738" fill="currentColor"></path></svg>`;
|
||||
|
||||
export const iconScrollOn = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scroll-text"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`;
|
||||
|
||||
export const iconScrollOff = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scroll"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/></svg>`;
|
||||
|
||||
export const iconUpload = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-upload"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>`;
|
||||
|
||||
export const iconDownload = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`
|
||||
Loading…
Reference in New Issue