Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
1c45d744
Unverified
Commit
1c45d744
authored
Apr 18, 2024
by
Zzm0809
Committed by
GitHub
Apr 18, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Optimization][web] Optimize login page prompts (#3407)
Signed-off-by:
Zzm0809
<
934230207@qq.com
>
Co-authored-by:
Zzm0809
<
Zzm0809@users.noreply.github.com
>
parent
29cbffa2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
14 deletions
+34
-14
function.tsx
dinky-web/src/pages/Other/Login/function.tsx
+2
-3
index.tsx
dinky-web/src/pages/Other/Login/index.tsx
+2
-2
index.tsx
.../RegCenter/Resource/components/ResourceOverView/index.tsx
+13
-3
requestErrorConfig.ts
dinky-web/src/requestErrorConfig.ts
+17
-6
No files found.
dinky-web/src/pages/Other/Login/function.tsx
View file @
1c45d744
...
@@ -23,7 +23,6 @@ import {
...
@@ -23,7 +23,6 @@ import {
setKeyToLocalStorage
,
setKeyToLocalStorage
,
setLocalThemeToStorage
setLocalThemeToStorage
}
from
'@/utils/function'
;
}
from
'@/utils/function'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
WarningMessageAsync
}
from
'@/utils/messages'
;
import
{
WarningMessageAsync
}
from
'@/utils/messages'
;
import
{
history
}
from
'@@/core/history'
;
import
{
history
}
from
'@@/core/history'
;
...
@@ -36,9 +35,9 @@ export const gotoRedirectUrl = () => {
...
@@ -36,9 +35,9 @@ export const gotoRedirectUrl = () => {
},
10
);
},
10
);
};
};
export
const
redirectToLogin
=
async
(
)
=>
{
export
const
redirectToLogin
=
(
tipMsg
:
string
)
=>
{
//todo: 使用模态框提示, 但是目前会重复弹出,原因是接口每次都会调用,所以会出现重复弹出
//todo: 使用模态框提示, 但是目前会重复弹出,原因是接口每次都会调用,所以会出现重复弹出
await
WarningMessageAsync
(
l
(
'login.token.error'
)
);
WarningMessageAsync
(
tipMsg
);
window
.
location
.
href
=
'/#/user/login'
;
window
.
location
.
href
=
'/#/user/login'
;
};
};
...
...
dinky-web/src/pages/Other/Login/index.tsx
View file @
1c45d744
...
@@ -74,7 +74,7 @@ const Login: React.FC = () => {
...
@@ -74,7 +74,7 @@ const Login: React.FC = () => {
const
currentTime
=
Date
.
now
();
const
currentTime
=
Date
.
now
();
timeRemaining
=
expirationTime
-
currentTime
;
timeRemaining
=
expirationTime
-
currentTime
;
// use setInterval to set a timer
// use setInterval to set a timer
timer
=
setInterval
(()
=>
redirectToLogin
(),
timeRemaining
);
timer
=
setInterval
(()
=>
redirectToLogin
(
l
(
'login.token.error'
)
),
timeRemaining
);
}
}
return
()
=>
{
return
()
=>
{
clearTimeout
(
timer
);
clearTimeout
(
timer
);
...
@@ -141,7 +141,7 @@ const Login: React.FC = () => {
...
@@ -141,7 +141,7 @@ const Login: React.FC = () => {
setLocalStorageOfToken
(
JSON
.
stringify
(
res
));
setLocalStorageOfToken
(
JSON
.
stringify
(
res
));
}
else
{
}
else
{
// 如果没有获取到token信息,直接跳转到登录页
// 如果没有获取到token信息,直接跳转到登录页
redirectToLogin
();
redirectToLogin
(
l
(
'login.token.error'
)
);
}
}
});
});
}
}
...
...
dinky-web/src/pages/RegCenter/Resource/components/ResourceOverView/index.tsx
View file @
1c45d744
...
@@ -230,12 +230,22 @@ const ResourceOverView: React.FC<connect> = (props) => {
...
@@ -230,12 +230,22 @@ const ResourceOverView: React.FC<connect> = (props) => {
const
handleModalSubmit
=
async
(
value
:
Partial
<
ResourceInfo
>
)
=>
{
const
handleModalSubmit
=
async
(
value
:
Partial
<
ResourceInfo
>
)
=>
{
const
{
id
:
pid
}
=
resourceState
.
rightClickedNode
;
const
{
id
:
pid
}
=
resourceState
.
rightClickedNode
;
if
(
editModal
===
'createFolder'
)
{
if
(
editModal
===
'createFolder'
)
{
await
handleOption
(
API_CONSTANTS
.
RESOURCE_CREATE_FOLDER
,
l
(
'right.menu.createFolder'
),
{
await
handleOption
(
API_CONSTANTS
.
RESOURCE_CREATE_FOLDER
,
l
(
'right.menu.createFolder'
),
{
...
value
,
...
value
,
pid
pid
},
()
=>
handleModalCancel
());
},
()
=>
handleModalCancel
()
);
}
else
if
(
editModal
===
'rename'
)
{
}
else
if
(
editModal
===
'rename'
)
{
await
handleOption
(
API_CONSTANTS
.
RESOURCE_RENAME
,
l
(
'right.menu.rename'
),
{
...
value
,
pid
},()
=>
handleModalCancel
());
await
handleOption
(
API_CONSTANTS
.
RESOURCE_RENAME
,
l
(
'right.menu.rename'
),
{
...
value
,
pid
},
()
=>
handleModalCancel
()
);
}
}
};
};
const
handleUploadCancel
=
async
()
=>
{
const
handleUploadCancel
=
async
()
=>
{
...
...
dinky-web/src/requestErrorConfig.ts
View file @
1c45d744
...
@@ -31,7 +31,9 @@ enum ErrorCode {
...
@@ -31,7 +31,9 @@ enum ErrorCode {
ERROR
=
1
,
ERROR
=
1
,
EXCEPTION
=
5
,
EXCEPTION
=
5
,
PARAMS_ERROR
=
6
,
PARAMS_ERROR
=
6
,
AUTHORIZE_ERROR
=
7
AUTHORIZE_ERROR
=
7
,
SERVER_ERROR
=
504
,
UNAUTHORIZED
=
401
}
}
// Response data format agreed upon with the backend
// Response data format agreed upon with the backend
...
@@ -88,6 +90,13 @@ export const errorConfig: RequestConfig = {
...
@@ -88,6 +90,13 @@ export const errorConfig: RequestConfig = {
// Error reception and handling
// Error reception and handling
errorHandler
:
(
error
:
any
,
opts
:
any
)
=>
{
errorHandler
:
(
error
:
any
,
opts
:
any
)
=>
{
if
(
opts
?.
skipErrorHandler
)
throw
error
;
if
(
opts
?.
skipErrorHandler
)
throw
error
;
function
processNotification
(
error
:
any
,
isEnableTips
:
string
=
'false'
)
{
if
(
getValueFromLocalStorage
(
ENABLE_MODEL_TIP
)
==
isEnableTips
)
{
ErrorNotification
(
error
.
message
,
error
.
code
);
}
}
//The error thrown by our errorThrower.
//The error thrown by our errorThrower.
if
(
error
.
name
===
'BizError'
)
{
if
(
error
.
name
===
'BizError'
)
{
const
errorInfo
:
ResponseStructure
=
error
.
info
;
const
errorInfo
:
ResponseStructure
=
error
.
info
;
...
@@ -97,12 +106,14 @@ export const errorConfig: RequestConfig = {
...
@@ -97,12 +106,14 @@ export const errorConfig: RequestConfig = {
}
else
if
(
error
.
response
)
{
}
else
if
(
error
.
response
)
{
//The request was successfully sent and the server also responded with a status code, but the status code exceeded the range of 2xx
//The request was successfully sent and the server also responded with a status code, but the status code exceeded the range of 2xx
//Authentication error, redirect to login page
//Authentication error, redirect to login page
if
(
error
.
response
.
status
===
401
)
{
if
(
error
.
response
.
status
===
ErrorCode
.
UNAUTHORIZED
)
{
redirectToLogin
();
redirectToLogin
(
error
.
message
);
}
else
if
(
error
.
response
.
status
===
ErrorCode
.
SERVER_ERROR
)
{
processNotification
(
error
);
//Note: when the server is not available or the network is disconnected, redirect to login page
redirectToLogin
(
error
.
message
);
}
else
{
}
else
{
if
(
getValueFromLocalStorage
(
ENABLE_MODEL_TIP
)
==
'true'
)
{
processNotification
(
error
,
'true'
);
ErrorNotification
(
error
.
message
,
error
.
code
);
}
}
}
}
else
if
(
error
.
request
)
{
}
else
if
(
error
.
request
)
{
//The request has been successfully initiated, but no response has been received
//The request has been successfully initiated, but no response has been received
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment