From df96b56ab0cce1728294343bb6e7bbec9ca625cc Mon Sep 17 00:00:00 2001 From: pllx Date: Tue, 28 Apr 2026 23:01:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=9C=E6=9D=A0=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20/=E6=9F=A5=E7=9C=8B=E8=B5=84=E6=96=99?= =?UTF-8?q?=EF=BC=8C=E7=9B=B4=E6=8E=A5=E6=89=93=E5=BC=80=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/chat-room/slash-commands.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/resources/js/chat-room/slash-commands.js b/resources/js/chat-room/slash-commands.js index d2fc1f9..10ce1fa 100644 --- a/resources/js/chat-room/slash-commands.js +++ b/resources/js/chat-room/slash-commands.js @@ -1,5 +1,6 @@ // 斜杠命令菜单模块 // 输入 / 时弹出可用命令列表,支持键盘/鼠标选择,可扩展的命令注册表。 + // ── 命令注册表(后续新命令只需 push 到此数组)── const SLASH_COMMANDS = [ @@ -8,20 +9,32 @@ const SLASH_COMMANDS = [ name: "/拍一拍", description: "向当前选中的聊天对象发送拍一拍,屏幕会抖动", icon: "👋", - /** - * 选中命令后执行的填充逻辑。 - * 返回填充后的输入框文本,或 false 由框架自动填入 name。 - */ fill(input) { input.value = "/拍一拍"; window.persistChatDraft?.("/拍一拍"); }, }, + { + id: "profile", + name: "/查看资料", + description: "查看当前选中对象的个人资料名片", + icon: "📋", + fill(_input) { + const toUserSelect = document.getElementById("to_user"); + const target = toUserSelect?.value?.trim() || null; + if (!target || target === "大家") { + window.chatDialog?.alert("请先选择一个聊天对象,再查看资料。", "查看资料", "#6366f1"); + return; + } + if (typeof window.openUserCard === "function") { + window.openUserCard(target); + } + }, + }, ]; // ── 菜单状态 ── -let menuElement = null; let visible = false; let selectedIndex = 0; let currentFilter = "";