feat: 添加会话重命名功能
- 在 DialogController 中新增 session__rename 方法,支持用户重命名会话 - 更新前端组件 DialogSessionHistory.vue,添加重命名按钮及相关逻辑 - 修改样式以支持重命名功能的交互效果 - 优化用户体验,确保重命名操作的流畅性
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
|
||||
use DB;
|
||||
use Request;
|
||||
use Redirect;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use App\Tasks\PushTask;
|
||||
use App\Module\AI;
|
||||
@@ -3600,4 +3601,51 @@ class DialogController extends AbstractController
|
||||
//
|
||||
return Base::retSuccess('success', $session);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/dialog/session/rename 69. AI-重命名会话
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup dialog
|
||||
* @apiName session_rename
|
||||
*
|
||||
* @apiParam {Number} session_id 会话ID
|
||||
* @apiParam {String} title 会话名称
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function session__rename()
|
||||
{
|
||||
User::auth();
|
||||
//
|
||||
$session_id = intval(Request::input('session_id'));
|
||||
$title = trim((string)Request::input('title'));
|
||||
//
|
||||
if ($session_id <= 0) {
|
||||
return Base::retError('参数错误');
|
||||
}
|
||||
if ($title === '') {
|
||||
return Base::retError('请输入会话名称');
|
||||
}
|
||||
//
|
||||
$session = WebSocketDialogSession::whereId($session_id)->first();
|
||||
if (empty($session)) {
|
||||
return Base::retError('会话不存在或已被删除');
|
||||
}
|
||||
//
|
||||
$dialog = WebSocketDialog::checkDialog($session->dialog_id);
|
||||
if (!$dialog->isSessionDialog()) {
|
||||
return Base::retError('当前对话不支持');
|
||||
}
|
||||
//
|
||||
$session->title = Base::cutStr($title, 100);
|
||||
$session->save();
|
||||
$session->refresh();
|
||||
Cache::forever('dialog_session_title_' . $session->id, true);
|
||||
//
|
||||
return Base::retSuccess('重命名成功', $session);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user