feat(skin): expose visitor count widget for skins

This commit is contained in:
illusia committed 2026-10-14 00:43:43 +08:00
1 parent 26c638c2a2
commit 42a0755ad0
14 files changed
+256 -159

No files matched your search

@@ -0,0 +1,35 @@
<script setup lang="ts">
import Icon from "../Icon.vue";
defineProps<{
currentLabel: string;
totalLabel?: string;
}>();
</script>
<template>
<div
class="visitor-count"
data-ws-part="home.visitors"
role="status"
aria-live="polite"
>
<span class="visitor-count-orbit" data-ws-part="home.visitors.orbit" aria-hidden="true"></span>
<span class="visitor-count-icon" data-ws-part="home.visitors.icon">
<Icon name="users" :size="15" />
</span>
<span class="visitor-count-label" data-ws-part="home.visitors.label">{{ currentLabel }}</span>
<span
v-if="totalLabel"
class="visitor-count-divider"
data-ws-part="home.visitors.divider"
aria-hidden="true"
></span>
<span
v-if="totalLabel"
class="visitor-count-total"
data-ws-part="home.visitors.total"
>{{ totalLabel }}</span>
<span class="visitor-count-spark" data-ws-part="home.visitors.spark" aria-hidden="true">✦</span>
</div>
</template>
+1 -1
View File
@@ -46,7 +46,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
id: BUILTIN_KAAK_SKIN_ID,
name: "KAAK",
version: "3.1.108",
version: "3.1.115",
author: "WebSpeak Project",
license: "AGPL-3.0-only",
description: "A KOOK-inspired WebSpeak skin with a split-screen connection home, searchable server header, TeamSpeak banner, nested channel members, unified chat with local history, and a compact audio dock.",
+19 -2
View File
@@ -486,7 +486,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
const skin = await importSkinPack(file);
assert.equal(skin.id, "community.kaak-voice");
assert.equal(skin.version, "3.1.108");
assert.equal(skin.version, "3.1.115");
assert.equal(BUILTIN_SKIN_CATALOG.find((entry) => entry.id === skin.id)?.version, skin.version);
assert.equal(skin.schemaVersion, 3);
const home = skin.pluginData?.components.find((component) => component.page === "home");
@@ -496,6 +496,11 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
["kaak-workspace", "surface"],
]);
assert.ok(home?.permissions.includes("ui.surface.replace"));
assert.match(skin.css, /kaak-home\.home"\]\s*\{[\s\S]*?height: calc\(var\(--ws-viewport-height, 100dvh\) \/ var\(--ui-scale, 1\)\);[\s\S]*?overflow-y: auto;/, "only the explicitly named KAAK home root receives viewport layout styles");
assert.doesNotMatch(skin.css, /\[data-ws-plugin-part="kaak-home"\]\s*\{/, "unlabelled SVG nodes cannot inherit home root sizing rules");
assert.match(skin.css, /kaak-home\.right"\]\s*\{[\s\S]*?padding: 210px 28px 45px;/, "the login card keeps its existing vertical position");
assert.match(skin.css, /kaak-home\.hero"\]\s*\{[\s\S]*?display: grid;[\s\S]*?grid-template-rows: auto auto auto minmax\(0, 1fr\);/, "the announcement and illustration have separate rows within the left panel");
assert.match(skin.css, /kaak-home\.hero-media"\]\s*\{[\s\S]*?position: relative;[\s\S]*?margin: clamp\(16px, 2\.8dvh, 32px\) 6% 5%;/, "the left illustration follows the announcement with a bounded gap");
assert.match(skin.css, /@media \(max-width: 850px\)[\s\S]*?\[data-ws-plugin-part="kaak-home\.hero"\]\s*\{\s*display: none;/, "the narrow connection home hides the green hero and screen illustration");
assert.match(skin.css, /@media \(max-width: 850px\)[\s\S]*?\[data-ws-plugin-part="kaak-home\.welcome-title"\]\s*\{\s*display: none;/, "the narrow connection home shows only the login card");
assert.equal(voice?.stateScope, "session.status.channelId");
@@ -531,9 +536,21 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
}
assert.equal(findPart(home?.root, "home-language")?.widget, "app.language-switcher", "the KAAK connection home has a language switcher in its top corner");
assert.equal(findPart(home?.root, "server-announcement")?.widget, "home.server-announcement", "the KAAK connection home displays the localized administrator announcement");
assert.equal(findPart(home?.root, "visitor-stats")?.widget, "home.visitor-count", "the KAAK home composes the public visitor count widget over the monitor screen");
assert.match(skin.css, /kaak-home\.visitor-stats"\]\s*\{[^}]*position: absolute;[^}]*top: 64%;[^}]*left: 50%;[^}]*max-width: 58%;/, "visitor statistics are contained within the monitor screen by the package");
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home\.hero"\]\s*\{[^}]*overflow: visible;/, "the hero does not clip the announcement as it spans the full home width");
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home\.server-announcement"\][^}]*width: calc\(100% - 40px\);[^}]*margin: 20px 20px 0;/, "the announcement card fills its half-width hero with 20px side margins");
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home\.server-announcement"\] \[data-ws-part="home\.server-announcement\.body"\]\s*\{[^}]*color: #273248;/, "the announcement uses the published semantic text part with a readable color");
const illustration = findPart(home?.root, "illustration");
assert.equal(illustration?.attributes?.viewbox, "0 0 640 480", "the KAAK illustration uses a balanced 4:3 viewBox");
const monitorFrame = illustration?.children?.[5];
const screenBackground = illustration?.children?.[6];
const screenHeader = illustration?.children?.[7];
assert.deepEqual([monitorFrame?.attributes?.x, monitorFrame?.attributes?.y, monitorFrame?.attributes?.width, monitorFrame?.attributes?.height], [120, 110, 400, 288]);
assert.equal(screenBackground?.attributes?.d, "M147 122h346a15 15 0 0 1 15 15v234a15 15 0 0 1-15 15H147a15 15 0 0 1-15-15V137a15 15 0 0 1 15-15Z");
assert.equal(screenHeader?.attributes?.d, "M147 122h346a15 15 0 0 1 15 15v31H132v-31a15 15 0 0 1 15-15Z");
assert.match(skin.css, /kaak-home\.hero"\]\s*\{[^}]*min-width: 0;/, "the illustration column can shrink without overlapping the adjacent home panel");
assert.match(skin.css, /kaak-home\.hero-media"\]\s*\{[^}]*width: auto;[^}]*min-width: 0;[^}]*margin: clamp\(16px, 2\.8dvh, 32px\) 6% 5%;/, "the monitor artwork fits between its left and right margins without clipping");
assert.equal(findPart(home?.root, "home-social-links")?.widget, "home.social-links", "the KAAK connection home exposes icon links beside the language switcher");
assert.equal(findPart(home?.root, "identity-provider")?.widget, "home.identity-provider");
assert.deepEqual(findPart(home?.root, "identity-provider")?.options, { identityProviderId: "myts", identityProviderLabel: "myts" });
@@ -729,7 +746,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.match(skin.css, /\.settings-select:hover:not\(:disabled\) \{\s*border-color: #6cbf00;/);
assert.match(skin.css, /\.microphone-toggle:not\(\.muted\):active,[\s\S]*?background: #60ab00;\s*border-color: #60ab00;/);
assert.doesNotMatch(skin.css, /#58c877/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home"\] \{[^}]*font-family: Arial, "Microsoft YaHei", sans-serif;/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home\.home"\] \{[^}]*font-family: Arial, "Microsoft YaHei", sans-serif;/);
assert.match(skin.css, /\[data-ws-part="home\.identity-provider\.button"\][\s\S]*?clip-path: polygon\(0 0, 100% 0, 100% 100%\);/);
assert.match(skin.css, /\[data-ws-part="home\.identity-provider\.label"\][\s\S]*?color: #fff;[\s\S]*?transform: rotate\(45deg\);/);
assert.match(skin.css, /settings-select-menu[\s\S]*?background: #25262a/);
+9 -13
View File
@@ -351,7 +351,7 @@
font-size: 10px;
}
.visitor-count {
:global(.visitor-count) {
position: relative;
display: inline-flex;
align-items: center;
@@ -367,12 +367,12 @@
border-radius: 999px;
background: linear-gradient(110deg, rgba(225, 250, 245, .94), rgba(244, 255, 252, .78));
box-shadow: 0 10px 24px rgba(0, 106, 100, .1), inset 0 0 0 1px rgba(255, 255, 255, .55);
font-size: 12px;
font-size: 15px;
font-weight: 700;
letter-spacing: .035em;
}
.visitor-count::before {
:global(.visitor-count::before) {
position: absolute;
top: 0;
bottom: 0;
@@ -385,7 +385,7 @@
animation: visitor-shimmer 3.6s 1.5s ease-in-out infinite;
}
.visitor-count-orbit {
:global(.visitor-count-orbit) {
position: absolute;
top: -20px;
right: 12px;
@@ -397,7 +397,7 @@
animation: visitor-orbit 4s ease-in-out infinite;
}
.visitor-count-icon {
:global(.visitor-count-icon) {
position: relative;
z-index: 1;
display: grid;
@@ -411,7 +411,7 @@
box-shadow: 0 0 0 4px rgba(55, 205, 182, .12), 0 0 18px rgba(55, 205, 182, .24);
}
.visitor-count-label {
:global(.visitor-count-label) {
position: relative;
z-index: 1;
min-width: 0;
@@ -420,7 +420,7 @@
white-space: nowrap;
}
.visitor-count-divider {
:global(.visitor-count-divider) {
position: relative;
z-index: 1;
width: 1px;
@@ -430,7 +430,7 @@
opacity: .24;
}
.visitor-count-total {
:global(.visitor-count-total) {
position: relative;
z-index: 1;
min-width: 0;
@@ -443,7 +443,7 @@
opacity: .78;
}
.visitor-count-spark {
:global(.visitor-count-spark) {
position: relative;
z-index: 1;
color: #35bea7;
@@ -3926,10 +3926,6 @@
font-size: 16.25px;
}
.join-page .visitor-count {
font-size: 15px;
}
:deep(.join-page .notice) {
font-size: 15px;
}
+10 -35
View File
@@ -118,41 +118,11 @@
></div
>
</div>
<div
v-if="visitorNumber !== null"
class="visitor-count"
data-ws-part="home.visitors"
role="status"
aria-live="polite"
>
<span
class="visitor-count-orbit"
aria-hidden="true"
></span>
<span class="visitor-count-icon"
><Icon
name="users"
:size="15"
/></span>
<span class="visitor-count-label">{{
t("visitorCount", { count: visitorNumber })
}}</span>
<span
v-if="visitorTotal !== null"
class="visitor-count-divider"
aria-hidden="true"
></span>
<span
v-if="visitorTotal !== null"
class="visitor-count-total"
>{{ t("visitorTotal", { count: visitorTotal }) }}</span
>
<span
class="visitor-count-spark"
aria-hidden="true"
>✦</span
>
</div>
<VisitorCount
v-if="visitorNumber !== null"
:current-label="t('visitorCount', { count: visitorNumber })"
:total-label="visitorTotal === null ? undefined : t('visitorTotal', { count: visitorTotal })"
/>
</div>
<div
@@ -991,6 +961,7 @@ import VoiceChannelTree from "../components/web-client/VoiceChannelTree.vue";
import VoiceServerSwitcher from "../components/web-client/VoiceServerSwitcher.vue";
import VoiceServerHeader from "../components/web-client/VoiceServerHeader.vue";
import VoiceServerBanner from "../components/web-client/VoiceServerBanner.vue";
import VisitorCount from "../components/web-client/VisitorCount.vue";
import ScreenShareSettingsDialog from "../components/web-client/ScreenShareSettingsDialog.vue";
import ScreenSharePlayer from "../components/web-client/ScreenSharePlayer.vue";
import AudioDock from "../components/web-client/AudioDock.vue";
@@ -1786,6 +1757,10 @@ const homeConnectionStatus = computed(() => {
});
const skinPluginWidgets = {
"home.visitor-count": () => visitorNumber.value === null ? null : h(VisitorCount, {
currentLabel: t("visitorCount", { count: visitorNumber.value }),
totalLabel: visitorTotal.value === null ? undefined : t("visitorTotal", { count: visitorTotal.value }),
}),
"home.server-announcement": () => h("section", {
"data-ws-part": "home.server-announcement",
"aria-label": t("serverAnnouncement"),