mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Rework layout to match the real TS3 client's structure
Adds a menu bar, an icon-based toolbar, and splits the right side into a channel/server info panel (topic, codec, password, client count) on top of the chat log - previously a single click switched channels, now that only selects/shows info while a double-click actually joins, like the native client. Required exposing a few more real protocol fields from tsclientlib (channel codec/topic/max clients/password, server name/max clients) that weren't surfaced before. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ec034d2d6b
commit
95a3761235
4 files changed
+349
-80
No files matched your search
+111
-7
@@ -54,19 +54,92 @@
|
||||
|
||||
/* Toolbar */
|
||||
|
||||
.ts-toolbar {
|
||||
.ts-menubar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
gap: 1.1rem;
|
||||
padding: 0.25rem 0.75rem;
|
||||
background: var(--bg-toolbar-1);
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.ts-menubar-item {
|
||||
color: var(--text-muted);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.ts-toolbar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
padding: 0.4rem 0.75rem;
|
||||
background: linear-gradient(to bottom, var(--bg-toolbar-1), var(--bg-toolbar-2));
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.ts-toolbar-icons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.ts-icon-button {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 3px;
|
||||
background: linear-gradient(to bottom, var(--button-bg-1), var(--button-bg-2));
|
||||
color: var(--text);
|
||||
padding: 0.25rem 0.5rem;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.ts-icon-button:hover {
|
||||
background: linear-gradient(to bottom, var(--button-bg-hover-1), var(--button-bg-hover-2));
|
||||
}
|
||||
|
||||
.ts-icon-button:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.ts-toolbar-sep {
|
||||
width: 1px;
|
||||
align-self: stretch;
|
||||
background: var(--border);
|
||||
margin: 0 0.2rem;
|
||||
}
|
||||
|
||||
.ts-icon-slider,
|
||||
.ts-icon-select {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.ts-icon-slider input[type="range"] {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.ts-icon-select select {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 2px;
|
||||
padding: 0.1rem 0.3rem;
|
||||
font-size: 12px;
|
||||
background: var(--input-bg);
|
||||
color: var(--input-text);
|
||||
max-width: 160px;
|
||||
}
|
||||
|
||||
.ts-app-title {
|
||||
font-weight: 600;
|
||||
color: var(--accent);
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.ts-toolbar-fields {
|
||||
@@ -127,11 +200,6 @@
|
||||
background: linear-gradient(to bottom, var(--button-bg-hover-1), var(--button-bg-hover-2));
|
||||
}
|
||||
|
||||
.ts-theme-toggle {
|
||||
padding: 0.2rem 0.5rem !important;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* Body / tree */
|
||||
|
||||
.ts-body {
|
||||
@@ -149,6 +217,42 @@
|
||||
border-right: 1px solid var(--border-soft);
|
||||
}
|
||||
|
||||
.ts-main-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ts-info-panel {
|
||||
flex-shrink: 0;
|
||||
padding: 0.6rem 0.9rem;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
background: var(--bg-toolbar-1);
|
||||
}
|
||||
|
||||
.ts-info-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: var(--accent);
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
||||
|
||||
.ts-info-row {
|
||||
display: flex;
|
||||
gap: 0.4rem;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.ts-row-selected {
|
||||
background: var(--row-hover);
|
||||
outline: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.ts-tree-empty {
|
||||
color: var(--text-muted);
|
||||
padding: 1rem;
|
||||
|
||||
+185
-63
@@ -21,8 +21,14 @@ interface ChannelInfo {
|
||||
parent: number;
|
||||
order: number;
|
||||
name: string;
|
||||
topic: string;
|
||||
codec: string;
|
||||
maxClients: number | null;
|
||||
hasPassword: boolean;
|
||||
}
|
||||
|
||||
type SelectedItem = { type: "server" } | { type: "channel"; id: number };
|
||||
|
||||
interface ClientInfo {
|
||||
id: number;
|
||||
channel: number;
|
||||
@@ -85,7 +91,9 @@ function ChannelTree({
|
||||
parent,
|
||||
ownClientId,
|
||||
talkers,
|
||||
onSelectChannel,
|
||||
selected,
|
||||
onSelectItem,
|
||||
onSwitchChannel,
|
||||
onOpenPrivateChat,
|
||||
onPokeClient,
|
||||
}: {
|
||||
@@ -94,7 +102,9 @@ function ChannelTree({
|
||||
parent: number;
|
||||
ownClientId: number | null;
|
||||
talkers: Set<number>;
|
||||
onSelectChannel: (channelId: number) => void;
|
||||
selected: SelectedItem | null;
|
||||
onSelectItem: (item: SelectedItem) => void;
|
||||
onSwitchChannel: (channelId: number) => void;
|
||||
onOpenPrivateChat: (clientId: number, clientName: string) => void;
|
||||
onPokeClient: (clientId: number, clientName: string) => void;
|
||||
}) {
|
||||
@@ -105,9 +115,17 @@ function ChannelTree({
|
||||
<ul className="ts-tree-list">
|
||||
{children.map((channel) => (
|
||||
<li key={channel.id}>
|
||||
<div className="ts-row ts-channel-row" onClick={() => onSelectChannel(channel.id)}>
|
||||
<div
|
||||
className={`ts-row ts-channel-row${
|
||||
selected?.type === "channel" && selected.id === channel.id ? " ts-row-selected" : ""
|
||||
}`}
|
||||
onClick={() => onSelectItem({ type: "channel", id: channel.id })}
|
||||
onDoubleClick={() => onSwitchChannel(channel.id)}
|
||||
title="Click to select, double-click to join"
|
||||
>
|
||||
<ChannelIcon />
|
||||
<span>{channel.name}</span>
|
||||
{channel.hasPassword && <span title="Password protected">🔒</span>}
|
||||
</div>
|
||||
<ul className="ts-tree-list">
|
||||
{clients
|
||||
@@ -146,7 +164,9 @@ function ChannelTree({
|
||||
parent={channel.id}
|
||||
ownClientId={ownClientId}
|
||||
talkers={talkers}
|
||||
onSelectChannel={onSelectChannel}
|
||||
selected={selected}
|
||||
onSelectItem={onSelectItem}
|
||||
onSwitchChannel={onSwitchChannel}
|
||||
onOpenPrivateChat={onOpenPrivateChat}
|
||||
onPokeClient={onPokeClient}
|
||||
/>
|
||||
@@ -156,6 +176,65 @@ function ChannelTree({
|
||||
);
|
||||
}
|
||||
|
||||
function InfoPanel({
|
||||
selected,
|
||||
host,
|
||||
serverName,
|
||||
serverMaxClients,
|
||||
totalClientCount,
|
||||
channels,
|
||||
clients,
|
||||
}: {
|
||||
selected: SelectedItem | null;
|
||||
host: string;
|
||||
serverName: string;
|
||||
serverMaxClients: number;
|
||||
totalClientCount: number;
|
||||
channels: ChannelInfo[];
|
||||
clients: ClientInfo[];
|
||||
}) {
|
||||
if (!selected || selected.type === "server") {
|
||||
return (
|
||||
<div className="ts-info-panel">
|
||||
<div className="ts-info-title">
|
||||
<ServerIcon />
|
||||
<span>{serverName || host}</span>
|
||||
</div>
|
||||
<div className="ts-info-row">
|
||||
<span>Clients:</span> <span>{totalClientCount} / {serverMaxClients || "∞"}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const channel = channels.find((c) => c.id === selected.id);
|
||||
if (!channel) return <div className="ts-info-panel" />;
|
||||
const clientCount = clients.filter((c) => c.channel === channel.id).length;
|
||||
|
||||
return (
|
||||
<div className="ts-info-panel">
|
||||
<div className="ts-info-title">
|
||||
<ChannelIcon />
|
||||
<span>{channel.name}</span>
|
||||
</div>
|
||||
{channel.topic && (
|
||||
<div className="ts-info-row">
|
||||
<span>Topic:</span> <span>{channel.topic}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="ts-info-row">
|
||||
<span>Audio Codec:</span> <span>{channel.codec}</span>
|
||||
</div>
|
||||
<div className="ts-info-row">
|
||||
<span>Password protected:</span> <span>{channel.hasPassword ? "Yes" : "No"}</span>
|
||||
</div>
|
||||
<div className="ts-info-row">
|
||||
<span>Clients:</span> <span>{clientCount} / {channel.maxClients ?? "∞"}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface ChatEntry {
|
||||
from: string;
|
||||
message: string;
|
||||
@@ -193,6 +272,9 @@ function App() {
|
||||
const [connectError, setConnectError] = useState<string | null>(null);
|
||||
const [channels, setChannels] = useState<ChannelInfo[]>([]);
|
||||
const [clients, setClients] = useState<ClientInfo[]>([]);
|
||||
const [serverName, setServerName] = useState("");
|
||||
const [serverMaxClients, setServerMaxClients] = useState(0);
|
||||
const [selected, setSelected] = useState<SelectedItem | null>(null);
|
||||
const [chat, setChat] = useState<ChatEntry[]>([]);
|
||||
const [serverChat, setServerChat] = useState<ChatEntry[]>([]);
|
||||
const [chatInput, setChatInput] = useState("");
|
||||
@@ -300,6 +382,9 @@ function App() {
|
||||
setConnected(true);
|
||||
localStorage.setItem(LAST_HOST_KEY, host);
|
||||
localStorage.setItem(LAST_NICKNAME_KEY, nickname);
|
||||
setServerName(data.serverName);
|
||||
setServerMaxClients(data.serverMaxClients);
|
||||
setSelected({ type: "server" });
|
||||
setServerChat((prev) => [...prev, { from: "Server", message: data.welcomeMessage }]);
|
||||
break;
|
||||
case "channels":
|
||||
@@ -350,6 +435,7 @@ function App() {
|
||||
setConnected(false);
|
||||
setChannels([]);
|
||||
setClients([]);
|
||||
setSelected(null);
|
||||
setChat([]);
|
||||
setServerChat([]);
|
||||
setPmThreads({});
|
||||
@@ -432,10 +518,12 @@ function App() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelectChannel = (channelId: number) => {
|
||||
const handleSwitchChannel = (channelId: number) => {
|
||||
socketRef.current?.send(JSON.stringify({ type: "switchChannel", channelId }));
|
||||
};
|
||||
|
||||
const handleSelectItem = (item: SelectedItem) => setSelected(item);
|
||||
|
||||
const handleSendChat = () => {
|
||||
const message = chatInput.trim();
|
||||
if (!message) return;
|
||||
@@ -486,69 +574,40 @@ function App() {
|
||||
|
||||
return (
|
||||
<div className={`ts-app ts-theme-${theme}`}>
|
||||
<div className="ts-menubar">
|
||||
{["Verbindungen", "Favoriten", "Selbst", "Rechte", "Extras", "Hilfe"].map((item) => (
|
||||
<span key={item} className="ts-menubar-item">
|
||||
{item}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="ts-toolbar">
|
||||
<span className="ts-app-title">TS Web Client</span>
|
||||
<div className="ts-toolbar-fields">
|
||||
<label>
|
||||
Server
|
||||
<input value={host} onChange={(e) => setHost(e.target.value)} disabled={connected || connecting} />
|
||||
</label>
|
||||
<label>
|
||||
Nickname
|
||||
<input
|
||||
value={nickname}
|
||||
onChange={(e) => setNickname(e.target.value)}
|
||||
disabled={connected || connecting}
|
||||
/>
|
||||
</label>
|
||||
{!connected && (
|
||||
<button
|
||||
className={showPasswordFields ? "ts-mic-on" : undefined}
|
||||
onClick={() => setShowPasswordFields((v) => !v)}
|
||||
disabled={connecting}
|
||||
title="Server/channel password"
|
||||
>
|
||||
🔒
|
||||
</button>
|
||||
)}
|
||||
{!connected && showPasswordFields && (
|
||||
<>
|
||||
<label>
|
||||
Server password
|
||||
<input
|
||||
type="password"
|
||||
value={serverPassword}
|
||||
onChange={(e) => setServerPassword(e.target.value)}
|
||||
disabled={connecting}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Channel password
|
||||
<input
|
||||
type="password"
|
||||
value={channelPassword}
|
||||
onChange={(e) => setChannelPassword(e.target.value)}
|
||||
disabled={connecting}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
<div className="ts-toolbar-icons">
|
||||
{!connected ? (
|
||||
<button onClick={handleConnect} disabled={connecting}>
|
||||
{connecting ? "Connecting…" : "Connect"}
|
||||
<button
|
||||
className="ts-icon-button"
|
||||
onClick={handleConnect}
|
||||
disabled={connecting}
|
||||
title={connecting ? "Connecting…" : "Connect"}
|
||||
>
|
||||
🟢
|
||||
</button>
|
||||
) : (
|
||||
<button onClick={handleDisconnect}>Disconnect</button>
|
||||
<button className="ts-icon-button" onClick={handleDisconnect} title="Disconnect">
|
||||
🔴
|
||||
</button>
|
||||
)}
|
||||
<span className="ts-toolbar-sep" />
|
||||
<button
|
||||
className={micOn ? "ts-mic-on" : undefined}
|
||||
className={`ts-icon-button${micOn ? " ts-mic-on" : ""}`}
|
||||
onClick={handleToggleMic}
|
||||
disabled={!connected}
|
||||
title={micOn ? "Voice activation on - click to mute" : "Enable microphone (voice activation)"}
|
||||
>
|
||||
{micOn ? "🎤" : "🔇"}
|
||||
</button>
|
||||
<label title="Voice activation sensitivity">
|
||||
<label className="ts-icon-slider" title="Voice activation sensitivity">
|
||||
🎚️
|
||||
<input
|
||||
type="range"
|
||||
@@ -560,11 +619,11 @@ function App() {
|
||||
/>
|
||||
</label>
|
||||
{hasNativeOutputPicker() ? (
|
||||
<button onClick={handlePickOutputDevice} title="Choose output device">
|
||||
🔊 {outputDeviceLabel}
|
||||
<button className="ts-icon-button" onClick={handlePickOutputDevice} title="Choose output device">
|
||||
🔊
|
||||
</button>
|
||||
) : (
|
||||
<label>
|
||||
<label className="ts-icon-select">
|
||||
🔊
|
||||
<select
|
||||
value={outputDeviceId}
|
||||
@@ -580,14 +639,59 @@ function App() {
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<span className="ts-toolbar-sep" />
|
||||
<button
|
||||
className="ts-theme-toggle"
|
||||
className="ts-icon-button"
|
||||
onClick={() => setTheme((t) => (t === "dark" ? "light" : "dark"))}
|
||||
title="Toggle theme"
|
||||
>
|
||||
{theme === "dark" ? "☀️" : "🌙"}
|
||||
</button>
|
||||
<span className="ts-app-title">TS Web Client</span>
|
||||
</div>
|
||||
|
||||
{!connected && (
|
||||
<div className="ts-toolbar-fields">
|
||||
<label>
|
||||
Server
|
||||
<input value={host} onChange={(e) => setHost(e.target.value)} disabled={connecting} />
|
||||
</label>
|
||||
<label>
|
||||
Nickname
|
||||
<input value={nickname} onChange={(e) => setNickname(e.target.value)} disabled={connecting} />
|
||||
</label>
|
||||
<button
|
||||
className={showPasswordFields ? "ts-mic-on" : undefined}
|
||||
onClick={() => setShowPasswordFields((v) => !v)}
|
||||
disabled={connecting}
|
||||
title="Server/channel password"
|
||||
>
|
||||
🔒
|
||||
</button>
|
||||
{showPasswordFields && (
|
||||
<>
|
||||
<label>
|
||||
Server password
|
||||
<input
|
||||
type="password"
|
||||
value={serverPassword}
|
||||
onChange={(e) => setServerPassword(e.target.value)}
|
||||
disabled={connecting}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Channel password
|
||||
<input
|
||||
type="password"
|
||||
value={channelPassword}
|
||||
onChange={(e) => setChannelPassword(e.target.value)}
|
||||
disabled={connecting}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{connectError && (
|
||||
@@ -636,9 +740,12 @@ function App() {
|
||||
<div className="ts-tree-panel">
|
||||
{connected ? (
|
||||
<>
|
||||
<div className="ts-row ts-server-row">
|
||||
<div
|
||||
className={`ts-row ts-server-row${selected?.type === "server" ? " ts-row-selected" : ""}`}
|
||||
onClick={() => handleSelectItem({ type: "server" })}
|
||||
>
|
||||
<ServerIcon />
|
||||
<span>{host}</span>
|
||||
<span>{serverName || host}</span>
|
||||
</div>
|
||||
<ChannelTree
|
||||
channels={channels}
|
||||
@@ -646,7 +753,9 @@ function App() {
|
||||
parent={0}
|
||||
ownClientId={ownClient?.id ?? null}
|
||||
talkers={displayTalkers}
|
||||
onSelectChannel={handleSelectChannel}
|
||||
selected={selected}
|
||||
onSelectItem={handleSelectItem}
|
||||
onSwitchChannel={handleSwitchChannel}
|
||||
onOpenPrivateChat={handleOpenPrivateChat}
|
||||
onPokeClient={handlePokeClient}
|
||||
/>
|
||||
@@ -656,6 +765,18 @@ function App() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="ts-main-panel">
|
||||
{connected && (
|
||||
<InfoPanel
|
||||
selected={selected}
|
||||
host={host}
|
||||
serverName={serverName}
|
||||
serverMaxClients={serverMaxClients}
|
||||
totalClientCount={clients.length}
|
||||
channels={channels}
|
||||
clients={clients}
|
||||
/>
|
||||
)}
|
||||
<div className="ts-chat-panel">
|
||||
<div className="ts-chat-tabs">
|
||||
<button
|
||||
@@ -735,6 +856,7 @@ function App() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="ts-log">
|
||||
|
||||
Reference in new issue
Block a user