import { defineStore } from 'pinia' import { clientPost } from '@/utils/request.ts' import { ElMessage } from 'element-plus' interface PermissionReponse extends BaseResponse { data: { personName: string deptName: string deptId: string errorCode: number personCode: string userName: string isBusinessAtt: boolean message: string } } export const usePermissionStore = defineStore('permission', () => { const search = window.location.search // 获取"?appToken=xxx&appId=xxx" const params = new URLSearchParams(search) const getUserPermission = async () => { // if (!params.get('appId') || !params.get('appToken')) { // return // } const res = await clientPost( '/userPermissions/queryUserPermissions', null, { params: { appId: params.get('appId'), appToken: params.get('appToken'), }, }, ) console.log(11111,res) if (res.code !== 200) { ElMessage.error(res.msg) return } if (res.data.errorCode !== 2000) { ElMessage.error(res.data.message) return } localStorage.setItem('userInfo', JSON.stringify(res.data)) return res.data } return { getUserPermission, } })