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