feat: dau sort logic

This commit is contained in:
tim
2025-07-14 21:55:41 +08:00
parent d0f84b70cc
commit dc238f1522
3 changed files with 10 additions and 2 deletions

View File

@@ -18,7 +18,7 @@
<span class="menu-item-text">关于</span>
</router-link>
<router-link
v-if="authState.role === 'ADMIN'"
v-if="shouldShowStats"
class="menu-item"
exact-active-class="selected"
to="/about/stats"
@@ -118,6 +118,9 @@ export default {
},
showUnreadCount() {
return this.unreadCount > 99 ? '99+' : this.unreadCount
},
shouldShowStats() {
return authState.role === 'ADMIN'
}
},
async mounted() {

View File

@@ -25,6 +25,7 @@ async function loadData() {
})
if (res.ok) {
const data = await res.json()
data.sort((a, b) => new Date(a.date) - new Date(b.date))
const dates = data.map(d => d.date)
const values = data.map(d => d.value)
option.value = {
@@ -45,6 +46,7 @@ onMounted(loadData)
.site-stats-page {
padding: 20px;
max-width: var(--page-max-width);
background-color: var(--background-color);
margin: 0 auto;
height: calc(100vh - var(--header-height) - 40px);
}

View File

@@ -32,7 +32,10 @@ public class StatController {
LocalDate start = end.minusDays(days - 1L);
var data = userVisitService.countDauRange(start, end);
return data.entrySet().stream()
.map(e -> Map.of("date", e.getKey().toString(), "value", e.getValue()))
.map(e -> Map.<String,Object>of(
"date", e.getKey().toString(),
"value", e.getValue()
))
.toList();
}
}