best-unit 0.0.32 → 0.0.34
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/best-unit.cjs +7 -7
- package/dist/best-unit.js +716 -603
- package/dist/types/global.d.ts +3 -6
- package/package.json +1 -1
- package/src/api/proxy.ts +1 -6
- package/src/components/business/recharge-sdk/components/OfflineTransferForm.tsx +12 -11
- package/src/components/business/recharge-sdk/components/OnlineRechargeForm.tsx +9 -8
- package/src/components/business/recharge-sdk/components/Recharge.tsx +8 -7
- package/src/components/business/recharge-sdk/index.tsx +5 -4
- package/src/components/business/statistical-balance/index.tsx +15 -17
- package/src/components/common/HoverPopover.tsx +1 -1
- package/src/components/common/Upload.tsx +7 -6
- package/src/demo/App.tsx +126 -7
- package/src/local/en.ts +57 -0
- package/src/local/index.ts +42 -0
- package/src/local/zh.ts +57 -0
- package/src/main.ts +2 -2
- package/src/types/global.d.ts +3 -6
- package/src/utils/business/index.ts +4 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getZhText, zh } from "./zh";
|
|
2
|
+
import { getEnText, en } from "./en";
|
|
3
|
+
|
|
4
|
+
export type Locale = "zh" | "en";
|
|
5
|
+
|
|
6
|
+
const locales = {
|
|
7
|
+
zh,
|
|
8
|
+
en,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// 获取当前语言
|
|
12
|
+
export function getCurrentLocale(): Locale {
|
|
13
|
+
const fundUnitParams = JSON.parse(
|
|
14
|
+
sessionStorage.getItem("fund_unit_params") || "{}"
|
|
15
|
+
);
|
|
16
|
+
return fundUnitParams.locale || "zh";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 获取国际化文本
|
|
20
|
+
export function getLocaleText() {
|
|
21
|
+
const locale = getCurrentLocale();
|
|
22
|
+
return locales[locale];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 获取指定语言的文本
|
|
26
|
+
export function getLocaleTextByLang(locale: Locale) {
|
|
27
|
+
return locales[locale];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 使用中文key的t函数
|
|
31
|
+
export function t(zhKey: string): string {
|
|
32
|
+
const locale = getCurrentLocale();
|
|
33
|
+
|
|
34
|
+
if (locale === "zh") {
|
|
35
|
+
return getZhText(zhKey);
|
|
36
|
+
} else {
|
|
37
|
+
return getEnText(zhKey);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 导出所有语言包
|
|
42
|
+
export { zh, en };
|
package/src/local/zh.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// 中文语言包
|
|
2
|
+
export const zh: Record<string, string> = {
|
|
3
|
+
// 余额相关
|
|
4
|
+
余额详情: "余额详情",
|
|
5
|
+
真实金额: "真实金额",
|
|
6
|
+
冻结金额: "冻结金额",
|
|
7
|
+
总可用: "总可用",
|
|
8
|
+
|
|
9
|
+
// 充值相关
|
|
10
|
+
"充值 / 转账": "充值 / 转账",
|
|
11
|
+
在线充值: "在线充值",
|
|
12
|
+
线下转账: "线下转账",
|
|
13
|
+
充值币种: "充值币种",
|
|
14
|
+
充值金额: "充值金额",
|
|
15
|
+
支付平台: "支付平台",
|
|
16
|
+
请选择充值币种: "请选择充值币种",
|
|
17
|
+
请输入充值金额: "请输入充值金额",
|
|
18
|
+
请选择支付平台: "请选择支付平台",
|
|
19
|
+
"提交失败,请重试": "提交失败,请重试",
|
|
20
|
+
"提交中...": "提交中...",
|
|
21
|
+
去支付: "去支付",
|
|
22
|
+
取消: "取消",
|
|
23
|
+
关闭: "关闭",
|
|
24
|
+
|
|
25
|
+
// 离线转账相关
|
|
26
|
+
第三方支付平台: "第三方支付平台",
|
|
27
|
+
交易ID: "交易ID",
|
|
28
|
+
请输入转账交易ID: "请输入转账交易ID",
|
|
29
|
+
上传文件: "上传文件",
|
|
30
|
+
请上传转账凭证: "请上传转账凭证",
|
|
31
|
+
离线充值创建成功: "离线充值创建成功",
|
|
32
|
+
|
|
33
|
+
// 通用
|
|
34
|
+
"加载中...": "加载中...",
|
|
35
|
+
错误: "错误",
|
|
36
|
+
成功: "成功",
|
|
37
|
+
必填: "必填",
|
|
38
|
+
|
|
39
|
+
// 按钮文本
|
|
40
|
+
"充值/转账": "充值/转账",
|
|
41
|
+
切换为暗黑主题: "切换为暗黑主题",
|
|
42
|
+
切换为白色主题: "切换为白色主题",
|
|
43
|
+
|
|
44
|
+
// 上传组件相关
|
|
45
|
+
点击或拖拽文件到此处上传: "点击或拖拽文件到此处上传",
|
|
46
|
+
"支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传":
|
|
47
|
+
"支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传",
|
|
48
|
+
个文件: "个文件",
|
|
49
|
+
"正在上传...": "正在上传...",
|
|
50
|
+
已上传: "已上传",
|
|
51
|
+
移除: "移除",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// 根据中文key获取文本的函数
|
|
55
|
+
export function getZhText(zhKey: string): string {
|
|
56
|
+
return zh[zhKey] || zhKey;
|
|
57
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { npmTest, printCurrentTime } from "./utils/common/index";
|
|
2
2
|
import { initFundUnit } from "./utils/business/index";
|
|
3
|
-
import { viteProxy
|
|
3
|
+
import { viteProxy } from "./api/proxy";
|
|
4
4
|
|
|
5
5
|
import "./components/business/recharge-sdk";
|
|
6
6
|
import "./components/business/statistical-balance";
|
|
7
7
|
|
|
8
8
|
// 可选:导出组件列表或版本信息
|
|
9
9
|
export const components = ["best-recharge", "best-statistical-balance"];
|
|
10
|
-
export { npmTest, printCurrentTime, initFundUnit, viteProxy
|
|
10
|
+
export { npmTest, printCurrentTime, initFundUnit, viteProxy };
|
package/src/types/global.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ export declare function initFundUnit(params: {
|
|
|
8
8
|
biz_type: string;
|
|
9
9
|
user_id: string;
|
|
10
10
|
theme?: string;
|
|
11
|
+
locale?: "zh" | "en";
|
|
11
12
|
}): {
|
|
12
13
|
token: string;
|
|
13
14
|
merchantId: string;
|
|
14
15
|
bizType: string;
|
|
15
16
|
theme?: string;
|
|
16
17
|
userId: string;
|
|
18
|
+
locale: "zh" | "en";
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
// Vite 代理配置类型
|
|
@@ -26,12 +28,6 @@ export declare const viteProxy: {
|
|
|
26
28
|
};
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
// Next.js 代理配置类型
|
|
30
|
-
export declare const nextProxy: {
|
|
31
|
-
source: string;
|
|
32
|
-
destination: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
31
|
declare global {
|
|
36
32
|
interface Window {
|
|
37
33
|
bestUnit: {
|
|
@@ -39,6 +35,7 @@ declare global {
|
|
|
39
35
|
token: string;
|
|
40
36
|
merchant_id: string;
|
|
41
37
|
biz_type: string;
|
|
38
|
+
locale?: "zh" | "en";
|
|
42
39
|
}) => void;
|
|
43
40
|
};
|
|
44
41
|
}
|
|
@@ -4,8 +4,9 @@ export function initFundUnit(params: {
|
|
|
4
4
|
biz_type: string;
|
|
5
5
|
user_id: string;
|
|
6
6
|
theme?: string;
|
|
7
|
+
locale?: "zh" | "en";
|
|
7
8
|
}) {
|
|
8
|
-
const { merchant_id, biz_type, theme, user_id } = params;
|
|
9
|
+
const { merchant_id, biz_type, theme, user_id, locale = "zh" } = params;
|
|
9
10
|
const token = "Bearer " + params.token;
|
|
10
11
|
sessionStorage.setItem(
|
|
11
12
|
"fund_unit_params",
|
|
@@ -15,6 +16,7 @@ export function initFundUnit(params: {
|
|
|
15
16
|
userId: user_id,
|
|
16
17
|
token,
|
|
17
18
|
theme,
|
|
19
|
+
locale,
|
|
18
20
|
})
|
|
19
21
|
);
|
|
20
22
|
return {
|
|
@@ -23,5 +25,6 @@ export function initFundUnit(params: {
|
|
|
23
25
|
bizType: biz_type,
|
|
24
26
|
theme,
|
|
25
27
|
userId: user_id,
|
|
28
|
+
locale,
|
|
26
29
|
};
|
|
27
30
|
}
|