mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 21:17:30 +00:00
feat: 在 API Keys 页面使用统计栏添加最后使用时间显示
- 在桌面端表格视图的使用统计列中增加最后使用时间 - 在移动端卡片视图的统计区域增加最后使用时间 - 添加 formatLastUsed 函数格式化时间显示 - 时间显示规则与 Accounts 页面保持一致(刚刚/X分钟前/X小时前/X天前/具体日期) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
13
scripts/manage.sh
Normal file → Executable file
13
scripts/manage.sh
Normal file → Executable file
@@ -421,8 +421,8 @@ install_service() {
|
|||||||
print_info "安装项目依赖..."
|
print_info "安装项目依赖..."
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
# 确保脚本有执行权限
|
# 确保脚本有执行权限(仅在权限不正确时设置)
|
||||||
if [ -f "$APP_DIR/scripts/manage.sh" ]; then
|
if [ -f "$APP_DIR/scripts/manage.sh" ] && [ ! -x "$APP_DIR/scripts/manage.sh" ]; then
|
||||||
chmod +x "$APP_DIR/scripts/manage.sh"
|
chmod +x "$APP_DIR/scripts/manage.sh"
|
||||||
print_success "已设置脚本执行权限"
|
print_success "已设置脚本执行权限"
|
||||||
fi
|
fi
|
||||||
@@ -568,14 +568,11 @@ update_service() {
|
|||||||
stop_service
|
stop_service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 备份配置文件
|
# 备份配置文件(只备份.env,config.js可从example恢复)
|
||||||
print_info "备份配置文件..."
|
print_info "备份配置文件..."
|
||||||
if [ -f ".env" ]; then
|
if [ -f ".env" ]; then
|
||||||
cp .env .env.backup.$(date +%Y%m%d%H%M%S)
|
cp .env .env.backup.$(date +%Y%m%d%H%M%S)
|
||||||
fi
|
fi
|
||||||
if [ -f "config/config.js" ]; then
|
|
||||||
cp config/config.js config/config.js.backup.$(date +%Y%m%d%H%M%S)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 检查本地修改
|
# 检查本地修改
|
||||||
print_info "检查本地文件修改..."
|
print_info "检查本地文件修改..."
|
||||||
@@ -642,8 +639,8 @@ update_service() {
|
|||||||
print_info "更新依赖..."
|
print_info "更新依赖..."
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
# 确保脚本有执行权限
|
# 确保脚本有执行权限(仅在权限不正确时设置)
|
||||||
if [ -f "$APP_DIR/scripts/manage.sh" ]; then
|
if [ -f "$APP_DIR/scripts/manage.sh" ] && [ ! -x "$APP_DIR/scripts/manage.sh" ]; then
|
||||||
chmod +x "$APP_DIR/scripts/manage.sh"
|
chmod +x "$APP_DIR/scripts/manage.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -268,6 +268,12 @@
|
|||||||
>${{ (key.dailyCost || 0).toFixed(4) }}</span
|
>${{ (key.dailyCost || 0).toFixed(4) }}</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center justify-between text-sm">
|
||||||
|
<span class="text-gray-600">最后使用</span>
|
||||||
|
<span class="font-medium text-gray-700">{{
|
||||||
|
formatLastUsed(key.lastUsedAt)
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 每日费用限制进度条 -->
|
<!-- 每日费用限制进度条 -->
|
||||||
@@ -745,6 +751,12 @@
|
|||||||
<p class="text-xs text-gray-500">费用</p>
|
<p class="text-xs text-gray-500">费用</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mt-2 flex items-center justify-between">
|
||||||
|
<span class="text-xs text-gray-600">最后使用</span>
|
||||||
|
<span class="text-xs font-medium text-gray-700">{{
|
||||||
|
formatLastUsed(key.lastUsedAt)
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 限制进度 -->
|
<!-- 限制进度 -->
|
||||||
@@ -1736,6 +1748,19 @@ const formatTokenCount = (count) => {
|
|||||||
return count.toString()
|
return count.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 格式化最后使用时间
|
||||||
|
const formatLastUsed = (dateString) => {
|
||||||
|
if (!dateString) return '从未使用'
|
||||||
|
const date = new Date(dateString)
|
||||||
|
const now = new Date()
|
||||||
|
const diff = now - date
|
||||||
|
if (diff < 60000) return '刚刚'
|
||||||
|
if (diff < 3600000) return `${Math.floor(diff / 60000)} 分钟前`
|
||||||
|
if (diff < 86400000) return `${Math.floor(diff / 3600000)} 小时前`
|
||||||
|
if (diff < 604800000) return `${Math.floor(diff / 86400000)} 天前`
|
||||||
|
return date.toLocaleDateString('zh-CN')
|
||||||
|
}
|
||||||
|
|
||||||
// 监听筛选条件变化,重置页码
|
// 监听筛选条件变化,重置页码
|
||||||
watch([selectedTagFilter, apiKeyStatsTimeRange], () => {
|
watch([selectedTagFilter, apiKeyStatsTimeRange], () => {
|
||||||
currentPage.value = 1
|
currentPage.value = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user