2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
<template>
|
2023-01-05 22:40:17 -06:00
|
|
|
<div class="_gaps_m">
|
2023-05-19 06:52:15 -05:00
|
|
|
<MkRange v-model="masterVolume" :min="0" :max="1" :step="0.05" :textConverter="(v) => `${Math.floor(v * 100)}%`">
|
2022-05-05 08:51:05 -05:00
|
|
|
<template #label>{{ i18n.ts.masterVolume }}</template>
|
2023-01-07 00:09:46 -06:00
|
|
|
</MkRange>
|
2020-11-25 06:31:34 -06:00
|
|
|
|
2021-11-28 05:07:37 -06:00
|
|
|
<FormSection>
|
2022-05-05 08:51:05 -05:00
|
|
|
<template #label>{{ i18n.ts.sounds }}</template>
|
2023-01-05 22:40:17 -06:00
|
|
|
<div class="_gaps_s">
|
2023-04-11 20:39:57 -05:00
|
|
|
<MkFolder v-for="type in soundsKeys" :key="type">
|
2023-04-01 00:01:57 -05:00
|
|
|
<template #label>{{ i18n.t('_sfx.' + type) }}</template>
|
2023-01-05 06:04:56 -06:00
|
|
|
<template #suffix>{{ sounds[type].type ?? i18n.ts.none }}</template>
|
2022-12-21 18:01:58 -06:00
|
|
|
|
2023-01-05 06:04:56 -06:00
|
|
|
<XSound :type="sounds[type].type" :volume="sounds[type].volume" @update="(res) => updated(type, res)"/>
|
2023-01-08 18:41:25 -06:00
|
|
|
</MkFolder>
|
2023-01-05 06:04:56 -06:00
|
|
|
</div>
|
2021-11-28 05:07:37 -06:00
|
|
|
</FormSection>
|
2020-11-25 06:31:34 -06:00
|
|
|
|
2023-01-05 18:41:14 -06:00
|
|
|
<MkButton danger @click="reset()"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</MkButton>
|
2021-11-28 05:07:37 -06:00
|
|
|
</div>
|
2020-10-17 06:12:00 -05:00
|
|
|
</template>
|
|
|
|
|
2022-05-05 08:51:05 -05:00
|
|
|
<script lang="ts" setup>
|
2023-04-11 20:39:57 -05:00
|
|
|
import { Ref, computed, ref } from 'vue';
|
2022-12-21 18:01:58 -06:00
|
|
|
import XSound from './sounds.sound.vue';
|
2023-01-07 00:09:46 -06:00
|
|
|
import MkRange from '@/components/MkRange.vue';
|
2023-01-05 18:41:14 -06:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-28 05:07:37 -06:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2023-01-08 18:41:25 -06:00
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
2023-04-11 20:39:57 -05:00
|
|
|
import { soundConfigStore } from '@/scripts/sound';
|
2022-05-05 08:51:05 -05:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 03:38:49 -05:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-05-05 08:51:05 -05:00
|
|
|
|
2023-04-11 20:39:57 -05:00
|
|
|
const masterVolume = computed(soundConfigStore.makeGetterSetter('sound_masterVolume'));
|
2022-05-05 08:51:05 -05:00
|
|
|
|
2023-04-11 20:39:57 -05:00
|
|
|
const soundsKeys = ['note', 'noteMy', 'notification', 'chat', 'chatBg', 'antenna', 'channel'] as const;
|
2022-05-05 08:51:05 -05:00
|
|
|
|
2023-04-11 20:39:57 -05:00
|
|
|
const sounds = ref<Record<typeof soundsKeys[number], Ref<any>>>({
|
|
|
|
note: soundConfigStore.reactiveState.sound_note,
|
|
|
|
noteMy: soundConfigStore.reactiveState.sound_noteMy,
|
|
|
|
notification: soundConfigStore.reactiveState.sound_notification,
|
|
|
|
chat: soundConfigStore.reactiveState.sound_chat,
|
|
|
|
chatBg: soundConfigStore.reactiveState.sound_chatBg,
|
|
|
|
antenna: soundConfigStore.reactiveState.sound_antenna,
|
|
|
|
channel: soundConfigStore.reactiveState.sound_channel,
|
2022-05-05 08:51:05 -05:00
|
|
|
});
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2023-04-11 20:39:57 -05:00
|
|
|
async function updated(type: keyof typeof sounds.value, sound) {
|
2022-05-05 08:51:05 -05:00
|
|
|
const v = {
|
2022-12-21 18:01:58 -06:00
|
|
|
type: sound.type,
|
|
|
|
volume: sound.volume,
|
2022-05-05 08:51:05 -05:00
|
|
|
};
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2023-04-11 20:39:57 -05:00
|
|
|
soundConfigStore.set(`sound_${type}`, v);
|
2022-05-05 08:51:05 -05:00
|
|
|
sounds.value[type] = v;
|
|
|
|
}
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2022-05-05 08:51:05 -05:00
|
|
|
function reset() {
|
2023-04-11 20:39:57 -05:00
|
|
|
for (const sound of Object.keys(sounds.value) as Array<keyof typeof sounds.value>) {
|
|
|
|
const v = soundConfigStore.def[`sound_${sound}`].default;
|
|
|
|
soundConfigStore.set(`sound_${sound}`, v);
|
2022-05-05 08:51:05 -05:00
|
|
|
sounds.value[sound] = v;
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.sounds,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-music',
|
2020-10-17 06:12:00 -05:00
|
|
|
});
|
|
|
|
</script>
|