diff --git a/README.md b/README.md index 8b7dd21..668093a 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,10 @@ - [服务器要求](https://ecn5khs4t956.feishu.cn/wiki/W8YBww1Mmiu4Cdkp5W4c8pFNnMf?from=from_copylink) - [QQ机器人](https://github.com/ctwj/astrbot_plugin_urldb) +### v1.2.1 +1. 修复转存移除广告失败的问题和添加广告失败的问题 +2. 管理后台UI优化 + ### v1.2.0 1. 新增手动批量转存 2. 新增QQ机器人 diff --git a/VERSION b/VERSION index 26aaba0..6085e94 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.0 +1.2.1 diff --git a/db/repo/search_stat_repository.go b/db/repo/search_stat_repository.go index 8d48e96..8923e0e 100644 --- a/db/repo/search_stat_repository.go +++ b/db/repo/search_stat_repository.go @@ -18,6 +18,7 @@ type SearchStatRepository interface { GetSearchTrend(days int) ([]entity.DailySearchStat, error) GetKeywordTrend(keyword string, days int) ([]entity.DailySearchStat, error) GetSummary() (map[string]int64, error) + FindWithPaginationOrdered(page, limit int) ([]entity.SearchStat, int64, error) } // SearchStatRepositoryImpl 搜索统计Repository实现 @@ -157,3 +158,20 @@ func (r *SearchStatRepositoryImpl) GetSummary() (map[string]int64, error) { "keywords": keywords, }, nil } + +// FindWithPaginationOrdered 按时间倒序分页查找搜索记录 +func (r *SearchStatRepositoryImpl) FindWithPaginationOrdered(page, limit int) ([]entity.SearchStat, int64, error) { + var stats []entity.SearchStat + var total int64 + + offset := (page - 1) * limit + + // 获取总数 + if err := r.db.Model(&entity.SearchStat{}).Count(&total).Error; err != nil { + return nil, 0, err + } + + // 获取分页数据,按创建时间倒序排列(最新的在前面) + err := r.db.Order("created_at DESC").Offset(offset).Limit(limit).Find(&stats).Error + return stats, total, err +} diff --git a/handlers/search_stat_handler.go b/handlers/search_stat_handler.go index 1a54ac0..c6c83b6 100644 --- a/handlers/search_stat_handler.go +++ b/handlers/search_stat_handler.go @@ -37,7 +37,8 @@ func GetSearchStats(c *gin.Context) { page, _ := strconv.Atoi(c.DefaultQuery("page", "1")) pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20")) - stats, total, err := repoManager.SearchStatRepository.FindWithPagination(page, pageSize) + // 使用自定义方法获取按时间倒序排列的搜索记录 + stats, total, err := repoManager.SearchStatRepository.FindWithPaginationOrdered(page, pageSize) if err != nil { ErrorResponse(c, "获取搜索统计失败", http.StatusInternalServerError) return diff --git a/web/components.d.ts b/web/components.d.ts index 232f5d1..3df6072 100644 --- a/web/components.d.ts +++ b/web/components.d.ts @@ -24,7 +24,6 @@ declare module 'vue' { NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] NInput: typeof import('naive-ui')['NInput'] - NInputNumber: typeof import('naive-ui')['NInputNumber'] NList: typeof import('naive-ui')['NList'] NListItem: typeof import('naive-ui')['NListItem'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] diff --git a/web/pages/admin/search-stats.vue b/web/pages/admin/search-stats.vue index 6ac7dbe..1063c25 100644 --- a/web/pages/admin/search-stats.vue +++ b/web/pages/admin/search-stats.vue @@ -65,51 +65,60 @@ - - - -
-
-
- - {{ keyword.rank }} - - {{ keyword.keyword }} -
-
- {{ keyword.count }}次 -
-
+ +
+ + + +
+
+
+ + {{ keyword.rank }} + + {{ keyword.keyword }} +
+
+ {{ keyword.count }}次 +
+
+
+
+ 暂无热门关键词数据 +
-
- 暂无热门关键词数据 -
-
- + - - - - -
- 暂无搜索记录 -
-
+ + + +
+
+
+
{{ record.keyword }}
+
+ {{ formatDate(record.created_at) }} +
+
+
+
{{ record.count }}次
+
+
+
+ 暂无搜索记录 +
+
+
+
@@ -160,44 +169,35 @@ const loading = ref(false) const trendChart = ref(null) let chart: any = null -// 分页配置 -const pagination = ref({ - page: 1, - pageSize: 20, - showSizePicker: true, - pageSizes: [10, 20, 50, 100], - onChange: (page: number) => { - pagination.value.page = page - loadSearchRecords() - }, - onUpdatePageSize: (pageSize: number) => { - pagination.value.pageSize = pageSize - pagination.value.page = 1 - loadSearchRecords() - } +// 按时间排序的搜索记录(最新的在前面) +const sortedSearchList = computed(() => { + return [...searchList.value].sort((a, b) => { + return new Date(b.created_at).getTime() - new Date(a.created_at).getTime() + }) }) -// 表格列配置 -const columns = [ - { - title: '关键词', - key: 'keyword', - width: 200 - }, - { - title: '搜索次数', - key: 'count', - width: 120 - }, - { - title: '日期', - key: 'date', - width: 150, - render: (row: any) => { - return row.date ? new Date(row.date).toLocaleDateString() : '' - } - } -] +// 限制显示前10条热门关键词 +const limitedHotKeywords = computed(() => { + return stats.value.hotKeywords.slice(0, 10) +}) + +// 限制显示前10条搜索记录 +const limitedSearchList = computed(() => { + return sortedSearchList.value.slice(0, 10) +}) + +// 格式化日期 +const formatDate = (dateString: string) => { + if (!dateString) return '' + const date = new Date(dateString) + return date.toLocaleString('zh-CN', { + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit' + }) +} // 获取百分比 const getPercentage = (count: number) => { diff --git a/web/pages/index.vue b/web/pages/index.vue index 91f774c..20fbc9c 100644 --- a/web/pages/index.vue +++ b/web/pages/index.vue @@ -105,16 +105,16 @@
- +
- - - + + @@ -136,10 +136,16 @@ :class="isUpdatedToday(resource.updated_at) ? 'hover:bg-pink-50 dark:hover:bg-pink-900 bg-pink-50/30 dark:bg-pink-900/30' : 'hover:bg-gray-50 dark:hover:bg-gray-800'" :data-index="index" > - - - @@ -510,4 +516,27 @@ const animateCounters = () => { rgba(0,0,0,0.25) 100% ); } + +/* 文本截断样式 */ +.line-clamp-2 { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; + word-wrap: break-word; + word-break: break-word; +} + +/* 表格单元格内容溢出控制 */ +table td { + overflow: hidden; + word-wrap: break-word; + word-break: break-word; +} + +/* 确保flex容器不会溢出 */ +.min-w-0 { + min-width: 0; +} \ No newline at end of file
+
文件名
+
- {{ resource.title }} +
+
{{ resource.title }}
+ +
+ {{ resource.description }} +
+
@@ -155,7 +161,7 @@