全局配置与公共类型
全局配置 config
config 是一个响应式对象,运行时修改后组件即时生效。
uts
import { config } from "@/uni_modules/jzfw-ui";
config.fontSize = 1.1; // 全局字号缩放系数,null 表示不缩放
config.zIndex = 600; // 弹层层级基数,每次分配后自增| 字段 | 类型 | 默认 | 说明 |
|---|---|---|---|
fontSize | number | null | null | 全局字号缩放系数,null 表示按组件默认字号渲染 |
zIndex | number | 600 | 弹层层级基数,jz-popup 每次打开时取值并自增 |
fontSize 通过 useSize() 生效:组件用 useSize().toScale(默认字号) 计算最终字号。
公共类型速查
以下类型定义于 types/index.uts,可在页面中 import type 使用。
基础类型
| 类型 | 取值 | 说明 |
|---|---|---|
Size | "small" | "normal" | "large" | 控件尺寸 |
Type | "primary" | "success" | "warn" | "error" | "info" | 语义类型(按钮、标签等) |
Theme | "light" | "dark" | 明暗主题 |
Justify | "start" | "center" | "end" | 主轴对齐方式 |
PassThroughProps | { className?: string } | 透传属性基类 |
文本 / 按钮 / 图片
| 类型 | 取值 |
|---|---|
JzTextType | "default" | "phone" | "name" | "amount" | "card" | "email" |
JzButtonType | "primary" | "success" | "warn" | "error" | "info" | "light" | "dark" |
JzButtonFormType | "submit" | "reset" |
JzButtonLang | "en" | "zh_CN" | "zh_TW" |
JzImageMode | scaleToFill / aspectFit / aspectFill / widthFix / heightFix / top / bottom / center / left / right / top left / top right / bottom left / bottom right |
JzButtonOpenType | 小程序开放能力,如 getUserInfo、getPhoneNumber、share、chooseAvatar、launchApp、openSetting、feedback、contact、subscribe、login 等 |
弹窗 / 安全区
| 类型 | 取值 |
|---|---|
JzPopupDirection | "top" | "right" | "bottom" | "center" | "left" |
JzSafeAreaType | "top" | "bottom" |
输入 / 表单
| 类型 | 取值 / 结构 |
|---|---|
JzInputType | "text" | "number" | "idcard" | "digit" | "tel" | "safe-password" | "nickname" |
JzInputConfirmType | "done" | "go" | "next" | "search" | "send" |
JzTextareaInputMode | "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url" |
JzFormLabelPosition | "left" | "top" | "right" |
JzFormRule(表单校验规则):
| 字段 | 类型 | 说明 |
|---|---|---|
required? | boolean | 是否必填 |
message? | string | 错误信息,优先于内置文案 |
min? | number | 最小值或最小长度 |
max? | number | 最大值或最大长度 |
pattern? | RegExp | 正则校验 |
validator? | (value: any | null) => boolean | string | 自定义校验,返回字符串即错误信息 |
JzFormValidateResult:{ valid: boolean; errors: JzFormValidateError[] },其中 JzFormValidateError = { field: string; message: string }。
选择器 / 上传
| 类型 | 结构 |
|---|---|
JzSelectOption | { label: string; value: any; children?: JzSelectOption[] } |
JzSelectValue | string[] | number[] | number | string | null |
JzUploadItem | { uid: string; preview: string; url: string; progress: number } |
JzSelectDateType | "year" | "month" | "date" | "hour" | "minute" | "second" |
JzSelectTimeType | "hour" | "minute" | "second" |
反馈
| 类型 | 结构 |
|---|---|
JzToastPosition | "top" | "center" | "bottom" |
JzToastType | "success" | "warn" | "error" | "question" | "disabled" | "stop" |
JzToastOptions | { type?; icon?; image?; message: string; position?; duration?; clear? } |
JzConfirmAction | "confirm" | "cancel" | "close" |
JzConfirmOptions | { title; message; callback?; beforeClose?; confirmText?; showConfirm?; cancelText?; showCancel?; duration? } |
JzConfirmBeforeCloseEvent | { close(): void; showLoading(): void; hideLoading(): void } |
JzActionSheetItem | { label; icon?; disabled?; color?; callback? } |
JzActionSheetOptions | { list: JzActionSheetItem[]; title?; description?; cancelText?; showCancel?; maskClosable? } |
导航 / 数据展示
| 类型 | 结构 |
|---|---|
JzTabsItem | { label: string; value: string | number; disabled?: boolean } |
JzTabbarItem | { icon?; selectedIcon?; value: string; text? } |
JzListItem | { label; content?; icon?; arrow?; hoverable?; disabled? } |
JzListViewItem | { label?; value?; index?; children?: JzListViewItem[] } |
JzListViewRefresherStatus | "default" | "pulling" | "refreshing" |
JzPaginationMode | "simple" | "normal" |
JzMarqueeDirection | "horizontal" | "vertical" |
JzFilterItemType | "switch" | "sort" | "select" |
JzSkeletonType | "text" | "image" | "circle" | "button" |
JzTreeItem | { id; label; children?; disabled?; isChecked?; isHalfChecked?; isExpand? } |
其他
| 类型 | 结构 |
|---|---|
JzQrcodeMode | "rect" | "circular" | "line" | "rectSmall" |
JzSlideVerifyMode | "slide" | "image" |
JzSelectSeatItem | { row; col; disabled?; empty?; color?; bgColor?; borderColor?; selectedBgColor?; selectedColor?; selectedIcon?; icon?; image?; selectedImage? } |
JzSelectSeatValue | { row: number; col: number } |
JzCalendarMode | "single" | "multiple" | "range" |
JzCalendarDateConfig | { date: string; topText?; bottomText?; color?; disabled? } |
Canvas 绘制
| 类型 | 用途 |
|---|---|
JzCanvasImageMode | 画布图片裁剪模式(取值与 JzImageMode 略不同) |
JzCanvasTransformOptions | 缩放 / 旋转 / 平移变换参数 |
JzCanvasTextOptions | 文本渲染参数(坐标、字号、对齐、省略、行高等) |
JzCanvasImageOptions | 图片渲染参数(坐标、宽高、url、圆角、变换等) |
JzCanvasDivOptions | 矩形 / 圆角矩形渲染参数 |
JzCanvasCropResult | 图片裁剪结果(源裁剪区 + 画布绘制区) |
