jmash-core-mp 0.1.21 → 0.1.22

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.
Files changed (150) hide show
  1. package/.editorconfig +9 -9
  2. package/README.md +60 -60
  3. package/babel.config.json +34 -34
  4. package/eslint.config.mjs +7 -7
  5. package/lib/api/auth/index.d.ts +21 -21
  6. package/lib/api/auth/index.js +199 -199
  7. package/lib/api/auth/types.d.ts +86 -86
  8. package/lib/api/auth/types.js +9 -9
  9. package/lib/api/cms/index.d.ts +20 -20
  10. package/lib/api/cms/index.js +161 -161
  11. package/lib/api/cms/types.d.ts +200 -200
  12. package/lib/api/cms/types.js +1 -1
  13. package/lib/api/constant.d.ts +5 -5
  14. package/lib/api/constant.js +6 -6
  15. package/lib/api/dict/index.d.ts +18 -18
  16. package/lib/api/dict/index.js +34 -34
  17. package/lib/api/dict/types.d.ts +28 -28
  18. package/lib/api/dict/types.js +1 -1
  19. package/lib/api/dicts.d.ts +18 -18
  20. package/lib/api/dicts.js +67 -67
  21. package/lib/api/files/index.d.ts +25 -25
  22. package/lib/api/files/index.js +135 -135
  23. package/lib/api/files/types.d.ts +38 -38
  24. package/lib/api/files/types.js +1 -1
  25. package/lib/api/index.d.ts +4 -4
  26. package/lib/api/index.js +6 -6
  27. package/lib/api/myorgan/types.d.ts +22 -22
  28. package/lib/api/myorgan/types.js +1 -1
  29. package/lib/api/region/index.d.ts +7 -7
  30. package/lib/api/region/index.js +19 -19
  31. package/lib/api/region/types.d.ts +19 -19
  32. package/lib/api/region/types.js +1 -1
  33. package/lib/api/storage/index.d.ts +10 -10
  34. package/lib/api/storage/index.js +43 -43
  35. package/lib/api/storage/types.d.ts +28 -28
  36. package/lib/api/storage/types.js +1 -1
  37. package/lib/api/types.d.ts +42 -42
  38. package/lib/api/types.js +1 -1
  39. package/lib/app.mpx.d.ts +1 -1
  40. package/lib/components/auth-user/jmash-update-user.mpx.d.ts +1 -1
  41. package/lib/components/auth-user/jmash-user.mpx.d.ts +1 -1
  42. package/lib/components/cms/jmash-cms-acticle-list.mpx.d.ts +1 -1
  43. package/lib/components/cms/jmash-cms-article-item.mpx.d.ts +1 -1
  44. package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +1 -0
  45. package/lib/components/cms/jmash-cms-article.mpx.d.ts +1 -1
  46. package/lib/components/cms/jmash-cms-like.mpx.d.ts +1 -1
  47. package/lib/components/common/jmash-upload-picture.mpx.d.ts +1 -0
  48. package/lib/components/core/jmash-login.mpx.d.ts +1 -0
  49. package/lib/index.d.ts +21 -21
  50. package/lib/index.js +14 -14
  51. package/lib/packages/pages/cms/cms-article-list.mpx.d.ts +1 -1
  52. package/lib/pages/index.mpx.d.ts +1 -0
  53. package/lib/store/user.d.ts +31 -31
  54. package/lib/store/user.js +227 -227
  55. package/lib/utils/common.d.ts +35 -35
  56. package/lib/utils/common.js +166 -166
  57. package/lib/utils/config.d.ts +5 -5
  58. package/lib/utils/config.js +29 -29
  59. package/lib/utils/db.d.ts +21 -21
  60. package/lib/utils/db.js +84 -84
  61. package/lib/utils/grpc.d.ts +5 -5
  62. package/lib/utils/grpc.js +20 -20
  63. package/lib/utils/net.d.ts +7 -7
  64. package/lib/utils/net.js +15 -15
  65. package/lib/utils/request.d.ts +2 -2
  66. package/lib/utils/request.js +123 -123
  67. package/mpx.config.js +27 -27
  68. package/package.json +1 -1
  69. package/postcss.config.js +11 -11
  70. package/project.config.json +24 -24
  71. package/project.private.config.json +13 -13
  72. package/public/index.html +15 -15
  73. package/src/api/auth/index.ts +227 -227
  74. package/src/api/auth/types.ts +166 -166
  75. package/src/api/cms/index.ts +218 -218
  76. package/src/api/cms/types.ts +379 -379
  77. package/src/api/constant.ts +6 -6
  78. package/src/api/dict/index.ts +44 -44
  79. package/src/api/dict/types.ts +49 -49
  80. package/src/api/dicts.ts +72 -72
  81. package/src/api/files/index.ts +163 -163
  82. package/src/api/files/types.ts +67 -67
  83. package/src/api/index.ts +11 -11
  84. package/src/api/myorgan/types.ts +42 -42
  85. package/src/api/region/index.ts +23 -23
  86. package/src/api/region/types.ts +36 -36
  87. package/src/api/storage/index.ts +62 -62
  88. package/src/api/storage/types.ts +54 -54
  89. package/src/api/types.ts +72 -72
  90. package/src/app.mpx +71 -71
  91. package/src/components/auth-user/jmash-logout.mpx +91 -91
  92. package/src/components/auth-user/jmash-update-user.mpx +386 -386
  93. package/src/components/auth-user/jmash-update-user.web.mpx +366 -366
  94. package/src/components/auth-user/jmash-user.mpx +359 -359
  95. package/src/components/cms/jmash-cms-acticle-list.mpx +182 -182
  96. package/src/components/cms/jmash-cms-article-item.mpx +241 -241
  97. package/src/components/cms/jmash-cms-article-view.mpx +131 -131
  98. package/src/components/cms/jmash-cms-article.mpx +68 -68
  99. package/src/components/cms/jmash-cms-like.mpx +151 -151
  100. package/src/components/common/jmash-avatar-edit.mpx +153 -153
  101. package/src/components/common/jmash-cascader-region.mpx +112 -112
  102. package/src/components/common/jmash-menu.mpx +129 -129
  103. package/src/components/common/jmash-none-data.mpx +82 -82
  104. package/src/components/common/jmash-pic-swiper.mpx +71 -71
  105. package/src/components/common/jmash-popup.mpx +137 -137
  106. package/src/components/common/jmash-search.mpx +126 -126
  107. package/src/components/common/jmash-single-btn.mpx +53 -53
  108. package/src/components/common/jmash-stepper.mpx +214 -214
  109. package/src/components/common/jmash-tab-bar.mpx +50 -50
  110. package/src/components/common/jmash-textarea.mpx +88 -88
  111. package/src/components/common/jmash-top-navigation.mpx +203 -203
  112. package/src/components/common/jmash-upload-picture.mpx +129 -126
  113. package/src/components/core/jmash-cms-protocol.mpx +66 -66
  114. package/src/components/core/jmash-login.ali.mpx +284 -284
  115. package/src/components/core/jmash-login.mpx +348 -348
  116. package/src/components/core/jmash-login.web.mpx +421 -421
  117. package/src/components/core/jmash-popup-login.ali.mpx +311 -311
  118. package/src/components/core/jmash-popup-login.mpx +415 -415
  119. package/src/components/core/jmash-popup-login.web.mpx +389 -389
  120. package/src/custom-tab-bar/index.mpx +10 -10
  121. package/src/global.d.ts +11 -11
  122. package/src/index.ts +71 -71
  123. package/src/packages/index.mpx +10 -10
  124. package/src/packages/pages/auth/cms-protocol.mpx +31 -31
  125. package/src/packages/pages/auth/login.mpx +59 -59
  126. package/src/packages/pages/auth/update-user.mpx +17 -17
  127. package/src/packages/pages/cms/cms-article-list.mpx +164 -164
  128. package/src/packages/pages/cms/cms-article.mpx +32 -32
  129. package/src/pages/basic-component.mpx +30 -30
  130. package/src/pages/half-home.mpx +58 -58
  131. package/src/pages/home.mpx +52 -52
  132. package/src/pages/home2.mpx +47 -47
  133. package/src/pages/index.mpx +13 -3
  134. package/src/pages/tabbar/home.mpx +77 -77
  135. package/src/pages/tabbar/my.mpx +80 -80
  136. package/src/store/user.ts +270 -270
  137. package/src/styles/index.scss +20 -20
  138. package/src/styles/vars.scss +27 -27
  139. package/src/utils/common.ts +179 -179
  140. package/src/utils/config.ts +35 -35
  141. package/src/utils/db.ts +100 -100
  142. package/src/utils/grpc.ts +21 -21
  143. package/src/utils/net.ts +18 -18
  144. package/src/utils/request.ts +134 -134
  145. package/static/ali/mini.project.json +4 -4
  146. package/static/dd/project.config.json +15 -15
  147. package/static/swan/project.swan.json +14 -14
  148. package/static/tt/project.config.json +11 -11
  149. package/static/wx/project.config.json +40 -40
  150. package/uno.config.js +9 -9
