Skip to content

Commit 0c68747

Browse files
committed
refactor: UI 组件重构与样式优化
1 parent c028e44 commit 0c68747

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2122
-2660
lines changed

public/worker.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ async function processKeyWithRetry(apiKey, config, slotIndex) {
350350
error: result.error,
351351
retryCount: attempt,
352352
isPaid: finalResult.isPaid,
353-
cacheApiStatus: finalResult.cacheApiStatus
353+
cacheApiStatus: finalResult.cacheApiStatus,
354+
statusCode: extractStatusCode(result.error)
354355
}
355356
});
356357

@@ -380,7 +381,8 @@ async function processKeyWithRetry(apiKey, config, slotIndex) {
380381
key: apiKey,
381382
status: 'invalid',
382383
error: result.error,
383-
retryCount: attempt
384+
retryCount: attempt,
385+
statusCode: extractStatusCode(result.error)
384386
}
385387
});
386388

@@ -407,7 +409,8 @@ async function processKeyWithRetry(apiKey, config, slotIndex) {
407409
key: apiKey,
408410
status: 'invalid',
409411
error: result.error,
410-
retryCount: attempt
412+
retryCount: attempt,
413+
statusCode: extractStatusCode(result.error)
411414
}
412415
});
413416

@@ -453,7 +456,8 @@ async function processKeyWithRetry(apiKey, config, slotIndex) {
453456
key: apiKey,
454457
status: 'invalid',
455458
error: finalError,
456-
retryCount: attempt
459+
retryCount: attempt,
460+
statusCode: extractStatusCode(finalError)
457461
}
458462
});
459463

@@ -497,11 +501,13 @@ function shouldRetry(error, statusCode) {
497501
function extractStatusCode(error) {
498502
if (!error || typeof error !== 'string') return null;
499503

500-
const match = error.match(/$(\d{3})$/);
504+
// 匹配括号中的3位数字状态码,如 "认证失败 (401)" 或 "权限不足 (403)"
505+
const match = error.match(/\((\d{3})\)$/);
501506
if (match) {
502507
return parseInt(match[1]);
503508
}
504509

510+
// 匹配 "HTTP" + 空格 + 状态码的格式
505511
if (error.includes('HTTP ')) {
506512
const httpMatch = error.match(/HTTP (\d{3})/);
507513
if (httpMatch) {

src/App.jsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Controls from './components/features/Controls';
99
import Results from './components/features/Results';
1010
import AdvancedSettings from './components/features/AdvancedSettings';
1111
import ToastProvider from './components/common/ToastProvider';
12+
import Card from './components/common/Card';
1213
import { useLanguage } from './hooks/useLanguage';
1314

1415
const AppContent = () => {
@@ -17,17 +18,17 @@ const AppContent = () => {
1718

1819
const leftPanel = (
1920
<div>
20-
<div className="function-card">
21+
<Card variant="function">
2122
<ApiConfig />
22-
</div>
23+
</Card>
2324

24-
<div className="function-card">
25+
<Card variant="function">
2526
<KeyInput />
26-
</div>
27+
</Card>
2728

2829
<Controls />
2930

30-
<div className="function-card usage-card">
31+
<Card variant="usage">
3132
<div style={{ display: 'flex', alignItems: 'center', marginBottom: '8px' }}>
3233
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ marginRight: '8px', flexShrink: 0 }}>
3334
<circle cx="12" cy="12" r="10" />
@@ -37,10 +38,10 @@ const AppContent = () => {
3738
</div>
3839
<div>{t('usage1')}</div>
3940
<div>{t('usage2')}</div>
40-
</div>
41+
</Card>
4142

4243
<button
43-
className="settings-button"
44+
className="btn--settings"
4445
onClick={() => setIsAdvancedSettingsOpen(true)}
4546
>
4647
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
@@ -57,9 +58,7 @@ const AppContent = () => {
5758
</div>
5859
);
5960

60-
const rightPanel = (
61-
<Results />
62-
);
61+
const rightPanel = <Results />;
6362

6463
return (
6564
<>

0 commit comments

Comments
 (0)