feat: 配置 pinia 持久化工具

frontend/dev
Spark 1 month ago
parent c651874a8f
commit 98da5b2185

@ -0,0 +1,25 @@
import { defineStore } from 'pinia';
import {ref} from "vue";
export const useTokenStore = defineStore(
'token',
() => {
const token = ref('')
const setToken = (newToken) => {
token.value = newToken
}
const removeToken = () => {
token.value = ''
}
return {
token, setToken, removeToken
}
},
{
persist: true
}
)

@ -0,0 +1,25 @@
import { defineStore } from 'pinia';
import { ref } from "vue";
export const useUsernameStore = defineStore(
'username',
() => {
const username = ref('')
const setUsername = (newUsername) => {
username.value = newUsername
}
const removeUsername = () => {
username.value = ''
}
return {
username, setUsername, removeUsername
}
},
{
persist: true
}
)
Loading…
Cancel
Save