wip
This commit is contained in:
parent
0b88e08d81
commit
19481de459
|
@ -1,4 +1,4 @@
|
||||||
import { get, set } from 'idb-keyval';
|
import { get, set } from '@/scripts/idb-proxy';
|
||||||
import { reactive } from 'vue';
|
import { reactive } from 'vue';
|
||||||
import { apiUrl } from '@/config';
|
import { apiUrl } from '@/config';
|
||||||
import { waiting } from '@/os';
|
import { waiting } from '@/os';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
import '@/style.scss';
|
import '@/style.scss';
|
||||||
|
|
||||||
import { set } from 'idb-keyval';
|
import { set } from '@/scripts/idb-proxy';
|
||||||
|
|
||||||
// TODO: そのうち消す
|
// TODO: そのうち消す
|
||||||
if (localStorage.getItem('vuex') != null) {
|
if (localStorage.getItem('vuex') != null) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { get } from 'idb-keyval';
|
import { get } from '@/scripts/idb-proxy';
|
||||||
|
|
||||||
export async function getAccountFromId(id: string) {
|
export async function getAccountFromId(id: string) {
|
||||||
const accounts = await get('accounts') as { token: string; id: string; }[];
|
const accounts = await get('accounts') as { token: string; id: string; }[];
|
||||||
|
|
23
src/client/scripts/idb-proxy.ts
Normal file
23
src/client/scripts/idb-proxy.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// FirefoxのプライベートモードなどではindexedDBが使用不可能なので、使う
|
||||||
|
import {
|
||||||
|
get as iget,
|
||||||
|
set as iset,
|
||||||
|
del as idel
|
||||||
|
} from 'idb-keyval';
|
||||||
|
|
||||||
|
const fallbackName = (key: string) => `idbfallback::${key}`;
|
||||||
|
|
||||||
|
export async function get(key: string) {
|
||||||
|
if (window.indexedDB) return iget(key);
|
||||||
|
return JSON.parse(localStorage.getItem(fallbackName(key)) || 'null');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function set(key: string, val: any) {
|
||||||
|
if (window.indexedDB) return iset(key, val);
|
||||||
|
return localStorage.setItem(fallbackName(key), JSON.stringify(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function del(key: string) {
|
||||||
|
if (window.indexedDB) return idel(key);
|
||||||
|
return localStorage.removeItem(fallbackName(key));
|
||||||
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
declare var self: ServiceWorkerGlobalScope;
|
declare var self: ServiceWorkerGlobalScope;
|
||||||
|
|
||||||
import { get, set } from 'idb-keyval';
|
import { get, set } from '@/scripts/idb-proxy';
|
||||||
import { I18n } from '../../misc/i18n';
|
import { I18n } from '../../misc/i18n';
|
||||||
|
|
||||||
class SwLang {
|
class SwLang {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
declare var self: ServiceWorkerGlobalScope;
|
declare var self: ServiceWorkerGlobalScope;
|
||||||
|
|
||||||
import { get } from 'idb-keyval';
|
import { get } from '@/scripts/idb-proxy';
|
||||||
import { pushNotificationData } from '../../types';
|
import { pushNotificationData } from '../../types';
|
||||||
import { api } from './operations';
|
import { api } from './operations';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue