2020-10-17 11:12:00 +00:00
|
|
|
<template>
|
2023-01-05 12:04:56 +00:00
|
|
|
<div class="_autoGap">
|
|
|
|
<FormRange v-model="masterVolume" :min="0" :max="1" :step="0.05" :text-converter="(v) => `${Math.floor(v * 100)}%`">
|
2022-05-05 13:51:05 +00:00
|
|
|
<template #label>{{ i18n.ts.masterVolume }}</template>
|
2020-11-25 12:31:34 +00:00
|
|
|
</FormRange>
|
|
|
|
|
2021-11-28 11:07:37 +00:00
|
|
|
<FormSection>
|
2022-05-05 13:51:05 +00:00
|
|
|
<template #label>{{ i18n.ts.sounds }}</template>
|
2023-01-05 12:04:56 +00:00
|
|
|
<div class="_autoGap_half">
|
|
|
|
<FormFolder v-for="type in Object.keys(sounds)" :key="type">
|
|
|
|
<template #label>{{ $t('_sfx.' + type) }}</template>
|
|
|
|
<template #suffix>{{ sounds[type].type ?? i18n.ts.none }}</template>
|
2022-12-22 00:01:58 +00:00
|
|
|
|
2023-01-05 12:04:56 +00:00
|
|
|
<XSound :type="sounds[type].type" :volume="sounds[type].volume" @update="(res) => updated(type, res)"/>
|
|
|
|
</FormFolder>
|
|
|
|
</div>
|
2021-11-28 11:07:37 +00:00
|
|
|
</FormSection>
|
2020-11-25 12:31:34 +00:00
|
|
|
|
2023-01-05 12:04:56 +00:00
|
|
|
<FormButton danger @click="reset()"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</FormButton>
|
2021-11-28 11:07:37 +00:00
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</template>
|
|
|
|
|
2022-05-05 13:51:05 +00:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 08:38:49 +00:00
|
|
|
import { computed, ref } from 'vue';
|
2022-12-22 00:01:58 +00:00
|
|
|
import XSound from './sounds.sound.vue';
|
2021-11-28 11:07:37 +00:00
|
|
|
import FormRange from '@/components/form/range.vue';
|
2022-09-06 09:21:49 +00:00
|
|
|
import FormButton from '@/components/MkButton.vue';
|
2021-11-28 11:07:37 +00:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2022-12-22 00:01:58 +00:00
|
|
|
import FormFolder from '@/components/form/folder.vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { ColdDeviceStorage } from '@/store';
|
|
|
|
import { playFile } from '@/scripts/sound';
|
2022-05-05 13:51:05 +00:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 08:38:49 +00:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-05-05 13:51:05 +00:00
|
|
|
|
|
|
|
const masterVolume = computed({
|
|
|
|
get: () => {
|
|
|
|
return ColdDeviceStorage.get('sound_masterVolume');
|
|
|
|
},
|
|
|
|
set: (value) => {
|
|
|
|
ColdDeviceStorage.set('sound_masterVolume', value);
|
2022-06-20 08:38:49 +00:00
|
|
|
},
|
2022-05-05 13:51:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const volumeIcon = computed(() => masterVolume.value === 0 ? 'fas fa-volume-mute' : 'fas fa-volume-up');
|
|
|
|
|
|
|
|
const sounds = ref({
|
2022-06-20 08:38:49 +00:00
|
|
|
note: ColdDeviceStorage.get('sound_note'),
|
|
|
|
noteMy: ColdDeviceStorage.get('sound_noteMy'),
|
|
|
|
notification: ColdDeviceStorage.get('sound_notification'),
|
|
|
|
chat: ColdDeviceStorage.get('sound_chat'),
|
|
|
|
chatBg: ColdDeviceStorage.get('sound_chatBg'),
|
|
|
|
antenna: ColdDeviceStorage.get('sound_antenna'),
|
|
|
|
channel: ColdDeviceStorage.get('sound_channel'),
|
2022-05-05 13:51:05 +00:00
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-12-22 00:01:58 +00:00
|
|
|
async function updated(type, sound) {
|
2022-05-05 13:51:05 +00:00
|
|
|
const v = {
|
2022-12-22 00:01:58 +00:00
|
|
|
type: sound.type,
|
|
|
|
volume: sound.volume,
|
2022-05-05 13:51:05 +00:00
|
|
|
};
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-05 13:51:05 +00:00
|
|
|
ColdDeviceStorage.set('sound_' + type, v);
|
|
|
|
sounds.value[type] = v;
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-05-05 13:51:05 +00:00
|
|
|
function reset() {
|
|
|
|
for (const sound of Object.keys(sounds.value)) {
|
|
|
|
const v = ColdDeviceStorage.default['sound_' + sound];
|
|
|
|
ColdDeviceStorage.set('sound_' + sound, v);
|
|
|
|
sounds.value[sound] = v;
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.sounds,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-music',
|
2020-10-17 11:12:00 +00:00
|
|
|
});
|
|
|
|
</script>
|