feat(device/detail): update BinarySensors component, add Chart component for sensor data visualization and add update-iconfont.sh
This commit is contained in:
@@ -52,7 +52,8 @@ export const handleRequestConfig: RequestConfig = {
|
||||
return (
|
||||
(status >= 200 && status < 300) ||
|
||||
status === HTTPSTATUS.HTTP_NOTFOUND ||
|
||||
status === HTTPSTATUS.HTTP_UNAUTHORIZED
|
||||
status === HTTPSTATUS.HTTP_UNAUTHORIZED ||
|
||||
status === HTTPSTATUS.HTTP_FORBIDDEN
|
||||
);
|
||||
},
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||
@@ -121,15 +122,16 @@ export const handleRequestConfig: RequestConfig = {
|
||||
// Unwrap data from backend response
|
||||
responseInterceptors: [
|
||||
async (response: any, options: any) => {
|
||||
const isRefreshRequest = response.url?.includes(API_PATH_REFRESH_TOKEN);
|
||||
const alreadyRetried = options?.skipAuthRefresh === true;
|
||||
const isRefreshRequest = response.config.url?.includes(
|
||||
API_PATH_REFRESH_TOKEN,
|
||||
);
|
||||
console.log('Is refresh request:', isRefreshRequest);
|
||||
|
||||
// Xử lý 401: đưa request vào hàng đợi, gọi refresh token, rồi gọi lại
|
||||
if (
|
||||
response.status === HTTPSTATUS.HTTP_UNAUTHORIZED &&
|
||||
// Không tự refresh cho chính API refresh token để tránh vòng lặp vô hạn
|
||||
!isRefreshRequest &&
|
||||
!alreadyRetried
|
||||
!isRefreshRequest
|
||||
) {
|
||||
const newToken = await getValidAccessToken();
|
||||
console.log('Access Token hết hạn, đang refresh...');
|
||||
@@ -172,7 +174,7 @@ export const handleRequestConfig: RequestConfig = {
|
||||
|
||||
if (
|
||||
response.status === HTTPSTATUS.HTTP_UNAUTHORIZED &&
|
||||
(isRefreshRequest || alreadyRetried)
|
||||
isRefreshRequest
|
||||
) {
|
||||
clearAllData();
|
||||
history.push(ROUTE_LOGIN);
|
||||
|
||||
Reference in New Issue
Block a user