From cc378a454edb7de5c681a0b17a2e2d1cf8c68d16 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 27 May 2024 10:06:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20PageSpy=20=E7=99=BB?= =?UTF-8?q?=E9=99=86=E5=90=8E=E6=97=A0=E6=B3=95=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/AuthStore.js | 9 +-------- src/views/AuthApp.jsx | 6 +++++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index 045f9a3..4c903f4 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -1,7 +1,6 @@ import { create } from 'zustand' -import { fetchJSON, appendRequestHeader } from '@/utils/request' +import { fetchJSON } from '@/utils/request' import { isEmpty, isNotEmpty, } from '@/utils/commons' -import { loadPageSpy } from '@/utils/pagespy' export const PERM_MERGE_CONVERSATION = 'merge-conversation' export const PERM_ASSIGN_NEW_CONVERSATION = 'assign-new-conversation' @@ -114,18 +113,12 @@ const useAuthStore = create((set, get) => ({ set(() => ({ loginUser: sesstionObj, })); - - appendRequestHeader('X-User-Id', sesstionObj.userId); - - const __spytitle = sesstionObj.username; - loadPageSpy(__spytitle); } }, saveUserSession: () => { const { loginUser } = get() window.sessionStorage.setItem('GLOBAL_SALES_LOGIN_USER', JSON.stringify(loginUser)) - appendRequestHeader('X-User-Id', loginUser.userId) }, copyUserSession: () => { diff --git a/src/views/AuthApp.jsx b/src/views/AuthApp.jsx index 5dc44b8..d1186dc 100644 --- a/src/views/AuthApp.jsx +++ b/src/views/AuthApp.jsx @@ -7,6 +7,8 @@ import zhLocale from 'antd/locale/zh_CN' import 'dayjs/locale/zh-cn' import { useEffect } from 'react' import { Outlet, useHref, useNavigate } from 'react-router-dom' +import { appendRequestHeader } from '@/utils/request' +import { loadPageSpy } from '@/utils/pagespy' import AppLogo from '@/assets/highlights_travel_300_300.png' import '@/assets/App.css' @@ -33,8 +35,10 @@ function AuthApp() { Notification.requestPermission(); } if (loginUser.userId > 0) { + appendRequestHeader('X-User-Id', loginUser.userId); + loadPageSpy(loginUser.username); connectWebsocket(loginUser.userId); - fetchInitialData(loginUser.userId); // userIdStr + fetchInitialData(loginUser.userId); } return () => { disconnectWebsocket();