✌️
This commit is contained in:
7
src/client/scripts/get-account-from-id.ts
Normal file
7
src/client/scripts/get-account-from-id.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { get } from 'idb-keyval';
|
||||
|
||||
export async function getAccountFromId(id: string) {
|
||||
const accounts = await get('accounts') as { token: string; id: string; }[];
|
||||
if (!accounts) console.log('Accounts are not recorded');
|
||||
return accounts.find(e => e.id === id)
|
||||
}
|
@@ -1,8 +1,7 @@
|
||||
import { instance } from '@/instance';
|
||||
import { $i } from '@/account';
|
||||
import { api, post } from '@/os';
|
||||
import { api } from '@/os';
|
||||
import { lang } from '@/config';
|
||||
import { SwMessage } from '@/sw/types';
|
||||
|
||||
export async function initializeSw() {
|
||||
if (instance.swPublickey &&
|
||||
@@ -50,18 +49,6 @@ export async function initializeSw() {
|
||||
}
|
||||
}
|
||||
|
||||
navigator.serviceWorker.addEventListener('message', ev => {
|
||||
const data = ev.data as SwMessage;
|
||||
if (data.type !== 'order') return;
|
||||
|
||||
switch (data.order) {
|
||||
case 'post':
|
||||
return post(data.options);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Convert the URL safe base64 string to a Uint8Array
|
||||
* @param base64String base64 string
|
||||
|
11
src/client/scripts/login-id.ts
Normal file
11
src/client/scripts/login-id.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function appendLoginId(url: string, loginId: string) {
|
||||
const u = new URL(url, origin);
|
||||
u.searchParams.append('loginId', loginId);
|
||||
return u.toString();
|
||||
}
|
||||
|
||||
export function deleteLoginId(url: string) {
|
||||
const u = new URL(url);
|
||||
u.searchParams.delete('loginId');
|
||||
return u.toString();
|
||||
}
|
Reference in New Issue
Block a user