udxcms 1.0.15 → 1.0.17
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/dist/api/common.js +54 -88
- package/dist/api/h5/axios.js +15 -20
- package/dist/api/h5/common.js +21 -37
- package/dist/api/index.js +20 -62
- package/dist/components/businessComponents/Header.vue +1 -1
- package/dist/config/const.js +5 -8
- package/dist/config/index.js +1 -3
- package/dist/filter/dateyear.js +1 -4
- package/dist/filter/numberFormat.js +1 -4
- package/dist/index.js +35 -60
- package/dist/libs/localStorageConstant.js +18 -21
- package/dist/mixins/themeMixin-votex.js +1 -3
- package/dist/mixins/themeMixin.js +1 -3
- package/dist/router/Home.js +32 -70
- package/dist/router/index.js +1 -8
- package/dist/store/CmsStore.js +3 -5
- package/dist/store/CmsStoreH5.js +4 -6
- package/dist/store/index.js +2 -10
- package/dist/utils/EventBus.js +1 -4
- package/dist/utils/Session.js +1 -4
- package/dist/utils/Storage.js +2 -38
- package/dist/utils/apiEvent.js +2 -7
- package/dist/utils/axiosRetry.js +9 -14
- package/dist/utils/connect.js +21 -29
- package/dist/utils/http.js +17 -24
- package/dist/utils/index.js +97 -166
- package/dist/utils/isMobile.js +1 -4
- package/dist/utils/parse.js +3 -7
- package/dist/utils/pdf.js +3 -7
- package/package.json +1 -1
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,23 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.loadImportCacheScript = loadImportCacheScript;
|
|
19
|
-
exports.loadImportScript = loadImportScript;
|
|
20
|
-
const clipboard_copy_1 = __importDefault(require("clipboard-copy"));
|
|
21
|
-
const ethers_1 = require("ethers");
|
|
22
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
23
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
24
|
-
const index_1 = __importDefault(require("../config/index"));
|
|
25
|
-
const parse_1 = require("./parse");
|
|
26
|
-
Object.defineProperty(exports, "unwrapJSONStr", { enumerable: true, get: function () { return parse_1.unwrapJSONStr; } });
|
|
27
|
-
const AccountForm = (account, accountType) => {
|
|
10
|
+
import copy from "clipboard-copy";
|
|
11
|
+
import { ethers, utils } from 'ethers';
|
|
12
|
+
import dayjs from 'dayjs';
|
|
13
|
+
import BNP from "bignumber.js";
|
|
14
|
+
import conf from '../config/index';
|
|
15
|
+
import { unwrapJSONStr } from "./parse";
|
|
16
|
+
export const AccountForm = (account, accountType) => {
|
|
28
17
|
let AccArr = account.split("");
|
|
29
18
|
if (accountType === "Phone") {
|
|
30
19
|
let len = AccArr.length;
|
|
@@ -66,7 +55,6 @@ const AccountForm = (account, accountType) => {
|
|
|
66
55
|
;
|
|
67
56
|
return AccArr.join("");
|
|
68
57
|
};
|
|
69
|
-
exports.AccountForm = AccountForm;
|
|
70
58
|
/**
|
|
71
59
|
* @name: calc dots repalce nums
|
|
72
60
|
* @test: ●●●●●●● ●●●●●323q● 22323qw
|
|
@@ -75,7 +63,7 @@ exports.AccountForm = AccountForm;
|
|
|
75
63
|
* @return {*}
|
|
76
64
|
*/
|
|
77
65
|
const TEMPSAVEDATASPACE = {};
|
|
78
|
-
function calcDotDeal(val, resVal, sign = "●") {
|
|
66
|
+
export function calcDotDeal(val, resVal, sign = "●") {
|
|
79
67
|
let start = "";
|
|
80
68
|
let replaceArr = "";
|
|
81
69
|
let end = 0;
|
|
@@ -89,7 +77,7 @@ function calcDotDeal(val, resVal, sign = "●") {
|
|
|
89
77
|
}
|
|
90
78
|
return start + replaceArr + (end > 0 ? resVal.slice(-end) : "");
|
|
91
79
|
}
|
|
92
|
-
function loadImportCacheScript(src, callback, saveKey) {
|
|
80
|
+
export function loadImportCacheScript(src, callback, saveKey) {
|
|
93
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
82
|
return new Promise((resolve, reject) => {
|
|
95
83
|
var loadScriptArr = document.getElementsByTagName('script');
|
|
@@ -119,7 +107,7 @@ function loadImportCacheScript(src, callback, saveKey) {
|
|
|
119
107
|
});
|
|
120
108
|
});
|
|
121
109
|
}
|
|
122
|
-
const getTimeZone = () => {
|
|
110
|
+
export const getTimeZone = () => {
|
|
123
111
|
let offset = new Date().getTimezoneOffset();
|
|
124
112
|
if (offset != 0) {
|
|
125
113
|
let symbol = Math.abs(offset) === offset ? "-" : "+";
|
|
@@ -131,42 +119,34 @@ const getTimeZone = () => {
|
|
|
131
119
|
return "GMT+0";
|
|
132
120
|
}
|
|
133
121
|
};
|
|
134
|
-
|
|
135
|
-
const getUTCTime = (d1) => {
|
|
122
|
+
export const getUTCTime = (d1) => {
|
|
136
123
|
return new Date(d1.getUTCFullYear(), d1.getUTCMonth(), d1.getUTCDate(), d1.getUTCHours(), d1.getUTCMinutes(), d1.getUTCSeconds()).getTime();
|
|
137
124
|
};
|
|
138
|
-
|
|
139
|
-
const formatUTCTime = (date) => {
|
|
125
|
+
export const formatUTCTime = (date) => {
|
|
140
126
|
try {
|
|
141
|
-
return
|
|
127
|
+
return dayjs.utc(date).format('YYYY-MM-DD HH:mm:ss UTC');
|
|
142
128
|
}
|
|
143
129
|
catch (error) {
|
|
144
130
|
return null;
|
|
145
131
|
}
|
|
146
132
|
};
|
|
147
|
-
|
|
148
|
-
const isUserCenter = () => {
|
|
133
|
+
export const isUserCenter = () => {
|
|
149
134
|
let configType = (site_config && site_config.centralization_type) || "";
|
|
150
135
|
return configType == "CENTRALIZATION";
|
|
151
136
|
};
|
|
152
|
-
|
|
153
|
-
const onEvents = (type, fn) => {
|
|
137
|
+
export const onEvents = (type, fn) => {
|
|
154
138
|
$Vue.$bus.$on(type, fn);
|
|
155
139
|
};
|
|
156
|
-
|
|
157
|
-
const emitEvents = (type, args) => {
|
|
140
|
+
export const emitEvents = (type, args) => {
|
|
158
141
|
$Vue.$bus.$emit(type, args);
|
|
159
142
|
};
|
|
160
|
-
|
|
161
|
-
const refreshEvents = (events) => {
|
|
143
|
+
export const refreshEvents = (events) => {
|
|
162
144
|
$Vue && $Vue.$bus.$emit("refresh", events);
|
|
163
145
|
};
|
|
164
|
-
|
|
165
|
-
const emitLoading = (obj) => {
|
|
146
|
+
export const emitLoading = (obj) => {
|
|
166
147
|
$Vue && $Vue.$bus.$emit("linkLoading", obj);
|
|
167
148
|
};
|
|
168
|
-
|
|
169
|
-
function loadImportScript(src, callback, saveKey) {
|
|
149
|
+
export function loadImportScript(src, callback, saveKey) {
|
|
170
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
171
151
|
return new Promise((resolve, reject) => {
|
|
172
152
|
var loadScriptArr = document.getElementsByTagName('script');
|
|
@@ -197,36 +177,32 @@ function loadImportScript(src, callback, saveKey) {
|
|
|
197
177
|
});
|
|
198
178
|
});
|
|
199
179
|
}
|
|
200
|
-
const getToken = () => {
|
|
180
|
+
export const getToken = () => {
|
|
201
181
|
const token = localStorage.getItem("token");
|
|
202
182
|
if (token) {
|
|
203
183
|
return token;
|
|
204
184
|
}
|
|
205
185
|
return null;
|
|
206
186
|
};
|
|
207
|
-
|
|
208
|
-
const getAreaCode = () => {
|
|
187
|
+
export const getAreaCode = () => {
|
|
209
188
|
const areaCode = sessionStorage.getItem("userAreaCode");
|
|
210
189
|
if (areaCode) {
|
|
211
190
|
return areaCode;
|
|
212
191
|
}
|
|
213
192
|
return null;
|
|
214
193
|
};
|
|
215
|
-
exports.getAreaCode = getAreaCode;
|
|
216
194
|
/**
|
|
217
195
|
*
|
|
218
196
|
* @param {*} text 复制的内容
|
|
219
197
|
*/
|
|
220
|
-
const copyText = (text, e) => {
|
|
221
|
-
(
|
|
198
|
+
export const copyText = (text, e) => {
|
|
199
|
+
copy(text);
|
|
222
200
|
return true;
|
|
223
201
|
};
|
|
224
|
-
|
|
225
|
-
const isPhone = () => {
|
|
202
|
+
export const isPhone = () => {
|
|
226
203
|
return navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
|
|
227
204
|
};
|
|
228
|
-
|
|
229
|
-
const getChainId = function () {
|
|
205
|
+
export const getChainId = function () {
|
|
230
206
|
let chainId = window.ethereum && window.ethereum.chainId || localStorage.getItem('networkId') || '';
|
|
231
207
|
if (!chainId) {
|
|
232
208
|
if (window.site_config) {
|
|
@@ -243,7 +219,6 @@ const getChainId = function () {
|
|
|
243
219
|
// console.log('getChainId:', chainId);
|
|
244
220
|
return parseInt(chainId);
|
|
245
221
|
};
|
|
246
|
-
exports.getChainId = getChainId;
|
|
247
222
|
// export const getChainLayer2Config = function(chainId = 4) {
|
|
248
223
|
// let layer2Config = {}
|
|
249
224
|
// if (window.site_config) {
|
|
@@ -256,7 +231,7 @@ exports.getChainId = getChainId;
|
|
|
256
231
|
// }
|
|
257
232
|
// return layer2Config
|
|
258
233
|
// }
|
|
259
|
-
const getLayer1RpcUrl = function (chainId) {
|
|
234
|
+
export const getLayer1RpcUrl = function (chainId) {
|
|
260
235
|
let netWroks = [];
|
|
261
236
|
chainId = chainId && parseInt(chainId) || '';
|
|
262
237
|
if (window.site_config) {
|
|
@@ -280,14 +255,13 @@ const getLayer1RpcUrl = function (chainId) {
|
|
|
280
255
|
return chainId && (v.sub_type + chainId == v.subkey) || !chainId;
|
|
281
256
|
});
|
|
282
257
|
};
|
|
283
|
-
|
|
284
|
-
const getChainLayer2Config = function (chainId = 4) {
|
|
258
|
+
export const getChainLayer2Config = function (chainId = 4) {
|
|
285
259
|
let layer2Config = {};
|
|
286
260
|
if (window.site_config) {
|
|
287
261
|
try {
|
|
288
262
|
chainId = chainId && parseInt(chainId) || '';
|
|
289
263
|
let layer2_config = window.site_config['layer2_list'];
|
|
290
|
-
let layer1_config =
|
|
264
|
+
let layer1_config = getLayer1RpcUrl(chainId);
|
|
291
265
|
let layer2ConfigArr = layer2_config && layer2_config.length && JSON.parse(layer2_config);
|
|
292
266
|
layer2ConfigArr.map(v => {
|
|
293
267
|
let layer2_key = Object.keys(v)[0];
|
|
@@ -303,15 +277,13 @@ const getChainLayer2Config = function (chainId = 4) {
|
|
|
303
277
|
}
|
|
304
278
|
return layer2Config;
|
|
305
279
|
};
|
|
306
|
-
|
|
307
|
-
const toUpperDataKey = item => {
|
|
280
|
+
export const toUpperDataKey = item => {
|
|
308
281
|
let resItem = item.replace(/\_(\w)/g, function (a, b) {
|
|
309
282
|
return b.toUpperCase();
|
|
310
283
|
});
|
|
311
284
|
return resItem;
|
|
312
285
|
};
|
|
313
|
-
|
|
314
|
-
const getMarketApi = function (chainId, connectType = "market_api", apiType) {
|
|
286
|
+
export const getMarketApi = function (chainId, connectType = "market_api", apiType) {
|
|
315
287
|
const store = window.$Vue.$store;
|
|
316
288
|
apiType = apiType || 'api';
|
|
317
289
|
if (connectType == 'perpetual') {
|
|
@@ -325,7 +297,7 @@ const getMarketApi = function (chainId, connectType = "market_api", apiType) {
|
|
|
325
297
|
}
|
|
326
298
|
let marketApi = '';
|
|
327
299
|
try {
|
|
328
|
-
let config = store.state.siteConfig[connectType] || store.state.siteConfig[
|
|
300
|
+
let config = store.state.siteConfig[connectType] || store.state.siteConfig[toUpperDataKey(connectType)];
|
|
329
301
|
let marketSettingObj = config && config.length && typeof config == 'string' && JSON.parse(config) || config || {};
|
|
330
302
|
marketApi = marketSettingObj[chainId] || marketSettingObj['0'] || '';
|
|
331
303
|
}
|
|
@@ -334,27 +306,24 @@ const getMarketApi = function (chainId, connectType = "market_api", apiType) {
|
|
|
334
306
|
}
|
|
335
307
|
return marketApi;
|
|
336
308
|
};
|
|
337
|
-
|
|
338
|
-
const getQueryChainId = function (isMarketType) {
|
|
309
|
+
export const getQueryChainId = function (isMarketType) {
|
|
339
310
|
const store = window.$Vue.$store;
|
|
340
311
|
let resChainId;
|
|
341
312
|
let multiChainId = localStorage.getItem('isMultiChains'); // 0 isnot multiChain, !0 mutiCHain
|
|
342
313
|
let isPerpetual = store.state.trade.tradeMode == 'perpetual'; // 是否是永续,永续暂时不支持多练聚合
|
|
343
|
-
if ((
|
|
314
|
+
if ((isPhone() || multiChainId * 1) && isMarketType && !isPerpetual) {
|
|
344
315
|
resChainId = '0';
|
|
345
316
|
}
|
|
346
317
|
else {
|
|
347
|
-
resChainId =
|
|
318
|
+
resChainId = getTradeDefaultChainId();
|
|
348
319
|
}
|
|
349
320
|
return resChainId;
|
|
350
321
|
};
|
|
351
|
-
|
|
352
|
-
const getTradeDefaultChainId = function () {
|
|
322
|
+
export const getTradeDefaultChainId = function () {
|
|
353
323
|
const store = window.$Vue.$store;
|
|
354
324
|
return store.state.chainId;
|
|
355
325
|
};
|
|
356
|
-
|
|
357
|
-
const isMobile = () => {
|
|
326
|
+
export const isMobile = () => {
|
|
358
327
|
let isMobile = false;
|
|
359
328
|
if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
|
|
360
329
|
// console.log('移动端');
|
|
@@ -365,37 +334,35 @@ const isMobile = () => {
|
|
|
365
334
|
}
|
|
366
335
|
return isMobile;
|
|
367
336
|
};
|
|
368
|
-
|
|
369
|
-
const isInIsWalletApp = () => {
|
|
337
|
+
export const isInIsWalletApp = () => {
|
|
370
338
|
return navigator.userAgent.includes('isWallet');
|
|
371
339
|
};
|
|
372
|
-
|
|
373
|
-
const getStyleObj = (pageName, keyStr) => {
|
|
340
|
+
export const getStyleObj = (pageName, keyStr) => {
|
|
374
341
|
// let styleArrStr = ['commonConf', 'commonHeader', 'styleConf', 'indexStyleList'].join(',')
|
|
375
342
|
let resObj = {};
|
|
376
343
|
theme_config.map(v => {
|
|
377
344
|
v.pageList.map(component => {
|
|
378
345
|
component.configList.map(config => {
|
|
379
346
|
if (component.pageKey == 'common' && config.componentsKey == 'common_conf') {
|
|
380
|
-
let commonConf =
|
|
347
|
+
let commonConf = unwrapJSONStr(config.config) || {};
|
|
381
348
|
if (!!~keyStr.indexOf('commonConf')) {
|
|
382
349
|
resObj['commonConf'] = commonConf;
|
|
383
350
|
}
|
|
384
351
|
}
|
|
385
352
|
if (component.pageKey == 'common' && config.componentsKey.startsWith('header')) {
|
|
386
|
-
let commonHeader =
|
|
353
|
+
let commonHeader = unwrapJSONStr(config.config) || {};
|
|
387
354
|
if (!!~keyStr.indexOf('commonHeader')) {
|
|
388
355
|
resObj['commonHeader'] = commonHeader;
|
|
389
356
|
}
|
|
390
357
|
}
|
|
391
358
|
if (component.pageKey == pageName && pageName != 'home' && config.componentsKey.startsWith('header')) {
|
|
392
|
-
let styleConf =
|
|
359
|
+
let styleConf = unwrapJSONStr(config.config);
|
|
393
360
|
if (!!~keyStr.indexOf('styleConf')) {
|
|
394
361
|
resObj['styleConf'] = styleConf;
|
|
395
362
|
}
|
|
396
363
|
}
|
|
397
364
|
else if (component.pageKey == pageName && pageName == 'home' && config.componentsKey == 'common_conf' && component.pageKey == 'home') {
|
|
398
|
-
let indexStyleList =
|
|
365
|
+
let indexStyleList = unwrapJSONStr(config.config).headerStyleSet || [];
|
|
399
366
|
let styleConf = indexStyleList[0];
|
|
400
367
|
if (!!~keyStr.indexOf('styleConf')) {
|
|
401
368
|
resObj['styleConf'] = styleConf;
|
|
@@ -410,19 +377,17 @@ const getStyleObj = (pageName, keyStr) => {
|
|
|
410
377
|
// console.log('resObj', resObj)
|
|
411
378
|
return resObj;
|
|
412
379
|
};
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
return ethers_1.ethers.utils.formatUnits(val.toString(), decimal || 18);
|
|
380
|
+
export const formDataEthers = (val, decimal) => {
|
|
381
|
+
return ethers.utils.formatUnits(val.toString(), decimal || 18);
|
|
416
382
|
};
|
|
417
|
-
|
|
418
|
-
const formatDateDecimal = (num = 0, decimal = 2, zoreFalse = 0) => {
|
|
383
|
+
export const formatDateDecimal = (num = 0, decimal = 2, zoreFalse = 0) => {
|
|
419
384
|
if (!num && num !== 0)
|
|
420
385
|
return num;
|
|
421
|
-
let initVal =
|
|
386
|
+
let initVal = decimalFunc(num, decimal);
|
|
422
387
|
if (!Number(initVal) && decimal < 6)
|
|
423
|
-
initVal =
|
|
388
|
+
initVal = decimalFunc(num, 6);
|
|
424
389
|
if (!Number(initVal) && decimal < 10)
|
|
425
|
-
initVal =
|
|
390
|
+
initVal = decimalFunc(num, 10);
|
|
426
391
|
let reg = initVal.indexOf('.') > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
|
|
427
392
|
initVal = initVal.replace(reg, '$1,');
|
|
428
393
|
if (!zoreFalse) {
|
|
@@ -433,14 +398,13 @@ const formatDateDecimal = (num = 0, decimal = 2, zoreFalse = 0) => {
|
|
|
433
398
|
}
|
|
434
399
|
return initVal;
|
|
435
400
|
};
|
|
436
|
-
|
|
437
|
-
const checkEthAddress = function (address) {
|
|
401
|
+
export const checkEthAddress = function (address) {
|
|
438
402
|
if (!address || (address && !address.startsWith("0x"))) {
|
|
439
403
|
return "address must start with '0x'";
|
|
440
404
|
}
|
|
441
405
|
else {
|
|
442
406
|
try {
|
|
443
|
-
let addressBytes =
|
|
407
|
+
let addressBytes = utils.arrayify(address);
|
|
444
408
|
if (addressBytes.length !== 20) {
|
|
445
409
|
return "Address must be 20 bytes long";
|
|
446
410
|
}
|
|
@@ -451,13 +415,11 @@ const checkEthAddress = function (address) {
|
|
|
451
415
|
return "";
|
|
452
416
|
}
|
|
453
417
|
};
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
return exports.checkEthAddress && !(0, exports.checkEthAddress)(value) && (value.length > 10 && (value.slice(0, 4) + "******" + value.slice(-4, value.length)) || value) || value;
|
|
418
|
+
export const formatAccount = function (value) {
|
|
419
|
+
return checkEthAddress && !checkEthAddress(value) && (value.length > 10 && (value.slice(0, 4) + "******" + value.slice(-4, value.length)) || value) || value;
|
|
457
420
|
};
|
|
458
|
-
exports.formatAccount = formatAccount;
|
|
459
421
|
// trade-utils ----===---
|
|
460
|
-
const accMul = function accMul(arg1, arg2) {
|
|
422
|
+
export const accMul = function accMul(arg1, arg2) {
|
|
461
423
|
var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
|
|
462
424
|
try {
|
|
463
425
|
m += s1.split(".")[1].length;
|
|
@@ -469,8 +431,7 @@ const accMul = function accMul(arg1, arg2) {
|
|
|
469
431
|
catch (e) { }
|
|
470
432
|
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
|
|
471
433
|
};
|
|
472
|
-
|
|
473
|
-
const accDiv = function accDiv(arg1, arg2) {
|
|
434
|
+
export const accDiv = function accDiv(arg1, arg2) {
|
|
474
435
|
var t1 = 0, t2 = 0, r1, r2;
|
|
475
436
|
try {
|
|
476
437
|
t1 = arg1.toString().split(".")[1].length;
|
|
@@ -484,8 +445,7 @@ const accDiv = function accDiv(arg1, arg2) {
|
|
|
484
445
|
r2 = Number(arg2.toString().replace(".", ""));
|
|
485
446
|
return (r1 / r2) * Math.pow(10, t2 - t1);
|
|
486
447
|
};
|
|
487
|
-
|
|
488
|
-
const accAddSub = function (arg1, arg2, sign) {
|
|
448
|
+
export const accAddSub = function (arg1, arg2, sign) {
|
|
489
449
|
var r1, r2, m, n;
|
|
490
450
|
try {
|
|
491
451
|
r1 = arg1.toString().split(".")[1].length;
|
|
@@ -508,12 +468,10 @@ const accAddSub = function (arg1, arg2, sign) {
|
|
|
508
468
|
return ((arg1 * m - arg2 * m) / m).toFixed(n);
|
|
509
469
|
}
|
|
510
470
|
};
|
|
511
|
-
|
|
512
|
-
const getExplorer = function (chainId) {
|
|
471
|
+
export const getExplorer = function (chainId) {
|
|
513
472
|
return chainId == 4 ? 'rinkeby' : 'vm';
|
|
514
473
|
};
|
|
515
|
-
|
|
516
|
-
const getHashBlockUrl = (hash = '', chainId, layer) => {
|
|
474
|
+
export const getHashBlockUrl = (hash = '', chainId, layer) => {
|
|
517
475
|
const store = window.$Vue.$store;
|
|
518
476
|
const url = store.getters.filterNetworkItem(chainId, layer).blockExplorerUrl;
|
|
519
477
|
if (url) {
|
|
@@ -526,18 +484,17 @@ const getHashBlockUrl = (hash = '', chainId, layer) => {
|
|
|
526
484
|
return blockUrl + `tx/${txid}`;
|
|
527
485
|
}
|
|
528
486
|
};
|
|
529
|
-
exports.getHashBlockUrl = getHashBlockUrl;
|
|
530
487
|
/**
|
|
531
488
|
* 格式化Token,向下取(截取)
|
|
532
489
|
* 返回示例:1,000.0, 1,000.1234
|
|
533
490
|
* @param {*} value // unit:ether
|
|
534
491
|
* @param {*} dp // 显示精度
|
|
535
492
|
*/
|
|
536
|
-
const formatTokenCommify = (value, dp = 0, addSuffixZero = true) => {
|
|
493
|
+
export const formatTokenCommify = (value, dp = 0, addSuffixZero = true) => {
|
|
537
494
|
if (!value)
|
|
538
495
|
return value;
|
|
539
496
|
const arr = value.toString().split(".");
|
|
540
|
-
let result =
|
|
497
|
+
let result = utils.commify(arr[0]);
|
|
541
498
|
result += ".";
|
|
542
499
|
if (arr.length > 1 && dp > 0) {
|
|
543
500
|
result += arr[1].substr(0, dp);
|
|
@@ -547,38 +504,34 @@ const formatTokenCommify = (value, dp = 0, addSuffixZero = true) => {
|
|
|
547
504
|
}
|
|
548
505
|
return result;
|
|
549
506
|
};
|
|
550
|
-
|
|
551
|
-
const toRound = (value, ratio = 2) => {
|
|
507
|
+
export const toRound = (value, ratio = 2) => {
|
|
552
508
|
if (value === null)
|
|
553
509
|
return null;
|
|
554
510
|
const base = Math.pow(10, ratio);
|
|
555
|
-
return new
|
|
511
|
+
return new BNP(value).times(base).integerValue(BNP.ROUND_HALF_UP).div(base).toString();
|
|
556
512
|
};
|
|
557
|
-
exports.toRound = toRound;
|
|
558
513
|
/**
|
|
559
514
|
* 格式化法币价格/金额(四舍五入)
|
|
560
515
|
* 默认是格式化为10位。
|
|
561
516
|
* @param {*} value
|
|
562
517
|
* @param {Number} dp 显示精度
|
|
563
518
|
*/
|
|
564
|
-
const formatFiatCommify = (value, dp = 10) => {
|
|
519
|
+
export const formatFiatCommify = (value, dp = 10) => {
|
|
565
520
|
if (!value)
|
|
566
521
|
return value;
|
|
567
|
-
let result =
|
|
522
|
+
let result = toRound(value, dp);
|
|
568
523
|
// 格式化整数(逗号分割)
|
|
569
524
|
const arr = result.toString().split(".");
|
|
570
|
-
let integerStr =
|
|
525
|
+
let integerStr = utils.commify(arr[0]);
|
|
571
526
|
let mantissa = arr[1] || '0';
|
|
572
527
|
return integerStr + "." + mantissa;
|
|
573
528
|
};
|
|
574
|
-
|
|
575
|
-
const formatNumber = function (val, decimal) {
|
|
529
|
+
export const formatNumber = function (val, decimal) {
|
|
576
530
|
let reg = new RegExp(`^(\\d+)\\.(\\d{0,${decimal}}).*$`);
|
|
577
531
|
val = val.toString().replace(reg, '$1.$2');
|
|
578
532
|
return val;
|
|
579
533
|
};
|
|
580
|
-
|
|
581
|
-
const decimalFunc = function (val, decimal = 2) {
|
|
534
|
+
export const decimalFunc = function (val, decimal = 2) {
|
|
582
535
|
let sign = val * 1 < 0;
|
|
583
536
|
val = Math.abs(val);
|
|
584
537
|
let reg = new RegExp(`^(\\d+)\\.(\\d{0,${decimal}}).*$`);
|
|
@@ -587,17 +540,15 @@ const decimalFunc = function (val, decimal = 2) {
|
|
|
587
540
|
let resVal = sign ? '-' + val : val;
|
|
588
541
|
return resVal;
|
|
589
542
|
};
|
|
590
|
-
|
|
591
|
-
const addZoreFormat = function (demical) {
|
|
543
|
+
export const addZoreFormat = function (demical) {
|
|
592
544
|
var zoreInit = "0";
|
|
593
545
|
return zoreInit + "." + zoreInit.repeat(demical);
|
|
594
546
|
};
|
|
595
|
-
exports.addZoreFormat = addZoreFormat;
|
|
596
547
|
// 默认去掉0
|
|
597
|
-
const numberFormat = function (num, demical = 0, isZero = true) {
|
|
548
|
+
export const numberFormat = function (num, demical = 0, isZero = true) {
|
|
598
549
|
// console.log('numberFormat num, demical:',num, demical);
|
|
599
550
|
if ((!num || !(num * 1)) && !isZero) {
|
|
600
|
-
return
|
|
551
|
+
return addZoreFormat(demical);
|
|
601
552
|
}
|
|
602
553
|
else {
|
|
603
554
|
num = (!isZero ? Number(num).toFixed(demical) + '' : Number(num).toFixed(demical) * 1) + "";
|
|
@@ -606,8 +557,7 @@ const numberFormat = function (num, demical = 0, isZero = true) {
|
|
|
606
557
|
return num.replace(reg, "$1,");
|
|
607
558
|
}
|
|
608
559
|
};
|
|
609
|
-
|
|
610
|
-
const numDecimals = function (val, decimals, zeroDecimals = 1) {
|
|
560
|
+
export const numDecimals = function (val, decimals, zeroDecimals = 1) {
|
|
611
561
|
let dealVal = (val * 1).toFixed(decimals) * 1;
|
|
612
562
|
let zero = '0'.repeat(zeroDecimals);
|
|
613
563
|
if (dealVal != val * 1) {
|
|
@@ -615,15 +565,14 @@ const numDecimals = function (val, decimals, zeroDecimals = 1) {
|
|
|
615
565
|
}
|
|
616
566
|
return !!~(dealVal + '').indexOf('.') ? dealVal : (dealVal + '.' + zero);
|
|
617
567
|
};
|
|
618
|
-
|
|
619
|
-
const formatStringNum = (num = 0, decimal = 2, zoreFalse = 0) => {
|
|
568
|
+
export const formatStringNum = (num = 0, decimal = 2, zoreFalse = 0) => {
|
|
620
569
|
if (!num && num !== 0)
|
|
621
570
|
return num;
|
|
622
|
-
let initVal =
|
|
571
|
+
let initVal = decimalFunc(num, decimal);
|
|
623
572
|
if (!Number(initVal) && decimal < 6)
|
|
624
|
-
initVal =
|
|
573
|
+
initVal = decimalFunc(num, 6);
|
|
625
574
|
if (!Number(initVal) && decimal < 10)
|
|
626
|
-
initVal =
|
|
575
|
+
initVal = decimalFunc(num, 10);
|
|
627
576
|
let reg = initVal.indexOf('.') > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
|
|
628
577
|
// let reg = /(\d)(?=(?:\d{3})+$)/g
|
|
629
578
|
initVal = parseFloat(initVal) + '';
|
|
@@ -636,8 +585,7 @@ const formatStringNum = (num = 0, decimal = 2, zoreFalse = 0) => {
|
|
|
636
585
|
}
|
|
637
586
|
return initVal;
|
|
638
587
|
};
|
|
639
|
-
|
|
640
|
-
const formatArrStringNum = function (num) {
|
|
588
|
+
export const formatArrStringNum = function (num) {
|
|
641
589
|
num = num + '';
|
|
642
590
|
if (num.indexOf('.') == -1) {
|
|
643
591
|
return [num, 1];
|
|
@@ -646,12 +594,11 @@ const formatArrStringNum = function (num) {
|
|
|
646
594
|
let decimal = num.split('.')[1].length;
|
|
647
595
|
// return [num * Math.pow(10, decimal), 1 * Math.pow(10, decimal)]
|
|
648
596
|
const a2 = Math.pow(10, decimal);
|
|
649
|
-
const a1 = new
|
|
597
|
+
const a1 = new BNP(num).times(a2).toNumber();
|
|
650
598
|
return [a1, a2];
|
|
651
599
|
}
|
|
652
600
|
};
|
|
653
|
-
|
|
654
|
-
const setDecimals = function (name, value) {
|
|
601
|
+
export const setDecimals = function (name, value) {
|
|
655
602
|
let decimalsArr = {};
|
|
656
603
|
try {
|
|
657
604
|
decimalsArr = JSON.parse(localStorage.getItem('decimalsArr'));
|
|
@@ -664,8 +611,7 @@ const setDecimals = function (name, value) {
|
|
|
664
611
|
decimalsArr[name] = value;
|
|
665
612
|
localStorage.setItem('decimalsArr', JSON.stringify(decimalsArr));
|
|
666
613
|
};
|
|
667
|
-
|
|
668
|
-
const getDecimals = function (name) {
|
|
614
|
+
export const getDecimals = function (name) {
|
|
669
615
|
let decimalsArr = {};
|
|
670
616
|
try {
|
|
671
617
|
decimalsArr = JSON.parse(localStorage.getItem('decimalsArr'));
|
|
@@ -675,12 +621,11 @@ const getDecimals = function (name) {
|
|
|
675
621
|
return [];
|
|
676
622
|
}
|
|
677
623
|
};
|
|
678
|
-
exports.getDecimals = getDecimals;
|
|
679
624
|
/**
|
|
680
625
|
* 获取金额
|
|
681
626
|
* data: {committed,available,locked}
|
|
682
627
|
*/
|
|
683
|
-
const filterL2Balance = (data, type, symbol) => {
|
|
628
|
+
export const filterL2Balance = (data, type, symbol) => {
|
|
684
629
|
if (!data)
|
|
685
630
|
return null;
|
|
686
631
|
if (Object.prototype.toString.call(data) !== "[object Object]")
|
|
@@ -691,24 +636,22 @@ const filterL2Balance = (data, type, symbol) => {
|
|
|
691
636
|
return null;
|
|
692
637
|
return data[type]['balances'][symbol];
|
|
693
638
|
};
|
|
694
|
-
|
|
695
|
-
const commify = (value) => {
|
|
639
|
+
export const commify = (value) => {
|
|
696
640
|
if (value === null)
|
|
697
641
|
return null;
|
|
698
642
|
if (value === "+∞")
|
|
699
643
|
return "+∞";
|
|
700
644
|
if (value.toString().includes("e"))
|
|
701
645
|
return value;
|
|
702
|
-
return
|
|
646
|
+
return utils.commify(value);
|
|
703
647
|
};
|
|
704
|
-
exports.commify = commify;
|
|
705
648
|
// trade---
|
|
706
|
-
const getWalletCoinFee = function (transfer, fn) {
|
|
649
|
+
export const getWalletCoinFee = function (transfer, fn) {
|
|
707
650
|
return __awaiter(this, void 0, void 0, function* () {
|
|
708
651
|
let syncWallet = transfer.syncWallet || $Vue && $Vue.walletData.getSyncWallet();
|
|
709
652
|
let provider = syncWallet.provider;
|
|
710
653
|
if (provider) {
|
|
711
|
-
const fullFee = yield provider.getTransactionFee('Transfer', transfer.address,
|
|
654
|
+
const fullFee = yield provider.getTransactionFee('Transfer', transfer.address, conf.getFeeType || transfer.token);
|
|
712
655
|
transfer.fee = fullFee.totalFee;
|
|
713
656
|
fn && fn(transfer.fee);
|
|
714
657
|
}
|
|
@@ -717,12 +660,11 @@ const getWalletCoinFee = function (transfer, fn) {
|
|
|
717
660
|
}
|
|
718
661
|
});
|
|
719
662
|
};
|
|
720
|
-
|
|
721
|
-
const getFee = function (transfer, fn) {
|
|
663
|
+
export const getFee = function (transfer, fn) {
|
|
722
664
|
return __awaiter(this, void 0, void 0, function* () {
|
|
723
665
|
let provider = $Vue && $Vue.walletData.getSyncWallet().provider;
|
|
724
666
|
if (provider) {
|
|
725
|
-
const fullFee = yield provider.getTransactionFee('Transfer', transfer.address,
|
|
667
|
+
const fullFee = yield provider.getTransactionFee('Transfer', transfer.address, conf.getFeeType || transfer.token);
|
|
726
668
|
transfer.fee = fullFee.totalFee;
|
|
727
669
|
fn && fn(transfer.fee);
|
|
728
670
|
}
|
|
@@ -731,8 +673,7 @@ const getFee = function (transfer, fn) {
|
|
|
731
673
|
}
|
|
732
674
|
});
|
|
733
675
|
};
|
|
734
|
-
|
|
735
|
-
const shareUtils = (type, title) => {
|
|
676
|
+
export const shareUtils = (type, title) => {
|
|
736
677
|
let dest = {
|
|
737
678
|
href: '',
|
|
738
679
|
target: '_blank'
|
|
@@ -746,24 +687,14 @@ const shareUtils = (type, title) => {
|
|
|
746
687
|
}
|
|
747
688
|
window.open(dest.href, dest.target);
|
|
748
689
|
};
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
var blockies_js_1 = require("./blockies.js");
|
|
761
|
-
Object.defineProperty(exports, "blockies", { enumerable: true, get: function () { return __importDefault(blockies_js_1).default; } });
|
|
762
|
-
var connect_js_1 = require("./connect.js");
|
|
763
|
-
Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return __importDefault(connect_js_1).default; } });
|
|
764
|
-
var http_js_1 = require("./http.js");
|
|
765
|
-
Object.defineProperty(exports, "http", { enumerable: true, get: function () { return __importDefault(http_js_1).default; } });
|
|
766
|
-
var parse_js_1 = require("./parse.js");
|
|
767
|
-
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return __importDefault(parse_js_1).default; } });
|
|
768
|
-
var pdf_js_1 = require("./pdf.js");
|
|
769
|
-
Object.defineProperty(exports, "pdf", { enumerable: true, get: function () { return __importDefault(pdf_js_1).default; } });
|
|
690
|
+
export { default as EventBus } from './EventBus.js';
|
|
691
|
+
export { default as Session } from './Session.js';
|
|
692
|
+
export { default as Storage } from './Storage.js';
|
|
693
|
+
export { default as apiEvent } from './apiEvent.js';
|
|
694
|
+
export { default as axiosRetry } from './axiosRetry.js';
|
|
695
|
+
export { default as blockies } from './blockies.js';
|
|
696
|
+
export { default as connect } from './connect.js';
|
|
697
|
+
export { default as http } from './http.js';
|
|
698
|
+
export { default as parse } from './parse.js';
|
|
699
|
+
export { default as pdf } from './pdf.js';
|
|
700
|
+
export { unwrapJSONStr };
|
package/dist/utils/isMobile.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = isMobile;
|
|
4
1
|
// 判断是否为移动端
|
|
5
|
-
function isMobile() {
|
|
2
|
+
export default function isMobile() {
|
|
6
3
|
let isMobile = false;
|
|
7
4
|
if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
|
|
8
5
|
// console.log('移动端');
|