组件v1.14.9
@xmly/hi-components
包含 UI 与复杂交互逻辑的 React 组件库,非通用 UI 框架,依赖 antd 4 / styled-components。
LayoutPercentAttendanceCalendarImageUploadProBraftEditorEncodeText2,542 行 · 5 组件 · 12 demos
7 个包按职责分层,可按需单独安装。以下导出清单与版本号均取自仓库源码。
LayoutPercentAttendanceCalendarImageUploadProBraftEditorEncodeTextuseCountDownusePaypaycompareVersioncopyToClipboardresolveRuntimeEnvparseUrlgetXmAppVersion+5popupCheckstanduseInitPayPopupinitPayPopuplyConfigApiListcreatePaylyApiListPromotionTypeInitOptionpaymentsettlementsubscriptioncheckWxAuthgetWxAuthxmlySharesetXmlyConfigupdateWechatShareDataXMLYWechat下列为基于组件结构与文档还原的静态视觉示意,用于直观了解组件的呈现形态;真实交互逻辑与 API 请以仓库源码为准。
片段摘自仓库 README、demos 与 src/index.ts,保留原始 API 名称。
import { LayoutPercent, AttendanceCalendar, ImageUpload } from '@xmly/hi-components'; import '@xmly/hi-components/lib/index.css'; // 按需加载:babel-plugin-import,camel2DashComponentName 必须为 false const Demo = () => ( <LayoutPercent percent={75}> <AttendanceCalendar weekFormat="cn" onSelect={handleSelect} /> <ImageUpload multiple aspect={16 / 9} /> LayoutPercent> );
import { useCountDown, usePay } from '@xmly/hi-hooks'; const { count, start, stop } = useCountDown({ leftTime: 60 * 1000, interval: 1000, // 支持毫秒级 onEnd: () => notify('验证码已过期'), }); // 发送验证码、回调、自定义间隔等场景均有独立 demo const { pay } = usePay({ onSuccess, onError });
import { compareVersion, copyToClipboard, resolveRuntimeEnv, parseUrl, getXmAppVersion, } from '@xmly/hi-utils'; if (compareVersion(getXmAppVersion(), '6.6.60') >= 0) { copyToClipboard(parseUrl(location.href).query.shareCode); } // 运行环境判定:返回 RuntimeEnv / MultiRuntimeEnv 类型 const env = resolveRuntimeEnv();
import popupCheckstand, { lyConfigApiList, useInitPayPopup } from '@xmly/popup-checkstand'; const destroy = popupCheckstand.show({ cashierInfo, // JSON 字符串,必填 thirdPartyId: 17, tradeOrderNosRef, openIdRef, onPaySuccess: ({ selectedMethod, orderNo }) => {}, onPayError: ({ errorCode, errorMessage }) => {}, onSelectMethod: ({ selectedMethod }) => {}, pullToRefresh: false, }); // destroy() 关闭浮层;localStorage 记住上次成功的 payMethod
import { createPay, PromotionType } from '@xmly/common-pay'; // 单例:内部按设备/场景自动路由 h5 结算页 / 半浮层 / iap / rn const pay = createPay({ goodsId, onPaySuccess, onPayError, onCancel: () => retentionDialog(), // 支付挽留由业务方处理 }); // 流程:商品信息 → 前置校验 → 促销查询 → 下单 → 唤起支付 → 挽留
包间依赖呈单向分层,app-share 完全独立。内部依赖使得构建顺序必须被显式固定。
根 .fatherrc.ts 固定 hi-utils → payment-process → popup-checkstand 优先编译,新增含内部依赖的包需手工维护该顺序。
father-build 基于 Rollup 同时输出 esm 与 cjs;patch-package 修改了 father-build 源码以注入 @babel/runtime-corejs3 垫片。
scripts/create.js 提供组件、Hook、工具函数、新包四类模板,配套 dumi 文档与 Jest 单测。
Lerna 3 独立版本模式,7 个包分别维护版本号与 CHANGELOG。
一套 2021 年前后成型的完整前端基础库工程链路。