diff --git a/package.json b/package.json
index 2a27ce0..7f46485 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"version": "2.0.0",
"type": "module",
"scripts": {
- "dev": "vite",
+ "dev": "vite --host",
"build": "vite build",
"serve": "vite build && node server.js",
"test": "vitest",
diff --git a/src/components/ControllerPage.vue b/src/components/ControllerPage.vue
index f0ee409..6e44ff9 100644
--- a/src/components/ControllerPage.vue
+++ b/src/components/ControllerPage.vue
@@ -113,6 +113,8 @@
@click="configData.modalita = '2/3'">2/3
+
@@ -228,7 +230,7 @@ export default {
return null
},
isPartitaFinita() {
- if (!this.setVintoTeam) return false
+ if (!this.setVintoTeam || this.state.modalitaPartita === 'amichevole') return false
const setsToWin = this.state.modalitaPartita === '2/3' ? 2 : 3
return this.set[this.setVintoTeam] + 1 >= setsToWin
},
diff --git a/src/gameState.js b/src/gameState.js
index 6c0f5a8..3b7167f 100644
--- a/src/gameState.js
+++ b/src/gameState.js
@@ -46,6 +46,7 @@ export function checkVittoria(state) {
}
export function checkVittoriaPartita(state) {
+ if (state.modalitaPartita === 'amichevole') return false
const setsToWin = state.modalitaPartita === "2/3" ? 2 : 3
const sv = setVinti(state.sp.striscia)
return sv.home >= setsToWin || sv.guest >= setsToWin
diff --git a/src/server-utils.js b/src/server-utils.js
index 06f5867..63fb3ec 100644
--- a/src/server-utils.js
+++ b/src/server-utils.js
@@ -1,20 +1,34 @@
import { networkInterfaces } from 'os'
+import { readFileSync, existsSync } from 'fs'
+import { execSync } from 'child_process'
+
+function isWSL() {
+ try {
+ return existsSync('/proc/sys/kernel/osrelease') &&
+ readFileSync('/proc/sys/kernel/osrelease', 'utf8').toLowerCase().includes('microsoft')
+ } catch { return false }
+}
export function getNetworkIPs() {
- const nets = networkInterfaces()
- const networkIPs = []
-
- for (const name of Object.keys(nets)) {
- for (const net of nets[name]) {
- if (net.family === 'IPv4' &&
- !net.internal &&
- !net.address.startsWith('172.17.') &&
- !net.address.startsWith('172.18.')) {
- networkIPs.push(net.address)
- }
- }
+ if (isWSL()) {
+ try {
+ const out = execSync(
+ 'powershell.exe -NoProfile -Command "Get-NetIPAddress -AddressFamily IPv4 | Select-Object -ExpandProperty IPAddress"',
+ { timeout: 3000 }
+ )
+ return out.toString().trim().split('\n')
+ .map(s => s.trim())
+ .filter(ip => ip && !ip.startsWith('127.') && !ip.startsWith('169.254.') && !ip.startsWith('172.'))
+ } catch { return [] }
}
+ const nets = networkInterfaces()
+ const networkIPs = []
+ for (const name of Object.keys(nets)) {
+ for (const net of nets[name]) {
+ if (net.family === 'IPv4' && !net.internal) networkIPs.push(net.address)
+ }
+ }
return networkIPs
}
@@ -26,9 +40,10 @@ export function printServerInfo(port = 3000) {
console.log(` Controller: http://127.0.0.1:${port}/controller`)
if (networkIPs.length > 0) {
- console.log(`\n Controller da dispositivi remoti:`)
+ console.log(`\n Da dispositivi remoti:`)
networkIPs.forEach(ip => {
- console.log(` http://${ip}:${port}/controller`)
+ console.log(` Display: http://${ip}:${port}/display`)
+ console.log(` Controller: http://${ip}:${port}/controller`)
})
}