refactor: 控制台输入框不再区分聊天与指令,只留一个入口
聊天和指令本来就是同一个东西:以 / 开头按游戏指令发送,否则按公屏消息发送。 服务端 /api/bots/:id/chat 一直就是这么分流的,前端多一个模式下拉框纯属多余。 - 删掉「公屏聊天 / 游戏指令」下拉框与重复的「快捷公屏消息」输入框 - 只保留:一个输入框 + 快捷发送按钮 + 移动测试按钮 - 接口返回新增 kind 字段(chat / command)说明实际走的是哪条路 - Toast 区分「消息已发送」与「指令已发送:/xxx」 - 快捷发送补上 /u restore confirm(配合定时消息常用) - 空内容提示从「消息为空」改为「内容为空」(不再只针对聊天) 测试 325 -> 326,全部通过。
这个提交包含在:
+17
-1
@@ -202,7 +202,23 @@ test('空聊天消息被拒绝', () => {
|
||||
const { pool } = setup();
|
||||
const result = pool.sendChat('BotA', ' ');
|
||||
assert.strictEqual(result.ok, false);
|
||||
assert.ok(result.message.includes('消息为空'));
|
||||
assert.ok(result.message.includes('内容为空'));
|
||||
});
|
||||
|
||||
test('聊天与指令共用同一入口:以 / 开头按指令发送', () => {
|
||||
const { pool } = setup();
|
||||
const entry = pool.get('BotA');
|
||||
entry.manager.bot = { chat: () => {} };
|
||||
entry.manager.state = 'online';
|
||||
entry.manager.loggedIn = true;
|
||||
|
||||
const chat = pool.sendChat('BotA', '大家好');
|
||||
assert.strictEqual(chat.kind, 'chat');
|
||||
assert.ok(chat.message.includes('消息已发送'));
|
||||
|
||||
const command = pool.sendChat('BotA', '/u restore confirm');
|
||||
assert.strictEqual(command.kind, 'command', '以 / 开头应识别为指令');
|
||||
assert.ok(command.message.includes('指令已发送'));
|
||||
});
|
||||
|
||||
test('完成登录验证后允许发送指令与聊天', () => {
|
||||
|
||||
在新工单中引用
屏蔽一个用户