You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Global-sales/src/stores/AuthStore.js

45 lines
1.2 KiB
JavaScript

import { create } from 'zustand'
import { devtools } from 'zustand/middleware'
import { fetchJSON, postJSON } from '@/utils/request'
const useAuthStore = create((set, get) => ({
loginUser: {
// userId: '354',
// username: '廖一军',
// avatarUrl: 'https://static-legacy.dingtalk.com/media/lALPBDDrhXr716HNAoDNAoA_640_640.png',
// mobile: '86-18777396951',
// email: 'lyj@hainatravel.com',
// openId: 'iioljiPmZ4RPoOYpkFiSn7IKAiEiE',
// accountList: ['LYJ', 'LYJAH', 'LYJGH'],
// permissionList: ['view_chat', 'send_msg'],
},
loadUser: () => {
const sessionData = window.sessionStorage.getItem('GLOBAL_SALES_LOGIN_USER')
let userData = {
userId: 0,
username: '',
avatarUrl: '',
mobile: '',
email: '',
openId: '',
accountList: [],
permissionList: [],
}
if (sessionData !== null) {
userData = JSON.parse(sessionData)
}
return userData
},
saveUser: () => {
const { loginUser } = get()
window.sessionStorage.setItem('GLOBAL_SALES_LOGIN_USER', JSON.stringify(loginUser))
},
}))
export default useAuthStore