mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
continue forum coding
This commit is contained in:
@@ -397,7 +397,7 @@ export const useForumStore = defineStore('forum', () => {
|
||||
async function ConfirmApply(owner: number, id: number) {
|
||||
try {
|
||||
isLoading.value = true
|
||||
const data = await QueryGetAPI(FORUM_API_URL + 'manage/confirm-apply', { owner: owner, id: id })
|
||||
const data = await QueryGetAPI(FORUM_API_URL + 'manage/confirm-apply', { forum: owner, id: id })
|
||||
if (data.code == 200) {
|
||||
message?.success('已通过申请')
|
||||
return true
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
NTime,
|
||||
useMessage,
|
||||
} from 'naive-ui'
|
||||
import { h, ref } from 'vue'
|
||||
import { h, onMounted, ref } from 'vue'
|
||||
import { ForumModel, ForumUserLevels, ForumUserModel } from '@/api/models/forum'
|
||||
import { FORUM_API_URL } from '@/data/constants'
|
||||
// @ts-ignore
|
||||
@@ -40,7 +40,7 @@ const message = useMessage()
|
||||
|
||||
const managedForums = ref((await useForum.GetManagedForums()) ?? [])
|
||||
const currentForum = ref((await useForum.GetForumInfo(accountInfo.value.id)) ?? ({} as ForumModel))
|
||||
const selectedForum = ref(accountInfo.value.id)
|
||||
const selectedForum = ref()
|
||||
|
||||
const readedAgreement = ref(false)
|
||||
const showAgreement = ref(false)
|
||||
@@ -106,6 +106,7 @@ async function createForum() {
|
||||
}
|
||||
}
|
||||
async function SwitchForum(owner: number) {
|
||||
selectedForum.value = owner
|
||||
currentForum.value = (await useForum.GetForumInfo(owner)) ?? ({} as ForumModel)
|
||||
}
|
||||
async function refreshForumInfo() {
|
||||
@@ -152,17 +153,32 @@ const memberColumns: DataTableColumns<ForumUserModel> = [
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render(row) {
|
||||
return h(
|
||||
return h(NFlex, {}, () => [
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
text: true,
|
||||
type: 'success',
|
||||
type: 'error',
|
||||
onClick: () => {
|
||||
banUser(row.id)
|
||||
},
|
||||
},
|
||||
{ default: () => '封禁' },
|
||||
),
|
||||
currentForum.value.owner.id == accountInfo.value.id
|
||||
? h(
|
||||
NButton,
|
||||
{
|
||||
text: true,
|
||||
type: 'success',
|
||||
onClick: () => {
|
||||
addAdmin(row.id)
|
||||
},
|
||||
},
|
||||
{ default: () => '设为管理员' },
|
||||
)
|
||||
: null,
|
||||
])
|
||||
},
|
||||
},
|
||||
]
|
||||
@@ -190,8 +206,10 @@ const adminColumns: DataTableColumns<ForumUserModel> = [
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
disabled: () => currentForum.value.owner.id != accountInfo.value.id,
|
||||
render(row) {
|
||||
return h(
|
||||
return currentForum.value.owner.id == accountInfo.value.id
|
||||
? h(
|
||||
NButton,
|
||||
{
|
||||
text: true,
|
||||
@@ -202,18 +220,19 @@ const adminColumns: DataTableColumns<ForumUserModel> = [
|
||||
},
|
||||
{ default: () => ' 取消管理员' },
|
||||
)
|
||||
: null
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
async function addAdmin() {
|
||||
async function addAdmin(id: number) {
|
||||
try {
|
||||
const data = await QueryGetAPI<ForumModel>(FORUM_API_URL + 'manage/add-admin', {
|
||||
forum: currentForum.value.owner.id,
|
||||
id: currentAdminInfo.value?.id,
|
||||
id: id,
|
||||
})
|
||||
if (data.code == 200) {
|
||||
message.success('已添加 ' + currentAdminInfo.value?.name + ' 为管理员')
|
||||
message.success('已设置为管理员')
|
||||
refreshForumInfo()
|
||||
addAdminName.value = ''
|
||||
showAddAdminModal.value = false
|
||||
@@ -244,7 +263,7 @@ async function banUser(id: number) {
|
||||
try {
|
||||
const data = await QueryGetAPI<ForumModel>(FORUM_API_URL + 'manage/ban', {
|
||||
forum: currentForum.value.owner.id,
|
||||
id: currentBanUserInfo.value?.id,
|
||||
id: id,
|
||||
})
|
||||
if (data.code == 200) {
|
||||
message.success('已封禁用户')
|
||||
@@ -283,9 +302,36 @@ async function updateForumSettings() {
|
||||
message.error('修改失败: ' + err)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (currentForum.value.name) {
|
||||
selectedForum.value = currentForum.value.owner.id
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="!currentForum.name && managedForums.length > 0">
|
||||
<NAlert type="info"> 你是某些讨论区的管理员, 可以在下方选择需要管理的讨论区 </NAlert>
|
||||
<br />
|
||||
</template>
|
||||
<NSelect
|
||||
v-model:value="selectedForum"
|
||||
:options="
|
||||
managedForums.map((f) => ({
|
||||
label: (f.owner.id == accountInfo.id ? '[我的] ' : '') + f.name + ` (${f.owner.name})`,
|
||||
value: f.owner.id,
|
||||
}))
|
||||
"
|
||||
@update:value="(v) => SwitchForum(v)"
|
||||
placeholder="选择要管理的粉丝讨论区"
|
||||
:fallback-option="(v) => ({ label: '尚未创建', value: v })"
|
||||
>
|
||||
<template #header>
|
||||
<NButton @click="SwitchForum(accountInfo.id)" size="small" type="primary"> 我的粉丝讨论区 </NButton>
|
||||
</template>
|
||||
</NSelect>
|
||||
<NDivider />
|
||||
<NCard v-if="!currentForum.name" size="small" title="啊哦">
|
||||
<NAlert type="error"> 你尚未创建粉丝讨论区 </NAlert>
|
||||
<NDivider />
|
||||
@@ -310,23 +356,8 @@ async function updateForumSettings() {
|
||||
</NFlex>
|
||||
</NFlex>
|
||||
</NCard>
|
||||
<template v-else>
|
||||
<template v-else-if="currentForum">
|
||||
<NSpin :show="useForum.isLoading">
|
||||
<NSelect
|
||||
v-model:value="selectedForum"
|
||||
:options="
|
||||
managedForums.map((f) => ({
|
||||
label: (f.owner.id == accountInfo.id ? '[我的] ' : '') + f.name + ` (${f.owner.name})`,
|
||||
value: f.owner.id,
|
||||
}))
|
||||
"
|
||||
@update:value="(v) => SwitchForum(v)"
|
||||
>
|
||||
<template #header>
|
||||
<NButton @click="SwitchForum(accountInfo.id)" size="small" type="primary"> 我的粉丝讨论区 </NButton>
|
||||
</template>
|
||||
</NSelect>
|
||||
<NDivider />
|
||||
<NTabs animated v-bind:key="selectedForum" type="segment">
|
||||
<NTabPane tab="信息" name="info">
|
||||
<NDescriptions bordered size="small">
|
||||
@@ -375,6 +406,12 @@ async function updateForumSettings() {
|
||||
<NTabPane tab="成员" name="member">
|
||||
<NDivider> 申请加入 </NDivider>
|
||||
<NDataTable :columns="applyingColumns" :data="currentForum.applying" :pagination="paginationSetting" />
|
||||
<NDivider> 成员 </NDivider>
|
||||
<NDataTable
|
||||
:columns="memberColumns"
|
||||
:data="currentForum.members.sort((a, b) => (a.isAdmin ? 1 : 0) - (b.isAdmin ? 1 : 0))"
|
||||
:pagination="paginationSetting"
|
||||
/>
|
||||
<NDivider> 管理员 </NDivider>
|
||||
<NFlex>
|
||||
<NButton
|
||||
@@ -388,14 +425,6 @@ async function updateForumSettings() {
|
||||
</NFlex>
|
||||
<br />
|
||||
<NDataTable :columns="adminColumns" :data="currentForum.admins" :pagination="paginationSetting" />
|
||||
<template v-if="currentForum.settings.requireApply">
|
||||
<NDivider> 成员 </NDivider>
|
||||
<NDataTable
|
||||
:columns="memberColumns"
|
||||
:data="currentForum.members.sort((a, b) => (a.isAdmin ? 1 : 0) - (b.isAdmin ? 1 : 0))"
|
||||
:pagination="paginationSetting"
|
||||
/>
|
||||
</template>
|
||||
<NDivider> 封禁用户 </NDivider>
|
||||
<NFlex>
|
||||
<NButton @click="showBanModal = true" size="small" type="primary"> 封禁用户 </NButton>
|
||||
@@ -419,7 +448,7 @@ async function updateForumSettings() {
|
||||
<br />
|
||||
<NInput v-model:value="addAdminName" placeholder="请输入用户名或VTsuruId" />
|
||||
<NDivider />
|
||||
<NButton @click="addAdmin" type="primary" :disabled="!currentAdminInfo?.id"> 添加 </NButton>
|
||||
<NButton @click="addAdmin(currentAdminInfo!.id)" type="primary" :disabled="!currentAdminInfo?.id"> 添加 </NButton>
|
||||
</NModal>
|
||||
|
||||
<NModal v-model:show="showBanModal" preset="card" title="封禁用户" style="width: 600px; max-width: 90vw">
|
||||
|
||||
@@ -37,6 +37,7 @@ const props = defineProps<{
|
||||
|
||||
type PointUserSettings = {
|
||||
onlyAuthed: boolean
|
||||
searchKeyword?: string
|
||||
}
|
||||
|
||||
const message = useMessage()
|
||||
@@ -63,6 +64,12 @@ const filteredUsers = computed(() => {
|
||||
if (settings.value.onlyAuthed) {
|
||||
return user.isAuthed
|
||||
}
|
||||
if (settings.value.searchKeyword) {
|
||||
return (
|
||||
user.info.name?.toLowerCase().includes(settings.value.searchKeyword.toLowerCase()) == true ||
|
||||
user.info.userId?.toString() == settings.value.searchKeyword
|
||||
)
|
||||
}
|
||||
return true
|
||||
})
|
||||
.sort((a, b) => b.updateAt - a.updateAt)
|
||||
@@ -137,7 +144,7 @@ const column: DataTableColumns<ResponsePointUserModel> = [
|
||||
NPopconfirm,
|
||||
{ onPositiveClick: () => deleteUser(row) },
|
||||
{
|
||||
default: '确定要删除这个用户吗?记录将无法恢复',
|
||||
default: () => '确定要删除这个用户吗?记录将无法恢复',
|
||||
trigger: () =>
|
||||
h(
|
||||
NButton,
|
||||
@@ -260,7 +267,24 @@ onMounted(async () => {
|
||||
<NButton type="info" @click="showGivePointModal = true">给予/扣除积分</NButton>
|
||||
</NFlex>
|
||||
</template>
|
||||
<NFlex>
|
||||
<NFlex align="center">
|
||||
<NFlex :wrap="false" align="center" :size="5">
|
||||
<NInput
|
||||
v-model:value="settings.searchKeyword"
|
||||
placeholder="搜索用户 (用户名或uid)"
|
||||
style="max-width: 200px"
|
||||
clearable
|
||||
/>
|
||||
<NTooltip>
|
||||
<template #trigger>
|
||||
<NIcon :component="Info24Filled" />
|
||||
</template>
|
||||
1. 如果 EventFetcher 使用的是开放平台连接则无法通过UId搜索除了已认证和手动添加之外的用户
|
||||
(因为开放平台提供的是用户uid)
|
||||
<br/>
|
||||
2. 用户名只会保持在首条记录出现时的用户名
|
||||
</NTooltip>
|
||||
</NFlex>
|
||||
<NCheckbox v-model:checked="settings.onlyAuthed"> 只显示已认证用户 </NCheckbox>
|
||||
</NFlex>
|
||||
</NCard>
|
||||
@@ -271,6 +295,7 @@ onMounted(async () => {
|
||||
</template>
|
||||
<NDataTable
|
||||
v-else
|
||||
v-model:page="pn"
|
||||
scroll-x="600"
|
||||
:columns="column"
|
||||
:data="filteredUsers"
|
||||
|
||||
Reference in New Issue
Block a user