Refactor application structure and simplify implementation

This commit is contained in:
2026-07-22 00:08:09 +03:00
parent dbba3806cc
commit 90b2eb507c
74 changed files with 11362 additions and 6814 deletions
+40 -21
View File
@@ -1,8 +1,8 @@
import { Button } from './Button';
import { Button } from "./Button";
export interface LogDockEntry {
id: string;
kind: 'success' | 'error' | 'info';
kind: "success" | "error" | "info";
title: string;
text: string;
at: number;
@@ -18,7 +18,10 @@ export interface LogDockProps {
function isNativePreviewError(entry: LogDockEntry | null) {
if (!entry) return false;
return entry.text.includes("reading 'invoke'") || entry.text.includes('undefined (reading');
return (
entry.text.includes("reading 'invoke'") ||
entry.text.includes("undefined (reading")
);
}
function displayEntry(entry: LogDockEntry | null) {
@@ -26,8 +29,8 @@ function displayEntry(entry: LogDockEntry | null) {
if (!isNativePreviewError(entry)) return entry;
return {
...entry,
title: 'Desktop-команды недоступны',
text: 'Запусти клиент через Tauri, чтобы управлять службами и применять конфиг.',
title: "Desktop-команды недоступны",
text: "Запусти клиент через Tauri, чтобы управлять службами и применять конфиг.",
};
}
@@ -41,8 +44,11 @@ export function LogDock({
const current = displayEntry(activeEntry);
return (
<footer className={`log-dock ${current?.kind ?? 'idle'}`} aria-live="polite">
<div className={`log-current ${current ? 'visible' : 'hidden'}`}>
<footer
className={`log-dock ${current?.kind ?? "idle"}`}
aria-live="polite"
>
<div className={`log-current ${current ? "visible" : "hidden"}`}>
{current ? (
<>
<strong>{current.title}</strong>
@@ -52,24 +58,37 @@ export function LogDock({
<span className="log-muted">Журнал событий</span>
)}
</div>
<Button type="button" variant="neutral" size="sm" className="log-toggle" onClick={onToggle}>
{open ? 'Скрыть' : 'Посмотреть'} <span className="log-count">{entries.length}</span>
<Button
type="button"
variant="neutral"
size="sm"
className="log-toggle"
onClick={onToggle}
>
{open ? "Скрыть" : "Посмотреть"}{" "}
<span className="log-count">{entries.length}</span>
</Button>
{open ? (
<div className="log-history">
{entries.length ? entries.map((entry) => {
const friendly = displayEntry(entry);
return (
<div className={`log-history-row ${entry.kind}`} key={entry.id}>
<time>{formatTime(entry.at)}</time>
<div>
<strong>{friendly?.title ?? entry.title}</strong>
<span>{friendly?.text ?? entry.text}</span>
{isNativePreviewError(entry) ? <span className="log-raw-detail">Детали: {entry.text}</span> : null}
{entries.length ? (
entries.map((entry) => {
const friendly = displayEntry(entry);
return (
<div className={`log-history-row ${entry.kind}`} key={entry.id}>
<time>{formatTime(entry.at)}</time>
<div>
<strong>{friendly?.title ?? entry.title}</strong>
<span>{friendly?.text ?? entry.text}</span>
{isNativePreviewError(entry) ? (
<span className="log-raw-detail">
Детали: {entry.text}
</span>
) : null}
</div>
</div>
</div>
);
}) : (
);
})
) : (
<div className="log-history-row">
<time>--:--:--</time>
<span>Событий пока нет.</span>