add clear

This commit is contained in:
Chuck1sn
2025-06-14 13:54:31 +08:00
parent ab72508408
commit f559e4cde3
4 changed files with 1876 additions and 1802 deletions

View File

@@ -747,6 +747,19 @@
} }
} }
}, },
"/ai/chat/refresh": {
"post": {
"tags": [
"ai-controller"
],
"operationId": "createNewConversation",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/ai/action/search": { "/ai/action/search": {
"post": { "post": {
"tags": [ "tags": [
@@ -1627,10 +1640,6 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"parentId": {
"type": "integer",
"format": "int64"
},
"isBound": { "isBound": {
"type": "boolean" "type": "boolean"
} }
@@ -1641,6 +1650,14 @@
"properties": { "properties": {
"username": { "username": {
"type": "string" "type": "string"
},
"startDate": {
"type": "string",
"format": "date-time"
},
"endDate": {
"type": "string",
"format": "date-time"
} }
} }
}, },

View File

@@ -372,6 +372,22 @@ export interface paths {
patch?: never; patch?: never;
trace?: never; trace?: never;
}; };
"/ai/chat/refresh": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
post: operations["createNewConversation"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/ai/action/search": { "/ai/action/search": {
parameters: { parameters: {
query?: never; query?: never;
@@ -730,12 +746,14 @@ export interface components {
/** Format: int64 */ /** Format: int64 */
id: number; id: number;
name: string; name: string;
/** Format: int64 */
parentId?: number;
isBound?: boolean; isBound?: boolean;
}; };
UserQueryDto: { UserQueryDto: {
username?: string; username?: string;
/** Format: date-time */
startDate?: string;
/** Format: date-time */
endDate?: string;
}; };
PageResponseDtoListUserRolePermissionDto: { PageResponseDtoListUserRolePermissionDto: {
/** Format: int64 */ /** Format: int64 */
@@ -1512,6 +1530,24 @@ export interface operations {
}; };
}; };
}; };
createNewConversation: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content?: never;
};
};
};
searchAction: { searchAction: {
parameters: { parameters: {
query?: never; query?: never;

View File

@@ -20,7 +20,7 @@
<button <button
v-if="chatElement.type === 'action' && (chatElement.command === 'CREATE_USER' || chatElement.command === 'CREATE_DEPARTMENT')" v-if="chatElement.type === 'action' && (chatElement.command === 'CREATE_USER' || chatElement.command === 'CREATE_DEPARTMENT')"
type="button" @click="commandActionMap[chatElement.command!]" type="button" @click="commandActionMap[chatElement.command!]"
class="px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"> class="px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300">
{{ {{
commandContentMap[chatElement.command!] commandContentMap[chatElement.command!]
}}</button> }}</button>
@@ -38,6 +38,14 @@
</div> </div>
<form class="sticky"> <form class="sticky">
<button @click.prevent="clearConversation"
class="relative inline-flex items-center justify-center p-0.5 mb-2 me-2
overflow-hidden text-sm font-medium text-gray-900 rounded-lg group bg-gradient-to-br from-purple-600 to-blue-500 group-hover:from-purple-600 group-hover:to-blue-500 hover:text-white focus:ring-4 focus:outline-none focus:ring-blue-300 ">
<span
class="relative px-3 py-2 text-xs font-medium transition-all ease-in duration-75 bg-white rounded-md group-hover:bg-transparent">
开启新对话
</span>
</button>
<div class="w-full border border-gray-200 rounded-lg bg-gray-50"> <div class="w-full border border-gray-200 rounded-lg bg-gray-50">
<div class="px-4 py-2 bg-white rounded-t-lg"> <div class="px-4 py-2 bg-white rounded-t-lg">
<label for="comment" class="sr-only"></label> <label for="comment" class="sr-only"></label>
@@ -103,7 +111,7 @@ import useUserStore from "../composables/store/useUserStore";
import { useUserUpsert } from "../composables/user/useUserUpsert"; import { useUserUpsert } from "../composables/user/useUserUpsert";
import type { UserUpsertSubmitModel } from "../types/user"; import type { UserUpsertSubmitModel } from "../types/user";
const { messages, chat, isLoading, cancel, searchAction, executeAction } = const { messages, chat, isLoading, cancel, searchAction, executeAction, clearConversation } =
useAiChat(); useAiChat();
const { user } = useUserStore(); const { user } = useUserStore();
const userUpsertModal = ref<ModalInterface>(); const userUpsertModal = ref<ModalInterface>();

View File

@@ -117,6 +117,11 @@ export const useAiChat = () => {
} }
}; };
const clearConversation = async () => {
await client.POST("/ai/chat/refresh");
messages.value = [];
};
const cancel = () => { const cancel = () => {
if (currentController) { if (currentController) {
currentController.abort(); currentController.abort();
@@ -124,5 +129,13 @@ export const useAiChat = () => {
} }
}; };
return { messages, chat, isLoading, cancel, searchAction, executeAction }; return {
messages,
chat,
isLoading,
cancel,
searchAction,
executeAction,
clearConversation,
};
}; };