mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-06 23:21:16 +08:00
Compare commits
1 Commits
feature/lo
...
codex/add-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
901b3f344a |
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@ package com.openisle.model;
|
||||
/** Activity type enumeration. */
|
||||
public enum ActivityType {
|
||||
NORMAL,
|
||||
MILK_TEA
|
||||
MILK_TEA,
|
||||
INVITE_POINTS
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user