From 3e99ee01e2f7292047f54385653c89df01982554 Mon Sep 17 00:00:00 2001 From: Alexander Guryanov Date: Thu, 20 Jun 2024 13:34:57 +0700 Subject: [PATCH] Implement kiosk mode --- index.html | 3 ++- src/main.tsx | 16 +++++++++++++++- src/public/types.ts | 3 +++ src/sidebar/sidebar.tsx | 5 +++++ src/store/ui.ts | 5 +++++ src/window/prerun-window.tsx | 5 +++-- src/window/window.tsx | 3 ++- 7 files changed, 35 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 6bc299ad..7542434b 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,8 @@ // url: "https://cdn.dos.zone/original/2X/7/744842062905f72648a4d492ccc2526d039b3702.jsdos", // sim-city // dosboxConf: diabloConf, // loginUrl: "http://localhost:8080/subscription.html", - autoStart: true, + // autoStart: true, + // kiosk: true, pathPrefix: "/emulators/", server: params.get("server"), room: params.get("room"), diff --git a/src/main.tsx b/src/main.tsx index 5572b444..48b01352 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -115,6 +115,14 @@ export const Dos: DosFn = (element: HTMLDivElement, browserSetFullScreen(fullScreen, store); } + function setAutoStart(autoStart: boolean) { + store.dispatch(uiSlice.actions.autoStart(autoStart)); + } + + function setKiosk(kiosk: boolean) { + store.dispatch(uiSlice.actions.kiosk(kiosk)); + } + if (options.theme) { setTheme(options.theme); } @@ -160,7 +168,11 @@ export const Dos: DosFn = (element: HTMLDivElement, } if (options.autoStart !== undefined) { - store.dispatch(uiSlice.actions.autoStart(options.autoStart)); + setAutoStart(options.autoStart); + } + + if (options.kiosk !== undefined) { + setKiosk(options.kiosk); } render( @@ -182,6 +194,8 @@ export const Dos: DosFn = (element: HTMLDivElement, setFrame, setBackground, setFullScreen, + setAutoStart, + setKiosk, }; }; diff --git a/src/public/types.ts b/src/public/types.ts index 4f81e316..c044e496 100644 --- a/src/public/types.ts +++ b/src/public/types.ts @@ -26,6 +26,7 @@ export interface DosOptions { }, loginUrl: string, autoStart: boolean, + kiosk: boolean, } export interface DosProps { @@ -40,6 +41,8 @@ export interface DosProps { setFrame(frame: "network"): void; setBackground(background: string | null): void; setFullScreen(fullScreen: boolean): void; + setAutoStart(autoStart: boolean): void; + setKiosk(kiosk: boolean): void; } export type DosFn = (element: HTMLDivElement, options: Partial) => DosProps; diff --git a/src/sidebar/sidebar.tsx b/src/sidebar/sidebar.tsx index 37de4983..ac96ab2e 100644 --- a/src/sidebar/sidebar.tsx +++ b/src/sidebar/sidebar.tsx @@ -11,6 +11,11 @@ export function SideBar(props: {}) { const window = useSelector((state: State) => state.ui.window); const editor = useSelector((state: State) => state.ui.editor); const backend = useSelector((state: State) => state.dos.backend); + const kiosk = useSelector((state: State) => state.ui.kiosk); + + if (kiosk) { + return null; + } return