mirror of
https://forgejo.merr.is/annika/isl-vue3.git
synced 2025-12-11 10:56:31 -05:00
34 lines
No EOL
909 B
TypeScript
34 lines
No EOL
909 B
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
|
|
export const useGeneralState = defineStore('general', () => {
|
|
const LOGIN_RETURN_URL_STORAGE = 'LOGIN_RETURN_URL_STORAGE'
|
|
|
|
const loginReturnUrl = ref("")
|
|
|
|
function setLoginReturnUrl(url: string) {
|
|
loginReturnUrl.value = url
|
|
localStorage.setItem(
|
|
LOGIN_RETURN_URL_STORAGE,
|
|
loginReturnUrl.value,
|
|
)
|
|
}
|
|
|
|
function getLoginReturnUrl(): string {
|
|
const storedUrl = localStorage.getItem(LOGIN_RETURN_URL_STORAGE)
|
|
if (storedUrl === null || storedUrl === undefined || storedUrl === "") {
|
|
localStorage.removeItem(LOGIN_RETURN_URL_STORAGE)
|
|
const res = loginReturnUrl.value
|
|
loginReturnUrl.value == null
|
|
return res
|
|
}
|
|
localStorage.removeItem(LOGIN_RETURN_URL_STORAGE)
|
|
loginReturnUrl.value == null
|
|
return storedUrl
|
|
}
|
|
|
|
return {
|
|
setLoginReturnUrl,
|
|
getLoginReturnUrl
|
|
}
|
|
}) |