This commit is contained in:
2026-08-02 12:07:51 +02:00
parent aa486be6e5
commit bb4e17ba2f
15 changed files with 502 additions and 152 deletions
+27 -1
View File
@@ -1,18 +1,24 @@
<script lang="ts" setup>
import {storeToRefs} from 'pinia'
import {useServerStore} from '@/stores/server'
import {useServerStore, type Server} from '@/stores/server'
import {computed, ref, watch} from 'vue'
import {useRoute, useRouter} from 'vue-router'
import ContextMenu from "@/components/ContextMenu.vue";
import UserListDrawer from '@/components/UserListDrawer.vue'
import ServerSettingsDialog from '@/components/server/ServerSettingsDialog.vue'
import {useContextMenu} from '@/composables/useContextMenu'
const serverStore = useServerStore()
const route = useRoute()
const router = useRouter()
const {openContextMenu} = useContextMenu()
const {servers} = storeToRefs(serverStore)
const showUsersDrawer = ref(false)
const showServerSettings = ref(false)
const selectedServerId = ref<string | null>(null)
const selectedServerName = ref('')
const isServerContext = computed(() => Boolean(route.params.serverId))
watch(isServerContext, (isActive) => {
@@ -82,6 +88,18 @@ const getServerColor = (str: string): string => {
return `hsl(${hue}, 60%, 45%)`
}
function onServerContextMenu(event: MouseEvent, server: Server) {
openContextMenu(event, [{
label: 'Gérer le serveur',
icon: 'mdi-cog',
action: () => {
selectedServerId.value = server.id
selectedServerName.value = server.name
showServerSettings.value = true
},
}])
}
</script>
<template>
@@ -125,6 +143,7 @@ const getServerColor = (str: string): string => {
v-for="server in servers"
:key="server.id"
:to="`/server/${server.id}`"
@contextmenu="onServerContextMenu($event, server)"
>
<v-avatar
:style="{ backgroundColor: getServerColor(server.name) }"
@@ -150,6 +169,13 @@ const getServerColor = (str: string): string => {
v-model="showUsersDrawer"
/>
<ServerSettingsDialog
v-if="selectedServerId"
v-model="showServerSettings"
:server-id="selectedServerId"
:server-name="selectedServerName"
/>
<router-view/>
<!-- Menu contextuel global -->
<ContextMenu/>