Compare commits
1 Commits
14a81f6fdf
...
29c085bd2c
Author | SHA1 | Date |
---|---|---|
Ferdinand Thiessen | 29c085bd2c |
|
@ -10,7 +10,7 @@ function loadToken() {
|
|||
}
|
||||
|
||||
function clearToken() {
|
||||
PersistentStorage.remove('fg_token');
|
||||
void PersistentStorage.remove('fg_token');
|
||||
}
|
||||
|
||||
export function saveToken(token?: string) {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { LocalStorage, Platform } from 'quasar';
|
||||
import { Storage } from '@capacitor/storage';
|
||||
|
||||
type GetReturn = Date | number | boolean | string | object;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type PersitentTypes = Date | RegExp | number | boolean | string | object;
|
||||
|
||||
export class PersistentStorage {
|
||||
static clear() {
|
||||
|
@ -14,13 +15,12 @@ export class PersistentStorage {
|
|||
else return Promise.resolve(LocalStorage.remove(key));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
static set(key: string, value: any) {
|
||||
static set(key: string, value: PersitentTypes) {
|
||||
if (Platform.is.capacitor) return Storage.set({ key, value: JSON.stringify(value) });
|
||||
else return Promise.resolve(LocalStorage.set(key, value));
|
||||
}
|
||||
|
||||
static get<T extends GetReturn>(key: string) {
|
||||
static get<T extends PersitentTypes>(key: string) {
|
||||
if (Platform.is.capacitor)
|
||||
return Storage.get({ key }).then((v) =>
|
||||
v.value === null ? null : (JSON.parse(v.value) as T)
|
||||
|
|
|
@ -25,13 +25,13 @@ export default defineComponent({
|
|||
setup() {
|
||||
const router = useRouter();
|
||||
|
||||
const server = ref<string | undefined>(api.defaults.baseURL);
|
||||
const server = ref(api.defaults.baseURL);
|
||||
|
||||
function changeUrl() {
|
||||
if (server.value) {
|
||||
void PersistentStorage.set('baseURL', server.value).then(() => {
|
||||
console.log('uiuiui');
|
||||
router.push({ name: 'login' }).then(() => router.go(0));
|
||||
void router.push({ name: 'login' }).then(() => router.go(0));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue