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
6c761774
Commit
6c761774
authored
Oct 24, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:增加通用模式
parent
174e2c1e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
19 deletions
+36
-19
src/assets/general-icon.png
+0
-0
src/components/ChatEditor/index.tsx
+31
-14
src/pages/Home/HomeNew.tsx
+5
-5
No files found.
src/assets/general-icon.png
0 → 100644
View file @
6c761774
This diff was suppressed by a .gitattributes entry.
src/components/ChatEditor/index.tsx
View file @
6c761774
...
...
@@ -6,6 +6,7 @@ import { LoginModal } from '../LoginModal'
import
type
{
RootState
}
from
'@/store'
import
SendIcon
from
'@/assets/svg/send.svg?react'
import
efficiencyIcon
from
'@/assets/efficiency-icon.png'
import
generalIcon
from
'@/assets/general-icon.png'
import
{
type
WithAuthProps
,
withAuth
}
from
'@/auth/withAuth'
import
{
useAppSelector
}
from
'@/store/hook'
import
{
fetchToolList
}
from
'@/api/home'
...
...
@@ -30,7 +31,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
const
isAsking
=
useAppSelector
((
state
:
RootState
)
=>
state
.
chat
.
isAsking
)
const
[
toolList
,
setToolList
]
=
useState
<
any
[]
>
([])
const
[
selectedToolId
,
setSelectedToolId
]
=
useState
<
string
|
null
>
(
null
)
const
[
isToolBtnActive
,
setIsToolBtnActive
]
=
useState
<
boolean
>
(
fals
e
)
const
[
isToolBtnActive
,
setIsToolBtnActive
]
=
useState
<
boolean
>
(
tru
e
)
// 获取工具列表
const
getToolList
=
async
()
=>
{
...
...
@@ -111,8 +112,8 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
document
.
execCommand
(
'insertText'
,
false
,
text
)
}
// 处理
工具
按钮点击
const
handle
Tool
Click
=
()
=>
{
// 处理
提质增效
按钮点击
const
handle
Efficiency
Click
=
()
=>
{
// 查找"提质增效"工具
const
efficiencyTool
=
toolList
.
find
((
tool
:
any
)
=>
tool
.
toolName
===
'提质增效'
)
let
currentToolId
=
null
...
...
@@ -127,11 +128,18 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
currentToolId
=
toolList
[
0
].
toolId
}
}
// 切换工具按钮状态
const
newToolBtnState
=
!
isToolBtnActive
setIsToolBtnActive
(
newToolBtnState
)
// 调用父组件的回调函数,传递切换后的状态和工具ID
onToolClick
?.(
newToolBtnState
,
currentToolId
)
// 切换到工具模式(false 表示工具模式,会切换左侧展示)
setIsToolBtnActive
(
false
)
// 调用父组件的回调函数,传递工具模式状态和工具ID
onToolClick
?.(
false
,
currentToolId
)
}
// 处理通用模式按钮点击
const
handleGeneralClick
=
()
=>
{
// 切换到通用模式(true 表示通用模式,恢复默认不切换左侧)
setIsToolBtnActive
(
true
)
// 调用父组件的回调函数,传递通用模式状态和工具ID
onToolClick
?.(
false
,
undefined
)
}
useEffect
(()
=>
{
...
...
@@ -146,10 +154,6 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
clearInterval
(
intervalRef
.
current
)
}
document
.
removeEventListener
(
'visibilitychange'
,
handleVisibilityChange
)
// console.log(isAsking, 'isAskingisAsking')
// if (isAsking) {
// dispatch(setIsAsking(false))
// }
}
},
[
content
])
...
...
@@ -250,17 +254,30 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
</Button> */
}
<
Button
className=
{
`w-[96px] h-[32px] px-3 rounded-full shadow-none text-[12px] transition-all duration-200 ${
isToolBtnActive
!
isToolBtnActive
? 'bg-[#F3F7FF] border-[#F3F7FF] text-[#165DFF]'
: 'bg-white border border-[#E6E8EB] text-[#111827]'
}`
}
radius=
"full"
variant=
"bordered"
startContent=
{
<
img
src=
{
efficiencyIcon
}
alt=
"提质增效"
className=
"w-5 h-5"
/>
}
onPress=
{
handle
Tool
Click
}
onPress=
{
handle
Efficiency
Click
}
>
提质增效
</
Button
>
<
Button
className=
{
`w-[96px] h-[32px] px-3 rounded-full shadow-none text-[12px] transition-all duration-200 ${
isToolBtnActive
? 'bg-[#F3F7FF] border-[#F3F7FF] text-[#165DFF]'
: 'bg-white border border-[#E6E8EB] text-[#111827]'
}`
}
radius=
"full"
variant=
"bordered"
startContent=
{
<
img
src=
{
generalIcon
}
alt=
"通用模式"
className=
"w-5 h-5"
/>
}
onPress=
{
handleGeneralClick
}
>
通用模式
</
Button
>
</
div
>
<
LoginModal
onClose=
{
handleCloseLoginModal
}
isOpen=
{
isOpenLoginModal
}
/>
</
div
>
...
...
src/pages/Home/HomeNew.tsx
View file @
6c761774
...
...
@@ -85,7 +85,7 @@ export const Home: React.FC = () => {
// 可以在这里添加错误处理逻辑
console
.
error
(
'Failed to fetch chat records:'
,
error
)
}
finally
{
finally
{
setIsLoading
(
false
)
setIsDataLoaded
(
true
)
}
...
...
@@ -112,8 +112,8 @@ export const Home: React.FC = () => {
// 处理工具按钮点击
const
_handleToolClick
=
useCallback
(
async
(
isToolBtn
:
boolean
,
toolId
?:
string
)
=>
{
if
(
isToolBtn
&&
toolId
)
{
//
当isToolBtn为true时,替换configType为07的数据
if
(
!
isToolBtn
&&
toolId
)
{
//
提质增效模式:只修改左侧页面内容,加载工具相关问题
// 先清空数据,确保显示空数据样式
setOtherQuestions
((
prev
:
any
)
=>
({
...
prev
,
...
...
@@ -136,8 +136,8 @@ export const Home: React.FC = () => {
setIsDataLoaded
(
true
)
// 无论成功失败都标记为已加载
}
}
else
if
(
!
isToolBtn
)
{
//
当isToolBtn为false时,恢复原始的configType为07的数据
else
if
(
isToolBtn
)
{
//
通用模式:恢复刷新时的状态,包括左侧内容也要恢复到初始状态
setOtherQuestions
(
originalOtherQuestions
)
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