This commit is contained in:
mattyatea 2024-05-16 06:25:32 +09:00
parent db588acce0
commit 514595c5a7
2 changed files with 26 additions and 11 deletions

View File

@ -73,8 +73,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
this.userProfilesRepository.update({ userId: user.id }, { this.userProfilesRepository.update({ userId: user.id }, {
loggedInDates: [...userProfile.loggedInDates, today], loggedInDates: [...userProfile.loggedInDates, today],
}); });
this.usersRepository.update({ userId: user.id }, { this.usersRepository.update( user.id, {
getPoints: userProfile.getPoints + todayGetPoints, getPoints: user.getPoints + todayGetPoints,
}); });
this.notificationService.createNotification(user.id, 'loginbonus', { this.notificationService.createNotification(user.id, 'loginbonus', {
loginbonus: todayGetPoints, loginbonus: todayGetPoints,

View File

@ -5,6 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<div <div
:id="(audio.url).slice(32).replace('-','')"
ref="playerEl" ref="playerEl"
v-hotkey="keymap" v-hotkey="keymap"
tabindex="0" tabindex="0"
@ -29,9 +30,9 @@ SPDX-License-Identifier: AGPL-3.0-only
preload="metadata" preload="metadata"
controls controls
:class="$style.nativeAudio" :class="$style.nativeAudio"
:src="audio.url"
@keydown.prevent @keydown.prevent
> >
<source :src="audio.url">
</audio> </audio>
</div> </div>
@ -39,8 +40,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<audio <audio
ref="audioEl" ref="audioEl"
preload="metadata" preload="metadata"
:src="audio.url"
> >
<source :src="audio.url">
</audio> </audio>
<div :class="[$style.controlsChild, $style.controlsLeft]"> <div :class="[$style.controlsChild, $style.controlsLeft]">
<button class="_button" :class="$style.controlButton" @click="togglePlayPause"> <button class="_button" :class="$style.controlButton" @click="togglePlayPause">
@ -64,10 +65,24 @@ SPDX-License-Identifier: AGPL-3.0-only
:class="$style.volumeSeekbar" :class="$style.volumeSeekbar"
/> />
</div> </div>
{{ audioEl }}
<WaveSurferPlayer
:class="$style.seekbarRoot"
:options="{ media: audioEl,
height: 32,
waveColor: 'gray',
progressColor: 'red',
barGap: 5,
barWidth: 5,
barRadius: 8,
duration: 80,
backend: 'WebAudio'
}"
></WaveSurferPlayer>
<MkMediaRange <MkMediaRange
v-if="defaultStore.state.dataSaver.media && !hide"
v-model="rangePercent" v-model="rangePercent"
:class="$style.seekbarRoot" :class="$style.seekbarRoot"
:buffer="bufferedDataRatio"
/> />
</div> </div>
</div> </div>
@ -76,6 +91,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { shallowRef, watch, computed, ref, onDeactivated, onActivated, onMounted } from 'vue'; import { shallowRef, watch, computed, ref, onDeactivated, onActivated, onMounted } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { WaveSurferPlayer } from '@meersagor/wavesurfer-vue';
import type WaveSurfer from 'wavesurfer.js';
import type { MenuItem } from '@/types/menu.js'; import type { MenuItem } from '@/types/menu.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -84,7 +101,6 @@ import bytes from '@/filters/bytes.js';
import { hms } from '@/filters/hms.js'; import { hms } from '@/filters/hms.js';
import MkMediaRange from '@/components/MkMediaRange.vue'; import MkMediaRange from '@/components/MkMediaRange.vue';
import { $i, iAmModerator } from '@/account.js'; import { $i, iAmModerator } from '@/account.js';
const props = defineProps<{ const props = defineProps<{
audio: Misskey.entities.DriveFile; audio: Misskey.entities.DriveFile;
}>(); }>();
@ -132,6 +148,8 @@ const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.data
// Menu // Menu
const menuShowing = ref(false); const menuShowing = ref(false);
const waveSuferOptions = ref();
function showMenu(ev: MouseEvent) { function showMenu(ev: MouseEvent) {
let menu: MenuItem[] = []; let menu: MenuItem[] = [];
@ -226,10 +244,7 @@ const volume = ref(.25);
const speed = ref(1); const speed = ref(1);
const loop = ref(false); // TODO: const loop = ref(false); // TODO:
const bufferedEnd = ref(0); const bufferedEnd = ref(0);
const bufferedDataRatio = computed(() => { let audioContext = new AudioContext();
if (!audioEl.value) return 0;
return bufferedEnd.value / audioEl.value.duration;
});
// MediaControl Events // MediaControl Events
function togglePlayPause() { function togglePlayPause() {
@ -325,7 +340,7 @@ watch(loop, (to) => {
if (audioEl.value) audioEl.value.loop = to; if (audioEl.value) audioEl.value.loop = to;
}); });
onMounted(() => { onMounted(async () => {
init(); init();
}); });