Add: Update-Modal mit Download-Fortschritt in Electron App
- Modal-Overlay statt Banner fuer Update-Benachrichtigung - 3 Zustaende: Downloading (Ladeanimation), Ready (OK-Button), Error - IPC-Events: update-available, update-ready, update-error
This commit is contained in:
parent
feeabe147c
commit
c2942737bd
4 changed files with 94 additions and 22 deletions
|
|
@ -27,7 +27,7 @@ export function registerTab(pluginName: string, component: React.FC<{ data: any
|
|||
export default function App() {
|
||||
const [connected, setConnected] = useState(false);
|
||||
const [plugins, setPlugins] = useState<PluginInfo[]>([]);
|
||||
const [updateReady, setUpdateReady] = useState(false);
|
||||
const [updateState, setUpdateState] = useState<'idle' | 'downloading' | 'ready' | 'error'>('idle');
|
||||
const [activeTab, setActiveTabRaw] = useState<string>(() => localStorage.getItem('hub_activeTab') ?? '');
|
||||
|
||||
const setActiveTab = (tab: string) => {
|
||||
|
|
@ -97,8 +97,10 @@ export default function App() {
|
|||
// Listen for Electron auto-update events
|
||||
useEffect(() => {
|
||||
const api = (window as any).electronAPI;
|
||||
if (!api?.onUpdateReady) return;
|
||||
api.onUpdateReady(() => setUpdateReady(true));
|
||||
if (!api?.onUpdateAvailable) return;
|
||||
api.onUpdateAvailable(() => setUpdateState('downloading'));
|
||||
api.onUpdateReady(() => setUpdateState('ready'));
|
||||
api.onUpdateError?.(() => setUpdateState('error'));
|
||||
}, []);
|
||||
|
||||
// Tab icon mapping
|
||||
|
|
@ -153,12 +155,40 @@ export default function App() {
|
|||
</div>
|
||||
</header>
|
||||
|
||||
{updateReady && (
|
||||
<div className="hub-update-bar">
|
||||
<span>Neues Update verfügbar!</span>
|
||||
<button onClick={() => (window as any).electronAPI?.installUpdate()}>
|
||||
Jetzt neu starten
|
||||
</button>
|
||||
{updateState !== 'idle' && (
|
||||
<div className="hub-update-overlay">
|
||||
<div className="hub-update-modal">
|
||||
{updateState === 'downloading' && (
|
||||
<>
|
||||
<div className="hub-update-icon">{'\u2B07\uFE0F'}</div>
|
||||
<h2>Update verfügbar</h2>
|
||||
<p>Update wird heruntergeladen...</p>
|
||||
<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()}>
|
||||
OK
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{updateState === 'error' && (
|
||||
<>
|
||||
<div className="hub-update-icon">{'\u274C'}</div>
|
||||
<h2>Update fehlgeschlagen</h2>
|
||||
<p>Das Update konnte nicht heruntergeladen werden.</p>
|
||||
<button className="hub-update-btn" onClick={() => setUpdateState('idle')}>
|
||||
Schließen
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -226,22 +226,61 @@ html, body {
|
|||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* ── Update Banner ── */
|
||||
.hub-update-bar {
|
||||
/* ── Update Modal ── */
|
||||
.hub-update-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 8px 16px;
|
||||
background: rgba(var(--accent-rgb), 0.15);
|
||||
border-bottom: 1px solid rgba(var(--accent-rgb), 0.3);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--accent);
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
.hub-update-bar button {
|
||||
padding: 4px 14px;
|
||||
font-size: 12px;
|
||||
.hub-update-modal {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
padding: 32px 40px;
|
||||
text-align: center;
|
||||
min-width: 320px;
|
||||
max-width: 400px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.hub-update-icon {
|
||||
font-size: 40px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.hub-update-modal h2 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 18px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.hub-update-modal p {
|
||||
margin: 0 0 20px;
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.hub-update-progress {
|
||||
height: 4px;
|
||||
border-radius: 2px;
|
||||
background: var(--bg-deep);
|
||||
overflow: hidden;
|
||||
}
|
||||
.hub-update-progress-bar {
|
||||
height: 100%;
|
||||
width: 40%;
|
||||
border-radius: 2px;
|
||||
background: var(--accent);
|
||||
animation: hub-update-slide 1.5s ease-in-out infinite;
|
||||
}
|
||||
@keyframes hub-update-slide {
|
||||
0% { transform: translateX(-100%); }
|
||||
100% { transform: translateX(350%); }
|
||||
}
|
||||
.hub-update-btn {
|
||||
padding: 8px 32px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
|
|
@ -250,7 +289,7 @@ html, body {
|
|||
cursor: pointer;
|
||||
transition: opacity var(--transition);
|
||||
}
|
||||
.hub-update-bar button:hover {
|
||||
.hub-update-btn:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue