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
80f76e0f
Commit
80f76e0f
authored
Sep 28, 2025
by
weiw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修复收藏页点击新建时的bug
parent
75e4968b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
26 deletions
+43
-26
src/layouts/Navbar/Navbar.tsx
+10
-9
src/pages/Home/HomeNew.tsx
+33
-17
No files found.
src/layouts/Navbar/Navbar.tsx
View file @
80f76e0f
...
@@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom'
...
@@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom'
import
{
useClickAway
,
useSessionStorageState
}
from
'ahooks'
import
{
useClickAway
,
useSessionStorageState
}
from
'ahooks'
import
styles
from
'./Navbar.module.less'
import
styles
from
'./Navbar.module.less'
import
{
NavBarItem
}
from
'./components/NavBarItem'
import
{
NavBarItem
}
from
'./components/NavBarItem'
import
{
clearNavigationFlag
,
createConversation
}
from
'@/store/conversationSlice'
import
{
clearNavigationFlag
}
from
'@/store/conversationSlice'
import
type
{
WithAuthProps
}
from
'@/auth/withAuth'
import
type
{
WithAuthProps
}
from
'@/auth/withAuth'
import
{
withAuth
}
from
'@/auth/withAuth'
import
{
withAuth
}
from
'@/auth/withAuth'
import
{
NAV_BAR_ITEMS
}
from
'@/config/nav'
import
{
NAV_BAR_ITEMS
}
from
'@/config/nav'
...
@@ -24,13 +24,13 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
...
@@ -24,13 +24,13 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
const
{
currentConversationId
,
shouldNavigateToNewConversation
}
=
useAppSelector
(
state
=>
state
.
conversation
)
const
{
currentConversationId
,
shouldNavigateToNewConversation
}
=
useAppSelector
(
state
=>
state
.
conversation
)
const
handleCreateConversation
=
()
=>
{
//
const handleCreateConversation = () => {
dispatch
(
createConversation
({
//
dispatch(createConversation({
conversationData
:
{},
//
conversationData: {},
shouldNavigate
:
true
,
//
shouldNavigate: true,
shouldSendQuestion
:
''
,
//
shouldSendQuestion: '',
}))
//
}))
}
//
}
const
[
isH5NavVisible
,
setIsH5NavVisible
]
=
useState
(
isMobile
())
const
[
isH5NavVisible
,
setIsH5NavVisible
]
=
useState
(
isMobile
())
...
@@ -51,7 +51,8 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
...
@@ -51,7 +51,8 @@ const NavbarBase: React.FC<NavbarProps & WithAuthProps> = ({ isHistoryVisible, c
}
}
if
(
type
===
'add'
)
{
if
(
type
===
'add'
)
{
handleCreateConversation
()
// handleCreateConversation()
navigate
(
'/'
)
onSetHistoryVisible
(
false
)
onSetHistoryVisible
(
false
)
}
}
...
...
src/pages/Home/HomeNew.tsx
View file @
80f76e0f
...
@@ -52,17 +52,6 @@ export const Home: React.FC = () => {
...
@@ -52,17 +52,6 @@ export const Home: React.FC = () => {
const
[
token
,
setToken
]
=
useLocalStorageState
<
string
|
undefined
>
(
'__TOKEN__'
,
{
const
[
token
,
setToken
]
=
useLocalStorageState
<
string
|
undefined
>
(
'__TOKEN__'
,
{
defaultValue
:
''
,
defaultValue
:
''
,
})
})
// 检查当前路径是否包含 "/chat/"
// const showOutlet = location.pathname.includes('/chat/')
// const handleCreateConversation = (question: string) => {
// dispatch(
// createConversation({
// conversationData: {},
// shouldNavigate: true,
// shouldSendQuestion: question,
// }),
// )
// }
/** 获取qa记录 */
/** 获取qa记录 */
const
getQuestionList
=
useCallback
(
async
()
=>
{
const
getQuestionList
=
useCallback
(
async
()
=>
{
...
@@ -128,13 +117,36 @@ export const Home: React.FC = () => {
...
@@ -128,13 +117,36 @@ export const Home: React.FC = () => {
let
res
=
{}
as
any
let
res
=
{}
as
any
if
(
viteOutputObj
===
'inner'
)
{
if
(
viteOutputObj
===
'inner'
)
{
if
(
_loginCode
)
{
res
=
await
fetchLoginByToken
(
_loginCode
)
res
=
await
fetchLoginByToken
(
_loginCode
)
if
(
res
.
data
)
{
setToken
(
res
.
data
.
token
)
// 主动触发 storage 事件,确保其他组件能监听到变化
window
.
dispatchEvent
(
new
StorageEvent
(
'storage'
,
{
key
:
'__TOKEN__'
,
oldValue
:
token
,
newValue
:
res
.
data
.
token
,
url
:
window
.
location
.
href
,
storageArea
:
localStorage
,
}),
)
await
getQuestionList
()
initConversation
()
dispatch
(
fetchConversations
())
}
}
else
{
await
getQuestionList
()
initConversation
()
dispatch
(
fetchConversations
())
}
}
}
else
{
else
{
// 模拟登录 可以用来测试
// 模拟登录 可以用来测试
res
=
await
fetchLoginByUid
(
'123123'
)
res
=
await
fetchLoginByUid
(
'123123'
)
}
if
(
res
.
data
)
{
if
(
res
.
data
)
{
setToken
(
res
.
data
.
token
)
setToken
(
res
.
data
.
token
)
...
@@ -153,12 +165,13 @@ export const Home: React.FC = () => {
...
@@ -153,12 +165,13 @@ export const Home: React.FC = () => {
initConversation
()
initConversation
()
dispatch
(
fetchConversations
())
dispatch
(
fetchConversations
())
}
}
}
},
[
setToken
])
},
[
setToken
])
// 修改 useEffect
// 修改 useEffect
useEffect
(()
=>
{
useEffect
(()
=>
{
login
()
login
()
},
[])
// 依赖数组为空,只在组件挂载时执行一次
},
[])
// 依赖数组为空,只在组件挂载时执行一次
return
(
return
(
<
div
className=
{
styles
.
homePage
}
>
<
div
className=
{
styles
.
homePage
}
>
...
@@ -173,7 +186,10 @@ useEffect(() => {
...
@@ -173,7 +186,10 @@ useEffect(() => {
<
div
className=
"w-full"
>
<
div
className=
"w-full"
>
<
div
className=
"flex justify-center gap-[20px]"
>
<
div
className=
"flex justify-center gap-[20px]"
>
{
/* 左侧区域 - 产品问答和您可以试着问我 */
}
{
/* 左侧区域 - 产品问答和您可以试着问我 */
}
<
div
className=
"flex flex-col gap-[20px] items-center overflow-y-auto scrollbar-hide"
style=
{
{
height
:
'calc(100vh - 64px)'
}
}
>
<
div
className=
"flex flex-col gap-[20px] items-center overflow-y-auto scrollbar-hide"
style=
{
{
height
:
'calc(100vh - 64px)'
}
}
>
<
motion
.
div
className=
"w-full sm:w-auto"
{
...
getAnimationProps
(2)}
>
<
motion
.
div
className=
"w-full sm:w-auto"
{
...
getAnimationProps
(2)}
>
<
QuestionList
<
QuestionList
questions=
{
productQuestions
.
content
}
questions=
{
productQuestions
.
content
}
...
...
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