making WEB

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-11 00:47:52 +03:00
1 parent 7a18682b0e
commit 24fecc90f3
107 files changed
+14935 -1919

No files matched your search

+121
View File
@@ -0,0 +1,121 @@
import { useEffect } from 'react';
import { appStore, boot, getStoredToken, toast } from './lib/app';
import { initWatch } from './lib/watch';
import { initRouter } from './lib/router';
import { initShortcuts } from './lib/shortcuts';
import { initMediaSession } from './lib/mediaSession';
import { useStore } from './lib/store';
import { useLanguage, t } from './i18n';
import { HelpIcon, MenuIcon } from './components/icons';
import { Sidebar } from './components/Sidebar';
import { MiniPlayer } from './components/MiniPlayer';
import { DialogHost } from './components/DialogHost';
import { ShortcutsHelp } from './components/ShortcutsHelp';
import { NowView } from './views/NowView';
import { QueueView } from './views/QueueView';
import { SearchView } from './views/SearchView';
import { LibraryView } from './views/LibraryView';
import { StatsView } from './views/StatsView';
import { WatchView } from './views/WatchView';
import { ServerView } from './views/ServerView';
import { RpcView } from './views/RpcView';
const HEADS: Record<string, [string, string]> = {
now: ['Now Playing', 'What Echoion is streaming to the channel'],
queue: ['Queue', 'Reorder and manage upcoming tracks'],
search: ['Search', 'Find tracks across YouTube and Yandex Music'],
library: ['Library', 'Your favorites and saved playlists'],
stats: ['History & Stats', 'Playback history and server insights'],
watch: ['Watch Together', 'Synced viewing room — everyone in step'],
server: ['Server & Admin', 'Manage subscribers and broadcast'],
rpc: ['RPC / API', 'Connect to Echoion programmatically'],
};
export function App() {
const s = useStore(appStore);
useLanguage(); // re-render everything on language switch
useEffect(() => {
boot();
initWatch({
getName: () =>
(appStore.get().identity &&
appStore.get().identity!.nickname) ||
null,
getToken: getStoredToken,
toast,
});
initRouter();
initShortcuts();
initMediaSession();
}, []);
const [title, sub] = HEADS[s.view] || HEADS.now;
return (
<div id="app">
<Sidebar />
{s.sidebarOpen && (
<div
className="drawer-backdrop"
onClick={() => appStore.set({ sidebarOpen: false })}
/>
)}
<main className="main">
<header className="header">
<div className="header-title">
<button
className="icon-btn hamburger"
title={t('Menu')}
aria-label={t('Menu')}
onClick={() =>
appStore.set({ sidebarOpen: !s.sidebarOpen })
}
>
<MenuIcon />
</button>
<div>
<h1>{t(title)}</h1>
<div className="header-sub">{t(sub)}</div>
</div>
</div>
<div className="header-right">
<span className="pill">
<span className="dot dot-green" />
{s.onlineCount}&nbsp;{t('listening')}
</span>
<button
className="icon-btn"
title={t('Keyboard shortcuts')}
aria-label={t('Keyboard shortcuts')}
onClick={() =>
appStore.set({ shortcutsOpen: true })
}
>
<HelpIcon />
</button>
</div>
</header>
{s.view === 'now' && <NowView />}
{s.view === 'queue' && <QueueView />}
{s.view === 'search' && <SearchView />}
{s.view === 'library' && <LibraryView />}
{s.view === 'stats' && <StatsView />}
{/* The watch view stays mounted so the embedded player and
room connection survive view switches (the old UI only
toggled `hidden`). */}
<div hidden={s.view !== 'watch'}>
<WatchView />
</div>
{s.view === 'server' && <ServerView />}
{s.view === 'rpc' && <RpcView />}
<MiniPlayer />
</main>
{s.toast && <div className="toast">{s.toast}</div>}
<DialogHost />
<ShortcutsHelp />
</div>
);
}