This commit is contained in:
Shiny Nematoda 2023-04-02 21:44:04 +05:30
parent 2e2f6b78f9
commit 08da12fa67
No known key found for this signature in database
GPG key ID: 367DA4C64DF057AD
6 changed files with 65 additions and 44 deletions

View file

@ -5,6 +5,7 @@ import {
PIPED_INSTANCE,
HYPERPIPE_INSTANCE,
getJson,
useAuthLogout,
} from '@/scripts/fetch.js';
import { useStore } from '@/scripts/util.js';
@ -17,6 +18,7 @@ import('@/assets/version.json').then(v => {
});
const { t, setupLocale } = useI18n(),
store = useStore(),
instances = ref([]),
hypInstances = ref([]),
next = ref(false),
@ -41,11 +43,11 @@ function getBool(val) {
}
function getStore(key) {
return useStore().getItem(key);
return store.getItem(key);
}
function setStore(key, value) {
useStore().setItem(key, value);
store.setItem(key, value);
}
function getTheme() {
@ -72,6 +74,19 @@ function getStoreBool(key, ele, def) {
ele.value = getStore(key) || def;
}
async function setAuth(key) {
if (getStore('authapi')) {
if (!confirm('This requires a logout. Confirm logout?')) return;
const res = await useAuthLogout();
if (res?.error) if (!confirm(`Got Error: ${res.error}. Continue?`)) return;
}
store.removeItem('auth');
setStore('authapi', key);
}
const verifyApi = computed(() =>
hypInstances.value
.map(i => i.api_url.replace('https://', '').replace('http://', ''))
@ -271,7 +286,7 @@ onMounted(() => {
v-if="instances"
class="input"
:value="getStore('authapi') || PIPED_INSTANCE"
@change="setStore('authapi', $event.target.value)">
@change="setAuth($event.target.value)">
<option
v-for="i in instances"
:key="i.name"