diff --git a/.gitignore b/.gitignore index 9e186c1..d0c8fbe 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ npm-debug.log* # Editor directories and files .project .idea +.hbuilderx *.suo *.ntvs* *.njsproj diff --git a/pages/demo/basic/button.uvue b/pages/demo/basic/button.uvue index cd996a5..e1fde5d 100644 --- a/pages/demo/basic/button.uvue +++ b/pages/demo/basic/button.uvue @@ -6,18 +6,18 @@ - + {{ t("主要") }} {{ t("成功") }} {{ t("警告") }} - + {{ t("危险") }} {{ t("信息") }} - + {{ t("浅色") }} {{ t("深色") }} diff --git a/pages/demo/data/draggable.uvue b/pages/demo/data/draggable.uvue index 1d542cc..1dccc18 100644 --- a/pages/demo/data/draggable.uvue +++ b/pages/demo/data/draggable.uvue @@ -1,6 +1,12 @@ diff --git a/types/uni-app.d.ts b/types/uni-app.d.ts index bbd74d5..758a5e4 100644 --- a/types/uni-app.d.ts +++ b/types/uni-app.d.ts @@ -446,6 +446,26 @@ declare interface UniElement { success?: (res: { tempFilePath: string }) => void; fail?: (err: { errCode: number; errMsg: string }) => void; }): void; + getDrawableContext(): DrawableContext; + animate( + keyframes: UniAnimationKeyframe | UniAnimationKeyframe[], + options?: + | { + delay?: number; + direction?: "normal" | "reverse" | "alternate" | "alternate-reverse"; + duration?: number; + easing?: + | "ease" + | "ease-in" + | "ease-out" + | "ease-in-out" + | "linear" + | "cubic-bezier"; + fill?: "backwards" | "forwards" | "both" | "none"; + iterations?: number; + } + | number + ): { id: string; playState: "running" | "paused" | "finished" | "idle" } | null; } declare interface CanvasContext extends HTMLCanvasElement { diff --git a/uni_modules/cool-svg/utssdk/app-harmony/config.json b/uni_modules/cool-svg/utssdk/app-harmony/config.json new file mode 100644 index 0000000..a26cedb --- /dev/null +++ b/uni_modules/cool-svg/utssdk/app-harmony/config.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@ohos/svg": "2.2.1" + } +} \ No newline at end of file diff --git a/uni_modules/cool-svg/utssdk/app-harmony/index.uts b/uni_modules/cool-svg/utssdk/app-harmony/index.uts new file mode 100644 index 0000000..9f3e25c --- /dev/null +++ b/uni_modules/cool-svg/utssdk/app-harmony/index.uts @@ -0,0 +1,5 @@ +import { BuilderNode } from "@kit.ArkUI"; + +export class CoolSvg { + load(src: string, color: string) {} +} diff --git a/uni_modules/cool-ui/components/cl-cropper/cl-cropper.uvue b/uni_modules/cool-ui/components/cl-cropper/cl-cropper.uvue index a2a45b6..075ab75 100644 --- a/uni_modules/cool-ui/components/cl-cropper/cl-cropper.uvue +++ b/uni_modules/cool-ui/components/cl-cropper/cl-cropper.uvue @@ -10,6 +10,7 @@ > + + 1为多列网格布局 */ columns: { type: Number, default: 1 + }, + // 是否需要长按触发 + longPress: { + type: Boolean, + default: true } }); @@ -376,12 +384,6 @@ function getItemStyle(index: number) { return style; } - // 为非拖拽元素添加过渡动画 - if (props.animation > 0 && !isCurrent) { - style["transition-property"] = "transform"; - style["transition-duration"] = `${props.animation}ms`; - } - // 拖拽状态下的样式处理 if (dragging.value) { if (isCurrent) { @@ -391,9 +393,7 @@ function getItemStyle(index: number) { } else { // 其他元素:显示排序预览位移 const translateOffset = getItemTranslateOffset(index); - if (translateOffset.x != 0 || translateOffset.y != 0) { - style["transform"] = `translate(${translateOffset.x}px, ${translateOffset.y}px)`; - } + style["transform"] = `translate(${translateOffset.x}px, ${translateOffset.y}px)`; } } @@ -513,22 +513,31 @@ function checkMovedToOtherElement(): boolean { * @param event 触摸事件对象 * @param index 触摸的项目索引 */ -async function onTouchStart(event: UniTouchEvent, index: number): Promise { +async function onTouchStart(event: UniTouchEvent, index: number, type: string) { + // 如果是长按触发,但未开启长按功能,则直接返回 + if (type == "longpress" && !props.longPress) return; + // 如果是普通触摸触发,但已开启长按功能,则直接返回 + if (type == "touch" && props.longPress) return; + // 检查是否禁用或索引无效 if (props.disabled) return; if (getItemDisabled(index)) return; if (index < 0 || index >= list.value.length) return; + // 获取触摸点 const touch = event.touches[0]; // 初始化拖拽状态 dragging.value = true; + + // 初始化拖拽索引 dragIndex.value = index; insertIndex.value = index; // 初始插入位置为原位置 startX.value = touch.clientX; startY.value = touch.clientY; offsetX.value = 0; offsetY.value = 0; + // 初始化拖拽数据项 dragItem.value = list.value[index]; // 先获取所有项目的位置信息,为后续计算做准备 @@ -536,6 +545,14 @@ async function onTouchStart(event: UniTouchEvent, index: number): Promise // 触发开始事件 emit("start", index); + + // 震动 + vibrate(1); + + // 阻止事件冒泡 + event.stopPropagation(); + // 阻止默认行为 + event.preventDefault(); } /** @@ -575,7 +592,7 @@ function onTouchMove(event: TouchEvent): void { } } - // 阻止默认行为和事件冒泡 + // 阻止默认行为 event.preventDefault(); } @@ -585,7 +602,10 @@ function onTouchMove(event: TouchEvent): void { function onTouchEnd(): void { if (!dragging.value) return; + // 旧索引 const oldIndex = dragIndex.value; + + // 新索引 const newIndex = insertIndex.value; // 如果位置发生变化,立即更新数组 @@ -604,15 +624,11 @@ function onTouchEnd(): void { dropping.value = true; dragging.value = false; - // 让拖拽元素回到自然位置(偏移归零) - offsetX.value = 0; - offsetY.value = 0; + // 重置所有状态 + reset(); // 等待放下动画完成后重置所有状态 - setTimeout(() => { - emit("end", newIndex >= 0 ? newIndex : oldIndex); - reset(); - }, 10); + emit("end", newIndex >= 0 ? newIndex : oldIndex); } /** @@ -652,21 +668,30 @@ watch( diff --git a/uni_modules/cool-ui/components/cl-input-otp/cl-input-otp.uvue b/uni_modules/cool-ui/components/cl-input-otp/cl-input-otp.uvue index d57fbf5..6378522 100644 --- a/uni_modules/cool-ui/components/cl-input-otp/cl-input-otp.uvue +++ b/uni_modules/cool-ui/components/cl-input-otp/cl-input-otp.uvue @@ -22,8 +22,6 @@ :hold-keyboard="false" :clearable="false" @change="onChange" - @focus="animateCursor(true)" - @blur="animateCursor(true)" > @@ -36,12 +34,13 @@ { 'is-disabled': disabled, 'is-dark': isDark, - 'is-active': value.length == index && isFocus + 'is-active': value.length >= index && isFocus }, pt.item?.className ]" > @@ -184,51 +180,6 @@ function onChange(val: string) { emit("done", val); } } - -/** - * 光标闪烁透明度值 - * 范围: 0.3-1.0 - */ -const cursorOpacity = ref(0.3); - -/** - * 光标闪烁动画帧ID - */ -let cursorAnimationId = 0; - -/** - * 控制光标闪烁动画 - * @param isIncreasing 透明度是否递增 - */ -function animateCursor(isIncreasing: boolean) { - // #ifdef APP - // 未获得焦点时不执行动画 - if (!isFocus.value) { - return; - } - - // 取消上一次动画 - if (cursorAnimationId != 0) { - cancelAnimationFrame(cursorAnimationId); - cursorAnimationId = 0; - } - - // 执行动画帧 - cursorAnimationId = requestAnimationFrame(() => { - // 根据方向调整透明度值 - cursorOpacity.value += isIncreasing ? 0.01 : -0.01; - - // 到达边界值时改变方向 - if (cursorOpacity.value > 1) { - animateCursor(false); - } else if (cursorOpacity.value <= 0.3) { - animateCursor(true); - } else { - animateCursor(isIncreasing); - } - }); - // #endif -}