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\Module\Base;
use App\Models\Complaint; use App\Models\Complaint;
use App\Models\WebSocketDialog; use App\Models\WebSocketDialog;
use App\Models\WebSocketDialogMsg;
/** /**
* @apiDefine dialog * @apiDefine dialog
@ -103,6 +104,19 @@ class ComplaintController extends AbstractController
'reason' => $reason, 'reason' => $reason,
'imgs' => $report_imgs, 'imgs' => $report_imgs,
])->save(); ])->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'); return Base::retSuccess('success');
} }

View File

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

View File

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