feat(clients): scaffold mobile (Capacitor) + desktop (Electron) shells
Plan + decisions in CLIENTS.md (parallel mobile+desktop; desktop = technician client + existing remote-control agent host; mobile = Capacitor wrap). - desktop/: Electron technician client — loads the live Connect UI, native screen capture via setDisplayMediaRequestHandler, persisted session, external links to browser; electron-builder config for Win/Mac/Linux installers. - mobile/: Capacitor project — server.url loads Connect UI, push/camera/status-bar plugins declared, www splash fallback; iOS/Android added via `cap add`. - Reuses the existing /api/v1 + Bearer auth backend; no web-code changes. - .gitignore: ignore generated mobile/android, mobile/ios platform dirs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cette révision appartient à :
@@ -0,0 +1,26 @@
|
||||
# Biz Connect — Desktop client
|
||||
|
||||
Electron shell that loads the live Connect web UI and adds native screen capture. See the
|
||||
overall plan in [../CLIENTS.md](../CLIENTS.md).
|
||||
|
||||
## Run (dev)
|
||||
```bash
|
||||
npm install
|
||||
SERVER_URL=http://localhost:8090 npm start # default is https://remote.bizgaze.com
|
||||
```
|
||||
|
||||
## Build installers
|
||||
```bash
|
||||
npm run dist # electron-builder → Win NSIS / Mac dmg / Linux AppImage
|
||||
```
|
||||
Signed, trusted installers need certificates:
|
||||
- **Windows:** an EV (or OV) code-signing certificate.
|
||||
- **macOS:** Apple Developer ID cert + notarization (`CSC_LINK`, `APPLE_ID`, `APPLE_APP_SPECIFIC_PASSWORD`).
|
||||
|
||||
## Notes
|
||||
- The window loads `${SERVER_URL}/home`; relative `/api` and `/ws` URLs work because the
|
||||
origin is the server itself — no web-code changes.
|
||||
- `setDisplayMediaRequestHandler` in `main.js` is what makes "Share Screen" work in Electron;
|
||||
it currently defaults to the primary display. Swap in a source-picker for production.
|
||||
- The session is persisted (`persist:bizconnect`) so login survives restarts.
|
||||
- `window.__NATIVE__ === 'desktop'` is exposed for the web UI to feature-detect.
|
||||
@@ -0,0 +1,62 @@
|
||||
// Biz Connect — technician desktop client (Electron main process).
|
||||
//
|
||||
// This is a thin shell: it loads the live Connect web UI from the server origin, so every
|
||||
// relative /api and /ws URL in the web app keeps working unchanged. What it adds over a
|
||||
// browser tab:
|
||||
// - native full-screen capture for "Share Screen" (setDisplayMediaRequestHandler)
|
||||
// - a real desktop window (no browser chrome), persisted login session
|
||||
// - external links open in the user's browser, not inside the app
|
||||
//
|
||||
// Server origin is configurable so the same build works against prod or a dev server.
|
||||
const { app, BrowserWindow, session, desktopCapturer, shell, Menu } = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
const SERVER_URL = (process.env.SERVER_URL || 'https://remote.bizgaze.com').replace(/\/+$/, '');
|
||||
|
||||
let win;
|
||||
|
||||
function createWindow() {
|
||||
win = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
minWidth: 880,
|
||||
minHeight: 600,
|
||||
title: 'Biz Connect',
|
||||
backgroundColor: '#0f1830',
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
// Persist cookies/localStorage so the technician stays logged in between launches.
|
||||
partition: 'persist:bizconnect',
|
||||
},
|
||||
});
|
||||
|
||||
win.loadURL(SERVER_URL + '/home');
|
||||
|
||||
// Open target=_blank / external links in the system browser instead of a new Electron window.
|
||||
win.webContents.setWindowOpenHandler(({ url }) => {
|
||||
if (!url.startsWith(SERVER_URL)) { shell.openExternal(url); return { action: 'deny' }; }
|
||||
return { action: 'allow' };
|
||||
});
|
||||
}
|
||||
|
||||
// Electron requires an explicit handler for getDisplayMedia(); without it the web UI's
|
||||
// "Share Screen" silently fails. Default to the primary display with loopback audio.
|
||||
// A production build can swap this for a source-picker window.
|
||||
function registerDisplayMediaHandler() {
|
||||
session.fromPartition('persist:bizconnect').setDisplayMediaRequestHandler((request, callback) => {
|
||||
desktopCapturer.getSources({ types: ['screen', 'window'] }).then((sources) => {
|
||||
callback(sources.length ? { video: sources[0], audio: 'loopback' } : {});
|
||||
}).catch(() => callback({}));
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
registerDisplayMediaHandler();
|
||||
createWindow();
|
||||
Menu.setApplicationMenu(null); // hide the default menu bar; the web UI is the chrome
|
||||
app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); });
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); });
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "biz-connect-desktop",
|
||||
"version": "0.1.0",
|
||||
"description": "Biz Connect technician desktop client — loads the Connect web UI with native screen capture",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"dist": "electron-builder"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^31.0.0",
|
||||
"electron-builder": "^24.13.3"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.bizgaze.connect.desktop",
|
||||
"productName": "Biz Connect",
|
||||
"files": ["main.js", "preload.js", "assets/**"],
|
||||
"win": { "target": "nsis" },
|
||||
"mac": { "target": "dmg", "category": "public.app-category.business" },
|
||||
"linux": { "target": "AppImage" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Minimal, safe bridge into the web UI. Runs with contextIsolation, so it only exposes a
|
||||
// frozen marker the web app can feature-detect against (e.g. to hide the PWA install prompt
|
||||
// or prefer native push). No Node APIs are exposed to page JS.
|
||||
const { contextBridge } = require('electron');
|
||||
|
||||
contextBridge.exposeInMainWorld('__NATIVE__', 'desktop');
|
||||
contextBridge.exposeInMainWorld('bizConnectNative', Object.freeze({
|
||||
platform: 'desktop',
|
||||
version: process.env.npm_package_version || '0.1.0',
|
||||
}));
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur