perf: 消息接口支持MARKDOWN

This commit is contained in:
kuaifan 2023-04-02 10:53:21 +08:00
parent 679a0002a7
commit c2db186620
4 changed files with 58 additions and 51 deletions

View File

@ -20,6 +20,7 @@ use Carbon\Carbon;
use DB; use DB;
use Redirect; use Redirect;
use Request; use Request;
use Str;
/** /**
* @apiDefine dialog * @apiDefine dialog
@ -664,6 +665,9 @@ class DialogController extends AbstractController
* *
* @apiParam {Number} dialog_id 对话ID * @apiParam {Number} dialog_id 对话ID
* @apiParam {String} text 消息内容 * @apiParam {String} text 消息内容
* @apiParam {String} [text_type] 消息类型
* - html: HTML默认
* - md: MARKDOWN
* @apiParam {Number} [update_id] 更新消息ID优先大于 reply_id * @apiParam {Number} [update_id] 更新消息ID优先大于 reply_id
* @apiParam {Number} [reply_id] 回复ID * @apiParam {Number} [reply_id] 回复ID
* @apiParam {String} [silence] 是否静默发送 * @apiParam {String} [silence] 是否静默发送
@ -694,7 +698,8 @@ class DialogController extends AbstractController
$update_id = intval(Request::input('update_id')); $update_id = intval(Request::input('update_id'));
$reply_id = intval(Request::input('reply_id')); $reply_id = intval(Request::input('reply_id'));
$text = trim(Request::input('text')); $text = trim(Request::input('text'));
$silence = trim(Request::input('silence')) === 'yes'; $text_type = strtolower(trim(Request::input('text_type')));
$silence = in_array(strtolower(trim(Request::input('silence'))), ['yes', 'true', '1']);
// //
WebSocketDialog::checkDialog($dialog_id); WebSocketDialog::checkDialog($dialog_id);
// //
@ -706,6 +711,9 @@ class DialogController extends AbstractController
$action = ""; $action = "";
} }
// //
if (in_array($text_type, ['md', 'markdown'])) {
$text = Str::markdown($text);
}
$text = WebSocketDialogMsg::formatMsg($text, $dialog_id); $text = WebSocketDialogMsg::formatMsg($text, $dialog_id);
$strlen = mb_strlen($text); $strlen = mb_strlen($text);
$noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text)); $noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text));

File diff suppressed because one or more lines are too long

View File

@ -49,7 +49,6 @@ input[type="date"] {
src: url('./glyphicons-halflings-regular.eot'); src: url('./glyphicons-halflings-regular.eot');
src: url('./glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), src: url('./glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
url('./glyphicons-halflings-regular.woff') format('woff'), url('./glyphicons-halflings-regular.woff') format('woff'),
url('./glyphicons-halflings-regular.woff2') format('woff2'),
url('./glyphicons-halflings-regular.ttf') format('truetype'), url('./glyphicons-halflings-regular.ttf') format('truetype'),
url('./glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg'); url('./glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');
} }

View File

@ -5,13 +5,13 @@
<meta name="description" content="APP接口文档"> <meta name="description" content="APP接口文档">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="assets/bootstrap.min.css?v=1679925462953" rel="stylesheet" media="screen"> <link href="assets/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="assets/prism.css?v=1679925462953" rel="stylesheet" /> <link href="assets/prism.css" rel="stylesheet" />
<link href="assets/main.css?v=1679925462953" rel="stylesheet" media="screen, print"> <link href="assets/main.css" rel="stylesheet" media="screen, print">
<link href="assets/favicon.ico?v=1679925462953" rel="icon" type="image/x-icon"> <link href="assets/favicon.ico" rel="icon" type="image/x-icon">
<link href="assets/apple-touch-icon.png?v=1679925462953" rel="apple-touch-icon" sizes="180x180"> <link href="assets/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180">
<link href="assets/favicon-32x32.png?v=1679925462953" rel="icon" type="image/png" sizes="32x32"> <link href="assets/favicon-32x32.png" rel="icon" type="image/png" sizes="32x32">
<link href="assets/favicon-16x16.png?v=1679925462953" rel="icon" type="image/png" sizes="16x16"> <link href="assets/favicon-16x16.png"rel="icon" type="image/png" sizes="16x16">
</head> </head>
<body class="container-fluid"> <body class="container-fluid">
@ -306,7 +306,7 @@
{{#if optional}} {{#if optional}}
<span class="label optional">{{__ "optional"}}</span> <span class="label optional">{{__ "optional"}}</span>
{{else}} {{else}}
{{#if ../../template.showRequiredLabels}} {{#if ../template.showRequiredLabels}}
<span class="label required">{{__ "required"}}</span> <span class="label required">{{__ "required"}}</span>
{{/if}} {{/if}}
{{/if}}</td> {{/if}}</td>
@ -928,6 +928,6 @@
</div> </div>
</div> </div>
<script src="assets/main.bundle.js?v=1679925462953"></script> <script src="assets/main.bundle.js"></script>
</body> </body>
</html> </html>