@topgroup/diginext
Version:
A BUILD SERVER & CLI to deploy apps to any Kubernetes clusters.
71 lines (54 loc) • 1.41 kB
Plain Text
/* eslint-disable @typescript-eslint/no-use-before-define */
import AppThree from "diginext-three/dist/components/AppThree";
import AppEvent from "diginext-three/dist/data/AppEvent";
import type { ReactNode } from "react";
import React, { useEffect, useState } from "react";
import { useListener } from "@/components/context/ListenerProvider";
import @ from "@/modules/three/scenes/@@PAGE_FILE_NAMEScene";
interface IPage@@PAGE_FILE_NAME {
\tchildren?: ReactNode;
}
const Page@ = (props: IPage@) => {
\tconst [main, setMain] = useState(<></>);
\tconst listener = useListener();
\tconst onListen = (e: any) => {
\t\tconst { type } = e;
\t\tswitch (type) {
\t\t\tcase AppEvent.LOADED_APP_THREE:
\t\t\t\t{
\t\t\t\t\tinit();
\t\t\t\t}
\t\t\t\tbreak;
\t\t\tdefault:
\t\t\t\tbreak;
\t\t}
\t};
\tif (listener) {
\t\tlistener.useSubscription((e: any) => {
\t\t\tonListen(e);
\t\t});
\t}
\tconst init = async () => {
\t\t//
\t\tconst uData = (window as any).uData;
\t\tif (!uData) return;
\t\tconst { scene } = uData;
\t\tif (!scene) return;
\t\tconst root = new @();
\t\tscene.add(root);
\t};
\tuseEffect(() => {
\t\t// effect
\t\tsetMain(<AppThree listener={listener} />);
\t\treturn () => {
\t\t\t// cleanup
\t\t};
\t}, []);
\treturn (
\t\t<>
\t\t\t{main}
\t\t\t{props.children}
\t\t</>
\t);
};
export default Page@;