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
b4204fda
Commit
b4204fda
authored
Dec 22, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:工具按钮将“通用模型”改为“制度活化”&&按钮顺序
parent
6d1bb26e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
27 deletions
+27
-27
src/api/mock/home.ts
+1
-1
src/components/ChatEditor/index.tsx
+11
-11
src/layouts/HistoryBar/components/HistoryBarList/index.tsx
+1
-1
src/pages/Chat/Chat.tsx
+7
-7
src/pages/Home/HomeNew.tsx
+7
-7
No files found.
src/api/mock/home.ts
View file @
b4204fda
...
...
@@ -69,7 +69,7 @@
// },
// {
// toolId: 'general-mode',
// toolName: '
通用模式
',
// toolName: '
制度活化
',
// toolContent: 'https://sit-wechat.guominpension.com/underwrite',
// toolIcon: 'http://p-cf-co-1255000025.cos.bj.csyun001.ccbcos.co/tool-normal.svg',
// toolType: '01',
...
...
src/components/ChatEditor/index.tsx
View file @
b4204fda
...
...
@@ -114,13 +114,13 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
useEffect
(()
=>
{
const
syncSessionToolId
=
()
=>
{
const
storedToolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
// 如果 currentToolId 是空字符串,视为 null,确保
通用模式
能正确高亮
// 如果 currentToolId 是空字符串,视为 null,确保
制度活化
能正确高亮
setSessionToolId
(
storedToolId
&&
storedToolId
.
trim
()
?
storedToolId
:
null
)
}
syncSessionToolId
()
window
.
addEventListener
(
'storage'
,
syncSessionToolId
)
// 监听强制重置为
通用模式
的事件(登录成功后触发)
// 监听强制重置为
制度活化
的事件(登录成功后触发)
const
handleForceReset
=
()
=>
{
// 强制同步 sessionStorage(此时应该已经被清除了)
syncSessionToolId
()
...
...
@@ -128,7 +128,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
if
(
currentToolId
)
{
dispatch
(
clearCurrentToolId
())
}
// 强制设置为
通用模式
// 强制设置为
制度活化
setSelectedToolId
(
null
)
setIsToolBtnActive
(
true
)
}
...
...
@@ -143,7 +143,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 当路由变化时,同步更新 sessionToolId(因为 storage 事件不会在同标签页触发)
useEffect
(()
=>
{
const
storedToolId
=
safeSessionStorageGetItem
(
'currentToolId'
)
// 如果 currentToolId 是空字符串,视为 null,确保
通用模式
能正确高亮
// 如果 currentToolId 是空字符串,视为 null,确保
制度活化
能正确高亮
setSessionToolId
(
storedToolId
&&
storedToolId
.
trim
()
?
storedToolId
:
null
)
// 当路由切换(如点击历史记录)时,同步最新的 sessionStorage,避免同标签页删除后状态不同步
},
[
toolIdFromUrl
,
location
.
pathname
])
...
...
@@ -176,7 +176,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
return
if
(
checkAuth
())
{
if
(
content
.
trim
())
{
// 只在提质增效模式下传递 toolId,
通用模式
不传
// 只在提质增效模式下传递 toolId,
制度活化
不传
let
toolId
:
string
|
undefined
if
(
selectedToolId
)
{
...
...
@@ -184,7 +184,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
toolId
=
selectedToolId
}
else
{
//
通用模式
:不传递 toolId
//
制度活化
:不传递 toolId
toolId
=
undefined
}
onSubmit
?.(
content
.
trim
(),
toolId
)
...
...
@@ -214,7 +214,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
document
.
execCommand
(
'insertText'
,
false
,
text
)
}
// 处理
通用模式
按钮点击:先创建新会话
// 处理
制度活化
按钮点击:先创建新会话
const
handleGeneralClick
=
async
()
=>
{
if
(
!
checkAuth
())
return
...
...
@@ -228,7 +228,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
setSessionToolId
(
null
)
setShowToolQuestion
(
false
)
// 先通知上层更新欢迎语(即便后续接口异常也能生效)
onToolClick
?.(
true
,
undefined
,
'
通用模式
'
,
false
)
onToolClick
?.(
true
,
undefined
,
'
制度活化
'
,
false
)
// 清空路由中的 toolId 参数
if
(
toolIdFromUrl
)
{
const
newSearchParams
=
new
URLSearchParams
(
searchParams
)
...
...
@@ -402,8 +402,8 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
const
toolIdStr
=
String
(
tool
.
toolId
)
const
isSelectedByState
=
selectedToolId
&&
toolIdStr
===
String
(
selectedToolId
)
const
isSelectedBySession
=
!
selectedToolId
&&
sessionToolId
&&
toolIdStr
===
String
(
sessionToolId
)
//
通用模式
高亮:路由内没有 toolId 或 toolId 为空时默认高亮,点击后也要高亮
const
isGeneralMode
=
tool
.
toolName
===
'
通用模式
'
&&
isToolBtnActive
&&
!
selectedToolId
&&
!
sessionToolId
&&
!
toolIdFromUrl
//
制度活化
高亮:路由内没有 toolId 或 toolId 为空时默认高亮,点击后也要高亮
const
isGeneralMode
=
tool
.
toolName
===
'
制度活化
'
&&
isToolBtnActive
&&
!
selectedToolId
&&
!
sessionToolId
&&
!
toolIdFromUrl
const
isSelected
=
isSelectedByState
||
isSelectedBySession
||
isGeneralMode
const
baseBtnClass
...
...
@@ -418,7 +418,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
// 高亮状态直接返回,避免重复触发
if
(
isSelected
)
return
if
(
tool
.
toolName
===
'
通用模式
'
)
if
(
tool
.
toolName
===
'
制度活化
'
)
await
handleGeneralClick
()
else
await
handleToolClick
(
tool
)
...
...
src/layouts/HistoryBar/components/HistoryBarList/index.tsx
View file @
b4204fda
...
...
@@ -53,7 +53,7 @@ export const HistoryBarList: React.FC<HistoryBarListProps> = ({ searchValue, onS
// 通知首页根据对应 toolId 重新拉取常见问题(与底部工具按钮保持一致逻辑)
window
.
dispatchEvent
(
new
CustomEvent
(
'toolButtonClick'
,
{
detail
:
{
// 有 toolId 表示工具模式,没 toolId 表示
通用模式
// 有 toolId 表示工具模式,没 toolId 表示
制度活化
isToolBtn
:
!
conversation
.
toolId
,
toolId
:
conversation
.
toolId
||
''
,
toolName
:
''
,
...
...
src/pages/Chat/Chat.tsx
View file @
b4204fda
...
...
@@ -63,7 +63,7 @@ export const Chat: React.FC = () => {
const
toolIdFromStateRef
=
useRef
<
string
|
null
|
undefined
>
(
undefined
)
// 当外部系统直接以 /chat/:id 链接进入(没有 location.state,且 URL 中也没有 toolId)时,
// 视为一次新的会话入口:重置为
通用模式
,清除历史遗留的工具模式状态
// 视为一次新的会话入口:重置为
制度活化
,清除历史遗留的工具模式状态
useEffect
(()
=>
{
if
(
!
location
.
state
&&
!
rawToolIdFromUrl
)
{
// 20251211 调试:无 URL、无 state 时清除 toolId
...
...
@@ -95,7 +95,7 @@ export const Chat: React.FC = () => {
currentUrl
.
searchParams
.
delete
(
'toolId'
)
window
.
history
.
replaceState
({},
''
,
currentUrl
.
toString
())
}
// 4. 触发自定义事件,通知 ChatEditor 强制重置为
通用模式
// 4. 触发自定义事件,通知 ChatEditor 强制重置为
制度活化
window
.
dispatchEvent
(
new
CustomEvent
(
'forceResetToGeneralMode'
))
// 同步 react-router 的 searchParams 状态
...
...
@@ -450,10 +450,10 @@ export const Chat: React.FC = () => {
}
else
{
// 如果 qaRecords 和 conversation 中都没有 toolId
// 如果有历史记录但没有 toolId,说明是
通用模式
,应该清除
// 如果有历史记录但没有 toolId,说明是
制度活化
,应该清除
if
(
hasQaRecords
&&
currentToolId
)
{
// eslint-disable-next-line no-console
console
.
log
(
'[Chat] 清除 toolId (qaRecords 中有记录但没有 toolId,
通用模式
)'
)
console
.
log
(
'[Chat] 清除 toolId (qaRecords 中有记录但没有 toolId,
制度活化
)'
)
dispatch
(
clearCurrentToolId
())
}
// 如果没有历史记录,可能是新会话,但如果 Redux 中已经有 toolId(从 HistoryBarList 设置的),暂时保留
...
...
@@ -536,8 +536,8 @@ export const Chat: React.FC = () => {
}
}
else
{
//
通用模式
setCurrentToolName
(
'
通用模式
'
)
//
制度活化
setCurrentToolName
(
'
制度活化
'
)
}
}
getToolNameFromToolId
()
...
...
@@ -555,7 +555,7 @@ export const Chat: React.FC = () => {
dispatch
(
setCurrentToolId
(
toolId
))
}
else
{
//
通用模式
,清除 toolId
//
制度活化
,清除 toolId
dispatch
(
clearCurrentToolId
())
}
}
...
...
src/pages/Home/HomeNew.tsx
View file @
b4204fda
...
...
@@ -112,7 +112,7 @@ export const Home: React.FC = () => {
// 处理工具按钮点击
const
_handleToolClick
=
useCallback
(
async
(
isToolBtn
:
boolean
,
toolId
?:
string
,
ignoreUrlToolId
?:
boolean
)
=>
{
// 提质增效模式 / 数据助手 /
通用模式
:都先清空数据,重新拉常见问题
// 提质增效模式 / 数据助手 /
制度活化
:都先清空数据,重新拉常见问题
setOtherQuestions
((
prev
:
any
)
=>
({
...
prev
,
content
:
[],
...
...
@@ -132,7 +132,7 @@ export const Home: React.FC = () => {
let
finalToolId
=
toolId
||
''
// 场景:首页首次挂载(ignoreUrlToolId === true)且为
通用模式
(!isToolBtn && !toolId)
// 场景:首页首次挂载(ignoreUrlToolId === true)且为
制度活化
(!isToolBtn && !toolId)
// 此时无论 sessionStorage 中是否残留上一次的 toolId,都强制使用空字符串,避免带入历史工具 ID
if
(
ignoreUrlToolId
&&
!
isToolBtn
&&
!
toolId
)
{
finalToolId
=
''
...
...
@@ -141,7 +141,7 @@ export const Home: React.FC = () => {
finalToolId
=
''
}
else
if
(
!
finalToolId
&&
!
isToolBtn
)
{
// 仅在工具模式下才使用回退逻辑,避免
通用模式
误用上一次的 toolId
// 仅在工具模式下才使用回退逻辑,避免
制度活化
误用上一次的 toolId
finalToolId
=
storedToolId
}
...
...
@@ -186,7 +186,7 @@ export const Home: React.FC = () => {
dispatch
(
setCurrentToolId
(
toolId
))
}
else
{
//
通用模式
,清除 toolId
//
制度活化
,清除 toolId
dispatch
(
clearCurrentToolId
())
}
...
...
@@ -242,7 +242,7 @@ export const Home: React.FC = () => {
storageArea
:
localStorage
,
}),
)
// 触发自定义事件,通知 ChatEditor 强制重置为
通用模式
// 触发自定义事件,通知 ChatEditor 强制重置为
制度活化
window
.
dispatchEvent
(
new
CustomEvent
(
'forceResetToGeneralMode'
))
initConversation
()
dispatch
(
fetchConversations
())
...
...
@@ -278,7 +278,7 @@ export const Home: React.FC = () => {
storageArea
:
localStorage
,
}),
)
// 触发自定义事件,通知 ChatEditor 强制重置为
通用模式
// 触发自定义事件,通知 ChatEditor 强制重置为
制度活化
window
.
dispatchEvent
(
new
CustomEvent
(
'forceResetToGeneralMode'
))
initConversation
()
dispatch
(
fetchConversations
())
...
...
@@ -301,7 +301,7 @@ export const Home: React.FC = () => {
// 只有登录成功(拿到 token)后才拉业务接口
if
(
!
token
)
return
// 首页首次挂载时重置为
通用模式
:
// 首页首次挂载时重置为
制度活化
:
// 1. 清除 Redux 中的 currentToolId
dispatch
(
clearCurrentToolId
())
},
[
token
,
dispatch
,
_handleToolClick
])
...
...
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