rexma-design 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "rexma-design",
3
3
  "name": "rexma-design",
4
4
  "displayName": "rexma-design",
5
- "version": "1.2.0",
5
+ "version": "1.2.2",
6
6
  "description": "rexma-design",
7
7
  "author": "mqyun",
8
8
  "keywords": [
@@ -10,15 +10,20 @@ type IGetClientSignParams = {
10
10
  developmentClientSign?: IXinhuaClientState['clientSign'];
11
11
  };
12
12
 
13
+ type IAesDecryptParams = {
14
+ key: string;
15
+ offset: string;
16
+ };
17
+
13
18
  class ClientSign {
14
19
  /**
15
20
  * ASE 解密
16
21
  * @description 使用加密秘钥,对 需要解密的参数 进行解密
17
- * @param {string} content - 需要解密的参数
18
- * @param {string} params.key - 加密密钥(长度必须是 16 的整数倍)
19
- * @param {string} params.offset - 偏移量
22
+ * @param content - 需要解密的参数
23
+ * @param params - 加密信息
20
24
  */
21
- static aesDecryptParams(content, { key, offset }) {
25
+ static aesDecryptParams(content: string, params: IAesDecryptParams) {
26
+ const { key, offset } = params;
22
27
  if (!key || !offset) {
23
28
  throw new Error('缺少加密相关配置');
24
29
  }
@@ -42,8 +47,7 @@ class ClientSign {
42
47
  */
43
48
  static async getClientSign(options: IGetClientSignParams) {
44
49
  const { developmentClientSign, key, offset, moduleCode } = options;
45
- // @ts-ignore
46
- if (process?.env?.NODE_ENV === 'development' && developmentClientSign) {
50
+ if (import.meta.env.DEV && developmentClientSign) {
47
51
  return developmentClientSign;
48
52
  }
49
53
  if (!xh.isMediaConvergenceXinhuaApp()) {
@@ -23,6 +23,8 @@ export type IXinhuaClientInitOptions = {
23
23
  };
24
24
  /** 本地运行时的全局状态(仅浏览器环境生效) */
25
25
  developmentState?: IXinhuaClientState;
26
+ /** 未登录时是否需要用户登录(useState 调用时生效) */
27
+ goLogin?: boolean;
26
28
  /** 配置该项后,本地环境 developmentState 在客户端也生效 */
27
29
  clientDebug?: boolean;
28
30
  };
@@ -27,17 +27,24 @@ class XinhuaClient {
27
27
 
28
28
  private static async stateInit() {
29
29
  const initOptions = this.initOptions;
30
- // @ts-ignore
31
- if (process?.env?.NODE_ENV === 'development' && initOptions.developmentState) {
30
+ if (import.meta.env.DEV && initOptions.developmentState) {
31
+ // 本地开发、配置的本地开发环境的数据
32
32
  this.state = {
33
33
  ...this.state,
34
34
  ...initOptions.developmentState,
35
35
  };
36
36
  }
37
- if (xh.isMediaConvergenceXinhuaApp() && !initOptions.clientDebug) {
37
+ const isClientDebug = import.meta.env.DEV && initOptions.clientDebug;
38
+ if (xh.isMediaConvergenceXinhuaApp() && !isClientDebug) {
38
39
  // 客户端环境
39
40
  this.state.siteId = getValueFromUA('currentSiteId');
40
- this.state.userId = getValueFromUA('userId');
41
+ const userInfo = await new Promise<any>((resolve) => {
42
+ xh.getUserInfo({
43
+ goLogin: initOptions.goLogin ?? false,
44
+ success: (res) => resolve(res),
45
+ });
46
+ });
47
+ this.state.userId = userInfo?.info?.id;
41
48
  const numberStatusBarHeight = Number(getValueFromUA('statusBarHeight'));
42
49
  this.state.statusBarHeight = isNaN(numberStatusBarHeight) ? 0 : numberStatusBarHeight;
43
50
  this.state.clientSign = await ClientSign.getClientSign({