@peng_kai/kit 0.2.26 → 0.2.27

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.
@@ -2,9 +2,17 @@
2
2
  import { computed, reactive } from 'vue';
3
3
  import { useInjectedAdminConfig } from '../../provider';
4
4
 
5
- const icons = reactive<Record<string, string>>({});
6
-
7
- const fullback = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDIwIDIwIj48cGF0aCBmaWxsPSIjODQ4YTlkNTUiIGQ9Ik0xMCAyMGExMCAxMCAwIDEgMSAwLTIwIDEwIDEwIDAgMCAxIDAgMjBtMS01aDFhMyAzIDAgMCAwIDAtNkg3Ljk5YTEgMSAwIDAgMSAwLTJIMTRWNWgtM1YzSDl2Mkg4YTMgMyAwIDEgMCAwIDZoNGExIDEgMCAxIDEgMCAySDZ2MmgzdjJoMnoiLz48L3N2Zz4=';
5
+ const presetSymbols = reactive<Record<string, string>>({
6
+ USDT: 'https://api.iconify.design/cryptocurrency-color:usdt.svg',
7
+ TRX: 'https://api.iconify.design/cryptocurrency-color:trx.svg',
8
+ USDC: 'https://api.iconify.design/cryptocurrency-color:usdc.svg',
9
+ ETH: 'https://api.iconify.design/cryptocurrency-color:eth.svg',
10
+ BNB: 'https://api.iconify.design/cryptocurrency-color:bnb.svg',
11
+ BUSD: 'https://api.iconify.design/token-branded:busd.svg',
12
+ MATIC: 'https://api.iconify.design/cryptocurrency-color:matic.svg',
13
+ SOL: 'https://api.iconify.design/cryptocurrency-color:sol.svg',
14
+ });
15
+ const presetTextSymbols = reactive(['¥', '€', '¥', '₱', '$', 'AED', 'ARS', '$', 'BDT', 'R$', '$', 'Fr', '$', 'Kč', 'KR', '£', 'Ft', 'Rp', '₪', '₹', '₩', '$', 'RM', 'NGN', 'KR', '$', 'Rs', 'zł', '₽', 'SAR', 'SEK', 'S$', '฿', '₺', 'NT$', 'UAH', '₫', 'R']);
8
16
  </script>
9
17
 
10
18
  <script setup lang="ts">
@@ -18,17 +26,19 @@ const props = withDefaults(defineProps<{
18
26
  useCdn: true,
19
27
  });
20
28
 
21
- const { cdn } = useInjectedAdminConfig()!;
29
+ const { cdn } = useInjectedAdminConfig() ?? {};
22
30
 
23
31
  const src = computed(() => {
24
32
  const isHttpUrl = props.symbol.startsWith('http');
25
33
 
26
34
  if (isHttpUrl)
27
35
  return props.symbol;
28
- else if (props.useCdn && cdn.value)
36
+ else if (presetTextSymbols.includes(props.symbol))
37
+ return props.symbol;
38
+ else if (props.useCdn && cdn?.value)
29
39
  return `${cdn.value}/currency/${props.symbol}.svg`;
30
40
  else
31
- return icons[props.symbol.toUpperCase()];
41
+ return presetSymbols[props.symbol.toUpperCase()];
32
42
  });
33
43
  </script>
34
44
 
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { computed, reactive } from 'vue';
2
+ import { computed } from 'vue';
3
3
  import bigNumber from 'bignumber.js';
4
4
  import isNil from 'lodash-es/isNil';
5
5
  import { CurrencyIcon } from '../../currency';
@@ -8,15 +8,6 @@ export const config = {
8
8
  aboveColor: '#52c41a',
9
9
  belowColor: '#ff4d4f',
10
10
  };
11
-
12
- /**
13
- * 当 symbol 为以下值时,使用预设的 Logo
14
- */
15
- const presetTextSymbols = reactive(['$', '¥']);
16
-
17
- export function setConfig(textSymbols: string[]) {
18
- presetTextSymbols.concat(textSymbols);
19
- }
20
11
  </script>
21
12
 
22
13
  <script setup lang="ts">
@@ -75,15 +66,10 @@ const amountColor = computed(() => {
75
66
  <div class="amount-wrapper" :style="{ '--amount-color': amountColor }">
76
67
  <!-- 约等于 -->
77
68
  <span v-if="props.approx" class="color-$amount-color">≈</span>
78
-
79
- <!-- 文本符号,如法定币种符号(¥、$) -->
80
- <span v-if="!symbol || presetTextSymbols.includes(symbol)" class="color-$amount-color">{{ symbol }}</span>
81
- <!-- 图片符号 -->
69
+ <!-- 符号 -->
82
70
  <CurrencyIcon v-else class="symbol-logo" :symbol="symbol" :useCdn="useCdn" />
83
-
84
71
  <!-- 金额 -->
85
72
  <span class="color-$amount-color amount">{{ amountText }}</span>
86
-
87
73
  <!-- 单位 -->
88
74
  <span v-if="props.unit" class="unit">{{ props.unit }}</span>
89
75
  </div>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.2.26",
4
+ "version": "0.2.27",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",