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
7632c25c
Commit
7632c25c
authored
Aug 28, 2025
by
weiw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:根据环境变量控制显示的图标
parent
d42546d4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
34 deletions
+64
-34
src/assets/ai-icon.png
+0
-0
src/pages/Chat/Chat.tsx
+1
-1
src/pages/Chat/components/ChatItem/ChatAnswerBox.tsx
+35
-16
src/pages/Chat/components/ChatWelcome/index.tsx
+4
-1
src/pages/Home/HomeNew.tsx
+24
-16
No files found.
src/assets/ai-icon.png
0 → 100644
View file @
7632c25c
This diff was suppressed by a .gitattributes entry.
src/pages/Chat/Chat.tsx
View file @
7632c25c
...
...
@@ -136,7 +136,7 @@ export const Chat: React.FC = () => {
abortControllerRef
.
current
=
new
AbortController
()
let
fetchUrl
=
`/conversation/api/conversation/mobile/v1/submit_question_stream`
const
proxy
=
import
.
meta
.
env
.
MODE
===
'dev
'
?
'/api'
:
'/dev-sdream-api'
const
proxy
=
import
.
meta
.
env
.
MODE
!==
'prod
'
?
'/api'
:
'/dev-sdream-api'
fetchUrl
=
proxy
+
fetchUrl
fetchStreamResponse
(
...
...
src/pages/Chat/components/ChatItem/ChatAnswerBox.tsx
View file @
7632c25c
...
...
@@ -6,6 +6,7 @@ import { ChatAnswerRecommend } from './ChatAnswerRecommend'
import
{
ChatMaxCount
}
from
'./ChatMaxCount'
import
type
{
Answer
,
ChatRecord
}
from
'@/types/chat'
import
AvatarBot
from
'@/assets/avatarBot.png'
import
AIIcon
from
'@/assets/ai-icon.png'
import
{
useAppDispatch
}
from
'@/store/hook'
import
{
setIsAsking
}
from
'@/store/chatSlice'
import
SdreamLoading
from
'@/components/SdreamLoading'
...
...
@@ -24,6 +25,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
const
[
innerRecord
,
setInnerRecord
]
=
useState
<
ChatRecord
>
(
record
)
const
[
isTyping
,
setIsTyping
]
=
useState
(
false
)
const
dispatch
=
useAppDispatch
()
const
viteOutputObj
=
import
.
meta
.
env
.
VITE_OUTPUT_OBJ
||
'open'
const
handleTyping
=
()
=>
{
setIsTyping
(
true
)
...
...
@@ -53,21 +55,40 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
index
===
showIndex
&&
(
<
div
className=
"chatItemBotContainer w-full"
key=
{
`${item.recordId}-${index}`
}
>
<
div
className=
"flex"
>
<
Avatar
className=
"sm:mr-[20px] hidden sm:block flex-shrink-0"
src=
{
AvatarBot
}
/>
<
Avatar
className=
"sm:mr-[20px] hidden sm:block flex-shrink-0"
src=
{
viteOutputObj
===
'inner'
?
AIIcon
:
AvatarBot
}
/>
<
div
style=
{
{
background
:
'#F7FAFD'
}
}
className=
"rounded-[20px] box-border px-[16px] py-[12px] sm:px-[24px] sm:py-[20px] relative"
>
{
(
item
.
answer
?.
length
||
item
.
cardList
?.
length
)
?
(
<
div
className=
"content"
>
{
item
.
isShow
&&
<
ChatAnswerShower
onSubmitQuestion=
{
onSubmitQuestion
}
isLastAnswer=
{
isLastAnswer
}
answer=
{
item
}
/>
}
{
!
item
.
isShow
&&
!
item
.
isChatMaxCount
&&
<
ChatAnswerParser
onSubmitQuestion=
{
onSubmitQuestion
}
isLastAnswer=
{
isLastAnswer
}
isStopTyping=
{
item
.
isStopTyping
}
onTyping=
{
handleTyping
}
onComplate=
{
()
=>
handleComplate
(
item
)
}
answer=
{
item
}
/>
}
{
!
item
.
isShow
&&
item
.
isChatMaxCount
&&
<
ChatMaxCount
/>
}
</
div
>
)
:
<
SdreamLoading
/>
}
{
item
.
answer
?.
length
||
item
.
cardList
?.
length
?
(
<
div
className=
"content"
>
{
item
.
isShow
&&
(
<
ChatAnswerShower
onSubmitQuestion=
{
onSubmitQuestion
}
isLastAnswer=
{
isLastAnswer
}
answer=
{
item
}
/>
)
}
{
!
item
.
isShow
&&
!
item
.
isChatMaxCount
&&
(
<
ChatAnswerParser
onSubmitQuestion=
{
onSubmitQuestion
}
isLastAnswer=
{
isLastAnswer
}
isStopTyping=
{
item
.
isStopTyping
}
onTyping=
{
handleTyping
}
onComplate=
{
()
=>
handleComplate
(
item
)
}
answer=
{
item
}
/>
)
}
{
!
item
.
isShow
&&
item
.
isChatMaxCount
&&
<
ChatMaxCount
/>
}
</
div
>
)
:
(
<
SdreamLoading
/>
)
}
</
div
>
<
div
className=
"hidden sm:block w-[65px] flex-shrink-0"
></
div
>
</
div
>
...
...
@@ -79,11 +100,9 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
</
div
>
)
}
{
isLastAnswer
&&
!
item
.
isChatMaxCount
&&
isShowRecommend
&&
recommendUseAnswer
&&
<
ChatAnswerRecommend
onSubmitQuestion=
{
onSubmitQuestion
}
answer=
{
recommendUseAnswer
}
/>
}
{
isLastAnswer
&&
!
item
.
isChatMaxCount
&&
isShowRecommend
&&
recommendUseAnswer
&&
(
<
ChatAnswerRecommend
onSubmitQuestion=
{
onSubmitQuestion
}
answer=
{
recommendUseAnswer
}
/>
)
}
<
div
className=
"h-[20px] sm:h-[32px] w-full"
></
div
>
</
div
>
)
...
...
src/pages/Chat/components/ChatWelcome/index.tsx
View file @
7632c25c
import
{
Avatar
}
from
'@heroui/react'
import
{
motion
}
from
'framer-motion'
import
AvatarBot
from
'@/assets/avatarBot.png'
import
AIIcon
from
'@/assets/ai-icon.png'
export
const
ChatWelcome
:
React
.
FC
=
()
=>
{
const
viteOutputObj
=
import
.
meta
.
env
.
VITE_OUTPUT_OBJ
||
'open'
return
(
<
div
className=
"chatWelcomeContainer w-full"
>
<
div
className=
"h-[20px] sm:h-[32px] w-full"
></
div
>
<
div
className=
"flex"
>
<
Avatar
className=
"mr-[12px] hidden sm:block flex-shrink-0"
src=
{
AvatarBot
}
/>
<
Avatar
className=
"mr-[12px] hidden sm:block flex-shrink-0"
src=
{
viteOutputObj
===
'inner'
?
AIIcon
:
AvatarBot
}
/>
<
motion
.
div
className=
"sm:ml-[20px] rounded-[20px] box-border px-[16px] py-[16px] sm:px-[24px] sm:py-[20px]"
style=
{
{
background
:
'#F7FAFD'
}
}
...
...
src/pages/Home/HomeNew.tsx
View file @
7632c25c
...
...
@@ -11,8 +11,7 @@ import { createConversation, fetchConversations } from '@/store/conversationSlic
import
{
useAppDispatch
}
from
'@/store/hook'
import
{
fetchQuestionList
}
from
'@/api/home'
import
SdreamLoading
from
'@/components/SdreamLoading'
// import { fetchLoginByToken } from '@/api/common'
import
{
fetchLoginByUid
}
from
'@/api/common'
import
{
fetchLoginByToken
,
fetchLoginByUid
}
from
'@/api/common'
function
getAnimationProps
(
delay
:
number
)
{
return
{
...
...
@@ -41,6 +40,7 @@ function getAnimationProps(delay: number) {
}
export
const
Home
:
React
.
FC
=
()
=>
{
const
viteOutputObj
=
import
.
meta
.
env
.
VITE_OUTPUT_OBJ
||
'open'
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
)
const
dispatch
=
useAppDispatch
()
const
location
=
useLocation
()
...
...
@@ -86,11 +86,11 @@ export const Home: React.FC = () => {
}
}
}
catch
(
error
)
{
catch
(
error
)
{
// 可以在这里添加错误处理逻辑
console
.
error
(
'Failed to fetch chat records:'
,
error
)
}
finally
{
finally
{
setIsLoading
(
false
)
}
},
[])
...
...
@@ -119,27 +119,35 @@ export const Home: React.FC = () => {
if
(
hasFetched
.
current
)
{
return
}
hasFetched
.
current
=
true
const
url
=
new
URL
(
window
.
location
.
href
)
// 获取查询参数
const
searchParams
=
new
URLSearchParams
(
url
.
search
)
const
_loginCode
=
searchParams
.
get
(
'loginCode'
)
// const res = await fetchLoginByToken(loginCode)
// 模拟登录 可以用来测试
const
res
=
await
fetchLoginByUid
(
'123123'
)
let
res
=
{}
as
any
if
(
viteOutputObj
===
'inner'
)
{
res
=
await
fetchLoginByToken
(
_loginCode
)
}
else
{
// 模拟登录 可以用来测试
res
=
await
fetchLoginByUid
(
'123123'
)
}
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
,
}))
window
.
dispatchEvent
(
new
StorageEvent
(
'storage'
,
{
key
:
'__TOKEN__'
,
oldValue
:
token
,
newValue
:
res
.
data
.
token
,
url
:
window
.
location
.
href
,
storageArea
:
localStorage
,
}),
)
await
getQuestionList
()
initConversation
()
...
...
@@ -151,7 +159,7 @@ export const Home: React.FC = () => {
if
(
!
token
)
{
login
()
}
else
{
else
{
getQuestionList
()
initConversation
()
dispatch
(
fetchConversations
())
...
...
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