✨ Channel manage
This commit is contained in:
parent
012a02751c
commit
73b1e376a3
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-menu eager :close-on-content-click="false">
|
<v-menu eager :close-on-content-click="false">
|
||||||
<template #activator="{ props }">
|
<template #activator="{ props }">
|
||||||
<v-btn v-bind="props" stacked rounded="circle" size="small" variant="text" :loading="loading">
|
<v-btn v-bind="props" icon rounded="circle" size="small" variant="text" :loading="loading">
|
||||||
<v-badge v-if="pagination.total > 0" color="error" :content="pagination.total">
|
<v-badge v-if="pagination.total > 0" color="error" :content="pagination.total">
|
||||||
<v-icon icon="mdi-bell" />
|
<v-icon icon="mdi-bell" />
|
||||||
</v-badge>
|
</v-badge>
|
||||||
|
36
src/components/chat/channels/ChannelAction.vue
Normal file
36
src/components/chat/channels/ChannelAction.vue
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<template>
|
||||||
|
<v-menu>
|
||||||
|
<template #activator="{ props }">
|
||||||
|
<v-btn v-bind="props" icon="mdi-cog" variant="text" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<v-list density="compact" lines="one">
|
||||||
|
<v-list-item disabled append-icon="mdi-flag" title="Report" />
|
||||||
|
<v-list-item v-if="isOwned" append-icon="mdi-pencil" title="Edit" @click="editChannel" />
|
||||||
|
<v-list-item v-if="isOwned" append-icon="mdi-delete" title="Delete" @click="deleteChannel" />
|
||||||
|
</v-list>
|
||||||
|
</v-menu>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useUserinfo } from "@/stores/userinfo"
|
||||||
|
import { useChannels } from "@/stores/channels"
|
||||||
|
import { computed } from "vue"
|
||||||
|
|
||||||
|
const id = useUserinfo()
|
||||||
|
const channels = useChannels()
|
||||||
|
|
||||||
|
const props = defineProps<{ item: any }>()
|
||||||
|
|
||||||
|
const isOwned = computed(() => props.item?.account_id === id.userinfo.idSet?.messaging)
|
||||||
|
|
||||||
|
function editChannel() {
|
||||||
|
channels.related.edit_to = props.item
|
||||||
|
channels.show.editor = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteChannel() {
|
||||||
|
channels.related.delete_to = props.item
|
||||||
|
channels.show.delete = true
|
||||||
|
}
|
||||||
|
</script>
|
@ -22,7 +22,7 @@ const realms = useRealms()
|
|||||||
|
|
||||||
const props = defineProps<{ item: any }>()
|
const props = defineProps<{ item: any }>()
|
||||||
|
|
||||||
const isOwned = computed(() => props.item?.account_id === id.userinfo.data.id)
|
const isOwned = computed(() => props.item?.account_id === id.userinfo.idSet?.interactive)
|
||||||
|
|
||||||
function editRealm() {
|
function editRealm() {
|
||||||
realms.related.edit_to = props.item
|
realms.related.edit_to = props.item
|
||||||
|
@ -4,8 +4,13 @@
|
|||||||
<v-app-bar-nav-icon icon="mdi-chat" :loading="loading" />
|
<v-app-bar-nav-icon icon="mdi-chat" :loading="loading" />
|
||||||
|
|
||||||
<h2 class="ml-2 text-lg font-500">{{ channels.current?.name }}</h2>
|
<h2 class="ml-2 text-lg font-500">{{ channels.current?.name }}</h2>
|
||||||
|
|
||||||
<p class="ml-3 text-xs opacity-80">{{ channels.current?.description }}</p>
|
<p class="ml-3 text-xs opacity-80">{{ channels.current?.description }}</p>
|
||||||
|
|
||||||
|
<v-spacer />
|
||||||
|
|
||||||
|
<div v-if="channels.current">
|
||||||
|
<channel-action :item="channels.current" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
|
|
||||||
@ -20,6 +25,7 @@ import { request } from "@/scripts/request"
|
|||||||
import { useRoute } from "vue-router"
|
import { useRoute } from "vue-router"
|
||||||
import { ref, watch } from "vue"
|
import { ref, watch } from "vue"
|
||||||
import { useChannels } from "@/stores/channels"
|
import { useChannels } from "@/stores/channels"
|
||||||
|
import ChannelAction from "@/components/chat/channels/ChannelAction.vue"
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const channels = useChannels()
|
const channels = useChannels()
|
||||||
@ -47,4 +53,13 @@ watch(
|
|||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
watch(() => channels.done, (val) => {
|
||||||
|
if (val) {
|
||||||
|
readMetadata().then(() => {
|
||||||
|
channels.messages = []
|
||||||
|
channels.done = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, { immediate: true })
|
||||||
</script>
|
</script>
|
@ -9,6 +9,7 @@ export interface Userinfo {
|
|||||||
isReady: boolean
|
isReady: boolean
|
||||||
isLoggedIn: boolean
|
isLoggedIn: boolean
|
||||||
displayName: string
|
displayName: string
|
||||||
|
idSet: { [id: string]: number }
|
||||||
data: any
|
data: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ const defaultUserinfo: Userinfo = {
|
|||||||
isReady: false,
|
isReady: false,
|
||||||
isLoggedIn: false,
|
isLoggedIn: false,
|
||||||
displayName: "Citizen",
|
displayName: "Citizen",
|
||||||
|
idSet: {},
|
||||||
data: null
|
data: null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,17 +49,29 @@ export const useUserinfo = defineStore("userinfo", () => {
|
|||||||
const res = await request("identity", "/api/users/me", {
|
const res = await request("identity", "/api/users/me", {
|
||||||
headers: { Authorization: `Bearer ${await getAtk()}` }
|
headers: { Authorization: `Bearer ${await getAtk()}` }
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
|
|
||||||
|
const federationResp = await Promise.all([
|
||||||
|
request("interactive", "/api/users/me", {
|
||||||
|
headers: { Authorization: `Bearer ${await getAtk()}` }
|
||||||
|
}),
|
||||||
|
request("messaging", "/api/users/me", {
|
||||||
|
headers: { Authorization: `Bearer ${await getAtk()}` }
|
||||||
|
})
|
||||||
|
])
|
||||||
|
|
||||||
userinfo.value = {
|
userinfo.value = {
|
||||||
isReady: true,
|
isReady: true,
|
||||||
isLoggedIn: true,
|
isLoggedIn: true,
|
||||||
displayName: data["nick"],
|
displayName: data["nick"],
|
||||||
|
idSet: {
|
||||||
|
interactive: (await federationResp[0].json())["id"],
|
||||||
|
messaging: (await federationResp[1].json())["id"]
|
||||||
|
},
|
||||||
data: data
|
data: data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +74,13 @@ async function readMore({ done }: any) {
|
|||||||
|
|
||||||
watch(() => channels.current, (val) => {
|
watch(() => channels.current, (val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
|
pagination.page = 1
|
||||||
|
pagination.total = 0
|
||||||
readHistory()
|
readHistory()
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
function scrollTop() {
|
function scrollTop() {
|
||||||
window.scroll({ top: 0 })
|
window.scroll({ top: 0 })
|
||||||
|
@ -105,6 +105,8 @@ watch(
|
|||||||
() => route.params.realmId,
|
() => route.params.realmId,
|
||||||
() => {
|
() => {
|
||||||
posts.value = []
|
posts.value = []
|
||||||
|
pagination.page = 1
|
||||||
|
pagination.total = 0
|
||||||
readMetadata()
|
readMetadata()
|
||||||
readPosts()
|
readPosts()
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user