From 014440850014ee86d766bb07467c2970b17a1fc6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 25 Nov 2020 21:31:34 +0900 Subject: nanka iroiro (#6853) * wip * Update maps.ts * wip * wip * wip * wip * Update base.vue * wip * wip * wip * wip * Update link.vue * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update privacy.vue * wip * wip * wip * wip * Update range.vue * wip * wip * wip * wip * Update profile.vue * wip * Update a.vue * Update index.vue * wip * Update sidebar.vue * wip * wip * Update account-info.vue * Update a.vue * wip * wip * Update sounds.vue * wip * wip * wip * wip * wip * wip * wip * wip * Update account-info.vue * Update account-info.vue * wip * wip * wip * Update d-persimmon.json5 * wip --- src/client/scripts/sound.ts | 24 ++++++++++++++++++++++++ src/client/scripts/theme.ts | 13 +++---------- 2 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 src/client/scripts/sound.ts (limited to 'src/client/scripts') diff --git a/src/client/scripts/sound.ts b/src/client/scripts/sound.ts new file mode 100644 index 0000000000..13fd9a80f5 --- /dev/null +++ b/src/client/scripts/sound.ts @@ -0,0 +1,24 @@ +import { device } from '@/cold-storage'; + +const cache = new Map(); + +export function play(type: string) { + const sound = device.get('sound_' + type as any); + if (sound.type == null) return; + playFile(sound.type, sound.volume); +} + +export function playFile(file: string, volume: number) { + const masterVolume = device.get('sound_masterVolume'); + if (masterVolume === 0) return; + + let audio: HTMLAudioElement; + if (cache.has(file)) { + audio = cache.get(file); + } else { + audio = new Audio(`/assets/sounds/${file}.mp3`); + cache.set(file, audio); + } + audio.volume = masterVolume - ((1 - volume) * masterVolume); + audio.play(); +} diff --git a/src/client/scripts/theme.ts b/src/client/scripts/theme.ts index c1fc88bf0e..c1580c6367 100644 --- a/src/client/scripts/theme.ts +++ b/src/client/scripts/theme.ts @@ -15,19 +15,12 @@ export const darkTheme: Theme = require('../themes/_dark.json5'); export const themeProps = Object.keys(lightTheme.props).filter(key => !key.startsWith('X')); export const builtinThemes = [ - require('../themes/l-white.json5'), - require('../themes/l-red.json5'), - require('../themes/l-green.json5'), - require('../themes/l-blue.json5'), + require('../themes/l-light.json5'), require('../themes/l-apricot.json5'), - require('../themes/d-black.json5'), - require('../themes/d-red.json5'), - require('../themes/d-green.json5'), - require('../themes/d-blue.json5'), + require('../themes/d-dark.json5'), require('../themes/d-persimmon.json5'), - - require('../themes/d-battery-saver.json5'), + require('../themes/d-black.json5'), ] as Theme[]; let timeout = null; -- cgit v1.2.3-freya