diff --git a/app/Models/UserBot.php b/app/Models/UserBot.php index 86570078a..a16d3e653 100644 --- a/app/Models/UserBot.php +++ b/app/Models/UserBot.php @@ -189,10 +189,22 @@ class UserBot extends AbstractModel default: if (preg_match('/^ai-(.*?)@bot\.system$/', $email)) { - return [ - [ + if (!Base::judgeClientVersion('0.42.62')) { + return [ 'key' => '%3A.clear', 'label' => Doo::translate('清空上下文') + ]; + } + return [ + [ + 'key' => 'ai-newchat', + 'label' => Doo::translate('开启新对话'), + 'config' => [] + ], + [ + 'key' => 'ai-historychat', + 'label' => Doo::translate('历史对话'), + 'config' => [] ] ]; } diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index 06181e775..c95f215ca 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -27,6 +27,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $read 已阅数量 * @property int|null $send 发送数量 * @property int|null $tag 标注会员ID + * @property string|null $session 会话标识符 * @property int|null $todo 设为待办会员ID * @property int|null $link 是否存在链接 * @property int|null $modify 是否编辑 @@ -69,6 +70,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereReplyId($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereReplyNum($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereSend($value) + * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereSession($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereTag($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereTodo($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereType($value) diff --git a/app/Models/WebSocketDialogSession.php b/app/Models/WebSocketDialogSession.php new file mode 100644 index 000000000..f94a13612 --- /dev/null +++ b/app/Models/WebSocketDialogSession.php @@ -0,0 +1,61 @@ +belongsTo(WebSocketDialog::class, 'dialog_id'); + } + + /** + * 获取关联的用户 + */ + public function user() + { + return $this->belongsTo(User::class, 'userid'); + } +} diff --git a/database/migrations/2025_02_07_163329_web_socket_dialog_msgs_add_session.php b/database/migrations/2025_02_07_163329_web_socket_dialog_msgs_add_session.php new file mode 100644 index 000000000..9ed726398 --- /dev/null +++ b/database/migrations/2025_02_07_163329_web_socket_dialog_msgs_add_session.php @@ -0,0 +1,34 @@ +string('session', 36)->nullable()->default('')->after('tag')->comment('会话标识符'); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('web_socket_dialog_msgs', function (Blueprint $table) { + $table->dropColumn('session'); + }); + } +} diff --git a/database/migrations/2025_02_07_163701_create_web_socket_dialog_sessions_table.php b/database/migrations/2025_02_07_163701_create_web_socket_dialog_sessions_table.php new file mode 100644 index 000000000..39c7845f8 --- /dev/null +++ b/database/migrations/2025_02_07_163701_create_web_socket_dialog_sessions_table.php @@ -0,0 +1,36 @@ +id(); + $table->bigInteger('dialog_id')->unsigned()->index()->comment('对话ID'); + $table->bigInteger('userid')->unsigned()->index()->comment('用户ID'); + $table->string('title', 255)->default('')->comment('会话标题'); + $table->timestamps(); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('web_socket_dialog_sessions'); + } +} diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 34755b204..cbd013a0e 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -255,7 +255,7 @@