feat: Assistant api

This commit is contained in:
fit2cloud-chenyw
2025-07-09 18:29:07 +08:00
parent 32f0495f91
commit 4bd69b845f
9 changed files with 212 additions and 8 deletions
+11
View File
@@ -0,0 +1,11 @@
import { request } from '@/utils/request'
export const assistantApi = {
queryAll: (keyword?: string) =>
request.get('/system/assistant', { params: keyword ? { keyword } : {} }),
add: (data: any) => request.post('/system/assistant', data),
edit: (data: any) => request.put('/system/assistant', data),
delete: (id: number) => request.delete(`/system/assistant/${id}`),
query: (id: number) => request.get(`/system/assistant/${id}`),
validate: (id: any) => request.get(`/system/assistant/validator/${id}`),
}
+2 -2
View File
@@ -6,12 +6,12 @@ const router = createRouter({
history: createWebHashHistory(),
routes: [
{
path: '/',
path: '/:id',
name: 'index',
component: assistant,
},
{
path: '/assistant',
path: '/assistant:id',
name: 'assistant',
component: assistant,
},
+20 -2
View File
@@ -8,7 +8,7 @@
<h4>SQLBot 小助手</h4>
</div>
</div>
<chat-component ref="chatRef" class="sqlbot-chat-container" />
<chat-component v-if="!loading" ref="chatRef" class="sqlbot-chat-container" />
</div>
<div class="sqlbot-top-btn">
<el-icon style="cursor: pointer" @click="openHistory">
@@ -54,12 +54,17 @@
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { onBeforeMount, ref } from 'vue'
import ChatComponent from '@/views/chat/index.vue'
import AssistantGif from '@/assets/img/assistant.gif'
import history from '@/assets/svg/chart/history.svg'
import IconOpeEdit from '@/assets/svg/operate/ope-edit.svg'
import IconOpeDelete from '@/assets/svg/operate/ope-delete.svg'
import { useRoute } from 'vue-router'
import { assistantApi } from '@/api/assistant'
import { useUserStore } from '@/stores/user'
const userStore = useUserStore()
const route = useRoute()
const chatRef = ref()
const chatList = ref<Array<any>>([])
@@ -81,6 +86,19 @@ const EditPen = (chat: any) => {
const Delete = (chat: any) => {
chatRef.value?.onChatDeleted(chat.id)
}
const validator = ref({
id: '',
valid: false,
id_match: false,
token: '',
})
const loading = ref(true)
onBeforeMount(async () => {
const assistantId = route.params.id
validator.value = await assistantApi.validate(assistantId)
userStore.setToken(validator.value.token)
loading.value = false
})
</script>
<style lang="less" scoped>