best-unit 1.2.6 → 1.2.7

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.
@@ -19,16 +19,19 @@ export enum Env {
19
19
 
20
20
  // 类型定义
21
21
  export interface BalanceData {
22
- fundBalanceId: string; // 余额账户id
23
- merchantId: number; // 商户id
24
- bizType: string; // 业务类型
25
- currency: string; // 币种
26
- totalAmount: string; // 真实金额
27
- availableAmount: string; // 可用余额
28
- frozenAmount: string; // 冻结金额
29
- pendingAmount: string; // 待处理金额
30
- status: string; // 状态
31
- createdAt: string; // 创建时间
22
+ fundBalanceId: string;
23
+ merchantId: number;
24
+ bizType: string;
25
+ currency: string;
26
+ totalAmount: string;
27
+ frozenAmount: string;
28
+ creditLimit: string;
29
+ creditUsed: string;
30
+ isCredit: boolean;
31
+ availableAmount: string;
32
+ pendingAmount: string;
33
+ status: string;
34
+ createdAt: string;
32
35
  }
33
36
 
34
37
  export interface InitParams {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "best-unit",
3
3
  "private": false,
4
- "version": "1.2.6",
4
+ "version": "1.2.7",
5
5
  "type": "module",
6
6
  "main": "dist/best-unit.cjs",
7
7
  "module": "dist/best-unit.js",
@@ -19,16 +19,19 @@ export enum Env {
19
19
 
20
20
  // 类型定义
21
21
  export interface BalanceData {
22
- fundBalanceId: string; // 余额账户id
23
- merchantId: number; // 商户id
24
- bizType: string; // 业务类型
25
- currency: string; // 币种
26
- totalAmount: string; // 真实金额
27
- availableAmount: string; // 可用余额
28
- frozenAmount: string; // 冻结金额
29
- pendingAmount: string; // 待处理金额
30
- status: string; // 状态
31
- createdAt: string; // 创建时间
22
+ fundBalanceId: string;
23
+ merchantId: number;
24
+ bizType: string;
25
+ currency: string;
26
+ totalAmount: string;
27
+ frozenAmount: string;
28
+ creditLimit: string;
29
+ creditUsed: string;
30
+ isCredit: boolean;
31
+ availableAmount: string;
32
+ pendingAmount: string;
33
+ status: string;
34
+ createdAt: string;
32
35
  }
33
36
 
34
37
  export interface InitParams {
@@ -4,16 +4,19 @@ import { Locale, Theme, type Env } from "@/types";
4
4
 
5
5
  // 余额数据结构接口
6
6
  export interface BalanceData {
7
- fundBalanceId: string; // 余额账户id
8
- merchantId: number; // 商户id
9
- bizType: string; // 业务类型
10
- currency: string; // 币种
11
- totalAmount: string; // 真实金额
12
- availableAmount: string; // 可用余额
13
- frozenAmount: string; // 冻结金额
14
- pendingAmount: string; // 待处理金额
15
- status: string; // 状态
16
- createdAt: string; // 创建时间
7
+ fundBalanceId: string;
8
+ merchantId: number;
9
+ bizType: string;
10
+ currency: string;
11
+ totalAmount: string;
12
+ frozenAmount: string;
13
+ creditLimit: string;
14
+ creditUsed: string;
15
+ isCredit: boolean;
16
+ availableAmount: string;
17
+ pendingAmount: string;
18
+ status: string;
19
+ createdAt: string;
17
20
  }
18
21
 
19
22
  interface ThemeConfig {
@@ -1,79 +0,0 @@
1
- // 外部项目使用示例
2
- import {
3
- getBalanceData,
4
- type BalanceData,
5
- type InitParams,
6
- type ThemeConfig,
7
- type Locale,
8
- type Theme,
9
- type Env,
10
- } from "best-unit";
11
-
12
- // 使用 BalanceData 类型
13
- async function handleBalanceData() {
14
- try {
15
- const balance: BalanceData = await getBalanceData();
16
- console.log(`余额账户: ${balance.fundBalanceId}`);
17
- console.log(`可用余额: ${balance.availableAmount} ${balance.currency}`);
18
- } catch (error) {
19
- console.error("获取余额失败:", error);
20
- }
21
- }
22
-
23
- // 使用 InitParams 类型
24
- function initializeApp() {
25
- const params: InitParams = {
26
- token: "your-token-here",
27
- user_id: "user-123",
28
- env: Env.DEV,
29
- theme: Theme.WHITE,
30
- locale: Locale.ZH,
31
- themeConfig: {
32
- white: {
33
- color: "#52c41a", // 绿色
34
- },
35
- dark: {
36
- color: "#722ed1", // 紫色
37
- },
38
- },
39
- };
40
-
41
- // 调用初始化函数
42
- // initFundUnit(params);
43
- }
44
-
45
- // 使用 ThemeConfig 类型
46
- function createCustomTheme(primaryColor: string): ThemeConfig {
47
- return {
48
- white: {
49
- color: primaryColor,
50
- },
51
- dark: {
52
- color: primaryColor,
53
- },
54
- };
55
- }
56
-
57
- // 类型安全的余额处理函数
58
- function processBalance(balance: BalanceData): {
59
- total: number;
60
- available: number;
61
- frozen: number;
62
- pending: number;
63
- } {
64
- return {
65
- total: parseFloat(balance.totalAmount),
66
- available: parseFloat(balance.availableAmount),
67
- frozen: parseFloat(balance.frozenAmount),
68
- pending: parseFloat(balance.pendingAmount),
69
- };
70
- }
71
-
72
- // 导出示例函数
73
- export { handleBalanceData, initializeApp, createCustomTheme, processBalance };
74
-
75
- // 使用说明:
76
- // 1. 从 'best-unit' 导入类型和函数
77
- // 2. 所有类型都提供完整的 TypeScript 支持
78
- // 3. 支持智能提示和类型检查
79
- // 4. 可以在任何 TypeScript 项目中使用