feat: 自定义重试间隔策略 + 修复按钮hover样式
- 新增重试间隔阶段配置,支持自定义时间分界点和频率 - 默认配置: 0-8秒=130ms, 8-25秒=260ms, 25-75秒=900ms - 设置面板添加可增删的阶段配置 UI - 修复按钮 hover 时文字变白的问题
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { ref } from 'vue'
|
||||
import { useToast } from './useToast'
|
||||
|
||||
export interface RetryStage {
|
||||
maxElapsed: number
|
||||
interval: number
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
timeApiUrl: string
|
||||
traceEnabled: boolean
|
||||
@@ -8,17 +13,25 @@ export interface Settings {
|
||||
logLevel: string
|
||||
concurrency: number
|
||||
attempts: number
|
||||
retryStages: RetryStage[]
|
||||
}
|
||||
|
||||
const App = window.go.main.App
|
||||
|
||||
const defaultRetryStages: RetryStage[] = [
|
||||
{ maxElapsed: 8, interval: 130 },
|
||||
{ maxElapsed: 25, interval: 260 },
|
||||
{ maxElapsed: 75, interval: 900 }
|
||||
]
|
||||
|
||||
const settings = ref<Settings>({
|
||||
timeApiUrl: '',
|
||||
traceEnabled: false,
|
||||
traceMaxBody: 0,
|
||||
logLevel: 'info',
|
||||
concurrency: 80,
|
||||
attempts: 1
|
||||
attempts: 1,
|
||||
retryStages: [...defaultRetryStages]
|
||||
})
|
||||
|
||||
export function useSettings() {
|
||||
@@ -33,7 +46,10 @@ export function useSettings() {
|
||||
traceMaxBody: cfg.traceMaxBody || 0,
|
||||
logLevel: cfg.logLevel || 'info',
|
||||
concurrency: cfg.concurrency || 80,
|
||||
attempts: cfg.attempts || 1
|
||||
attempts: cfg.attempts || 1,
|
||||
retryStages: cfg.retryStages && cfg.retryStages.length > 0
|
||||
? cfg.retryStages
|
||||
: [...defaultRetryStages]
|
||||
}
|
||||
} catch (e: any) {
|
||||
showToast('读取设置失败', e.message, 'error')
|
||||
|
||||
Reference in New Issue
Block a user