primero
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
# Dependencias
|
||||
node_modules/
|
||||
|
||||
# Variables de entorno
|
||||
.env
|
||||
|
||||
# Archivos de logs
|
||||
*.log
|
||||
|
||||
# Archivos del sistema
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Carpetas de compilación
|
||||
dist/
|
||||
build/
|
||||
@@ -0,0 +1,32 @@
|
||||
# Template Design App — Electron + React
|
||||
|
||||
Starter de escritorio centrado en la estructura de la referencia, con estilos neutros en escala de grises. Incluye panel principal, título editable, columnas de texto, panel de preview y variantes seleccionables.
|
||||
|
||||
## Requisitos
|
||||
- Node.js 20 o superior (recomendado)
|
||||
- npm
|
||||
|
||||
## Ejecutar en desarrollo
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Compilar el frontend
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Abrir la versión compilada
|
||||
Después de `npm run build`:
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
## Estructura
|
||||
- `electron/main.cjs`: ventana principal de Electron.
|
||||
- `electron/preload.cjs`: puente seguro para futuras APIs de escritorio.
|
||||
- `src/App.jsx`: componentes y estado de la interfaz.
|
||||
- `src/styles.css`: layout y diseño adaptable.
|
||||
|
||||
La aplicación mantiene `nodeIntegration: false` y `contextIsolation: true`. Para añadir acceso a archivos, diálogos nativos o persistencia, expón funciones concretas desde `preload.cjs` y valídalas en el proceso principal; no habilites Node directamente dentro de React.
|
||||
@@ -0,0 +1,31 @@
|
||||
const { app, BrowserWindow } = require("electron");
|
||||
const path = require("node:path");
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
width: 1120,
|
||||
height: 760,
|
||||
minWidth: 760,
|
||||
minHeight: 560,
|
||||
backgroundColor: "#7daeb7",
|
||||
title: "Template Design App",
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload.cjs"),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false
|
||||
}
|
||||
});
|
||||
|
||||
win.loadURL("http://localhost:5173");
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
app.on("activate", () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") app.quit();
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
const { contextBridge } = require("electron");
|
||||
|
||||
// Expose only safe, purpose-specific APIs here when the app needs them.
|
||||
contextBridge.exposeInMainWorld("desktopApp", {
|
||||
platform: process.platform
|
||||
});
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Mi aplicación</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+3399
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "electron-react-template-layout",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "electron/main.cjs",
|
||||
"scripts": {
|
||||
"dev": "concurrently -k \"vite\" \"wait-on http://localhost:5173 && electron .\"",
|
||||
"build": "vite build",
|
||||
"start": "electron ."
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"concurrently": "^9.1.2",
|
||||
"electron": "^33.2.1",
|
||||
"vite": "^6.0.5",
|
||||
"wait-on": "^8.0.1"
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import Navbar from './components/Navbar';
|
||||
import Sidebar from './components/Sidebar';
|
||||
import CanvasArea from './components/CanvasArea';
|
||||
import './styles.css';
|
||||
|
||||
export default function App() {
|
||||
// Array de enlaces
|
||||
const links = [
|
||||
{ title: "Personal", url: "#Personal" },
|
||||
{ title: "Inventario", url: "#Inventario" },
|
||||
{ title: "Incidencias", url: "#Incidencias" },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="app-container">
|
||||
<Navbar />
|
||||
<div className="main-layout">
|
||||
<Sidebar links={links} />
|
||||
<CanvasArea />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function CanvasArea() {
|
||||
return (
|
||||
<main className="canvas-container">
|
||||
<canvas
|
||||
id="mainCanvas"
|
||||
ref={(canvas) => {
|
||||
if (canvas && canvas.parentElement) {
|
||||
canvas.width = canvas.parentElement.clientWidth - 40;
|
||||
canvas.height = canvas.parentElement.clientHeight - 40;
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (ctx) {
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function NavBtn({ title, url }) {
|
||||
return (
|
||||
<a href={url} className="nav-btn">
|
||||
{title}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import React, { useState} from 'react';
|
||||
import NavBtn from './NavBtn';
|
||||
|
||||
export default function Navbar() {
|
||||
|
||||
const [hora] = useState(() => new Date().toLocaleTimeString());
|
||||
|
||||
return (
|
||||
<header className="nav-menu">
|
||||
<div className="nav-logo">
|
||||
<img src="https://img.magnific.com/vector-premium/vector-diseno-logotipo-minimalista-abstracto-creativo-elegante-cualquier-empresa-marca_1253202-135975.jpg?semt=ais_hybrid&w=740&q=80" alt="Logo" className="nav-logo"></img>
|
||||
</div>
|
||||
<div className="nav-brand">Empresa Avelino</div>
|
||||
<div className="nav-buttons">
|
||||
</div>
|
||||
<div className="nav-time">{hora}</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
import NavBtn from './NavBtn';
|
||||
|
||||
export default function Sidebar({ links }) {
|
||||
return (
|
||||
<aside className="sidebar">
|
||||
<h3>SIDEBAR</h3>
|
||||
<div className='sidebar-buttons'>
|
||||
{links.map((link, index) => (
|
||||
<NavBtn key={index} title={link.title} url={link.url}/>
|
||||
))}
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App.jsx'
|
||||
import './styles.css' // <-- Asegúrate de que esta línea apunte al nombre real de tu archivo CSS
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
)
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
body, html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
font-family: sans-serif;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
background-color: #1e1e1e;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* NAV MENU Superior */
|
||||
.nav-menu {
|
||||
height: 50px;
|
||||
background-color: #202020;
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 20px;
|
||||
border-bottom: 1px solid #333;
|
||||
flex-shrink: 0; /* Evita que el menú se reduzca de tamaño */
|
||||
}
|
||||
|
||||
.nav-brand {
|
||||
font-weight: bold;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
background-color: #333333;
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.nav-btn:hover {
|
||||
background-color: #555555;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
/* Layout principal */
|
||||
.main-layout {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 180px;
|
||||
background-color: #2b2b2b;
|
||||
color: white;
|
||||
padding: 15px;
|
||||
border-right: 1px solid #333;
|
||||
flex-shrink: 0; /* Mantiene fijo el ancho del sidebar */
|
||||
}
|
||||
|
||||
.sidebar ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.sidebar li {
|
||||
padding: 8px 0;
|
||||
color: #aaa;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.sidebar li:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Contenedor del Canvas flexible */
|
||||
.canvas-container {
|
||||
flex: 1;
|
||||
background-color: #121212;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* El elemento canvas llena todo su contenedor */
|
||||
#mainCanvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.sidebar-buttons {
|
||||
display: flex;
|
||||
flex-direction: column; /* Esto hace que se apilen de arriba a abajo */
|
||||
gap: 10px; /* Espacio opcional de separación entre cada botón */
|
||||
margin-top: 15px; /* Separación opcional respecto al título "SIDEBAR" */
|
||||
}
|
||||
|
||||
.nav-logo {
|
||||
height: 40px;
|
||||
width: auto;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
base: "./",
|
||||
server: { host: "127.0.0.1", port: 5173, strictPort: true }
|
||||
});
|
||||
Reference in New Issue
Block a user