diff --git a/src/lib/components/LogsModal.svelte b/src/lib/components/LogsModal.svelte index 2004068d2..21e216c4f 100644 --- a/src/lib/components/LogsModal.svelte +++ b/src/lib/components/LogsModal.svelte @@ -5,7 +5,7 @@ import Modal from './Modal.svelte'; import { getConsoleLogsAsText } from '$lib/stores/consoleLogStore'; import { showToast } from '$lib/stores/toastStore'; - import { Loader2 } from 'lucide-svelte'; + import { Loader2, Copy, Check } from 'lucide-svelte'; interface Props { isOpen: boolean; @@ -17,12 +17,18 @@ let activeTab = $state<'terminal' | 'console'>('terminal'); let terminalLogs = $state(''); let consoleLogs = $state(''); - let isUploading = $state(false); + let isUploadingTerminal = $state(false); + let isUploadingConsole = $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() { isLoading = true; + terminalUrl = ''; + consoleUrl = ''; try { const lines: string[] = await invoke('get_backend_logs'); terminalLogs = lines.join('\n'); @@ -33,30 +39,36 @@ isLoading = false; } - function handleOpen() { - if (isOpen) { - loadLogs(); - } - } - $effect(() => { - handleOpen(); + if (isOpen) loadLogs(); }); - async function handleUpload() { - isUploading = true; + async function uploadTab(tab: 'terminal' | 'console') { + const content = tab === 'terminal' ? terminalLogs : consoleLogs; + if (tab === 'terminal') isUploadingTerminal = true; + else isUploadingConsole = true; + 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: combined }); - uploadedUrl = url; + const url: string = await invoke('upload_logs_to_paste', { content }); + if (tab === 'terminal') terminalUrl = url; + else consoleUrl = url; await copyToClipboard(url); showToast($t('settings.developer.uploadSuccess'), 'success'); } catch (e) { showToast(`${$t('settings.developer.uploadError')}: ${e}`, 'error'); } 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); } + } @@ -68,6 +80,7 @@ onclick={() => activeTab = 'terminal'} > {$t('settings.developer.tabTerminal')} + {#if terminalUrl}✓{/if} @@ -91,20 +105,41 @@ {#snippet footer()} + + {#if terminalUrl || consoleUrl} +

+ {$t('settings.developer.bugReportHint')} +

{/if} {/snippet} @@ -118,6 +153,9 @@ } .tab { + display: flex; + align-items: center; + gap: 6px; padding: 6px 16px; border: 1px solid var(--bg-tertiary); background: transparent; @@ -139,6 +177,11 @@ border-color: var(--accent-primary); } + .tab-check { + font-size: 11px; + opacity: 0.8; + } + .log-container { background: var(--bg-secondary); border: 1px solid var(--bg-tertiary); @@ -166,6 +209,20 @@ 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 { display: flex; align-items: center; @@ -178,6 +235,7 @@ font-size: 13px; cursor: pointer; transition: all 150ms ease; + white-space: nowrap; } .upload-btn:hover:not(:disabled) { @@ -189,11 +247,10 @@ cursor: not-allowed; } - .footer-content { + .url-row { display: flex; align-items: center; - gap: 12px; - width: 100%; + gap: 6px; } .uploaded-url { @@ -204,9 +261,33 @@ padding: 4px 8px; border-radius: 4px; 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) { diff --git a/src/lib/i18n/locales/de.json b/src/lib/i18n/locales/de.json index 4e5d0d529..59f63070d 100644 --- a/src/lib/i18n/locales/de.json +++ b/src/lib/i18n/locales/de.json @@ -704,9 +704,11 @@ "tabTerminal": "Terminal", "tabConsole": "Konsole", "uploadLogs": "Zu 0x0.st hochladen", + "uploadTab": "{tab} hochladen", "uploadSuccess": "Log-URL in Zwischenablage kopiert", "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": { "title": "Künstler-Blacklist", diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index 0dbb1ffc5..451477a57 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -724,9 +724,11 @@ "tabTerminal": "Terminal", "tabConsole": "Console", "uploadLogs": "Upload to 0x0.st", + "uploadTab": "Upload {tab}", "uploadSuccess": "Log URL copied to clipboard", "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": { "title": "Artist Blacklist", diff --git a/src/lib/i18n/locales/es.json b/src/lib/i18n/locales/es.json index 0ba729cf7..950b4ff89 100644 --- a/src/lib/i18n/locales/es.json +++ b/src/lib/i18n/locales/es.json @@ -724,9 +724,11 @@ "tabTerminal": "Terminal", "tabConsole": "Consola", "uploadLogs": "Subir a 0x0.st", + "uploadTab": "Subir {tab}", "uploadSuccess": "URL del log copiada al portapapeles", "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": { "title": "Lista Negra de Artistas", diff --git a/src/lib/i18n/locales/fr.json b/src/lib/i18n/locales/fr.json index 96ab452a3..e312ed535 100644 --- a/src/lib/i18n/locales/fr.json +++ b/src/lib/i18n/locales/fr.json @@ -704,9 +704,11 @@ "tabTerminal": "Terminal", "tabConsole": "Console", "uploadLogs": "Téléverser sur 0x0.st", + "uploadTab": "Téléverser {tab}", "uploadSuccess": "URL du log copiée dans le presse-papiers", "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": { "title": "Liste noire des artistes",