mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2024-10-22 18:56:38 +03:00
perf(App): Display loading when fetching initial login status (#1793)
This commit is contained in:
parent
5b9b2e0626
commit
1599b0f5e7
3 changed files with 10 additions and 2 deletions
|
@ -9,7 +9,10 @@ import { backend } from '@/services/backend'
|
|||
import { useAddTorrentStore, useAppStore, useDialogStore, useLogStore, useMaindataStore, usePreferenceStore, useTorrentStore, useVueTorrentStore } from '@/stores'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { onBeforeMount, watch, watchEffect } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { toast } from 'vue3-toastify'
|
||||
|
||||
const { t } = useI18n()
|
||||
const addTorrentStore = useAddTorrentStore()
|
||||
const appStore = useAppStore()
|
||||
const dialogStore = useDialogStore()
|
||||
|
@ -22,7 +25,9 @@ const vuetorrentStore = useVueTorrentStore()
|
|||
const { language, uiTitleCustom, uiTitleType, useBitSpeed } = storeToRefs(vuetorrentStore)
|
||||
|
||||
const checkAuthentication = async () => {
|
||||
await appStore.fetchAuthStatus()
|
||||
const promise = appStore.fetchAuthStatus()
|
||||
const timer = setTimeout(() => toast.promise(promise, { pending: t('login.pending')}), 1000)
|
||||
promise.then(() => clearTimeout(timer))
|
||||
}
|
||||
|
||||
const blockContextMenu = () => {
|
||||
|
|
|
@ -474,6 +474,7 @@
|
|||
"login": {
|
||||
"error": "Login failed!",
|
||||
"password": "Password",
|
||||
"pending": "Checking current auth status...",
|
||||
"rules": {
|
||||
"password_required": "Password is required",
|
||||
"username_required": "Username is required"
|
||||
|
|
|
@ -8,7 +8,9 @@ export const useAppStore = defineStore('app', () => {
|
|||
|
||||
async function fetchAuthStatus() {
|
||||
const ver: string | false = await qbit.getVersion().catch(() => false)
|
||||
await setAuthStatus(ver !== false, ver || undefined)
|
||||
const auth_status = ver !== false
|
||||
await setAuthStatus(auth_status, ver || undefined)
|
||||
return auth_status
|
||||
}
|
||||
|
||||
async function setAuthStatus(val: boolean, ver?: string) {
|
||||
|
|
Loading…
Reference in a new issue