diff --git a/app/Http/Controllers/Api/ApproveController.php b/app/Http/Controllers/Api/ApproveController.php
index 828abff95..428c54980 100755
--- a/app/Http/Controllers/Api/ApproveController.php
+++ b/app/Http/Controllers/Api/ApproveController.php
@@ -1012,7 +1012,7 @@ class ApproveController extends AbstractController
$proc_msg->userid = $toUser['userid'];
$proc_msg->save();
}
- // 更新工作报告 未读数量
+ // 更新审批 未读数量
if ($type == 'approve_reviewer' && $toUser['userid']) {
$params = [
'userid' => [$toUser['userid'], User::auth()->userid()],
diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php
index 7232242ce..0282182b7 100644
--- a/app/Models/WebSocketDialogMsg.php
+++ b/app/Models/WebSocketDialogMsg.php
@@ -573,15 +573,7 @@ class WebSocketDialogMsg extends AbstractModel
return "[{$action}] ${$data['msg']['name']}";
case 'file':
- if ($data['msg']['type'] == 'img') {
- $action = Doo::translate("图片");
- return "[{$action}]";
- } elseif ($data['msg']['ext'] == 'mp4') {
- $action = Doo::translate("视频");
- return "[{$action}]";
- }
- $action = Doo::translate("文件");
- return "[{$action}] {$data['msg']['name']}";
+ return $this->previewFileMsg($data['msg']);
case 'tag':
$action = Doo::translate($data['msg']['action'] === 'remove' ? '取消标注' : '标注');
@@ -598,12 +590,82 @@ class WebSocketDialogMsg extends AbstractModel
case 'notice':
return $data['msg']['notice'];
+ case 'template':
+ return $this->previewTemplateMsg($data['msg']);
+
default:
$action = Doo::translate("未知的消息");
return "[{$action}]";
}
}
+ /**
+ * 预览文件消息
+ * @param $msg
+ * @return string
+ */
+ private function previewFileMsg($msg)
+ {
+ if ($msg['type'] == 'img') {
+ $action = Doo::translate("图片");
+ return "[{$action}]";
+ } elseif ($msg['ext'] == 'mp4') {
+ $action = Doo::translate("视频");
+ return "[{$action}]";
+ }
+ $action = Doo::translate("文件");
+ return "[{$action}] {$msg['name']}";
+ }
+
+ /**
+ * 预览模板消息
+ * @param $msg
+ * @return string
+ */
+ private function previewTemplateMsg($msg)
+ {
+ switch ($msg['type']) {
+ case '/help':
+ return Doo::translate('帮助指令');
+ case '/list':
+ return Doo::translate('我的机器人');
+ case '/info':
+ return Doo::translate('机器人信息');
+ case '/newbot':
+ return Doo::translate('新建机器人');
+ case '/setname':
+ return Doo::translate('设置名称');
+ case '/deletebot':
+ return Doo::translate('删除机器人');
+ case '/token':
+ return Doo::translate('机器人Token');
+ case '/revoke':
+ return Doo::translate('更新Token');
+ case '/webhook':
+ return Doo::translate('设置Webhook');
+ case '/clearday':
+ return Doo::translate('设置保留消息时间');
+ case '/dialog':
+ return Doo::translate('对话列表');
+ case '/api':
+ return Doo::translate('API接口文档');
+
+ case 'approve_reviewer':
+ return Doo::translate('待你审批');
+ case 'approve_notifier':
+ return Doo::translate('审批通知');
+ case 'approve_comment_notifier':
+ return Doo::translate('审批评论通知');
+ case 'approve_submitter':
+ return Doo::translate('审批结果');
+
+ case 'notice':
+ return $msg['notice'];
+ default:
+ return Doo::translate(preg_match("/^\//", $msg['type']) ? '帮助菜单' : '未知消息类型');
+ }
+ }
+
/**
* 生成关键词
* @return string
diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js
index 977542697..07c513452 100755
--- a/resources/assets/js/functions/web.js
+++ b/resources/assets/js/functions/web.js
@@ -386,46 +386,106 @@ import {MarkdownPreview} from "../store/markdown";
* @returns {string|*}
*/
getMsgSimpleDesc(data, imgClassName = null) {
- if ($A.isJson(data)) {
- switch (data.type) {
- case 'text':
- return $A.getMsgTextPreview(data.msg.type === 'md' ? MarkdownPreview(data.msg.text) : data.msg.text, imgClassName)
- case 'vote':
- return `[${$A.L('投票')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
- case 'word-chain':
- return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
- case 'record':
- return `[${$A.L('语音')}]`
- case 'meeting':
- return `[${$A.L('会议')}] ${data.msg.name}`
- case 'file':
- if (data.msg.type == 'img') {
- if (imgClassName) {
- // 缩略图,主要用于回复消息预览
- const width = parseInt(data.msg.width),
- height = parseInt(data.msg.height),
- maxSize = 40;
- const scale = $A.scaleToScale(width, height, maxSize, maxSize);
- return `
`
- }
- return `[${$A.L('图片')}]`
- } else if (data.msg.ext == 'mp4') {
- return `[${$A.L('视频')}]`
- }
- return `[${$A.L('文件')}] ${data.msg.name}`
- case 'tag':
- return `[${$A.L(data.msg.action === 'remove' ? '取消标注' : '标注')}] ${$A.getMsgSimpleDesc(data.msg.data)}`
- case 'top':
- return `[${$A.L(data.msg.action === 'remove' ? '取消置顶' : '置顶')}] ${$A.getMsgSimpleDesc(data.msg.data)}`
- case 'todo':
- return `[${$A.L(data.msg.action === 'remove' ? '取消待办' : (data.msg.action === 'done' ? '完成' : '设待办'))}] ${$A.getMsgSimpleDesc(data.msg.data)}`
- case 'notice':
- return data.msg.notice
- default:
- return `[${$A.L('未知的消息')}]`
- }
+ if (!$A.isJson(data)) {
+ return '';
+ }
+ switch (data.type) {
+ case 'text':
+ return $A.getMsgTextPreview(data.msg.type === 'md' ? MarkdownPreview(data.msg.text) : data.msg.text, imgClassName)
+ case 'vote':
+ return `[${$A.L('投票')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
+ case 'word-chain':
+ return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
+ case 'record':
+ return `[${$A.L('语音')}]`
+ case 'meeting':
+ return `[${$A.L('会议')}] ${data.msg.name}`
+ case 'file':
+ return $A.fileMsgSimpleDesc(data.msg, imgClassName)
+ case 'tag':
+ return `[${$A.L(data.msg.action === 'remove' ? '取消标注' : '标注')}] ${$A.getMsgSimpleDesc(data.msg.data)}`
+ case 'top':
+ return `[${$A.L(data.msg.action === 'remove' ? '取消置顶' : '置顶')}] ${$A.getMsgSimpleDesc(data.msg.data)}`
+ case 'todo':
+ return `[${$A.L(data.msg.action === 'remove' ? '取消待办' : (data.msg.action === 'done' ? '完成' : '设待办'))}] ${$A.getMsgSimpleDesc(data.msg.data)}`
+ case 'notice':
+ return data.msg.notice
+ case 'template':
+ return $A.tempMsgSimpleDesc(data.msg)
+ default:
+ return `[${$A.L('未知的消息')}]`
+ }
+ },
+
+ /**
+ * 文件消息简单描述
+ * @param msg
+ * @param imgClassName
+ * @returns {string}
+ */
+ fileMsgSimpleDesc(msg, imgClassName = null) {
+ if (msg.type == 'img') {
+ if (imgClassName) {
+ // 缩略图,主要用于回复消息预览
+ const width = parseInt(msg.width),
+ height = parseInt(msg.height),
+ maxSize = 40;
+ const scale = $A.scaleToScale(width, height, maxSize, maxSize);
+ return `
`
+ }
+ return `[${$A.L('图片')}]`
+ } else if (msg.ext == 'mp4') {
+ return `[${$A.L('视频')}]`
+ }
+ return `[${$A.L('文件')}] ${msg.name}`
+ },
+
+ /**
+ * 模板消息简单描述
+ * @param msg
+ * @returns {string|*}
+ */
+ tempMsgSimpleDesc(msg) {
+ switch (msg.type) {
+ case '/help':
+ return $A.L('帮助指令');
+ case '/list':
+ return $A.L('我的机器人');
+ case '/info':
+ return $A.L('机器人信息');
+ case '/newbot':
+ return $A.L('新建机器人');
+ case '/setname':
+ return $A.L('设置名称');
+ case '/deletebot':
+ return $A.L('删除机器人');
+ case '/token':
+ return $A.L('机器人Token');
+ case '/revoke':
+ return $A.L('更新Token');
+ case '/webhook':
+ return $A.L('设置Webhook');
+ case '/clearday':
+ return $A.L('设置保留消息时间');
+ case '/dialog':
+ return $A.L('对话列表');
+ case '/api':
+ return $A.L('API接口文档');
+
+ case 'approve_reviewer':
+ return $A.L('待你审批');
+ case 'approve_notifier':
+ return $A.L('审批通知');
+ case 'approve_comment_notifier':
+ return $A.L('审批评论通知');
+ case 'approve_submitter':
+ return $A.L('审批结果');
+
+ case 'notice':
+ return msg.notice;
+ default:
+ return $A.L(/^\//.test(msg.type) ? '帮助菜单' : '未知消息类型');
}
- return '';
},
/**
diff --git a/resources/assets/js/pages/manage/components/DialogView/template/other.vue b/resources/assets/js/pages/manage/components/DialogView/template/other.vue
index d86cf2b1e..1a9d65116 100644
--- a/resources/assets/js/pages/manage/components/DialogView/template/other.vue
+++ b/resources/assets/js/pages/manage/components/DialogView/template/other.vue
@@ -17,7 +17,7 @@ export default {
},
computed: {
isBot() {
- return this.msg.type.startsWith('/');
+ return /^\//.test(this.msg.type);
},
},
methods: {},