Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 8cb615f

Browse files
committed
Merge branch 'master' into feat/fast-login
2 parents 0b44493 + ef82dac commit 8cb615f

File tree

26 files changed

+94
-35
lines changed

26 files changed

+94
-35
lines changed

example/xconsole-example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xconsole",
3-
"version": "2.3.44",
3+
"version": "2.3.50",
44
"description": "",
55
"main": "src/index.js",
66
"scripts": {
@@ -20,7 +20,7 @@
2020
],
2121
"author": "",
2222
"dependencies": {
23-
"@alicloud/xconsole": "^2.3.44",
23+
"@alicloud/xconsole": "^2.3.50",
2424
"lodash": "^4.17.4",
2525
"moment": "^2.22.1",
2626
"prop-types": "^15.6.1",

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"tagVersionPrefix": ""
1414
}
1515
},
16-
"version": "2.3.44",
16+
"version": "2.3.50",
1717
"lerna": "2.11.0"
1818
}

packages/console-utils/fastlogin/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ const render = async (options: IFastLoginOptions) => {
5757
target: options.target,
5858
// @ts-ignore
5959
type: "one_login", // one_login, password, qr
60+
custom: {
61+
footerComs: ['third-party']
62+
},
6063
loginCallback: (result) => {
6164
if (result.success) {
6265
resolve(result);

packages/console-utils/xconsole-service/src/configuration/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const defaultOption = {
33
// Empty
44
},
55
ignoreError: false,
6+
fastLogin: false,
67
}
78

89
export default defaultOption;

packages/console-utils/xconsole-service/src/interceptors/consoleInterceptor/response.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
/* eslint-disable @typescript-eslint/no-throw-literal */
2+
import qs from 'qs';
23
import { IError, IResponse, IResponseData } from '../../types';
34
import { ApiType } from '../../const/index';
45
import { AxiosResponse } from 'axios';
56

67
const injectErrorPromptAdaptor = (error: IError, response: AxiosResponse) => {
8+
let body = {};
9+
try {
10+
body = qs.parse(response?.config?.data)
11+
} catch (e){
12+
// nothing
13+
}
714
error.response = response;
815
error.code = response.data?.code;
916
error.requestId = response.data?.requestId;
1017
error.message = response.data?.message;
1118
error.details = {
1219
url: response?.config?.url,
13-
body: response?.config?.data,
20+
body: body,
1421
method: response?.config?.method
1522
}
1623
};

packages/console-utils/xconsole-service/src/interceptors/fastloginInterceptor/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import { ApiType } from '../../const/index';
2+
import defaultConfig from '../../configuration/config'
23
import { IResponse, IResponseData } from '../../types';
34
import { login } from './login';
45

56

67
async function fastLoginInterceptor(response: IResponse<IResponseData> ): Promise<IResponse<IResponseData>> {
78
const { data: responseData, config } = response;
8-
const { apiType } = config;
9+
const { apiType, fastLogin } = config;
10+
11+
// 只在开启了 fastLogin 的站点才显示
12+
// @ts-ignore
13+
if((!fastLogin && !defaultConfig.fastLogin) || window?.ALIYUN_CONSOLE_CONFIG?.CHANNEL !== 'OFFICIAL') {
14+
return response;
15+
}
916

1017
if (apiType === ApiType.custom) return response;
1118

packages/console-utils/xconsole-service/src/interceptors/fastloginInterceptor/login.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ export const LoginContent: React.FC<any> = (props) => {
3636
if (ref.current || document.querySelector('#loginContent')) {
3737
(async () => {
3838
try {
39-
const result = await render({ env: 'prepub', target: ref.current || document.querySelector('#loginContent'), height: 560 });
40-
console.log(result)
39+
const result = await render({ env: 'prepub', target: ref.current || document.querySelector('#loginContent'), height: 560, width: 501 });
4140
if (result.success) {
4241
await refreshToken();
4342
}
@@ -52,12 +51,12 @@ export const LoginContent: React.FC<any> = (props) => {
5251

5352
return (
5453
<Dialog visible footer={<div/>} onClose={() => {props.onError()}}>
55-
<div style={{height: 660, width: 500, paddingTop: 20}}>
54+
<div style={{height: 630, width: 500, paddingTop: 20}}>
5655
<div ref={ref} id="loginContent" ></div>
5756
<div style={{textAlign: 'center', width: 500, paddingTop: 20, fontSize: 13}}>
58-
<span style={{verticalAlign: 'text-top'}}>快速登录有问题?直接去</span>
59-
<Button text type="primary">登录页</Button>
60-
<span style={{verticalAlign: 'text-top'}}>登录</span>
57+
<span >快速登录有问题?直接去</span>
58+
<a href="#" onClick={() => { window.location.reload()}}>登录页</a>
59+
<span >登录</span>
6160
</div>
6261
</div>
6362
</Dialog>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { getLocale } from '../../utils/index';
2+
3+
const locale = getLocale() || 'en-US';
4+
/* eslint-disable max-len */
5+
const messages = {
6+
'en-US': {
7+
8+
},
9+
10+
// 中文文案
11+
'zh-CN': {
12+
13+
},
14+
15+
};
16+
17+
export default (messages as any)[locale] || messages['en-US'];

packages/console-utils/xconsole-service/src/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export default function createRequest(
3939

4040
instance.interceptors.response.use(armsResponseInterceptor);
4141
instance.interceptors.response.use(fastLoginInterceptor);
42-
instance.interceptors.response.use(consoleResponseInterceptor);
4342
instance.interceptors.response.use(consoleRiskInterceptor);
43+
instance.interceptors.response.use(consoleResponseInterceptor);
4444
}
4545

4646
let requestInterceptor = requestInterceptors.shift();

packages/console-utils/xconsole-service/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type Risk = {
3131

3232
export interface IOptions extends AxiosRequestConfig {
3333
apiType?: ApiType;
34+
fastLogin?: boolean;
3435
ignoreError?: boolean;
3536
description?: any;
3637
useCors?: boolean;

0 commit comments

Comments
 (0)