mantur-components 0.1.13-beta.1 → 0.1.13-beta.2
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/README.md +23 -4
- package/dist/header/ManturHeader.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/mantur-components.js +729 -703
- package/dist/mantur-components.umd.cjs +3 -3
- package/dist/types.d.ts +2 -0
- package/dist/utils/url.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,7 +42,13 @@ export function Header({
|
|
|
42
42
|
}: {
|
|
43
43
|
userInfo: { username?: string; nickname?: string; avatar?: string } | null;
|
|
44
44
|
}) {
|
|
45
|
-
return
|
|
45
|
+
return (
|
|
46
|
+
<ManturHeader
|
|
47
|
+
user={userInfo}
|
|
48
|
+
appName={import.meta.env.VITE_APP_NAME}
|
|
49
|
+
mainPrefix={import.meta.env.VITE_MAIN_PREFIX}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
46
52
|
}
|
|
47
53
|
```
|
|
48
54
|
|
|
@@ -63,6 +69,7 @@ export function Header({
|
|
|
63
69
|
user={userInfo}
|
|
64
70
|
disabled={disabled}
|
|
65
71
|
appName={import.meta.env.VITE_APP_NAME}
|
|
72
|
+
mainPrefix={import.meta.env.VITE_MAIN_PREFIX}
|
|
66
73
|
brandSlot={<span className="text-lg font-bold">自定义品牌</span>}
|
|
67
74
|
>
|
|
68
75
|
<div className="px-4">自定义中间内容</div>
|
|
@@ -82,6 +89,7 @@ interface ManturHeaderProps {
|
|
|
82
89
|
onTenantContextChange?: (detail: ManturTenantContextDetail) => void;
|
|
83
90
|
rechargePaymentMethod?: "card" | "alipay" | "wechat_pay";
|
|
84
91
|
appName?: string;
|
|
92
|
+
mainPrefix?: string;
|
|
85
93
|
stripePublishableKey?: string;
|
|
86
94
|
stripePaymentWindowFeatures?: string;
|
|
87
95
|
}
|
|
@@ -101,6 +109,8 @@ interface ManturHeaderProps {
|
|
|
101
109
|
|
|
102
110
|
`appName`:当前宿主应用名,建议宿主在调用 Header 时传 `appName={import.meta.env.VITE_APP_NAME}`。充值创建订单时会优先使用该值作为请求体 `app`,不传时才回退到 `window.__MANTUR_APP_NAME__`、组件库构建环境或本地开发端口推断。
|
|
103
111
|
|
|
112
|
+
`mainPrefix`:主应用域名前缀,建议宿主传 `mainPrefix={import.meta.env.VITE_MAIN_PREFIX}`。Header logo hover 时展示“主页/Home”,点击会跳回主应用首页;本地开发环境(`localhost`/`127.0.0.1`)固定跳到 `:80`,测试和生产环境按 `mainPrefix` 替换当前子域名。
|
|
113
|
+
|
|
104
114
|
`stripePublishableKey`:Stripe publishable key。订单返回 Checkout Session `clientSecret`(字段名为 `clientSecret`,值以 `cs_` 开头)时,组件库会在自己的支付弹窗中挂载 Stripe Checkout Elements。
|
|
105
115
|
|
|
106
116
|
`stripePaymentWindowFeatures`:兼容旧版本的窗口配置参数。当前支付不再打开新窗口,不读取该参数。
|
|
@@ -191,6 +201,7 @@ function Header({ userInfo }: { userInfo: UserInfo | null }) {
|
|
|
191
201
|
<ManturHeader
|
|
192
202
|
user={userInfo}
|
|
193
203
|
appName={import.meta.env.VITE_APP_NAME}
|
|
204
|
+
mainPrefix={import.meta.env.VITE_MAIN_PREFIX}
|
|
194
205
|
onTenantContextChange={applyTenantContext}
|
|
195
206
|
/>
|
|
196
207
|
);
|
|
@@ -249,12 +260,13 @@ formatDateByLang("2026-05-19T12:00:00Z", "datetime", "en-US");
|
|
|
249
260
|
|
|
250
261
|
## 主应用跳转工具
|
|
251
262
|
|
|
252
|
-
组件库导出 `redirectToManturMain
|
|
263
|
+
组件库导出 `redirectToManturMain` 和 `redirectToManturMainHome`,用于从当前子应用跳转到主应用:
|
|
253
264
|
|
|
254
265
|
```ts
|
|
255
|
-
import { redirectToManturMain } from "mantur-components";
|
|
266
|
+
import { redirectToManturMain, redirectToManturMainHome } from "mantur-components";
|
|
256
267
|
|
|
257
268
|
redirectToManturMain(import.meta.env.VITE_MAIN_PREFIX, import.meta.env.VITE_APP_NAME);
|
|
269
|
+
redirectToManturMainHome(import.meta.env.VITE_MAIN_PREFIX);
|
|
258
270
|
```
|
|
259
271
|
|
|
260
272
|
行为说明:
|
|
@@ -262,12 +274,19 @@ redirectToManturMain(import.meta.env.VITE_MAIN_PREFIX, import.meta.env.VITE_APP_
|
|
|
262
274
|
- `VITE_MAIN_PREFIX` 为空时保留当前域名并移除端口。
|
|
263
275
|
- `VITE_MAIN_PREFIX` 存在时,将当前 URL 的子域名替换为 `VITE_MAIN_PREFIX`。
|
|
264
276
|
- 非 dev 跳转会追加 `appName=VITE_APP_NAME` 和 `redirect=当前路由地址` 参数。
|
|
277
|
+
- `redirectToManturMainHome` 只跳主应用首页;本地开发固定跳 `localhost:80`。
|
|
265
278
|
- 需要只生成 URL 不跳转时,可传 `{ navigate: false }`。
|
|
266
279
|
|
|
267
280
|
## 公共导出
|
|
268
281
|
|
|
269
282
|
```ts
|
|
270
|
-
import {
|
|
283
|
+
import {
|
|
284
|
+
ManturHeader,
|
|
285
|
+
formatDateByLang,
|
|
286
|
+
redirectToManturMain,
|
|
287
|
+
redirectToManturMainHome,
|
|
288
|
+
resolveManturMainHomeUrl,
|
|
289
|
+
} from "mantur-components";
|
|
271
290
|
import type {
|
|
272
291
|
ManturBillingPackageDTO,
|
|
273
292
|
ManturCreateRechargeOrderResponse,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ManturHeaderProps } from "../types";
|
|
2
|
-
export declare function ManturHeader({ user, disabled, brandSlot, children, onTenantContextChange, appName, stripePublishableKey, }: ManturHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function ManturHeader({ user, disabled, brandSlot, children, onTenantContextChange, appName, mainPrefix, stripePublishableKey, }: ManturHeaderProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { cancelManturRechargeOrder, createManturRechargeOrder, getManturBillingA
|
|
|
3
3
|
export type { ManturBillingAccountDTO, ManturBillingPackageDTO, ManturChargePointWithModelsDTO, ManturCreateRechargeOrderRequest, ManturCreateRechargeOrderResponse, ManturLedgerEntryDTO, ManturLedgerQuery, ManturModelRuleDTO, ManturPageResult, ManturRechargeOrderDTO, } from "./api";
|
|
4
4
|
export { formatDateByLang } from "./utils/date";
|
|
5
5
|
export type { ManturDateFormatType, ManturDateInput } from "./utils/date";
|
|
6
|
-
export { getManturRechargeRedirectContext, redirectToManturMain } from "./utils/url";
|
|
6
|
+
export { getManturRechargeRedirectContext, redirectToManturMain, redirectToManturMainHome, resolveManturMainHomeUrl, } from "./utils/url";
|
|
7
7
|
export type { ManturMainRedirectOptions } from "./utils/url";
|
|
8
8
|
export { isManturStripePaymentWindowMessage, MANTUR_STRIPE_PAYMENT_ROUTE, MANTUR_STRIPE_PAYMENT_WINDOW_MESSAGE_TYPE, postManturStripePaymentWindowMessage, resolveManturRechargePaymentPageUrl, resolveManturStripePaymentPageUrl, } from "./utils/stripe-payment-window";
|
|
9
9
|
export type { ManturStripePaymentPageUrlOptions, ManturStripePaymentWindowAction, ManturStripePaymentWindowMessage, } from "./utils/stripe-payment-window";
|