mirror of
https://github.com/misskey-dev/misskey
synced 2024-12-27 04:59:10 +09:00
0144408500
* 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
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
// 常にメモリにロードしておく必要がないような設定情報を保管するストレージ
|
|
|
|
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<T extends keyof typeof defaultDeviceSettings>(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));
|
|
},
|
|
};
|