perf: 优化举报功能

This commit is contained in:
kuaifan 2024-05-30 22:46:34 +08:00
parent dcffeded9a
commit efce884494
3 changed files with 79 additions and 31 deletions

View File

@ -7,6 +7,7 @@ use App\Models\User;
use App\Module\Base;
use App\Models\Complaint;
use App\Models\WebSocketDialog;
use App\Models\WebSocketDialogMsg;
/**
* @apiDefine dialog
@ -103,6 +104,19 @@ class ComplaintController extends AbstractController
'reason' => $reason,
'imgs' => $report_imgs,
])->save();
// 通知管理员
$botUser = User::botGetOrCreate('system-msg');
User::where("identity", "like", "%,admin,%")
->orderByDesc('line_at')
->take(10)
->get()
->each(function ($adminUser) use ($reason, $botUser) {
$dialog = WebSocketDialog::checkUserDialog($botUser, $adminUser->userid);
if ($dialog) {
$text = "<p>收到新的举报信息:{$reason} (请前往应用查看详情)</p>";
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid); // todo 未能在任务end事件来发送任务
}
});
//
return Base::retSuccess('success');
}

View File

@ -94,61 +94,89 @@ export default {
{
title: this.$L('举报类型'),
key: 'type',
minWidth: 80,
minWidth: 120,
render: (h, { row }) => {
const arr = [h('AutoTip', this.$L(typeList.find(h => h.id == row.type).label))];
return h('div', arr)
const label = this.$L(typeList.find(h => h.id == row.type).label)
return h('div', {
style: {
'overflow': 'hidden',
'text-overflow': 'ellipsis',
'white-space': 'nowrap'
},
on: {
click: () => {
$A.modalInfo({
language: false,
title: this.$L('举报类型'),
content: label
})
}
}
}, label)
}
},
{
title: this.$L('状态'),
key: 'status',
minWidth: 60,
minWidth: 80,
render: (h, { row }) => {
let text = row.status == 0 ? '未处理': '已处理';
return h('div', this.$L(text))
return h('div', {
style: {
color: row.status == 0 ? '#f00' : 'inherit',
}
}, [h('AutoTip', this.$L(text))])
}
},
{
title: this.$L('举报原因'),
minWidth: 120,
minWidth: 150,
render: (h, { row }) => {
return h('div', [h('AutoTip', row.reason)])
return h('div', {
style: {
'overflow': 'hidden',
'text-overflow': 'ellipsis',
'white-space': 'nowrap'
},
on: {
click: () => {
$A.modalInfo({
language: false,
title: this.$L('举报原因'),
content: row.reason
})
}
}
}, row.reason)
}
},
{
title: this.$L('举报图'),
minWidth: 100,
minWidth: 85,
render: (h, { row }) => {
const arr = [];
const imgs = JSON.parse(row.imgs)?.map(path => {
const list = JSON.parse(row.imgs)?.map(path => {
return {
src: $A.apiUrl("../" + path),
}
});
imgs.forEach((item, index) => {
arr.push(h('img', {
attrs: {
src: item.src,
width: 70
},
on: {
click: () => {
this.$store.dispatch("previewImage", { index: index, list: imgs })
}
}
}))
});
if (list.length === 0) {
return h('div', '-')
}
return h('div', {
attrs: {
style: "display: flex;padding: 4px 0;gap: 10px;"
style: {
color: '#1890ff',
},
on: {
click: () => {
this.$store.dispatch("previewImage", { index: 0, list })
}
}
}, arr)
}, [h('AutoTip', this.$L('点击查看'))])
}
},
{
title: this.$L('举报人'),
minWidth: 60,
minWidth: 100,
render: (h, { row }) => {
return h('UserAvatar', {
props: {
@ -200,7 +228,7 @@ export default {
cancelText: this.$L('取消'),
},
style: {
marginLeft: '8px',
marginLeft: params.row.status == 0 ? '8px' : '0',
fontSize: '13px',
cursor: 'pointer',
color: '#f00',

View File

@ -77,9 +77,6 @@
@command="onDialogMenu">
<i class="taskfont dialog-menu-icon">&#xe6e9;</i>
<EDropdownMenu slot="dropdown">
<EDropdownItem v-if="dialogData.bot == 0" command="report">
<div>{{$L('举报投诉')}}</div>
</EDropdownItem>
<EDropdownItem command="searchMsg">
<div>{{$L('搜索消息')}}</div>
</EDropdownItem>
@ -90,6 +87,9 @@
<EDropdownItem command="openCreate">
<div>{{$L('创建群组')}}</div>
</EDropdownItem>
<EDropdownItem v-if="dialogData.bot == 0" command="report">
<div>{{$L('举报投诉')}}</div>
</EDropdownItem>
</template>
<template v-else>
<EDropdownItem command="groupInfo">
@ -99,6 +99,9 @@
<EDropdownItem v-if="dialogData.group_type === 'all' && userIsAdmin" command="modifyAdmin">
<div>{{$L('修改资料')}}</div>
</EDropdownItem>
<EDropdownItem command="report">
<div>{{$L('举报投诉')}}</div>
</EDropdownItem>
<EDropdownItem command="exit">
<div style="color:#f00">{{$L('退出群组')}}</div>
</EDropdownItem>
@ -110,6 +113,9 @@
<EDropdownItem command="transfer">
<div>{{$L('转让群主')}}</div>
</EDropdownItem>
<EDropdownItem command="report">
<div>{{$L('举报投诉')}}</div>
</EDropdownItem>
<EDropdownItem command="disband">
<div style="color:#f00">{{$L('解散群组')}}</div>
</EDropdownItem>