feat: level 模块

This commit is contained in:
Tim
2025-07-28 13:35:59 +08:00
parent 56c89c3228
commit 46531b5461
3 changed files with 31 additions and 8 deletions

View File

@@ -21,11 +21,11 @@
</div>
<div v-if="loggedIn && !isAuthor && !subscribed" class="article-subscribe-button" @click="subscribePost">
<i class="fas fa-user-plus"></i>
订阅文章
<div class="article-subscribe-button-text">订阅文章</div>
</div>
<div v-if="loggedIn && !isAuthor && subscribed" class="article-unsubscribe-button" @click="unsubscribePost">
<i class="fas fa-user-minus"></i>
取消订阅
<div class="article-unsubscribe-button-text">取消订阅</div>
</div>
<DropdownMenu v-if="articleMenuItems.length > 0" :items="articleMenuItems">
<template #trigger>
@@ -699,6 +699,15 @@ export default {
border-radius: 8px;
font-size: 14px;
cursor: pointer;
display: flex;
align-items: center;
gap: 5px;
white-space: nowrap;
}
.article-subscribe-button-text,
.article-unsubscribe-button-text {
white-space: nowrap;
}
.article-subscribe-button:hover {
@@ -713,6 +722,11 @@ export default {
border-radius: 8px;
font-size: 14px;
cursor: pointer;
display: flex;
align-items: center;
gap: 5px;
white-space: nowrap;
}
.article-pending-button {

View File

@@ -25,10 +25,12 @@
<div class="profile-level-bar">
<div class="profile-level-bar-inner" :style="{ width: `${levelInfo.percent}%` }" />
</div>
<div class="profile-level-exp">
{{ levelInfo.exp }} / {{ levelInfo.nextExp }}
<div class="profile-level-info">
<div class="profile-level-exp">
{{ levelInfo.exp }} / {{ levelInfo.nextExp }}
</div>
<div class="profile-level-target">🎉目标 Lv.{{ levelInfo.currentLevel + 1 }}</div>
</div>
<div class="profile-level-target">目标 Lv.{{ levelInfo.currentLevel + 1 }}</div>
</div>
</div>
</div>
@@ -578,6 +580,13 @@ export default {
background-color: var(--primary-color);
}
.profile-level-info {
display: flex;
flex-direction: row;
gap: 10px;
align-items: center;
}
.profile-level-exp,
.profile-level-target {
font-size: 12px;

View File

@@ -32,7 +32,7 @@ public class LevelService {
User user = userRepository.findByUsername(username).orElseThrow();
LocalDateTime start = LocalDate.now().atStartOfDay();
long count = postRepository.countByAuthorAfter(username, start);
if (count >= 1) return 0;
if (count > 1) return 0;
return addExperience(user,30);
}
@@ -40,7 +40,7 @@ public class LevelService {
User user = userRepository.findByUsername(username).orElseThrow();
LocalDateTime start = LocalDate.now().atStartOfDay();
long count = commentRepository.countByAuthorAfter(username, start);
if (count >= 3) return 0;
if (count > 3) return 0;
return addExperience(user,10);
}
@@ -48,7 +48,7 @@ public class LevelService {
User user = userRepository.findByUsername(username).orElseThrow();
LocalDateTime start = LocalDate.now().atStartOfDay();
long count = reactionRepository.countByUserAfter(username, start);
if (count >= 3) return 0;
if (count > 3) return 0;
return addExperience(user,5);
}