Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
8aaaeb29
Unverified
Commit
8aaaeb29
authored
Mar 06, 2026
by
Wesley Liddick
Committed by
GitHub
Mar 06, 2026
Browse files
Merge pull request #813 from FizzlyCode/fix/account-usage-display
fix: 修复账号列表五小时用量显示为 $0.00 的问题
parents
cac23020
60fce4f1
Changes
3
Show whitespace changes
Inline
Side-by-side
backend/internal/handler/admin/account_handler.go
View file @
8aaaeb29
...
...
@@ -288,19 +288,8 @@ func (h *AccountHandler) List(c *gin.Context) {
}
}
//
窗口费用获取:lite 模式从快照缓存读取,非 lite 模式执行
PostgreSQL
查询后写入缓存
//
始终获取窗口费用(
PostgreSQL
聚合查询)
if
len
(
windowCostAccountIDs
)
>
0
{
if
lite
{
// lite 模式:尝试从快照缓存读取
cacheKey
:=
buildWindowCostCacheKey
(
windowCostAccountIDs
)
if
cached
,
ok
:=
accountWindowCostCache
.
Get
(
cacheKey
);
ok
{
if
costs
,
ok
:=
cached
.
Payload
.
(
map
[
int64
]
float64
);
ok
{
windowCosts
=
costs
}
}
// 缓存未命中则 windowCosts 保持 nil(仅发生在服务刚启动时)
}
else
{
// 非 lite 模式:执行 PostgreSQL 聚合查询(高开销)
windowCosts
=
make
(
map
[
int64
]
float64
)
var
mu
sync
.
Mutex
g
,
gctx
:=
errgroup
.
WithContext
(
c
.
Request
.
Context
())
...
...
@@ -325,11 +314,6 @@ func (h *AccountHandler) List(c *gin.Context) {
})
}
_
=
g
.
Wait
()
// 查询完毕后写入快照缓存,供 lite 模式使用
cacheKey
:=
buildWindowCostCacheKey
(
windowCostAccountIDs
)
accountWindowCostCache
.
Set
(
cacheKey
,
windowCosts
)
}
}
// Build response with concurrency info
...
...
backend/internal/handler/admin/account_window_cost_cache.go
deleted
100644 → 0
View file @
cac23020
package
admin
import
(
"strconv"
"strings"
"time"
)
var
accountWindowCostCache
=
newSnapshotCache
(
30
*
time
.
Second
)
func
buildWindowCostCacheKey
(
accountIDs
[]
int64
)
string
{
if
len
(
accountIDs
)
==
0
{
return
"accounts_window_cost_empty"
}
var
b
strings
.
Builder
b
.
Grow
(
len
(
accountIDs
)
*
6
)
_
,
_
=
b
.
WriteString
(
"accounts_window_cost:"
)
for
i
,
id
:=
range
accountIDs
{
if
i
>
0
{
_
=
b
.
WriteByte
(
','
)
}
_
,
_
=
b
.
WriteString
(
strconv
.
FormatInt
(
id
,
10
))
}
return
b
.
String
()
}
frontend/src/i18n/locales/zh.ts
View file @
8aaaeb29
...
...
@@ -2640,6 +2640,12 @@ export default {
allProtocols
:
'
全部协议
'
,
allStatus
:
'
全部状态
'
,
searchProxies
:
'
搜索代理...
'
,
protocols
:
{
http
:
'
HTTP
'
,
https
:
'
HTTPS
'
,
socks5
:
'
SOCKS5
'
,
socks5h
:
'
SOCKS5H (远程 DNS)
'
,
},
name
:
'
名称
'
,
protocol
:
'
协议
'
,
host
:
'
主机
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment