mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-20 15:06:36 +00:00
Merge pull request #6760 from wucm667/feat/issue-6752-weekly-cost-estimate
feat(accounts): show estimated weekly account cost
This commit is contained in:
5 files changed
+113
-2
No files matched your search
@@ -134,6 +134,7 @@
|
||||
:utilization="usageInfo.seven_day.utilization"
|
||||
:resets-at="usageInfo.seven_day.resets_at"
|
||||
:window-stats="usageInfo.seven_day.window_stats"
|
||||
:estimated-total-cost="openAISevenDayEstimatedTotalCost"
|
||||
:show-now-when-idle="true"
|
||||
color="emerald"
|
||||
/>
|
||||
@@ -785,6 +786,25 @@ const hasOpenAIUsageFallback = computed(() => {
|
||||
return !!usageInfo.value?.five_hour || !!usageInfo.value?.seven_day
|
||||
})
|
||||
|
||||
const openAISevenDayEstimatedTotalCost = computed(() => {
|
||||
const sevenDay = usageInfo.value?.seven_day
|
||||
const utilization = sevenDay?.utilization
|
||||
const currentCost = sevenDay?.window_stats?.cost
|
||||
if (
|
||||
typeof utilization !== 'number' ||
|
||||
typeof currentCost !== 'number' ||
|
||||
!Number.isFinite(utilization) ||
|
||||
!Number.isFinite(currentCost) ||
|
||||
utilization <= 0 ||
|
||||
currentCost <= 0
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
const estimate = (currentCost * 100) / utilization
|
||||
return Number.isFinite(estimate) && estimate > 0 ? estimate : null
|
||||
})
|
||||
|
||||
const openAIUsageRefreshKey = computed(() => buildOpenAIUsageRefreshKey(props.account))
|
||||
|
||||
const shouldAutoLoadUsageOnMount = computed(() => {
|
||||
|
||||
Reference in new issue
Block a user