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

Commit e0a807f

Browse files
committed
fix: change route regionid changed error
1 parent b6dd9a2 commit e0a807f

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

packages/console-utils/xconsole-context/src/region/determineRegionId.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
1-
// @ts-ignore
2-
import Cookie from 'js-cookie';
3-
41
import isArray from 'lodash/isArray';
52
import { IPayloadRegion } from 'src/types/ConsoleBase';
6-
7-
// 默认标识
8-
const DEFAULT_COOKIE_KEY = 'activeRegionId';
9-
const CURRENT_DEFAULT_COOKIE_KEY = 'currentRegionId';
10-
11-
const getRegionFromCookie = (key = ''): string => {
12-
if (key === '') {
13-
return (
14-
Cookie.get(CURRENT_DEFAULT_COOKIE_KEY) ||
15-
Cookie.get(DEFAULT_COOKIE_KEY) ||
16-
'cn-hangzhou'
17-
);
18-
}
19-
return Cookie.get(key);
20-
};
3+
import { getActiveId } from './cookies';
214

225
const getIdFromItem = (item: IPayloadRegion): string => {
236
return item.id
@@ -33,7 +16,7 @@ export const determineRegionId = (
3316
// 没有调用者从 context 中获取失败, 或调用者明确不为该参数赋值,
3417
// 则使用 getActiveId 从 cookie 中取值进行兜底, 尽量让该值保持一个有效的状态.
3518
// 只有在用户第一次访问控制台时, 该值可能为空
36-
const exactCurrentActiveId = currentActiveId || getRegionFromCookie();
19+
const exactCurrentActiveId = currentActiveId || getActiveId();
3720

3821
// 对 dataSource 进行预处理, 如果不符合期望, 则直接返回当前的 activeId
3922
// 之所以没有返回用户声明的 id, 是因为用户的输入无法进行预测,

0 commit comments

Comments
 (0)