Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
50481f4c
authored
May 22, 2025
by
Compasafe
Committed by
GitHub
May 22, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改语音组件中判断isPc的逻辑 (#4854)
* fix: 修改语音组件中判断isPc的逻辑 * fix: 修改语音组件中判断isPc的逻辑
parent
88bd3aaa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
packages/web/common/system/utils.ts
+29
-0
projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/VoiceInput.tsx
+2
-1
No files found.
packages/web/common/system/utils.ts
View file @
50481f4c
...
@@ -16,3 +16,32 @@ export const getWebReqUrl = (url: string = '') => {
...
@@ -16,3 +16,32 @@ export const getWebReqUrl = (url: string = '') => {
if
(
!
url
.
startsWith
(
'/'
)
||
url
.
startsWith
(
baseUrl
))
return
url
;
if
(
!
url
.
startsWith
(
'/'
)
||
url
.
startsWith
(
baseUrl
))
return
url
;
return
`
${
baseUrl
}${
url
}
`
;
return
`
${
baseUrl
}${
url
}
`
;
};
};
export
const
isMobile
=
()
=>
{
// 服务端渲染时返回 false
if
(
typeof
window
===
'undefined'
)
return
false
;
// 1. 检查 User-Agent
const
userAgent
=
navigator
.
userAgent
.
toLowerCase
();
const
mobileKeywords
=
[
'android'
,
'iphone'
,
'ipod'
,
'ipad'
,
'windows phone'
,
'blackberry'
,
'webos'
,
'iemobile'
,
'opera mini'
];
const
isMobileUA
=
mobileKeywords
.
some
((
keyword
)
=>
userAgent
.
includes
(
keyword
));
// 2. 检查屏幕宽度
const
isMobileWidth
=
window
.
innerWidth
<=
900
;
// 3. 检查是否支持触摸事件(排除触控屏PC)
const
isTouchDevice
=
'ontouchstart'
in
window
||
navigator
.
maxTouchPoints
>
0
;
// 综合判断:满足以下任一条件即视为移动端
return
isMobileUA
||
(
isMobileWidth
&&
isTouchDevice
);
};
projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/VoiceInput.tsx
View file @
50481f4c
...
@@ -16,6 +16,7 @@ import { useSystem } from '@fastgpt/web/hooks/useSystem';
...
@@ -16,6 +16,7 @@ import { useSystem } from '@fastgpt/web/hooks/useSystem';
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
ChatBoxContext
}
from
'../Provider'
;
import
{
ChatBoxContext
}
from
'../Provider'
;
import
MyIconButton
from
'@/pageComponents/account/team/OrgManage/IconButton'
;
import
MyIconButton
from
'@/pageComponents/account/team/OrgManage/IconButton'
;
import
{
isMobile
}
from
'@fastgpt/web/common/system/utils'
;
export
interface
VoiceInputComponentRef
{
export
interface
VoiceInputComponentRef
{
onSpeak
:
()
=>
void
;
onSpeak
:
()
=>
void
;
...
@@ -213,7 +214,7 @@ const MobileVoiceInput = ({
...
@@ -213,7 +214,7 @@ const MobileVoiceInput = ({
const
VoiceInput
=
forwardRef
<
VoiceInputComponentRef
,
VoiceInputProps
>
(
const
VoiceInput
=
forwardRef
<
VoiceInputComponentRef
,
VoiceInputProps
>
(
({
onSendMessage
,
resetInputVal
},
ref
)
=>
{
({
onSendMessage
,
resetInputVal
},
ref
)
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
{
isPc
}
=
useSystem
();
const
isPc
=
!
isMobile
();
const
outLinkAuthData
=
useContextSelector
(
ChatBoxContext
,
(
v
)
=>
v
.
outLinkAuthData
);
const
outLinkAuthData
=
useContextSelector
(
ChatBoxContext
,
(
v
)
=>
v
.
outLinkAuthData
);
const
appId
=
useContextSelector
(
ChatBoxContext
,
(
v
)
=>
v
.
appId
);
const
appId
=
useContextSelector
(
ChatBoxContext
,
(
v
)
=>
v
.
appId
);
...
...
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