fix: Just show session expired error when 401

just show session expired error when 401

Change-Id: If561f233ba87bbb732556a29ac59c4316768b7a6
This commit is contained in:
zhuyue 2021-09-29 16:18:11 +08:00
parent 1b9c23e5c2
commit 520a48e954
4 changed files with 10 additions and 2 deletions

View File

@ -639,7 +639,10 @@ export default class BaseList extends React.Component {
// eslint-disable-next-line no-console
console.log('fetch list error', e);
const { message = '', data, status } = (e || {}).response || e || {};
if (status === 500) {
if (status === 401) {
const title = t('The session has expired, please log in again.');
Notify.errorWithDetail(null, title);
} else if (status === 500) {
const sysErr = t('System is error, please try again later.');
const title = `${t('Get {name} error.', {
name: this.name.toLowerCase(),

View File

@ -266,7 +266,10 @@ export default class DetailBase extends React.Component {
// eslint-disable-next-line no-console
console.log(e);
const { data, status } = (e || {}).response || e || {};
if (status === 404) {
if (status === 401) {
const title = t('The session has expired, please log in again.');
Notify.errorWithDetail(null, title);
} else if (status === 404) {
this.setState({ notFound: true });
Notify.warn(
t('{name} {id} could not be found.', {

View File

@ -1572,6 +1572,7 @@
"The selected VPC/ subnet does not have IPv6 enabled.": "The selected VPC/ subnet does not have IPv6 enabled.",
"The selected network has no subnet": "The selected network has no subnet",
"The server {name} is locked. Please unlock first.": "The server {name} is locked. Please unlock first.",
"The session has expired, please log in again.": "The session has expired, please log in again.",
"The shelved offloaded instance only supports immediate deletion": "The shelved offloaded instance only supports immediate deletion",
"The start source is a template used to create an instance. You can choose an image or a bootable volume.": "The start source is a template used to create an instance. You can choose an image or a bootable volume.",
"The starting number must be less than the ending number": "The starting number must be less than the ending number",

View File

@ -1572,6 +1572,7 @@
"The selected VPC/ subnet does not have IPv6 enabled.": "所选的VPC/子网未开通IPv6",
"The selected network has no subnet": "选择的网络没有子网",
"The server {name} is locked. Please unlock first.": "云主机{name}已被锁定,请先解锁。",
"The session has expired, please log in again.": "会话已过期,请重新登录。",
"The shelved offloaded instance only supports immediate deletion": "已归档的云主机仅支持立即删除",
"The start source is a template used to create an instance. You can choose an image or a bootable volume.": "启动源是用来创建云主机的模板, 您可以选择镜像或者可启动的卷。",
"The starting number must be less than the ending number": "起始数字必须小于结束数字",