mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 20:12:52 +08:00
fix: scope identity operations to the active dialog
This commit is contained in:
1 parent
db08fbda6b
commit
15e22d3099
9 files changed
+605
-182
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div class="modal-backdrop identity-import-backdrop" @click.self="emit('close')" tabindex="-1">
|
||||
<section ref="dialog" class="identity-import-modal" data-ws-part="home.identity-import-dialog" role="dialog" aria-modal="true" aria-labelledby="identity-import-title" tabindex="-1" @keydown.esc="emit('close')">
|
||||
<header class="identity-import-header" data-ws-part="home.identity-import.header">
|
||||
<div><h2 id="identity-import-title">{{ t('identityImportTitle') }}</h2><p>{{ t('identityImportDescription') }}</p></div>
|
||||
<button type="button" class="qq-modal-close identity-import-close" data-ws-part="home.identity-import.close" :aria-label="t('close')" :disabled="busy" @click="emit('close')"><Icon name="close" :size="18" /></button>
|
||||
</header>
|
||||
<textarea v-model="text" class="identity-import-textarea" data-ws-part="home.identity-import.textarea" :aria-label="t('identityImportTitle')" :placeholder="t('identityImportPlaceholder')" :disabled="busy" maxlength="131072" spellcheck="false"></textarea>
|
||||
<div :class="['identity-drop-zone', { active: dropActive }]" data-ws-part="home.identity-import.drop-zone" role="group" :aria-disabled="busy" :tabindex="busy ? -1 : 0" @click="chooseFile" @keydown.enter.prevent="chooseFile" @keydown.space.prevent="chooseFile" @dragover.prevent="dropActive = !busy" @dragleave.prevent="dropActive = false" @drop.prevent.stop="onDrop">
|
||||
<Icon name="paperclip" :size="18" /><span>{{ t('identityDropZone') }}</span>
|
||||
<button type="button" class="identity-file-button" data-ws-part="home.identity-import.file-button" :disabled="busy" @click.stop="chooseFile">{{ t('identityChooseFile') }}</button>
|
||||
</div>
|
||||
<input ref="fileInput" class="identity-file-input" type="file" accept=".ini,.txt,.identity,.wsi,text/plain" :disabled="busy" @change="onFileChange" />
|
||||
<p v-if="error" class="identity-import-error" data-ws-part="home.identity-import.error" role="alert">{{ error }}</p>
|
||||
<p class="identity-import-security" data-ws-part="home.identity-import.security"><Icon name="lock" :size="14" /> {{ t('identityImportSecurity') }}</p>
|
||||
<footer class="identity-import-footer" data-ws-part="home.identity-import.footer">
|
||||
<button type="button" class="text-button identity-import-cancel" data-ws-part="home.identity-import.cancel" :disabled="busy" @click="emit('close')">{{ t('identityImportCancel') }}</button>
|
||||
<button type="button" class="primary-button identity-import-submit" data-ws-part="home.identity-import.submit" :disabled="busy || reading || !text.trim()" @click="emit('submit')">{{ busy ? t('connecting') : t('identityImportSubmit') }}</button>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from "vue";
|
||||
import Icon from "../Icon.vue";
|
||||
|
||||
const props = defineProps<{ busy: boolean; reading: boolean; error: string; t: (key: string) => string }>();
|
||||
const text = defineModel<string>({ required: true });
|
||||
const emit = defineEmits<{ close: []; submit: []; file: [file: File] }>();
|
||||
const dialog = ref<HTMLElement | null>(null);
|
||||
const fileInput = ref<HTMLInputElement | null>(null);
|
||||
const dropActive = ref(false);
|
||||
let previousFocus: HTMLElement | null = null;
|
||||
|
||||
onMounted(() => {
|
||||
previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
dialog.value?.focus();
|
||||
});
|
||||
onUnmounted(() => { if (previousFocus?.isConnected) previousFocus.focus(); });
|
||||
function chooseFile() { if (!props.busy) fileInput.value?.click(); }
|
||||
function onFileChange(event: Event) {
|
||||
const input = event.currentTarget as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
input.value = "";
|
||||
if (file && !props.busy) emit("file", file);
|
||||
}
|
||||
function onDrop(event: DragEvent) {
|
||||
dropActive.value = false;
|
||||
const file = event.dataTransfer?.files[0];
|
||||
if (file && !props.busy) emit("file", file);
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,159 @@
|
||||
import { onScopeDispose, ref, watch, type Ref } from "vue";
|
||||
import { exportTeamSpeakIdentity, IdentityImportError, importIdentityText } from "../services/identity-import.js";
|
||||
|
||||
interface IdentityOptions {
|
||||
identityMaterial: Ref<string>;
|
||||
rememberIdentity: Ref<boolean>;
|
||||
t: (key: string) => string;
|
||||
showToast: (message: string) => void;
|
||||
parse?: (text: string) => Promise<string>;
|
||||
serialize?: (material: string) => Promise<string>;
|
||||
}
|
||||
|
||||
/** Page-owned identity operations; the dialog only renders state and emits input. */
|
||||
export function useWebClientIdentity({ identityMaterial, rememberIdentity, t, showToast,
|
||||
parse = importIdentityText, serialize = exportTeamSpeakIdentity }: IdentityOptions) {
|
||||
const open = ref(false);
|
||||
const text = ref("");
|
||||
const error = ref("");
|
||||
const busy = ref(false);
|
||||
const reading = ref(false);
|
||||
const exporting = ref(false);
|
||||
let generation = 0;
|
||||
let exportGeneration = 0;
|
||||
let identityRevision = 0;
|
||||
let disposed = false;
|
||||
const downloads = new Map<string, ReturnType<typeof setTimeout> | undefined>();
|
||||
const isCurrent = (operation: number) => !disposed && open.value && operation === generation;
|
||||
|
||||
function invalidate() {
|
||||
generation++;
|
||||
reading.value = false;
|
||||
busy.value = false;
|
||||
}
|
||||
watch(text, () => { invalidate(); error.value = ""; }, { flush: "sync" });
|
||||
watch([identityMaterial, rememberIdentity], () => {
|
||||
identityRevision++;
|
||||
exportGeneration++;
|
||||
exporting.value = false;
|
||||
}, { flush: "sync" });
|
||||
|
||||
function show() {
|
||||
if (disposed || busy.value) return;
|
||||
invalidate();
|
||||
text.value = "";
|
||||
error.value = "";
|
||||
open.value = true;
|
||||
}
|
||||
function close() {
|
||||
if (busy.value) return;
|
||||
invalidate();
|
||||
open.value = false;
|
||||
}
|
||||
function reset() {
|
||||
invalidate();
|
||||
identityRevision++;
|
||||
exportGeneration++;
|
||||
exporting.value = false;
|
||||
open.value = false;
|
||||
text.value = "";
|
||||
error.value = "";
|
||||
for (const url of downloads.keys()) releaseDownload(url);
|
||||
}
|
||||
async function readFile(file?: Pick<File, "size" | "arrayBuffer">) {
|
||||
if (!file || disposed || !open.value || busy.value) return;
|
||||
invalidate();
|
||||
const operation = generation;
|
||||
error.value = "";
|
||||
if (file.size > 128 * 1024) {
|
||||
error.value = t("identityImportErrorTooLarge");
|
||||
return;
|
||||
}
|
||||
reading.value = true;
|
||||
try {
|
||||
const bytes = new Uint8Array(await file.arrayBuffer());
|
||||
if (!isCurrent(operation)) return;
|
||||
let encoding = "utf-8";
|
||||
if (bytes[0] === 0xff && bytes[1] === 0xfe) encoding = "utf-16le";
|
||||
else if (bytes[0] === 0xfe && bytes[1] === 0xff) encoding = "utf-16be";
|
||||
text.value = new TextDecoder(encoding, { fatal: true }).decode(bytes);
|
||||
error.value = text.value.trim() ? "" : t("identityImportErrorEmpty");
|
||||
} catch {
|
||||
if (isCurrent(operation)) error.value = t("identityImportErrorMalformed");
|
||||
} finally {
|
||||
if (isCurrent(operation)) reading.value = false;
|
||||
}
|
||||
}
|
||||
async function submit() {
|
||||
if (disposed || !open.value || busy.value || reading.value) return;
|
||||
invalidate();
|
||||
const operation = generation;
|
||||
busy.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const material = await parse(text.value);
|
||||
if (!isCurrent(operation)) return;
|
||||
invalidate();
|
||||
rememberIdentity.value = true;
|
||||
identityMaterial.value = material;
|
||||
open.value = false;
|
||||
text.value = "";
|
||||
showToast(t("identityImportSuccess"));
|
||||
} catch (failure) {
|
||||
if (!isCurrent(operation)) return;
|
||||
const code = failure instanceof IdentityImportError ? failure.code : "invalid-key";
|
||||
error.value = t(({
|
||||
empty: "identityImportErrorEmpty", "too-large": "identityImportErrorTooLarge",
|
||||
multiple: "identityImportErrorMultiple", malformed: "identityImportErrorMalformed",
|
||||
"invalid-key": "identityImportErrorInvalidKey", unsupported: "identityImportErrorUnsupported",
|
||||
} as const)[code]);
|
||||
} finally { if (isCurrent(operation)) busy.value = false; }
|
||||
}
|
||||
async function exportIdentity() {
|
||||
if (disposed || exporting.value || !rememberIdentity.value || !identityMaterial.value) return;
|
||||
const operation = ++exportGeneration;
|
||||
const current = () => !disposed && operation === exportGeneration;
|
||||
exporting.value = true;
|
||||
let url: string | undefined;
|
||||
let link: HTMLAnchorElement | undefined;
|
||||
try {
|
||||
const content = await serialize(identityMaterial.value);
|
||||
if (!current()) return;
|
||||
url = URL.createObjectURL(new Blob([content], { type: "text/plain;charset=utf-8" }));
|
||||
downloads.set(url, undefined);
|
||||
link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "webspeak-identity.ini";
|
||||
document.body.append(link);
|
||||
link.click();
|
||||
const downloadUrl = url;
|
||||
downloads.set(url, setTimeout(() => releaseDownload(downloadUrl), 1000));
|
||||
showToast(t("identityExportSuccess"));
|
||||
} catch {
|
||||
if (url) releaseDownload(url);
|
||||
if (current()) showToast(t("identityExportError"));
|
||||
} finally {
|
||||
try { link?.remove(); } catch { /* URL cleanup is independent of DOM removal. */ }
|
||||
if (current()) exporting.value = false;
|
||||
}
|
||||
}
|
||||
function releaseDownload(url: string) {
|
||||
if (!downloads.has(url)) return;
|
||||
clearTimeout(downloads.get(url));
|
||||
downloads.delete(url);
|
||||
try { URL.revokeObjectURL(url); } catch { /* Continue releasing other owned URLs. */ }
|
||||
}
|
||||
async function restore(load: () => Promise<string | null>) {
|
||||
if (disposed) return;
|
||||
const revision = ++identityRevision;
|
||||
try {
|
||||
const stored = await load();
|
||||
if (!disposed && revision === identityRevision && stored) {
|
||||
rememberIdentity.value = true;
|
||||
identityMaterial.value = stored;
|
||||
}
|
||||
} catch { /* Optional local storage cannot prevent a new browser session. */ }
|
||||
}
|
||||
onScopeDispose(() => { disposed = true; reset(); });
|
||||
return { open, text, error, busy, reading, exporting, show, close, reset, restore, readFile, submit, exportIdentity };
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { readFile, readdir } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
import { strToU8, zipSync } from "fflate";
|
||||
import { importSkinPack, resolveSkinCssAssets, SkinPackError } from "./skin-pack.js";
|
||||
@@ -78,16 +78,18 @@ test("community skins use a scoped light fallback instead of inheriting the nigh
|
||||
});
|
||||
|
||||
test("all public skin parts are documented and the admin console is outside skin scope", async () => {
|
||||
const [webClient, header, demo, skinSwitcher, languageSwitcher, admin, documentation] = await Promise.all([
|
||||
const componentRoot = new URL("../components/web-client/", import.meta.url);
|
||||
const componentFiles = (await readdir(componentRoot, { recursive: true })).filter(path => path.endsWith(".vue"));
|
||||
const components = (await Promise.all(componentFiles.map(path => readFile(new URL(path.replaceAll("\\", "/"), componentRoot), "utf8")))).join("\n");
|
||||
const [webClient, demo, skinSwitcher, languageSwitcher, admin, documentation] = await Promise.all([
|
||||
readFile(new URL("../views/WebClient.vue", import.meta.url), "utf8"),
|
||||
readFile(new URL("../components/web-client/WebClientHeader.vue", import.meta.url), "utf8"),
|
||||
readFile(new URL("../views/DemoView.vue", import.meta.url), "utf8"),
|
||||
readFile(new URL("../components/SkinSwitcher.vue", import.meta.url), "utf8"),
|
||||
readFile(new URL("../components/LanguageSwitcher.vue", import.meta.url), "utf8"),
|
||||
readFile(new URL("../views/AdminView.vue", import.meta.url), "utf8"),
|
||||
readFile(new URL("../../../docs/SKIN_DEVELOPMENT.md", import.meta.url), "utf8"),
|
||||
]);
|
||||
const publicParts = new Set([...`${webClient}\n${header}\n${demo}\n${skinSwitcher}\n${languageSwitcher}`.matchAll(/data-ws-part="([^"]+)"/g)].map((match) => match[1]));
|
||||
const publicParts = new Set([...`${webClient}\n${components}\n${demo}\n${skinSwitcher}\n${languageSwitcher}`.matchAll(/data-ws-part="([^"]+)"/g)].map((match) => match[1]));
|
||||
for (const part of publicParts) assert.ok(documentation.includes(`\`${part}\``), `Undocumented skin part: ${part}`);
|
||||
assert.match(skinSwitcher, /data-ws-skin-id/);
|
||||
assert.match(skinSwitcher, /data-ws-state/);
|
||||
|
||||
@@ -80,10 +80,10 @@
|
||||
.field-wrap:focus-within { color: #006a64; background: #fff; box-shadow: 0 0 0 2px #81d8d0; }
|
||||
.field-wrap input { width: 100%; min-width: 0; padding: 0; color: #24312f; outline: none; border: 0; background: transparent; font-size: 13px; }
|
||||
.field-wrap input::placeholder { color: #a5b0ad; }
|
||||
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; color: #fff; background: #006a64; border-radius: 9px; font-size: 12px; font-weight: 700; cursor: pointer; transition: transform .18s, box-shadow .18s, background .18s; }
|
||||
.primary-button:hover:not(:disabled) { background: #005650; box-shadow: 0 9px 20px rgba(0, 106, 100, .18); transform: translateY(-1px); }
|
||||
.primary-button:active:not(:disabled) { transform: translateY(0); }
|
||||
.primary-button:disabled { cursor: not-allowed; opacity: .45; }
|
||||
.primary-button, :deep(.identity-import-submit) { display: inline-flex; align-items: center; justify-content: center; gap: 10px; color: #fff; background: #006a64; border-radius: 9px; font-size: 12px; font-weight: 700; cursor: pointer; transition: transform .18s, box-shadow .18s, background .18s; }
|
||||
.primary-button:hover:not(:disabled), :deep(.identity-import-submit:hover:not(:disabled)) { background: #005650; box-shadow: 0 9px 20px rgba(0, 106, 100, .18); transform: translateY(-1px); }
|
||||
.primary-button:active:not(:disabled), :deep(.identity-import-submit:active:not(:disabled)) { transform: translateY(0); }
|
||||
.primary-button:disabled, :deep(.identity-import-submit:disabled) { cursor: not-allowed; opacity: .45; }
|
||||
.connect-button { width: 100%; min-height: 44px; margin-top: 10px; font-size: 13px; }
|
||||
.button-spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
|
||||
.join-meta { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 12px; color: #96a29f; font-size: 10px; }
|
||||
@@ -119,7 +119,7 @@
|
||||
|
||||
.member-panel { min-width: 0; padding: 26px 16px; color: #2c3935; background: #fbfcfc; border-left: 1px solid #eef2f0; }.member-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; }.member-panel-heading h2 { margin: 5px 0 0; color: #25322e; font-size: 19px; letter-spacing: -.04em; }.member-search { margin-top: 18px; padding: 0 10px; min-height: 33px; }.member-group { margin-top: 24px; }.member-group-title { display: flex; align-items: center; gap: 8px; color: #85928e; font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }.group-line { height: 1px; flex: 1; background: #e6edeb; }.member-list { display: flex; flex-direction: column; gap: 17px; margin-top: 17px; }.member-row { display: flex; align-items: center; gap: 8px; min-width: 0; }.member-avatar { position: relative; display: grid; place-items: center; width: 33px; height: 33px; flex: 0 0 auto; color: #fff; border-radius: 10px; font-size: 10px; font-weight: 700; }.member-avatar.speaking { box-shadow: 0 0 0 2px #90f691, 0 0 10px rgba(144,246,145,.35); }.member-presence { position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border: 2px solid #fbfcfc; border-radius: 50%; background: #65d879; }.member-copy { min-width: 0; flex: 1; }.member-copy strong, .member-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.member-copy strong { color: #34423d; font-size: 10px; }.member-copy span { margin-top: 4px; color: #96a29e; font-size: 9px; }.member-volume { display: flex; align-items: center; gap: 5px; color: #a1afaa; width: 64px; }.member-volume input { width: 45px; height: 4px; appearance: none; border-radius: 99px; outline: none; cursor: pointer; }.member-volume input::-webkit-slider-thumb, .settings-range::-webkit-slider-thumb { width: 14px; height: 14px; appearance: none; border: 2px solid #81d8d0; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.12); cursor: pointer; }.member-volume input::-moz-range-thumb, .settings-range::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #81d8d0; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.12); cursor: pointer; }.member-empty { margin-top: 22px; color: #98a49f; font-size: 10px; text-align: center; }.member-panel-tip { display: flex; gap: 8px; margin-top: 36px; padding: 12px; color: #72827c; background: #eef5f2; border-radius: 9px; font-size: 9px; line-height: 1.5; }.member-panel-tip .ui-icon { color: #5e9e96; }
|
||||
|
||||
.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 28px; background: rgba(25, 33, 31, .42); backdrop-filter: blur(5px); }.settings-modal { display: flex; width: min(920px, 100%); max-height: min(760px, calc(100dvh - 56px)); overflow: hidden; border-radius: 16px; background: #fff; box-shadow: 0 20px 60px rgba(16,40,35,.2); }.settings-nav { display: flex; flex-direction: column; width: 215px; flex: 0 0 auto; padding: 28px 12px 20px; background: #f8faf9; border-right: 1px solid #e6ecea; }.settings-title { padding: 0 13px 20px; color: #25322e; font-size: 19px; font-weight: 700; }.settings-nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 13px; color: #65736f; background: transparent; border-left: 3px solid transparent; border-radius: 8px; font-size: 11px; text-align: left; cursor: pointer; }.settings-nav-item.active { color: #006a64; background: #e2efec; border-left-color: #006a64; font-weight: 700; }.settings-version { margin-top: auto; padding: 20px 13px 0; color: #98a5a0; border-top: 1px solid #e4ebe8; font-size: 10px; line-height: 1.7; }.settings-version span { color: #b0bbb7; }.settings-main { display: flex; min-width: 0; flex: 1; flex-direction: column; }.settings-header { display: flex; align-items: center; justify-content: space-between; min-height: 75px; padding: 0 28px; border-bottom: 1px solid #edf1ef; }.settings-header h2 { margin: 0; color: #202c29; font-size: 22px; letter-spacing: -.045em; }.settings-content { flex: 1; overflow-y: auto; padding: 28px 40px; }.settings-section { max-width: 620px; margin: 0 auto; }.settings-section h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 21px; color: #293631; font-size: 16px; }.settings-section h3 .ui-icon { color: #006a64; }.settings-label { display: block; margin-bottom: 8px; color: #5e6d67; font-size: 10px; font-weight: 500; }.select-like { display: flex; align-items: center; justify-content: space-between; min-height: 39px; margin-bottom: 19px; padding: 0 13px; color: #394742; background: #f4f7f6; border-radius: 8px; font-size: 11px; }.select-like .ui-icon { color: #677671; }.settings-range-row { display: flex; align-items: center; justify-content: space-between; }.settings-range-row .settings-label { margin: 0; }.settings-range-row strong { color: #006a64; font-size: 10px; }.settings-range { width: 100%; height: 6px; margin: 11px 0 20px; appearance: none; border-radius: 999px; outline: none; cursor: pointer; }.settings-range::-webkit-slider-thumb { width: 19px; height: 19px; }.settings-range::-moz-range-thumb { width: 19px; height: 19px; }.mic-test { padding: 15px; border: 1px solid #e5ece9; border-radius: 11px; background: #fafcfb; }.mic-test-header { display: flex; align-items: center; justify-content: space-between; }.mic-test-header strong { color: #36453f; font-size: 11px; }.mic-test-header button { padding: 6px 9px; color: #006a64; background: #e0f1ee; border-radius: 5px; font-size: 10px; cursor: pointer; }.meter { display: flex; align-items: flex-end; justify-content: space-between; gap: 4px; height: 39px; margin-top: 12px; padding: 0 4px 4px; border-bottom: 1px solid #dce6e2; }.meter i { width: 5px; min-height: 4px; border-radius: 3px 3px 0 0; background: #dfe6e3; }.meter i.active { background: #81ed8b; box-shadow: 0 0 7px rgba(129,237,139,.45); animation: meter 1s ease-in-out infinite alternate; }.meter-labels { display: flex; justify-content: space-between; margin-top: 6px; color: #9ba6a2; font-size: 8px; }.settings-separator { max-width: 620px; margin: 32px auto; border-top: 1px solid #edf1ef; }.mode-note { display: flex; align-items: flex-start; gap: 8px; padding: 12px; color: #66817a; background: #eef7f4; border-radius: 8px; font-size: 10px; line-height: 1.5; }.mode-note .ui-icon { color: #4f9c91; }.settings-footer { display: flex; justify-content: flex-end; gap: 16px; min-height: 67px; padding: 15px 28px; border-top: 1px solid #edf1ef; }.text-button { padding: 0 6px; color: #63716c; background: transparent; font-size: 11px; font-weight: 600; cursor: pointer; }.save-button { padding: 0 23px; }.qq-modal-card { position: relative; width: min(460px, 100%); max-height: min(90dvh, 720px); overflow-y: auto; padding: 30px; color: #263431; border: 1px solid #d9e7e3; border-radius: 20px; background: #fff; box-shadow: 0 20px 60px rgba(16,40,35,.22); text-align: center; }.qq-modal-heading { padding: 0 24px 18px; }.qq-modal-heading h2 { margin: 8px 0 0; color: #1d2d29; font-size: 25px; letter-spacing: -.04em; }.qq-modal-close { position: absolute; top: 13px; right: 13px; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: #6d7d78; background: #f1f6f4; border: 1px solid #e1ebe8; border-radius: 50%; cursor: pointer; }.qq-modal-close:hover { color: #006a64; background: #e2f2ef; border-color: #c8e6e1; }.qq-qr-image { display: block; width: min(100%, 360px); max-height: min(55vh, 520px); margin: 0 auto; object-fit: contain; border-radius: 1Line truncated
|
||||
.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 28px; background: rgba(25, 33, 31, .42); backdrop-filter: blur(5px); }.settings-modal { display: flex; width: min(920px, 100%); max-height: min(760px, calc(100dvh - 56px)); overflow: hidden; border-radius: 16px; background: #fff; box-shadow: 0 20px 60px rgba(16,40,35,.2); }.settings-nav { display: flex; flex-direction: column; width: 215px; flex: 0 0 auto; padding: 28px 12px 20px; background: #f8faf9; border-right: 1px solid #e6ecea; }.settings-title { padding: 0 13px 20px; color: #25322e; font-size: 19px; font-weight: 700; }.settings-nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 13px; color: #65736f; background: transparent; border-left: 3px solid transparent; border-radius: 8px; font-size: 11px; text-align: left; cursor: pointer; }.settings-nav-item.active { color: #006a64; background: #e2efec; border-left-color: #006a64; font-weight: 700; }.settings-version { margin-top: auto; padding: 20px 13px 0; color: #98a5a0; border-top: 1px solid #e4ebe8; font-size: 10px; line-height: 1.7; }.settings-version span { color: #b0bbb7; }.settings-main { display: flex; min-width: 0; flex: 1; flex-direction: column; }.settings-header { display: flex; align-items: center; justify-content: space-between; min-height: 75px; padding: 0 28px; border-bottom: 1px solid #edf1ef; }.settings-header h2 { margin: 0; color: #202c29; font-size: 22px; letter-spacing: -.045em; }.settings-content { flex: 1; overflow-y: auto; padding: 28px 40px; }.settings-section { max-width: 620px; margin: 0 auto; }.settings-section h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 21px; color: #293631; font-size: 16px; }.settings-section h3 .ui-icon { color: #006a64; }.settings-label { display: block; margin-bottom: 8px; color: #5e6d67; font-size: 10px; font-weight: 500; }.select-like { display: flex; align-items: center; justify-content: space-between; min-height: 39px; margin-bottom: 19px; padding: 0 13px; color: #394742; background: #f4f7f6; border-radius: 8px; font-size: 11px; }.select-like .ui-icon { color: #677671; }.settings-range-row { display: flex; align-items: center; justify-content: space-between; }.settings-range-row .settings-label { margin: 0; }.settings-range-row strong { color: #006a64; font-size: 10px; }.settings-range { width: 100%; height: 6px; margin: 11px 0 20px; appearance: none; border-radius: 999px; outline: none; cursor: pointer; }.settings-range::-webkit-slider-thumb { width: 19px; height: 19px; }.settings-range::-moz-range-thumb { width: 19px; height: 19px; }.mic-test { padding: 15px; border: 1px solid #e5ece9; border-radius: 11px; background: #fafcfb; }.mic-test-header { display: flex; align-items: center; justify-content: space-between; }.mic-test-header strong { color: #36453f; font-size: 11px; }.mic-test-header button { padding: 6px 9px; color: #006a64; background: #e0f1ee; border-radius: 5px; font-size: 10px; cursor: pointer; }.meter { display: flex; align-items: flex-end; justify-content: space-between; gap: 4px; height: 39px; margin-top: 12px; padding: 0 4px 4px; border-bottom: 1px solid #dce6e2; }.meter i { width: 5px; min-height: 4px; border-radius: 3px 3px 0 0; background: #dfe6e3; }.meter i.active { background: #81ed8b; box-shadow: 0 0 7px rgba(129,237,139,.45); animation: meter 1s ease-in-out infinite alternate; }.meter-labels { display: flex; justify-content: space-between; margin-top: 6px; color: #9ba6a2; font-size: 8px; }.settings-separator { max-width: 620px; margin: 32px auto; border-top: 1px solid #edf1ef; }.mode-note { display: flex; align-items: flex-start; gap: 8px; padding: 12px; color: #66817a; background: #eef7f4; border-radius: 8px; font-size: 10px; line-height: 1.5; }.mode-note .ui-icon { color: #4f9c91; }.settings-footer { display: flex; justify-content: flex-end; gap: 16px; min-height: 67px; padding: 15px 28px; border-top: 1px solid #edf1ef; }.text-button, :deep(.identity-import-cancel) { padding: 0 6px; color: #63716c; background: transparent; font-size: 11px; font-weight: 600; cursor: pointer; }.save-button { padding: 0 23px; }.qq-modal-card { position: relative; width: min(460px, 100%); max-height: min(90dvh, 720px); overflow-y: auto; padding: 30px; color: #263431; border: 1px solid #d9e7e3; border-radius: 20px; background: #fff; box-shadow: 0 20px 60px rgba(16,40,35,.22); text-align: center; }.qq-modal-heading { padding: 0 24px 18px; }.qq-modal-heading h2 { margin: 8px 0 0; color: #1d2d29; font-size: 25px; letter-spacing: -.04em; }.qq-modal-close, :deep(.identity-import-close) { position: absolute; top: 13px; right: 13px; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: #6d7d78; background: #f1f6f4; border: 1px solid #e1ebe8; border-radius: 50%; cursor: pointer; }.qq-modal-close:hover, :deep(.identity-import-close:hover) { color: #006a64; background: #e2f2ef; border-color: #c8e6e1; }.qq-qr-image { display: block; width: mLine truncated
|
||||
|
||||
.channel-password-modal { position: relative; width: min(420px, 100%); padding: 31px 32px 28px; color: #263431; border: 1px solid #d9e7e3; border-radius: 18px; background: #fff; box-shadow: 0 20px 60px rgba(16,40,35,.22); }
|
||||
.channel-password-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 17px; color: #006a64; background: #e4f4f0; border-radius: 14px; }
|
||||
@@ -248,26 +248,26 @@
|
||||
.identity-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.identity-controls .remember-identity { min-width: 0; flex: 1; }
|
||||
.identity-actions { display: flex; flex: 0 0 auto; gap: 7px; }
|
||||
.identity-action-button, .identity-file-button { min-height: 31px; padding: 0 10px; color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface-1)); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border)); border-radius: 8px; font: inherit; font-size: 10px; font-weight: 700; cursor: pointer; }
|
||||
.identity-action-button:hover, .identity-file-button:hover { background: color-mix(in srgb, var(--accent) 16%, var(--surface-1)); }
|
||||
.identity-action-button, :deep(.identity-file-button) { min-height: 31px; padding: 0 10px; color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface-1)); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border)); border-radius: 8px; font: inherit; font-size: 10px; font-weight: 700; cursor: pointer; }
|
||||
.identity-action-button:hover, :deep(.identity-file-button:hover) { background: color-mix(in srgb, var(--accent) 16%, var(--surface-1)); }
|
||||
.identity-action-button:disabled { cursor: not-allowed; opacity: .48; }
|
||||
.identity-import-backdrop { z-index: 50; }
|
||||
.identity-import-modal { display: flex; width: min(620px, 100%); max-height: min(720px, calc(100dvh - 56px)); flex-direction: column; gap: 15px; overflow-y: auto; padding: 25px; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 20px 60px color-mix(in srgb, var(--text-primary) 22%, transparent); }
|
||||
.identity-import-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-right: 35px; }
|
||||
.identity-import-header h2 { margin: 0; color: var(--text-primary); font-size: 20px; letter-spacing: -.035em; }
|
||||
.identity-import-header p { margin: 7px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
|
||||
.identity-import-textarea { display: block; width: 100%; min-height: 190px; resize: vertical; padding: 12px; color: var(--text-primary); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; outline: none; font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
|
||||
.identity-import-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 17%, transparent); }
|
||||
.identity-drop-zone { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; min-height: 58px; padding: 10px 14px; color: var(--text-muted); background: color-mix(in srgb, var(--accent) 5%, var(--surface-1)); border: 1px dashed color-mix(in srgb, var(--accent) 48%, var(--border)); border-radius: 10px; font-size: 11px; cursor: pointer; transition: background .16s, border-color .16s; }
|
||||
.identity-drop-zone > .ui-icon { color: var(--accent); }
|
||||
.identity-drop-zone.active, .identity-drop-zone:hover { background: color-mix(in srgb, var(--accent) 12%, var(--surface-1)); border-color: var(--accent); }
|
||||
.identity-file-input { display: none; }
|
||||
.identity-import-error { margin: -5px 0 0; color: var(--danger); font-size: 11px; line-height: 1.45; }
|
||||
.identity-import-security { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 11px 12px; color: var(--text-muted); background: color-mix(in srgb, var(--warning) 10%, var(--surface-1)); border-radius: 9px; font-size: 10px; line-height: 1.5; }
|
||||
.identity-import-security .ui-icon { flex: 0 0 auto; color: var(--warning); }
|
||||
.identity-import-footer { display: flex; align-items: center; justify-content: flex-end; gap: 15px; }
|
||||
.identity-import-submit { min-height: 39px; padding: 0 16px; }
|
||||
.identity-import-submit:disabled { cursor: not-allowed; opacity: .52; }
|
||||
:deep(.identity-import-backdrop) { z-index: 50; }
|
||||
:deep(.identity-import-modal) { position: relative; display: flex; width: min(620px, 100%); max-height: min(720px, calc(100dvh - 56px)); flex-direction: column; gap: 15px; overflow-y: auto; padding: 25px; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 20px 60px color-mix(in srgb, var(--text-primary) 22%, transparent); }
|
||||
:deep(.identity-import-header) { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-right: 35px; }
|
||||
:deep(.identity-import-header h2) { margin: 0; color: var(--text-primary); font-size: 20px; letter-spacing: -.035em; }
|
||||
:deep(.identity-import-header p) { margin: 7px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
|
||||
:deep(.identity-import-textarea) { display: block; width: 100%; min-height: 190px; resize: vertical; padding: 12px; color: var(--text-primary); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; outline: none; font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
|
||||
:deep(.identity-import-textarea:focus) { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 17%, transparent); }
|
||||
:deep(.identity-drop-zone) { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; min-height: 58px; padding: 10px 14px; color: var(--text-muted); background: color-mix(in srgb, var(--accent) 5%, var(--surface-1)); border: 1px dashed color-mix(in srgb, var(--accent) 48%, var(--border)); border-radius: 10px; font-size: 11px; cursor: pointer; transition: background .16s, border-color .16s; }
|
||||
:deep(.identity-drop-zone > .ui-icon) { color: var(--accent); }
|
||||
:deep(.identity-drop-zone.active), :deep(.identity-drop-zone:hover) { background: color-mix(in srgb, var(--accent) 12%, var(--surface-1)); border-color: var(--accent); }
|
||||
:deep(.identity-file-input) { display: none; }
|
||||
:deep(.identity-import-error) { margin: -5px 0 0; color: var(--danger); font-size: 11px; line-height: 1.45; }
|
||||
:deep(.identity-import-security) { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 11px 12px; color: var(--text-muted); background: color-mix(in srgb, var(--warning) 10%, var(--surface-1)); border-radius: 9px; font-size: 10px; line-height: 1.5; }
|
||||
:deep(.identity-import-security .ui-icon) { flex: 0 0 auto; color: var(--warning); }
|
||||
:deep(.identity-import-footer) { display: flex; align-items: center; justify-content: flex-end; gap: 15px; }
|
||||
:deep(.identity-import-submit) { min-height: 39px; padding: 0 16px; }
|
||||
:deep(.identity-import-submit:disabled) { cursor: not-allowed; opacity: .52; }
|
||||
.local-servers { display: grid; gap: 8px; margin: 1px 0 5px; }
|
||||
.local-server-group { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
|
||||
.local-server-group > span { width: 100%; color: #87958f; font-size: 10px; font-weight: 700; }
|
||||
@@ -330,7 +330,7 @@
|
||||
.join-page .notice { font-size: 15px; }
|
||||
.join-page .field-label { font-size: 13.75px; }
|
||||
.join-page .field-wrap input { font-size: 16.25px; }
|
||||
.join-page .primary-button { font-size: 15px; }
|
||||
.join-page .primary-button, .join-page :deep(.identity-import-submit) { font-size: 15px; }
|
||||
.join-page .connect-button { font-size: 16.25px; }
|
||||
.join-page .join-meta, .join-page .join-footer { font-size: 12.5px; }
|
||||
|
||||
@@ -844,7 +844,9 @@
|
||||
.web-client.language-en .join-page .field-wrap input,
|
||||
.web-client.language-de .join-page .field-wrap input { font-size: 14.3px; }
|
||||
.web-client.language-en .join-page .primary-button,
|
||||
.web-client.language-de .join-page .primary-button { font-size: 13.2px; }
|
||||
.web-client.language-de .join-page .primary-button,
|
||||
.web-client.language-en .join-page :deep(.identity-import-submit),
|
||||
.web-client.language-de .join-page :deep(.identity-import-submit) { font-size: 13.2px; }
|
||||
.web-client.language-en .join-page .connect-button,
|
||||
.web-client.language-de .join-page .connect-button { font-size: 14.3px; }
|
||||
.web-client.language-en .join-page .join-meta,
|
||||
@@ -1272,19 +1274,19 @@
|
||||
}
|
||||
|
||||
@media (max-width: 740px) {
|
||||
.identity-import-backdrop { align-items: flex-end; padding: 0; }
|
||||
.identity-import-modal { width: 100%; max-height: calc(100svh - env(safe-area-inset-top, 0px)); padding: 24px 19px calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 22px 22px 0 0; }
|
||||
.identity-import-textarea { min-height: 24svh; }
|
||||
.identity-drop-zone { justify-content: flex-start; }
|
||||
.identity-import-footer .identity-import-submit { min-height: 46px; }
|
||||
:deep(.identity-import-backdrop) { align-items: flex-end; padding: 0; }
|
||||
:deep(.identity-import-modal) { width: 100%; max-height: calc(100svh - env(safe-area-inset-top, 0px)); padding: 24px 19px calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 22px 22px 0 0; }
|
||||
:deep(.identity-import-textarea) { min-height: 24svh; }
|
||||
:deep(.identity-drop-zone) { justify-content: flex-start; }
|
||||
:deep(.identity-import-footer .identity-import-submit) { min-height: 46px; }
|
||||
}
|
||||
|
||||
@media (max-width: 420px) {
|
||||
.identity-controls { align-items: flex-start; flex-direction: column; gap: 8px; }
|
||||
.identity-actions { width: 100%; }
|
||||
.identity-action-button { flex: 1; }
|
||||
.identity-import-header { padding-right: 27px; }
|
||||
.identity-import-header h2 { font-size: 18px; }
|
||||
:deep(.identity-import-header) { padding-right: 27px; }
|
||||
:deep(.identity-import-header h2) { font-size: 18px; }
|
||||
}
|
||||
|
||||
/* Give the brand and actions their own rows before they can overlap. */
|
||||
|
||||
+20
-121
@@ -76,7 +76,7 @@
|
||||
<input id="channel" v-model="channel" :placeholder="t('emptyDefault')" @keyup.enter="doConnect" />
|
||||
</div>
|
||||
|
||||
<details class="identity-options" data-ws-part="home.identity"><summary>{{ t('identityOptions') }}</summary><div class="identity-controls"><label class="remember-identity"><input v-model="rememberIdentity" type="checkbox" /><span><strong>{{ t('rememberIdentity') }}</strong><small>{{ t('rememberIdentityHint') }}</small></span></label><div class="identity-actions" data-ws-part="home.identity-actions"><button type="button" class="identity-action-button" data-ws-part="home.identity-import.open" @click="openIdentityImport">{{ t('identityImport') }}</button><button type="button" class="identity-action-button" data-ws-part="home.identity-export.button" :disabled="!rememberIdentity || !identityMaterial" @click="exportIdentity">{{ t('identityExport') }}</button></div></div></details><p v-if="rememberIdentity" class="identity-warning">{{ t('rememberIdentityConcurrentWarning') }}</p>
|
||||
<details class="identity-options" data-ws-part="home.identity"><summary>{{ t('identityOptions') }}</summary><div class="identity-controls"><label class="remember-identity"><input v-model="rememberIdentity" type="checkbox" /><span><strong>{{ t('rememberIdentity') }}</strong><small>{{ t('rememberIdentityHint') }}</small></span></label><div class="identity-actions" data-ws-part="home.identity-actions"><button type="button" class="identity-action-button" data-ws-part="home.identity-import.open" @click="openIdentityImport">{{ t('identityImport') }}</button><button type="button" class="identity-action-button" data-ws-part="home.identity-export.button" :disabled="identityExportBusy || !rememberIdentity || !identityMaterial" @click="exportIdentity">{{ t('identityExport') }}</button></div></div></details><p v-if="rememberIdentity" class="identity-warning">{{ t('rememberIdentityConcurrentWarning') }}</p>
|
||||
|
||||
<button class="primary-button connect-button" data-ws-part="home.connect" :disabled="!canJoin || serverConfigLoading || !identityReady || voiceState.connecting" type="submit">
|
||||
<span v-if="voiceState.connecting" class="button-spinner"></span>
|
||||
@@ -89,19 +89,9 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div v-if="identityImportOpen" class="modal-backdrop identity-import-backdrop" @click.self="closeIdentityImport" tabindex="-1">
|
||||
<section ref="identityImportModal" class="identity-import-modal" data-ws-part="home.identity-import-dialog" role="dialog" aria-modal="true" aria-labelledby="identity-import-title" tabindex="-1" @keydown.esc="closeIdentityImport">
|
||||
<header class="identity-import-header" data-ws-part="home.identity-import.header"><div><h2 id="identity-import-title">{{ t('identityImportTitle') }}</h2><p>{{ t('identityImportDescription') }}</p></div><button type="button" class="qq-modal-close" data-ws-part="home.identity-import.close" :aria-label="t('close')" @click="closeIdentityImport"><Icon name="close" :size="18" /></button></header>
|
||||
<textarea v-model="identityImportText" class="identity-import-textarea" data-ws-part="home.identity-import.textarea" :placeholder="t('identityImportPlaceholder')" maxlength="131072" spellcheck="false"></textarea>
|
||||
<div :class="['identity-drop-zone', { active: identityDropActive }]" data-ws-part="home.identity-import.drop-zone" role="group" tabindex="0" @click="chooseIdentityFile" @keydown.enter.prevent="chooseIdentityFile" @keydown.space.prevent="chooseIdentityFile" @dragover.prevent="identityDropActive = true" @dragleave.prevent="identityDropActive = false" @drop.prevent.stop="onIdentityFileDrop">
|
||||
<Icon name="paperclip" :size="18" /><span>{{ t('identityDropZone') }}</span><button type="button" class="identity-file-button" data-ws-part="home.identity-import.file-button" @click.stop="chooseIdentityFile">{{ t('identityChooseFile') }}</button>
|
||||
</div>
|
||||
<input ref="identityFileInput" class="identity-file-input" type="file" accept=".ini,.txt,.identity,.wsi,text/plain" @change="onIdentityFileChange" />
|
||||
<p v-if="identityImportError" class="identity-import-error" data-ws-part="home.identity-import.error" role="alert">{{ identityImportError }}</p>
|
||||
<p class="identity-import-security" data-ws-part="home.identity-import.security"><Icon name="lock" :size="14" /> {{ t('identityImportSecurity') }}</p>
|
||||
<footer class="identity-import-footer" data-ws-part="home.identity-import.footer"><button type="button" class="text-button" data-ws-part="home.identity-import.cancel" @click="closeIdentityImport">{{ t('identityImportCancel') }}</button><button type="button" class="primary-button identity-import-submit" data-ws-part="home.identity-import.submit" :disabled="identityImportBusy || !identityImportText.trim()" @click="importIdentity">{{ identityImportBusy ? t('connecting') : t('identityImportSubmit') }}</button></footer>
|
||||
</section>
|
||||
</div>
|
||||
<IdentityImportDialog v-if="identityImportOpen" v-model="identityImportText"
|
||||
:busy="identityImportBusy" :reading="identityFileReading" :error="identityImportError" :t="t"
|
||||
@close="closeIdentityImport" @submit="importIdentity" @file="readIdentityFile" />
|
||||
|
||||
<footer class="join-footer" data-ws-part="home.footer">
|
||||
<span>WebSpeak</span><span class="footer-separator">·</span><span>{{ t('teamSpeakClient') }}</span><span class="footer-spacer"></span><button type="button" class="clear-local-button" @click="clearBrowserData">{{ t('clearLocalData') }}</button><span class="footer-separator">·</span><span>{{ t('browserSupport') }}</span>
|
||||
@@ -395,9 +385,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, shallowRef, watch } from "vue";
|
||||
import { computed, onMounted, onUnmounted, reactive, ref, shallowRef, watch } from "vue";
|
||||
import Icon from "../components/Icon.vue";
|
||||
import WebClientHeader from "../components/web-client/WebClientHeader.vue";
|
||||
import IdentityImportDialog from "../components/web-client/IdentityImportDialog.vue";
|
||||
import { useWebClientIdentity } from "../composables/useWebClientIdentity.js";
|
||||
import LanguageSwitcher from "../components/LanguageSwitcher.vue";
|
||||
import SkinSwitcher, { type SkinOption } from "../components/SkinSwitcher.vue";
|
||||
import { useWebClientChat } from "../composables/useWebClientChat.js";
|
||||
@@ -412,7 +404,6 @@ 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 { exportTeamSpeakIdentity, IdentityImportError, importIdentityText } from "../services/identity-import.js";
|
||||
import { clearLocalData as clearStoredLocalData, isLocalPersistenceAvailable, listInstalledSkins, loadLocalPreferences, loadStoredIdentity, removeStoredIdentity, saveLocalPreferences, saveStoredIdentity } from "../services/local-persistence.js";
|
||||
import type { InstalledSkin, SkinHomeCopy } from "../services/skin-pack.js";
|
||||
import { getPublicDefaultSkinId, isPublicSkinEnabled, listPublicSkins, type SkinCatalogEntry } from "../services/skin-catalog.js";
|
||||
@@ -528,13 +519,6 @@ const serverHost = ref(initialTarget.address);
|
||||
const serverPort = ref(initialTarget.port);
|
||||
const serverPassword = ref("");
|
||||
const rememberIdentity = ref(localStorage.getItem("webspeak:remember-identity") !== "0");
|
||||
const identityImportOpen = ref(false);
|
||||
const identityImportText = ref("");
|
||||
const identityImportError = ref("");
|
||||
const identityImportBusy = ref(false);
|
||||
const identityDropActive = ref(false);
|
||||
const identityFileInput = ref<HTMLInputElement | null>(null);
|
||||
const identityImportModal = ref<HTMLElement | null>(null);
|
||||
const accelerationRelayId = ref("");
|
||||
const browserError = ref("");
|
||||
const memberQuery = ref("");
|
||||
@@ -562,6 +546,12 @@ function t(key: string, variables: Record<string, string | number> = {}) {
|
||||
if (template === undefined || !template.trim()) return translate(key, variables);
|
||||
return Object.entries(variables).reduce((value, [name, replacement]) => value.replaceAll(`{{${name}}}`, String(replacement)), template);
|
||||
}
|
||||
const {
|
||||
open: identityImportOpen, text: identityImportText, error: identityImportError,
|
||||
busy: identityImportBusy, reading: identityFileReading, exporting: identityExportBusy,
|
||||
show: openIdentityImport, close: closeIdentityImport, reset: resetIdentityOperations, restore: restoreIdentity,
|
||||
readFile: readIdentityFile, submit: importIdentity, exportIdentity,
|
||||
} = useWebClientIdentity({ identityMaterial, rememberIdentity, t, showToast });
|
||||
const {
|
||||
favoriteServers,
|
||||
recentServers,
|
||||
@@ -972,6 +962,9 @@ watch(() => voiceState.connected, (connected) => {
|
||||
playNotification("connected");
|
||||
recordCurrentServer();
|
||||
});
|
||||
watch(() => voiceState.connected || voiceState.reconnecting || voiceState.reconnectFailed, (roomVisible) => {
|
||||
if (roomVisible) resetIdentityOperations();
|
||||
}, { flush: "sync" });
|
||||
|
||||
watch(() => voiceState.reconnecting, (reconnecting, wasReconnecting) => {
|
||||
if (reconnecting && !wasReconnecting) {
|
||||
@@ -995,11 +988,9 @@ onMounted(() => {
|
||||
void loadLocalPreferences().then((preferences) => {
|
||||
if (!localStorage.getItem("webspeak:language") && (preferences.language === "zh" || preferences.language === "en" || preferences.language === "de" || preferences.language === "ru" || preferences.language === "ja")) language.value = preferences.language;
|
||||
});
|
||||
void loadStoredIdentity().then((stored) => {
|
||||
if (stored && localStorage.getItem("webspeak:remember-identity") === "1") {
|
||||
identityMaterial.value = stored.privateMaterial;
|
||||
rememberIdentity.value = true;
|
||||
}
|
||||
void restoreIdentity(async () => {
|
||||
const stored = await loadStoredIdentity();
|
||||
return stored && localStorage.getItem("webspeak:remember-identity") === "1" ? stored.privateMaterial : null;
|
||||
}).finally(() => {
|
||||
identityReady.value = true;
|
||||
});
|
||||
@@ -1038,101 +1029,9 @@ function doShare() {
|
||||
navigator.clipboard?.writeText(invite.toString()).then(() => showToast(t("copiedToast")), () => showToast(t("copyFailedToast")));
|
||||
}
|
||||
|
||||
function openIdentityImport(): void {
|
||||
identityImportText.value = "";
|
||||
identityImportError.value = "";
|
||||
identityImportOpen.value = true;
|
||||
void nextTick(() => identityImportModal.value?.focus());
|
||||
}
|
||||
|
||||
function closeIdentityImport(): void {
|
||||
if (identityImportBusy.value) return;
|
||||
identityImportOpen.value = false;
|
||||
identityDropActive.value = false;
|
||||
}
|
||||
|
||||
function chooseIdentityFile(): void {
|
||||
identityFileInput.value?.click();
|
||||
}
|
||||
|
||||
function onIdentityFileChange(event: Event): void {
|
||||
const input = event.currentTarget as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
input.value = "";
|
||||
void readIdentityFile(file);
|
||||
}
|
||||
|
||||
function onIdentityFileDrop(event: DragEvent): void {
|
||||
identityDropActive.value = false;
|
||||
void readIdentityFile(event.dataTransfer?.files[0]);
|
||||
}
|
||||
|
||||
async function readIdentityFile(file?: File): Promise<void> {
|
||||
if (!file) return;
|
||||
if (file.size > 128 * 1024) {
|
||||
identityImportError.value = t("identityImportErrorTooLarge");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const bytes = new Uint8Array(await file.arrayBuffer());
|
||||
let encoding = "utf-8";
|
||||
if (bytes[0] === 0xff && bytes[1] === 0xfe) encoding = "utf-16le";
|
||||
else if (bytes[0] === 0xfe && bytes[1] === 0xff) encoding = "utf-16be";
|
||||
identityImportText.value = new TextDecoder(encoding, { fatal: true }).decode(bytes);
|
||||
identityImportError.value = identityImportText.value.trim() ? "" : t("identityImportErrorEmpty");
|
||||
} catch {
|
||||
identityImportError.value = t("identityImportErrorMalformed");
|
||||
}
|
||||
}
|
||||
|
||||
async function importIdentity(): Promise<void> {
|
||||
if (identityImportBusy.value) return;
|
||||
identityImportBusy.value = true;
|
||||
identityImportError.value = "";
|
||||
try {
|
||||
const material = await importIdentityText(identityImportText.value);
|
||||
// Imported identity material is only used if remembered identities are enabled.
|
||||
rememberIdentity.value = true;
|
||||
identityMaterial.value = material;
|
||||
identityImportOpen.value = false;
|
||||
identityImportText.value = "";
|
||||
showToast(t("identityImportSuccess"));
|
||||
} catch (error) {
|
||||
const code = error instanceof IdentityImportError ? error.code : "invalid-key";
|
||||
const errorKey = ({
|
||||
empty: "identityImportErrorEmpty",
|
||||
"too-large": "identityImportErrorTooLarge",
|
||||
multiple: "identityImportErrorMultiple",
|
||||
malformed: "identityImportErrorMalformed",
|
||||
"invalid-key": "identityImportErrorInvalidKey",
|
||||
unsupported: "identityImportErrorUnsupported",
|
||||
} as const)[code];
|
||||
identityImportError.value = t(errorKey);
|
||||
} finally {
|
||||
identityImportBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function exportIdentity(): Promise<void> {
|
||||
if (!rememberIdentity.value || !identityMaterial.value) return;
|
||||
try {
|
||||
const content = await exportTeamSpeakIdentity(identityMaterial.value);
|
||||
const url = URL.createObjectURL(new Blob([content], { type: "text/plain;charset=utf-8" }));
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "webspeak-identity.ini";
|
||||
document.body.append(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||||
showToast(t("identityExportSuccess"));
|
||||
} catch {
|
||||
showToast(t("identityExportError"));
|
||||
}
|
||||
}
|
||||
|
||||
async function clearBrowserData(): Promise<void> {
|
||||
if (!window.confirm(t("clearLocalDataConfirm"))) return;
|
||||
resetIdentityOperations();
|
||||
await clearStoredLocalData();
|
||||
for (const key of ["webspeak:nickname", "webspeak:language", "webspeak:theme", "webspeak:active-skin", "webspeak:skin-choice", "webspeak:input-device", "webspeak:output-device", "webspeak:remember-identity"]) localStorage.removeItem(key);
|
||||
clearCustomSkinStyle();
|
||||
|
||||
Reference in new issue
Block a user