feat: separazione display e controller su porte distinte (5173/3001)

- Creati entry point separati per il Display (porta 5173) e il Controller (porta 3001).
- Aggiunti controller.html e src/controller-main.js per l'app di controllo remoto.
- Semplificato src/main.js per montare direttamente DisplayPage, rimuovendo vue-router.
- Implementato un server di sviluppo proxy per il controller in vite-plugin-websocket.js.
- Aggiornato server.js per gestire due istanze Express (display e controller) in produzione.
- Aggiornata la configurazione di Vite per il supporto alla build multi-pagina
This commit is contained in:
2026-02-10 23:45:58 +01:00
parent 9598d587c6
commit f84f3805cd
10 changed files with 211 additions and 53 deletions

View File

@@ -308,7 +308,7 @@ export default {
this.isConnecting = true
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:'
const wsUrl = `${protocol}//${location.host}`
const wsUrl = `${protocol}//${location.host}/ws`
try {
this.ws = new WebSocket(wsUrl)

View File

@@ -221,7 +221,7 @@ export default {
this.isConnecting = true
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:'
const wsUrl = `${protocol}//${location.host}`
const wsUrl = `${protocol}//${location.host}/ws`
try {
this.ws = new WebSocket(wsUrl)

9
src/controller-main.js Normal file
View File

@@ -0,0 +1,9 @@
import { createApp } from 'vue'
import './style.css'
import WaveUI from 'wave-ui'
import 'wave-ui/dist/wave-ui.css'
import ControllerPage from './components/ControllerPage.vue'
const app = createApp(ControllerPage)
app.use(WaveUI)
app.mount('#app')

View File

@@ -1,21 +1,12 @@
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import './style.css'
import App from './App.vue'
import WaveUI from 'wave-ui'
import 'wave-ui/dist/wave-ui.css'
import DisplayPage from './components/DisplayPage.vue'
import ControllerPage from './components/ControllerPage.vue'
const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/', component: DisplayPage },
{ path: '/controller', component: ControllerPage },
],
})
const app = createApp(App)
app.use(router)
// In modalità display-only, non serve il router.
// Il display viene montato direttamente.
const app = createApp(DisplayPage)
app.use(WaveUI)
app.mount('#app')

View File

@@ -12,9 +12,9 @@ export function getNetworkIPs() {
for (const net of nets[name]) {
// Esclude loopback (127.0.0.1), indirizzi non IPv4 e bridge Docker (172.17.x.x, 172.18.x.x).
if (net.family === 'IPv4' &&
!net.internal &&
!net.address.startsWith('172.17.') &&
!net.address.startsWith('172.18.')) {
!net.internal &&
!net.address.startsWith('172.17.') &&
!net.address.startsWith('172.18.')) {
networkIPs.push(net.address)
}
}
@@ -25,19 +25,20 @@ export function getNetworkIPs() {
/**
* Stampa il riepilogo di avvio del server con gli URL di accesso.
* @param {number} port - Porta sulla quale il server e in ascolto.
* @param {number} displayPort - Porta del display.
* @param {number} controllerPort - Porta del controller.
*/
export function printServerInfo(port = 5173) {
export function printServerInfo(displayPort = 5173, controllerPort = 3001) {
const networkIPs = getNetworkIPs()
console.log(`\nSegnapunti Server`)
console.log(` Display: http://localhost:${port}/`)
console.log(` Controller: http://localhost:${port}/controller`)
console.log(` Display: http://localhost:${displayPort}/`)
console.log(` Controller: http://localhost:${controllerPort}/`)
if (networkIPs.length > 0) {
console.log(`\n Da dispositivi remoti:`)
console.log(`\n Controller da dispositivi remoti:`)
networkIPs.forEach(ip => {
console.log(` http://${ip}:${port}/controller`)
console.log(` http://${ip}:${controllerPort}/`)
})
}