多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
593 B

import type { UseGlobalStateReturn } from './state'
import type { Getters } from '~/lib'
import { computed } from '#imports'
export function useGlobalGetters(state: UseGlobalStateReturn) {
/** Getters */
/** Verify that a user is signed in by checking if token exists and is not expired */
const signedIn: Getters['signedIn'] = computed(
() =>
!!(
!!state.token &&
state.token.value !== '' &&
state.payload.value &&
state.payload.value.exp &&
state.payload.value.exp > state.timestamp.value / 1000
),
)
return { signedIn }
}