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
91c11f7b
Commit
91c11f7b
authored
Apr 17, 2026
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:代码漏洞
parent
d376992e
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
40 deletions
+15
-40
src/components/ChatEditor/index.tsx
+3
-1
src/pages/Chat/Chat.tsx
+0
-6
src/pages/ChatTactics/TacticsChat.tsx
+2
-19
src/pages/ChatTactics/components/TacticsWelcome/index.tsx
+0
-11
src/pages/Collect/Collect.tsx
+8
-1
src/pages/Home/HomeNew.tsx
+2
-2
No files found.
src/components/ChatEditor/index.tsx
View file @
91c11f7b
...
@@ -101,7 +101,9 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
...
@@ -101,7 +101,9 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 监听 storage 事件(跨标签页)
// 监听 storage 事件(跨标签页)
window
.
addEventListener
(
'storage'
,
checkTokenChange
)
window
.
addEventListener
(
'storage'
,
checkTokenChange
)
// 轮询检查(同标签页)
// 轮询检查(同标签页)
const
interval
=
setInterval
(
checkTokenChange
,
100
)
const
interval
=
window
.
setInterval
(()
=>
{
checkTokenChange
()
},
100
)
// 等待最多 1 秒,检测 token 是否变化
// 等待最多 1 秒,检测 token 是否变化
const
waitForChange
=
new
Promise
<
void
>
((
resolve
)
=>
{
const
waitForChange
=
new
Promise
<
void
>
((
resolve
)
=>
{
...
...
src/pages/Chat/Chat.tsx
View file @
91c11f7b
...
@@ -759,12 +759,6 @@ export const Chat: React.FC = () => {
...
@@ -759,12 +759,6 @@ export const Chat: React.FC = () => {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
id
)
{
if
(
id
)
{
console
.
log
(
'[Chat] 路由变化检查:'
,
{
id
,
currentIdRef
:
currentIdRef
.
current
,
locationState
:
location
.
state
,
toolHistoryLoadedId
:
toolHistoryLoadedRef
.
current
.
conversationId
,
})
// 检查是否已通过 toolHistoryLoaded 事件加载过相同会话的数据
// 检查是否已通过 toolHistoryLoaded 事件加载过相同会话的数据
// 如果已加载,跳过接口调用,避免重复请求
// 如果已加载,跳过接口调用,避免重复请求
if
(
toolHistoryLoadedRef
.
current
.
conversationId
===
id
)
{
if
(
toolHistoryLoadedRef
.
current
.
conversationId
===
id
)
{
...
...
src/pages/ChatTactics/TacticsChat.tsx
View file @
91c11f7b
...
@@ -29,18 +29,6 @@ export const TacticsChat: React.FC = () => {
...
@@ -29,18 +29,6 @@ export const TacticsChat: React.FC = () => {
const
{
id
}
=
useParams
<
{
id
:
string
}
>
()
const
{
id
}
=
useParams
<
{
id
:
string
}
>
()
const
location
=
useLocation
()
const
location
=
useLocation
()
const
navigate
=
useNavigate
()
const
navigate
=
useNavigate
()
const
logFullUrl
=
useCallback
((
reason
?:
string
)
=>
{
console
.
log
(
'[TacticsChat] full url snapshot'
,
{
reason
,
href
:
window
.
location
.
href
,
pathname
:
location
.
pathname
,
search
:
location
.
search
,
state
:
location
.
state
,
})
},
[
location
.
pathname
,
location
.
search
,
location
.
state
])
useEffect
(()
=>
{
logFullUrl
(
'mount or location change'
)
},
[
logFullUrl
])
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
)
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
)
const
[
allItems
,
setAllItems
]
=
useState
<
ChatRecord
[]
>
([])
const
[
allItems
,
setAllItems
]
=
useState
<
ChatRecord
[]
>
([])
const
[
historyDividers
,
setHistoryDividers
]
=
useState
<
{
index
:
number
,
time
:
string
}[]
>
([])
const
[
historyDividers
,
setHistoryDividers
]
=
useState
<
{
index
:
number
,
time
:
string
}[]
>
([])
...
@@ -120,12 +108,10 @@ export const TacticsChat: React.FC = () => {
...
@@ -120,12 +108,10 @@ export const TacticsChat: React.FC = () => {
return
undefined
return
undefined
}
}
// 打印完整链接
// 打印完整链接
console
.
log
(
'[TacticsChat] from=tactics&place=order 完整链接:'
,
window
.
location
.
href
)
const
workOrderIds
=
searchParams
.
get
(
'workOrderIds'
)
const
workOrderIds
=
searchParams
.
get
(
'workOrderIds'
)
const
result
=
{
const
result
=
{
workOrderIds
:
workOrderIds
!==
null
?
workOrderIds
:
undefined
,
workOrderIds
:
workOrderIds
!==
null
?
workOrderIds
:
undefined
,
}
}
console
.
log
(
'[TacticsChat] orderMeta result:'
,
result
)
// 如果 URL 中有 workOrderIds 参数(包括空字符串),则使用它;否则为 undefined
// 如果 URL 中有 workOrderIds 参数(包括空字符串),则使用它;否则为 undefined
return
result
return
result
},
[
searchParams
])
},
[
searchParams
])
...
@@ -133,7 +119,6 @@ export const TacticsChat: React.FC = () => {
...
@@ -133,7 +119,6 @@ export const TacticsChat: React.FC = () => {
// 仅用于创建会话的额外参数(create_conversation)
// 仅用于创建会话的额外参数(create_conversation)
const
getConversationExtra
=
useCallback
(()
=>
{
const
getConversationExtra
=
useCallback
(()
=>
{
if
(
orderMeta
)
{
if
(
orderMeta
)
{
console
.
log
(
'orderMeta'
,
orderMeta
)
// 从 localStorage 读取 userId
// 从 localStorage 读取 userId
const
userIdFromStorage
=
safeLocalStorageGetItem
(
'__USER_NAME__'
)
const
userIdFromStorage
=
safeLocalStorageGetItem
(
'__USER_NAME__'
)
let
userId
=
''
let
userId
=
''
...
@@ -840,10 +825,9 @@ export const TacticsChat: React.FC = () => {
...
@@ -840,10 +825,9 @@ export const TacticsChat: React.FC = () => {
// 重新拉取会话列表,保持原有行为
// 重新拉取会话列表,保持原有行为
await
dispatch
(
fetchTacticsConversations
())
await
dispatch
(
fetchTacticsConversations
())
if
(
currentIdRef
.
current
)
{
if
(
currentIdRef
.
current
)
{
logFullUrl
(
'before navigate reanalyze'
)
navigate
(
`/tactics/chat/
${
currentIdRef
.
current
}${
location
.
search
}
`
)
navigate
(
`/tactics/chat/
${
currentIdRef
.
current
}${
location
.
search
}
`
)
}
}
},
[
dispatch
,
navigate
,
handleSubmitQuestion
,
orderMeta
,
userMeta
,
getNumberTypeWithUserMeta
,
isLoading
,
isAsking
,
lo
gFullUrl
,
lo
cation
.
search
])
},
[
dispatch
,
navigate
,
handleSubmitQuestion
,
orderMeta
,
userMeta
,
getNumberTypeWithUserMeta
,
isLoading
,
isAsking
,
location
.
search
])
const
handleCancelClear
=
useCallback
(()
=>
{
const
handleCancelClear
=
useCallback
(()
=>
{
setShowClearConfirm
(
false
)
setShowClearConfirm
(
false
)
...
@@ -988,7 +972,6 @@ export const TacticsChat: React.FC = () => {
...
@@ -988,7 +972,6 @@ export const TacticsChat: React.FC = () => {
// 创建新会话成功后跳转到新会话页面
// 创建新会话成功后跳转到新会话页面
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
shouldNavigateToNewConversation
&&
currentConversationId
)
{
if
(
shouldNavigateToNewConversation
&&
currentConversationId
)
{
logFullUrl
(
'before navigate create new conversation'
)
navigate
(
`/tactics/chat/
${
currentConversationId
}${
location
.
search
}
`
,
{
navigate
(
`/tactics/chat/
${
currentConversationId
}${
location
.
search
}
`
,
{
state
:
{
state
:
{
shouldSendQuestion
:
shouldSendQuestionFromState
,
shouldSendQuestion
:
shouldSendQuestionFromState
,
...
@@ -997,7 +980,7 @@ export const TacticsChat: React.FC = () => {
...
@@ -997,7 +980,7 @@ export const TacticsChat: React.FC = () => {
})
})
dispatch
(
clearTacticsNavigationFlag
())
dispatch
(
clearTacticsNavigationFlag
())
}
}
},
[
shouldNavigateToNewConversation
,
currentConversationId
,
navigate
,
dispatch
,
shouldSendQuestionFromState
,
location
.
search
,
logFullUrl
])
},
[
shouldNavigateToNewConversation
,
currentConversationId
,
navigate
,
dispatch
,
shouldSendQuestionFromState
,
location
.
search
])
// 处理shouldSendQuestion的变化 - 自动发送问题
// 处理shouldSendQuestion的变化 - 自动发送问题
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
src/pages/ChatTactics/components/TacticsWelcome/index.tsx
View file @
91c11f7b
...
@@ -15,17 +15,6 @@ export const TacticsWelcome: React.FC<TacticsWelcomeProps> = ({ cleared }) => {
...
@@ -15,17 +15,6 @@ export const TacticsWelcome: React.FC<TacticsWelcomeProps> = ({ cleared }) => {
const
from
=
searchParams
.
get
(
'from'
)
const
from
=
searchParams
.
get
(
'from'
)
const
place
=
searchParams
.
get
(
'place'
)
const
place
=
searchParams
.
get
(
'place'
)
const
isOrderPlace
=
from
===
'tactics'
&&
place
===
'order'
const
isOrderPlace
=
from
===
'tactics'
&&
place
===
'order'
// 打印路由参数
console
.
log
(
'TacticsWelcome 路由参数:'
,
{
searchParams
:
Object
.
fromEntries
(
searchParams
.
entries
()),
from
,
place
,
isOrderPlace
,
cleared
,
url
:
window
.
location
.
href
,
})
const
welcomeText
=
cleared
const
welcomeText
=
cleared
?
'暂无分析记录,点击右上方按钮开始新的分析吧!'
?
'暂无分析记录,点击右上方按钮开始新的分析吧!'
:
isOrderPlace
:
isOrderPlace
...
...
src/pages/Collect/Collect.tsx
View file @
91c11f7b
...
@@ -91,8 +91,15 @@ export const Collect: React.FC = () => {
...
@@ -91,8 +91,15 @@ export const Collect: React.FC = () => {
navigate
(
-
1
)
navigate
(
-
1
)
return
return
}
}
const
conversationId
=
sessionStorage
.
getItem
(
'currentConversationId'
)
||
''
const
rawConversationId
=
sessionStorage
.
getItem
(
'currentConversationId'
)
||
''
// 仅允许常见会话 ID 字符,避免可控输入直接参与路由拼接
if
(
/^
[\w
-
]
+$/
.
test
(
rawConversationId
))
{
const
conversationId
=
encodeURIComponent
(
rawConversationId
)
navigate
(
`/chat/
${
conversationId
}
`
,
{
state
:
{
fromCollect
:
true
}
})
navigate
(
`/chat/
${
conversationId
}
`
,
{
state
:
{
fromCollect
:
true
}
})
return
}
// 无效 ID 时保持原有目标页(等价于 conversationId 为空时的 /chat/)
navigate
(
'/chat/'
,
{
state
:
{
fromCollect
:
true
}
})
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
src/pages/Home/HomeNew.tsx
View file @
91c11f7b
...
@@ -305,8 +305,8 @@ export const Home: React.FC = () => {
...
@@ -305,8 +305,8 @@ export const Home: React.FC = () => {
setIsDataLoaded
(
false
)
setIsDataLoaded
(
false
)
fetchBusinessInsightQuestions
()
fetchBusinessInsightQuestions
()
.
catch
((
error
)
=>
{
.
catch
(()
=>
{
console
.
error
(
'[HomeNew] 业务洞察常见问题获取失败
:'
,
error
)
console
.
error
(
'[HomeNew] 业务洞察常见问题获取失败
'
)
})
})
.
finally
(()
=>
{
.
finally
(()
=>
{
setIsDataLoaded
(
true
)
setIsDataLoaded
(
true
)
...
...
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