feat: complete M008 web ux and demo

This commit is contained in:
illusia committed 2026-09-01 17:54:51 +08:00
1 parent 277fa9d8fe
commit cab7707e51
7 files changed
+238 -19

No files matched your search

+5
View File
@@ -28,6 +28,7 @@ WebSpeak 是一个自托管的 TeamSpeak 浏览器客户端与访客接入网关
- 可清除全部 WebSpeak 本地数据;不保存服务器密码。
- TeamSpeak 密码使用安装级主密钥加密保存,不向管理 API 返回明文。
- 旧 `config.json` 一次性导入,导入后不再作为实时配置源。
- `/demo` 提供不连接真实 TeamSpeak 的交互式模拟页面,可用于产品预览和录屏。
### 环境要求
@@ -190,6 +191,9 @@ npm run dev
# 前端开发服务;/api 和 /ws 代理到 3040
npm run web:dev
# 浏览器打开演示页(不会连接真实 TeamSpeak)
# http://localhost:5173/demo
# 自动测试(覆盖 M000–M007 已实现的后端协议与安全边界)
npm test
@@ -245,6 +249,7 @@ WebSpeak is a self-hosted TeamSpeak web client and guest gateway. Every browser
- Clear all WebSpeak local data at any time; server passwords are never stored there.
- Encrypted TeamSpeak server password and one-time legacy config import.
- No ServerQuery, WebQuery, admin token, or maintenance bot.
- `/demo` is a clearly labeled interactive simulation and never opens a real TeamSpeak connection.
### Requirements and startup
+4
View File
@@ -41,6 +41,10 @@
<path v-else-if="name === 'bell'" d="M18 9a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9M10 21h4" />
<path v-else-if="name === 'clock'" d="M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm0-14v5l3 2" />
<path v-else-if="name === 'help'" d="M9.3 9a3 3 0 1 1 4.9 2.3c-1.3 1-2.2 1.5-2.2 3m0 3h.01M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Z" />
<template v-else-if="name === 'info'">
<circle cx="12" cy="12" r="9" />
<path d="M12 10v6m0-9h.01" />
</template>
<template v-else-if="name === 'plus'">
<path d="M12 5v14M5 12h14" />
</template>
+3
View File
@@ -4,10 +4,13 @@ import { createRouter, createWebHistory } from "vue-router";
import App from "./App.vue";
import WebClient from "./views/WebClient.vue";
import AdminView from "./views/AdminView.vue";
import DemoView from "./views/DemoView.vue";
import "./services/theme.js";
const routes = [
{ path: "/", name: "webclient", component: WebClient },
{ path: "/join", name: "join", component: WebClient },
{ path: "/demo", name: "demo", component: DemoView },
{ path: "/admin/:pathMatch(.*)*", name: "admin", component: AdminView },
];
+24
View File
@@ -0,0 +1,24 @@
export type ThemeMode = "system" | "light" | "dark";
const THEME_KEY = "webspeak:theme";
export function getStoredTheme(): ThemeMode {
const value = typeof localStorage === "undefined" ? "" : localStorage.getItem(THEME_KEY);
return value === "light" || value === "dark" || value === "system" ? value : "system";
}
export function applyTheme(theme: ThemeMode): void {
if (typeof document === "undefined") return;
document.documentElement.dataset.theme = theme;
}
export function saveTheme(theme: ThemeMode): void {
if (typeof localStorage !== "undefined") localStorage.setItem(THEME_KEY, theme);
applyTheme(theme);
}
export function nextTheme(theme: ThemeMode): ThemeMode {
return theme === "system" ? "light" : theme === "light" ? "dark" : "system";
}
applyTheme(getStoredTheme());
+20 -2
View File
@@ -28,7 +28,7 @@
</aside>
<main class="admin-main">
<header class="admin-topbar"><div><small>{{ tr('adminConsole') }}</small><h1>{{ currentPageTitle }}</h1></div><div><span class="running-dot"></span>{{ tr('gatewayRunning') }}<button type="button" @click="toggleLanguage">{{ tr('languageSwitch') }}</button></div></header>
<header class="admin-topbar"><div><small>{{ tr('adminConsole') }}</small><h1>{{ currentPageTitle }}</h1></div><div><span class="running-dot"></span>{{ tr('gatewayRunning') }}<button type="button" :title="themeLabel" @click="cycleTheme">{{ themeLabel }}</button><button type="button" @click="toggleLanguage">{{ tr('languageSwitch') }}</button></div></header>
<div v-if="errorMessage" class="alert error page-alert">{{ errorMessage }}</div>
<section v-if="route.path === '/admin/server'" class="page-content">
@@ -55,6 +55,7 @@
import { computed, onMounted, reactive, ref, watch } from "vue";
import { RouterLink, useRoute, useRouter } from "vue-router";
import Icon from "../components/Icon.vue";
import { applyTheme, getStoredTheme, nextTheme, saveTheme, type ThemeMode } from "../services/theme.js";
type Language = "zh" | "en";
type Screen = "login" | "change-password" | "admin";
@@ -64,6 +65,9 @@ interface ProbeState { ok: boolean; protocol?: string | null; latencyMs?: number
const route = useRoute();
const router = useRouter();
const language = ref<Language>((localStorage.getItem("webspeak:language") as Language) || "zh");
const themeMode = ref<ThemeMode>(getStoredTheme());
const themeLabel = computed(() => themeMode.value === "dark" ? tr("themeDark") : themeMode.value === "light" ? tr("themeLight") : tr("themeSystem"));
applyTheme(themeMode.value);
const loading = ref(true);
const screen = ref<Screen>("login");
const csrfToken = ref("");
@@ -93,6 +97,9 @@ const copy = {
passwordHint: "建议使用长且唯一的密码。",
confirmPassword: "确认管理员密码",
languageSwitch: "English",
themeSystem: "跟随系统",
themeLight: "浅色主题",
themeDark: "深色主题",
welcomeAdmin: "欢迎回来",
loginLead: "输入管理员账号和密码以管理此 WebSpeak 实例。",
adminPassword: "管理员密码",
@@ -178,6 +185,9 @@ const copy = {
passwordHint: "Use a long, unique password.",
confirmPassword: "Confirm admin password",
languageSwitch: "中文",
themeSystem: "System theme",
themeLight: "Light theme",
themeDark: "Dark theme",
welcomeAdmin: "Welcome back",
loginLead: "Enter the admin account and password to manage this WebSpeak instance.",
adminPassword: "Admin password",
@@ -273,6 +283,7 @@ function serverPayload() { return { target: serverForm.target, serverPassword: s
async function runTest(url: string, body: Record<string, unknown>) { testing.value = true; errorMessage.value = ""; testResult.value = null; try { testResult.value = await sendJson(url, "POST", body, url.includes("/server/test")); } catch (error) { testResult.value = { ok: false, code: (error as ApiError).code }; } finally { testing.value = false; } }
async function dismissLegacyNotice() { await sendJson("/api/admin/legacy-import/dismiss", "POST", {}); overview.legacyConfigImported = false; }
function toggleLanguage() { language.value = language.value === "zh" ? "en" : "zh"; localStorage.setItem("webspeak:language", language.value); }
function cycleTheme() { themeMode.value = nextTheme(themeMode.value); saveTheme(themeMode.value); }
function formatDate(value: string | null) { return value ? new Intl.DateTimeFormat(language.value === "zh" ? "zh-CN" : "en-US", { dateStyle: "medium", timeStyle: "short" }).format(new Date(value)) : "—"; }
function formatUptime(seconds: number) { const hours = Math.floor(seconds / 3600); const minutes = Math.floor((seconds % 3600) / 60); return language.value === "zh" ? `已运行 ${hours} 小时 ${minutes} 分钟` : `Up ${hours}h ${minutes}m`; }
function eventName(event: string) { if (event === "ADMIN_LOGIN_FAILED") return language.value === "zh" ? "管理员登录失败" : "Administrator login failed"; if (event === "CONNECTION_TEST_SUCCEEDED") return language.value === "zh" ? "连接测试成功" : "Connection test succeeded"; if (event === "CONNECTION_TEST_FAILED") return language.value === "zh" ? "连接测试失败" : "Connection test failed"; const names: Record<string, keyof typeof copy.zh> = { ADMIN_LOGIN_SUCCEEDED: "loginEvent", ADMIN_LOGOUT: "logoutEvent", SETTINGS_CHANGED: "settingsEvent", ADMIN_INITIALIZED: "initializedEvent", LEGACY_CONFIG_IMPORTED: "importedEvent", CONNECTION_TEST: "testEvent" }; return names[event] ? tr(names[event]) : language.value === "zh" ? "系统事件" : event.replaceAll("_", " "); }
@@ -289,5 +300,12 @@ async function parseResponse(response: Response) { const value = await response.
:global(*){box-sizing:border-box}:global(body){margin:0;font-family:Inter,"Segoe UI","PingFang SC",sans-serif;color:#20302c;background:#f4f8f6}.admin-root{min-height:100dvh}.auth-layout{display:grid;min-height:100dvh;grid-template-columns:minmax(360px,.82fr) minmax(520px,1.18fr)}.auth-intro{display:flex;flex-direction:column;padding:48px clamp(38px,6vw,92px);color:#e8fffa;background:radial-gradient(circle at 20% 0,rgba(90,211,191,.28),transparent 32rem),#063f3b}.admin-brand{display:flex;align-items:center;gap:12px}.admin-brand>span{display:grid;place-items:center;width:42px;height:42px;color:#fff;background:#07877d;border-radius:12px;box-shadow:0 8px 22px rgba(0,0,0,.15)}.admin-brand strong,.admin-brand small{display:block}.admin-brand strong{font-size:20px;letter-spacing:-.04em}.admin-brand small{margin-top:3px;color:#9bc9c2;font-size:11px}.intro-copy{margin:auto 0 48px}.intro-copy i{color:#75e3d2;font-size:12px;font-style:normal;font-weight:800;letter-spacing:.12em}.intro-copy h1{max-width:540px;margin:16px 0;font-size:clamp(40px,5vw,66px);line-height:1.03;letter-spacing:-.065em}.intro-copy p{max-width:530px;color:#a9d0ca;font-size:16px;line-height:1.75}.step-list{display:grid;gap:10px}.step-list button{display:flex;align-items:center;gap:13px;width:100%;padding:13px;color:#89bbb4;text-align:left;background:transparent;border:1px solid transparent;border-radius:12px}.step-list button.active{color:#fff;background:rgba(255,255,255,.08);border-color:rgba(255,255,255,.1)}.step-list button.done{color:#8ee4d7}.step-list button>span{display:grid;place-items:center;width:28px;height:28px;flex:none;border:1px solid currentColor;border-radius:50%;font-size:12px;font-weight:800}.step-list strong,.step-list small{display:block}.step-list strong{font-size:13px}.step-list small{margin-top:3px;font-size:10px;opacity:.75}.auth-panel{position:relative;display:grid;place-items:center;padding:80px 40px;background:radial-gradient(circle at 80% 10%,rgba(99,205,188,.15),transparent 25rem),#f5f9f7}.panel-tools{position:absolute;top:28px;right:34px}.panel-tools button,.language-link,.admin-topbar button{color:#08766e;background:#e4f3ef;border:1px solid #cae7e0;border-radius:8px;padding:8px 12px;font-size:11px;font-weight:700;cursor:pointer}.setup-card,.login-card{width:min(560px,100%);padding:36px;background:#fff;border:1px solid #dfeae6;border-radius:20px;box-shadow:0 20px 55px rgba(27,69,61,.09)}.setup-card header small{color:#07877d;font-size:11px;font-weight:800;letter-spacing:.08em}.setup-card header h2,.login-card h1{margin:10px 0 7px;font-size:29px;letter-spacing:-.045em}.setup-card header p,.login-card header p{margin:0;color:#71817c;font-size:13px;line-height:1.6}.form-stack,.login-card form{display:grid;gap:17px;margin-top:27px}label>span,fieldset legend{display:block;margin-bottom:7px;color:#40514c;font-size:12px;font-weight:700}label em{color:#91a09c;font-size:10px;font-style:normal;font-weight:500}label small{display:block;margin-top:6px;color:#899792;font-size:10px;line-height:1.5}input,textarea{width:100%;padding:11px 12px;color:#22332f;background:#fbfdfc;border:1px solid #dbe7e3;border-radius:9px;font:inherit;font-size:13px;outline:none}input{height:43px}input:focus,textarea:focus{border-color:#54bdb2;box-shadow:0 0 0 3px rgba(84,189,178,.13)}textarea{resize:vertical}.strength{height:4px;overflow:hidden;background:#e7eeeb;border-radius:4px}.strength i{display:block;height:100%;background:linear-gradient(90deg,#e7a452,#50c5a2);transition:.2s}fieldset{display:grid;gap:9px;margin:0;padding:0;border:0}.choice{display:flex;align-items:flex-start;gap:10px;padding:13px;border:1px solid #dfe9e6;border-radius:10px;cursor:pointer}.choice:has(input:checked){border-color:#62bfb5;background:#eff8f6}.choice input{width:16px;height:16px;flex:none;margin:2px 0}.choice strong,.choice small{display:block}.choice strong{font-size:12px}.choice small{margin-top:4px;color:#7b8985;font-size:10px;line-height:1.45}.setup-card footer{display:flex;align-items:center;justify-content:space-between;margin-top:28px;padding-top:20px;border-top:1px solid #edf1ef}.primary-button,.secondary-button,.text-button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:42px;padding:0 18px;border:0;border-radius:9px;font-size:12px;font-weight:800;cursor:pointer}.primary-button{color:#fff;background:#087d74}.primary-button:hover{background:#056b63}.primary-button:disabled,.secondary-button:disabled{opacity:.55;cursor:not-allowed}.secondary-button{color:#08776e;background:#eaf6f3;border:1px solid #cfe9e3}.text-button{color:#687a74;background:transparent}.wide{width:100%}.spinner{display:inline-block;width:22px;height:22px;border:2px solid #cde6df;border-top-color:#087d74;border-radius:50%;animation:spin .7s linear infinite}.spinner.small{width:15px;height:15px;border-color:rgba(255,255,255,.35);border-top-color:currentColor}@keyframes spin{to{transform:rotate(360deg)}}.alert{padding:12px 14px;border-radius:9px;font-size:12px;linLine truncated
@media(max-width:850px){.auth-layout{display:block}.auth-intro{min-height:auto;padding:28px 24px}.intro-copy{margin:55px 0 35px}.step-list{display:none}.auth-panel{padding:35px 18px 60px}.panel-tools{top:18px;right:18px}.admin-shell{display:block}.admin-sidebar{position:static;width:100%;height:auto;flex-direction:row;align-items:center;padding:12px 16px}.admin-sidebar .admin-brand{padding:0}.admin-sidebar .admin-brand small{display:none}.admin-sidebar nav{display:flex;margin-left:auto}.admin-sidebar nav a{font-size:0}.admin-sidebar nav a .ui-icon{width:20px;height:20px}.sidebar-bottom{display:flex;margin:0 0 0 8px;padding:0;border:0}.sidebar-bottom a{display:none}.sidebar-bottom button{font-size:0}.settings-grid,.overview-columns{grid-template-columns:1fr}.readonly-card dl{grid-template-columns:1fr 1fr}.admin-topbar{padding:0 18px}.page-content{width:min(100% - 28px,700px);padding-top:24px}.metric-grid{grid-template-columns:1fr}.hero-status{align-items:flex-start;gap:20px}.hero-status p{max-width:75%}}
@media(max-width:520px){.setup-card,.login-card{padding:25px 20px;border-radius:15px}.setup-card header h2{font-size:24px}.admin-topbar>div:last-child{font-size:0}.page-heading{gap:15px}.page-heading .primary-button{padding-inline:12px}.settings-card,.readonly-card,.overview-card{padding:18px}.readonly-card dl,.overview-card dl{grid-template-columns:1fr}.password-row{grid-template-columns:1fr}.password-actions{padding:0}.hero-status{padding:23px}.status-badge{display:none}}
.security-note{margin:18px 0 0;color:#879590;font-size:11px;line-height:1.5}
.security-note{margin:18px 0 0;color:#879590;font-size:11px;line-height:1.5}
:global(:root[data-theme="dark"]) .admin-root, :global(:root[data-theme="dark"]) .login-page, :global(:root[data-theme="dark"]) .auth-panel { color: #e8f3f0; background: #101918; }
:global(:root[data-theme="dark"]) .admin-topbar, :global(:root[data-theme="dark"]) .setup-card, :global(:root[data-theme="dark"]) .login-card, :global(:root[data-theme="dark"]) .settings-card, :global(:root[data-theme="dark"]) .readonly-card, :global(:root[data-theme="dark"]) .overview-card, :global(:root[data-theme="dark"]) input, :global(:root[data-theme="dark"]) textarea { color: #e8f3f0; background: #172321; border-color: #30413d; }
:global(:root[data-theme="dark"]) .admin-topbar, :global(:root[data-theme="dark"]) .settings-card, :global(:root[data-theme="dark"]) .readonly-card, :global(:root[data-theme="dark"]) .overview-card { border-color: #30413d; }
:global(:root[data-theme="dark"]) .admin-topbar h1, :global(:root[data-theme="dark"]) .page-heading h2, :global(:root[data-theme="dark"]) .settings-card h3, :global(:root[data-theme="dark"]) .readonly-card h3, :global(:root[data-theme="dark"]) .overview-card h3, :global(:root[data-theme="dark"]) .login-card h1 { color: #e8f3f0; }
:global(:root[data-theme="dark"]) .page-heading p, :global(:root[data-theme="dark"]) .admin-topbar small, :global(:root[data-theme="dark"]) label > span, :global(:root[data-theme="dark"]) .page-heading p { color: #9bb0aa; }
:global(:root[data-theme="dark"]) .metric-grid article, :global(:root[data-theme="dark"]) .readonly-card dl div, :global(:root[data-theme="dark"]) .overview-card dl div, :global(:root[data-theme="dark"]) .event-list li { background: #202f2c; border-color: #30413d; }
@media (prefers-color-scheme: dark) { :global(:root[data-theme="system"]) .admin-root, :global(:root[data-theme="system"]) .login-page, :global(:root[data-theme="system"]) .auth-panel { color: #e8f3f0; background: #101918; } :global(:root[data-theme="system"]) .admin-topbar, :global(:root[data-theme="system"]) .setup-card, :global(:root[data-theme="system"]) .login-card, :global(:root[data-theme="system"]) .settings-card, :global(:root[data-theme="system"]) .readonly-card, :global(:root[data-theme="system"]) .overview-card { background: #172321; border-color: #30413d; } }
</style>
+94
View File
@@ -0,0 +1,94 @@
<template>
<div class="demo-page">
<header class="demo-header">
<div class="demo-brand"><span><Icon name="waveform" :size="21" /></span><div><strong>WebSpeak</strong><small>{{ copy.browserClient }}</small></div></div>
<div class="demo-tools"><span class="demo-badge">{{ copy.demoBadge }}</span><button type="button" @click="toggleLanguage">{{ copy.languageSwitch }}</button><a href="/">{{ copy.back }}</a></div>
</header>
<div v-if="reconnecting" class="demo-reconnect" role="status"><Icon name="refresh" :size="17" /><span>{{ copy.reconnecting }}</span><button type="button" @click="reconnecting = false">{{ copy.restore }}</button></div>
<main class="demo-shell">
<aside class="demo-channel-panel">
<div class="demo-panel-title"><span>{{ copy.channels }}</span><strong>{{ selectedChannel.name }}</strong></div>
<div v-for="channel in channels" :key="channel.id" :class="['demo-channel', { active: selectedChannelId === channel.id }]">
<button type="button" @click="selectChannel(channel.id)"><Icon name="volume" :size="16" /><span>{{ channel.name }}</span><small>{{ channel.members.length }}</small></button>
<div class="demo-channel-members"><span v-for="member in channel.members" :key="member.id" :class="{ speaking: speakingId === member.id }"><i :style="avatarStyle(member.name)">{{ member.name[0] }}</i>{{ member.name }}</span></div>
</div>
</aside>
<section class="demo-main">
<div class="demo-hero"><div><span class="demo-live"><i></i>{{ copy.simulated }}</span><h1><Icon name="volume" :size="24" /> {{ selectedChannel.name }}</h1><p>{{ copy.heroLead }}</p><small><Icon name="users" :size="14" /> {{ selectedChannel.members.length }} {{ copy.online }}</small></div><div class="demo-wave" aria-hidden="true"><i v-for="bar in bars" :key="bar" :style="{ height: `${bar}px` }"></i></div></div>
<div class="demo-section-heading"><span>{{ copy.voiceActivity }}</span><strong>{{ copy.speakingNow }}</strong></div>
<div class="demo-voice-grid"><article v-for="member in selectedChannel.members" :key="member.id" :class="['demo-voice-card', { speaking: speakingId === member.id }]" @click="speakingId = member.id"><i :style="avatarStyle(member.name)">{{ member.name[0] }}</i><strong>{{ member.name }}</strong><span>{{ speakingId === member.id ? copy.speaking : copy.connected }}</span></article></div>
<div class="demo-chat-head"><div><span>{{ copy.textChannel }}</span><strong># {{ selectedChannel.name }} {{ copy.chat }}</strong></div><div class="demo-tabs"><button v-for="tab in tabs" :key="tab.id" type="button" :class="{ active: activeTab === tab.id }" @click="activeTab = tab.id">{{ tab.label }}</button></div></div>
<div class="demo-messages"><div v-for="message in visibleMessages" :key="message.id" :class="['demo-message', { mine: message.mine }]" @dblclick="message.mine = !message.mine"><i :style="avatarStyle(message.author)">{{ message.author[0] }}</i><div><small>{{ message.author }} · {{ message.time }}</small><p>{{ messageText(message) }}</p></div></div><div v-if="!visibleMessages.length" class="demo-empty"><Icon name="message" :size="22" /><strong>{{ copy.emptyChat }}</strong></div></div>
<form class="demo-composer" @submit.prevent="sendMessage"><input v-model="draft" :placeholder="copy.placeholder" :aria-label="copy.placeholder" /><button type="submit" :disabled="!draft.trim()"><Icon name="send" :size="17" /></button></form>
</section>
<aside class="demo-actions-panel"><div class="demo-panel-title"><span>{{ copy.voice }}</span><strong>{{ copy.simulationControls }}</strong></div><button type="button" @click="toggleSpeaking"><Icon name="mic" :size="17" /> {{ speakingId ? copy.stopSpeaking : copy.simulateSpeaking }}</button><button type="button" @click="poke = !poke"><Icon name="bell" :size="17" /> {{ copy.poke }}</button><button type="button" @click="reconnecting = true"><Icon name="refresh" :size="17" /> {{ copy.simulateReconnect }}</button><div class="demo-note"><Icon name="shield" :size="16" /><span>{{ copy.demoNote }}</span></div><div class="demo-user"><i :style="avatarStyle('illusia')">I</i><div><strong>illusia</strong><small>{{ copy.you }} · {{ copy.ready }}</small></div><span class="demo-green-dot"></span></div></aside>
</main>
<div v-if="poke" class="demo-poke" role="status"><Icon name="bell" :size="17" /><span><strong>msicbot</strong> {{ copy.pokedYou }}</span><button type="button" @click="poke = false"><Icon name="close" :size="14" /></button></div>
</div>
</template>
<script setup lang="ts">
import { computed, ref } from "vue";
import Icon from "../components/Icon.vue";
type Language = "zh" | "en";
interface DemoMessage { id: number; author: string; time: string; text: string; zhText?: string; enText?: string; mine: boolean }
type Tab = "channel" | "server";
const language = ref<Language>(localStorage.getItem("webspeak:language") === "en" ? "en" : "zh");
const copy = computed(() => language.value === "zh" ? zh : en);
const selectedChannelId = ref("quiet");
const activeTab = ref<Tab>("channel");
const speakingId = ref("illusia");
const reconnecting = ref(false);
const poke = ref(false);
const draft = ref("");
const bars = [15, 31, 21, 42, 25, 50, 32, 21, 38, 27, 45, 18, 33];
const channels = [
{ id: "quiet", name: "Quiet Zone", members: [{ id: "illusia", name: "illusia" }, { id: "msicbot", name: "msicbot" }] },
{ id: "lounge", name: "Lounge", members: [{ id: "alice", name: "Alice" }] },
{ id: "music", name: "Music room", members: [] },
];
const messages = ref<DemoMessage[]>([
{ id: 1, author: "illusia", time: "10:24", text: "", zhText: "大家好,欢迎来到 WebSpeak。", enText: "Hello everyone, welcome to WebSpeak.", mine: true },
{ id: 2, author: "msicbot", time: "10:25", text: "", zhText: "语音和文字频道都已同步。", enText: "Voice and text channels are in sync.", mine: false },
]);
const zh = { browserClient: "浏览器语音工作台", demoBadge: "演示 — 模拟数据", languageSwitch: "English", back: "返回主页", reconnecting: "连接中断,正在恢复…", restore: "恢复连接", channels: "频道", channel: "频道", simulated: "演示状态", heroLead: "这里展示 WebSpeak 的频道、语音和聊天交互。", online: "人在线", voiceActivity: "语音活动", speakingNow: "正在语音中", speaking: "正在说话…", connected: "已连接", textChannel: "文字频道", chat: "聊天", server: "服务器", emptyChat: "暂无消息", placeholder: "发送一条消息…", voice: "语音", simulationControls: "模拟控制", stopSpeaking: "停止说话", simulateSpeaking: "模拟发言", poke: "戳一戳", simulateReconnect: "模拟重连", demoNote: "此页面不会连接真实 TeamSpeak 服务器。", you: "你", ready: "已就绪", pokedYou: "戳了你一下" };
const en = { browserClient: "Browser voice workspace", demoBadge: "Demo — simulated data", languageSwitch: "中文", back: "Back home", reconnecting: "Connection interrupted, recovering…", restore: "Restore", channels: "Channels", channel: "Channel", simulated: "Simulation", heroLead: "A preview of WebSpeak channels, voice, and chat interactions.", online: "online", voiceActivity: "VOICE ACTIVITY", speakingNow: "Speaking now", speaking: "Speaking…", connected: "Connected", textChannel: "TEXT CHANNEL", chat: "chat", server: "Server", emptyChat: "No messages yet", placeholder: "Send a message…", voice: "Voice", simulationControls: "Simulation controls", stopSpeaking: "Stop speaking", simulateSpeaking: "Simulate speaking", poke: "Poke", simulateReconnect: "Simulate reconnect", demoNote: "This page never connects to a real TeamSpeak server.", you: "You", ready: "Ready", pokedYou: "poked you" };
const tabs = computed(() => [{ id: "channel" as const, label: copy.value.channel }, { id: "server" as const, label: copy.value.server }]);
const selectedChannel = computed(() => channels.find((channel) => channel.id === selectedChannelId.value) ?? channels[0]);
const visibleMessages = computed(() => activeTab.value === "channel" ? messages.value : []);
function toggleLanguage() { language.value = language.value === "zh" ? "en" : "zh"; localStorage.setItem("webspeak:language", language.value); }
function selectChannel(id: string) { selectedChannelId.value = id; activeTab.value = "channel"; }
function toggleSpeaking() { speakingId.value = speakingId.value ? "" : selectedChannel.value.members[0]?.id ?? ""; }
function messageText(message: DemoMessage): string { return language.value === "zh" ? message.zhText ?? message.text : message.enText ?? message.text; }
function sendMessage() { const text = draft.value.trim(); if (!text) return; messages.value.push({ id: Date.now(), author: "illusia", time: "now", text, mine: true }); draft.value = ""; }
function avatarStyle(name: string) { let hash = 0; for (const char of name) hash = char.charCodeAt(0) + ((hash << 5) - hash); const colors = ["#168f83", "#7b9ed0", "#b99070", "#8b78b9"]; return { background: colors[Math.abs(hash) % colors.length] }; }
</script>
<style scoped>
:global(*) { box-sizing: border-box; }
:global(body) { margin: 0; font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f7f9f8; color: #1c2b28; }
.demo-page { min-height: 100dvh; padding: 0 28px 38px; background: radial-gradient(circle at 72% 12%, rgba(126, 213, 205, .18), transparent 26rem), #f7f9f8; }
.demo-header { display: flex; align-items: center; justify-content: space-between; width: min(1380px, 100%); min-height: 82px; margin: 0 auto; }
.demo-brand, .demo-tools, .demo-brand > div, .demo-tools { display: flex; align-items: center; }.demo-brand { gap: 10px; }.demo-brand > span { display: grid; place-items: center; width: 39px; height: 39px; color: #fff; background: #006a64; border-radius: 12px; }.demo-brand strong, .demo-brand small { display: block; }.demo-brand strong { color: #006a64; font-size: 18px; }.demo-brand small { margin-top: 2px; color: #84938e; font-size: 10px; }.demo-tools { gap: 15px; color: #68807a; font-size: 12px; }.demo-tools button, .demo-tools a { padding: 7px 10px; color: #006a64; background: #e1f2ee; border: 1px solid #cbe6e0; border-radius: 7px; font-size: 11px; font-weight: 700; text-decoration: none; cursor: pointer; }.demo-badge { color: #2d7d50; font-weight: 700; }
.demo-reconnect { display: flex; align-items: center; gap: 9px; width: min(1380px, 100%); margin: 0 auto 14px; padding: 11px 14px; color: #8b6537; background: #fff8e9; border: 1px solid #efd9aa; border-radius: 10px; }.demo-reconnect span { flex: 1; }.demo-reconnect button { padding: 6px 10px; color: #7d5d35; background: #fff; border: 1px solid #ead0a0; border-radius: 6px; cursor: pointer; }
.demo-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr) 235px; gap: 18px; width: min(1380px, 100%); min-height: 720px; margin: 0 auto; }.demo-channel-panel, .demo-actions-panel, .demo-main { min-width: 0; padding: 20px; border: 1px solid #e0ebe7; border-radius: 16px; background: rgba(255,255,255,.9); box-shadow: 0 12px 30px rgba(26,66,59,.05); }.demo-panel-title { display: grid; gap: 5px; margin-bottom: 20px; }.demo-panel-title span, .demo-section-heading span, .demo-chat-head span { color: #79918c; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }.demo-panel-title strong { color: #263a35; font-size: 18px; }.demo-channel { margin: 4px -8px 12px; padding: 3px 8px 9px; border-radius: 10px; }.demo-channel.active { background: #e2f3ef; }.demo-channel > button { display: flex; align-items: center; gap: 7px; width: 100%; padding: 8px 0; color: #45635b; background: transparent; border: 0; text-align: left; cursor: pointer; }.demo-channel.active > button { color: #006a64; font-weight: 800; }.demo-channel button span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.demo-channel button small { color: #84a19a; }.demo-channel-members { display: grid; gap: 7px; padding-left: 22px; color: #7b8e88; font-size: 11px; }.demo-channel-members span { display: flex; align-items: center; gap: 7px; }.demo-channel-members i, .demo-user > i, .demo-voice-card > i, .demo-message > i { display: grid; place-items: center; flex: 0 0 auto; color: #fff; border-radius: 50%; font-style: normal; font-weight: 800; }.demo-channel-members i { width: 20px; height: 20px; font-size: 9px; }.demo-channel-members span.speaking i { box-shadow: 0 0 0 2px #83e88d, 0 0 10px rgba(83,214,105,.45); }
.demo-main { padding: 27px 32px; }.demo-hero { display: flex; align-items: center; justify-content: space-between; min-height: 190px; padding: 26px 29px; overflow: hidden; border-radius: 14px; background: linear-gradient(112deg, #dff3ef, #f6fbfa); }.demo-live { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; color: #2d7e48; background: #d4f3d9; border-radius: 999px; font-size: 10px; font-weight: 700; }.demo-live i, .demo-green-dot { width: 7px; height: 7px; background: #58d476; border-radius: 50%; }.demo-hero h1 { display: flex; align-items: center; gap: 8px; margin: 17px 0 7px; color: #18302c; font-size: 28px; letter-spacing: -.05em; }.demo-hero p { margin: 0 0 15px; color: #64817a; font-size: 12px; }.demo-hero small { display: flex; align-items: center; gap: 6px; color: #52716b; font-size: 11px; }.demo-wave { display: flex; align-items: center; gap: 5px; height: 60px; padding-right: 22px; }.demo-wave i { width: 4px; border-radius: 4px; background: #65cabe; }.demo-wave i:nth-child(3n) { background: #8fe990; }.demo-section-heading { display: grid; gap: 5px; margin: 31px 0 15px; }.demo-section-heading strong { color: #1d2c28; font-size: 21px; }.demo-voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 11px; }.demo-voice-card { display: grid; justify-items: center; gap: 7px; padding: 15px 8px; border: 1px solid #edf1ef; border-radius: 12px; background: #fff; cursor: pointer; }.demo-voice-card > i { width: 56px; height: 56px; font-size: 18px; }.demo-voice-card strong { color: #2c3935; font-size: 12px; }.demo-voice-card span { color: #91a09a; font-size: 10px; }.demo-voice-card.speaking { border-color: #83e88d; box-shadow: 0 0 0 2px rgba(131,232,141,.18), 0 8px 20px rgba(68,173,79,.12); }.demo-voice-card.speaking span { color: #2e8b45; }.demo-chat-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 33px; padding-top: 23px; border-top: 1px solid #edf2f0; }.demo-chat-head strong { display: block; margin-top: 6px; color: #1d2c28; font-size: 20px; }.demo-tabs { display: flex; gap: 5px; }.demo-tabs button { padding: 7px 9px; color: #78908a; background: #f0f6f3; border: 0; border-radius: 7px; cursor: pointer; }.demo-tabs button.active { color: #006a64; background: #dff1ed; font-weight: 700; }.demo-messages { display: grid; align-content: start; gap: 13px; min-height: 215px; max-height: 270px; margin-top: 17px; overflow-y: auto; padding: 7px 3px; }.demo-message { display: flex; align-items: flex-start; gap: 9px; max-width: 76%; }.demo-message.mine { justify-self: end; flex-direction: row-reverse; text-align: right; }.demo-message > i { width: 29px; height: 29px; font-size: 10px; }.demo-message small { color: #9ca9a4; font-size: 9px; }.demo-message p { margin: 4px 0 0; padding: 8px 11px; color: #43534e; background: #f1f5f3; border-radius: 4px 11px 11px 11px; font-size: 12px; }.demo-message.mine p { color: #fff; background: #006a64; border-radius: 11px 4px 11px 11px; }.demo-empty { display: grid; place-content: center; justify-items: center; gap: 8px; min-height: 170px; color: #91a29b; }.demo-empty strong { font-size: 12px; }.demo-composer { display: flex; gap: 8px; padding: 7px 8px 7px 12px; background: #f1f6f4; border-radius: 10px; }.demo-composer input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 12px; }.demo-composer button { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: #006a64; border: 0; border-radius: 8px; cursor: pointer; }.demo-composer button:disabled { opacity: .35; cursor: not-allowed; }
.demo-actions-panel { display: flex; flex-direction: column; gap: 9px; }.demo-actions-panel > button { display: flex; align-items: center; gap: 8px; padding: 10px; color: #4d6a62; background: #f0f6f3; border: 1px solid #e1ece8; border-radius: 8px; text-align: left; cursor: pointer; }.demo-actions-panel > button:hover { color: #006a64; border-color: #b9ddd6; }.demo-note { display: flex; gap: 8px; margin-top: 10px; padding: 11px; color: #68837b; background: #eef8f4; border-radius: 9px; font-size: 10px; line-height: 1.5; }.demo-user { display: flex; align-items: center; gap: 9px; margin-top: auto; padding-top: 15px; border-top: 1px solid #e9efed; }.demo-user > i { width: 35px; height: 35px; font-size: 12px; }.demo-user div { min-width: 0; flex: 1; }.demo-user strong, .demo-user small { display: block; }.demo-user strong { color: #34423d; font-size: 12px; }.demo-user small { margin-top: 4px; color: #8a9a94; font-size: 10px; }.demo-poke { position: fixed; z-index: 10; top: 82px; right: 25px; display: flex; align-items: center; gap: 9px; max-width: min(380px, calc(100% - 32px)); padding: 11px 12px; color: #52645c; background: #fffdf6; border: 1px solid #f0dfbd; border-radius: 9px; box-shadow: 0 8px 22px rgba(88,65,28,.12); font-size: 12px; }.demo-poke span { flex: 1; }.demo-poke strong { color: #8f6532; }.demo-poke button { display: grid; place-items: center; padding: 3px; color: #9b8a6e; background: transparent; border: 0; cursor: pointer; }
@media (max-width: 1080px) { .demo-shell { grid-template-columns: 210px minmax(0, 1fr); }.demo-actions-panel { grid-column: 1 / -1; min-height: 160px; }.demo-actions-panel .demo-panel-title { margin-bottom: 3px; }.demo-actions-panel > button { display: inline-flex; width: fit-content; }.demo-note { margin-top: 4px; }.demo-user { margin-top: 0; } }
@media (max-width: 720px) { .demo-page { padding: 0 14px 24px; }.demo-header { min-height: 68px; }.demo-tools { gap: 6px; font-size: 10px; }.demo-badge { display: none; }.demo-shell { display: block; min-height: 0; }.demo-channel-panel { margin-bottom: 12px; }.demo-channel-panel .demo-channel:not(.active) { display: none; }.demo-actions-panel { margin-top: 12px; }.demo-main { padding: 17px 14px; }.demo-hero { min-height: 170px; padding: 20px; }.demo-wave { padding-right: 0; transform: scale(.75); transform-origin: right center; }.demo-chat-head { display: grid; align-items: start; }.demo-tabs { overflow-x: auto; }.demo-message { max-width: 94%; } }
@media (max-width: 360px) { .demo-tools a { display: none; }.demo-hero h1 { font-size: 23px; }.demo-hero p { font-size: 11px; }.demo-voice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
:global(:root[data-theme="dark"]) .demo-page { color: #e8f3f0; background: #101918; }
:global(:root[data-theme="dark"]) .demo-channel-panel, :global(:root[data-theme="dark"]) .demo-actions-panel, :global(:root[data-theme="dark"]) .demo-main, :global(:root[data-theme="dark"]) .demo-voice-card { background: #172321; border-color: #30413d; }
:global(:root[data-theme="dark"]) .demo-panel-title strong, :global(:root[data-theme="dark"]) .demo-hero h1, :global(:root[data-theme="dark"]) .demo-section-heading strong, :global(:root[data-theme="dark"]) .demo-chat-head strong, :global(:root[data-theme="dark"]) .demo-voice-card strong, :global(:root[data-theme="dark"]) .demo-user strong { color: #e8f3f0; }
:global(:root[data-theme="dark"]) .demo-hero { background: linear-gradient(112deg, #173e3a, #172321); }
:global(:root[data-theme="dark"]) .demo-message p, :global(:root[data-theme="dark"]) .demo-composer, :global(:root[data-theme="dark"]) .demo-actions-panel > button { background: #202f2c; color: #d7e7e3; }
:global(:root[data-theme="dark"]) .demo-chat-head, :global(:root[data-theme="dark"]) .demo-user { border-color: #30413d; }
@media (prefers-color-scheme: dark) { :global(:root[data-theme="system"]) .demo-channel-panel, :global(:root[data-theme="system"]) .demo-actions-panel, :global(:root[data-theme="system"]) .demo-main, :global(:root[data-theme="system"]) .demo-voice-card { background: #172321; border-color: #30413d; } }
:global(button:focus-visible), :global(a:focus-visible), :global(input:focus-visible) { outline: 3px solid #69d2c7; outline-offset: 2px; }
</style>
+88 -17
View File
@@ -10,7 +10,7 @@
<small>{{ t('browserWorkspace') }}</small>
</div>
</div>
<div class="header-tools"><div class="header-note"><span class="tiny-dot"></span> {{ t('secureGateway') }}</div><a class="guide-button" href="/admin"><Icon name="settings" :size="15" /> {{ t('adminConsole') }}</a><button class="language-switch" :aria-label="t('langSwitch')" @click="toggleLanguage">{{ t('langSwitch') }}</button></div>
<div class="header-tools"><div class="header-note"><span class="tiny-dot"></span> {{ t('secureGateway') }}</div><a class="guide-button" href="/admin"><Icon name="settings" :size="15" /> {{ t('adminConsole') }}</a><button type="button" class="header-action theme-toggle" :title="themeLabel" :aria-label="themeLabel" @click="cycleTheme"><Icon name="monitor" :size="17" /></button><button class="language-switch" :aria-label="t('langSwitch')" @click="toggleLanguage">{{ t('langSwitch') }}</button></div>
</header>
<main class="join-content">
@@ -64,18 +64,14 @@
<input id="channel" v-model="channel" :placeholder="t('emptyDefault')" @keyup.enter="doConnect" />
</div>
<label class="remember-identity"><input v-model="rememberIdentity" type="checkbox" /><span><strong>{{ t('rememberIdentity') }}</strong><small>{{ t('rememberIdentityHint') }}</small></span></label>
<div class="identity-tools">
<button type="button" class="identity-tool-button" @click="identityFileInput?.click()">{{ t('identityImport') }}</button>
<button v-if="identityMaterial" type="button" class="identity-tool-button" @click="exportIdentity">{{ t('identityExport') }}</button>
<input ref="identityFileInput" class="visually-hidden" type="file" accept=".json,.txt,application/json,text/plain" @change="importIdentity" />
</div>
<details class="identity-options"><summary>{{ t('identityOptions') }}</summary><label class="remember-identity"><input v-model="rememberIdentity" type="checkbox" /><span><strong>{{ t('rememberIdentity') }}</strong><small>{{ t('rememberIdentityHint') }}</small></span></label><div class="identity-tools"><button type="button" class="identity-tool-button" @click="identityFileInput?.click()">{{ t('identityImport') }}</button><button v-if="identityMaterial" type="button" class="identity-tool-button" @click="exportIdentity">{{ t('identityExport') }}</button><input ref="identityFileInput" class="visually-hidden" type="file" accept=".json,.txt,application/json,text/plain" @change="importIdentity" /></div></details>
<button class="primary-button connect-button" :disabled="!canJoin || serverConfigLoading || voiceState.connecting" type="submit">
<span v-if="voiceState.connecting" class="button-spinner"></span>
<span>{{ voiceState.connecting ? t('connecting') : t('enterVoice') }}</span>
<Icon v-if="!voiceState.connecting" name="chevron-right" :size="17" />
</button>
<button v-if="voiceState.connecting" type="button" class="cancel-connect-button" @click="doDisconnect">{{ t('cancel') }}</button>
</form>
<div class="join-meta"><Icon name="lock" :size="14" /> {{ t('connectionAuthorized') }}</div>
</div>
@@ -99,7 +95,8 @@
</select>
</label>
<button class="header-action" :title="t('copyInvite')" @click="doShare"><Icon name="share" :size="18" /></button>
<button class="header-action" :title="t('audioSettings')" @click="settingsOpen = true"><Icon name="settings" :size="18" /></button>
<button class="header-action" :title="t('audioSettings')" :aria-label="t('audioSettings')" @click="settingsOpen = true"><Icon name="settings" :size="18" /></button>
<button type="button" class="header-action theme-toggle" :title="themeLabel" :aria-label="themeLabel" @click="cycleTheme"><Icon name="monitor" :size="17" /></button>
<button class="language-switch workspace-language" :aria-label="t('langSwitch')" @click="toggleLanguage">{{ t('langSwitch') }}</button>
<button class="disconnect-button" @click="doDisconnect"><Icon name="door" :size="17" /> {{ t('exit') }}</button>
</div>
@@ -129,11 +126,11 @@
<div v-if="currentMembers.length" class="voice-grid">
<article v-for="member in roomMembers" :key="member.id" :class="['voice-card', { speaking: isSpeaking(member), self: member.isSelf }]">
<div class="voice-avatar-wrap"><div :class="['voice-avatar', { speaking: isSpeaking(member) }]" :style="avatarStyle(member.nickname, member.isSelf)">{{ avatarInitial(member.nickname) }}</div></div>
<strong>{{ member.isSelf ? (language === 'zh' ? '你' : 'You') : member.nickname }}</strong><span>{{ isSpeaking(member) ? t('speaking') : member.isSelf ? t('connectedYou') : t('connected') }}</span>
<strong>{{ member.isSelf ? t('you') : member.nickname }}</strong><span>{{ isSpeaking(member) ? t('speaking') : member.isSelf ? t('connectedYou') : t('connected') }}</span>
</article>
<article v-if="currentMembers.length > roomMembers.length" class="voice-card more-card"><div class="more-count">+{{ currentMembers.length - roomMembers.length }}</div><strong>{{ t('moreMembers') }}</strong><span>{{ t('viewLeft') }}</span></article>
</div>
<div v-else class="voice-empty"><span class="empty-icon"><Icon name="users" :size="20" /></span><strong>{{ language === 'zh' ? '等待成员加入语音' : 'Waiting for people to join' }}</strong><span>{{ language === 'zh' ? '你可以先在这里准备好麦克风。' : 'You can get your microphone ready.' }}</span></div>
<div v-else class="voice-empty"><span class="empty-icon"><Icon name="users" :size="20" /></span><strong>{{ t('waitingForMembers') }}</strong><span>{{ t('prepareMicrophone') }}</span></div>
</section>
<section class="chat-panel">
@@ -153,7 +150,7 @@
<template v-for="message in visibleChatMessages" :key="message.id">
<article v-if="chatTab !== 'events'" :class="['message-row', { mine: message.isSelf }]">
<div class="message-avatar" :style="avatarStyle(message.invokerName, message.isSelf)">{{ avatarInitial(message.invokerName) }}</div>
<div class="message-body"><div class="message-meta"><strong>{{ message.isSelf ? (language === 'zh' ? '你' : 'You') : message.invokerName }}</strong><time>{{ formatTime(message.timestamp) }}</time></div><div class="message-bubble">{{ message.message }}</div></div>
<div class="message-body"><div class="message-meta"><strong>{{ message.isSelf ? t('you') : message.invokerName }}</strong><time>{{ formatTime(message.timestamp) }}</time></div><div class="message-bubble">{{ message.message }}</div></div>
</article>
</template>
</div>
@@ -181,7 +178,7 @@
<div v-if="channelItem.members.length" class="member-list">
<div v-for="member in channelItem.members" :key="`${channelItem.id}-${member.id}`" class="member-row" @contextmenu.prevent="openMemberMenu(member, $event)">
<div :class="['member-avatar', { speaking: isSpeaking(member) }]" :style="avatarStyle(member.nickname, member.isSelf)">{{ avatarInitial(member.nickname) }}<span class="member-presence"></span></div>
<div class="member-copy"><strong>{{ member.isSelf ? `${member.nickname}${language === 'zh' ? '(你)' : ' (You)'}` : member.nickname }}</strong><span>{{ member.away ? t('away') : isSpeaking(member) ? t('speaking') : member.isSelf ? t('yourDevice') : t('memberOnline') }}</span></div>
<div class="member-copy"><strong>{{ memberDisplayName(member) }}</strong><span>{{ member.away ? t('away') : isSpeaking(member) ? t('speaking') : member.isSelf ? t('yourDevice') : t('memberOnline') }}</span></div>
<div class="member-flags" :aria-label="t('memberStates')"><span v-if="member.away" :title="t('away')" :aria-label="t('away')"><Icon name="clock" :size="13" /></span><span v-if="member.inputMuted" :title="t('inputMuted')" :aria-label="t('inputMuted')"><Icon name="mic-off" :size="13" /></span><span v-if="member.outputMuted" :title="t('outputMuted')" :aria-label="t('outputMuted')"><Icon name="volume-off" :size="13" /></span><span v-if="member.channelCommander" :title="t('channelCommander')" :aria-label="t('channelCommander')"><Icon name="shield" :size="13" /></span></div>
<div class="member-volume"><Icon :name="(volumes[member.id] ?? 1) === 0 ? 'volume-off' : 'volume'" :size="14" /><input type="range" min="0" max="400" :value="(volumes[member.id] ?? 1) * 100" :style="rangeStyle((volumes[member.id] ?? 1) / 4, 1)" :aria-label="t('memberVolume')" @input="onVolInput(member.id, $event)" /></div>
<button v-if="!member.isSelf" type="button" class="member-more" :aria-label="t('moreMemberOptions')" :title="t('moreMemberOptions')" @click.stop="openMemberMenu(member, $event)"><Icon name="more" :size="17" /></button>
@@ -197,6 +194,7 @@
<div v-if="memberMenu" class="member-context-menu" :style="memberMenuStyle" @click.stop>
<strong>{{ memberMenu.member.nickname }}</strong>
<label class="menu-volume"><span>{{ t('memberVolume') }}</span><input type="range" min="0" max="400" :value="(volumes[memberMenu.member.id] ?? 1) * 100" :style="rangeStyle((volumes[memberMenu.member.id] ?? 1) / 4, 1)" :aria-label="t('memberVolume')" @input="onVolInput(memberMenu.member.id, $event)" /></label>
<button type="button" @click="openPrivateChat(memberMenu.member.id); memberMenu = null"><Icon name="message" :size="15" /> {{ t('privateMessage') }}</button>
<button type="button" @click="pokeMember(memberMenu.member); memberMenu = null"><Icon name="bell" :size="15" /> {{ t('poke') }}</button>
<button type="button" @click="copyMemberName(memberMenu.member); memberMenu = null"><Icon name="copy" :size="15" /> {{ t('copyNickname') }}</button>
@@ -221,6 +219,7 @@ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue";
import Icon from "../components/Icon.vue";
import { useVoiceWebSocket, type ChannelInfo, type ChannelMember } from "../composables/useVoiceWebSocket.js";
import { clearLocalData as clearStoredLocalData, isLocalPersistenceAvailable, listFavorites, listRecentServers, loadLocalPreferences, loadStoredIdentity, recordRecentServer, removeFavorite, saveFavorite, saveLocalPreferences, saveStoredIdentity, type FavoriteServer, type RecentServer } from "../services/local-persistence.js";
import { applyTheme, getStoredTheme, nextTheme, saveTheme, type ThemeMode } from "../services/theme.js";
interface TreeChannel extends ChannelInfo {
depth: number;
@@ -313,8 +312,14 @@ let toastTimer: ReturnType<typeof setTimeout> | undefined;
type Language = "zh" | "en";
const language = ref<Language>(getInitialLanguage());
const themeMode = ref<ThemeMode>(getStoredTheme());
const themeLabel = computed(() => themeMode.value === "dark" ? t("themeDark") : themeMode.value === "light" ? t("themeLight") : t("themeSystem"));
applyTheme(themeMode.value);
const translations: Record<Language, Record<string, string>> = {
zh: {
themeSystem: "跟随系统",
themeLight: "浅色主题",
themeDark: "深色主题",
browserWorkspace: "浏览器语音工作台",
secureGateway: "安全语音网关",
adminConsole: "管理控制台",
@@ -346,6 +351,7 @@ const translations: Record<Language, Record<string, string>> = {
emptyDefault: "留空进入默认频道",
rememberIdentity: "记住此设备的 TeamSpeak 身份",
rememberIdentityHint: "仅保存在本设备,用于下次连接时保持身份。",
identityOptions: "设备身份选项",
localPersistenceUnavailable: "当前浏览器无法使用持久化存储,本次将使用临时身份。",
identityImport: "导入身份",
identityExport: "导出身份",
@@ -403,9 +409,13 @@ const translations: Record<Language, Record<string, string>> = {
voiceActivity: "语音活动",
speakingNow: "正在语音中",
onlineShort: "{{count}} 在线",
you: "你",
selfSuffix: "(你)",
connected: "已连接",
speaking: "正在说话…",
connectedYou: "已连接 · 你",
waitingForMembers: "等待成员加入语音",
prepareMicrophone: "你可以先在这里准备好麦克风。",
moreMembers: "更多成员",
viewLeft: "在左侧查看",
textChannel: "文字频道",
@@ -515,6 +525,9 @@ const translations: Record<Language, Record<string, string>> = {
langSwitch: "English",
},
en: {
themeSystem: "System theme",
themeLight: "Light theme",
themeDark: "Dark theme",
browserWorkspace: "Browser voice workspace",
secureGateway: "Secure voice gateway",
adminConsole: "Admin console",
@@ -546,6 +559,7 @@ const translations: Record<Language, Record<string, string>> = {
emptyDefault: "Leave empty to use the default channel",
rememberIdentity: "Remember this TeamSpeak identity on this device",
rememberIdentityHint: "Stored only on this device and reused on the next connection.",
identityOptions: "Device identity options",
localPersistenceUnavailable: "Persistent browser storage is unavailable; this session will use an ephemeral identity.",
identityImport: "Import identity",
identityExport: "Export identity",
@@ -603,9 +617,13 @@ const translations: Record<Language, Record<string, string>> = {
voiceActivity: "VOICE ACTIVITY",
speakingNow: "Speaking now",
onlineShort: "{{count}} online",
you: "You",
selfSuffix: " (You)",
connected: "Connected",
speaking: "Speaking…",
connectedYou: "Connected · you",
waitingForMembers: "Waiting for people to join",
prepareMicrophone: "You can get your microphone ready.",
moreMembers: "More members",
viewLeft: "See them on the left",
textChannel: "TEXT CHANNEL",
@@ -730,9 +748,7 @@ function initialServerAddress(): string {
function getInitialLanguage(): Language {
const stored = localStorage.getItem("webspeak:language");
if (stored === "zh" || stored === "en") return stored;
// Keep the existing Chinese-first experience; the choice is remembered
// after the visitor uses the language switcher.
return "zh";
return typeof navigator !== "undefined" && navigator.language.toLowerCase().startsWith("zh") ? "zh" : "en";
}
function t(key: string, variables: Record<string, string | number> = {}) {
@@ -790,6 +806,12 @@ function toggleLanguage() {
void saveLocalPreferences({ schemaVersion: 1, language: language.value });
}
function cycleTheme() {
themeMode.value = nextTheme(themeMode.value);
saveTheme(themeMode.value);
void saveLocalPreferences({ schemaVersion: 1, theme: themeMode.value });
}
const heroBars = [12, 24, 18, 35, 18, 28, 42, 23, 50, 34, 19, 28, 39, 22, 46, 25, 17, 31, 14];
const channelTree = computed<TreeChannel[]>(() => {
@@ -944,6 +966,10 @@ onMounted(() => {
void loadPublicConfig();
void loadLocalPreferences().then((preferences) => {
if (!localStorage.getItem("webspeak:language") && (preferences.language === "zh" || preferences.language === "en")) language.value = preferences.language;
if (!localStorage.getItem("webspeak:theme") && (preferences.theme === "system" || preferences.theme === "light" || preferences.theme === "dark")) {
themeMode.value = preferences.theme;
applyTheme(themeMode.value);
}
});
void loadStoredIdentity().then((stored) => {
if (stored) {
@@ -1054,7 +1080,9 @@ async function toggleFavorite(): Promise<void> {
async function clearBrowserData(): Promise<void> {
if (!window.confirm(t("clearLocalDataConfirm"))) return;
await clearStoredLocalData();
for (const key of ["webspeak:nickname", "webspeak:language", "webspeak:input-device", "webspeak:remember-identity"]) localStorage.removeItem(key);
for (const key of ["webspeak:nickname", "webspeak:language", "webspeak:theme", "webspeak:input-device", "webspeak:output-device", "webspeak:remember-identity"]) localStorage.removeItem(key);
themeMode.value = "system";
applyTheme(themeMode.value);
identityMaterial.value = "";
rememberIdentity.value = false;
favoriteServers.value = [];
@@ -1183,6 +1211,10 @@ function isSpeaking(member: ChannelMember) {
return speakingIds.has(member.id) || Boolean(member.isSelf && pttActive.value);
}
function memberDisplayName(member: ChannelMember): string {
return member.isSelf ? `${member.nickname}${t("selfSuffix")}` : member.nickname;
}
function formatTime(timestamp: number) {
return new Intl.DateTimeFormat(language.value === "zh" ? "zh-CN" : "en-US", { hour: "2-digit", minute: "2-digit" }).format(timestamp);
}
@@ -1413,6 +1445,11 @@ function onMobilePttUp(event: PointerEvent) {
.nav-rail, .channel-sidebar { display: none; }
.workspace { min-width: 0; }
.identity-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1px; }
.identity-options { margin-top: 8px; color: #677872; font-size: 11px; }
.identity-options summary { width: fit-content; color: #277970; cursor: pointer; }
.identity-options[open] summary { margin-bottom: 10px; }
.cancel-connect-button { justify-self: center; min-height: 32px; padding: 0 10px; color: #6b7d77; background: transparent; font-size: 11px; cursor: pointer; }
.cancel-connect-button:hover { color: #006a64; text-decoration: underline; }
.identity-tool-button { padding: 5px 8px; color: #277970; background: #eef8f5; border: 1px solid #d7ebe6; border-radius: 6px; font-size: 10px; cursor: pointer; }
.identity-tool-button:hover { background: #e0f3ee; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@@ -1524,8 +1561,9 @@ function onMobilePttUp(event: PointerEvent) {
/* Keep the connected workspace sized to the browser viewport and let the
workspace and member tree own their scroll areas when the window shrinks. */
:global(html), :global(body), :global(#app) { width: 100%; height: 100dvh; min-height: 0; max-height: 100dvh; }
:global(body) { overflow: hidden; }
:global(body) { overflow-x: hidden; overflow-y: auto; }
.web-client { height: 100dvh; min-height: 0; max-height: 100dvh; }
.web-client { overflow: hidden; }
.join-page { height: 100dvh; min-height: 0; overflow-y: auto; }
.app-shell { grid-template-columns: 318px minmax(0, 1fr); height: 100dvh; min-height: 0; max-height: 100dvh; }
.workspace { grid-column: 2; grid-row: 1; min-height: 0; height: 100%; }
@@ -1581,6 +1619,10 @@ function onMobilePttUp(event: PointerEvent) {
.member-context-menu strong { padding: 4px 8px 7px; color: #2a3934; font-size: 12px; }
.member-context-menu button { display: flex; align-items: center; gap: 8px; padding: 8px; color: #52625c; background: transparent; border-radius: 6px; font-size: 11px; text-align: left; cursor: pointer; }
.member-context-menu button:hover { color: #006a64; background: #edf6f3; }
.menu-volume { display: grid; gap: 6px; padding: 4px 8px 8px; color: #71817c; font-size: 10px; }
.menu-volume input { width: 100%; height: 5px; appearance: none; border-radius: 99px; outline: none; cursor: pointer; }
.menu-volume input::-webkit-slider-thumb { width: 14px; height: 14px; appearance: none; border: 2px solid #81d8d0; border-radius: 50%; background: #fff; cursor: pointer; }
.menu-volume input::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #81d8d0; border-radius: 50%; background: #fff; cursor: pointer; }
.poke-banner { position: fixed; z-index: 35; top: 82px; right: 24px; display: flex; align-items: center; gap: 9px; max-width: min(380px, calc(100% - 48px)); padding: 10px 11px; color: #52645c; background: #fffdf6; border: 1px solid #f0dfbd; border-radius: 9px; box-shadow: 0 8px 22px rgba(88, 65, 28, .12); font-size: 12px; }
.poke-banner > .ui-icon { color: #d2973d; }
.poke-banner span { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -1598,4 +1640,33 @@ function onMobilePttUp(event: PointerEvent) {
.mobile-ptt-button { display: none; align-items: center; justify-content: center; gap: 9px; min-height: 54px; margin-top: 12px; color: #fff; background: #006a64; border-radius: 12px; font-size: 14px; font-weight: 700; cursor: pointer; touch-action: none; user-select: none; }
.mobile-ptt-button.active { background: #2f9d5c; box-shadow: 0 0 0 4px rgba(47,157,92,.16); }
@media (max-width: 740px) { .mobile-ptt-button { display: flex; } }
/* M008 semantic theme tokens and keyboard-safe surfaces. */
:global(:root) { color-scheme: light; --surface-0: #f7f9f8; --surface-1: #fff; --surface-2: #f1f6f4; --text-primary: #192120; --text-muted: #71807c; --border: #e4ece9; --accent: #006a64; --success: #65d879; --warning: #c89143; --danger: #c95a54; }
:global(:root[data-theme="dark"]) { color-scheme: dark; --surface-0: #101918; --surface-1: #172321; --surface-2: #202f2c; --text-primary: #e8f3f0; --text-muted: #9bb0aa; --border: #30413d; --accent: #69d2c7; --success: #78e489; --warning: #e2b36c; --danger: #ee8a82; }
@media (prefers-color-scheme: dark) { :global(:root[data-theme="system"]) { color-scheme: dark; --surface-0: #101918; --surface-1: #172321; --surface-2: #202f2c; --text-primary: #e8f3f0; --text-muted: #9bb0aa; --border: #30413d; --accent: #69d2c7; --success: #78e489; --warning: #e2b36c; --danger: #ee8a82; } }
.web-client, .join-page { background: var(--surface-0); color: var(--text-primary); }
.app-shell, .workspace { background: var(--surface-1); }
.workspace-header, .member-panel, .voice-card, .settings-modal { background: var(--surface-1); border-color: var(--border); }
.workspace-header { border-bottom-color: var(--border); }
.workspace-content { color: var(--text-primary); }
.join-card { background: color-mix(in srgb, var(--surface-1) 92%, transparent); border-color: var(--border); }
.field-wrap, .message-composer, .member-search, .mic-mode-switch, .mode-note { background: var(--surface-2); }
.field-wrap input, .message-composer input, .member-search input, .settings-select { color: var(--text-primary); }
.room-hero { background: linear-gradient(110deg, color-mix(in srgb, var(--accent) 18%, var(--surface-1)), var(--surface-1) 75%); }
.voice-card, .member-panel, .settings-modal { box-shadow: 0 7px 18px color-mix(in srgb, var(--text-primary) 8%, transparent); }
.section-heading h2, .room-hero h1, .join-card h2, .member-panel-heading h2, .message-meta strong, .member-copy strong { color: var(--text-primary); }
.section-kicker, .card-kicker, .settings-label, .header-note, .section-counter, .message-meta time, .member-copy span, .chat-empty, .join-description, .card-lead { color: var(--text-muted); }
.chat-panel, .chat-heading, .settings-header, .settings-footer, .settings-separator { border-color: var(--border); }
.message-bubble { color: var(--text-primary); background: var(--surface-2); }
.settings-content, .settings-nav { background: var(--surface-1); }
.settings-nav { border-right-color: var(--border); }
.settings-section h3, .settings-header h2 { color: var(--text-primary); }
.settings-select { background: var(--surface-2); border-color: var(--border); }
.audio-level-track, .meter i { background: var(--border); }
.member-presence { border-color: var(--surface-1); }
:global(button:focus-visible), :global(a:focus-visible), :global(input:focus-visible), :global(select:focus-visible), :global(textarea:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.message-composer { position: sticky; bottom: env(safe-area-inset-bottom, 0px); z-index: 3; }
@media (max-width: 740px) { .workspace-scroll { overscroll-behavior: contain; }.workspace-content { width: min(100% - 24px, 650px); padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }.message-composer { margin-bottom: 8px; }.mobile-ptt-button { position: sticky; bottom: env(safe-area-inset-bottom, 0px); z-index: 3; } }
@media (max-width: 740px) { .member-context-menu { left: 12px !important; right: 12px; top: auto !important; bottom: env(safe-area-inset-bottom, 0px); min-width: 0; border-radius: 16px 16px 0 0; padding: 14px; } .member-context-menu button { min-height: 42px; font-size: 13px; } .member-context-menu strong { padding: 4px 8px 11px; font-size: 14px; } .menu-volume { font-size: 12px; } }
</style>