refactor(frontend): improve API and component handling
优化文件内容组件和API工具函数,改进错误处理和配置管理。 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
+13
-1
@@ -1,4 +1,4 @@
|
||||
import { API_URL, API_KEY, TTS_URL, TTS_STATUS_URL } from './config.js'
|
||||
import { API_URL, API_KEY, TTS_URL, TTS_STATUS_URL, TTS_CONFIG_URL } from './config.js'
|
||||
import { useSettingsStore } from '../stores/settings'
|
||||
|
||||
function generateRequestId() {
|
||||
@@ -146,3 +146,15 @@ export async function fetchTTSStatus(apiUrl = TTS_STATUS_URL) {
|
||||
|
||||
return res.json()
|
||||
}
|
||||
|
||||
export async function fetchTTSConfig(apiUrl = TTS_CONFIG_URL) {
|
||||
const res = await fetch(apiUrl, {
|
||||
headers: { 'X-API-Key': API_KEY },
|
||||
})
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`TTS Config HTTP ${res.status}`)
|
||||
}
|
||||
|
||||
return res.json()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user