返回 Social Auto Upload
user.js
根目录 / sau_frontend / src / stores / user.js
1 import { defineStore } from 'pinia'
2 import { ref } from 'vue'
3
4 export const useUserStore = defineStore('user', () => {
5 const userInfo = ref({
6 name: '',
7 email: ''
8 })
9
10 const isLoggedIn = ref(false)
11
12 const setUserInfo = (info) => {
13 userInfo.value = info
14 isLoggedIn.value = true
15 }
16
17 const logout = () => {
18 userInfo.value = {
19 name: '',
20 email: ''
21 }
22 isLoggedIn.value = false
23 }
24
25 return {
26 userInfo,
27 isLoggedIn,
28 setUserInfo,
29 logout
30 }
31 })
31 lines JAVASCRIPT