feat(web): add skinnable favorite server switching

This commit is contained in:
illusia committed 2026-10-09 10:35:01 +08:00
1 parent ae1cd707be
commit b6e4d349a2
19 files changed
+1220 -44

No files matched your search

+1
View File
@@ -53,6 +53,7 @@
<template v-else-if="name === 'plus'">
<path d="M12 5v14M5 12h14" />
</template>
<path v-else-if="name === 'star'" d="m12 3 2.8 5.7 6.2.9-4.5 4.4 1.1 6.2-5.6-3-5.6 3 1.1-6.2L3 9.6l6.2-.9z" />
<path v-else-if="name === 'chevron-down'" d="m6 9 6 6 6-6" />
<path v-else-if="name === 'chevron-right'" d="m9 6 6 6-6 6" />
<path v-else-if="name === 'hash'" d="M9 3 7 21M17 3l-2 18M4 9h16M3 15h16" />
@@ -0,0 +1,335 @@
<template>
<div
v-if="open"
class="modal-backdrop favorite-server-dialog-backdrop"
data-ws-part="voice.favorite-servers.dialog-backdrop"
@click.self="$emit('close')"
>
<section
class="favorite-server-dialog"
data-ws-part="voice.favorite-servers.dialog"
role="dialog"
aria-modal="true"
:aria-labelledby="titleId"
@keydown.esc.prevent="$emit('close')"
>
<header class="favorite-server-dialog-header" data-ws-part="voice.favorite-servers.dialog.header">
<div>
<span>{{ t("favoriteServers") }}</span>
<h2 :id="titleId">{{ t("quickConnectTitle") }}</h2>
</div>
<button
type="button"
class="favorite-server-dialog-close"
data-ws-part="voice.favorite-servers.dialog.close"
:aria-label="t('close')"
@click="$emit('close')"
>
<Icon name="close" :size="18" />
</button>
</header>
<form class="favorite-server-dialog-form" data-ws-part="voice.favorite-servers.dialog.form" @submit.prevent="submit">
<label class="favorite-server-dialog-field" data-ws-part="voice.favorite-servers.dialog.field">
<span>{{ t("favoriteDisplayName") }}</span>
<input
v-model="label"
data-ws-part="voice.favorite-servers.dialog.input"
maxlength="48"
:placeholder="t('favoriteDisplayNamePlaceholder')"
autocomplete="off"
/>
</label>
<div class="favorite-server-dialog-target" data-ws-part="voice.favorite-servers.dialog.target">
<label class="favorite-server-dialog-field" data-ws-part="voice.favorite-servers.dialog.field">
<span>{{ t("serverAddress") }}</span>
<input
ref="addressInput"
v-model="address"
data-ws-part="voice.favorite-servers.dialog.input"
required
maxlength="253"
:placeholder="t('serverAddressPlaceholder')"
autocomplete="off"
autocapitalize="off"
spellcheck="false"
/>
</label>
<label class="favorite-server-dialog-field favorite-server-dialog-port" data-ws-part="voice.favorite-servers.dialog.field">
<span>{{ t("serverPort") }}</span>
<input
v-model="port"
data-ws-part="voice.favorite-servers.dialog.input"
type="text"
inputmode="numeric"
pattern="[0-9]*"
:placeholder="t('serverPortPlaceholder')"
/>
</label>
</div>
<p class="favorite-server-dialog-hint" data-ws-part="voice.favorite-servers.dialog.hint">{{ t("serverAddressHint") }}</p>
<label class="favorite-server-dialog-field" data-ws-part="voice.favorite-servers.dialog.field">
<span>{{ t("nickname") }}</span>
<input
v-model="nickname"
data-ws-part="voice.favorite-servers.dialog.input"
required
maxlength="64"
:placeholder="t('nicknamePlaceholder')"
autocomplete="nickname"
/>
</label>
<label class="favorite-server-dialog-field" data-ws-part="voice.favorite-servers.dialog.field">
<span>{{ t("targetChannel") }} <small>{{ t("optional") }}</small></span>
<input
v-model="channel"
data-ws-part="voice.favorite-servers.dialog.input"
maxlength="128"
:placeholder="t('emptyDefault')"
autocomplete="off"
/>
</label>
<footer class="favorite-server-dialog-actions" data-ws-part="voice.favorite-servers.dialog.actions">
<button type="button" class="favorite-server-dialog-cancel" data-ws-part="voice.favorite-servers.dialog.cancel" @click="$emit('close')">
{{ t("cancel") }}
</button>
<button type="submit" class="favorite-server-dialog-submit" data-ws-part="voice.favorite-servers.dialog.submit" :disabled="busy">
<Icon name="plus" :size="17" />
{{ t("quickConnectAndSave") }}
</button>
</footer>
</form>
</section>
</div>
</template>
<script setup lang="ts">
import { nextTick, ref, watch } from "vue";
import Icon from "../Icon.vue";
export interface FavoriteServerDraft {
label: string;
address: string;
port: string;
nickname: string;
channel: string;
}
const props = defineProps<{
open: boolean;
busy: boolean;
defaultNickname: string;
t: (key: string) => string;
}>();
const emit = defineEmits<{
close: [];
submit: [draft: FavoriteServerDraft];
}>();
const titleId = "favorite-server-dialog-title";
const label = ref("");
const address = ref("");
const port = ref("9987");
const nickname = ref("");
const channel = ref("");
const addressInput = ref<HTMLInputElement | null>(null);
watch(() => props.open, (open) => {
if (!open) return;
label.value = "";
address.value = "";
port.value = "9987";
nickname.value = props.defaultNickname;
channel.value = "";
void nextTick(() => addressInput.value?.focus());
});
function submit(): void {
emit("submit", {
label: label.value.trim(),
address: address.value.trim(),
port: port.value.trim(),
nickname: nickname.value.trim(),
channel: channel.value.trim(),
});
}
</script>
<style scoped>
.favorite-server-dialog-backdrop {
position: fixed;
inset: 0;
display: grid;
place-items: center;
z-index: 60;
padding: 24px;
background: rgba(15, 25, 23, .48);
backdrop-filter: blur(5px);
}
.favorite-server-dialog {
width: min(460px, 100%);
max-height: min(760px, calc(100dvh - 48px));
overflow-y: auto;
padding: 24px;
color: var(--text-primary, #182321);
background: var(--surface-1, #fff);
border: 1px solid var(--border, #dce5e2);
border-radius: 18px;
box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}
.favorite-server-dialog-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 20px;
}
.favorite-server-dialog-header > div > span {
color: var(--accent, #08766c);
font-size: 11px;
font-weight: 750;
letter-spacing: .08em;
text-transform: uppercase;
}
.favorite-server-dialog-header h2 {
margin: 5px 0 0;
font-size: 22px;
}
.favorite-server-dialog-close {
display: grid;
flex: 0 0 38px;
place-items: center;
width: 38px;
height: 38px;
color: var(--text-muted, #687773);
background: var(--surface-2, #f2f6f4);
border: 1px solid var(--border, #dce5e2);
border-radius: 10px;
cursor: pointer;
}
.favorite-server-dialog-form {
display: grid;
gap: 14px;
}
.favorite-server-dialog-field {
display: grid;
min-width: 0;
gap: 7px;
color: var(--text-secondary, #43534e);
font-size: 12px;
font-weight: 700;
}
.favorite-server-dialog-field > span {
display: flex;
align-items: baseline;
gap: 6px;
}
.favorite-server-dialog-field small {
color: var(--text-muted, #81908b);
font-size: 10px;
font-weight: 500;
}
.favorite-server-dialog-field input {
width: 100%;
min-width: 0;
height: 44px;
padding: 0 12px;
color: var(--text-primary, #182321);
background: var(--surface-2, #f7f9f8);
border: 1px solid var(--border, #dce5e2);
border-radius: 10px;
outline: none;
font: inherit;
font-size: 14px;
}
.favorite-server-dialog-field input:focus {
border-color: var(--accent, #08766c);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #08766c) 16%, transparent);
}
.favorite-server-dialog-target {
display: grid;
grid-template-columns: minmax(0, 1fr) 112px;
gap: 10px;
}
.favorite-server-dialog-hint {
margin: -7px 0 0;
color: var(--text-muted, #75847f);
font-size: 11px;
line-height: 1.5;
}
.favorite-server-dialog-actions {
display: flex;
justify-content: flex-end;
gap: 9px;
margin-top: 4px;
}
.favorite-server-dialog-actions button {
display: inline-flex;
min-height: 42px;
align-items: center;
justify-content: center;
gap: 6px;
padding: 0 14px;
border-radius: 10px;
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
}
.favorite-server-dialog-cancel {
color: var(--text-secondary, #43534e);
background: var(--surface-2, #f2f6f4);
border: 1px solid var(--border, #dce5e2);
}
.favorite-server-dialog-submit {
color: #fff;
background: var(--accent, #08766c);
border: 1px solid var(--accent, #08766c);
}
.favorite-server-dialog-submit:disabled {
cursor: wait;
opacity: .65;
}
@media (max-width: 740px) {
.favorite-server-dialog-backdrop {
align-items: flex-end;
padding: 0;
}
.favorite-server-dialog {
width: 100%;
max-height: calc(var(--ws-viewport-height, 100dvh) - env(safe-area-inset-top, 0px));
padding: 22px 18px calc(18px + env(safe-area-inset-bottom, 0px));
border-radius: 22px 22px 0 0;
}
.favorite-server-dialog-actions button {
min-height: 46px;
}
}
</style>
@@ -32,7 +32,7 @@ interface UseWebClientConnectionOptions {
rememberIdentity: Readonly<Ref<boolean>>;
identityMaterial: Ref<string>;
accelerationRelayId: Ref<string>;
inviteToken: string;
inviteToken: Ref<string>;
selectedChannelId: Ref<string>;
channels: Readonly<Ref<TreeChannel[]>>;
clientId: Readonly<Ref<number>>;
@@ -113,7 +113,7 @@ export function useWebClientConnection({
serverPassword.value,
rememberIdentity.value ? identityMaterial.value : "",
rememberIdentity.value,
inviteToken,
inviteToken.value,
Boolean(accelerationRelayId.value),
accelerationRelayId.value,
);
@@ -28,7 +28,7 @@ export function useWebClientPublicConfig({
const initialized = ref(false);
const mobileMode = ref(false);
const siteName = ref("WebSpeak");
const appVersion = ref("0.2.6");
const appVersion = ref("0.2.7-preview");
const visitorNumber = ref<number | null>(null);
const visitorTotal = ref<number | null>(null);
const accelerationRelays = ref<RelayOption[]>([]);
@@ -3,7 +3,7 @@ import {
listFavorites,
listRecentServers,
recordRecentServer,
removeFavorite,
removeFavorite as deleteFavorite,
saveFavorite,
type FavoriteServer,
type RecentServer,
@@ -65,27 +65,44 @@ export function useWebClientServerHistory({
if (savedNickname && !nickname.value.trim()) nickname.value = savedNickname;
}
async function saveFavoriteServer(
address: string,
label = address,
savedNickname = nickname.value.trim(),
channelHint = channel.value.trim(),
): Promise<void> {
const normalizedAddress = address.trim();
if (!normalizedAddress) return;
const id = serverKey(normalizedAddress);
const favorite: FavoriteServer = {
id,
label: label.trim() || normalizedAddress,
address: normalizedAddress,
...(savedNickname ? { nickname: savedNickname } : {}),
...(rememberIdentity.value && identityMaterial.value ? { identityId: "current" } : {}),
...(channelHint ? { lastChannelHint: { name: channelHint } } : {}),
};
await saveFavorite(favorite);
favoriteServers.value = [...favoriteServers.value.filter((item) => item.id !== id), favorite]
.sort((left, right) => left.label.localeCompare(right.label));
}
async function removeFavoriteServer(id: string): Promise<void> {
await deleteFavorite(id);
favoriteServers.value = favoriteServers.value.filter((favorite) => favorite.id !== id);
}
async function toggleFavorite(): Promise<void> {
const address = currentTarget.value;
if (!address) return;
const id = serverKey(address);
const existing = favoriteServers.value.find((favorite) => favorite.id === id);
if (existing) {
await removeFavorite(id);
favoriteServers.value = favoriteServers.value.filter((favorite) => favorite.id !== id);
await removeFavoriteServer(id);
showToast(t("removedFavoriteToast"));
return;
}
const favorite: FavoriteServer = {
id,
label: address,
address,
...(nickname.value.trim() ? { nickname: nickname.value.trim() } : {}),
...(rememberIdentity.value && identityMaterial.value ? { identityId: "current" } : {}),
...(channel.value.trim() ? { lastChannelHint: { name: channel.value.trim() } } : {}),
};
await saveFavorite(favorite);
favoriteServers.value = [...favoriteServers.value, favorite].sort((left, right) => left.label.localeCompare(right.label));
await saveFavoriteServer(address, address);
showToast(t("savedFavoriteToast"));
}
@@ -101,6 +118,8 @@ export function useWebClientServerHistory({
loadSavedServers,
recordCurrentServer,
selectLocalServer,
saveFavoriteServer,
removeFavoriteServer,
toggleFavorite,
clearServerHistory,
};
+58
View File
@@ -82,6 +82,16 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
identityImportErrorUnsupported: "此浏览器不支持本地身份解析所需的安全加密功能。",
localPersistenceUnavailable: "当前浏览器无法使用持久化存储,本次将使用临时身份。",
favoriteServers: "常用服务器",
addFavoriteServer: "添加服务器",
quickConnectTitle: "添加服务器收藏",
favoriteDisplayName: "显示名称",
favoriteDisplayNamePlaceholder: "例如:游戏、朋友或社区",
quickConnectAndSave: "保存并连接",
switchToFavorite: "切换到 {{server}}",
removeFavoriteForServer: "移除收藏:{{server}}",
favoriteSwitching: "正在切换到 {{server}}…",
favoriteConnectionFailed: "无法连接到 {{server}}",
quickConnectFailed: "连接失败,请检查服务器地址和昵称。",
recentServers: "最近连接",
saveFavorite: "保存到常用",
removeFavorite: "移除常用",
@@ -477,6 +487,16 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
identityImportErrorUnsupported: "This browser does not support the secure cryptography needed to parse identities locally.",
localPersistenceUnavailable: "Persistent browser storage is unavailable; this session will use an ephemeral identity.",
favoriteServers: "Favorites",
addFavoriteServer: "Add server",
quickConnectTitle: "Add a server favorite",
favoriteDisplayName: "Display name",
favoriteDisplayNamePlaceholder: "For example: gaming, friends, or community",
quickConnectAndSave: "Save and connect",
switchToFavorite: "Switch to {{server}}",
removeFavoriteForServer: "Remove {{server}} from favorites",
favoriteSwitching: "Switching to {{server}}…",
favoriteConnectionFailed: "Could not connect to {{server}}",
quickConnectFailed: "Connection failed. Check the server address and nickname.",
recentServers: "Recent servers",
saveFavorite: "Save favorite",
removeFavorite: "Remove favorite",
@@ -875,6 +895,16 @@ webClientTranslations.de = {
identityImportErrorUnsupported: "Dieser Browser unterstützt die sichere lokale Identitätsverarbeitung nicht.",
localPersistenceUnavailable: "Dauerhafter Browserspeicher ist nicht verfügbar; diese Sitzung verwendet eine temporäre Identität.",
favoriteServers: "Favoriten",
addFavoriteServer: "Server hinzufügen",
quickConnectTitle: "Server zu Favoriten hinzufügen",
favoriteDisplayName: "Anzeigename",
favoriteDisplayNamePlaceholder: "Zum Beispiel: Gaming, Freunde oder Community",
quickConnectAndSave: "Speichern und verbinden",
switchToFavorite: "Zu {{server}} wechseln",
removeFavoriteForServer: "{{server}} aus Favoriten entfernen",
favoriteSwitching: "Wechsel zu {{server}}…",
favoriteConnectionFailed: "Verbindung zu {{server}} fehlgeschlagen",
quickConnectFailed: "Verbindung fehlgeschlagen. Serveradresse und Spitzname prüfen.",
recentServers: "Zuletzt verwendet",
saveFavorite: "Als Favorit speichern",
removeFavorite: "Aus Favoriten entfernen",
@@ -1302,6 +1332,20 @@ webClientTranslations.ru = {
enterVoice: "Войти в голосовое пространство",
connectionAuthorized: "Данные подключения используются только для этой голосовой сессии",
recentServers: "Недавние серверы",
favoriteServers: "Избранное",
addFavoriteServer: "Добавить сервер",
quickConnectTitle: "Добавить сервер в избранное",
favoriteDisplayName: "Отображаемое имя",
favoriteDisplayNamePlaceholder: "Например: игра, друзья или сообщество",
quickConnectAndSave: "Сохранить и подключиться",
switchToFavorite: "Переключиться на {{server}}",
removeFavoriteForServer: "Удалить {{server}} из избранного",
favoriteSwitching: "Переключение на {{server}}…",
favoriteConnectionFailed: "Не удалось подключиться к {{server}}",
quickConnectFailed: "Не удалось подключиться. Проверьте адрес сервера и имя.",
removeFavorite: "Удалить из избранного",
cancel: "Отмена",
close: "Закрыть",
saveFavorite: "Сохранить в избранное",
savedFavoriteToast: "Сервер сохранён в избранное",
removedFavoriteToast: "Сервер удалён из избранного",
@@ -1482,6 +1526,20 @@ webClientTranslations.ja = {
enterVoice: "音声スペースに参加",
connectionAuthorized: "接続情報は今回の音声セッションでのみ使用されます",
recentServers: "最近のサーバー",
favoriteServers: "お気に入り",
addFavoriteServer: "サーバーを追加",
quickConnectTitle: "サーバーをお気に入りに追加",
favoriteDisplayName: "表示名",
favoriteDisplayNamePlaceholder: "例:ゲーム、友人、コミュニティ",
quickConnectAndSave: "保存して接続",
switchToFavorite: "{{server}} に切り替え",
removeFavoriteForServer: "{{server}} をお気に入りから削除",
favoriteSwitching: "{{server}} に切り替えています…",
favoriteConnectionFailed: "{{server}} に接続できませんでした",
quickConnectFailed: "接続できませんでした。サーバーアドレスと名前を確認してください。",
removeFavorite: "お気に入りから削除",
cancel: "キャンセル",
close: "閉じる",
saveFavorite: "お気に入りに保存",
savedFavoriteToast: "サーバーをお気に入りに保存しました",
removedFavoriteToast: "お気に入りから削除しました",
+2 -2
View File
@@ -32,11 +32,11 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
id: BUILTIN_ILLUSIA_SKIN_ID,
name: "ILLUSIA风",
version: "1.0.27",
version: "1.0.28",
author: "WebSpeak Project",
license: "All rights reserved",
description: "A bright original-character art skin for the home, voice room, and demo pages.",
minAppVersion: "0.2.6",
minAppVersion: "0.2.7-preview",
previewUrl: "/skins/illusia-voice-preview.webp",
installedAt: 0,
builtIn: true,
+6 -1
View File
@@ -132,7 +132,8 @@ test("the ILLUSIA visual-only example imports without replacing WebSpeak's base
const skin = await importSkinPack(new File([bytes], "illusia-voice.wskin", { type: "application/octet-stream" }));
assert.equal(skin.id, "community.illusia-voice");
assert.equal(skin.name, "ILLUSIA风");
assert.equal(skin.version, "1.0.27");
assert.equal(skin.version, "1.0.28");
assert.equal(skin.minAppVersion, "0.2.7-preview");
assert.equal(skin.contentData, undefined);
assert.equal(skin.previewBlob?.type, "image/webp");
assert.ok(skin.assets["assets/background-composite.webp"]);
@@ -152,6 +153,10 @@ test("the ILLUSIA visual-only example imports without replacing WebSpeak's base
assert.match(skin.css, /language\.menu[^{}]*\[role="listbox"\]/);
assert.match(skin.css, /language\.option/);
assert.match(skin.css, /data-ws-skin-id="community\.illusia-voice"/);
assert.match(skin.css, /data-ws-part="voice\.favorite-servers\.rail"/);
assert.match(skin.css, /data-ws-part="voice\.favorite-servers\.strip\.server"\]\[data-ws-state="current"\]/);
assert.match(skin.css, /data-ws-part="voice\.favorite-servers\.dialog"\]\s*\{[^}]*background:\s*linear-gradient/s);
assert.match(skin.css, /data-ws-part="voice\.favorite-servers\.dialog\.input"\]:focus-visible\s*\{[^}]*box-shadow:/s);
assert.match(skin.css, /data-ws-part="home\.join-card\.waveform"/);
assert.match(skin.css, /data-ws-part="home\.join-card\.sonar"/);
assert.match(skin.css, /data-ws-part="home\.join-card"\]\s*\{[^}]*background-image:\s*url\("wskin-asset:assets%2Fbanner-mascot-blob\.webp"\)/s);
+1 -1
View File
@@ -33,7 +33,7 @@ export async function activateStoredSkin(): Promise<InstalledSkin | null> {
return activateSkin(selectedId);
}
export async function activateSkin(id: string, expectedVersion?: string, appVersion = "0.2.6", options: SkinLoadOptions = {}): Promise<InstalledSkin | null> {
export async function activateSkin(id: string, expectedVersion?: string, appVersion = "0.2.7-preview", options: SkinLoadOptions = {}): Promise<InstalledSkin | null> {
// An already retired page must not cancel a newer page's activation.
options.signal?.throwIfAborted();
pendingActivation?.cancel();
+395
View File
@@ -7659,3 +7659,398 @@
gap: 6px;
}
}
/* Favorite servers stay one click away while the connected workspace is open. */
.app-shell[data-favorite-rail="true"] {
grid-template-columns: 68px 318px minmax(0, 1fr);
}
.app-shell[data-favorite-rail="true"] .favorite-server-rail {
grid-column: 1;
grid-row: 1;
}
.app-shell[data-favorite-rail="true"] .workspace {
grid-column: 3;
grid-row: 1;
}
.app-shell[data-favorite-rail="true"] :deep(.member-panel) {
grid-column: 2;
grid-row: 1;
border-right: 1px solid var(--border);
border-left: 0;
}
.favorite-server-rail {
position: relative;
z-index: 12;
display: flex;
min-width: 0;
flex-direction: column;
align-items: center;
gap: 12px;
padding: 14px 8px 16px;
overflow: visible;
background: color-mix(in srgb, var(--surface-1) 96%, var(--accent));
border-right: 1px solid var(--border);
}
.favorite-server-rail-list {
display: flex;
min-height: 0;
flex: 1 1 auto;
flex-direction: column;
align-items: center;
gap: 10px;
overflow-x: visible;
overflow-y: auto;
scrollbar-width: none;
}
.favorite-server-rail-list::-webkit-scrollbar {
display: none;
}
.favorite-server-rail-item {
position: relative;
flex: 0 0 auto;
}
.favorite-server-button,
.favorite-server-add {
position: relative;
display: grid;
width: 48px;
height: 48px;
flex: 0 0 48px;
place-items: center;
padding: 3px;
color: var(--text-primary);
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 16px;
cursor: pointer;
transition: border-radius .16s ease, transform .16s ease, box-shadow .16s ease;
}
.favorite-server-button:hover,
.favorite-server-button:focus-visible,
.favorite-server-button.active,
.favorite-server-add:hover,
.favorite-server-add:focus-visible {
border-radius: 15px;
border-color: var(--accent);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}
.favorite-server-button.active::before {
position: absolute;
left: -9px;
width: 4px;
height: 24px;
content: "";
background: var(--accent);
border-radius: 0 4px 4px 0;
}
.favorite-server-button:disabled {
cursor: wait;
opacity: .65;
}
.favorite-server-avatar {
display: grid;
width: 40px;
height: 40px;
flex: 0 0 40px;
place-items: center;
overflow: hidden;
color: #19342f;
border-radius: 13px;
font-size: 17px;
font-weight: 800;
line-height: 1;
text-transform: uppercase;
}
.favorite-server-tooltip {
position: absolute;
z-index: 45;
top: 50%;
left: calc(100% + 13px);
display: grid;
width: max-content;
max-width: min(260px, calc(100vw - 110px));
gap: 3px;
padding: 9px 11px;
color: var(--text-primary);
background: var(--surface-1);
border: 1px solid var(--border);
border-radius: 9px;
box-shadow: 0 10px 26px color-mix(in srgb, var(--text-primary) 18%, transparent);
opacity: 0;
pointer-events: none;
transform: translateY(-50%) translateX(-4px);
transition: opacity .14s ease, transform .14s ease;
}
.favorite-server-tooltip strong {
overflow: hidden;
max-width: 238px;
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.favorite-server-tooltip small {
overflow: hidden;
max-width: 238px;
color: var(--text-muted);
font-size: 10px;
text-overflow: ellipsis;
white-space: nowrap;
}
.favorite-server-button:hover .favorite-server-tooltip,
.favorite-server-button:focus-visible .favorite-server-tooltip {
opacity: 1;
transform: translateY(-50%);
}
.favorite-server-remove {
position: absolute;
z-index: 1;
top: -5px;
right: -5px;
display: grid;
width: 19px;
height: 19px;
place-items: center;
padding: 0;
color: #fff;
background: #6f7d78;
border: 2px solid var(--surface-1);
border-radius: 50%;
cursor: pointer;
opacity: 0;
transform: scale(.85);
transition: opacity .14s ease, transform .14s ease, background .14s ease;
}
.favorite-server-rail-item:hover .favorite-server-remove,
.favorite-server-rail-item:focus-within .favorite-server-remove {
opacity: 1;
transform: scale(1);
}
.favorite-server-remove:hover {
background: var(--danger);
}
.favorite-server-add {
flex: 0 0 42px;
width: 42px;
height: 42px;
color: var(--text-muted);
border-radius: 50%;
}
.favorite-server-strip {
display: none;
}
.favorite-current-toggle.active :deep(.ui-icon) {
color: #e0a62f;
fill: currentColor;
}
.favorite-switch-banner {
display: flex;
align-items: center;
gap: 11px;
margin: 10px 16px 0;
padding: 10px 12px;
color: var(--text-primary);
background: color-mix(in srgb, var(--accent) 8%, var(--surface-1));
border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
border-radius: 12px;
}
.favorite-switch-banner.failed {
background: color-mix(in srgb, var(--danger) 7%, var(--surface-1));
border-color: color-mix(in srgb, var(--danger) 32%, var(--border));
}
.favorite-switch-indicator {
display: grid;
width: 34px;
height: 34px;
flex: 0 0 34px;
place-items: center;
color: var(--accent);
background: color-mix(in srgb, var(--accent) 12%, var(--surface-1));
border-radius: 10px;
}
.favorite-switch-banner.failed .favorite-switch-indicator {
color: var(--danger);
background: color-mix(in srgb, var(--danger) 11%, var(--surface-1));
}
.favorite-switch-copy {
display: flex;
min-width: 0;
flex: 1;
flex-direction: column;
gap: 3px;
}
.favorite-switch-copy strong {
overflow: hidden;
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.favorite-switch-copy small {
color: var(--text-muted);
font-size: 11px;
}
.favorite-switch-banner > button {
min-height: 34px;
padding: 0 11px;
color: var(--text-primary);
background: var(--surface-1);
border: 1px solid var(--border);
border-radius: 8px;
font-size: 11px;
font-weight: 700;
cursor: pointer;
}
@media (max-width: 980px) {
.app-shell[data-favorite-rail="true"] {
grid-template-columns: minmax(0, 1fr);
grid-template-rows: 76px minmax(0, 1fr) minmax(210px, 35dvh);
}
.app-shell[data-favorite-rail="true"] .favorite-server-strip {
grid-column: 1;
grid-row: 1;
}
.app-shell[data-favorite-rail="true"] .workspace {
grid-column: 1;
grid-row: 2;
}
.app-shell[data-favorite-rail="true"] :deep(.member-panel) {
grid-column: 1;
grid-row: 3;
}
.favorite-server-rail {
display: none;
}
.favorite-server-strip {
display: flex;
min-width: 0;
flex: 0 0 auto;
align-items: center;
gap: 8px;
padding: 8px 14px;
overflow-x: auto;
overflow-y: hidden;
background: color-mix(in srgb, var(--surface-1) 94%, transparent);
border-bottom: 1px solid var(--border);
scrollbar-width: none;
}
.favorite-server-strip::-webkit-scrollbar {
display: none;
}
.favorite-server-strip-button {
display: grid;
min-width: 56px;
max-width: 94px;
flex: 0 0 auto;
justify-items: center;
gap: 4px;
padding: 3px 5px;
color: var(--text-muted);
background: transparent;
border: 1px solid transparent;
border-radius: 11px;
cursor: pointer;
}
.favorite-server-strip-button .favorite-server-avatar {
width: 38px;
height: 38px;
flex-basis: 38px;
font-size: 16px;
}
.favorite-server-strip-button > span:last-child {
overflow: hidden;
width: 100%;
font-size: 10px;
text-overflow: ellipsis;
white-space: nowrap;
}
.favorite-server-strip-button.active {
color: var(--accent);
background: color-mix(in srgb, var(--accent) 9%, var(--surface-1));
border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
}
.favorite-server-strip-button:disabled {
cursor: wait;
opacity: .65;
}
.favorite-server-strip-add {
display: grid;
width: 38px;
height: 38px;
flex: 0 0 38px;
place-items: center;
color: var(--text-muted);
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 50%;
cursor: pointer;
}
}
@media (max-width: 740px) {
.favorite-server-strip {
padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px;
gap: 5px;
}
.app-shell[data-favorite-rail="true"] .workspace-header {
min-height: 60px;
padding-top: 0;
}
.app-shell[data-favorite-rail="true"] :deep(.member-panel.mobile-section-visible) {
padding-top: 18px;
}
.favorite-server-strip-button {
min-width: 50px;
}
.favorite-switch-banner {
flex: 0 0 auto;
margin: 7px 10px 0;
padding: 8px;
}
}
+251 -16
View File
@@ -8,15 +8,11 @@
]"
:style="{ '--ws-viewport-height': `${mobileViewport.height}px`, '--ws-viewport-top': `${mobileViewport.top}px` }"
data-ws-part="app"
:data-ws-page="
voiceState.connected || voiceState.reconnecting || voiceState.reconnectFailed
? 'voice'
: 'home'
"
:data-ws-page="showVoiceShell ? 'voice' : 'home'"
>
<!-- Connection / welcome screen -->
<section
v-if="!voiceState.connected && !voiceState.reconnecting && !voiceState.reconnectFailed"
v-if="!showVoiceShell"
class="join-page"
data-ws-part="home"
>
@@ -306,9 +302,104 @@
v-else
:class="['app-shell', `mobile-view-${mobileSection}`]"
:data-performance-open="performancePanelOpen ? 'true' : 'false'"
:data-favorite-rail="accessMode === 'open' ? 'true' : 'false'"
data-ws-part="voice.shell"
@click="memberMenu = null"
>
<aside
v-if="accessMode === 'open'"
class="favorite-server-rail"
data-ws-part="voice.favorite-servers.rail"
:aria-label="t('favoriteServers')"
>
<div class="favorite-server-rail-list" data-ws-part="voice.favorite-servers.rail.list">
<div
v-for="favorite in favoriteServers"
:key="favorite.id"
class="favorite-server-rail-item"
data-ws-part="voice.favorite-servers.rail.item"
>
<button
type="button"
:class="['favorite-server-button', { active: isFavoriteTarget(favorite) }]"
data-ws-part="voice.favorite-servers.server"
:data-ws-state="isFavoriteTarget(favorite) ? 'current' : 'idle'"
:title="favorite.label + '\n' + favorite.address"
:aria-label="t('switchToFavorite', { server: favorite.label })"
:aria-pressed="isFavoriteTarget(favorite)"
:disabled="voiceState.connecting"
@click.stop="connectFavoriteServer(favorite)"
>
<span class="favorite-server-avatar" data-ws-part="voice.favorite-servers.avatar" :style="avatarStyle(favorite.label)">{{ avatarInitial(favorite.label) }}</span>
<span class="favorite-server-tooltip" data-ws-part="voice.favorite-servers.tooltip"><strong>{{ favorite.label }}</strong><small>{{ favorite.address }}</small></span>
</button>
<button
type="button"
class="favorite-server-remove"
data-ws-part="voice.favorite-servers.remove"
:aria-label="t('removeFavoriteForServer', { server: favorite.label })"
:title="t('removeFavorite')"
@click.stop="removeFavoriteFromRail(favorite)"
>
<Icon name="close" :size="12" />
</button>
</div>
</div>
<button
type="button"
class="favorite-server-add"
data-ws-part="voice.favorite-servers.add"
:aria-label="t('addFavoriteServer')"
:title="t('addFavoriteServer')"
@click.stop="favoriteServerDialogOpen = true"
><Icon name="plus" :size="20" /></button>
</aside>
<nav
v-if="accessMode === 'open'"
class="favorite-server-strip"
data-ws-part="voice.favorite-servers.strip"
:aria-label="t('favoriteServers')"
>
<button
v-for="favorite in favoriteServers"
:key="favorite.id"
type="button"
:class="['favorite-server-strip-button', { active: isFavoriteTarget(favorite) }]"
data-ws-part="voice.favorite-servers.strip.server"
:data-ws-state="isFavoriteTarget(favorite) ? 'current' : 'idle'"
:aria-label="t('switchToFavorite', { server: favorite.label })"
:aria-pressed="isFavoriteTarget(favorite)"
:disabled="voiceState.connecting"
@click="connectFavoriteServer(favorite)"
><span class="favorite-server-avatar" data-ws-part="voice.favorite-servers.avatar" :style="avatarStyle(favorite.label)">{{ avatarInitial(favorite.label) }}</span><span>{{ favorite.label }}</span></button>
<button
type="button"
class="favorite-server-strip-add"
data-ws-part="voice.favorite-servers.strip.add"
:aria-label="t('addFavoriteServer')"
:title="t('addFavoriteServer')"
@click="favoriteServerDialogOpen = true"
><Icon name="plus" :size="18" /></button>
</nav>
<div
v-if="isMobileViewport && (favoriteSwitchPending || favoriteSwitchFailed)"
:class="['favorite-switch-banner', 'favorite-switch-mobile-banner', { failed: favoriteSwitchFailed }]"
data-ws-part="voice.favorite-servers.switch-status"
:data-ws-state="favoriteSwitchFailed ? 'failed' : 'connecting'"
role="status"
aria-live="polite"
>
<span class="favorite-switch-indicator"><Icon :name="favoriteSwitchFailed ? 'info' : 'server'" :size="17" /></span>
<span class="favorite-switch-copy">
<strong>{{ favoriteSwitchFailed ? t('favoriteConnectionFailed', { server: favoriteSwitchLabel }) : t('favoriteSwitching', { server: favoriteSwitchLabel }) }}</strong>
<small v-if="favoriteSwitchPending">{{ t('connecting') }}</small>
<small v-else>{{ favoriteSwitchError || t('quickConnectFailed') }}</small>
</span>
<button v-if="favoriteSwitchFailed" type="button" @click="leaveVoiceWorkspace">{{ t('back') }}</button>
</div>
<main
class="workspace"
data-ws-part="voice.workspace"
@@ -344,6 +435,16 @@
name="share"
:size="18"
/></button>
<button
v-if="accessMode === 'open'"
:class="['header-action', 'favorite-current-toggle', { active: isFavorite }]"
data-ws-part="voice.favorite-servers.current-toggle"
:data-ws-state="isFavorite ? 'saved' : 'unsaved'"
:title="t(isFavorite ? 'removeFavorite' : 'saveFavorite')"
:aria-label="t(isFavorite ? 'removeFavorite' : 'saveFavorite')"
:aria-pressed="isFavorite"
@click="toggleFavorite"
><Icon name="star" :size="18" /></button>
<button
v-if="isMobileViewport"
class="header-action microphone-header-toggle"
@@ -382,7 +483,7 @@
<button
class="disconnect-button"
:aria-label="t('exit')"
@click="doDisconnect"
@click="leaveVoiceWorkspace"
><Icon
name="door"
:size="17"
@@ -391,6 +492,23 @@
</div>
</header>
<div
v-if="!isMobileViewport && (favoriteSwitchPending || favoriteSwitchFailed)"
:class="['favorite-switch-banner', { failed: favoriteSwitchFailed }]"
data-ws-part="voice.favorite-servers.switch-status"
:data-ws-state="favoriteSwitchFailed ? 'failed' : 'connecting'"
role="status"
aria-live="polite"
>
<span class="favorite-switch-indicator"><Icon :name="favoriteSwitchFailed ? 'info' : 'server'" :size="17" /></span>
<span class="favorite-switch-copy">
<strong>{{ favoriteSwitchFailed ? t('favoriteConnectionFailed', { server: favoriteSwitchLabel }) : t('favoriteSwitching', { server: favoriteSwitchLabel }) }}</strong>
<small v-if="favoriteSwitchPending">{{ t('connecting') }}</small>
<small v-else>{{ favoriteSwitchError || t('quickConnectFailed') }}</small>
</span>
<button v-if="favoriteSwitchFailed" type="button" @click="leaveVoiceWorkspace">{{ t('back') }}</button>
</div>
<ScreenShareSettingsDialog
v-if="screenShareSettingsOpen"
:model="screenShareControls"
@@ -423,7 +541,7 @@
><button
type="button"
class="text-button"
@click="doDisconnect"
@click="leaveVoiceWorkspace"
>{{ t("back") }}</button
></div
>
@@ -551,7 +669,7 @@
@click="toggleOutputMute"
><Icon :name="outputMuted ? 'volume-off' : 'volume'" :size="18" /><span>{{ t("speaker") }}</span></button
>
<button type="button" class="mobile-voice-leave" :aria-label="t('exit')" :title="t('exit')" @click="doDisconnect"><Icon name="door" :size="17" /></button
<button type="button" class="mobile-voice-leave" :aria-label="t('exit')" :title="t('exit')" @click="leaveVoiceWorkspace"><Icon name="door" :size="17" /></button
>
</div>
</section>
@@ -589,7 +707,7 @@
<div v-if="isMobileViewport" class="mobile-member-controls" role="toolbar" :aria-label="t('desktopAudioControls')">
<button type="button" class="mobile-voice-toggle" :class="{ muted: microphoneMuted }" :aria-label="t('microphone')" :title="microphoneMuted ? t('microphoneMuted') : t('microphoneActive')" :aria-pressed="!microphoneMuted" @click="toggleMicrophone"><Icon :name="microphoneMuted ? 'mic-off' : 'mic'" :size="20" /><span>{{ t('microphone') }}</span></button>
<button type="button" class="mobile-voice-toggle" :class="{ muted: outputMuted }" :aria-label="t('speaker')" :title="outputMuted ? t('outputMuted') : t('speaker')" :aria-pressed="!outputMuted" @click="toggleOutputMute"><Icon :name="outputMuted ? 'volume-off' : 'volume'" :size="20" /><span>{{ t('speaker') }}</span></button>
<button type="button" class="mobile-member-leave" :aria-label="t('exit')" :title="t('exit')" @click="doDisconnect"><Icon name="door" :size="18" /></button>
<button type="button" class="mobile-member-leave" :aria-label="t('exit')" :title="t('exit')" @click="leaveVoiceWorkspace"><Icon name="door" :size="18" /></button>
</div>
<AudioDock
v-if="!isMobileViewport"
@@ -647,7 +765,7 @@
<button
type="button"
class="danger"
@click="doDisconnect"
@click="leaveVoiceWorkspace"
><Icon
name="door"
:size="18"
@@ -732,10 +850,19 @@
v-model="serverPasswordDialog.password"
:error-code="serverPasswordDialog.errorCode"
:t="t"
@cancel="cancelServerPassword"
@cancel="cancelFavoriteServerPassword"
@submit="submitServerPassword"
/>
<FavoriteServerDialog
:open="favoriteServerDialogOpen"
:busy="favoriteDialogBusy"
:default-nickname="nickname"
:t="t"
@close="favoriteServerDialogOpen = false"
@submit="submitFavoriteServerDraft"
/>
<!-- Audio settings modal -->
<AudioSettingsDialog
v-if="settingsOpen"
@@ -782,6 +909,7 @@ import JoinForm from "../components/web-client/JoinForm.vue";
import ChatPanel from "../components/web-client/ChatPanel.vue";
import WebClientHeader from "../components/web-client/WebClientHeader.vue";
import IdentityImportDialog from "../components/web-client/IdentityImportDialog.vue";
import FavoriteServerDialog, { type FavoriteServerDraft } from "../components/web-client/FavoriteServerDialog.vue";
import { usePublicSkin } from "../composables/usePublicSkin.js";
import { useWebClientIdentity } from "../composables/useWebClientIdentity.js";
import LanguageSwitcher from "../components/LanguageSwitcher.vue";
@@ -798,14 +926,14 @@ import { useWebClientI18n } from "../composables/useWebClientI18n.js";
import { useWebClientPublicConfig } from "../composables/useWebClientPublicConfig.js";
import { useWebClientServerHistory } from "../composables/useWebClientServerHistory.js";
import { getInitialLanguage, type Language } from "../i18n/web-client.js";
import { clearLocalData as clearStoredLocalData, isLocalPersistenceAvailable, loadLocalPreferences, loadStoredIdentity, removeStoredIdentity, saveLocalPreferences, saveStoredIdentity } from "../services/local-persistence.js";
import { clearLocalData as clearStoredLocalData, isLocalPersistenceAvailable, loadLocalPreferences, loadStoredIdentity, removeStoredIdentity, saveLocalPreferences, saveStoredIdentity, type FavoriteServer } from "../services/local-persistence.js";
import type { InstalledSkin, SkinHomeCopy } from "../services/skin-pack.js";
import { isPublicSkinEnabled } from "../services/skin-catalog.js";
import { BUILTIN_DARK_SKIN, BUILTIN_LIGHT_SKIN } from "../services/skin-runtime.js";
import { applyTheme, getStoredTheme, type ThemeMode } from "../services/theme.js";
import { createScreenWakeLockController, getScreenWakeLockApi, type ScreenWakeLockController, type ScreenWakeLockSnapshot } from "../services/screen-wake-lock.js";
import { createMobileAwayController, type MobileAwayController } from "../services/mobile-away.js";
import { combineTeamSpeakTarget, DEFAULT_TEAM_SPEAK_PORT, splitTeamSpeakTarget } from "../services/teamspeak-target.js";
import { combineTeamSpeakTarget, DEFAULT_TEAM_SPEAK_PORT, isValidTeamSpeakPort, splitTeamSpeakTarget } from "../services/teamspeak-target.js";
const {
state: voiceState,
@@ -892,7 +1020,7 @@ const { panelOpen: performancePanelOpen } = performance;
const query = new URLSearchParams(location.search);
const initialChannel = query.get("channel") ?? "";
const inviteToken = query.get("invite") ?? "";
const inviteToken = ref(query.get("invite") ?? "");
const initialTarget = initialServerTarget();
const nickname = ref(localStorage.getItem("webspeak:nickname") ?? "");
const channel = ref(initialChannel);
@@ -905,6 +1033,11 @@ const browserError = ref("");
const memberQuery = ref("");
const selectedChannelId = ref("");
const settingsOpen = ref(false);
const favoriteServerDialogOpen = ref(false);
const favoriteDialogBusy = ref(false);
const favoriteSwitchPending = ref(false);
const favoriteSwitchFailed = ref(false);
const favoriteSwitchError = ref("");
const channelPasswordDialog = reactive({ open: false, channelId: "", password: "", error: "", submitting: false });
const serverPasswordDialog = reactive({ open: false, password: "", errorCode: "" });
const qqModalOpen = ref(false);
@@ -946,6 +1079,8 @@ const {
loadSavedServers,
recordCurrentServer,
selectLocalServer,
saveFavoriteServer,
removeFavoriteServer,
toggleFavorite,
clearServerHistory,
} = useWebClientServerHistory({ serverHost, serverPort, nickname, channel, rememberIdentity, identityMaterial, t, showToast });
@@ -1192,6 +1327,99 @@ const {
showToast,
t,
});
const showVoiceShell = computed(() => Boolean(
voiceState.connected || voiceState.reconnecting || voiceState.reconnectFailed
|| favoriteSwitchPending.value || favoriteSwitchFailed.value,
));
const favoriteSwitchLabel = computed(() => favoriteServers.value.find((favorite) =>
favorite.id === currentServerTarget().toLocaleLowerCase(),
)?.label ?? currentServerTarget());
function isFavoriteTarget(favorite: FavoriteServer): boolean {
return favorite.id === currentServerTarget().toLocaleLowerCase();
}
function connectFavoriteServer(favorite: FavoriteServer): void {
if (accessMode.value !== "open" || voiceState.connecting || (voiceState.connected && isFavoriteTarget(favorite))) return;
const target = splitTeamSpeakTarget(favorite.address);
serverHost.value = target.address;
serverPort.value = target.port || DEFAULT_TEAM_SPEAK_PORT;
nickname.value = favorite.nickname?.trim() || nickname.value.trim();
channel.value = favorite.lastChannelHint?.name ?? "";
serverPassword.value = "";
accelerationRelayId.value = "";
inviteToken.value = "";
selectedChannelId.value = "";
serverPasswordDialog.open = false;
serverPasswordDialog.password = "";
serverPasswordDialog.errorCode = "";
favoriteServerDialogOpen.value = false;
beginFavoriteConnection();
}
function beginFavoriteConnection(): void {
favoriteSwitchPending.value = true;
favoriteSwitchFailed.value = false;
favoriteSwitchError.value = "";
doConnect();
if (!voiceState.connecting && !voiceState.connected) failFavoriteConnection(t("quickConnectFailed"));
}
function failFavoriteConnection(message: string): void {
favoriteSwitchPending.value = false;
favoriteSwitchFailed.value = true;
favoriteSwitchError.value = message;
}
function cancelFavoriteServerPassword(): void {
cancelServerPassword();
if (favoriteSwitchPending.value) failFavoriteConnection(t("quickConnectFailed"));
}
function leaveVoiceWorkspace(): void {
favoriteSwitchPending.value = false;
favoriteSwitchFailed.value = false;
favoriteSwitchError.value = "";
doDisconnect();
}
function removeFavoriteFromRail(favorite: FavoriteServer): void {
void removeFavoriteServer(favorite.id).then(() => showToast(t("removedFavoriteToast")));
}
async function submitFavoriteServerDraft(draft: FavoriteServerDraft): Promise<void> {
if (favoriteDialogBusy.value || voiceState.connecting || accessMode.value !== "open") return;
const port = draft.port || DEFAULT_TEAM_SPEAK_PORT;
if (!draft.address || !draft.nickname || !isValidTeamSpeakPort(port)) {
showToast(t("quickConnectFailed"));
return;
}
const parsed = splitTeamSpeakTarget(draft.address, port);
serverHost.value = parsed.address;
serverPort.value = parsed.port || DEFAULT_TEAM_SPEAK_PORT;
nickname.value = draft.nickname;
channel.value = draft.channel;
serverPassword.value = "";
accelerationRelayId.value = "";
inviteToken.value = "";
selectedChannelId.value = "";
serverPasswordDialog.open = false;
serverPasswordDialog.password = "";
serverPasswordDialog.errorCode = "";
favoriteDialogBusy.value = true;
try {
const target = currentServerTarget();
await saveFavoriteServer(target, draft.label || target, nickname.value, channel.value);
favoriteServerDialogOpen.value = false;
beginFavoriteConnection();
} finally {
favoriteDialogBusy.value = false;
}
}
const visiblePokes = computed(() => pokeNotifications.slice(-3));
watch(() => pokeNotifications.length, (length, previousLength) => {
@@ -1214,10 +1442,17 @@ watch([rememberIdentity, identityMaterial], ([remember, material]) => {
});
watch(() => voiceState.connected, (connected) => {
if (!connected) return;
favoriteSwitchPending.value = false;
favoriteSwitchFailed.value = false;
favoriteSwitchError.value = "";
playNotification("connected");
recordCurrentServer();
});
watch(() => voiceState.connected || voiceState.reconnecting || voiceState.reconnectFailed, (roomVisible) => {
watch(() => voiceState.errorCode, (code) => {
if (!favoriteSwitchPending.value || !code || code === "SERVER_PASSWORD_REQUIRED" || code === "INVALID_SERVER_PASSWORD") return;
failFavoriteConnection(localizedMessage(voiceState.error) || t("quickConnectFailed"));
});
watch(() => showVoiceShell.value, (roomVisible) => {
if (roomVisible) resetIdentityOperations();
}, { flush: "sync" });