Some checks are pending
Check / lint (push) Waiting to run
Check / typecheck (push) Waiting to run
Check / build (build, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build, 18.x, windows-latest) (push) Waiting to run
Check / build (build:app, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:app, 18.x, windows-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Waiting to run
49 lines
2.0 KiB
JavaScript
49 lines
2.0 KiB
JavaScript
import {createGlobalState,useStorage} from '@vueuse/core'
|
|
import {uniStorage} from "@/utils/uniStorage.js"
|
|
import { userInfoApi } from "@/api/user";
|
|
|
|
import {ref} from 'vue'
|
|
export const useAuth = createGlobalState(() => {
|
|
// const token = useStorage('token', '', uniStorage)
|
|
const token = ref('79b5c732d96d2b27a48a99dfd4a5566c43aaa5796242e854ebe3ffc198d6876b9628e7b764d9af65ab5dbb2d517ced88170491b74b048c0ba827c0d3741462cb89dc59ed46653a449af837a8262941ca1430937103230a1e32a1715f569f3efdbe6f8cb8b7b8642bd679668081b9b08f693d1b5be6002d936ec51e1e3e0c4927de9e32ac99a109b326e5d2bda27ec87624bb416ec70d2a95a2e190feeba9f0d6bae8571b3dfe89c824712344759a8f2bff9d70747c52525cf6a5614f9c770bca461a9b9c247b6dca97bcf83bbaf99bb726752c4fe1e9a4aa7de5c4cf3e88a3e480801280d45cdc124f9d8221105d8529c7c268c1251c3477bff5c051043bf9804c4f7096c5178cc01261bbedf04108b969333baf0bd5226c426de3591fc50b70691f2a5e275fa67ea3a7301df448929c13e4b71bf2182b6bfc270e21c142aa693844a0a175637f907e4438786a6e5e50')
|
|
const refreshToken = useStorage('refreshToken', '', uniStorage)
|
|
const userInfo = useStorage('userInfo', {}, uniStorage)
|
|
const leaderList = useStorage('leaderList', [], uniStorage)
|
|
const myCompany = useStorage('myCompany','', uniStorage)
|
|
const isLeader=ref(false)
|
|
// const leaderList=ref([])
|
|
const getUserInfo=async ()=>{
|
|
const data={
|
|
ID:userInfo.value.ID
|
|
}
|
|
const res= await userInfoApi(data)
|
|
if (res.status===0){
|
|
userInfo.value=res.data
|
|
}
|
|
}
|
|
// const getUserLeader=async ()=>{
|
|
// const data={
|
|
// departmentId:userInfo.value.PositionUsers?.map(x=>x.DepartmentId)
|
|
// }
|
|
|
|
// const res= await userLeaderApi(data)
|
|
// if (res.status===0){
|
|
// isLeader.value=!!res.data.departmentLeaders?.find((x) => {
|
|
// return x.userID === userInfo.value.ID
|
|
// })
|
|
// leaderList.value=res.data.departmentLeaders
|
|
// myCompany.value=res.data.company
|
|
// }
|
|
|
|
// }
|
|
return {
|
|
leaderList,
|
|
myCompany,
|
|
// getUserLeader,
|
|
getUserInfo,
|
|
userInfo,
|
|
token,
|
|
refreshToken,
|
|
}
|
|
})
|