diff options
| author | Mar0xy <marie@kaifa.ch> | 2023-11-04 14:32:28 +0100 |
|---|---|---|
| committer | Mar0xy <marie@kaifa.ch> | 2023-11-04 14:32:28 +0100 |
| commit | 647e76ab36ee99d5c3e6da95cd4a941d6cbc8114 (patch) | |
| tree | 01039aa66e053c1da9cf9d04a9474b1b7756daf3 /packages/frontend/src/scripts | |
| parent | upd: change misskey to sharkey, msky to shonk (diff) | |
| parent | New Crowdin updates (#12241) (diff) | |
| download | sharkey-647e76ab36ee99d5c3e6da95cd4a941d6cbc8114.tar.gz sharkey-647e76ab36ee99d5c3e6da95cd4a941d6cbc8114.tar.bz2 sharkey-647e76ab36ee99d5c3e6da95cd4a941d6cbc8114.zip | |
merge: upstream
Diffstat (limited to 'packages/frontend/src/scripts')
| -rw-r--r-- | packages/frontend/src/scripts/nyaize.ts | 19 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/sound.ts | 46 |
2 files changed, 16 insertions, 49 deletions
diff --git a/packages/frontend/src/scripts/nyaize.ts b/packages/frontend/src/scripts/nyaize.ts index 0ac77e1006..62833b4de3 100644 --- a/packages/frontend/src/scripts/nyaize.ts +++ b/packages/frontend/src/scripts/nyaize.ts @@ -3,18 +3,25 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +const enRegex1 = /(?<=n)a/gi; +const enRegex2 = /(?<=morn)ing/gi; +const enRegex3 = /(?<=every)one/gi; +const koRegex1 = /[나-낳]/g; +const koRegex2 = /(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm; +const koRegex3 = /(야(?=\?))|(야$)|(야(?= ))/gm; + export function nyaize(text: string): string { return text // ja-JP .replaceAll('な', 'にゃ').replaceAll('ナ', 'ニャ').replaceAll('ナ', 'ニャ') // en-US - .replace(/(?<=n)a/gi, x => x === 'A' ? 'YA' : 'ya') - .replace(/(?<=morn)ing/gi, x => x === 'ING' ? 'YAN' : 'yan') - .replace(/(?<=every)one/gi, x => x === 'ONE' ? 'NYAN' : 'nyan') + .replace(enRegex1, x => x === 'A' ? 'YA' : 'ya') + .replace(enRegex2, x => x === 'ING' ? 'YAN' : 'yan') + .replace(enRegex3, x => x === 'ONE' ? 'NYAN' : 'nyan') // ko-KR - .replace(/[나-낳]/g, match => String.fromCharCode( + .replace(koRegex1, match => String.fromCharCode( match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0), )) - .replace(/(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm, '다냥') - .replace(/(야(?=\?))|(야$)|(야(?= ))/gm, '냥'); + .replace(koRegex2, '다냥') + .replace(koRegex3, '냥'); } diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts index 22c77dbffa..f995c122d1 100644 --- a/packages/frontend/src/scripts/sound.ts +++ b/packages/frontend/src/scripts/sound.ts @@ -3,47 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { markRaw } from 'vue'; -import { Storage } from '@/pizzax.js'; - -export const soundConfigStore = markRaw(new Storage('sound', { - sound_masterVolume: { - where: 'device', - default: 0.3, - }, - sound_note: { - where: 'account', - default: { type: 'syuilo/n-aec', volume: 0 }, - }, - sound_noteMy: { - where: 'account', - default: { type: 'syuilo/n-cea-4va', volume: 1 }, - }, - sound_notification: { - where: 'account', - default: { type: 'syuilo/n-ea', volume: 1 }, - }, - sound_antenna: { - where: 'account', - default: { type: 'syuilo/triple', volume: 1 }, - }, - sound_channel: { - where: 'account', - default: { type: 'syuilo/square-pico', volume: 1 }, - }, -})); - -await soundConfigStore.ready; - -//#region サウンドのColdDeviceStorage => indexedDBのマイグレーション -for (const target of Object.keys(soundConfigStore.state) as Array<keyof typeof soundConfigStore.state>) { - const value = localStorage.getItem(`miux:${target}`); - if (value) { - soundConfigStore.set(target, JSON.parse(value) as typeof soundConfigStore.def[typeof target]['default']); - localStorage.removeItem(`miux:${target}`); - } -} -//#endregion +import { defaultStore } from '@/store.js'; const cache = new Map<string, HTMLAudioElement>(); @@ -112,13 +72,13 @@ export function getAudio(file: string, useCache = true): HTMLAudioElement { } export function setVolume(audio: HTMLAudioElement, volume: number): HTMLAudioElement { - const masterVolume = soundConfigStore.state.sound_masterVolume; + const masterVolume = defaultStore.state.sound_masterVolume; audio.volume = masterVolume - ((1 - volume) * masterVolume); return audio; } export function play(type: 'noteMy' | 'note' | 'antenna' | 'channel' | 'notification') { - const sound = soundConfigStore.state[`sound_${type}`]; + const sound = defaultStore.state[`sound_${type}`]; if (_DEV_) console.log('play', type, sound); if (sound.type == null) return; playFile(sound.type, sound.volume); |