Remove: Electron Desktop-App Versionsnummer und Update-Check
Desktop App ist nur ein Wrapper - Web-Inhalte updaten sich automatisch. Separate Version verwirrt User wenn sie nicht übereinstimmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
961a947e91
commit
33e718ddf6
1 changed files with 1 additions and 136 deletions
137
web/src/App.tsx
137
web/src/App.tsx
|
|
@ -27,8 +27,6 @@ export function registerTab(pluginName: string, component: React.FC<{ data: any
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [connected, setConnected] = useState(false);
|
const [connected, setConnected] = useState(false);
|
||||||
const [plugins, setPlugins] = useState<PluginInfo[]>([]);
|
const [plugins, setPlugins] = useState<PluginInfo[]>([]);
|
||||||
const [updateState, setUpdateState] = useState<'idle' | 'checking' | 'downloading' | 'ready' | 'uptodate' | 'error'>('idle');
|
|
||||||
const [updateError, setUpdateError] = useState<string>('');
|
|
||||||
const [activeTab, setActiveTabRaw] = useState<string>(() => localStorage.getItem('hub_activeTab') ?? '');
|
const [activeTab, setActiveTabRaw] = useState<string>(() => localStorage.getItem('hub_activeTab') ?? '');
|
||||||
|
|
||||||
const setActiveTab = (tab: string) => {
|
const setActiveTab = (tab: string) => {
|
||||||
|
|
@ -103,30 +101,6 @@ export default function App() {
|
||||||
|
|
||||||
const version = (import.meta as any).env?.VITE_APP_VERSION ?? 'dev';
|
const version = (import.meta as any).env?.VITE_APP_VERSION ?? 'dev';
|
||||||
|
|
||||||
// Listen for Electron auto-update events
|
|
||||||
useEffect(() => {
|
|
||||||
const api = (window as any).electronAPI;
|
|
||||||
if (!api?.onUpdateAvailable) return;
|
|
||||||
api.onUpdateAvailable(() => {
|
|
||||||
setUpdateState('downloading');
|
|
||||||
if (Notification.permission === 'granted') {
|
|
||||||
new Notification('Gaming Hub Update', { body: 'Ein Update wird heruntergeladen...' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
api.onUpdateReady(() => {
|
|
||||||
setUpdateState('ready');
|
|
||||||
if (Notification.permission === 'granted') {
|
|
||||||
new Notification('Gaming Hub Update bereit', { body: 'Klicke OK um das Update zu installieren.' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
api.onUpdateNotAvailable?.(() => setUpdateState('uptodate'));
|
|
||||||
api.onUpdateError?.((msg: string) => {
|
|
||||||
setUpdateError(msg || 'Unbekannter Fehler');
|
|
||||||
setUpdateState('error');
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const electronVersion = (window as any).electronAPI?.version ?? null;
|
|
||||||
|
|
||||||
// Close version modal on Escape
|
// Close version modal on Escape
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -136,16 +110,6 @@ export default function App() {
|
||||||
return () => window.removeEventListener('keydown', handler);
|
return () => window.removeEventListener('keydown', handler);
|
||||||
}, [showVersionModal]);
|
}, [showVersionModal]);
|
||||||
|
|
||||||
const handleCheckForUpdates = () => {
|
|
||||||
setUpdateState('checking');
|
|
||||||
setUpdateError('');
|
|
||||||
(window as any).electronAPI?.checkForUpdates?.();
|
|
||||||
// Timeout: falls Electron nicht antwortet, nach 15s zurücksetzen
|
|
||||||
setTimeout(() => {
|
|
||||||
setUpdateState(prev => prev === 'checking' ? 'error' : prev);
|
|
||||||
setUpdateError(prev => prev || 'Zeitüberschreitung — Server nicht erreichbar.');
|
|
||||||
}, 15000);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Tab icon mapping
|
// Tab icon mapping
|
||||||
const tabIcons: Record<string, string> = {
|
const tabIcons: Record<string, string> = {
|
||||||
|
|
@ -195,16 +159,6 @@ export default function App() {
|
||||||
<span className="hub-download-label">Desktop App</span>
|
<span className="hub-download-label">Desktop App</span>
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
{(window as any).electronAPI && (
|
|
||||||
<button
|
|
||||||
className="hub-check-update-btn"
|
|
||||||
onClick={handleCheckForUpdates}
|
|
||||||
disabled={updateState !== 'idle'}
|
|
||||||
title="Nach Updates suchen"
|
|
||||||
>
|
|
||||||
{'\u{1F504}'}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
<span
|
<span
|
||||||
className="hub-version hub-version-clickable"
|
className="hub-version hub-version-clickable"
|
||||||
onClick={() => setShowVersionModal(true)}
|
onClick={() => setShowVersionModal(true)}
|
||||||
|
|
@ -215,81 +169,6 @@ export default function App() {
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{updateState !== 'idle' && (
|
|
||||||
<div className="hub-update-overlay">
|
|
||||||
<div className="hub-update-modal">
|
|
||||||
{updateState === 'checking' && (
|
|
||||||
<>
|
|
||||||
<div className="hub-update-icon">{'\u{1F50D}'}</div>
|
|
||||||
<h2>Suche nach Updates...</h2>
|
|
||||||
<div className="hub-update-versions">
|
|
||||||
{electronVersion && <span>Desktop App: v{electronVersion}</span>}
|
|
||||||
<span>Server: v{version}</span>
|
|
||||||
</div>
|
|
||||||
<div className="hub-update-progress">
|
|
||||||
<div className="hub-update-progress-bar" />
|
|
||||||
</div>
|
|
||||||
<button className="hub-update-btn" onClick={() => setUpdateState('idle')}>
|
|
||||||
Abbrechen
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{updateState === 'downloading' && (
|
|
||||||
<>
|
|
||||||
<div className="hub-update-icon">{'\u2B07\uFE0F'}</div>
|
|
||||||
<h2>Update wird heruntergeladen...</h2>
|
|
||||||
<div className="hub-update-versions">
|
|
||||||
{electronVersion && <span>Aktuell: v{electronVersion}</span>}
|
|
||||||
</div>
|
|
||||||
<div className="hub-update-progress">
|
|
||||||
<div className="hub-update-progress-bar" />
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{updateState === 'ready' && (
|
|
||||||
<>
|
|
||||||
<div className="hub-update-icon">{'\u2705'}</div>
|
|
||||||
<h2>Update bereit!</h2>
|
|
||||||
<p>Die App wird neu gestartet, um das Update zu installieren.</p>
|
|
||||||
<button className="hub-update-btn" onClick={() => (window as any).electronAPI?.installUpdate()}>
|
|
||||||
Jetzt installieren
|
|
||||||
</button>
|
|
||||||
<button className="hub-update-btn hub-update-btn-secondary" onClick={() => setUpdateState('idle')}>
|
|
||||||
Später
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{updateState === 'uptodate' && (
|
|
||||||
<>
|
|
||||||
<div className="hub-update-icon">{'\u2705'}</div>
|
|
||||||
<h2>Alles aktuell!</h2>
|
|
||||||
<div className="hub-update-versions">
|
|
||||||
{electronVersion && <span>Desktop App: v{electronVersion}</span>}
|
|
||||||
<span>Server: v{version}</span>
|
|
||||||
</div>
|
|
||||||
<p>Du verwendest bereits die neueste Version.</p>
|
|
||||||
<button className="hub-update-btn" onClick={() => setUpdateState('idle')}>
|
|
||||||
OK
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{updateState === 'error' && (
|
|
||||||
<>
|
|
||||||
<div className="hub-update-icon">{'\u274C'}</div>
|
|
||||||
<h2>Update fehlgeschlagen</h2>
|
|
||||||
<div className="hub-update-versions">
|
|
||||||
{electronVersion && <span>Desktop App: v{electronVersion}</span>}
|
|
||||||
<span>Server: v{version}</span>
|
|
||||||
</div>
|
|
||||||
{updateError && <p className="hub-update-error-detail">{updateError}</p>}
|
|
||||||
<button className="hub-update-btn" onClick={() => setUpdateState('idle')}>
|
|
||||||
Schließen
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{showVersionModal && (
|
{showVersionModal && (
|
||||||
<div className="hub-version-overlay" onClick={() => setShowVersionModal(false)}>
|
<div className="hub-version-overlay" onClick={() => setShowVersionModal(false)}>
|
||||||
|
|
@ -302,18 +181,9 @@ export default function App() {
|
||||||
</div>
|
</div>
|
||||||
<div className="hub-version-modal-body">
|
<div className="hub-version-modal-body">
|
||||||
<div className="hub-version-modal-row">
|
<div className="hub-version-modal-row">
|
||||||
<span className="hub-version-modal-label">Hub Version</span>
|
<span className="hub-version-modal-label">Version</span>
|
||||||
<span className="hub-version-modal-value">v{version}</span>
|
<span className="hub-version-modal-value">v{version}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="hub-version-modal-row">
|
|
||||||
<span className="hub-version-modal-label">Desktop App</span>
|
|
||||||
<span className="hub-version-modal-value">
|
|
||||||
{electronVersion
|
|
||||||
? `v${electronVersion}`
|
|
||||||
: <a href="/downloads/GamingHub-Setup.exe" download className="hub-version-modal-link">Herunterladen</a>
|
|
||||||
}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="hub-version-modal-row">
|
<div className="hub-version-modal-row">
|
||||||
<span className="hub-version-modal-label">Server</span>
|
<span className="hub-version-modal-label">Server</span>
|
||||||
<span className="hub-version-modal-value">
|
<span className="hub-version-modal-value">
|
||||||
|
|
@ -321,11 +191,6 @@ export default function App() {
|
||||||
{connected ? 'Verbunden' : 'Getrennt'}
|
{connected ? 'Verbunden' : 'Getrennt'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{electronVersion && electronVersion !== version && (
|
|
||||||
<div className="hub-version-modal-hint">
|
|
||||||
Desktop App und Hub Version unterschiedlich — Update verfügbar.
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue