Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sdream-ai-fe
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
0
Merge Requests
0
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
侯明涛
sdream-ai-fe
Commits
63732688
Commit
63732688
authored
Nov 13, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:运行报错
parent
396bb0c0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
3 deletions
+28
-3
pnpm-lock.yaml
+0
-0
pnpm-workspace.yaml
+6
-1
src/api/chat.ts
+10
-1
src/routes/RouteChangeHandler.tsx
+12
-1
No files found.
pnpm-lock.yaml
0 → 100644
View file @
63732688
This source diff could not be displayed because it is too large. You can
view the blob
instead.
pnpm-workspace.yaml
View file @
63732688
packages
:
-
'
fixtures/*'
-
fixtures/*
ignoredBuiltDependencies
:
-
core-js
-
simple-git-hooks
-
unrs-resolver
src/api/chat.ts
View file @
63732688
...
...
@@ -68,11 +68,20 @@ export function fetchStreamResponse(url: string, body: Record<string, any>, onMe
})
})
}
const
tokenStr
=
window
.
localStorage
.
getItem
(
'__TOKEN__'
)
||
'""'
let
token
=
''
try
{
token
=
JSON
.
parse
(
tokenStr
)
}
catch
{
token
=
''
}
fetch
(
url
,
{
headers
:
{
'accept'
:
'text/event-stream'
,
'Content-Type'
:
'application/json'
,
'X-Token'
:
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'__TOKEN__'
)
||
''
)
,
'X-Token'
:
token
,
},
method
:
'POST'
,
body
:
JSON
.
stringify
(
body
),
...
...
src/routes/RouteChangeHandler.tsx
View file @
63732688
...
...
@@ -27,7 +27,18 @@ export function withRouteChangeHandler(WrappedComponent: React.ComponentType) {
else
if
(
location
.
pathname
.
startsWith
(
'/chat/'
))
{
const
conversationId
=
location
.
pathname
.
split
(
'/'
)[
2
]
if
(
!
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'__TOKEN__'
)
||
''
))
{
const
tokenStr
=
window
.
localStorage
.
getItem
(
'__TOKEN__'
)
||
'""'
let
token
=
''
try
{
token
=
JSON
.
parse
(
tokenStr
)
}
catch
{
// 如果解析失败,说明没有有效的 token
navigate
(
'/'
)
return
// 提前返回,不执行后续的 dispatch
}
if
(
!
token
)
{
// 如果没有有效的 token,重定向到首页
navigate
(
'/'
)
return
// 提前返回,不执行后续的 dispatch
...
...
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