优化细节

This commit is contained in:
icssoa
2025-08-19 18:11:00 +08:00
parent 67a6b2c29f
commit 10e17efb67
18 changed files with 72 additions and 28 deletions

View File

@@ -0,0 +1,4 @@
export type ClBackTopProps = {
className?: string;
top?: number | any;
};

View File

@@ -1,7 +1,8 @@
import type { Type } from "../../types";
import type { PassThroughProps, Type } from "../../types";
export type ClBadgePassThrough = {
className?: string;
text?: PassThroughProps;
};
export type ClBadgeProps = {

View File

@@ -1,4 +1,4 @@
import type { ClFormLabelPosition, PassThroughProps } from "../../types";
import type { ClFormLabelPosition, ClFormRule, PassThroughProps } from "../../types";
export type ClFormItemPassThrough = {
className?: string;
@@ -13,6 +13,7 @@ export type ClFormItemProps = {
pt?: ClFormItemPassThrough;
label?: string;
prop?: string;
rules?: ClFormRule[];
labelPosition?: ClFormLabelPosition;
labelWidth?: string | any;
showAsterisk?: boolean | any;

View File

@@ -14,4 +14,5 @@ export type ClFormProps = {
showAsterisk?: boolean;
showMessage?: boolean;
disabled?: boolean;
scrollToError?: boolean;
};

View File

@@ -1,9 +1,13 @@
import type { ClListViewItem, PassThroughProps } from "../../types";
import type { ClListViewItem, ClListViewGroup, ClListViewVirtualItem, PassThroughProps, ClListViewRefresherStatus } from "../../types";
export type ClListViewPassThrough = {
className?: string;
item?: PassThroughProps;
itemHover?: PassThroughProps;
list?: PassThroughProps;
indexBar?: PassThroughProps;
scroller?: PassThroughProps;
refresher?: PassThroughProps;
};
export type ClListViewProps = {
@@ -16,12 +20,14 @@ export type ClListViewProps = {
bottomHeight?: number;
bufferSize?: number;
virtual?: boolean;
// 下拉刷新相关属性
scrollIntoView?: string;
scrollWithAnimation?: boolean;
showScrollbar?: boolean;
refresherEnabled?: boolean;
refresherThreshold?: number;
refresherTriggered?: boolean;
refresherBackground?: string;
refresherDefaultText?: string;
refresherPullingText?: string;
refresherRefreshingText?: string;
showBackTop?: boolean;
};

View File

@@ -13,4 +13,5 @@ export type ClLoadmoreProps = {
loadingText?: string;
finish?: boolean;
finishText?: string;
safeAreaBottom?: boolean;
};

View File

@@ -295,6 +295,7 @@ function initCanvas() {
success: (context: CanvasContext) => {
// 获取绘图上下文
drawCtx = context.getContext("2d")!;
// 设置宽高
drawCtx!.canvas.width = props.width * dpr;
drawCtx!.canvas.height = props.height * dpr;

View File

@@ -9,6 +9,7 @@ export type ClTextProps = {
pt?: ClTextPassThrough;
value?: string | number | any;
color?: string;
size?: number | string | any;
type?: ClTextType;
mask?: boolean;
currency?: string;

View File

@@ -1,5 +1,5 @@
<template>
<view class="cl-timeline-item" :class="[pt.classNames]">
<view class="cl-timeline-item" :class="[pt.className]">
<view class="cl-timeline-item__left">
<cl-icon
v-if="icon != ''"
@@ -99,7 +99,7 @@ const props = defineProps({
});
type PassThrough = {
classNames?: string;
className?: string;
icon?: PassThroughProps;
title?: PassThroughProps;
content?: PassThroughProps;

View File

@@ -1,7 +1,7 @@
import type { PassThroughProps } from "../../types";
export type ClTimelineItemPassThrough = {
classNames?: string;
className?: string;
icon?: PassThroughProps;
title?: PassThroughProps;
content?: PassThroughProps;

View File

@@ -1,5 +1,5 @@
<template>
<view class="cl-timeline" :class="[pt.classNames]">
<view class="cl-timeline" :class="[pt.className]">
<slot></slot>
</view>
</template>
@@ -20,7 +20,7 @@ const props = defineProps({
});
type PassThrough = {
classNames?: string;
className?: string;
};
const pt = computed(() => parsePt<PassThrough>(props.pt));

View File

@@ -1,5 +1,5 @@
export type ClTimelinePassThrough = {
classNames?: string;
className?: string;
};
export type ClTimelineProps = {

View File

@@ -7,16 +7,16 @@
<view
class="cl-topbar"
:class="[{ 'cl-topbar--fixed': fixed }, pt.classNames]"
:style="{
paddingTop: offsetTop,
backgroundColor
}"
:class="[{ 'cl-topbar--fixed': fixed }, pt.className]"
:style="topbarStyle"
>
<view class="cl-topbar__inner" :style="{ height }">
<view class="cl-topbar__prepend">
<view v-if="showBack" class="cl-topbar__icon" @tap="back()">
<cl-icon
:pt="{
className: pt.back?.className
}"
:name="backIcon"
:size="pt.back?.size ?? 48"
:color="pt.back?.color ?? color"
@@ -48,7 +48,7 @@
<script setup lang="ts">
import { computed, type PropType } from "vue";
import { getConfig, parseClass, parsePt, parseRpx, router } from "@/cool";
import { getConfig, getSafeAreaHeight, parseClass, parsePt, parseRpx, router } from "@/cool";
import type { PassThroughProps } from "../../types";
import type { ClIconProps } from "../cl-icon/props";
@@ -109,11 +109,9 @@ const props = defineProps({
}
});
const { safeAreaInsets } = uni.getWindowInfo();
// 定义样式透传的类型接口
type PassThrough = {
classNames?: string;
className?: string;
title?: PassThroughProps;
back?: ClIconProps;
};
@@ -124,7 +122,7 @@ const pt = computed(() => parsePt<PassThrough>(props.pt));
// 使用设备安全区域顶部边距
const offsetTop = computed(() => {
if (props.safeAreaTop) {
return safeAreaInsets.top + "px";
return getSafeAreaHeight("top") + "px";
}
return "0px";
@@ -181,6 +179,20 @@ const color = computed(() => {
return getConfig("navTxtStyle");
});
// 导航栏样式
const topbarStyle = computed(() => {
const style = {
paddingTop: offsetTop.value
};
// 不与 pt 样式中的背景色冲突
if (pt.value.className == null || !pt.value.className.includes("bg-")) {
style["backgroundColor"] = backgroundColor.value;
}
return style;
});
// 返回按钮点击事件
function back() {
if (props.backPath != "") {

View File

@@ -2,7 +2,7 @@ import type { PassThroughProps } from "../../types";
import type { ClIconProps } from "../cl-icon/props";
export type ClTopbarPassThrough = {
classNames?: string;
className?: string;
title?: PassThroughProps;
back?: ClIconProps;
};

View File

@@ -1,7 +1,7 @@
<template>
<view
class="cl-waterfall"
:class="[pt.classNames]"
:class="[pt.className]"
:style="{
padding: `0 ${props.gutter / 2}rpx`
}"
@@ -72,7 +72,7 @@ const props = defineProps({
const { proxy } = getCurrentInstance()!;
type PassThrough = {
classNames?: string;
className?: string;
};
const pt = computed(() => parsePt<PassThrough>(props.pt));

View File

@@ -1,5 +1,5 @@
export type ClWaterfallPassThrough = {
classNames?: string;
className?: string;
};
export type ClWaterfallProps = {