Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-middle-front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-middle-front
Commits
e52639b8
Commit
e52639b8
authored
Apr 01, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p
parent
76387c42
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
6 deletions
+46
-6
src/api/ai/ai.js
+46
-6
src/views/ai/index.vue
+0
-0
No files found.
src/api/ai/ai.js
View file @
e52639b8
...
...
@@ -14,9 +14,6 @@ export function randList(data) {
/**
* 查询输出流信息(流式响应)
* @param {string} question 用户问题
* @param {number} timeout 超时时间(毫秒),默认 300000
* @returns {Promise<Response>} fetch 响应对象
*/
export
function
getStream
(
question
,
timeout
=
300000
)
{
const
userStore
=
useUserStore
()
...
...
@@ -31,12 +28,9 @@ export function getStream(question, timeout = 300000) {
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
)
...
...
@@ -47,4 +41,49 @@ export function getStream(question, timeout = 300000) {
}).
finally
(()
=>
{
clearTimeout
(
timeoutId
)
})
}
/**
* 获取服务卡片列表(产品列表)
*/
export
async
function
getServiceCardList
()
{
const
userStore
=
useUserStore
()
const
token
=
getToken
()
// 根据实际 store 获取 userId,如果不存在则使用默认值(示例中为 '30')
const
userId
=
userStore
.
userInfo
?.
userId
||
userStore
.
userId
||
'30'
// 处理 token 格式(去掉 "Bearer " 前缀)
let
cleanToken
=
token
if
(
token
&&
token
.
startsWith
(
'Bearer '
))
{
cleanToken
=
token
.
slice
(
7
)
}
const
headers
=
{
'Content-Type'
:
'application/json'
,
'x-authorization'
:
`sfpfamilyfinancialplanning
${
cleanToken
}
`
}
const
url
=
'https://hoservice.ydhomeoffice.cn/hoserviceApi/ydServiceCard/serviceCardList'
const
body
=
{
userId
:
String
(
userId
),
cardType
:
'11'
}
try
{
const
response
=
await
fetch
(
url
,
{
method
:
'POST'
,
headers
:
headers
,
body
:
JSON
.
stringify
(
body
)
})
if
(
!
response
.
ok
)
{
throw
new
Error
(
`HTTP
${
response
.
status
}
:
${
response
.
statusText
}
`
)
}
const
data
=
await
response
.
json
()
return
data
}
catch
(
error
)
{
console
.
error
(
'获取服务卡片列表失败:'
,
error
)
throw
error
}
}
\ No newline at end of file
src/views/ai/index.vue
View file @
e52639b8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment