1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 06:18:40 +09:00

enhance(client): show fireworks when visit user who today is birthday

Resolve #9476
This commit is contained in:
syuilo 2023-01-06 13:25:49 +09:00
parent 6adc0521d8
commit dc5b4a0402
4 changed files with 44 additions and 0 deletions

View File

@ -80,6 +80,7 @@ You should also include the user name that made the change.
- Client: add user list widget @syuilo - Client: add user list widget @syuilo
- Client: add heatmap of daily active users to about page @syuilo - Client: add heatmap of daily active users to about page @syuilo
- Client: introduce fluent emoji @syuilo - Client: introduce fluent emoji @syuilo
- Client: show fireworks when visit user who today is birthday @syuilo
- Client: show bot warning on screen when logged in as bot account @syuilo - Client: show bot warning on screen when logged in as bot account @syuilo
- Client: improve overall performance of client @syuilo - Client: improve overall performance of client @syuilo
- Client: ui tweaks @syuilo - Client: ui tweaks @syuilo

View File

@ -20,6 +20,7 @@
"blurhash": "2.0.4", "blurhash": "2.0.4",
"broadcast-channel": "4.19.1", "broadcast-channel": "4.19.1",
"browser-image-resizer": "git+https://github.com/misskey-dev/browser-image-resizer#v2.2.1-misskey.3", "browser-image-resizer": "git+https://github.com/misskey-dev/browser-image-resizer#v2.2.1-misskey.3",
"canvas-confetti": "^1.6.0",
"chart.js": "4.1.1", "chart.js": "4.1.1",
"chartjs-adapter-date-fns": "3.0.0", "chartjs-adapter-date-fns": "3.0.0",
"chartjs-chart-matrix": "^1.3.0", "chartjs-chart-matrix": "^1.3.0",

View File

@ -110,6 +110,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { defineAsyncComponent, computed, inject, onMounted, onUnmounted, watch } from 'vue'; import { defineAsyncComponent, computed, inject, onMounted, onUnmounted, watch } from 'vue';
import calcAge from 's-age'; import calcAge from 's-age';
import confetti from 'canvas-confetti';
import * as misskey from 'misskey-js'; import * as misskey from 'misskey-js';
import XUserTimeline from './index.timeline.vue'; import XUserTimeline from './index.timeline.vue';
import XNote from '@/components/MkNote.vue'; import XNote from '@/components/MkNote.vue';
@ -155,6 +156,29 @@ const age = $computed(() => {
return calcAge(props.user.birthday); return calcAge(props.user.birthday);
}); });
function birthdayEffect() {
const duration = 1000 * 5;
const animationEnd = Date.now() + duration;
const defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: os.claimZIndex('high') };
function randomInRange(min, max) {
return Math.random() * (max - min) + min;
}
const interval = setInterval(() => {
const timeLeft = animationEnd - Date.now();
if (timeLeft <= 0) {
return clearInterval(interval);
}
const particleCount = 50 * (timeLeft / duration);
// since particles fall down, start a bit higher than random
confetti(Object.assign({}, defaults, { particleCount, origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 } }));
confetti(Object.assign({}, defaults, { particleCount, origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 } }));
}, 250);
}
function menu(ev) { function menu(ev) {
os.popupMenu(getUserMenu(props.user, router), ev.currentTarget ?? ev.target); os.popupMenu(getUserMenu(props.user, router), ev.currentTarget ?? ev.target);
} }
@ -180,6 +204,16 @@ function parallax() {
onMounted(() => { onMounted(() => {
window.requestAnimationFrame(parallaxLoop); window.requestAnimationFrame(parallaxLoop);
narrow = rootEl!.clientWidth < 1000; narrow = rootEl!.clientWidth < 1000;
if (props.user.birthday) {
const m = new Date().getMonth() + 1;
const d = new Date().getDate();
const bm = parseInt(props.user.birthday.split('-')[1]);
const bd = parseInt(props.user.birthday.split('-')[2]);
if (m === bm && d === bd) {
birthdayEffect();
}
}
}); });
onUnmounted(() => { onUnmounted(() => {

View File

@ -4833,6 +4833,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"canvas-confetti@npm:^1.6.0":
version: 1.6.0
resolution: "canvas-confetti@npm:1.6.0"
checksum: be19e3be736ab28aa8af7b53cba9f4146f5714edadbf4d5a7d7b1899914dc59a8ac5574260fe6b7d9995c51df5787b0b707adfbb72dbacbc61fc03f9f2b25291
languageName: node
linkType: hard
"caseless@npm:~0.12.0": "caseless@npm:~0.12.0":
version: 0.12.0 version: 0.12.0
resolution: "caseless@npm:0.12.0" resolution: "caseless@npm:0.12.0"
@ -8052,6 +8059,7 @@ __metadata:
blurhash: 2.0.4 blurhash: 2.0.4
broadcast-channel: 4.19.1 broadcast-channel: 4.19.1
browser-image-resizer: "git+https://github.com/misskey-dev/browser-image-resizer#v2.2.1-misskey.3" browser-image-resizer: "git+https://github.com/misskey-dev/browser-image-resizer#v2.2.1-misskey.3"
canvas-confetti: ^1.6.0
chart.js: 4.1.1 chart.js: 4.1.1
chartjs-adapter-date-fns: 3.0.0 chartjs-adapter-date-fns: 3.0.0
chartjs-chart-matrix: ^1.3.0 chartjs-chart-matrix: ^1.3.0