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) {
|
async function ConfirmApply(owner: number, id: number) {
|
||||||
try {
|
try {
|
||||||
isLoading.value = true
|
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) {
|
if (data.code == 200) {
|
||||||
message?.success('已通过申请')
|
message?.success('已通过申请')
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
NTime,
|
NTime,
|
||||||
useMessage,
|
useMessage,
|
||||||
} from 'naive-ui'
|
} from 'naive-ui'
|
||||||
import { h, ref } from 'vue'
|
import { h, onMounted, ref } from 'vue'
|
||||||
import { ForumModel, ForumUserLevels, ForumUserModel } from '@/api/models/forum'
|
import { ForumModel, ForumUserLevels, ForumUserModel } from '@/api/models/forum'
|
||||||
import { FORUM_API_URL } from '@/data/constants'
|
import { FORUM_API_URL } from '@/data/constants'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -40,7 +40,7 @@ const message = useMessage()
|
|||||||
|
|
||||||
const managedForums = ref((await useForum.GetManagedForums()) ?? [])
|
const managedForums = ref((await useForum.GetManagedForums()) ?? [])
|
||||||
const currentForum = ref((await useForum.GetForumInfo(accountInfo.value.id)) ?? ({} as ForumModel))
|
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 readedAgreement = ref(false)
|
||||||
const showAgreement = ref(false)
|
const showAgreement = ref(false)
|
||||||
@@ -106,6 +106,7 @@ async function createForum() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function SwitchForum(owner: number) {
|
async function SwitchForum(owner: number) {
|
||||||
|
selectedForum.value = owner
|
||||||
currentForum.value = (await useForum.GetForumInfo(owner)) ?? ({} as ForumModel)
|
currentForum.value = (await useForum.GetForumInfo(owner)) ?? ({} as ForumModel)
|
||||||
}
|
}
|
||||||
async function refreshForumInfo() {
|
async function refreshForumInfo() {
|
||||||
@@ -152,17 +153,32 @@ const memberColumns: DataTableColumns<ForumUserModel> = [
|
|||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
render(row) {
|
render(row) {
|
||||||
return h(
|
return h(NFlex, {}, () => [
|
||||||
|
h(
|
||||||
NButton,
|
NButton,
|
||||||
{
|
{
|
||||||
text: true,
|
text: true,
|
||||||
type: 'success',
|
type: 'error',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
banUser(row.id)
|
banUser(row.id)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ default: () => '封禁' },
|
{ 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: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
|
disabled: () => currentForum.value.owner.id != accountInfo.value.id,
|
||||||
render(row) {
|
render(row) {
|
||||||
return h(
|
return currentForum.value.owner.id == accountInfo.value.id
|
||||||
|
? h(
|
||||||
NButton,
|
NButton,
|
||||||
{
|
{
|
||||||
text: true,
|
text: true,
|
||||||
@@ -202,18 +220,19 @@ const adminColumns: DataTableColumns<ForumUserModel> = [
|
|||||||
},
|
},
|
||||||
{ default: () => ' 取消管理员' },
|
{ default: () => ' 取消管理员' },
|
||||||
)
|
)
|
||||||
|
: null
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
async function addAdmin() {
|
async function addAdmin(id: number) {
|
||||||
try {
|
try {
|
||||||
const data = await QueryGetAPI<ForumModel>(FORUM_API_URL + 'manage/add-admin', {
|
const data = await QueryGetAPI<ForumModel>(FORUM_API_URL + 'manage/add-admin', {
|
||||||
forum: currentForum.value.owner.id,
|
forum: currentForum.value.owner.id,
|
||||||
id: currentAdminInfo.value?.id,
|
id: id,
|
||||||
})
|
})
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
message.success('已添加 ' + currentAdminInfo.value?.name + ' 为管理员')
|
message.success('已设置为管理员')
|
||||||
refreshForumInfo()
|
refreshForumInfo()
|
||||||
addAdminName.value = ''
|
addAdminName.value = ''
|
||||||
showAddAdminModal.value = false
|
showAddAdminModal.value = false
|
||||||
@@ -244,7 +263,7 @@ async function banUser(id: number) {
|
|||||||
try {
|
try {
|
||||||
const data = await QueryGetAPI<ForumModel>(FORUM_API_URL + 'manage/ban', {
|
const data = await QueryGetAPI<ForumModel>(FORUM_API_URL + 'manage/ban', {
|
||||||
forum: currentForum.value.owner.id,
|
forum: currentForum.value.owner.id,
|
||||||
id: currentBanUserInfo.value?.id,
|
id: id,
|
||||||
})
|
})
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
message.success('已封禁用户')
|
message.success('已封禁用户')
|
||||||
@@ -283,9 +302,36 @@ async function updateForumSettings() {
|
|||||||
message.error('修改失败: ' + err)
|
message.error('修改失败: ' + err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (currentForum.value.name) {
|
||||||
|
selectedForum.value = currentForum.value.owner.id
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<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="啊哦">
|
<NCard v-if="!currentForum.name" size="small" title="啊哦">
|
||||||
<NAlert type="error"> 你尚未创建粉丝讨论区 </NAlert>
|
<NAlert type="error"> 你尚未创建粉丝讨论区 </NAlert>
|
||||||
<NDivider />
|
<NDivider />
|
||||||
@@ -310,23 +356,8 @@ async function updateForumSettings() {
|
|||||||
</NFlex>
|
</NFlex>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
</NCard>
|
</NCard>
|
||||||
<template v-else>
|
<template v-else-if="currentForum">
|
||||||
<NSpin :show="useForum.isLoading">
|
<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">
|
<NTabs animated v-bind:key="selectedForum" type="segment">
|
||||||
<NTabPane tab="信息" name="info">
|
<NTabPane tab="信息" name="info">
|
||||||
<NDescriptions bordered size="small">
|
<NDescriptions bordered size="small">
|
||||||
@@ -375,6 +406,12 @@ async function updateForumSettings() {
|
|||||||
<NTabPane tab="成员" name="member">
|
<NTabPane tab="成员" name="member">
|
||||||
<NDivider> 申请加入 </NDivider>
|
<NDivider> 申请加入 </NDivider>
|
||||||
<NDataTable :columns="applyingColumns" :data="currentForum.applying" :pagination="paginationSetting" />
|
<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>
|
<NDivider> 管理员 </NDivider>
|
||||||
<NFlex>
|
<NFlex>
|
||||||
<NButton
|
<NButton
|
||||||
@@ -388,14 +425,6 @@ async function updateForumSettings() {
|
|||||||
</NFlex>
|
</NFlex>
|
||||||
<br />
|
<br />
|
||||||
<NDataTable :columns="adminColumns" :data="currentForum.admins" :pagination="paginationSetting" />
|
<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>
|
<NDivider> 封禁用户 </NDivider>
|
||||||
<NFlex>
|
<NFlex>
|
||||||
<NButton @click="showBanModal = true" size="small" type="primary"> 封禁用户 </NButton>
|
<NButton @click="showBanModal = true" size="small" type="primary"> 封禁用户 </NButton>
|
||||||
@@ -419,7 +448,7 @@ async function updateForumSettings() {
|
|||||||
<br />
|
<br />
|
||||||
<NInput v-model:value="addAdminName" placeholder="请输入用户名或VTsuruId" />
|
<NInput v-model:value="addAdminName" placeholder="请输入用户名或VTsuruId" />
|
||||||
<NDivider />
|
<NDivider />
|
||||||
<NButton @click="addAdmin" type="primary" :disabled="!currentAdminInfo?.id"> 添加 </NButton>
|
<NButton @click="addAdmin(currentAdminInfo!.id)" type="primary" :disabled="!currentAdminInfo?.id"> 添加 </NButton>
|
||||||
</NModal>
|
</NModal>
|
||||||
|
|
||||||
<NModal v-model:show="showBanModal" preset="card" title="封禁用户" style="width: 600px; max-width: 90vw">
|
<NModal v-model:show="showBanModal" preset="card" title="封禁用户" style="width: 600px; max-width: 90vw">
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const props = defineProps<{
|
|||||||
|
|
||||||
type PointUserSettings = {
|
type PointUserSettings = {
|
||||||
onlyAuthed: boolean
|
onlyAuthed: boolean
|
||||||
|
searchKeyword?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
@@ -63,6 +64,12 @@ const filteredUsers = computed(() => {
|
|||||||
if (settings.value.onlyAuthed) {
|
if (settings.value.onlyAuthed) {
|
||||||
return user.isAuthed
|
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
|
return true
|
||||||
})
|
})
|
||||||
.sort((a, b) => b.updateAt - a.updateAt)
|
.sort((a, b) => b.updateAt - a.updateAt)
|
||||||
@@ -137,7 +144,7 @@ const column: DataTableColumns<ResponsePointUserModel> = [
|
|||||||
NPopconfirm,
|
NPopconfirm,
|
||||||
{ onPositiveClick: () => deleteUser(row) },
|
{ onPositiveClick: () => deleteUser(row) },
|
||||||
{
|
{
|
||||||
default: '确定要删除这个用户吗?记录将无法恢复',
|
default: () => '确定要删除这个用户吗?记录将无法恢复',
|
||||||
trigger: () =>
|
trigger: () =>
|
||||||
h(
|
h(
|
||||||
NButton,
|
NButton,
|
||||||
@@ -260,7 +267,24 @@ onMounted(async () => {
|
|||||||
<NButton type="info" @click="showGivePointModal = true">给予/扣除积分</NButton>
|
<NButton type="info" @click="showGivePointModal = true">给予/扣除积分</NButton>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
</template>
|
</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>
|
<NCheckbox v-model:checked="settings.onlyAuthed"> 只显示已认证用户 </NCheckbox>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
</NCard>
|
</NCard>
|
||||||
@@ -271,6 +295,7 @@ onMounted(async () => {
|
|||||||
</template>
|
</template>
|
||||||
<NDataTable
|
<NDataTable
|
||||||
v-else
|
v-else
|
||||||
|
v-model:page="pn"
|
||||||
scroll-x="600"
|
scroll-x="600"
|
||||||
:columns="column"
|
:columns="column"
|
||||||
:data="filteredUsers"
|
:data="filteredUsers"
|
||||||
|
|||||||
Reference in New Issue
Block a user