Rework LogsModal: per-tab upload, URL display with copy, bug report hint

Upload is now per-tab (Terminal/Console separately). Each tab shows a
checkmark after upload. URL displayed inline with copy button. Help text
appears after first upload encouraging users to share both URLs.
This commit is contained in:
vicrodh committed 2026-02-08 15:13:52 -06:00
1 parent ff968456c8
commit edaf6e442c
5 files changed
+128 -39

No files matched your search

+116 -35
View File
@@ -5,7 +5,7 @@
import Modal from './Modal.svelte'; import Modal from './Modal.svelte';
import { getConsoleLogsAsText } from '$lib/stores/consoleLogStore'; import { getConsoleLogsAsText } from '$lib/stores/consoleLogStore';
import { showToast } from '$lib/stores/toastStore'; import { showToast } from '$lib/stores/toastStore';
import { Loader2 } from 'lucide-svelte'; import { Loader2, Copy, Check } from 'lucide-svelte';
interface Props { interface Props {
isOpen: boolean; isOpen: boolean;
@@ -17,12 +17,18 @@
let activeTab = $state<'terminal' | 'console'>('terminal'); let activeTab = $state<'terminal' | 'console'>('terminal');
let terminalLogs = $state(''); let terminalLogs = $state('');
let consoleLogs = $state(''); let consoleLogs = $state('');
let isUploading = $state(false); let isUploadingTerminal = $state(false);
let isUploadingConsole = $state(false);
let isLoading = $state(false); let isLoading = $state(false);
let uploadedUrl = $state(''); let terminalUrl = $state('');
let consoleUrl = $state('');
let copiedTerminal = $state(false);
let copiedConsole = $state(false);
async function loadLogs() { async function loadLogs() {
isLoading = true; isLoading = true;
terminalUrl = '';
consoleUrl = '';
try { try {
const lines: string[] = await invoke('get_backend_logs'); const lines: string[] = await invoke('get_backend_logs');
terminalLogs = lines.join('\n'); terminalLogs = lines.join('\n');
@@ -33,30 +39,36 @@
isLoading = false; isLoading = false;
} }
function handleOpen() {
if (isOpen) {
loadLogs();
}
}
$effect(() => { $effect(() => {
handleOpen(); if (isOpen) loadLogs();
}); });
async function handleUpload() { async function uploadTab(tab: 'terminal' | 'console') {
isUploading = true; const content = tab === 'terminal' ? terminalLogs : consoleLogs;
if (tab === 'terminal') isUploadingTerminal = true;
else isUploadingConsole = true;
try { try {
const combined = `=== QBZ Terminal Logs ===\n${terminalLogs}\n\n=== QBZ Console Logs ===\n${consoleLogs}`; const url: string = await invoke('upload_logs_to_paste', { content });
const url: string = await invoke('upload_logs_to_paste', { content: combined }); if (tab === 'terminal') terminalUrl = url;
uploadedUrl = url; else consoleUrl = url;
await copyToClipboard(url); await copyToClipboard(url);
showToast($t('settings.developer.uploadSuccess'), 'success'); showToast($t('settings.developer.uploadSuccess'), 'success');
} catch (e) { } catch (e) {
showToast(`${$t('settings.developer.uploadError')}: ${e}`, 'error'); showToast(`${$t('settings.developer.uploadError')}: ${e}`, 'error');
} finally { } finally {
isUploading = false; if (tab === 'terminal') isUploadingTerminal = false;
else isUploadingConsole = false;
} }
} }
async function copyUrl(tab: 'terminal' | 'console') {
const url = tab === 'terminal' ? terminalUrl : consoleUrl;
if (!url) return;
await copyToClipboard(url);
if (tab === 'terminal') { copiedTerminal = true; setTimeout(() => copiedTerminal = false, 2000); }
else { copiedConsole = true; setTimeout(() => copiedConsole = false, 2000); }
}
</script> </script>
<Modal {isOpen} {onClose} title={$t('settings.developer.logsTitle')} maxWidth="760px"> <Modal {isOpen} {onClose} title={$t('settings.developer.logsTitle')} maxWidth="760px">
@@ -68,6 +80,7 @@
onclick={() => activeTab = 'terminal'} onclick={() => activeTab = 'terminal'}
> >
{$t('settings.developer.tabTerminal')} {$t('settings.developer.tabTerminal')}
{#if terminalUrl}<span class="tab-check">&#10003;</span>{/if}
</button> </button>
<button <button
class="tab" class="tab"
@@ -75,6 +88,7 @@
onclick={() => activeTab = 'console'} onclick={() => activeTab = 'console'}
> >
{$t('settings.developer.tabConsole')} {$t('settings.developer.tabConsole')}
{#if consoleUrl}<span class="tab-check">&#10003;</span>{/if}
</button> </button>
</div> </div>
@@ -91,20 +105,41 @@
{#snippet footer()} {#snippet footer()}
<div class="footer-content"> <div class="footer-content">
<button <div class="footer-left">
class="upload-btn" <button
onclick={handleUpload} class="upload-btn"
disabled={isUploading} onclick={() => uploadTab(activeTab)}
> disabled={activeTab === 'terminal' ? isUploadingTerminal : isUploadingConsole}
{#if isUploading} >
<Loader2 size={14} class="spin" /> {#if (activeTab === 'terminal' ? isUploadingTerminal : isUploadingConsole)}
{$t('settings.developer.uploading')} <Loader2 size={14} class="spin" />
{:else} {$t('settings.developer.uploading')}
{$t('settings.developer.uploadLogs')} {:else}
{$t('settings.developer.uploadTab', { values: { tab: activeTab === 'terminal' ? $t('settings.developer.tabTerminal') : $t('settings.developer.tabConsole') } })}
{/if}
</button>
{#if activeTab === 'terminal' && terminalUrl}
<div class="url-row">
<code class="uploaded-url">{terminalUrl}</code>
<button class="copy-url-btn" onclick={() => copyUrl('terminal')}>
{#if copiedTerminal}<Check size={12} />{:else}<Copy size={12} />{/if}
</button>
</div>
{/if} {/if}
</button> {#if activeTab === 'console' && consoleUrl}
{#if uploadedUrl} <div class="url-row">
<code class="uploaded-url">{uploadedUrl}</code> <code class="uploaded-url">{consoleUrl}</code>
<button class="copy-url-btn" onclick={() => copyUrl('console')}>
{#if copiedConsole}<Check size={12} />{:else}<Copy size={12} />{/if}
</button>
</div>
{/if}
</div>
{#if terminalUrl || consoleUrl}
<p class="help-hint">
{$t('settings.developer.bugReportHint')}
</p>
{/if} {/if}
</div> </div>
{/snippet} {/snippet}
@@ -118,6 +153,9 @@
} }
.tab { .tab {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 16px; padding: 6px 16px;
border: 1px solid var(--bg-tertiary); border: 1px solid var(--bg-tertiary);
background: transparent; background: transparent;
@@ -139,6 +177,11 @@
border-color: var(--accent-primary); border-color: var(--accent-primary);
} }
.tab-check {
font-size: 11px;
opacity: 0.8;
}
.log-container { .log-container {
background: var(--bg-secondary); background: var(--bg-secondary);
border: 1px solid var(--bg-tertiary); border: 1px solid var(--bg-tertiary);
@@ -166,6 +209,20 @@
color: var(--text-muted); color: var(--text-muted);
} }
.footer-content {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
width: 100%;
}
.footer-left {
display: flex;
flex-direction: column;
gap: 8px;
}
.upload-btn { .upload-btn {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -178,6 +235,7 @@
font-size: 13px; font-size: 13px;
cursor: pointer; cursor: pointer;
transition: all 150ms ease; transition: all 150ms ease;
white-space: nowrap;
} }
.upload-btn:hover:not(:disabled) { .upload-btn:hover:not(:disabled) {
@@ -189,11 +247,10 @@
cursor: not-allowed; cursor: not-allowed;
} }
.footer-content { .url-row {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 12px; gap: 6px;
width: 100%;
} }
.uploaded-url { .uploaded-url {
@@ -204,9 +261,33 @@
padding: 4px 8px; padding: 4px 8px;
border-radius: 4px; border-radius: 4px;
user-select: all; user-select: all;
overflow: hidden; }
text-overflow: ellipsis;
white-space: nowrap; .copy-url-btn {
display: flex;
align-items: center;
justify-content: center;
padding: 4px;
background: transparent;
border: none;
color: var(--text-muted);
border-radius: 4px;
cursor: pointer;
transition: all 150ms ease;
}
.copy-url-btn:hover {
background: var(--bg-hover);
color: var(--text-primary);
}
.help-hint {
font-size: 12px;
color: var(--text-muted);
line-height: 1.5;
margin: 0;
max-width: 280px;
text-align: right;
} }
:global(.spin) { :global(.spin) {
+3 -1
View File
@@ -704,9 +704,11 @@
"tabTerminal": "Terminal", "tabTerminal": "Terminal",
"tabConsole": "Konsole", "tabConsole": "Konsole",
"uploadLogs": "Zu 0x0.st hochladen", "uploadLogs": "Zu 0x0.st hochladen",
"uploadTab": "{tab} hochladen",
"uploadSuccess": "Log-URL in Zwischenablage kopiert", "uploadSuccess": "Log-URL in Zwischenablage kopiert",
"uploadError": "Fehler beim Hochladen der Logs", "uploadError": "Fehler beim Hochladen der Logs",
"uploading": "Wird hochgeladen..." "uploading": "Wird hochgeladen...",
"bugReportHint": "Fehler melden? Laden Sie beide Tabs hoch und teilen Sie beide URLs — das hilft uns, Probleme schneller zu beheben. Danke!"
}, },
"blacklist": { "blacklist": {
"title": "Künstler-Blacklist", "title": "Künstler-Blacklist",
+3 -1
View File
@@ -724,9 +724,11 @@
"tabTerminal": "Terminal", "tabTerminal": "Terminal",
"tabConsole": "Console", "tabConsole": "Console",
"uploadLogs": "Upload to 0x0.st", "uploadLogs": "Upload to 0x0.st",
"uploadTab": "Upload {tab}",
"uploadSuccess": "Log URL copied to clipboard", "uploadSuccess": "Log URL copied to clipboard",
"uploadError": "Failed to upload logs", "uploadError": "Failed to upload logs",
"uploading": "Uploading..." "uploading": "Uploading...",
"bugReportHint": "Reporting a bug? Upload both tabs and share both URLs — it helps us fix things faster. Thanks!"
}, },
"blacklist": { "blacklist": {
"title": "Artist Blacklist", "title": "Artist Blacklist",
+3 -1
View File
@@ -724,9 +724,11 @@
"tabTerminal": "Terminal", "tabTerminal": "Terminal",
"tabConsole": "Consola", "tabConsole": "Consola",
"uploadLogs": "Subir a 0x0.st", "uploadLogs": "Subir a 0x0.st",
"uploadTab": "Subir {tab}",
"uploadSuccess": "URL del log copiada al portapapeles", "uploadSuccess": "URL del log copiada al portapapeles",
"uploadError": "Error al subir los logs", "uploadError": "Error al subir los logs",
"uploading": "Subiendo..." "uploading": "Subiendo...",
"bugReportHint": "Si vas a reportar un bug, sube ambas pestanas y comparte las dos URLs — nos ayuda a resolver el problema mas rapido. Gracias!"
}, },
"blacklist": { "blacklist": {
"title": "Lista Negra de Artistas", "title": "Lista Negra de Artistas",
+3 -1
View File
@@ -704,9 +704,11 @@
"tabTerminal": "Terminal", "tabTerminal": "Terminal",
"tabConsole": "Console", "tabConsole": "Console",
"uploadLogs": "Téléverser sur 0x0.st", "uploadLogs": "Téléverser sur 0x0.st",
"uploadTab": "Téléverser {tab}",
"uploadSuccess": "URL du log copiée dans le presse-papiers", "uploadSuccess": "URL du log copiée dans le presse-papiers",
"uploadError": "Échec du téléversement des logs", "uploadError": "Échec du téléversement des logs",
"uploading": "Téléversement..." "uploading": "Téléversement...",
"bugReportHint": "Vous signalez un bug ? Téléversez les deux onglets et partagez les deux URLs — cela nous aide a résoudre les problèmes plus vite. Merci !"
}, },
"blacklist": { "blacklist": {
"title": "Liste noire des artistes", "title": "Liste noire des artistes",