|
|
|
@ -2,6 +2,9 @@ import { create } from 'zustand'
|
|
|
|
|
import { fetchJSON, appendRequestHeader } from '@/utils/request'
|
|
|
|
|
import { isEmpty, isNotEmpty } from '@/utils/commons'
|
|
|
|
|
|
|
|
|
|
export const PERM_MERGE_CONVERSATION = 'merge-conversation'
|
|
|
|
|
export const PERM_ASSIGN_NEW_CONVERSATION = 'assign-new-conversation'
|
|
|
|
|
|
|
|
|
|
const useAuthStore = create((set, get) => ({
|
|
|
|
|
|
|
|
|
|
loginUser: {
|
|
|
|
@ -18,6 +21,30 @@ const useAuthStore = create((set, get) => ({
|
|
|
|
|
|
|
|
|
|
loginStatus: 0,
|
|
|
|
|
|
|
|
|
|
isPermitted: (perm) => {
|
|
|
|
|
const { loginUser } = get()
|
|
|
|
|
|
|
|
|
|
if (perm === PERM_MERGE_CONVERSATION) {
|
|
|
|
|
return ['404', '383', '227'].includes(loginUser.userId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (perm === PERM_ASSIGN_NEW_CONVERSATION) {
|
|
|
|
|
return ['79', '383', '404', '227'].includes(loginUser.userId)
|
|
|
|
|
}
|
|
|
|
|
// 以上是 Hardcode 判断
|
|
|
|
|
// 以下是权限列表从数据库读取后使用的方法
|
|
|
|
|
// return this.permissionList.some((value, key, arry) => {
|
|
|
|
|
// if (value.indexOf(WILDCARD_TOKEN) > -1) {
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
// if (value === perm) {
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
// return false;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
login: async (authCode) => {
|
|
|
|
|
|
|
|
|
|
const { saveUserSession, setLoginStatus } = get()
|
|
|
|
@ -89,8 +116,8 @@ const useAuthStore = create((set, get) => ({
|
|
|
|
|
|
|
|
|
|
appendRequestHeader('X-User-Id', sesstionObj.userId)
|
|
|
|
|
|
|
|
|
|
window.__spytitle = sesstionObj.username;
|
|
|
|
|
window.initPageSpy();
|
|
|
|
|
// window.__spytitle = sesstionObj.username;
|
|
|
|
|
// window.initPageSpy();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|