@peng_kai/kit 0.3.0-beta.8 → 0.3.0-beta.9

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.
@@ -6,7 +6,12 @@ import type { ComponentProps } from 'vue-component-type-helpers';
6
6
  import type { Writable } from 'type-fest';
7
7
  import { useTemplateRefs } from '../../vue';
8
8
 
9
- const defaultDrawerProps: DrawerProps = { open: false, destroyOnClose: true, rootClassName: 'antd-cover__basic-drawer' };
9
+ const defaultDrawerProps: DrawerProps = {
10
+ open: false,
11
+ destroyOnClose: true,
12
+ rootClassName: 'antd-cover__basic-drawer',
13
+ maskClosable: false,
14
+ };
10
15
 
11
16
  interface IComponentConfig<Comp extends Component> {
12
17
  is: Comp
@@ -30,6 +30,7 @@ const defaultModalProps: AntdModalProps = {
30
30
  destroyOnClose: true,
31
31
  wrapClassName: 'antd-cover__basic-modal',
32
32
  rejectOnClose: false,
33
+ maskClosable: false,
33
34
  };
34
35
 
35
36
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.3.0-beta.8",
4
+ "version": "0.3.0-beta.9",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",
@@ -25,6 +25,7 @@ export function getDeviceInfo(callback: (base: Record<string, any>, all: GetResu
25
25
  };
26
26
 
27
27
  req.headers.set('Device', callback(base, result));
28
+ req.headers.set('Device-Id', getDeviceID(base.visitor_id));
28
29
  req.headers.set('Accept-Date', getCurrentTimeZone());
29
30
 
30
31
  return req;
@@ -38,3 +39,24 @@ function getCurrentTimeZone() {
38
39
  const tzOffset = now.getTimezoneOffset() / 60;
39
40
  return toBase64([time, tz, tzOffset, describe].join('|'));
40
41
  }
42
+
43
+ function getDeviceID(visitorId: string) {
44
+ const key = 'APP_DEVICE_ID';
45
+ const oldId = localStorage.getItem(key);
46
+ const newId = oldId || visitorId || generateRandomStringSecure(32);
47
+ newId !== oldId && localStorage.setItem(key, newId);
48
+ return newId;
49
+ }
50
+
51
+ function generateRandomStringSecure(length: number) {
52
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
53
+ const randomValues = new Uint32Array(length);
54
+ window.crypto.getRandomValues(randomValues); // 浏览器内置加密 API
55
+
56
+ let result = '';
57
+ for (let i = 0; i < length; i++) {
58
+ result += chars[randomValues[i] % chars.length];
59
+ }
60
+
61
+ return result;
62
+ }
@@ -40,6 +40,10 @@ export function getScanBrowser(chain: string, hash: string, type: 'transaction'
40
40
  },
41
41
  'DOGE': () => `https://dogechain.info/${evmType()}/${hash}`,
42
42
  'BTC': () => `https://mempool.space/${evmType()}/${hash}`,
43
+ 'TON': () => {
44
+ const _type = type === 'transaction' ? '/transactions' : '';
45
+ return `https://tonscan.com${_type}/${hash}`;
46
+ },
43
47
  }[_chain] ?? (() => '');
44
48
 
45
49
  return urlFn();
@@ -60,20 +60,10 @@ export class LocaleManager {
60
60
  const localeTargets = [searchParams.get('locale'), searchParams.get('lang'), this.getStorageLocale(), navigator.language]
61
61
  .filter(locale => !!locale)
62
62
  .map(locale => locale!.replace('_', '-'));
63
- // 区域代码矩阵,2级数组的第1项是这个区域的标识(也是这个语言对应的文件名:en-US.json),后面是这个区域的代码
64
- const codeMatrix = this.localesAvailable.map(locale => [locale, ...this.localeMetas[locale].codes]);
65
63
  let localeFinal = '';
66
64
 
67
65
  for (const target of localeTargets) {
68
- for (const codes of codeMatrix) {
69
- const matched = codes.some(code => code.toUpperCase().startsWith(target.toUpperCase()));
70
-
71
- if (matched) {
72
- localeFinal = codes[0];
73
- break;
74
- }
75
- }
76
-
66
+ localeFinal = this.findMatchingLocale(target);
77
67
  if (localeFinal)
78
68
  break;
79
69
  }