mantur-components 0.1.13-beta.0 → 0.1.13-beta.1

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 CHANGED
@@ -42,7 +42,7 @@ export function Header({
42
42
  }: {
43
43
  userInfo: { username?: string; nickname?: string; avatar?: string } | null;
44
44
  }) {
45
- return <ManturHeader user={userInfo} />;
45
+ return <ManturHeader user={userInfo} appName={import.meta.env.VITE_APP_NAME} />;
46
46
  }
47
47
  ```
48
48
 
@@ -62,6 +62,7 @@ export function Header({
62
62
  <ManturHeader
63
63
  user={userInfo}
64
64
  disabled={disabled}
65
+ appName={import.meta.env.VITE_APP_NAME}
65
66
  brandSlot={<span className="text-lg font-bold">自定义品牌</span>}
66
67
  >
67
68
  <div className="px-4">自定义中间内容</div>
@@ -80,6 +81,7 @@ interface ManturHeaderProps {
80
81
  children?: React.ReactNode;
81
82
  onTenantContextChange?: (detail: ManturTenantContextDetail) => void;
82
83
  rechargePaymentMethod?: "card" | "alipay" | "wechat_pay";
84
+ appName?: string;
83
85
  stripePublishableKey?: string;
84
86
  stripePaymentWindowFeatures?: string;
85
87
  }
@@ -97,6 +99,8 @@ interface ManturHeaderProps {
97
99
 
98
100
  `rechargePaymentMethod`:兼容旧版本的支付方式参数。当前充值创建订单不再主动提交支付方式,支付方式由 Stripe Checkout Session 内部选择。
99
101
 
102
+ `appName`:当前宿主应用名,建议宿主在调用 Header 时传 `appName={import.meta.env.VITE_APP_NAME}`。充值创建订单时会优先使用该值作为请求体 `app`,不传时才回退到 `window.__MANTUR_APP_NAME__`、组件库构建环境或本地开发端口推断。
103
+
100
104
  `stripePublishableKey`:Stripe publishable key。订单返回 Checkout Session `clientSecret`(字段名为 `clientSecret`,值以 `cs_` 开头)时,组件库会在自己的支付弹窗中挂载 Stripe Checkout Elements。
101
105
 
102
106
  `stripePaymentWindowFeatures`:兼容旧版本的窗口配置参数。当前支付不再打开新窗口,不读取该参数。
@@ -153,7 +157,7 @@ import {
153
157
  } from "mantur-components";
154
158
  ```
155
159
 
156
- 充值面板打开时会调用 `getManturBillingPackages()` 拉取 `/billing/packages`;点击支付时会调用 `createManturRechargeOrder()` 创建 `/billing/recharge/orders`,请求体传 `packageId` 或 `customAmount`,并固定传 `uiMode: "elements"`。请求体还会补齐 `app` 和 `redirect`:`app` `window.__MANTUR_APP_NAME__` `VITE_APP_NAME`;本地开发若没有这些配置,会用当前端口兜底识别应用(`:82` creative-agent、`:83` production-agent、`:81` traffic-engine、`:84` distribution-matrix)。`redirect` 与路由拦截器一致,只取当前页面的 `pathname + search + hash`,不拼接协议、域名或开发端口。订单创建成功后会触发浏览器事件 `mantur-recharge-order-created`,`detail` 为后端返回的订单信息。
160
+ 充值面板打开时会调用 `getManturBillingPackages()` 拉取 `/billing/packages`;点击支付时会调用 `createManturRechargeOrder()` 创建 `/billing/recharge/orders`,请求体传 `packageId` 或 `customAmount`,并固定传 `uiMode: "elements"`。请求体还会补齐 `app` 和 `redirect`:`app` 优先取 `ManturHeader` 的 `appName` prop,建议宿主传 `import.meta.env.VITE_APP_NAME`;未传时回退到 `window.__MANTUR_APP_NAME__` 或组件库内可读取的 `VITE_APP_NAME`;本地开发若没有这些配置,会用当前端口兜底识别应用(`:82` creative-agent、`:83` production-agent、`:81` traffic-engine、`:84` distribution-matrix)。`redirect` 与路由拦截器一致,只取当前页面的 `pathname + search + hash`,不拼接协议、域名或开发端口。订单创建成功后会触发浏览器事件 `mantur-recharge-order-created`,`detail` 为后端返回的订单信息。
157
161
 
158
162
  积分明细弹窗打开后会调用 `getManturBillingLedger()` 拉取 `/billing/accounts/me/ledger`,并根据“获得/消耗”、来源和日期范围筛选传递 `directions`、`bizTypes`、`fromTime`、`toTime`,分页总数使用接口返回的 `total`。
159
163
 
@@ -183,7 +187,13 @@ function applyTenantContext(detail: ManturTenantContextDetail) {
183
187
  }
184
188
 
185
189
  function Header({ userInfo }: { userInfo: UserInfo | null }) {
186
- return <ManturHeader user={userInfo} onTenantContextChange={applyTenantContext} />;
190
+ return (
191
+ <ManturHeader
192
+ user={userInfo}
193
+ appName={import.meta.env.VITE_APP_NAME}
194
+ onTenantContextChange={applyTenantContext}
195
+ />
196
+ );
187
197
  }
188
198
  ```
189
199
 
@@ -277,3 +287,40 @@ import type {
277
287
  ```bash
278
288
  npm run build
279
289
  ```
290
+
291
+ ## 发布
292
+
293
+ 测试包和生产包直接发布到 npm,通过 npm tag 区分:
294
+
295
+ ```bash
296
+ npm run publish:test
297
+ npm run publish:pro
298
+ ```
299
+
300
+ `publish:test` 会使用 `vite build --mode test` 构建,并发布到 `test` tag。测试包版本必须是 prerelease,例如:
301
+
302
+ ```bash
303
+ npm version prerelease --preid beta --no-git-tag-version
304
+ npm run publish:test
305
+ ```
306
+
307
+ 测试项目安装:
308
+
309
+ ```bash
310
+ npm install mantur-components@test
311
+ ```
312
+
313
+ `publish:pro` 会使用 `vite build --mode pro` 构建,并发布到 `latest` tag。生产包版本不能包含 `beta`、`alpha`、`rc` 等 prerelease 标识,例如:
314
+
315
+ ```bash
316
+ npm version 0.1.13 --no-git-tag-version
317
+ npm run publish:pro
318
+ ```
319
+
320
+ 生产项目安装:
321
+
322
+ ```bash
323
+ npm install mantur-components@latest
324
+ ```
325
+
326
+ 环境变量读取遵循 Vite mode 规则:测试包读取 `.env` 和 `.env.test`,生产包读取 `.env` 和 `.env.pro`。发布前需要确认对应环境变量已经写入正确的 `VITE_*` 配置。
@@ -1,2 +1,2 @@
1
1
  import type { ManturHeaderProps } from "../types";
2
- export declare function ManturHeader({ user, disabled, brandSlot, children, onTenantContextChange, stripePublishableKey, }: ManturHeaderProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ManturHeader({ user, disabled, brandSlot, children, onTenantContextChange, appName, stripePublishableKey, }: ManturHeaderProps): import("react/jsx-runtime").JSX.Element;