Compare commits

...

3 Commits

Author SHA1 Message Date
Tim
901b3f344a Add invite code points activity 2025-08-17 11:37:21 +08:00
tim
ce94cd7e73 feat: 积分禁止删除 2025-08-17 02:31:23 +08:00
Tim
90147d6cd9 Merge pull request #606 from nagisa77/codex/add-new-notification-type-for-points-exchange
feat: add point redeem notification type
2025-08-17 02:27:33 +08:00
4 changed files with 49 additions and 2 deletions

View File

@@ -7,6 +7,8 @@ import lombok.RequiredArgsConstructor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
@Component
@RequiredArgsConstructor
public class ActivityInitializer implements CommandLineRunner {
@@ -22,5 +24,15 @@ public class ActivityInitializer implements CommandLineRunner {
a.setContent("为了有利于建站推广以及激励发布内容我们推出了建站送奶茶的活动前50名达到level 1的用户可以联系站长获取奶茶/咖啡一杯");
activityRepository.save(a);
}
if (activityRepository.findByType(ActivityType.INVITE_POINTS) == null) {
Activity a = new Activity();
a.setTitle("🎁邀请码送积分活动");
a.setType(ActivityType.INVITE_POINTS);
a.setIcon("https://icons.veryicon.com/png/o/commerce-shopping/two-color-icon-library/gift-30.png");
a.setContent("活动期间,邀请好友注册可获得积分奖励,快来参与吧!");
a.setEndTime(LocalDateTime.of(2025, 10, 1, 0, 0));
activityRepository.save(a);
}
}
}

View File

@@ -3,5 +3,6 @@ package com.openisle.model;
/** Activity type enumeration. */
public enum ActivityType {
NORMAL,
MILK_TEA
MILK_TEA,
INVITE_POINTS
}

View File

@@ -147,7 +147,7 @@ public class NotificationService {
*/
@org.springframework.transaction.annotation.Transactional
public void createPointRedeemNotifications(User user, String content) {
notificationRepository.deleteByTypeAndFromUser(NotificationType.POINT_REDEEM, user);
// notificationRepository.deleteByTypeAndFromUser(NotificationType.POINT_REDEEM, user);
for (User admin : userRepository.findByRole(Role.ADMIN)) {
createNotification(admin, NotificationType.POINT_REDEEM, null, null,
null, user, null, content);

View File

@@ -1,5 +1,11 @@
<template>
<div>
<ActivityPopup
:visible="showInvitePointsPopup"
:icon="invitePointsIcon"
text="邀请码送积分活动火热进行中,快来邀请好友吧!"
@close="closeInvitePointsPopup"
/>
<ActivityPopup
:visible="showMilkTeaPopup"
:icon="milkTeaIcon"
@@ -20,6 +26,8 @@ import { authState } from '~/utils/auth'
const config = useRuntimeConfig()
const API_BASE_URL = config.public.apiBaseUrl
const showInvitePointsPopup = ref(false)
const invitePointsIcon = ref('')
const showMilkTeaPopup = ref(false)
const milkTeaIcon = ref('')
const showNotificationPopup = ref(false)
@@ -27,6 +35,9 @@ const showMedalPopup = ref(false)
const newMedals = ref([])
onMounted(async () => {
await checkInvitePointsActivity()
if (showInvitePointsPopup.value) return
await checkMilkTeaActivity()
if (showMilkTeaPopup.value) return
@@ -59,6 +70,29 @@ const closeMilkTeaPopup = () => {
showMilkTeaPopup.value = false
checkNotificationSetting()
}
const checkInvitePointsActivity = async () => {
if (!process.client) return
if (localStorage.getItem('invitePointsActivityPopupShown')) return
try {
const res = await fetch(`${API_BASE_URL}/api/activities`)
if (res.ok) {
const list = await res.json()
const a = list.find((i) => i.type === 'INVITE_POINTS' && !i.ended)
if (a) {
invitePointsIcon.value = a.icon
showInvitePointsPopup.value = true
}
}
} catch (e) {
// ignore network errors
}
}
const closeInvitePointsPopup = () => {
if (!process.client) return
localStorage.setItem('invitePointsActivityPopupShown', 'true')
showInvitePointsPopup.value = false
checkMilkTeaActivity()
}
const checkNotificationSetting = async () => {
if (!process.client) return
if (!authState.loggedIn) return