This commit is contained in:
2026-07-27 09:37:36 +02:00
parent 70c0b649e6
commit 7b33b76b3d
6 changed files with 229 additions and 7 deletions
+2 -1
View File
@@ -1 +1,2 @@
node_modules/
node_modules/
dist/
+28 -2
View File
@@ -1,18 +1,44 @@
<script lang="ts" setup>
import {storeToRefs} from 'pinia'
import {useChannelStore} from '@/stores/channel'
import {ref} from 'vue'
import {useCategoryStore} from '@/stores/category'
import {ref, watch, onMounted} from 'vue'
import {useRoute} from 'vue-router'
const props = defineProps<{
serverId: string
channelId?: string
}>();
const serverId = props.serverId
const route = useRoute()
const channelStore = useChannelStore()
const categoryStore = useCategoryStore()
const {channels} = storeToRefs(channelStore)
const {categories} = storeToRefs(categoryStore)
const loadServerData = async (targetServerId: string) => {
if (!targetServerId) return
channelStore.reset()
categoryStore.reset()
try {
await Promise.all([
channelStore.fetchChannels(targetServerId),
categoryStore.fetchCategories(targetServerId)
])
} catch (error) {
console.error('Failed to load server-scoped channels and categories:', error)
}
}
watch(
() => props.serverId,
async (newServerId) => {
if (newServerId) {
await loadServerData(newServerId)
}
},
{immediate: true}
)
const showDialog = ref(false)
const formData = ref({
+6 -2
View File
@@ -6,9 +6,13 @@ export const useCategoryStore = defineStore("category", {
categories: []
}),
actions: {
async fetchCategories() {
async fetchCategories(serverId?: string) {
let api = useApi();
let response = await api.get("/categories");
let url = "/categories";
if (serverId) {
url += `?server_id=${serverId}`;
}
let response = await api.get(url);
this.categories = await response.json();
},
reset() {
+6 -2
View File
@@ -23,9 +23,13 @@ export const useChannelStore = defineStore('channel', {
error: null as string | null
}),
actions: {
async fetchChannels() {
async fetchChannels(serverId?: string) {
let api = useApi();
let response = await api.get("/channels");
let url = "/channels";
if (serverId) {
url += `?server_id=${serverId}`;
}
let response = await api.get(url);
this.channels = await response.json();
},
async createChannel(payload: {