feat: 欢迎语增加右下角弹窗通知;禁止对「大家」发送欢迎
This commit is contained in:
@@ -449,6 +449,17 @@ class ChatController extends Controller
|
||||
$messageData = array_merge($messageData, $imagePayload);
|
||||
}
|
||||
|
||||
// 欢迎动作:增加右下角弹窗通知(内容含发送者信息)
|
||||
if (($data['action'] ?? '') === '欢迎') {
|
||||
$messageData['toast_notification'] = [
|
||||
'title' => '👋 欢迎',
|
||||
'message' => strip_tags($pureContent),
|
||||
'icon' => '👋',
|
||||
'color' => '#e11d48',
|
||||
'duration' => 8000,
|
||||
];
|
||||
}
|
||||
|
||||
// 6.5 将用户当前激活的消息装扮注入广播 payload(气泡样式 + 昵称颜色),前端据此渲染消息外观
|
||||
$decorations = app(\App\Services\DecorationService::class)->getDecorationsForMessage($user);
|
||||
$messageData = array_merge($messageData, $decorations);
|
||||
|
||||
@@ -370,8 +370,8 @@ export function bindChatEvents() {
|
||||
window.showVipPresenceBanner(msg);
|
||||
}
|
||||
|
||||
// 若消息携带 toast_notification 字段且当前用户是接收者或为公屏广播,弹右下角小卡片
|
||||
if (msg.toast_notification && (msg.to_user === window.chatContext?.username || msg.to_user === '大家')) {
|
||||
// 若消息携带 toast_notification 字段且当前用户是接收者或为公屏广播或为欢迎动作,弹右下角小卡片
|
||||
if (msg.toast_notification && (msg.to_user === window.chatContext?.username || msg.to_user === '大家' || msg.action === '欢迎')) {
|
||||
const t = msg.toast_notification;
|
||||
window.chatToast?.show({
|
||||
title: t.title || "通知",
|
||||
|
||||
@@ -111,7 +111,11 @@
|
||||
*/
|
||||
function sendWelcomeTpl(tpl) {
|
||||
const toUser = document.getElementById('to_user')?.value || '大家';
|
||||
const name = toUser === '大家' ? '大家' : toUser;
|
||||
if (toUser === '大家') {
|
||||
window.chatDialog?.alert('欢迎语不能对「大家」发送,请先选择具体用户。', '🚫 提示', '#cc4444');
|
||||
return;
|
||||
}
|
||||
const name = toUser;
|
||||
const prefix = window.chatContext?.welcomePrefix || window.chatContext?.username || '';
|
||||
const body = tpl.replace(/\{name\}/g, name);
|
||||
const msg = `${prefix}:${body}`;
|
||||
|
||||
Reference in New Issue
Block a user