Compare commits

..

1 Commits

Author SHA1 Message Date
Tim
b1076d7256 Add invite points activity 2025-08-17 11:38:09 +08:00
2 changed files with 5 additions and 38 deletions

View File

@@ -6,7 +6,7 @@ import com.openisle.repository.ActivityRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Component
@@ -29,9 +29,10 @@ public class ActivityInitializer implements CommandLineRunner {
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));
a.setIcon("https://img.icons8.com/color/96/gift.png");
a.setContent("使用邀请码注册或邀请好友即可获得积分奖励,快来参与吧!");
a.setStartTime(LocalDateTime.now());
a.setEndTime(LocalDate.of(LocalDate.now().getYear(), 10, 1).atStartOfDay());
activityRepository.save(a);
}
}

View File

@@ -1,11 +1,5 @@
<template>
<div>
<ActivityPopup
:visible="showInvitePointsPopup"
:icon="invitePointsIcon"
text="邀请码送积分活动火热进行中,快来邀请好友吧!"
@close="closeInvitePointsPopup"
/>
<ActivityPopup
:visible="showMilkTeaPopup"
:icon="milkTeaIcon"
@@ -26,8 +20,6 @@ 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)
@@ -35,9 +27,6 @@ const showMedalPopup = ref(false)
const newMedals = ref([])
onMounted(async () => {
await checkInvitePointsActivity()
if (showInvitePointsPopup.value) return
await checkMilkTeaActivity()
if (showMilkTeaPopup.value) return
@@ -70,29 +59,6 @@ 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