@@ -1,179 +1,179 @@
1
- import mpx from "@mpxjs/core";
2
-
3
- // 获取不同手机的顶部/底部高度
4
- export const getHeight = () => {
5
- // 手机顶部电量等信息的高度+7 状态栏的高度+7
6
- let navigationPaddingHeight = 0;
7
- // 顶部整体高度(包括胶囊球高度)
8
- let topHeight = 0;
9
- // 手机底部的安全距离
10
- let bottomHeight = 0;
11
- // 胶囊球右边界到手机左侧的坐标-坐标信息以屏幕左上角为原点
12
- let MenuButtonRight = 0;
13
- // 胶囊球左边界到手机左侧的坐标-坐标信息以屏幕左上角为原点
14
- let MenuButtonLeft = 0;
15
- // 胶囊球上边界到手机顶部的坐标-坐标信息以屏幕左上角为原点
16
- let MenuButtonTop = 0;
17
- // 胶囊球下边界到手机顶部的坐标-坐标信息以屏幕左上角为原点
18
- let MenuButtonBottom = 0;
19
- // 胶囊球宽度
20
- let MenuButtonWidth = 0;
21
- // 胶囊球高度
22
- let MenuButtonHeight = 0;
23
- // 状态栏的高度
24
- let MenuButtonBounding = 0;
25
- // 屏幕宽度
26
- let screenWidth = 0;
27
- // 屏幕高度
28
- let screenHeight = 0;
29
- try {
30
- MenuButtonHeight = mpx.getMenuButtonBoundingClientRect().height
31
- ? mpx.getMenuButtonBoundingClientRect().height
32
- : 0;
33
- navigationPaddingHeight =
34
- mpx.getWindowInfo().statusBarHeight + 7
35
- ? mpx.getWindowInfo().statusBarHeight + 7
36
- : 0;
37
- topHeight = MenuButtonHeight + navigationPaddingHeight;
38
- bottomHeight =
39
- mpx.getWindowInfo().screenHeight - mpx.getWindowInfo().safeArea.bottom
40
- ? mpx.getWindowInfo().screenHeight - mpx.getWindowInfo().safeArea.bottom
41
- : 0;
42
- MenuButtonRight = mpx.getMenuButtonBoundingClientRect().right;
43
- MenuButtonLeft = mpx.getMenuButtonBoundingClientRect().left;
44
- MenuButtonTop = mpx.getMenuButtonBoundingClientRect().top;
45
- MenuButtonBottom = mpx.getMenuButtonBoundingClientRect().bottom;
46
- MenuButtonWidth = mpx.getMenuButtonBoundingClientRect().width;
47
- MenuButtonBounding = mpx.getWindowInfo().statusBarHeight;
48
- screenWidth = mpx.getWindowInfo().screenWidth;
49
- screenHeight = mpx.getWindowInfo().screenHeight;
50
- } catch (error) {
51
- console.log("getHeight", error);
52
- }
53
-
54
- /**
55
- * 判断手机型号如果没有底部横线的时候,添加的默认高度
56
- * @param height 本身计算的高度
57
- * @param stackingHeight 需要叠加的高度
58
- */
59
- function computeHeightFn(height: number, stackingHeight: number) {
60
- return height !== 0 ? height : height + stackingHeight;
61
- }
62
- /**
63
- * 原有基础上添加高度
64
- * @param height 本身计算的高度
65
- * @param addHeight 相加的高度
66
- */
67
- function addition(height: number, addHeight: number) {
68
- return height + addHeight;
69
- }
70
- return {
71
- navigationPaddingHeight,
72
- topHeight,
73
- bottomHeight,
74
- MenuButtonRight,
75
- MenuButtonLeft,
76
- MenuButtonTop,
77
- MenuButtonBottom,
78
- MenuButtonWidth,
79
- MenuButtonHeight,
80
- MenuButtonBounding,
81
- screenWidth,
82
- screenHeight,
83
- computeHeightFn,
84
- addition,
85
- };
86
- };
87
-
88
- /**
89
- * 格式化日期时间字符串
90
- * @param dateTimeString 日期时间字符串
91
- * @returns 格式化后的日期时间字符串
92
- */
93
- export const formatDateTime = (dateTimeString: string, format?: any) => {
94
- const date = new Date(dateTimeString);
95
- // 如果日期无效(即日期为Invalid Date),则返回一个空字符串或默认值
96
- if (isNaN(date.getTime())) {
97
- return "";
98
- }
99
- const year = date.getFullYear();
100
- const month = ("0" + (date.getMonth() + 1)).slice(-2);
101
- const day = ("0" + date.getDate()).slice(-2);
102
- const hours = ("0" + date.getHours()).slice(-2);
103
- const minutes = ("0" + date.getMinutes()).slice(-2);
104
- const seconds = ("0" + date.getSeconds()).slice(-2);
105
- if (format === "YYYY-MM-DD HH:mm:ss") {
106
- return (
107
- year +
108
- "-" +
109
- month +
110
- "-" +
111
- day +
112
- " " +
113
- hours +
114
- ":" +
115
- minutes +
116
- ":" +
117
- seconds
118
- );
119
- }
120
- if (format === "YYYY-MM-DD HH:mm") {
121
- return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
122
- }
123
- if (format === "YYYY-MM-DD") {
124
- return year + "-" + month + "-" + day;
125
- }
126
- if (format === "HH:mm:ss") {
127
- return hours + ":" + minutes + ":" + seconds;
128
- }
129
- if (format === "HH:mm") {
130
- return hours + ":" + minutes;
131
- }
132
- return "";
133
- };
134
-
135
- /**
136
- * 正则校验规则
137
- * @param {string} value 需要校验的值
138
- * @param {string} message 错误提示信息
139
- * @param {string} rules 正则校验规则
140
- */
141
- export const validateRules = (
142
- value: string,
143
- message: string,
144
- rules: any
145
- ): boolean => {
146
- if (value && !rules.test(value)) {
147
- // 显示错误提示
148
- mpx.showToast({
149
- title: message,
150
- icon: "none",
151
- duration: 2000,
152
- });
153
- return false;
154
- }
155
- return true;
156
- };
157
-
158
- /**
159
- * 校验必填项
160
- * @param {string} value 需要校验的值
161
- * @param {string} message 错误提示信息
162
- */
163
- export const validateRequired = (
164
- value: string | number,
165
- message: string
166
- ): boolean => {
167
- console.log(value, message);
168
- const valueStr = typeof value === "number" ? String(value) : value;
169
- if (!valueStr || valueStr.trim() === "") {
170
- // 显示错误提示
171
- mpx.showToast({
172
- title: message,
173
- icon: "none",
174
- duration: 2000,
175
- });
176
- return false;
177
- }
178
- return true;
179
- };
1
+ import mpx from "@mpxjs/core";
2
+
3
+ // 获取不同手机的顶部/底部高度
4
+ export const getHeight = () => {
5
+ // 手机顶部电量等信息的高度+7 状态栏的高度+7
6
+ let navigationPaddingHeight = 0;
7
+ // 顶部整体高度(包括胶囊球高度)
8
+ let topHeight = 0;
9
+ // 手机底部的安全距离
10
+ let bottomHeight = 0;
11
+ // 胶囊球右边界到手机左侧的坐标-坐标信息以屏幕左上角为原点
12
+ let MenuButtonRight = 0;
13
+ // 胶囊球左边界到手机左侧的坐标-坐标信息以屏幕左上角为原点
14
+ let MenuButtonLeft = 0;
15
+ // 胶囊球上边界到手机顶部的坐标-坐标信息以屏幕左上角为原点
16
+ let MenuButtonTop = 0;
17
+ // 胶囊球下边界到手机顶部的坐标-坐标信息以屏幕左上角为原点
18
+ let MenuButtonBottom = 0;
19
+ // 胶囊球宽度
20
+ let MenuButtonWidth = 0;
21
+ // 胶囊球高度
22
+ let MenuButtonHeight = 0;
23
+ // 状态栏的高度
24
+ let MenuButtonBounding = 0;
25
+ // 屏幕宽度
26
+ let screenWidth = 0;
27
+ // 屏幕高度
28
+ let screenHeight = 0;
29
+ try {
30
+ MenuButtonHeight = mpx.getMenuButtonBoundingClientRect().height
31
+ ? mpx.getMenuButtonBoundingClientRect().height
32
+ : 0;
33
+ navigationPaddingHeight =
34
+ mpx.getWindowInfo().statusBarHeight + 7
35
+ ? mpx.getWindowInfo().statusBarHeight + 7
36
+ : 0;
37
+ topHeight = MenuButtonHeight + navigationPaddingHeight;
38
+ bottomHeight =
39
+ mpx.getWindowInfo().screenHeight - mpx.getWindowInfo().safeArea.bottom
40
+ ? mpx.getWindowInfo().screenHeight - mpx.getWindowInfo().safeArea.bottom
41
+ : 0;
42
+ MenuButtonRight = mpx.getMenuButtonBoundingClientRect().right;
43
+ MenuButtonLeft = mpx.getMenuButtonBoundingClientRect().left;
44
+ MenuButtonTop = mpx.getMenuButtonBoundingClientRect().top;
45
+ MenuButtonBottom = mpx.getMenuButtonBoundingClientRect().bottom;
46
+ MenuButtonWidth = mpx.getMenuButtonBoundingClientRect().width;
47
+ MenuButtonBounding = mpx.getWindowInfo().statusBarHeight;
48
+ screenWidth = mpx.getWindowInfo().screenWidth;
49
+ screenHeight = mpx.getWindowInfo().screenHeight;
50
+ } catch (error) {
51
+ console.log("getHeight", error);
52
+ }
53
+
54
+ /**
55
+ * 判断手机型号如果没有底部横线的时候,添加的默认高度
56
+ * @param height 本身计算的高度
57
+ * @param stackingHeight 需要叠加的高度
58
+ */
59
+ function computeHeightFn(height: number, stackingHeight: number) {
60
+ return height !== 0 ? height : height + stackingHeight;
61
+ }
62
+ /**
63
+ * 原有基础上添加高度
64
+ * @param height 本身计算的高度
65
+ * @param addHeight 相加的高度
66
+ */
67
+ function addition(height: number, addHeight: number) {
68
+ return height + addHeight;
69
+ }
70
+ return {
71
+ navigationPaddingHeight,
72
+ topHeight,
73
+ bottomHeight,
74
+ MenuButtonRight,
75
+ MenuButtonLeft,
76
+ MenuButtonTop,
77
+ MenuButtonBottom,
78
+ MenuButtonWidth,
79
+ MenuButtonHeight,
80
+ MenuButtonBounding,
81
+ screenWidth,
82
+ screenHeight,
83
+ computeHeightFn,
84
+ addition,
85
+ };
86
+ };
87
+
88
+ /**
89
+ * 格式化日期时间字符串
90
+ * @param dateTimeString 日期时间字符串
91
+ * @returns 格式化后的日期时间字符串
92
+ */
93
+ export const formatDateTime = (dateTimeString: string, format?: any) => {
94
+ const date = new Date(dateTimeString);
95
+ // 如果日期无效(即日期为Invalid Date),则返回一个空字符串或默认值
96
+ if (isNaN(date.getTime())) {
97
+ return "";
98
+ }
99
+ const year = date.getFullYear();
100
+ const month = ("0" + (date.getMonth() + 1)).slice(-2);
101
+ const day = ("0" + date.getDate()).slice(-2);
102
+ const hours = ("0" + date.getHours()).slice(-2);
103
+ const minutes = ("0" + date.getMinutes()).slice(-2);
104
+ const seconds = ("0" + date.getSeconds()).slice(-2);
105
+ if (format === "YYYY-MM-DD HH:mm:ss") {
106
+ return (
107
+ year +
108
+ "-" +
109
+ month +
110
+ "-" +
111
+ day +
112
+ " " +
113
+ hours +
114
+ ":" +
115
+ minutes +
116
+ ":" +
117
+ seconds
118
+ );
119
+ }
120
+ if (format === "YYYY-MM-DD HH:mm") {
121
+ return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
122
+ }
123
+ if (format === "YYYY-MM-DD") {
124
+ return year + "-" + month + "-" + day;
125
+ }
126
+ if (format === "HH:mm:ss") {
127
+ return hours + ":" + minutes + ":" + seconds;
128
+ }
129
+ if (format === "HH:mm") {
130
+ return hours + ":" + minutes;
131
+ }
132
+ return "";
133
+ };
134
+
135
+ /**
136
+ * 正则校验规则
137
+ * @param {string} value 需要校验的值
138
+ * @param {string} message 错误提示信息
139
+ * @param {string} rules 正则校验规则
140
+ */
141
+ export const validateRules = (
142
+ value: string,
143
+ message: string,
144
+ rules: any
145
+ ): boolean => {
146
+ if (value && !rules.test(value)) {
147
+ // 显示错误提示
148
+ mpx.showToast({
149
+ title: message,
150
+ icon: "none",
151
+ duration: 2000,
152
+ });
153
+ return false;
154
+ }
155
+ return true;
156
+ };
157
+
158
+ /**
159
+ * 校验必填项
160
+ * @param {string} value 需要校验的值
161
+ * @param {string} message 错误提示信息
162
+ */
163
+ export const validateRequired = (
164
+ value: string | number,
165
+ message: string
166
+ ): boolean => {
167
+ console.log(value, message);
168
+ const valueStr = typeof value === "number" ? String(value) : value;
169
+ if (!valueStr || valueStr.trim() === "") {
170
+ // 显示错误提示
171
+ mpx.showToast({
172
+ title: message,
173
+ icon: "none",
174
+ duration: 2000,
175
+ });
176
+ return false;
177
+ }
178
+ return true;
179
+ };
@@ -1,35 +1,35 @@
1
- import { AppConfig } from "../api/types";
2
- import mpx from "@mpxjs/core";
3
-
4
- const defaultConfig: AppConfig = {
5
- name: "Jmash Core MPX",
6
- dev: true,
7
- testNewUser: false,
8
- tenant: "xyvcard",
9
- baseUrl: "https://mm.sooyie.cn",
10
- resourceUrl: "https://mm.sooyie.cn/v1/file/path/wxapp",
11
- appId: "",
12
- componentAppid: "wxe1b784ea80c01f40",
13
- wechatComponentAppId: "",
14
- wechatAppId: "",
15
- wechatBiz: "",
16
- siteId: "c0a28f0f-023a-420b-b4e8-0ce138ac8269",
17
- };
18
-
19
- const config: AppConfig = { ...defaultConfig };
20
-
21
- function setConfig(cfg: Partial<AppConfig>) {
22
- Object.assign(config, cfg);
23
- }
24
-
25
- function initConfig(config: Partial<AppConfig>, mode: string) {
26
- if (__mpx_mode__ !== "web") {
27
- // 只有运行时才能调用
28
- const accountInfo = mpx.getAccountInfoSync();
29
- // 微信
30
- config.appId = accountInfo.miniProgram.appId;
31
- }
32
- return config;
33
- }
34
-
35
- export { config, setConfig, initConfig };
1
+ import { AppConfig } from "../api/types";
2
+ import mpx from "@mpxjs/core";
3
+
4
+ const defaultConfig: AppConfig = {
5
+ name: "Jmash Core MPX",
6
+ dev: true,
7
+ testNewUser: false,
8
+ tenant: "xyvcard",
9
+ baseUrl: "https://mm.sooyie.cn",
10
+ resourceUrl: "https://mm.sooyie.cn/v1/file/path/wxapp",
11
+ appId: "",
12
+ componentAppid: "wxe1b784ea80c01f40",
13
+ wechatComponentAppId: "",
14
+ wechatAppId: "",
15
+ wechatBiz: "",
16
+ siteId: "c0a28f0f-023a-420b-b4e8-0ce138ac8269",
17
+ };
18
+
19
+ const config: AppConfig = { ...defaultConfig };
20
+
21
+ function setConfig(cfg: Partial<AppConfig>) {
22
+ Object.assign(config, cfg);
23
+ }
24
+
25
+ function initConfig(config: Partial<AppConfig>, mode: string) {
26
+ if (__mpx_mode__ !== "web") {
27
+ // 只有运行时才能调用
28
+ const accountInfo = mpx.getAccountInfoSync();
29
+ // 微信
30
+ config.appId = accountInfo.miniProgram.appId;
31
+ }
32
+ return config;
33
+ }
34
+
35
+ export { config, setConfig, initConfig };
package/src/utils/db.ts CHANGED
@@ -1,100 +1,100 @@
1
- import mpx from "@mpxjs/core";
2
- import type { TokenModel, UserInfo } from "../api/auth/types";
3
-
4
- // 本地存储
5
- class LocalStorage {
6
- // 获取token
7
- getToken(): string {
8
- return mpx.getStorageSync("token");
9
- }
10
- // 用户租户
11
- getUserTenant(): string {
12
- return this.getUserInfo().storage as string;
13
- }
14
- //获取组织租户
15
- getOrganTenant(tenant: string): string {
16
- return mpx.getStorageSync("OrganTenant:" + tenant);
17
- }
18
-
19
- //是否Token过期.
20
- isTokenExpires(): boolean {
21
- const expiresDate = this.getTokenExpiresDate();
22
- if (this.getToken() && expiresDate) {
23
- const now = new Date().getTime();
24
- //提前30秒过期.
25
- return now + 30000 > expiresDate;
26
- }
27
- return true;
28
- }
29
-
30
- // 获取刷新token
31
- getRefreshToken(): string {
32
- return mpx.getStorageSync("refreshToken");
33
- }
34
-
35
- // 删除刷新token
36
- removeRefreshToken() {
37
- mpx.removeStorageSync("refreshToken");
38
- }
39
-
40
- // 获取Token 过期时间
41
- getTokenExpiresDate(): number {
42
- return mpx.getStorageSync("expiresDate");
43
- }
44
-
45
- // 设置token
46
- setToken(data: TokenModel) {
47
- mpx.setStorageSync("token", data.accessToken);
48
- mpx.setStorageSync("expiresIn", data.expiresIn);
49
- mpx.setStorageSync("refreshToken", data.refreshToken);
50
- const expiresDate = new Date().getTime() + data.expiresIn * 1000;
51
- mpx.setStorageSync("expiresDate", expiresDate);
52
- }
53
-
54
- // 清理本地缓存
55
- clearStorage(): void {
56
- mpx.clearStorage();
57
- }
58
-
59
- // 获取Bearer 格式请求Token
60
- getBearerToken(): string {
61
- const token = this.getToken();
62
- if (token) {
63
- return "Bearer " + token;
64
- }
65
- return "";
66
- }
67
-
68
- // 获取用户信息
69
- getUserInfo() {
70
- return mpx.getStorageSync("userInfo") || {};
71
- }
72
-
73
- // 设置用户信息
74
- setUserInfo(data: UserInfo) {
75
- mpx.setStorageSync("userInfo", data);
76
- }
77
-
78
- // 获取角色列表
79
- getRoleCodes() {
80
- return mpx.getStorageSync("roleCodes") || [];
81
- }
82
-
83
- // 设置角色列表
84
- setRoleCodes(codes: string[]) {
85
- mpx.setStorageSync("roleCodes", codes);
86
- }
87
-
88
- // 获取权限列表
89
- getPermCodes() {
90
- return mpx.getStorageSync("permCodes") || [];
91
- }
92
-
93
- // 设置权限列表
94
- setPermCodes(codes: string[]) {
95
- mpx.setStorageSync("permCodes", codes);
96
- }
97
- }
98
-
99
- const db = new LocalStorage();
100
- export { db };
1
+ import mpx from "@mpxjs/core";
2
+ import type { TokenModel, UserInfo } from "../api/auth/types";
3
+
4
+ // 本地存储
5
+ class LocalStorage {
6
+ // 获取token
7
+ getToken(): string {
8
+ return mpx.getStorageSync("token");
9
+ }
10
+ // 用户租户
11
+ getUserTenant(): string {
12
+ return this.getUserInfo().storage as string;
13
+ }
14
+ //获取组织租户
15
+ getOrganTenant(tenant: string): string {
16
+ return mpx.getStorageSync("OrganTenant:" + tenant);
17
+ }
18
+
19
+ //是否Token过期.
20
+ isTokenExpires(): boolean {
21
+ const expiresDate = this.getTokenExpiresDate();
22
+ if (this.getToken() && expiresDate) {
23
+ const now = new Date().getTime();
24
+ //提前30秒过期.
25
+ return now + 30000 > expiresDate;
26
+ }
27
+ return true;
28
+ }
29
+
30
+ // 获取刷新token
31
+ getRefreshToken(): string {
32
+ return mpx.getStorageSync("refreshToken");
33
+ }
34
+
35
+ // 删除刷新token
36
+ removeRefreshToken() {
37
+ mpx.removeStorageSync("refreshToken");
38
+ }
39
+
40
+ // 获取Token 过期时间
41
+ getTokenExpiresDate(): number {
42
+ return mpx.getStorageSync("expiresDate");
43
+ }
44
+
45
+ // 设置token
46
+ setToken(data: TokenModel) {
47
+ mpx.setStorageSync("token", data.accessToken);
48
+ mpx.setStorageSync("expiresIn", data.expiresIn);
49
+ mpx.setStorageSync("refreshToken", data.refreshToken);
50
+ const expiresDate = new Date().getTime() + data.expiresIn * 1000;
51
+ mpx.setStorageSync("expiresDate", expiresDate);
52
+ }
53
+
54
+ // 清理本地缓存
55
+ clearStorage(): void {
56
+ mpx.clearStorage();
57
+ }
58
+
59
+ // 获取Bearer 格式请求Token
60
+ getBearerToken(): string {
61
+ const token = this.getToken();
62
+ if (token) {
63
+ return "Bearer " + token;
64
+ }
65
+ return "";
66
+ }
67
+
68
+ // 获取用户信息
69
+ getUserInfo() {
70
+ return mpx.getStorageSync("userInfo") || {};
71
+ }
72
+
73
+ // 设置用户信息
74
+ setUserInfo(data: UserInfo) {
75
+ mpx.setStorageSync("userInfo", data);
76
+ }
77
+
78
+ // 获取角色列表
79
+ getRoleCodes() {
80
+ return mpx.getStorageSync("roleCodes") || [];
81
+ }
82
+
83
+ // 设置角色列表
84
+ setRoleCodes(codes: string[]) {
85
+ mpx.setStorageSync("roleCodes", codes);
86
+ }
87
+
88
+ // 获取权限列表
89
+ getPermCodes() {
90
+ return mpx.getStorageSync("permCodes") || [];
91
+ }
92
+
93
+ // 设置权限列表
94
+ setPermCodes(codes: string[]) {
95
+ mpx.setStorageSync("permCodes", codes);
96
+ }
97
+ }
98
+
99
+ const db = new LocalStorage();
100
+ export { db };
package/src/utils/grpc.ts CHANGED
@@ -1,21 +1,21 @@
1
- // grpc工具类
2
- class GrpcUtil {
3
- //清理空参数.
4
- clearEmpty(params: any): void {
5
- for (const key in params) {
6
- if (params[key] !== null && typeof params[key] === "object") {
7
- this.clearEmpty(params[key]);
8
- if (Object.keys(params[key]).length === 0) {
9
- delete params[key];
10
- }
11
- }
12
-
13
- if ([undefined, null, ""].includes(params[key])) {
14
- delete params[key];
15
- }
16
- }
17
- return params;
18
- }
19
- }
20
- const grpc = new GrpcUtil();
21
- export { grpc };
1
+ // grpc工具类
2
+ class GrpcUtil {
3
+ //清理空参数.
4
+ clearEmpty(params: any): void {
5
+ for (const key in params) {
6
+ if (params[key] !== null && typeof params[key] === "object") {
7
+ this.clearEmpty(params[key]);
8
+ if (Object.keys(params[key]).length === 0) {
9
+ delete params[key];
10
+ }
11
+ }
12
+
13
+ if ([undefined, null, ""].includes(params[key])) {
14
+ delete params[key];
15
+ }
16
+ }
17
+ return params;
18
+ }
19
+ }
20
+ const grpc = new GrpcUtil();
21
+ export { grpc };