From 66857af14854804ab33791522ab3d3ad6960277f Mon Sep 17 00:00:00 2001 From: shaw Date: Fri, 8 Aug 2025 20:27:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=20API=20Keys=20=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BD=BF=E7=94=A8=E7=BB=9F=E8=AE=A1=E6=A0=8F=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=9C=80=E5=90=8E=E4=BD=BF=E7=94=A8=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在桌面端表格视图的使用统计列中增加最后使用时间 - 在移动端卡片视图的统计区域增加最后使用时间 - 添加 formatLastUsed 函数格式化时间显示 - 时间显示规则与 Accounts 页面保持一致(刚刚/X分钟前/X小时前/X天前/具体日期) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- scripts/manage.sh | 13 +++++-------- web/admin-spa/src/views/ApiKeysView.vue | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) mode change 100644 => 100755 scripts/manage.sh diff --git a/scripts/manage.sh b/scripts/manage.sh old mode 100644 new mode 100755 index fba168ad..6e8581ca --- a/scripts/manage.sh +++ b/scripts/manage.sh @@ -421,8 +421,8 @@ install_service() { print_info "安装项目依赖..." 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" print_success "已设置脚本执行权限" fi @@ -568,14 +568,11 @@ update_service() { stop_service fi - # 备份配置文件 + # 备份配置文件(只备份.env,config.js可从example恢复) print_info "备份配置文件..." if [ -f ".env" ]; then cp .env .env.backup.$(date +%Y%m%d%H%M%S) 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 "检查本地文件修改..." @@ -642,8 +639,8 @@ update_service() { print_info "更新依赖..." 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" fi diff --git a/web/admin-spa/src/views/ApiKeysView.vue b/web/admin-spa/src/views/ApiKeysView.vue index 2ad8cf54..f70d7422 100644 --- a/web/admin-spa/src/views/ApiKeysView.vue +++ b/web/admin-spa/src/views/ApiKeysView.vue @@ -268,6 +268,12 @@ >${{ (key.dailyCost || 0).toFixed(4) }} +
+ 最后使用 + {{ + formatLastUsed(key.lastUsedAt) + }} +
@@ -745,6 +751,12 @@

费用

+
+ 最后使用 + {{ + formatLastUsed(key.lastUsedAt) + }} +
@@ -1736,6 +1748,19 @@ const formatTokenCount = (count) => { 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], () => { currentPage.value = 1