Step 1 of adding a backend proxy server (API keys held server-side instead of shipped in the installer). Moves everything app-specific into "Max Avatar/" via git mv (preserves history): src/, tests/, scripts/, assets/, build/, resources/, package.json/-lock.json, electron-builder.yml, electron.vite.config.ts, eslint.config.mjs, playwright.config.ts, vitest.config.mts, sonar-project.properties, tsconfig*.json, Dockerfile, .editorconfig/.env*/.gitignore/.prettier*. CLAUDE.md, README.md, docs/, .claude/, .gitea/, .husky/, .vscode/, and the docker-compose files stay at the repo root, since they'll apply to both the app and the future backend. No application code needed changes (all its internal paths are relative to its own tree). Adjusted what referenced the old root from outside: - .husky/pre-commit: cd into "Max Avatar" before lint-staged - .gitea/workflows/*.yml: working-directory + cache-dependency-path + artifact paths + SonarQube projectBaseDir - docker-compose.yml: build context -> ./Max Avatar - Max Avatar/Dockerfile: node:20-alpine -> node:24-alpine (same node:sqlite issue already fixed elsewhere, never applied here before) - .vscode/launch.json, README.md: updated paths/instructions Verified from Max Avatar/ after the move: npm ci, typecheck, lint, test:coverage (473/473, same coverage numbers), build, and dev all work unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { BrowserWindow } from 'electron'
|
|
import { join } from 'path'
|
|
import { is } from '@electron-toolkit/utils'
|
|
import { SECURE_WEB_PREFERENCES, blockExternalNavigation } from '../utils/windowSecurity'
|
|
|
|
let win: BrowserWindow | null = null
|
|
|
|
export interface ModuleTarget {
|
|
subject: string
|
|
module: string
|
|
}
|
|
|
|
function sendNavigateToModule(window: BrowserWindow, target: ModuleTarget): void {
|
|
const send = (): void => window.webContents.send('navigate-to-module', target)
|
|
if (window.webContents.isLoading()) {
|
|
window.webContents.once('did-finish-load', send)
|
|
} else {
|
|
send()
|
|
}
|
|
}
|
|
|
|
// Fenetre normale et independante de l'avatar (qui continue de s'afficher a cote, inchange) :
|
|
// meme principe singleton que src/main/browser/browserWindow.ts, mais charge le renderer compile
|
|
// de l'app avec un hash different plutot qu'une URL externe.
|
|
export function openCoachProgressWindow(navigateTo?: ModuleTarget): void {
|
|
if (win && !win.isDestroyed()) {
|
|
win.show()
|
|
win.moveTop()
|
|
win.focus()
|
|
if (navigateTo) sendNavigateToModule(win, navigateTo)
|
|
return
|
|
}
|
|
|
|
win = new BrowserWindow({
|
|
width: 480,
|
|
height: 640,
|
|
title: "Max — courbe d'apprentissage",
|
|
alwaysOnTop: true,
|
|
webPreferences: {
|
|
preload: join(__dirname, '../preload/index.js'),
|
|
...SECURE_WEB_PREFERENCES
|
|
}
|
|
})
|
|
blockExternalNavigation(win)
|
|
win.setAlwaysOnTop(true, 'floating')
|
|
win.maximize()
|
|
win.on('closed', () => {
|
|
win = null
|
|
})
|
|
|
|
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
|
void win.loadURL(`${process.env['ELECTRON_RENDERER_URL']}#coach-progress`)
|
|
} else {
|
|
void win.loadFile(join(__dirname, '../renderer/index.html'), { hash: 'coach-progress' })
|
|
}
|
|
|
|
if (navigateTo) sendNavigateToModule(win, navigateTo)
|
|
}
|