feat: Add systemd service, configure API for proxy deployment, and enhance mobile audio playback with token authentication.
This commit is contained in:
@@ -11,15 +11,34 @@ interface AudioPlayerProps {
|
||||
jobId: number
|
||||
}
|
||||
|
||||
const isMobileDevice = () => {
|
||||
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
||||
}
|
||||
|
||||
const AudioPlayer = memo(({ audioUrl, jobId }: AudioPlayerProps) => {
|
||||
const [blobUrl, setBlobUrl] = useState<string>('')
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [loadError, setLoadError] = useState<string | null>(null)
|
||||
const [useMobileMode, setUseMobileMode] = useState(false)
|
||||
const previousAudioUrlRef = useRef<string>('')
|
||||
|
||||
useEffect(() => {
|
||||
setUseMobileMode(isMobileDevice())
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!audioUrl || audioUrl === previousAudioUrlRef.current) return
|
||||
|
||||
if (useMobileMode) {
|
||||
const token = localStorage.getItem('token')
|
||||
const separator = audioUrl.includes('?') ? '&' : '?'
|
||||
const urlWithToken = token ? `${audioUrl}${separator}token=${token}` : audioUrl
|
||||
setBlobUrl(urlWithToken)
|
||||
previousAudioUrlRef.current = audioUrl
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
let active = true
|
||||
const prevBlobUrl = blobUrl
|
||||
|
||||
@@ -55,7 +74,7 @@ const AudioPlayer = memo(({ audioUrl, jobId }: AudioPlayerProps) => {
|
||||
return () => {
|
||||
active = false
|
||||
}
|
||||
}, [audioUrl])
|
||||
}, [audioUrl, useMobileMode])
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
|
||||
@@ -342,6 +342,10 @@ export const jobApi = {
|
||||
getAudioUrl: (id: number, audioPath?: string): string => {
|
||||
if (audioPath) {
|
||||
if (audioPath.startsWith('http')) {
|
||||
if (audioPath.includes('localhost') || audioPath.includes('127.0.0.1')) {
|
||||
const url = new URL(audioPath)
|
||||
return `${import.meta.env.VITE_API_URL}${url.pathname}`
|
||||
}
|
||||
return audioPath
|
||||
} else {
|
||||
const baseUrl = import.meta.env.VITE_API_URL
|
||||
|
||||
@@ -93,7 +93,7 @@ export const PRESET_INSTRUCTS = [
|
||||
},
|
||||
{
|
||||
label: '温柔关怀',
|
||||
instruct: '温柔体贴的女性声音,语速平缓,音调柔和,充满关怀和安慰',
|
||||
instruct: '温柔体贴,语速平缓,音调柔和,充满关怀和安慰',
|
||||
text: '别担心,一切都会好起来的。我会一直陪在你身边。',
|
||||
},
|
||||
{
|
||||
@@ -108,17 +108,17 @@ export const PRESET_INSTRUCTS = [
|
||||
},
|
||||
{
|
||||
label: '专业播音员',
|
||||
instruct: '专业新闻播音员。性别:女性。音高:中等偏高,音域稳定。语速:标准播音语速,吐字清晰。音量:适中,音色饱满。情绪:沉稳专业,不带个人感情色彩。语调:平直中略有起伏,重点词汇加重。性格特征:严谨、客观、权威。',
|
||||
instruct: '专业新闻播音员。语速:标准播音语速,吐字清晰。情绪:沉稳专业,不带个人感情色彩。语调:平直中略有起伏,重点词汇加重。性格特征:严谨、客观、权威。',
|
||||
text: '据新华社报道,我国航天事业取得重大突破,神舟系列飞船成功完成载人飞行任务。',
|
||||
},
|
||||
{
|
||||
label: '温暖导师',
|
||||
instruct: '温暖的中年女性导师。音色:温和醇厚,带有亲和力。语速:不急不缓,娓娓道来。音调:平稳中带有鼓励性上扬。情绪:关怀、耐心、鼓励。性格:善解人意,循循善诱,充满正能量。适合场景:心理咨询、教育引导。',
|
||||
instruct: '温暖导师。语速:不急不缓,娓娓道来。音调:平稳中带有鼓励性上扬。情绪:关怀、耐心、鼓励。性格:善解人意,循循善诱,充满正能量。',
|
||||
text: '每个人都有自己的节奏,不要着急。慢慢来,你一定能找到属于自己的那条路。',
|
||||
},
|
||||
{
|
||||
label: '活力少年',
|
||||
instruct: '充满活力的青少年男性。音高:略高,富有朝气。语速:偏快,吐字利落。音量:响亮明快。情绪:开朗乐观,精力充沛。语调:跳跃感强,抑扬顿挫。性格:外向、自信、热情,充满青春气息。',
|
||||
instruct: '充满活力。语速:偏快,吐字利落。情绪:开朗乐观,精力充沛。语调:跳跃感强,抑扬顿挫。性格:外向、自信、热情,充满青春气息。',
|
||||
text: '哇,这个游戏太酷了!咱们组队一起玩吧,我保证带你们飞!',
|
||||
},
|
||||
] as const
|
||||
|
||||
Reference in New Issue
Block a user