modified: src/app/page.tsx
This commit is contained in:
parent
a657cde275
commit
688a6d40bf
|
@ -50,7 +50,25 @@ export default function Home() {
|
||||||
}),
|
}),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
let apiUrl: string;
|
const isSnackBarHidden = useMemo(() => {
|
||||||
|
if (typeof localStorage === "undefined") return false;
|
||||||
|
return localStorage.getItem("snackBarHidden") === "true";
|
||||||
|
}, []);
|
||||||
|
const [snackBarVisible, setSnackBarVisibility] = useState(false);
|
||||||
|
const [values, setValues] = useState<{
|
||||||
|
buses: BusProps["values"][];
|
||||||
|
strips: StripProps["values"][];
|
||||||
|
}>();
|
||||||
|
const [width, setWidth] = useState(1000);
|
||||||
|
const [isLoaded, setIsLoaded] = useState(false);
|
||||||
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||||
|
let [apiUrl, setApiUrl] = useState<string>();
|
||||||
|
|
||||||
|
const isItMobileDevice = useMemo(
|
||||||
|
() =>
|
||||||
|
typeof window !== "undefined" ? isItMobile(navigator.userAgent) : "",
|
||||||
|
[]
|
||||||
|
);
|
||||||
function sendApi(
|
function sendApi(
|
||||||
path: string,
|
path: string,
|
||||||
method: RequestInit["method"] = "GET",
|
method: RequestInit["method"] = "GET",
|
||||||
|
@ -106,32 +124,17 @@ export default function Home() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const isSnackBarHidden = useMemo(() => {
|
|
||||||
if (typeof localStorage === "undefined") return false;
|
|
||||||
return localStorage.getItem("snackBarHidden") === "true";
|
|
||||||
}, []);
|
|
||||||
const [snackBarVisible, setSnackBarVisibility] = useState(false);
|
|
||||||
const [values, setValues] = useState<{
|
|
||||||
buses: BusProps["values"][];
|
|
||||||
strips: StripProps["values"][];
|
|
||||||
}>();
|
|
||||||
const [width, setWidth] = useState(1000);
|
|
||||||
const [isLoaded, setIsLoaded] = useState(false);
|
|
||||||
|
|
||||||
const isItMobileDevice = useMemo(
|
|
||||||
() =>
|
|
||||||
typeof window !== "undefined" ? isItMobile(navigator.userAgent) : "",
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
const toggleFullscreen = () => {
|
const toggleFullscreen = () => {
|
||||||
|
new Promise((r) => {
|
||||||
if (document.fullscreenElement === null)
|
if (document.fullscreenElement === null)
|
||||||
document.documentElement.requestFullscreen();
|
r(document.documentElement.requestFullscreen());
|
||||||
else document.exitFullscreen();
|
else r(document.exitFullscreen());
|
||||||
|
}).then(() => setIsFullscreen(document.fullscreenElement !== null));
|
||||||
};
|
};
|
||||||
let isFullscreen: boolean = false;
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const _apiUrl = new URL(document.URL);
|
const _apiUrl = new URL(document.URL);
|
||||||
_apiUrl.port = "3001";
|
_apiUrl.port = "3001";
|
||||||
|
setApiUrl(_apiUrl.toString());
|
||||||
apiUrl = _apiUrl.toString();
|
apiUrl = _apiUrl.toString();
|
||||||
|
|
||||||
sendApi("/values")
|
sendApi("/values")
|
||||||
|
@ -155,7 +158,6 @@ export default function Home() {
|
||||||
window.onresize = () => {
|
window.onresize = () => {
|
||||||
setWidth(window.innerWidth);
|
setWidth(window.innerWidth);
|
||||||
};
|
};
|
||||||
isFullscreen = document.fullscreenElement !== null;
|
|
||||||
}, []);
|
}, []);
|
||||||
const strips = { virtual: 3, physical: 5 };
|
const strips = { virtual: 3, physical: 5 };
|
||||||
const buses = { virtual: 3, physical: 5 };
|
const buses = { virtual: 3, physical: 5 };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user