Basic chat layouts

This commit is contained in:
2024-03-30 21:26:22 +08:00
parent 05e8782557
commit 8bb9816cd0
9 changed files with 199 additions and 13 deletions

37
src/stores/channels.ts Normal file
View File

@@ -0,0 +1,37 @@
import { defineStore } from "pinia"
import { reactive, ref } from "vue"
import { checkLoggedIn, getAtk } from "@/stores/userinfo"
import { request } from "@/scripts/request"
export const useChannels = defineStore("channels", () => {
const done = ref(false)
const show = reactive({
editor: false,
delete: false
})
const related_to = reactive<{ edit_to: any; delete_to: any }>({
edit_to: null,
delete_to: null
})
const available = ref<any[]>([])
const current = ref<any>(null)
const messages = ref<any[]>([])
async function list() {
if (!(await checkLoggedIn())) return
const res = await request("messaging", "/api/channels/me/available", {
headers: { Authorization: `Bearer ${await getAtk()}` }
})
if (res.status !== 200) {
throw new Error(await res.text())
} else {
available.value = await res.json()
}
}
return { done, show, related_to, available, current, messages, list }
})