mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
feat(channels): render TeamSpeak spacers across skins
This commit is contained in:
1 parent
4bff2133b6
commit
b9fccb8757
21 files changed
+240
-17
No files matched your search
@@ -60,16 +60,19 @@
|
||||
<button
|
||||
class="member-channel-heading"
|
||||
data-ws-part="voice.channel-group.heading"
|
||||
:data-spacer="getChannelSpacer(channelItem) ? 'true' : undefined"
|
||||
:data-ws-state="channelItem.id === currentChannelId ? 'current' : 'idle'"
|
||||
:title="t('switchChannel')"
|
||||
@click="emit('selectChannel', channelItem)"
|
||||
>
|
||||
<Icon
|
||||
v-if="!getChannelSpacer(channelItem)"
|
||||
:name="channelItem.passwordProtected ? 'lock' : 'speaker'"
|
||||
:size="16"
|
||||
/>
|
||||
<span>{{ channelItem.name }}</span>
|
||||
<small>{{ channelItem.members.length }}</small>
|
||||
<ChannelSpacer v-if="getChannelSpacer(channelItem)" :spacer="getChannelSpacer(channelItem)!" />
|
||||
<span v-else>{{ channelItem.name }}</span>
|
||||
<small v-if="!getChannelSpacer(channelItem)">{{ channelItem.members.length }}</small>
|
||||
</button>
|
||||
<div
|
||||
v-if="channelItem.members.length"
|
||||
@@ -170,7 +173,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
v-else-if="!getChannelSpacer(channelItem)"
|
||||
class="channel-no-members"
|
||||
>{{ t("noMembersInChannel") }}</div
|
||||
>
|
||||
@@ -188,6 +191,8 @@
|
||||
<script setup lang="ts">
|
||||
import type { CSSProperties } from "vue";
|
||||
import Icon from "../Icon.vue";
|
||||
import ChannelSpacer from "./ChannelSpacer.vue";
|
||||
import { getChannelSpacer } from "../../../../src/shared/channel-spacer.js";
|
||||
import { memberPresenceKey } from "../../services/member-presence.js";
|
||||
import type { TreeChannel } from "../../composables/useWebClientChannels.js";
|
||||
import type { useWebClientMembers } from "../../composables/useWebClientMembers.js";
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<span
|
||||
class="ws-channel-spacer"
|
||||
data-ws-part="voice.channel-spacer"
|
||||
:data-alignment="spacer.alignment"
|
||||
:data-spacer-style="spacer.style"
|
||||
:aria-label="spacer.text || undefined"
|
||||
><span :aria-hidden="spacer.alignment === 'repeat' || spacer.style !== 'text' ? 'true' : undefined">{{ displayText }}</span></span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import type { ChannelSpacer } from "../../../../src/shared/channel-spacer.js";
|
||||
|
||||
const props = defineProps<{ spacer: ChannelSpacer }>();
|
||||
const displayText = computed(() => {
|
||||
if (props.spacer.style !== "text") return "";
|
||||
const text = props.spacer.text;
|
||||
// Clip a bounded run in CSS rather than measuring DOM or growing with viewport width.
|
||||
return props.spacer.alignment === "repeat" && text
|
||||
? text.repeat(Math.max(1, Math.floor(1024 / text.length)))
|
||||
: text;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.ws-channel-spacer {
|
||||
display: block;
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
min-height: 1.3em;
|
||||
overflow: hidden;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
line-height: 1.3;
|
||||
text-align: left;
|
||||
}
|
||||
.ws-channel-spacer > span { white-space: pre; }
|
||||
.ws-channel-spacer[data-alignment="center"] { text-align: center; }
|
||||
.ws-channel-spacer[data-alignment="right"] { text-align: right; }
|
||||
.ws-channel-spacer:where(:not([data-spacer-style="text"]))::before {
|
||||
content: "";
|
||||
display: block;
|
||||
margin-block: .6em;
|
||||
border-top: 1px solid currentColor;
|
||||
opacity: .55;
|
||||
}
|
||||
.ws-channel-spacer[data-spacer-style="dashed"]::before { border-top-style: dashed; }
|
||||
.ws-channel-spacer[data-spacer-style="dotted"]::before { border-top-style: dotted; }
|
||||
.ws-channel-spacer[data-spacer-style="dash-dot"]::before,
|
||||
.ws-channel-spacer[data-spacer-style="dash-dot-dot"]::before {
|
||||
height: 1px;
|
||||
border: 0;
|
||||
background: repeating-linear-gradient(to right, currentColor 0 6px, transparent 6px 9px, currentColor 9px 11px, transparent 11px 14px);
|
||||
}
|
||||
.ws-channel-spacer[data-spacer-style="dash-dot-dot"]::before {
|
||||
background: repeating-linear-gradient(to right, currentColor 0 6px, transparent 6px 9px, currentColor 9px 11px, transparent 11px 14px, currentColor 14px 16px, transparent 16px 19px);
|
||||
}
|
||||
</style>
|
||||
@@ -16,7 +16,7 @@
|
||||
type="button"
|
||||
class="ws-voice-channel-expander"
|
||||
data-ws-part="voice.channel-tree.expander"
|
||||
:aria-label="`${expanded ? '收起' : '展开'} ${node.channel.name} / ${expanded ? 'Collapse' : 'Expand'} channel`"
|
||||
:aria-label="`${expanded ? '收起' : '展开'} ${displayName} / ${expanded ? 'Collapse' : 'Expand'} channel`"
|
||||
:aria-expanded="expanded"
|
||||
@click.stop="emit('toggle', node.channel.id)"
|
||||
><Icon :name="expanded ? 'chevron-down' : 'chevron-right'" :size="13" /></button>
|
||||
@@ -24,8 +24,9 @@
|
||||
type="button"
|
||||
class="ws-voice-channel-row"
|
||||
data-ws-part="voice.channel-tree.row"
|
||||
:data-spacer="spacer ? 'true' : undefined"
|
||||
:data-drag-over="memberDragDrop && dragOverChannelId === node.channel.id ? 'true' : undefined"
|
||||
:title="`双击或按 Enter 加入 ${node.channel.name} / Double-click or press Enter to join${node.channel.passwordProtected ? ' · 需要频道密码 / Channel password required' : ''}`"
|
||||
:title="`双击或按 Enter 加入 ${displayName} / Double-click or press Enter to join${node.channel.passwordProtected ? ' · 需要频道密码 / Channel password required' : ''}`"
|
||||
:data-password-protected="node.channel.passwordProtected ? 'true' : undefined"
|
||||
@click="emit('select', node.channel.id)"
|
||||
@dblclick.stop.prevent="join"
|
||||
@@ -35,15 +36,17 @@
|
||||
@drop="handleChannelDrop($event)"
|
||||
>
|
||||
<Icon
|
||||
v-if="!spacer"
|
||||
class="ws-voice-channel-type"
|
||||
data-ws-part="voice.channel-tree.icon"
|
||||
:name="node.channel.passwordProtected ? 'lock' : 'speaker'"
|
||||
:data-password-protected="node.channel.passwordProtected ? 'true' : 'false'"
|
||||
:size="14"
|
||||
/>
|
||||
<span class="ws-voice-channel-name" data-ws-part="voice.channel-tree.name">{{ node.channel.name }}</span>
|
||||
<span v-if="selected && !current" class="ws-voice-channel-join-hint" data-ws-part="voice.channel-tree.join-hint">双击加入</span>
|
||||
<span class="ws-voice-channel-count" data-ws-part="voice.channel-tree.count">
|
||||
<ChannelSpacer v-if="spacer" :spacer="spacer" />
|
||||
<span v-else class="ws-voice-channel-name" data-ws-part="voice.channel-tree.name">{{ node.channel.name }}</span>
|
||||
<span v-if="!spacer && selected && !current" class="ws-voice-channel-join-hint" data-ws-part="voice.channel-tree.join-hint">双击加入</span>
|
||||
<span v-if="!spacer" class="ws-voice-channel-count" data-ws-part="voice.channel-tree.count">
|
||||
{{ memberCount }}<template v-if="node.channel.maxClientsLimited && typeof node.channel.maxClients === 'number'">/{{ node.channel.maxClients }}</template>
|
||||
</span>
|
||||
</button>
|
||||
@@ -230,6 +233,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, type CSSProperties } from "vue";
|
||||
import Icon from "../Icon.vue";
|
||||
import ChannelSpacer from "./ChannelSpacer.vue";
|
||||
import { channelDisplayName, getChannelSpacer } from "../../../../src/shared/channel-spacer.js";
|
||||
import type { ChannelMember } from "../../composables/useVoiceWebSocket.js";
|
||||
import type { TreeChannel } from "../../composables/useWebClientChannels.js";
|
||||
import type { VoiceChannelTreeNode } from "../../services/voice-channel-tree.js";
|
||||
@@ -267,6 +272,8 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const expanded = computed(() => props.expandedIds.has(props.node.channel.id));
|
||||
const spacer = computed(() => getChannelSpacer(props.node.channel));
|
||||
const displayName = computed(() => channelDisplayName(props.node.channel));
|
||||
const hasChildren = computed(() => props.node.children.length > 0);
|
||||
const hasContents = computed(() => hasChildren.value || props.node.channel.members.length > 0);
|
||||
const isExpandable = computed(() => props.layout === "server-sidebar" ? hasChildren.value : hasContents.value);
|
||||
|
||||
Reference in new issue
Block a user