remove DOMAIN env, initial fit fetching in /unity
This commit is contained in:
parent
7fb8601dd3
commit
de6bdf6aa0
|
|
@ -1,2 +1 @@
|
|||
# placing my env here
|
||||
DOMAIN=https://nextjs-test-rnd.vercel.app
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import { NextRequest } from "next/server";
|
||||
import { frame, ohg } from "../constant";
|
||||
import { LengthType } from "../types";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
|
@ -17,8 +18,8 @@ export async function GET(request: NextRequest) {
|
|||
(Object.keys(frameObject.length).reduce(
|
||||
(prev, curr) =>
|
||||
prev +
|
||||
(ohgObject.length[curr as keyof typeof ohgObject.length] -
|
||||
frameObject.length[curr as keyof typeof frameObject.length]) **
|
||||
(ohgObject.length[curr as keyof LengthType] -
|
||||
frameObject.length[curr as keyof LengthType]) **
|
||||
2,
|
||||
0,
|
||||
) /
|
||||
|
|
|
|||
|
|
@ -6,25 +6,12 @@ const getItem = async () => {
|
|||
return await Promise.resolve({ option, ohg, frame });
|
||||
};
|
||||
|
||||
const getInitMatch = async () => {
|
||||
return await fetch(`${process.env.DOMAIN}/fit?o=0&f=0`, {
|
||||
method: "GET",
|
||||
});
|
||||
};
|
||||
|
||||
export default async function UnityComponent() {
|
||||
const { option, ohg, frame } = await getItem();
|
||||
const res = await getInitMatch();
|
||||
const initMatch = (await res.json()) as { match: number };
|
||||
|
||||
return (
|
||||
<Suspense>
|
||||
<Unity
|
||||
option={option}
|
||||
ohg={ohg}
|
||||
frame={frame}
|
||||
initMatch={initMatch?.match ?? 0}
|
||||
/>
|
||||
<Unity option={option} ohg={ohg} frame={frame} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ const unityConfigBuilder: (path: string) => UnityConfig = (path) => ({
|
|||
});
|
||||
|
||||
export default function UnityComponent({
|
||||
initMatch,
|
||||
option = [],
|
||||
ohg = [],
|
||||
frame = [],
|
||||
|
|
@ -28,12 +27,11 @@ export default function UnityComponent({
|
|||
}[];
|
||||
ohg: ObjectType[];
|
||||
frame: ObjectType[];
|
||||
initMatch: number;
|
||||
}) {
|
||||
const params = useSearchParams();
|
||||
const p = params.get("p");
|
||||
const [selectedIndex, setSelectedIndex] = useState({ ohg: 0, frame: 0 });
|
||||
const [match, setMatch] = useState(initMatch);
|
||||
const [match, setMatch] = useState(100);
|
||||
if (!p || isNaN(Number(p))) location.href = "/unity?p=0";
|
||||
|
||||
const { unityProvider, isLoaded, loadingProgression, UNSAFE__unityInstance } =
|
||||
|
|
|
|||
Loading…
Reference in New Issue