@tmsfe/tms-core 0.0.1 → 0.0.5

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/src/request.js ADDED
@@ -0,0 +1,322 @@
1
+ /**
2
+ * @copyright 2021-present, Tencent, Inc. All rights reserved.
3
+ * @brief request.js用于发起网络请求.
4
+ * request模块作为基于 tms-core & tms-runtime 的应用的公共请求模块。
5
+ * 目前支持在出行服务小程序或基于出行服务的小程序中调用。在后续tms-runtime支持公众号H5后,
6
+ * 将支持在H5中调用。
7
+ *
8
+ * 考虑到对不同运行环境的支持,强依赖运行环境的依赖,比如 wx.request,应通过注入的形式提供。
9
+ * 框架判断在不同的运行环境,切换调用不同运行环境提供的方法。
10
+ */
11
+ import md5 from './md5';
12
+ import { getLogManager } from './log';
13
+ import { getEnvInfo, getAuthInfo } from './env';
14
+
15
+ /**
16
+ * 用于序列化需要签名的参数
17
+ * @private
18
+ * @param {object} param 需要序列化的参数
19
+ * @returns {string} 序列化之后的参数字符串
20
+ */
21
+ const seriesParam = (param) => {
22
+ const keys = Object.keys(param)
23
+ .filter(key => typeof param[key] !== 'undefined')
24
+ .sort();
25
+ const series = keys.map((key) => {
26
+ const val = param[key];
27
+ return `${key}${typeof val === 'object' ? JSON.stringify(val) : val}`;
28
+ });
29
+ return series.join('');
30
+ };
31
+
32
+ /**
33
+ * 用于对request请求对象做签名
34
+ * @private
35
+ * @param {object} param 需要做签名的参数
36
+ * @returns {object} 签名后的参数对象
37
+ */
38
+ const sign = (param = {}) => {
39
+ const token = '';
40
+ const signture = md5(seriesParam(param) + token);
41
+ return { ...param, sign: signture };
42
+ };
43
+ /**
44
+ * 用于对request请求对象添加系统参数
45
+ * @private
46
+ * @param {object} param 接口调用传入的参数
47
+ * @param {Boolean} withAuth 是否需要登录参数
48
+ * @param {object} baseParam request实例定义的基础参数
49
+ * @returns {object} 全部参数对象
50
+ */
51
+ const composeParam = async (param = {}, withAuth = true, baseParam = {}) => {
52
+ const version = '1.0';
53
+ const { appVersion, wxAppId, client } = getEnvInfo();
54
+ const nonce = Math.random()
55
+ .toString(36)
56
+ .substr(2, 10);
57
+ const timestamp = Date.now();
58
+ const random = Math.random()
59
+ .toString()
60
+ .slice(2, 7);
61
+ const sourceId = ['', 'sinan', 'mycar'].indexOf(client) + 7; // 6 未知 7 云函数 8 出行 9 我的车
62
+ const seqId = `${timestamp}${sourceId}${random}`;
63
+ const paramsWithAuth = await modifyAuthParam(param, withAuth);
64
+ const combinedParam = Object.assign(
65
+ {
66
+ version,
67
+ appVersion,
68
+ nonce,
69
+ timestamp,
70
+ seqId,
71
+ wxAppId,
72
+ },
73
+ { ...baseParam },
74
+ { ...paramsWithAuth },
75
+ );
76
+ return combinedParam;
77
+ };
78
+
79
+ /**
80
+ * 用于保证业务参数的登录态参数,
81
+ * 若接口不依赖登录态 如 user/login,则保证参数中不包括userId & token,
82
+ * 若接口依赖登录态,则保证参数中填充userId & token,
83
+ * @private
84
+ * @param {object} param 要校验登录态的业务参数
85
+ * @param {boolean} withAuth 是否要校验登录态
86
+ * @returns {object} 增加登录态后的参数
87
+ */
88
+ const modifyAuthParam = async (param, withAuth) => {
89
+ const requestParam = { ...param };
90
+ if (withAuth) {
91
+ const { userId, token } = await getAuthInfo();
92
+ requestParam.userId = userId;
93
+ requestParam.token = token;
94
+ return requestParam;
95
+ }
96
+ delete requestParam.userId;
97
+ delete requestParam.userid;
98
+ delete requestParam.token;
99
+ return requestParam;
100
+ };
101
+
102
+ /**
103
+ * @public
104
+ * @class Request
105
+ * @classdesc 网络请求类,对签名、鉴权等逻辑进行封装处理,用于向腾讯出行服务平台后台发送网络请求
106
+ */
107
+ export default class Request {
108
+ /**
109
+ * 默认的request host域名
110
+ * defaultHost 在tms-runtime初始化时进行设置,为出行服务接入层域名
111
+ * 具体业务模块 new Request() 使用时,不指定自定义 host ,将使用defaultHost
112
+ */
113
+ static defaultHost = '';
114
+
115
+ host = '';
116
+ withAuth = true;
117
+ baseParam = {};
118
+
119
+ /**
120
+ * Request 构造函数
121
+ * @param {Object} config 构造参数
122
+ * @param {Object} config.withAuth 是否填充登录态参数
123
+ * @param {Object} config.host 自定义的host域名
124
+ * @param {Object} config.baseParam 默认携带的参数
125
+ */
126
+ constructor(config = { withAuth: true }) {
127
+ if (config.host) {
128
+ this.host = config.host;
129
+ }
130
+ if (typeof config.withAuth !== 'undefined') {
131
+ this.withAuth = !!config.withAuth;
132
+ }
133
+ this.baseParam = config.baseParam || {};
134
+ }
135
+
136
+ /**
137
+ * 格式化接口路径
138
+ * @private
139
+ * @param {string} path 需要格式化的接口路径
140
+ * @returns {string} 格式化后的接口路径
141
+ */
142
+ makeUrl(path) {
143
+ if ((/^http/i).test(path)) return path;
144
+ const host = this.host || Request.defaultHost;
145
+ const validHost = (/^http/i).test(host) ? host : `https://${host}`;
146
+ return `${validHost}/${path}`;
147
+ };
148
+
149
+ /**
150
+ * @public
151
+ * @memberof Request
152
+ * @param {String} path 请求接口路径
153
+ * @param {Object} [param] 请求参数
154
+ * @param {Object} [header] 自定义请求头
155
+ * @returns {Promise} 接口响应
156
+ * @example
157
+ * const $ = getApp().tms.createRequest();
158
+ * $.get(apiPath)
159
+ * .then((data) => {
160
+ * // data {Object} 响应数据
161
+ * // {
162
+ * // errCode {Number} 接口响应状态码
163
+ * // errMsg {String} 接口响应状态信息
164
+ * // resData {Object} 接口返回数据
165
+ * // }
166
+ * })
167
+ * .catch((e) => {
168
+ * // e {Object} 错误信息
169
+ * });
170
+ */
171
+ get(path, param, header) {
172
+ return this.doRequest(path, param, 'GET', header);
173
+ }
174
+
175
+ /**
176
+ * @public
177
+ * @memberof Request
178
+ * @param {String} path 请求接口路径
179
+ * @param {Object} [param] 请求参数
180
+ * @param {Object} [header] 自定义请求头
181
+ * @returns {Promise} 接口响应
182
+ * @example
183
+ * const $ = getApp().tms.createRequest();
184
+ * $.post(apiPath)
185
+ * .then((data) => {
186
+ * // data {Object} 响应数据
187
+ * // {
188
+ * // errCode {Number} 接口响应状态码
189
+ * // errMsg {String} 接口响应状态信息
190
+ * // resData {Object} 接口返回数据
191
+ * // }
192
+ * })
193
+ * .catch((e) => {
194
+ * // e {Object} 错误信息
195
+ * });
196
+ */
197
+ post(path, param, header) {
198
+ return this.doRequest(path, param, 'POST', header);
199
+ }
200
+
201
+ /**
202
+ * 发送get方式的请求,该方法会返回wx.request全量的返回值(含data,header,cookies,statusCode)
203
+ * @memberof Request
204
+ * @param {string} path 请求接口路径
205
+ * @param {object} param 业务参数
206
+ * @param {object} header 自定义请求头
207
+ * @returns {promise} 接口请求promise
208
+ */
209
+ execGet(path, param, header) {
210
+ return this.createRequestTask(path, param, 'GET', header);
211
+ }
212
+
213
+ /**
214
+ * 发送post方式的请求,该方法会返回wx.request全量的返回值(含data,header,cookies,statusCode等)
215
+ * @memberof Request
216
+ * @param {string} path 请求接口路径
217
+ * @param {object} param 业务参数
218
+ * @param {object} header 自定义请求头
219
+ * @returns {promise} 接口请求promise
220
+ */
221
+ execPost(path, param, header) {
222
+ return this.createRequestTask(path, param, 'POST', header);
223
+ }
224
+
225
+ /**
226
+ * @memberof Request
227
+ * @param {String} path 请求接口路径
228
+ * @param {String} filePath 上传文件的本地路径
229
+ * @param {Object} param 需要携带的其他参数
230
+ * @param {Object} header 自定义的请求头
231
+ * @returns {Object} 接口返回结果
232
+ */
233
+ async upload(path, filePath, param, header) {
234
+ const requestParam = await composeParam(param, this.withAuth, this.baseParam);
235
+ const res = await new Promise((resolve, reject) => {
236
+ wx.uploadFile({
237
+ name: 'content',
238
+ url: this.makeUrl(path),
239
+ filePath,
240
+ formData: sign(requestParam),
241
+ header,
242
+ success: resolve,
243
+ fail: reject,
244
+ });
245
+ });
246
+
247
+ if (typeof res?.data === 'string') {
248
+ return JSON.parse(res?.data);
249
+ }
250
+ return res?.data;
251
+ }
252
+
253
+ /**
254
+ * @memberof Request
255
+ * @param {string} path 请求接口路径
256
+ * @param {string} param 业务参数
257
+ * @param {string} method 请求方法 get/post
258
+ * @param {object} header 自定义的请求头
259
+ * @returns {object} 接口返回结果
260
+ */
261
+ async doRequest(path, param = {}, method = 'POST', header = {}) {
262
+ const res = await this.createRequestTask(path, param, method, header);
263
+
264
+ if (typeof res?.data === 'string') {
265
+ return JSON.parse(res?.data);
266
+ }
267
+
268
+ return res?.data;
269
+ }
270
+
271
+ /**
272
+ * 序列化一个 get 请求地址
273
+ * @memberof Request
274
+ * @param {string} path 请求接口路径
275
+ * @param {object} data 业务参数
276
+ * @returns {Promise} 返回序列化之后的 get 请求地址
277
+ */
278
+ async serialize(path, data = {}) {
279
+ let url = this.makeUrl(path);
280
+ const signData = await composeParam(data, this.withAuth, this.baseParam);
281
+ const signture = sign(signData);
282
+ const params = [];
283
+ Object.keys(signture).forEach((key) => {
284
+ const val = encodeURIComponent(signture[key]);
285
+ params.push(`${key}=${val}`);
286
+ });
287
+ if (params.length) url += (/\?/.test(url) ? '&' : '?') + params.join('&');
288
+ return Promise.resolve({ url });
289
+ }
290
+
291
+ /**
292
+ * 创建发送请求任务
293
+ * @memberof Request
294
+ * @param {string} path 请求接口路径
295
+ * @param {string} param 业务参数
296
+ * @param {string} method 请求方法 get/post
297
+ * @param {object} header 自定义的请求头
298
+ * @returns {Promise} 接口返回结果
299
+ */
300
+ async createRequestTask(path, param = {}, method = 'POST', header = {}) {
301
+ const requestParam = await composeParam(param, this.withAuth, this.baseParam);
302
+ const data = sign(requestParam);
303
+ const logger = getLogManager();
304
+ const res = await new Promise((resolve, reject) => {
305
+ wx.request({
306
+ url: this.makeUrl(path),
307
+ header,
308
+ method,
309
+ data,
310
+ success: (res) => {
311
+ resolve(res);
312
+ logger.log({ path, header, method, param: data, res: res?.data });
313
+ },
314
+ fail: (err) => {
315
+ reject(err);
316
+ logger.log({ path, header, method, param: data, err });
317
+ },
318
+ });
319
+ });
320
+ return res;
321
+ }
322
+ }
package/src/rpx.js ADDED
@@ -0,0 +1,17 @@
1
+ import syncApi from './syncfnmanager';
2
+
3
+ /**
4
+ * @description rpx to px
5
+ * @param {Number} rpx 需要转换的rpx数值
6
+ * @returns {Number} 转换后的rpx数值
7
+ */
8
+ const rpxToPx = (rpx) => {
9
+ const sys = syncApi.getSystemInfoSync();
10
+ const ww = sys.windowWidth;
11
+ const ratio = ww / 750;
12
+ return rpx * ratio;
13
+ };
14
+
15
+ export {
16
+ rpxToPx,
17
+ };
@@ -0,0 +1,171 @@
1
+ /**
2
+ * 字符串截断,处理时按可见字符长度进行截断
3
+ * 可见字符的含义是指:字母、数字、汉字、表情等均等价于一个字符
4
+ * @param {String} str - 原始字符串
5
+ * @param {Number} maxLen - 字符串截断后的最大长度
6
+ * @returns {String} 截断后的字符串;如果确实进行了截断,在最后面加'...';
7
+ */
8
+ const subStr = (str, maxLen) => {
9
+ // 按照码点(codePoint),把原始字符串的前maxLen+1个字符放到chars数组中
10
+ const chars = [];
11
+ for (const codePoint of str) { // eslint-disable-line
12
+ chars.push(codePoint);
13
+ if (chars.length > maxLen) break;
14
+ }
15
+
16
+ // 如果可见字符数量小于等于字符串截断后的最大长度,无需截断,返回原始字符串
17
+ if (chars.length <= maxLen) {
18
+ return str;
19
+ }
20
+
21
+ // 可见字符数量多于字符串截断后的最大长度,需要截断,并在末尾添加...
22
+ // 注意,此时返回的字符串是 maxLen-2个可见字符 + ...(maxLen-2是因为...占用2个汉字字符位置)
23
+ return `${chars.splice(0, maxLen - 2).join('')}...`;
24
+ };
25
+
26
+ /**
27
+ * 手机号处理,隐藏中间部分位数
28
+ * 隐藏规则:假设隐藏部分位数后,手机号由ABC构成,其中A、C是可见部分,B是隐藏部分
29
+ * 1. 隐藏部分(B)占手机号总位数的1/3,且隐藏部分的位数向上取整
30
+ * 2. 不被隐藏的部分(A、C)要均匀分布在隐藏部分(B)的两侧,即尽量使AC等长
31
+ * 3. 如果不隐藏部分(A、C)长度无法等长,则使C多显示一位
32
+ * @param {String} phone 手机号
33
+ * @returns {String} 隐藏后的手机号
34
+ */
35
+ const hidePhoneCenter = (phone) => {
36
+ const len = phone && phone.length;
37
+ if (!len) {
38
+ return '';
39
+ }
40
+
41
+ // 各部分位数
42
+ const center = Math.ceil(len / 3);
43
+ const left = Math.floor((len - center) / 2);
44
+ const right = len - center - left;
45
+ // 各部分字符串
46
+ const centerStr = phone.substr(left, center).replace(/./g, '*');
47
+ const leftStr = phone.substr(0, left);
48
+ const rightStr = phone.substr(-right);
49
+ return `${leftStr}${centerStr}${rightStr}`;
50
+ };
51
+
52
+ /**
53
+ * 格式化车牌
54
+ * 例如:京A12345 -> 京A·12345
55
+ * @param {String} plate 车牌号
56
+ * @returns {String} 格式化后的车牌号
57
+ */
58
+ const formatPlate = (plate) => {
59
+ if (!plate || typeof plate !== 'string') {
60
+ return '';
61
+ }
62
+ if (plate.length <= 2 || /·/.test(plate)) {
63
+ return plate;
64
+ }
65
+ return `${plate.substring(0, 2)}·${plate.substring(2)}`;
66
+ };
67
+
68
+ /**
69
+ * 检查手机号是否合法
70
+ * @param {String} phone 手机号
71
+ * @returns {Boolean} 手机号是否合法
72
+ */
73
+ const isValidPhone = phone => /^1[\d]{10}$/.test(phone);
74
+
75
+ /**
76
+ * 检查验证码是否合法
77
+ * @param {String} code 验证码
78
+ * @returns {Boolean} 验证码是否合法
79
+ */
80
+ const isValidAuthCode = code => /^[\d]{6}$/.test(code);
81
+
82
+ const validPlateFirstLetters = ['京', '津', '冀', '晋', '蒙', '辽', '吉', '黑', '沪', '苏', '浙', '皖', '闽', '赣', '鲁',
83
+ '豫', '鄂', '湘', '粤', '桂', '琼', '渝', '川', '贵', '云', '藏', '陕', '甘', '青', '宁', '新', '使', '领'];
84
+
85
+ /**
86
+ * 检查车牌是否合法
87
+ * @param {String} plate 车牌
88
+ * @returns {Boolean} 车牌是否合法
89
+ */
90
+ const isValidPlate = (plate) => {
91
+ if (!plate || typeof plate !== 'string') {
92
+ return false;
93
+ }
94
+
95
+ // 检查首位是否是合法的汉字
96
+ const [firstLetter] = plate;
97
+ if (validPlateFirstLetters.indexOf(firstLetter) === -1) {
98
+ return false;
99
+ }
100
+
101
+ if (!/[使领警学]/.test(plate)) { // 普通车牌
102
+ const number = plate.substring(1);
103
+ return /^[a-zA-Z][0-9a-zA-Z]{5}$/.test(number) // 第一位是字母,后面5位是字母或数字
104
+ || /^[a-zA-Z][a-zA-Z][0-9a-zA-Z]{5}$/.test(number) // 第一位是字母,第二位是字母,后面再跟5位字母或数字(新能源小车)
105
+ || /^[a-zA-Z][0-9a-zA-Z]{5}[a-zA-Z]$/.test(number) // 第一位是字母,最后一位是字母,中间5位字母或数字(新能源大车)
106
+ || /^粤Z[0-9a-zA-Z]{4,5}[港澳]{1}/.test(plate); // 广东港澳两地车牌
107
+ }
108
+
109
+ // return /^[^使领警学]{1}[a-zA-Z][0-9a-zA-Z]{3,4}[使领警学]{1}$/.test(plate) || // 使/领/警/学车牌
110
+ // /^[使领]{1}[0-9a-zA-Z]{5}$/.test(plate); // 使馆领事馆特殊车牌
111
+ return false;
112
+ };
113
+
114
+ /**
115
+ * 四舍五入,并返回格式化的字符串
116
+ * 支持保留n位小数,n>=0,如 round(1.325, 2)=1.33
117
+ * 支持格式化字符串时取出末尾的0,如round(1.109, 2, true)=1.1
118
+ * @param {any} x 原数字
119
+ * 如果n不是合法数字或者无法转换为合法数字,roundStr结果返回''
120
+ * @param {any} n 保留几位小数,默认0
121
+ * 如果n不是合法数字或者无法转换为合法数字,roundStr结果返回''
122
+ * 如果n小于0,roundStr结果返回''
123
+ * 如果n的值包含小数部分,roundStr处理时只关注n的整数部分值
124
+ * @param {boolean} removeTrailingZero 是否移除字符串末尾的无效数字0
125
+ * @returns {string} 返回四舍五入后的字符串,异常情况下返回空字符串''
126
+ */
127
+ const roundStr = (x, n = 2, removeTrailingZero = false) => {
128
+ let xNum = Number(x); // x转换为数字
129
+ const nNum = Math.floor(Number(n)); // n转换为数字,且只保留整数部分
130
+
131
+ // 异常情况,返回''
132
+ if (isNaN(xNum) || isNaN(nNum) || nNum < 0) return '';
133
+
134
+ // 仅保留整数的情况
135
+ if (nNum === 0) return Math.round(xNum);
136
+
137
+ // 保留n位小数的情况
138
+ const xStr = xNum.toString();
139
+ const rexExp = new RegExp(`\\.\\d{${nNum}}5`);
140
+
141
+ // 1. 大部分情况下,四舍五入使用Number.toFixed即可
142
+ // 2. 然而,Number.toFixed方法在某些情况下对第n+1位是5的四舍五入存在问题,如1.325保留2小数时结果为1.32(期望为1.33)
143
+ // 对此种情况下,有两种处理方式:
144
+ // 2.1 先扩大10^n倍,舍掉小数部分取整数部分,然后加1,最后缩小10^n倍
145
+ // 但此种情况下,不能处理过大的数字,也不能处理保留小数位数过多的情况,会可能导致数字超过Infinity
146
+ // 2.2 Number.toFixed是四舍6入,对于第n+1位是5的情况,增加2*10^(-n-1),保证满足第n+1位>6
147
+ // 增加2*10^(-n-1)而不是增加1*10^(-n-1)是因为后者不能保证第n+1位>=6,例如1.325+0.001=1.32599999...第n+1位仍然为5
148
+ // 此处,采用2.2方式,解决Number.toFixed的问题,又能避免2.1方式中数字超过Infinity的问题
149
+ if (rexExp.test(xStr)) { // 情况2,处理方式2.1:如果小数部分第n+1位是5,增加2*10^(-n-1)
150
+ xNum += 2 * (10 ** (-nNum - 1));
151
+ }
152
+
153
+ const str = xNum.toFixed(nNum);
154
+ if (!removeTrailingZero) return str;
155
+
156
+ // 去除末尾的0
157
+ if (/^\d+\.0*$/.test(str)) { // 小数部分全是0
158
+ return str.replace(/^(\d+)(\.0*)$/, (_m, s1) => s1);
159
+ }
160
+ return str.replace(/^(\d+\.\d*[1-9]{1})(0*)$/, (_m, s1) => s1);
161
+ };
162
+
163
+ export {
164
+ formatPlate,
165
+ subStr,
166
+ hidePhoneCenter,
167
+ isValidPhone,
168
+ isValidPlate,
169
+ isValidAuthCode,
170
+ roundStr,
171
+ };
@@ -0,0 +1,106 @@
1
+ /**
2
+ * 本文件负责对小程序调用wx同步方法的管理
3
+ */
4
+ let systemInfo = null; // 系统信息。
5
+ let launchOptions = null; // 启动参数
6
+ let accountInfo = null; // 小程序账号信息
7
+
8
+ /**
9
+ * 获取系统信息。同wx.getSystemInfoSync
10
+ * @returns {Object} 系统信息
11
+ */
12
+ const getSystemInfoSync = () => {
13
+ if (systemInfo) {
14
+ return systemInfo;
15
+ }
16
+
17
+ try {
18
+ systemInfo = wx.getSystemInfoSync();
19
+
20
+ return systemInfo;
21
+ } catch (_) {
22
+ return {};
23
+ }
24
+ };
25
+
26
+ /**
27
+ * 重置系统信息,仅用于单元测试
28
+ * @returns {undefined}
29
+ */
30
+ const resetSystemInfoSync = () => {
31
+ systemInfo = null;
32
+ };
33
+
34
+ /**
35
+ * 获取启动参数。同wx.getLaunchOptionsSync
36
+ * @returns {Object} 启动参数
37
+ */
38
+ const getLaunchOptionsSync = () => {
39
+ if (launchOptions) {
40
+ return launchOptions;
41
+ }
42
+
43
+ try {
44
+ launchOptions = wx.getLaunchOptionsSync();
45
+
46
+ return launchOptions;
47
+ } catch (_) {
48
+ return {};
49
+ }
50
+ };
51
+
52
+ /**
53
+ * 获取客户端平台。同wx.getSystemInfoSync().platform
54
+ * @returns {String} 平台名称
55
+ */
56
+ const getPlatform = () => {
57
+ const UNKNOWN = 'unknown';
58
+
59
+ try {
60
+ const systemInfo = getSystemInfoSync();
61
+ const { platform } = systemInfo;
62
+ return platform || UNKNOWN;
63
+ } catch (_) {
64
+ return UNKNOWN;
65
+ }
66
+ };
67
+
68
+ /**
69
+ * 获取字符串类型的启动参数
70
+ * @returns {String} 序列化的参数字符串
71
+ */
72
+ const getLaunchParamOfString = () => {
73
+ try {
74
+ const options = getLaunchOptionsSync() || {};
75
+ return JSON.stringify(options);
76
+ } catch (_) {
77
+ return '';
78
+ }
79
+ };
80
+
81
+ /**
82
+ * @description 获取小程序账号信息
83
+ * @returns {Object} 小程序账号信息,返回内容同wx.getAccountInfoSync()
84
+ */
85
+ export const getAccountInfoSync = () => {
86
+ if (accountInfo) {
87
+ return accountInfo;
88
+ }
89
+
90
+ try {
91
+ accountInfo = wx.getAccountInfoSync();
92
+ return accountInfo;
93
+ } catch (_) {
94
+ return {};
95
+ }
96
+ };
97
+
98
+ const obj = {
99
+ getPlatform,
100
+ getSystemInfoSync,
101
+ getLaunchOptionsSync,
102
+ getLaunchParamOfString,
103
+ resetSystemInfoSync,
104
+ getAccountInfoSync,
105
+ };
106
+ export default obj;