mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
feat(perm): hide UI a member lacks capability for
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
cf76e0f69a
commit
221f7c8dcf
3 files changed
+36
-10
No files matched your search
@@ -10,8 +10,8 @@
|
||||
</div>
|
||||
|
||||
<div class="nav-right">
|
||||
<!-- Bot selector (always shown when at least one bot exists) -->
|
||||
<div v-if="store.bots.length > 0" class="bot-selector" ref="selectorRef">
|
||||
<!-- Bot selector (always shown when at least one controllable bot exists) -->
|
||||
<div v-if="controllableBots.length > 0" class="bot-selector" ref="selectorRef">
|
||||
<button class="bot-selector-btn" @click="dropdownOpen = !dropdownOpen">
|
||||
<span class="bot-dot" :class="{ online: activeBot?.connected }" />
|
||||
<span class="bot-selector-name">{{ activeBot?.name ?? '选择机器人' }}</span>
|
||||
@@ -22,7 +22,7 @@
|
||||
<div v-if="dropdownOpen" class="bot-dropdown">
|
||||
<div class="bot-dropdown-header">机器人</div>
|
||||
<div
|
||||
v-for="bot in store.bots"
|
||||
v-for="bot in controllableBots"
|
||||
:key="bot.id"
|
||||
class="bot-card"
|
||||
:class="{ active: bot.id === store.activeBotId }"
|
||||
@@ -131,12 +131,17 @@ import { useSession } from '../composables/useSession.js';
|
||||
|
||||
const store = usePlayerStore();
|
||||
const session = useSession();
|
||||
const { canControlBot } = session;
|
||||
const navRouter = useRouter();
|
||||
|
||||
async function onLogout() {
|
||||
await session.logout();
|
||||
navRouter.replace({ name: 'login' });
|
||||
}
|
||||
// Belt-and-suspenders: the backend already scopes store.bots to the allowed
|
||||
// set for members, but filtering here keeps the UI correct if an admin (who
|
||||
// sees all bots) is constrained, or if the list ever isn't pre-filtered.
|
||||
const controllableBots = computed(() => store.bots.filter((b) => canControlBot(b.id)));
|
||||
const activeBot = computed(() => store.activeBot);
|
||||
const dropdownOpen = ref(false);
|
||||
const selectorRef = ref<HTMLElement | null>(null);
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
<Queue :open="showQueue" @close="showQueue = false" />
|
||||
|
||||
<div class="player-bar frosted-glass">
|
||||
<!-- Progress bar -->
|
||||
<!-- Progress bar (read-only display; seek interaction gated on player.control) -->
|
||||
<div
|
||||
class="progress-bar-container"
|
||||
:class="{ 'no-seek': !canControl }"
|
||||
ref="progressBarRef"
|
||||
@click="onProgressClick"
|
||||
@mousemove="onProgressHover"
|
||||
@@ -37,6 +38,8 @@
|
||||
|
||||
<div class="player-center">
|
||||
<span class="time-display time-current">{{ formatTime(currentElapsed) }}</span>
|
||||
<!-- Transport controls require player.control -->
|
||||
<template v-if="canControl">
|
||||
<button class="control-btn" @click="store.prev()">
|
||||
<Icon icon="mdi:skip-previous" />
|
||||
</button>
|
||||
@@ -50,10 +53,13 @@
|
||||
<Icon :icon="modeIcon" />
|
||||
<span class="mode-label">{{ modeLabel }}</span>
|
||||
</button>
|
||||
</template>
|
||||
<span class="time-display time-total">{{ formatTime(currentSong?.duration ?? 0) }}</span>
|
||||
</div>
|
||||
|
||||
<div class="player-right">
|
||||
<!-- Volume requires player.control -->
|
||||
<template v-if="canControl">
|
||||
<Icon icon="mdi:volume-high" class="volume-icon" />
|
||||
<input
|
||||
type="range"
|
||||
@@ -63,6 +69,7 @@
|
||||
@change="onVolumeChange"
|
||||
class="volume-slider"
|
||||
/>
|
||||
</template>
|
||||
<button class="control-btn" :class="{ active: showQueue }" @click="showQueue = !showQueue">
|
||||
<Icon icon="mdi:playlist-music" />
|
||||
</button>
|
||||
@@ -79,6 +86,7 @@ import { computed, ref, onMounted, onUnmounted } from 'vue';
|
||||
import { Icon } from '@iconify/vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { usePlayerStore } from '../stores/player.js';
|
||||
import { useSession } from '../composables/useSession.js';
|
||||
import CoverArt from './CoverArt.vue';
|
||||
import Queue from './Queue.vue';
|
||||
|
||||
@@ -86,6 +94,9 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const showQueue = ref(false);
|
||||
|
||||
const { can } = useSession();
|
||||
const canControl = computed(() => can('player.control'));
|
||||
|
||||
const store = usePlayerStore();
|
||||
const activeBot = computed(() => store.activeBot);
|
||||
const currentSong = computed(() => store.currentSong);
|
||||
@@ -133,6 +144,7 @@ function updateProgress() {
|
||||
}
|
||||
|
||||
async function onProgressClick(e: MouseEvent) {
|
||||
if (!canControl.value) return; // seek requires player.control
|
||||
const bar = progressBarRef.value;
|
||||
if (!bar) return;
|
||||
const rect = bar.getBoundingClientRect();
|
||||
@@ -237,6 +249,14 @@ function cycleMode() {
|
||||
.progress-bar-bg { height: 4px; }
|
||||
.progress-bar-thumb { opacity: 1; transform: scale(1); }
|
||||
}
|
||||
|
||||
&.no-seek {
|
||||
cursor: default;
|
||||
&:hover {
|
||||
.progress-bar-bg { height: 2px; }
|
||||
.progress-bar-thumb { opacity: 0; transform: scale(0); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.progress-bar-bg {
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
<p v-if="ownPwSuccess" class="user-success">{{ ownPwSuccess }}</p>
|
||||
</section>
|
||||
|
||||
<!-- Bot Management -->
|
||||
<section class="settings-section">
|
||||
<!-- Bot Management (create/edit/delete/start-stop) requires bot.manage -->
|
||||
<section v-if="can('bot.manage')" class="settings-section">
|
||||
<h2 class="section-title">机器人管理</h2>
|
||||
<div class="bot-list">
|
||||
<div v-for="bot in store.bots" :key="bot.id" class="bot-item">
|
||||
@@ -157,8 +157,8 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Music Account - QR Code Login -->
|
||||
<section class="settings-section">
|
||||
<!-- Music Account - QR Code Login (platform auth) requires platform.auth -->
|
||||
<section v-if="can('platform.auth')" class="settings-section">
|
||||
<h2 class="section-title">音乐账号</h2>
|
||||
|
||||
<!-- NetEase -->
|
||||
@@ -371,8 +371,8 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Audio Quality -->
|
||||
<section class="settings-section">
|
||||
<!-- Audio Quality requires quality -->
|
||||
<section v-if="can('quality')" class="settings-section">
|
||||
<h2 class="section-title">音质设置</h2>
|
||||
<div class="setting-row">
|
||||
<div class="setting-label">
|
||||
@@ -967,6 +967,7 @@ async function updateProfile(botId: string, key: keyof ProfileConfig, value: boo
|
||||
|
||||
// --- User Management ---
|
||||
const session = useSession();
|
||||
const { can } = session;
|
||||
|
||||
// --- Own password change (available to all authenticated users) ---
|
||||
const ownPw = reactive({ old: '', new: '', confirm: '' });
|
||||
|
||||
Reference in new issue
Block a user