From 8348547baa7164c871c15e96a8b08b90e7b9b5a6 Mon Sep 17 00:00:00 2001 From: denis0001-dev Date: Sun, 24 Aug 2025 23:15:20 +0300 Subject: [PATCH] Adapt the web version to Electron --- frontend/electron.d.ts | 12 ++ frontend/electron/main.ts | 13 +- frontend/electron/preload.ts | 9 + frontend/index.html | 354 ++++++++++++++++--------------- frontend/src/auth.ts | 3 + frontend/src/css/_auth.scss | 2 +- frontend/src/css/_chat.scss | 2 + frontend/src/css/_electron.scss | 43 ++++ frontend/src/css/_panelchat.scss | 2 +- frontend/src/css/style.scss | 8 + frontend/src/electron.ts | 10 + frontend/src/main.ts | 3 +- 12 files changed, 286 insertions(+), 175 deletions(-) create mode 100644 frontend/electron.d.ts create mode 100644 frontend/src/css/_electron.scss create mode 100644 frontend/src/electron.ts diff --git a/frontend/electron.d.ts b/frontend/electron.d.ts new file mode 100644 index 0000000..ae8b74e --- /dev/null +++ b/frontend/electron.d.ts @@ -0,0 +1,12 @@ +export type Platform = "win32" | "darwin" | "linux" + +export interface ElectronInterface { + desktop: true, + platform: Platform +} + +declare global { + interface Window { + electronInterface: ElectronInterface + } +} \ No newline at end of file diff --git a/frontend/electron/main.ts b/frontend/electron/main.ts index 4fab3df..55fbeb7 100644 --- a/frontend/electron/main.ts +++ b/frontend/electron/main.ts @@ -1,10 +1,21 @@ import { app, BrowserWindow } from 'electron'; +import path from "node:path"; app.whenReady().then(() => { const win = new BrowserWindow({ title: 'Main window', minWidth: 650, - minHeight: 420 + minHeight: 420, + webPreferences: { + preload: path.join(import.meta.dirname, "preload.mjs") + }, + titleBarStyle: "hidden", + ...(process.platform !== 'darwin' ? { titleBarOverlay: true } : {}), + trafficLightPosition: { + x: 16 - 4, + y: 16 - 4 + }, + titleBarOverlay: process.platform !== "darwin" }) // You can use `process.env.VITE_DEV_SERVER_URL` when the vite command is called `serve` diff --git a/frontend/electron/preload.ts b/frontend/electron/preload.ts index e69de29..4d99711 100644 --- a/frontend/electron/preload.ts +++ b/frontend/electron/preload.ts @@ -0,0 +1,9 @@ +import { contextBridge } from "electron"; +import type { ElectronInterface, Platform } from "../electron"; + +const electronInterface: ElectronInterface = { + desktop: true, + platform: process.platform as Platform +} + +contextBridge.exposeInMainWorld("electronInterface", electronInterface); \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index 5a1549b..96eb4a7 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -7,185 +7,197 @@ - -
-
-
-

- login - Добро пожаловать! -

-

Войдите в свой аккаунт

-
-
-
- -
- - - - - - Войти -
- -
-

Ещё нет аккаунта? Зарегистрируйтесь

-
-
-
+
+
+
+
- - -