Skip to content

Commit

Permalink
feat: update types (#151)
Browse files Browse the repository at this point in the history
* feat: update common types

* fix: add EasyCom comments

* chore: comments

* feat: update globalStyles

* feat: update schema

* chore: naming

* feat: tabBar types

* fix: allow additional props

* feat: condition types

* feat!: subPackages types

* feat: preloadRule types

* feat: workers types

* feat: theWindow types

* feat: uniIdRouter types

* fix: update exports

* feat: globalStyle navigationBarShadow type

* test: fix

* fix: fix types
  • Loading branch information
ModyQyW authored Apr 9, 2024
1 parent fa093d0 commit cf58452
Show file tree
Hide file tree
Showing 24 changed files with 5,468 additions and 787 deletions.
77 changes: 0 additions & 77 deletions packages/core/src/config/types/appPlus.ts

This file was deleted.

113 changes: 112 additions & 1 deletion packages/core/src/config/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,116 @@ export type RGBColor = `rgb(${number}, ${number}, ${number})`
export type RGBAColor = `rgba(${number}, ${number}, ${number}, ${number})`
export type HEXColor = `#${string}`
export type ThemeColor = `@${string}`

export type Color = RGBColor | RGBAColor | HEXColor

export type PxSize = `${number}px`
export type RpxSize = `${number}rpx`
export type PercentageSize = `${number}%`

/**
* 窗口动画,详见 [窗口动画](https://uniapp.dcloud.net.cn/api/router.html#animation)
*/
export type AnimationType = 'slide-in-right' | 'slide-in-left' | 'slide-in-top' | 'slide-in-bottom' | 'pop-in' | 'fade-in' | 'zoom-out' | 'zoom-fade-out' | 'none'

export interface TitleNViewButton {
/**
* 自定义按钮样式,详见 [自定义按钮样式](https://uniapp.dcloud.net.cn/collocation/pages#app-titlenview-buttons-type)
*
* "forward" 前进按钮
*
* "back" 后退按钮
*
* "share" 分享按钮
*
* "favorite" 收藏按钮
*
* "home" 主页按钮
*
* "menu" 菜单按钮
*
* "close" 关闭按钮
*
* "none" 无样式,需通过 text 属性设置按钮上显示的内容、通过 fontSrc 属性设置使用的字体库
*
* @default "none"
*/
type?: 'forward' | 'back' | 'share' | 'favorite' | 'home' | 'menu' | 'close' | 'none'

/**
* 自定义按钮文字颜色,支持 HEX 颜色
*
* @default 与标题文字样式一样
*
* @format color
*/
color?: HEXColor

/**
* 自定义按钮背景色,仅在标题栏 type 为 "transparent" 时生效,支持 HEX 和 RGBA 颜色
*
* @default 灰色半透明
*
* @format color
*/
background?: HEXColor | RGBAColor

/**
* 自定义按钮按下状态文字颜色,支持 HEX 和 RGBA 颜色
*
* @default color 属性值自动调整透明度为 0.3
*
* @format color
*/
colorPressed?: HEXColor | RGBAColor

/**
* 自定义按钮在标题栏的显示位置,仅支持 "right" / "left"
*
* "right" 右侧
*
* "left" 左侧
*
* @default "right"
*/
float?: 'right' | 'left'

/**
* 自定义按钮文字粗细,仅支持 "normal" | "bold"
*
* "normal" 标准
*
* "bold" 加粗
*
* @default "normal"
*/
fontWeight?: 'normal' | 'bold'

/**
* 自定义按钮文字大小
*/
fontSize?: string

/**
* 自定义按钮字体文件路径,只支持本地地址
*/
fontSrc?: string

/**
* 自定义按钮是否显示选择指示图标(向下箭头),常用于城市选择
*
* @default false
*/
select?: boolean

/**
* 自定义按钮文字内容。使用字体图标时 unicode 字符表示必须以"\\u" 开头,如 "\\ue123"
*/
text?: string

/**
* 自定义按钮文字宽度,支持单位为 px 的逻辑像素值或 "auto",按钮内容居中显示
*
* @default "44px"
*/
width?: PxSize | 'auto'
}
28 changes: 28 additions & 0 deletions packages/core/src/config/types/condition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export interface ConditionItem {
/**
* 启动模式名称
*/
name: string

/**
* 启动页面路径
*/
path: string

/**
* 启动参数,可在页面的 onLoad 函数里获得
*/
query?: string
}

export interface Condition {
/**
* 当前激活的模式,list 节点的索引值
*/
current: number

/**
* 启动模式列表
*/
list: Partial<ConditionItem>[]
}
18 changes: 18 additions & 0 deletions packages/core/src/config/types/easycom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
export interface EasyCom {
/**
* 是否开启自动扫描,开启后将会自动扫描符合 `components/组件名称/组件名称.vue` 目录结构的组件
*
* @default true
*/
autoscan?: boolean

/**
* 以正则方式自定义组件匹配规则
*
* 如果 `autoscan` 不能满足需求,可以使用 `custom` 自定义匹配规则
*
* @example
* "custom": {
* "^uni-(.*)": "@/components/uni-$1.vue", // 匹配 components 目录内的 vue 文件
* "^vue-file-(.*)": "packageName/path/to/vue-file-$1.vue" // 匹配 node_modules 内的 vue 文件
* }
}
*/
custom?: Record<string, string>
}
Loading

0 comments on commit cf58452

Please sign in to comment.