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/cold-storage.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/client/cold-storage.ts (limited to 'src/client/cold-storage.ts') diff --git a/src/client/cold-storage.ts b/src/client/cold-storage.ts new file mode 100644 index 0000000000..1bee2313fa --- /dev/null +++ b/src/client/cold-storage.ts @@ -0,0 +1,34 @@ +// 常にメモリにロードしておく必要がないような設定情報を保管するストレージ + +const PREFIX = 'miux:'; + +export const defaultDeviceSettings = { + sound_masterVolume: 0.3, + sound_note: { type: 'syuilo/down', volume: 1 }, + sound_noteMy: { type: 'syuilo/up', volume: 1 }, + sound_notification: { type: 'syuilo/pope2', volume: 1 }, + sound_chat: { type: 'syuilo/pope1', volume: 1 }, + sound_chatBg: { type: 'syuilo/waon', volume: 1 }, + sound_antenna: { type: 'syuilo/triple', volume: 1 }, + sound_channel: { type: 'syuilo/square-pico', volume: 1 }, + sound_reversiPutBlack: { type: 'syuilo/kick', volume: 0.3 }, + sound_reversiPutWhite: { type: 'syuilo/snare', volume: 0.3 }, +}; + +export const device = { + get(key: T): typeof defaultDeviceSettings[T] { + // TODO: indexedDBにする + // ただしその際はnullチェックではなくキー存在チェックにしないとダメ + // (indexedDBはnullを保存できるため、ユーザーが意図してnullを格納した可能性がある) + const value = localStorage.getItem(PREFIX + key); + if (value == null) { + return defaultDeviceSettings[key]; + } else { + return JSON.parse(value); + } + }, + + set(key: keyof typeof defaultDeviceSettings, value: any): any { + localStorage.setItem(PREFIX + key, JSON.stringify(value)); + }, +}; -- cgit v1.3.1-freya