From 1b6fc90d599a191c95e502ac155936618f051ee6 Mon Sep 17 00:00:00 2001 From: icssoa <615206459@qq.com> Date: Sun, 7 Sep 2025 11:08:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20cl-text=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E5=92=8C?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=EF=BC=8C=E5=9C=A8=20pt=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=AD=E6=97=A0=E9=9C=80=E6=B7=BB=E5=8A=A0=20!=20=E7=AC=A6?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/tabbar.uvue | 4 +- cool/utils/comm.ts | 70 ---------------- cool/utils/device.ts | 70 ++++++++++++++++ cool/utils/index.ts | 1 + cool/utils/rect.ts | 2 +- cool/utils/tailwind.ts | 28 +++++++ package.json | 2 +- pages/demo/basic/image.uvue | 28 ++++++- pages/demo/basic/text.uvue | 12 ++- pages/demo/components/item.uvue | 2 +- pages/demo/components/tips.uvue | 2 +- pages/demo/data/filter-bar.uvue | 12 +-- pages/demo/data/list.uvue | 25 +++++- pages/demo/data/pagination.uvue | 4 +- pages/demo/data/timeline.uvue | 2 +- pages/demo/data/tree.uvue | 4 +- pages/demo/data/waterfall.uvue | 2 +- pages/demo/feedback/action-sheet.uvue | 2 +- pages/demo/form/checkbox.uvue | 18 +++- pages/demo/form/form.uvue | 2 +- pages/demo/form/radio.uvue | 12 ++- pages/demo/form/select.uvue | 4 +- pages/demo/form/textarea.uvue | 2 +- pages/set/general.uvue | 11 +++ pages/template/shop/shopping-cart.uvue | 12 +-- pages/user/components/login/phone.uvue | 4 +- pages/user/components/login/wx.uvue | 2 +- pages/user/edit-name.uvue | 4 +- pages/user/login.uvue | 10 +-- .../cl-action-sheet/cl-action-sheet.uvue | 2 +- .../cool-ui/components/cl-badge/cl-badge.uvue | 2 +- .../components/cl-banner/cl-banner.uvue | 1 + .../components/cl-button/cl-button.uvue | 2 +- .../components/cl-cascader/cl-cascader.uvue | 2 +- .../components/cl-checkbox/cl-checkbox.uvue | 4 +- .../components/cl-cropper/cl-cropper.uvue | 4 +- .../cool-ui/components/cl-empty/cl-empty.uvue | 2 +- .../cl-filter-item/cl-filter-item.uvue | 2 +- .../components/cl-form-item/cl-form-item.uvue | 2 +- .../cool-ui/components/cl-icon/cl-icon.uvue | 75 ++++++++++------- .../cl-keyboard-car/cl-keyboard-car.uvue | 4 +- .../cl-keyboard-number.uvue | 10 +-- .../cl-keyboard-password.uvue | 12 +-- .../cl-pagination/cl-pagination.uvue | 39 +++++---- .../cl-picker-view/cl-picker-view.uvue | 6 +- .../cool-ui/components/cl-popup/cl-popup.uvue | 2 +- .../cool-ui/components/cl-radio/cl-radio.uvue | 4 +- .../cl-select-date/cl-select-date.uvue | 4 +- .../cl-select-trigger/cl-select-trigger.uvue | 8 +- .../cool-ui/components/cl-tabs/cl-tabs.uvue | 2 +- .../cool-ui/components/cl-tag/cl-tag.uvue | 2 +- .../cool-ui/components/cl-text/cl-text.uvue | 82 ++++++++++++------- .../components/cl-textarea/cl-textarea.uvue | 2 +- .../cl-timeline-item/cl-timeline-item.uvue | 6 +- .../cool-ui/components/cl-toast/cl-toast.uvue | 3 +- .../components/cl-topbar/cl-topbar.uvue | 2 +- .../components/cl-upload/cl-upload.uvue | 6 +- 57 files changed, 406 insertions(+), 239 deletions(-) create mode 100644 cool/utils/tailwind.ts diff --git a/components/tabbar.uvue b/components/tabbar.uvue index 3873116..7c9ce7d 100644 --- a/components/tabbar.uvue +++ b/components/tabbar.uvue @@ -23,8 +23,8 @@ v-if="item.text != null" :pt="{ className: parseClass([ - '!text-xs mt-1', - [path == item.pagePath, '!text-primary-500', '!text-surface-400'] + 'text-xs mt-1', + [path == item.pagePath, 'text-primary-500', 'text-surface-400'] ]) }" >{{ t(item.text!) }} { - // #ifdef MP - return true; - // #endif - - return false; -}; - -/** - * 检查是否为App环境 - * @returns 是否为App环境 - */ -export const isApp = (): boolean => { - // #ifdef APP - return true; - // #endif - - return false; -}; - -/** - * 检查是否为App-IOS环境 - * @returns 是否为App-IOS环境 - */ -export const isAppIOS = (): boolean => { - // #ifdef APP-IOS - return true; - // #endif - return false; -}; - -/** - * 检查是否为App-Android环境 - * @returns 是否为App-Android环境 - */ -export const isAppAndroid = (): boolean => { - // #ifdef APP-ANDROID - return true; - // #endif - return false; -}; - -/** - * 检查是否为H5环境 - * @returns 是否为H5环境 - */ -export const isH5 = (): boolean => { - // #ifdef H5 - return true; - // #endif - - return false; -}; - -/** - * 检查是否为鸿蒙环境 - * @returns 是否为鸿蒙环境 - */ -export const isHarmony = (): boolean => { - // #ifdef APP-HARMONY - return true; - // #endif - - return false; -}; diff --git a/cool/utils/device.ts b/cool/utils/device.ts index 0d51a0d..b5f73c2 100644 --- a/cool/utils/device.ts +++ b/cool/utils/device.ts @@ -1,3 +1,73 @@ +/** + * 检查是否为小程序环境 + * @returns 是否为小程序环境 + */ +export const isMp = (): boolean => { + // #ifdef MP + return true; + // #endif + + return false; +}; + +/** + * 检查是否为App环境 + * @returns 是否为App环境 + */ +export const isApp = (): boolean => { + // #ifdef APP + return true; + // #endif + + return false; +}; + +/** + * 检查是否为App-IOS环境 + * @returns 是否为App-IOS环境 + */ +export const isAppIOS = (): boolean => { + // #ifdef APP-IOS + return true; + // #endif + return false; +}; + +/** + * 检查是否为App-Android环境 + * @returns 是否为App-Android环境 + */ +export const isAppAndroid = (): boolean => { + // #ifdef APP-ANDROID + return true; + // #endif + return false; +}; + +/** + * 检查是否为H5环境 + * @returns 是否为H5环境 + */ +export const isH5 = (): boolean => { + // #ifdef H5 + return true; + // #endif + + return false; +}; + +/** + * 检查是否为鸿蒙环境 + * @returns 是否为鸿蒙环境 + */ +export const isHarmony = (): boolean => { + // #ifdef APP-HARMONY + return true; + // #endif + + return false; +}; + /** * 获取设备像素比 * @returns 设备像素比 diff --git a/cool/utils/index.ts b/cool/utils/index.ts index a1282c2..90c3e69 100644 --- a/cool/utils/index.ts +++ b/cool/utils/index.ts @@ -1,3 +1,4 @@ +export * from "./tailwind"; export * from "./comm"; export * from "./day"; export * from "./device"; diff --git a/cool/utils/rect.ts b/cool/utils/rect.ts index 8cf64d6..13aeb62 100644 --- a/cool/utils/rect.ts +++ b/cool/utils/rect.ts @@ -1,6 +1,6 @@ import { config } from "@/config"; import { router } from "../router"; -import { isH5, isHarmony } from "./comm"; +import { isH5, isHarmony } from "./device"; import { ctx } from "../ctx"; import { getPx } from "./parse"; diff --git a/cool/utils/tailwind.ts b/cool/utils/tailwind.ts new file mode 100644 index 0000000..bf47477 --- /dev/null +++ b/cool/utils/tailwind.ts @@ -0,0 +1,28 @@ +/** + * 判断 Tailwind class 字符串中是否包含文本颜色类(如 text-red, text-red-500, text-sky 等) + * @param className 传入的 class 字符串 + * @returns 是否包含文本颜色类 + */ +export function hasTextColor(className: string): boolean { + if (className == "") return false; + + const regex = + /\btext-(primary|surface|red|blue|green|yellow|purple|pink|indigo|gray|grey|black|white|orange|amber|lime|emerald|teal|cyan|sky|violet|fuchsia|rose|slate|zinc|neutral|stone)(?:-\d+)?\b/; + + return regex.test(className); +} + +/** + * 判断 Tailwind class 字符串中是否包含字体大小类 + * 支持如 text-xs, text-sm, text-base, text-lg, text-xl, 以及 text-[22px]、text-[22rpx] 等自定义写法 + * @param className 传入的 class 字符串 + * @returns 是否包含字体大小类 + */ +export function hasTextSize(className: string): boolean { + if (className == "") return false; + + const regex = + /\btext-(xs|sm|md|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl|\[\d+[a-zA-Z%]*\])\b/; + + return regex.test(className); +} diff --git a/package.json b/package.json index 9ac5cc5..3ef52b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cool-unix", - "version": "8.0.20", + "version": "8.0.21", "license": "MIT", "scripts": { "build-ui": "node ./uni_modules/cool-ui/scripts/generate-types.js", diff --git a/pages/demo/basic/image.uvue b/pages/demo/basic/image.uvue index 2b48aaa..399998d 100644 --- a/pages/demo/basic/image.uvue +++ b/pages/demo/basic/image.uvue @@ -9,22 +9,42 @@ - aspectFill + aspectFill - aspectFit + aspectFit - heightFix + heightFix - scaleToFill + scaleToFill diff --git a/pages/demo/basic/text.uvue b/pages/demo/basic/text.uvue index 0a0be4e..1e3c18e 100644 --- a/pages/demo/basic/text.uvue +++ b/pages/demo/basic/text.uvue @@ -6,7 +6,17 @@ - 云想衣裳花想容,春风拂槛露华浓。 + 明月松间照,清泉石上流。 + 举头望明月,低头思故乡。 + 春眠不觉晓,处处闻啼鸟。 + 劝君更尽一杯酒,西出阳关无故人。 + 孤帆远影碧空尽,唯见长江天际流。 + 大漠孤烟直,长河落日圆。 diff --git a/pages/demo/components/item.uvue b/pages/demo/components/item.uvue index 301df78..1ceffa2 100644 --- a/pages/demo/components/item.uvue +++ b/pages/demo/components/item.uvue @@ -1,6 +1,6 @@