mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-03 00:02:28 +08:00
refactor(frontend): 优化 Usage 功能模块可组合函数
- 改进 useUsageData 和 useUsageFilters composables
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { ref, computed, watch, type Ref } from 'vue'
|
import { ref, computed, type Ref } from 'vue'
|
||||||
import { usageApi } from '@/api/usage'
|
import { usageApi } from '@/api/usage'
|
||||||
import { meApi } from '@/api/me'
|
import { meApi } from '@/api/me'
|
||||||
import type {
|
import type {
|
||||||
@@ -11,6 +11,7 @@ import type {
|
|||||||
EnhancedModelStatsItem
|
EnhancedModelStatsItem
|
||||||
} from '../types'
|
} from '../types'
|
||||||
import { createDefaultStats } from '../types'
|
import { createDefaultStats } from '../types'
|
||||||
|
import { log } from '@/utils/logger'
|
||||||
|
|
||||||
export interface UseUsageDataOptions {
|
export interface UseUsageDataOptions {
|
||||||
isAdminPage: Ref<boolean>
|
isAdminPage: Ref<boolean>
|
||||||
@@ -221,7 +222,7 @@ export function useUsageData(options: UseUsageDataOptions) {
|
|||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error.response?.status !== 403) {
|
if (error.response?.status !== 403) {
|
||||||
console.error('加载统计数据失败:', error)
|
log.error('加载统计数据失败:', error)
|
||||||
}
|
}
|
||||||
stats.value = createDefaultStats()
|
stats.value = createDefaultStats()
|
||||||
modelStats.value = []
|
modelStats.value = []
|
||||||
@@ -273,7 +274,7 @@ export function useUsageData(options: UseUsageDataOptions) {
|
|||||||
totalRecords.value = response.total || 0
|
totalRecords.value = response.total || 0
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载记录失败:', error)
|
log.error('加载记录失败:', error)
|
||||||
currentRecords.value = []
|
currentRecords.value = []
|
||||||
totalRecords.value = 0
|
totalRecords.value = 0
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ref, computed, type Ref, watch } from 'vue'
|
import { ref, computed, type Ref } from 'vue'
|
||||||
import type { UsageRecord, FilterStatusValue } from '../types'
|
import type { UsageRecord, FilterStatusValue } from '../types'
|
||||||
|
|
||||||
export interface UseUsageFiltersOptions {
|
export interface UseUsageFiltersOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user