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:
2026-04-07 12:47:16 +08:00
parent 538f3e227a
commit bece7be267
3 changed files with 30 additions and 15 deletions
+16 -14
View File
@@ -75,8 +75,8 @@ function formatDate(timestamp) {
<div v-if="isRoot || isFolder" class="content-directory-view">
<div class="directory-list">
<div class="directory-header">
<div class="col-name">名称</div>
<div class="col-date">更新时间</div>
<div class="col-name">Name</div>
<div class="col-date">Date</div>
</div>
<div v-if="!isRoot" class="directory-row" @click="navigateUp">
@@ -167,14 +167,14 @@ function renderMarkdown(text) {
gap: 4px;
padding: 8px 16px;
font-size: 13px;
color: var(--muted-text);
color: var(--github-text-secondary);
border-bottom: 1px solid var(--panel-border);
flex-shrink: 0;
}
.breadcrumb-item {
cursor: pointer;
color: var(--focus-ring);
color: var(--github-accent);
}
.breadcrumb-item:hover {
@@ -182,7 +182,7 @@ function renderMarkdown(text) {
}
.breadcrumb-current {
color: var(--app-text);
color: var(--github-text);
cursor: default;
}
@@ -230,18 +230,20 @@ function renderMarkdown(text) {
display: flex;
align-items: center;
padding: 12px 16px;
background: var(--ghost-code-bg);
border-bottom: 1px solid var(--panel-border);
font-size: 13px;
background: var(--github-hover);
border-bottom: 1px solid var(--github-border);
font-size: 12px;
font-weight: 600;
color: var(--muted-text);
text-transform: uppercase;
color: var(--github-text-secondary);
}
.directory-row {
display: flex;
align-items: center;
padding: 10px 16px;
border-bottom: 1px solid var(--panel-border);
height: 28px;
padding: 0 16px;
border-bottom: 1px solid var(--github-border);
cursor: pointer;
transition: background 0.15s ease;
font-size: 14px;
@@ -252,7 +254,7 @@ function renderMarkdown(text) {
}
.directory-row:hover {
background: var(--ghost-code-bg);
background: var(--github-hover);
}
.col-icon {
@@ -282,10 +284,10 @@ function renderMarkdown(text) {
}
.col-date {
width: 120px;
width: 140px;
flex-shrink: 0;
text-align: right;
color: var(--muted-text);
color: var(--github-text-secondary);
font-size: 13px;
}
+13 -1
View File
@@ -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()
}
+1
View File
@@ -9,4 +9,5 @@ export const CONVERT_URL = import.meta.env.VITE_CONVERT_URL || `${API_BASE_URL}/
export const EXPORT_PDF_URL = import.meta.env.VITE_EXPORT_PDF_URL || '/v1/export/pdf'
export const TTS_URL = import.meta.env.VITE_TTS_URL || `${API_BASE_URL}/v1/tts-asr/tts`
export const TTS_STATUS_URL = import.meta.env.VITE_TTS_STATUS_URL || `${API_BASE_URL}/v1/tts-asr/status`
export const TTS_CONFIG_URL = import.meta.env.VITE_TTS_CONFIG_URL || `${API_BASE_URL}/v1/tts-asr/config`
export const API_KEY = import.meta.env.VITE_API_KEY || 'your-secret-key-here'