fix prasi, font swap
This commit is contained in:
parent
898685f117
commit
7c2ed2b435
|
|
@ -1,6 +1,6 @@
|
|||
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;600&display=swap');
|
||||
|
||||
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=block');
|
||||
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
overscroll-behavior-y: none;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ export const PanelFont: FC<{
|
|||
const doc = document;
|
||||
let weight = `:wght@${[300, 400, 500, 600].join(";")}`;
|
||||
let fontName = item.value.replace(/ /g, "+");
|
||||
const _href = `https://fonts.googleapis.com/css2?family=${fontName}${weight}&display=block`;
|
||||
const _href = `https://fonts.googleapis.com/css2?family=${fontName}${weight}`;
|
||||
if (!doc.querySelector(`link[href="${_href}]`)) {
|
||||
const link = doc.createElement("link");
|
||||
link.type = "text/css";
|
||||
|
|
|
|||
|
|
@ -99,7 +99,10 @@ const loadNpmPage = async (p: PG, id: string) => {
|
|||
if (typeof window.exports === "undefined") {
|
||||
window.exports = {};
|
||||
}
|
||||
await importModule(p.loader.npm(p, "page", id));
|
||||
const npmurl = p.loader.npm(p, "page", id);
|
||||
if (npmurl) {
|
||||
await importModule(npmurl);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { produceCSS } from "../../../utils/css/gen";
|
||||
import { IContent } from "../../../utils/types/general";
|
||||
import { IItem, MItem } from "../../../utils/types/item";
|
||||
import { FNCompDef } from "../../../utils/types/meta-fn";
|
||||
import { IItem } from "../../../utils/types/item";
|
||||
import { instantiateComp, loadComponent } from "./comp";
|
||||
import { ItemMeta, LiveGlobal, PG } from "./global";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,43 +1,50 @@
|
|||
import { w } from "../../utils/script/init-api";
|
||||
import { Loader } from "../live/logic/global";
|
||||
|
||||
const base = `/_web/${(window as any).id_site}`;
|
||||
|
||||
const cache = { site: null as any, pages: [] as any, api: null };
|
||||
const cache = {
|
||||
site: null as any,
|
||||
pages: [] as any,
|
||||
api: null,
|
||||
npm_pages: [] as string[],
|
||||
};
|
||||
|
||||
export const mobileLoader: Loader = {
|
||||
async site(p, id) {
|
||||
const res = (await load(`/site?prod=1`)) as {
|
||||
site: any;
|
||||
pages: any;
|
||||
api: any;
|
||||
};
|
||||
cache.site = res.site;
|
||||
cache.pages = res.pages;
|
||||
cache.api = res.api;
|
||||
const res = (await load(`/content/site/site.json`)) as any;
|
||||
cache.site = res;
|
||||
|
||||
w.serverurl = res.site.config.api_url;
|
||||
w.apiurl = res.site.config.api_url;
|
||||
const pages = (await load(`/content/site/pages.json`)) as any;
|
||||
cache.pages = pages;
|
||||
|
||||
const npm_pages = (await load(`/content/site/npm_pages.json`)) as any;
|
||||
cache.npm_pages = npm_pages;
|
||||
|
||||
w.serverurl = res.config.api_url;
|
||||
w.apiurl = res.config.api_url;
|
||||
|
||||
w.prasiApi = {
|
||||
[res.site.config.api_url]: { apiEntry: res.api },
|
||||
[res.config.api_url]: { apiEntry: res.api },
|
||||
};
|
||||
|
||||
return res.site;
|
||||
return res;
|
||||
},
|
||||
async comp(p, id) {
|
||||
const comp = (await load(`/comp/${id}`)) as any;
|
||||
const comp = (await load(`/content/comps/${id}.json`)) as any;
|
||||
p.comps.all[id] = comp;
|
||||
return comp;
|
||||
},
|
||||
npm(p, type, id) {
|
||||
if (type === "site") return `/_web/${cache.site.id}/npm-site/site.js`;
|
||||
return `/_web/${cache.site.id}/npm-page/${id}/page.js`;
|
||||
if (type === "site") return `/content/npm/site/index.js`;
|
||||
if (cache.npm_pages.includes(id)) {
|
||||
return `/content/npm/pages/${id}/index.js`;
|
||||
}
|
||||
return "";
|
||||
},
|
||||
async page(p, id) {
|
||||
const page = cache.pages.find((x: any) => x.id === id);
|
||||
if (page && !page.content_tree) {
|
||||
const res = (await load(`/page/${id}`)) as any;
|
||||
const res = (await load(`/content/pages/${id}.json`)) as any;
|
||||
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
|
|
@ -48,7 +55,7 @@ export const mobileLoader: Loader = {
|
|||
};
|
||||
|
||||
const load = async (url: string) => {
|
||||
const res = await fetch(`${base}${url}`);
|
||||
const res = await fetch(`${w.mobilepath}${url}`);
|
||||
const text = await res.text();
|
||||
const json = JSON.parse(text);
|
||||
return json;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { createRoot } from "react-dom/client";
|
|||
import { GlobalContext, defineReact, defineWindow } from "web-utils";
|
||||
import { siteLoader } from "./site-loader";
|
||||
import { registerMobile } from "../live/logic/mobile";
|
||||
import { mobileLoader } from "./mobile-loader";
|
||||
|
||||
const w = window as unknown as {
|
||||
prasiContext: any;
|
||||
|
|
@ -32,7 +33,7 @@ const Root: FC<{ url: URL; Live: any }> = ({ url, Live }) => {
|
|||
<Live
|
||||
domain={url.host}
|
||||
pathname={location.pathname}
|
||||
loader={siteLoader}
|
||||
loader={w.mobilepath ? mobileLoader : siteLoader}
|
||||
/>
|
||||
</Provider>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export const cssFont = (
|
|||
if (glbFont.loadedFonts.indexOf(font.family) < 0) {
|
||||
glbFont.loadedFonts.push(font.family);
|
||||
const doc = document;
|
||||
const _href = `https://fonts.googleapis.com/css2?family=${fontName}${weight}&display=block`;
|
||||
const _href = `https://fonts.googleapis.com/css2?family=${fontName}${weight}`;
|
||||
if (!doc.querySelector(`link[href="${_href}]`)) {
|
||||
const link = doc.createElement("link");
|
||||
link.type = "text/css";
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export const w = window as unknown as {
|
|||
dbClient: typeof dbClient;
|
||||
serverurl: string;
|
||||
apiurl: string;
|
||||
mobilepath: string;
|
||||
};
|
||||
|
||||
export const createAPI = (url: string) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue