Commit 365ac9c9 by zhangxingmin

ai

parent 58a41c40
......@@ -20,17 +20,23 @@
"@element-plus/icons-vue": "2.3.1",
"@vueup/vue-quill": "1.2.0",
"@vueuse/core": "13.3.0",
"ali-oss": "^6.23.0",
"axios": "1.9.0",
"clipboard": "2.0.11",
"dompurify": "^3.3.3",
"echarts": "5.6.0",
"element-plus": "2.9.9",
"file-saver": "2.0.5",
"file-saver": "^2.0.5",
"fuse.js": "6.6.2",
"highlight.js": "^11.11.1",
"js-beautify": "1.14.11",
"js-cookie": "3.0.5",
"jsencrypt": "3.3.2",
"jszip": "^3.10.1",
"lodash-es": "^4.17.21",
"marked": "^4.3.0",
"nprogress": "0.2.0",
"p-limit": "^7.3.0",
"pinia": "3.0.2",
"splitpanes": "^4.0.4",
"vue": "3.5.16",
......
// src/api/ai/ai.js
import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import useUserStore from '@/store/modules/user'
// 加载随机词条列表
export function randList(data) {
return request({
url: '/ai/api/entry/rand/list',
method: 'post',
data: data
})
}
/**
* 查询输出流信息(流式响应)
* @param {string} question 用户问题
* @param {number} timeout 超时时间(毫秒),默认 300000
* @returns {Promise<Response>} fetch 响应对象
*/
export function getStream(question, timeout = 300000) {
const userStore = useUserStore()
const token = getToken()
const tenantId = userStore.currentTenant?.apiLoginTenantInfoResponse?.tenantBizId
const headers = {
'Accept': 'text/event-stream',
'Authorization': `Bearer ${token}`
}
if (tenantId) {
headers['X-Tenant-ID'] = tenantId
}
// 从环境变量获取基础 URL
const baseUrl = import.meta.env.VITE_APP_BASE_API
// 拼接完整 URL(注意:后端实际路径为 /ai/api/ai/stream)
const url = `${baseUrl}/ai/api/api/ai/stream?question=${encodeURIComponent(question)}`
// 使用 AbortController 实现超时控制
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), timeout)
return fetch(url, {
method: 'GET',
headers,
signal: controller.signal
}).finally(() => {
clearTimeout(timeoutId)
})
}
\ No newline at end of file
......@@ -37,6 +37,22 @@ export const constantRoutes = [
}
]
},
// {
// path: '/system',
// component: Layout,
// children: [
// {
// path: 'ai',
// name: 'Ai',
// component: Ai,
// meta: {
// title: '银盾AI',
// icon: 'message' // 【关键修改】补充图标名,避免 undefined
// // 如果项目里有其他 svg 图标,换成对应的文件名(不含.svg)
// }
// }
// ]
// },
{
path: '/login',
component: () => import('@/views/login'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment