mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-05-24 10:29:11 +00:00
Update: Electron implementation changed BrowserRouter to HashRouter due to Electron implementation issues. Basic Electron build configuration in package.json.
This commit is contained in:
parent
3f633d6dc5
commit
f2e239beaa
29
main.cjs
29
main.cjs
@ -1,41 +1,30 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('node:path');
|
||||
const { app, BrowserWindow, Menu } = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
|
||||
|
||||
function createWindow() {
|
||||
const isDev = !app.isPackaged; // Detectar si es entorno de desarrollo
|
||||
const isDev = !app.isPackaged;
|
||||
const win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
//icon: path.join(__dirname, 'public/favicon.ico'),
|
||||
icon: path.join(__dirname, 'favicon.ico'),
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
contextIsolation: true, // Mejora la seguridad
|
||||
enableRemoteModule: false, // Deshabilitar módulos remotos por seguridad
|
||||
nodeIntegration: false, // Desactiva integración con Node.js
|
||||
contextIsolation: true,
|
||||
enableRemoteModule: false,
|
||||
},
|
||||
});
|
||||
|
||||
if (isDev) {
|
||||
// En desarrollo, cargar la URL del servidor de Vite
|
||||
win.loadURL('http://localhost:5173');
|
||||
win.webContents.openDevTools(); // Abrir herramientas de desarrollo
|
||||
win.webContents.openDevTools();
|
||||
} else {
|
||||
// En producción, cargar el archivo index.html de la carpeta dist
|
||||
win.loadFile(path.join(__dirname, 'dist/index.html'));
|
||||
}
|
||||
|
||||
if (!isDev) {
|
||||
import('@vercel/analytics').then(({ inject }) => inject());
|
||||
win.loadURL(`file://${path.join(__dirname, 'dist/index.html')}`);
|
||||
Menu.setApplicationMenu(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
|
51
package-lock.json
generated
51
package-lock.json
generated
@ -7507,6 +7507,17 @@
|
||||
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/isomorphic.js": {
|
||||
"version": "0.2.5",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.5.tgz",
|
||||
"integrity": "sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"type": "GitHub Sponsors ❤",
|
||||
"url": "https://github.com/sponsors/dmonad"
|
||||
}
|
||||
},
|
||||
"node_modules/iterator.prototype": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.3.tgz",
|
||||
@ -7772,6 +7783,28 @@
|
||||
"resolved": "https://registry.npmjs.org/lexical/-/lexical-0.12.6.tgz",
|
||||
"integrity": "sha512-Nlfjc+k9cIWpOMv7XufF0Mv09TAXSemNAuAqFLaOwTcN+RvhvYTDtVLSp9D9r+5I097fYs1Vf/UYwH2xEpkFfQ=="
|
||||
},
|
||||
"node_modules/lib0": {
|
||||
"version": "0.2.98",
|
||||
"resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.98.tgz",
|
||||
"integrity": "sha512-XteTiNO0qEXqqweWx+b21p/fBnNHUA1NwAtJNJek1oPrewEZs2uiT4gWivHKr9GqCjDPAhchz0UQO8NwU3bBNA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"isomorphic.js": "^0.2.4"
|
||||
},
|
||||
"bin": {
|
||||
"0ecdsa-generate-keypair": "bin/0ecdsa-generate-keypair.js",
|
||||
"0gentesthtml": "bin/gentesthtml.js",
|
||||
"0serve": "bin/0serve.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"funding": {
|
||||
"type": "GitHub Sponsors ❤",
|
||||
"url": "https://github.com/sponsors/dmonad"
|
||||
}
|
||||
},
|
||||
"node_modules/lilconfig": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz",
|
||||
@ -12775,6 +12808,24 @@
|
||||
"fd-slicer": "~1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/yjs": {
|
||||
"version": "13.6.20",
|
||||
"resolved": "https://registry.npmjs.org/yjs/-/yjs-13.6.20.tgz",
|
||||
"integrity": "sha512-Z2YZI+SYqK7XdWlloI3lhMiKnCdFCVC4PchpdO+mCYwtiTwncjUbnRK9R1JmkNfdmHyDXuWN3ibJAt0wsqTbLQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"lib0": "^0.2.98"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0",
|
||||
"npm": ">=8.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "GitHub Sponsors ❤",
|
||||
"url": "https://github.com/sponsors/dmonad"
|
||||
}
|
||||
},
|
||||
"node_modules/yocto-queue": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||
|
@ -62,6 +62,12 @@
|
||||
"win": {
|
||||
"target": "nsis",
|
||||
"signAndEditExecutable": false
|
||||
},
|
||||
"mac": {
|
||||
"target": "dmg"
|
||||
},
|
||||
"linux": {
|
||||
"target": ["AppImage", "deb", "rpm"]
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
|
||||
import { HashRouter, Routes, Route, useLocation } from "react-router-dom";
|
||||
import { useLayoutEffect } from "react";
|
||||
import Editor from "./pages/Editor";
|
||||
import Survey from "./pages/Survey";
|
||||
@ -13,7 +13,8 @@ import NotFound from "./pages/NotFound";
|
||||
export default function App() {
|
||||
return (
|
||||
<SettingsContextProvider>
|
||||
<BrowserRouter>
|
||||
{/* Cambiado de BrowserRouter a HashRouter */}
|
||||
<HashRouter>
|
||||
<RestoreScroll />
|
||||
<Routes>
|
||||
<Route path="/" element={<LandingPage />} />
|
||||
@ -52,7 +53,7 @@ export default function App() {
|
||||
<Route path="/templates" element={<Templates />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</HashRouter>
|
||||
</SettingsContextProvider>
|
||||
);
|
||||
}
|
||||
|
@ -4,13 +4,13 @@ import react from '@vitejs/plugin-react'
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
base: './', // Esto asegura que las rutas generadas sean relativas al archivo index.html
|
||||
base: './',
|
||||
build: {
|
||||
outDir: 'dist', // Carpeta de salida para producción
|
||||
emptyOutDir: true, // Limpia la carpeta antes de construir
|
||||
outDir: 'dist',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
server: {
|
||||
port: 5173, // El puerto donde Vite escucha por defecto
|
||||
port: 5173,
|
||||
},
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user