mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-03 00:02:28 +08:00
refactor(frontend): 优化可组合函数
- 改进 useClipboard, useFormDialog, useTTLAnalysis composables
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useToast } from './useToast'
|
||||
import { log } from '@/utils/logger'
|
||||
|
||||
export function useClipboard() {
|
||||
const { success, error: showError } = useToast()
|
||||
@@ -33,7 +34,7 @@ export function useClipboard() {
|
||||
document.body.removeChild(textArea)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('复制失败:', err)
|
||||
log.error('复制失败:', err)
|
||||
showError('复制失败,请手动选择文本进行复制')
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ref, computed, watch, type Ref, type ComputedRef } from 'vue'
|
||||
import { computed, watch, type Ref, type ComputedRef } from 'vue'
|
||||
|
||||
/**
|
||||
* 表单对话框通用逻辑
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
type IntervalTimelineResponse
|
||||
} from '@/api/cache'
|
||||
import type { ChartData } from 'chart.js'
|
||||
import { log } from '@/utils/logger'
|
||||
|
||||
// 时间范围选项
|
||||
export const ANALYSIS_HOURS_OPTIONS = [
|
||||
@@ -104,7 +105,7 @@ export function useTTLAnalysis() {
|
||||
}
|
||||
} catch (error) {
|
||||
showError('获取 TTL 分析失败')
|
||||
console.error(error)
|
||||
log.error('获取 TTL 分析失败', error)
|
||||
} finally {
|
||||
ttlAnalysisLoading.value = false
|
||||
}
|
||||
@@ -119,7 +120,7 @@ export function useTTLAnalysis() {
|
||||
})
|
||||
} catch (error) {
|
||||
showError('获取缓存命中分析失败')
|
||||
console.error(error)
|
||||
log.error('获取缓存命中分析失败', error)
|
||||
} finally {
|
||||
hitAnalysisLoading.value = false
|
||||
}
|
||||
@@ -136,7 +137,7 @@ export function useTTLAnalysis() {
|
||||
})
|
||||
} catch (error) {
|
||||
showError('获取用户时间线数据失败')
|
||||
console.error(error)
|
||||
log.error('获取用户时间线数据失败', error)
|
||||
} finally {
|
||||
userTimelineLoading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user