From 07509a238774c62a257c46bd321a31ab1274c57e Mon Sep 17 00:00:00 2001 From: "evan.liu" <583229071@qq.com> Date: Fri, 4 Sep 2026 06:02:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BBuni-app=20x=E5=88=B0uni-app?= =?UTF-8?q?=20vue3=EF=BC=8C=E8=93=9D=E7=89=99=E5=8E=BB=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E6=8F=92=E4=BB=B6=E6=94=B9uni=E5=86=85=E7=BD=AEBLE=20?= =?UTF-8?q?API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - uni-app x官方无内置蓝牙API(文档明确见插件市场),为实现去插件化,工程整体迁移为uni-app vue3(vue/ts),App端内置完整BLE API,标准基座即可运行 - 新建src/BluetoothManager.ts:基于uni内置BLE API(createBLEConnection/notifyBLECharacteristicValueChange/writeBLECharacteristicValue(writeNoResponse)/setBLEMTU/getBLEDeviceRSSI等),保持原插件type约定,页面业务逻辑不变 - 删除uni_modules/android-ble及未使用的lime-*、uni-wifi;保留uni-icons、uni-scss - uts模块全部移植为ts(src/mcm、api、common):UTSJSONObject改Record,适配vue3 getStorageSync空值返回空串的差异 - 7个页面uvue转vue:模板不变,显式import ref与生命周期钩子;OTA固件读取由java.io改为plus.io+uni.base64ToArrayBuffer - manifest.json去uni-app-x改app-plus结构,补Android 12+蓝牙权限;删除platformConfig.json;运行改用标准基座 --- .hbuilderx/launch.json | 2 +- App.uvue => App.vue | 53 +- api/{httpInstance.uts => httpInstance.ts} | 33 +- api/{requestApi.uts => requestApi.ts} | 26 +- api/{responseData.uts => responseData.ts} | 0 common/{auth.uts => auth.ts} | 32 +- common/{bleInfo.uts => bleInfo.ts} | 14 +- ...录_2026-09-03_迁移uni-app-vue3与蓝牙去插件.md | 62 + main.uts => main.js | 4 +- manifest.json | 90 +- pages.json | 2 +- ...hOperation.uvue => bluetoothOperation.vue} | 18 +- ...splayUserInfo.uvue => displayUserInfo.vue} | 4 +- pages/login/{login.uvue => login.vue} | 8 +- .../register/{register.uvue => register.vue} | 7 +- pages/tabbar/{home.uvue => home.vue} | 18 +- pages/tabbar/{my.uvue => my.vue} | 16 +- pages/tabbar/{ota.uvue => ota.vue} | 124 +- platformConfig.json | 7 - src/BluetoothManager.ts | 439 ++ src/BluetoothManager.uts | 180 - ...commonFunctions.uts => commonFunctions.ts} | 0 src/mcm/{Crc.uts => Crc.ts} | 0 src/mcm/{FrameCodec.uts => FrameCodec.ts} | 2 +- src/mcm/{McmChannel.uts => McmChannel.ts} | 8 +- src/mcm/{McmCommands.uts => McmCommands.ts} | 4 +- src/mcm/{McmInfo.uts => McmInfo.ts} | 4 +- src/mcm/{OtaManager.uts => OtaManager.ts} | 6 +- uni_modules/android-ble/changelog.md | 170 - uni_modules/android-ble/encrypt | 1 - uni_modules/android-ble/old.md | 126 - uni_modules/android-ble/package.json | 111 - uni_modules/android-ble/readme.md | 1240 ------ .../utssdk/app-android/AndroidManifest.xml | 13 - .../utssdk/app-android/Result.java | 7 - .../app-android/com/clj/fastble/BleHelper.kt | Bin 36752 -> 0 bytes .../com/clj/fastble/BleManager.java | Bin 32880 -> 0 bytes .../app-android/com/clj/fastble/ByteUtil.java | Bin 7744 -> 0 bytes .../clj/fastble/bluetooth/BleBluetooth.java | Bin 27664 -> 0 bytes .../clj/fastble/bluetooth/BleConnector.java | Bin 27520 -> 0 bytes .../MultipleBluetoothController.java | Bin 4896 -> 0 bytes .../clj/fastble/bluetooth/SplitWriter.java | Bin 8512 -> 0 bytes .../clj/fastble/callback/BleBaseCallback.java | Bin 448 -> 0 bytes .../clj/fastble/callback/BleGattCallback.java | Bin 752 -> 0 bytes .../fastble/callback/BleIndicateCallback.java | Bin 336 -> 0 bytes .../callback/BleMtuChangedCallback.java | Bin 288 -> 0 bytes .../fastble/callback/BleNotifyCallback.java | Bin 336 -> 0 bytes .../clj/fastble/callback/BleReadCallback.java | Bin 272 -> 0 bytes .../clj/fastble/callback/BleRssiCallback.java | 3 - .../callback/BleScanAndConnectCallback.java | Bin 304 -> 0 bytes .../clj/fastble/callback/BleScanCallback.java | Bin 304 -> 0 bytes .../fastble/callback/BleScanPresenterImp.java | 2 - .../fastble/callback/BleWriteCallback.java | Bin 368 -> 0 bytes .../callback/NotificationCallback.java | Bin 368 -> 0 bytes .../data/BleConnectStateParameter.java | Bin 496 -> 0 bytes .../com/clj/fastble/data/BleDevice.java | Bin 2576 -> 0 bytes .../com/clj/fastble/data/BleMsg.java | Bin 2368 -> 0 bytes .../com/clj/fastble/data/BleScanState.java | 2 - .../com/clj/fastble/data/BleWriteState.java | 1 - .../com/clj/fastble/entity/MessageEntity.java | Bin 1600 -> 0 bytes .../clj/fastble/entity/UserInfoEntity.java | Bin 1440 -> 0 bytes .../clj/fastble/exception/BleException.java | Bin 1104 -> 0 bytes .../fastble/exception/ConnectException.java | Bin 1088 -> 0 bytes .../clj/fastble/exception/GattException.java | Bin 640 -> 0 bytes .../clj/fastble/exception/OtherException.java | Bin 208 -> 0 bytes .../fastble/exception/TimeoutException.java | 1 - .../clj/fastble/scan/BleScanPresenter.java | Bin 7360 -> 0 bytes .../clj/fastble/scan/BleScanRuleConfig.java | Bin 2384 -> 0 bytes .../com/clj/fastble/scan/BleScanner.java | Bin 5104 -> 0 bytes .../com/clj/fastble/utils/BleLog.java | Bin 672 -> 0 bytes .../com/clj/fastble/utils/BleLruHashMap.java | Bin 896 -> 0 bytes .../com/clj/fastble/utils/HexUtil.java | Bin 3632 -> 0 bytes .../utssdk/app-android/config.json | 6 - .../android-ble/utssdk/app-android/index.uts | Bin 41296 -> 0 bytes .../android-ble/utssdk/app-harmony/index.uts | Bin 50288 -> 0 bytes .../utssdk/app-harmony/module.json5 | 45 - .../resources/base/element/string.json | 24 - .../android-ble/utssdk/app-ios/bt.swift | Bin 36640 -> 0 bytes .../android-ble/utssdk/app-ios/config.json | 3 - .../android-ble/utssdk/app-ios/index.uts | Bin 34384 -> 0 bytes .../android-ble/utssdk/app-ios/info.plist | 15 - uni_modules/android-ble/utssdk/interface.uts | 110 - uni_modules/android-ble/utssdk/mp-weixin.zip | Bin 6986 -> 0 bytes .../android-ble/utssdk/mp-weixin/index.uts | Bin 28544 -> 0 bytes uni_modules/lime-color/changelog.md | 27 - uni_modules/lime-color/common/color.uts | 646 --- uni_modules/lime-color/common/conversion.uts | 307 -- .../lime-color/common/css-color-names.uts | 156 - .../lime-color/common/format-input.uts | 388 -- uni_modules/lime-color/common/generate.uts | 240 - uni_modules/lime-color/common/test.uts | 211 - uni_modules/lime-color/common/util.uts | 198 - .../components/lime-color/lime-color.vue | 10 - uni_modules/lime-color/index.ts | 5 - uni_modules/lime-color/index.uts | 6 - uni_modules/lime-color/interface.uts | 87 - uni_modules/lime-color/package.json | 108 - uni_modules/lime-color/readme - 副本.md | 557 --- uni_modules/lime-color/readme.md | 342 -- .../utssdk/app-android-o/config.json | 3 - .../lime-color/utssdk/app-android-o/index.uts | 2 - .../lime-color/utssdk/app-js-o/config.json | 3 - .../lime-color/utssdk/app-js-o/index.uts | 2 - uni_modules/lime-color/utssdk/index-o.uts | 3 - uni_modules/lime-color/utssdk/interface.uts | 93 - uni_modules/lime-color/utssdk/unierror.uts | 41 - .../lime-date-time-picker/changelog.md | 30 - .../components/l-date-time-picker/constant.ts | 56 - .../l-date-time-picker.uvue | 313 -- .../l-date-time-picker/l-date-time-picker.vue | 321 -- .../components/l-date-time-picker/props.ts | 140 - .../components/l-date-time-picker/type.ts | 67 - .../components/l-date-time-picker/utils.ts | 89 - .../lime-date-time-picker.uvue | 205 - .../lime-date-time-picker.vue | 179 - uni_modules/lime-date-time-picker/index.ts | 2 - .../lime-date-time-picker/package.json | 110 - uni_modules/lime-date-time-picker/readme.md | 234 - .../lime-date-time-picker/readme_old.md | 136 - uni_modules/lime-dayuts/changelog.md | 43 - uni_modules/lime-dayuts/common/constant.ts | 32 - uni_modules/lime-dayuts/common/dates.ts | 194 - uni_modules/lime-dayuts/common/index.ts | 1104 ----- .../lime-dayuts/common/locale/en/index.ts | 57 - .../lime-dayuts/common/locale/zh-cn/index.ts | 75 - uni_modules/lime-dayuts/common/test.ts | 110 - uni_modules/lime-dayuts/common/use.ts | 63 - uni_modules/lime-dayuts/common/utils.ts | 106 - uni_modules/lime-dayuts/index.ts | 6 - uni_modules/lime-dayuts/package.json | 107 - uni_modules/lime-dayuts/readme - 副本.md | 445 -- uni_modules/lime-dayuts/readme.md | 462 -- .../lime-dayuts/utssdk/app-js/config.json | 3 - .../lime-dayuts/utssdk/app-js/index.uts | 3 - uni_modules/lime-dayuts/utssdk/interface.uts | 405 -- uni_modules/lime-dayuts/utssdk/unierror.uts | 39 - uni_modules/lime-loading/changelog.md | 44 - .../components/l-loading/index-u.scss | 252 -- .../components/l-loading/index.scss | 246 -- .../components/l-loading/l-loading.uvue | 122 - .../components/l-loading/l-loading.vue | 79 - .../components/l-loading/props.ts | 28 - .../lime-loading/components/l-loading/type.ts | 18 - .../components/lime-loading/lime-loading.uvue | 132 - .../components/lime-loading/lime-loading.vue | 52 - uni_modules/lime-loading/index.uts | 439 -- uni_modules/lime-loading/package.json | 110 - uni_modules/lime-loading/readme.md | 114 - uni_modules/lime-picker/changelog.md | 76 - .../components/l-cascade/l-cascade.uvue | 129 - .../components/l-cascade/l-cascade.vue | 154 - .../lime-picker/components/l-cascade/type.ts | 58 - .../components/l-cascade/utils.uts | 123 - .../l-picker-item/PickerRenderer.uts | 187 - .../components/l-picker-item/index.scss | 82 - .../l-picker-item/l-picker-item-old.uvue | 324 -- .../l-picker-item/l-picker-item.uvue | 297 -- .../l-picker-item/l-picker-item.vue | 212 - .../components/l-picker-item/props.ts | 15 - .../components/l-picker-item/type.ts | 13 - .../components/l-picker-item/usePickerMask.ts | 86 - .../components/l-picker-view/index.scss | 191 - .../l-picker-view/l-picker-view.uvue | 285 -- .../l-picker-view/l-picker-view.vue | 173 - .../components/l-picker-view/props.ts | 128 - .../components/l-picker-view/type.ts | 10 - .../components/l-picker-view/usePickerView.ts | 339 -- .../components/l-picker/index.scss | 149 - .../components/l-picker/l-picker.uvue | 269 -- .../components/l-picker/l-picker.vue | 271 -- .../lime-picker/components/l-picker/props.ts | 126 - .../lime-picker/components/l-picker/type.ts | 87 - .../lime-picker/components/l-picker/utils.ts | 36 - .../components/lime-picker/lime-picker.uvue | 411 -- .../components/lime-picker/lime-picker.vue | 398 -- uni_modules/lime-picker/index.uts | 6 - uni_modules/lime-picker/package.json | 110 - uni_modules/lime-picker/readme.md | 573 --- uni_modules/lime-picker/readme_old.md | 555 --- uni_modules/lime-shared/addSeparator/index.ts | 10 - uni_modules/lime-shared/addUnit/index.ts | 41 - uni_modules/lime-shared/animation/bezier.ts | 83 - uni_modules/lime-shared/animation/ease.ts | 4 - uni_modules/lime-shared/animation/index.ts | 10 - .../lime-shared/animation/useTransition.ts | 110 - uni_modules/lime-shared/animation/uvue.ts | 119 - uni_modules/lime-shared/animation/uvue.uts | 119 - uni_modules/lime-shared/animation/vue.ts | 123 - .../lime-shared/areaData/city-china.json | 3888 ----------------- uni_modules/lime-shared/areaData/index.ts | 71 - .../lime-shared/arrayBufferToFile/index.ts | 10 - .../lime-shared/arrayBufferToFile/uvue.ts | 10 - .../lime-shared/arrayBufferToFile/uvue.uts | 10 - .../lime-shared/arrayBufferToFile/vue.ts | 63 - uni_modules/lime-shared/arrayEqual/index.ts | 13 - .../lime-shared/assignAtIndex/index.ts | 42 - .../lime-shared/base64ToArrayBuffer/index.ts | 13 - uni_modules/lime-shared/base64ToPath/index.ts | 11 - uni_modules/lime-shared/base64ToPath/uvue.ts | 22 - uni_modules/lime-shared/base64ToPath/uvue.uts | 22 - uni_modules/lime-shared/base64ToPath/vue.ts | 75 - uni_modules/lime-shared/bem/index.ts | 289 -- uni_modules/lime-shared/camelCase/index.ts | 22 - .../lime-shared/canIUseCanvas2d/index.ts | 67 - .../lime-shared/capitalizedAmount/index.ts | 111 - uni_modules/lime-shared/changelog.md | 126 - .../lime-shared/characterLimit/index.ts | 63 - uni_modules/lime-shared/clamp/index.ts | 16 - uni_modules/lime-shared/classNames/index.ts | 96 - uni_modules/lime-shared/cloneDeep/index.ts | 10 - uni_modules/lime-shared/cloneDeep/uvue.ts | 44 - uni_modules/lime-shared/cloneDeep/uvue.uts | 39 - uni_modules/lime-shared/cloneDeep/vue.ts | 103 - uni_modules/lime-shared/closest/index.ts | 22 - uni_modules/lime-shared/coalesce/index.ts | 27 - .../components/lime-shared/lime-shared.vue | 407 -- uni_modules/lime-shared/computed/index.ts | 16 - .../lime-shared/createAnimation/index.ts | 11 - .../lime-shared/createAnimation/type.ts | 25 - .../lime-shared/createAnimation/uvue.ts | 5 - .../lime-shared/createAnimation/uvue.uts | 5 - .../lime-shared/createAnimation/vue.ts | 148 - uni_modules/lime-shared/createCanvas/index.ts | 72 - .../createCanvasContextAsync/index.ts | 329 -- uni_modules/lime-shared/createImage/index.ts | 70 - uni_modules/lime-shared/cssToObj/index.ts | 50 - uni_modules/lime-shared/debounce/index.ts | 11 - uni_modules/lime-shared/debounce/uvue.ts | 36 - uni_modules/lime-shared/debounce/uvue.uts | 36 - uni_modules/lime-shared/debounce/vue.ts | 40 - uni_modules/lime-shared/dom/index.ts | 18 - uni_modules/lime-shared/exif/index.ts | 11 - uni_modules/lime-shared/exif/uvue.ts | 7 - uni_modules/lime-shared/exif/uvue.uts | 7 - uni_modules/lime-shared/exif/vue.ts | 1057 ----- uni_modules/lime-shared/fillArray/index.ts | 18 - uni_modules/lime-shared/fillZero/index.ts | 11 - .../lime-shared/findLastIndex/index.ts | 23 - uni_modules/lime-shared/floatAdd/index.ts | 27 - uni_modules/lime-shared/floatDiv/index.ts | 45 - uni_modules/lime-shared/floatMul/index.ts | 44 - uni_modules/lime-shared/floatSub/index.ts | 32 - uni_modules/lime-shared/getClassStr/index.ts | 53 - .../lime-shared/getCurrentPage/index.ts | 9 - .../lime-shared/getCurrentPage/uvue.ts | 5 - .../lime-shared/getCurrentPage/uvue.uts | 5 - uni_modules/lime-shared/getCurrentPage/vue.ts | 6 - .../lime-shared/getDeviceInfo/index.ts | 13 - .../lime-shared/getLocalFilePath/index.ts | 64 - uni_modules/lime-shared/getRect/index.ts | 136 - uni_modules/lime-shared/getRect/uvue.ts | 35 - uni_modules/lime-shared/getRect/uvue.uts | 17 - uni_modules/lime-shared/getRect/vue.ts | 130 - uni_modules/lime-shared/getStyleStr/index.ts | 54 - .../lime-shared/getWindowInfo/index.ts | 13 - uni_modules/lime-shared/guid/index.ts | 36 - uni_modules/lime-shared/hasOwn/index.ts | 9 - uni_modules/lime-shared/hasOwn/uvue.ts | 43 - uni_modules/lime-shared/hasOwn/uvue.uts | 43 - uni_modules/lime-shared/hasOwn/vue.ts | 30 - uni_modules/lime-shared/index.ts | 43 - uni_modules/lime-shared/index.uts | 0 uni_modules/lime-shared/isBase64/index.ts | 23 - uni_modules/lime-shared/isBoolean/index.ts | 25 - uni_modules/lime-shared/isBrowser/index.ts | 8 - uni_modules/lime-shared/isByteLength/index.ts | 86 - uni_modules/lime-shared/isDate/index.ts | 189 - uni_modules/lime-shared/isDef/index.ts | 23 - uni_modules/lime-shared/isEmail/index.ts | 11 - uni_modules/lime-shared/isEmpty/index.ts | 81 - uni_modules/lime-shared/isFunction/index.ts | 16 - uni_modules/lime-shared/isIP/index.ts | 64 - uni_modules/lime-shared/isNumber/index.ts | 26 - uni_modules/lime-shared/isNumeric/index.ts | 33 - uni_modules/lime-shared/isObject/index.ts | 19 - uni_modules/lime-shared/isPromise/index.ts | 22 - uni_modules/lime-shared/isRegExp/index.ts | 33 - uni_modules/lime-shared/isString/index.ts | 19 - uni_modules/lime-shared/isURL/index.ts | 198 - .../lime-shared/isValidDomain/index.ts | 90 - uni_modules/lime-shared/kebabCase/index.ts | 24 - uni_modules/lime-shared/merge/index.ts | 33 - uni_modules/lime-shared/obj2url/index.ts | 61 - uni_modules/lime-shared/objToCss/index.ts | 49 - uni_modules/lime-shared/package.json | 111 - uni_modules/lime-shared/parseStyle/index.ts | 50 - uni_modules/lime-shared/pathToBase64/index.ts | 9 - uni_modules/lime-shared/pathToBase64/uvue.ts | 17 - uni_modules/lime-shared/pathToBase64/uvue.uts | 17 - uni_modules/lime-shared/pathToBase64/vue.ts | 142 - uni_modules/lime-shared/platform/index.ts | 34 - uni_modules/lime-shared/raf/index.ts | 12 - uni_modules/lime-shared/raf/uvue.ts | 26 - uni_modules/lime-shared/raf/uvue.uts | 48 - uni_modules/lime-shared/raf/vue.ts | 32 - uni_modules/lime-shared/random/index.ts | 24 - uni_modules/lime-shared/range/index.ts | 36 - uni_modules/lime-shared/readme.md | 353 -- .../lime-shared/selectAllComponent/index.ts | 8 - .../lime-shared/selectAllComponent/uvue.ts | 39 - .../lime-shared/selectAllComponent/uvue.uts | 39 - .../lime-shared/selectAllComponent/vue.ts | 151 - .../lime-shared/selectComponent/index.ts | 7 - .../lime-shared/selectComponent/uvue.ts | 75 - .../lime-shared/selectComponent/uvue.uts | 75 - .../lime-shared/selectComponent/vue.ts | 149 - .../lime-shared/selectElement/index.ts | 277 -- uni_modules/lime-shared/shuffle/index.ts | 16 - uni_modules/lime-shared/sleep/index.ts | 44 - .../lime-shared/stringifyStyle/index.ts | 158 - uni_modules/lime-shared/throttle/index.ts | 89 - uni_modules/lime-shared/throttle/index_old.ts | 112 - uni_modules/lime-shared/toArray/index.ts | 21 - uni_modules/lime-shared/toBoolean/index.ts | 36 - uni_modules/lime-shared/toNumber/index.ts | 28 - uni_modules/lime-shared/uniqid/index.ts | 17 - uni_modules/lime-shared/unitConvert/index.ts | 94 - uni_modules/lime-shared/useVModel/index.ts | 38 - uni_modules/lime-shared/vue/index.ts | 105 - uni_modules/lime-shared/while/index.ts | 55 - uni_modules/lime-style/changelog.md | 50 - .../lime-style/color/colorPalette.scss | 236 - uni_modules/lime-style/color/colors.scss | 18 - uni_modules/lime-style/functions.scss | 11 - uni_modules/lime-style/hairline.uts | 153 - uni_modules/lime-style/index.scss | 7 - uni_modules/lime-style/index.uts | 3 - uni_modules/lime-style/mixins/bem.scss | 0 uni_modules/lime-style/mixins/create.scss | 235 - .../mixins/directionalProperty.scss | 401 -- uni_modules/lime-style/mixins/ellipsis.scss | 22 - uni_modules/lime-style/mixins/flex.scss | 20 - uni_modules/lime-style/mixins/hairline.scss | 66 - uni_modules/lime-style/mixins/platform.scss | 17 - uni_modules/lime-style/mixins/useTheme.scss | 60 - uni_modules/lime-style/mixins/utilities.scss | 7 - uni_modules/lime-style/package.json | 103 - uni_modules/lime-style/readme.md | 16 - uni_modules/lime-style/theme/dark.scss | 638 --- uni_modules/lime-style/theme/default.scss | 181 - uni_modules/lime-style/token/dark.uts | 67 - .../lime-style/token/genFontMapToken.uts | 49 - uni_modules/lime-style/token/genFontSizes.uts | 30 - uni_modules/lime-style/token/genRadius.uts | 63 - .../lime-style/token/genSizeMapToken.uts | 20 - uni_modules/lime-style/token/interface.uts | 184 - uni_modules/lime-style/token/light.uts | 66 - uni_modules/lime-style/token/shared.uts | 24 - uni_modules/lime-style/token/useThemeMode.uts | 126 - uni_modules/lime-style/token/useThemeVars.uts | 123 - uni_modules/lime-style/token/vue.ts | 13 - uni_modules/lime-style/var.scss | 64 - uni_modules/uni-wifi/changelog.md | 14 - uni_modules/uni-wifi/package.json | 147 - uni_modules/uni-wifi/readme.md | 145 - .../uni-wifi/utssdk/app-android/config.json | 3 - .../uni-wifi/utssdk/app-android/index.uts | 803 ---- .../uni-wifi/utssdk/app-ios/Info.plist | 8 - .../uni-wifi/utssdk/app-ios/UTS.entitlements | 8 - .../uni-wifi/utssdk/app-ios/config.json | 7 - uni_modules/uni-wifi/utssdk/app-ios/index.uts | 322 -- uni_modules/uni-wifi/utssdk/index.d.ts | 388 -- uni_modules/uni-wifi/utssdk/interface.uts | 444 -- uni_modules/uni-wifi/utssdk/uni.autotest.js | 35 - uni_modules/uni-wifi/utssdk/unierror.uts | 59 - 365 files changed, 736 insertions(+), 36729 deletions(-) rename App.uvue => App.vue (59%) rename api/{httpInstance.uts => httpInstance.ts} (72%) rename api/{requestApi.uts => requestApi.ts} (78%) rename api/{responseData.uts => responseData.ts} (100%) rename common/{auth.uts => auth.ts} (85%) rename common/{bleInfo.uts => bleInfo.ts} (68%) create mode 100644 docs/修改记录_2026-09-03_迁移uni-app-vue3与蓝牙去插件.md rename main.uts => main.js (79%) rename pages/bleTest/bluetoothOperation/{bluetoothOperation.uvue => bluetoothOperation.vue} (93%) rename pages/displayUserInfo/{displayUserInfo.uvue => displayUserInfo.vue} (90%) rename pages/login/{login.uvue => login.vue} (97%) rename pages/register/{register.uvue => register.vue} (97%) rename pages/tabbar/{home.uvue => home.vue} (95%) rename pages/tabbar/{my.uvue => my.vue} (96%) rename pages/tabbar/{ota.uvue => ota.vue} (77%) delete mode 100644 platformConfig.json create mode 100644 src/BluetoothManager.ts delete mode 100644 src/BluetoothManager.uts rename src/{commonFunctions.uts => commonFunctions.ts} (100%) rename src/mcm/{Crc.uts => Crc.ts} (100%) rename src/mcm/{FrameCodec.uts => FrameCodec.ts} (99%) rename src/mcm/{McmChannel.uts => McmChannel.ts} (98%) rename src/mcm/{McmCommands.uts => McmCommands.ts} (95%) rename src/mcm/{McmInfo.uts => McmInfo.ts} (96%) rename src/mcm/{OtaManager.uts => OtaManager.ts} (98%) delete mode 100644 uni_modules/android-ble/changelog.md delete mode 100644 uni_modules/android-ble/encrypt delete mode 100644 uni_modules/android-ble/old.md delete mode 100644 uni_modules/android-ble/package.json delete mode 100644 uni_modules/android-ble/readme.md delete mode 100644 uni_modules/android-ble/utssdk/app-android/AndroidManifest.xml delete mode 100644 uni_modules/android-ble/utssdk/app-android/Result.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/BleHelper.kt delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/BleManager.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/ByteUtil.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/bluetooth/BleBluetooth.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/bluetooth/BleConnector.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/bluetooth/MultipleBluetoothController.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/bluetooth/SplitWriter.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleBaseCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleGattCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleIndicateCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleMtuChangedCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleNotifyCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleReadCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleRssiCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleScanAndConnectCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleScanCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleScanPresenterImp.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/BleWriteCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/callback/NotificationCallback.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/data/BleConnectStateParameter.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/data/BleDevice.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/data/BleMsg.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/data/BleScanState.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/data/BleWriteState.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/entity/MessageEntity.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/entity/UserInfoEntity.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/exception/BleException.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/exception/ConnectException.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/exception/GattException.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/exception/OtherException.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/exception/TimeoutException.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/scan/BleScanPresenter.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/scan/BleScanRuleConfig.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/scan/BleScanner.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/utils/BleLog.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/utils/BleLruHashMap.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/com/clj/fastble/utils/HexUtil.java delete mode 100644 uni_modules/android-ble/utssdk/app-android/config.json delete mode 100644 uni_modules/android-ble/utssdk/app-android/index.uts delete mode 100644 uni_modules/android-ble/utssdk/app-harmony/index.uts delete mode 100644 uni_modules/android-ble/utssdk/app-harmony/module.json5 delete mode 100644 uni_modules/android-ble/utssdk/app-harmony/resources/base/element/string.json delete mode 100644 uni_modules/android-ble/utssdk/app-ios/bt.swift delete mode 100644 uni_modules/android-ble/utssdk/app-ios/config.json delete mode 100644 uni_modules/android-ble/utssdk/app-ios/index.uts delete mode 100644 uni_modules/android-ble/utssdk/app-ios/info.plist delete mode 100644 uni_modules/android-ble/utssdk/interface.uts delete mode 100644 uni_modules/android-ble/utssdk/mp-weixin.zip delete mode 100644 uni_modules/android-ble/utssdk/mp-weixin/index.uts delete mode 100644 uni_modules/lime-color/changelog.md delete mode 100644 uni_modules/lime-color/common/color.uts delete mode 100644 uni_modules/lime-color/common/conversion.uts delete mode 100644 uni_modules/lime-color/common/css-color-names.uts delete mode 100644 uni_modules/lime-color/common/format-input.uts delete mode 100644 uni_modules/lime-color/common/generate.uts delete mode 100644 uni_modules/lime-color/common/test.uts delete mode 100644 uni_modules/lime-color/common/util.uts delete mode 100644 uni_modules/lime-color/components/lime-color/lime-color.vue delete mode 100644 uni_modules/lime-color/index.ts delete mode 100644 uni_modules/lime-color/index.uts delete mode 100644 uni_modules/lime-color/interface.uts delete mode 100644 uni_modules/lime-color/package.json delete mode 100644 uni_modules/lime-color/readme - 副本.md delete mode 100644 uni_modules/lime-color/readme.md delete mode 100644 uni_modules/lime-color/utssdk/app-android-o/config.json delete mode 100644 uni_modules/lime-color/utssdk/app-android-o/index.uts delete mode 100644 uni_modules/lime-color/utssdk/app-js-o/config.json delete mode 100644 uni_modules/lime-color/utssdk/app-js-o/index.uts delete mode 100644 uni_modules/lime-color/utssdk/index-o.uts delete mode 100644 uni_modules/lime-color/utssdk/interface.uts delete mode 100644 uni_modules/lime-color/utssdk/unierror.uts delete mode 100644 uni_modules/lime-date-time-picker/changelog.md delete mode 100644 uni_modules/lime-date-time-picker/components/l-date-time-picker/constant.ts delete mode 100644 uni_modules/lime-date-time-picker/components/l-date-time-picker/l-date-time-picker.uvue delete mode 100644 uni_modules/lime-date-time-picker/components/l-date-time-picker/l-date-time-picker.vue delete mode 100644 uni_modules/lime-date-time-picker/components/l-date-time-picker/props.ts delete mode 100644 uni_modules/lime-date-time-picker/components/l-date-time-picker/type.ts delete mode 100644 uni_modules/lime-date-time-picker/components/l-date-time-picker/utils.ts delete mode 100644 uni_modules/lime-date-time-picker/components/lime-date-time-picker/lime-date-time-picker.uvue delete mode 100644 uni_modules/lime-date-time-picker/components/lime-date-time-picker/lime-date-time-picker.vue delete mode 100644 uni_modules/lime-date-time-picker/index.ts delete mode 100644 uni_modules/lime-date-time-picker/package.json delete mode 100644 uni_modules/lime-date-time-picker/readme.md delete mode 100644 uni_modules/lime-date-time-picker/readme_old.md delete mode 100644 uni_modules/lime-dayuts/changelog.md delete mode 100644 uni_modules/lime-dayuts/common/constant.ts delete mode 100644 uni_modules/lime-dayuts/common/dates.ts delete mode 100644 uni_modules/lime-dayuts/common/index.ts delete mode 100644 uni_modules/lime-dayuts/common/locale/en/index.ts delete mode 100644 uni_modules/lime-dayuts/common/locale/zh-cn/index.ts delete mode 100644 uni_modules/lime-dayuts/common/test.ts delete mode 100644 uni_modules/lime-dayuts/common/use.ts delete mode 100644 uni_modules/lime-dayuts/common/utils.ts delete mode 100644 uni_modules/lime-dayuts/index.ts delete mode 100644 uni_modules/lime-dayuts/package.json delete mode 100644 uni_modules/lime-dayuts/readme - 副本.md delete mode 100644 uni_modules/lime-dayuts/readme.md delete mode 100644 uni_modules/lime-dayuts/utssdk/app-js/config.json delete mode 100644 uni_modules/lime-dayuts/utssdk/app-js/index.uts delete mode 100644 uni_modules/lime-dayuts/utssdk/interface.uts delete mode 100644 uni_modules/lime-dayuts/utssdk/unierror.uts delete mode 100644 uni_modules/lime-loading/changelog.md delete mode 100644 uni_modules/lime-loading/components/l-loading/index-u.scss delete mode 100644 uni_modules/lime-loading/components/l-loading/index.scss delete mode 100644 uni_modules/lime-loading/components/l-loading/l-loading.uvue delete mode 100644 uni_modules/lime-loading/components/l-loading/l-loading.vue delete mode 100644 uni_modules/lime-loading/components/l-loading/props.ts delete mode 100644 uni_modules/lime-loading/components/l-loading/type.ts delete mode 100644 uni_modules/lime-loading/components/lime-loading/lime-loading.uvue delete mode 100644 uni_modules/lime-loading/components/lime-loading/lime-loading.vue delete mode 100644 uni_modules/lime-loading/index.uts delete mode 100644 uni_modules/lime-loading/package.json delete mode 100644 uni_modules/lime-loading/readme.md delete mode 100644 uni_modules/lime-picker/changelog.md delete mode 100644 uni_modules/lime-picker/components/l-cascade/l-cascade.uvue delete mode 100644 uni_modules/lime-picker/components/l-cascade/l-cascade.vue delete mode 100644 uni_modules/lime-picker/components/l-cascade/type.ts delete mode 100644 uni_modules/lime-picker/components/l-cascade/utils.uts delete mode 100644 uni_modules/lime-picker/components/l-picker-item/PickerRenderer.uts delete mode 100644 uni_modules/lime-picker/components/l-picker-item/index.scss delete mode 100644 uni_modules/lime-picker/components/l-picker-item/l-picker-item-old.uvue delete mode 100644 uni_modules/lime-picker/components/l-picker-item/l-picker-item.uvue delete mode 100644 uni_modules/lime-picker/components/l-picker-item/l-picker-item.vue delete mode 100644 uni_modules/lime-picker/components/l-picker-item/props.ts delete mode 100644 uni_modules/lime-picker/components/l-picker-item/type.ts delete mode 100644 uni_modules/lime-picker/components/l-picker-item/usePickerMask.ts delete mode 100644 uni_modules/lime-picker/components/l-picker-view/index.scss delete mode 100644 uni_modules/lime-picker/components/l-picker-view/l-picker-view.uvue delete mode 100644 uni_modules/lime-picker/components/l-picker-view/l-picker-view.vue delete mode 100644 uni_modules/lime-picker/components/l-picker-view/props.ts delete mode 100644 uni_modules/lime-picker/components/l-picker-view/type.ts delete mode 100644 uni_modules/lime-picker/components/l-picker-view/usePickerView.ts delete mode 100644 uni_modules/lime-picker/components/l-picker/index.scss delete mode 100644 uni_modules/lime-picker/components/l-picker/l-picker.uvue delete mode 100644 uni_modules/lime-picker/components/l-picker/l-picker.vue delete mode 100644 uni_modules/lime-picker/components/l-picker/props.ts delete mode 100644 uni_modules/lime-picker/components/l-picker/type.ts delete mode 100644 uni_modules/lime-picker/components/l-picker/utils.ts delete mode 100644 uni_modules/lime-picker/components/lime-picker/lime-picker.uvue delete mode 100644 uni_modules/lime-picker/components/lime-picker/lime-picker.vue delete mode 100644 uni_modules/lime-picker/index.uts delete mode 100644 uni_modules/lime-picker/package.json delete mode 100644 uni_modules/lime-picker/readme.md delete mode 100644 uni_modules/lime-picker/readme_old.md delete mode 100644 uni_modules/lime-shared/addSeparator/index.ts delete mode 100644 uni_modules/lime-shared/addUnit/index.ts delete mode 100644 uni_modules/lime-shared/animation/bezier.ts delete mode 100644 uni_modules/lime-shared/animation/ease.ts delete mode 100644 uni_modules/lime-shared/animation/index.ts delete mode 100644 uni_modules/lime-shared/animation/useTransition.ts delete mode 100644 uni_modules/lime-shared/animation/uvue.ts delete mode 100644 uni_modules/lime-shared/animation/uvue.uts delete mode 100644 uni_modules/lime-shared/animation/vue.ts delete mode 100644 uni_modules/lime-shared/areaData/city-china.json delete mode 100644 uni_modules/lime-shared/areaData/index.ts delete mode 100644 uni_modules/lime-shared/arrayBufferToFile/index.ts delete mode 100644 uni_modules/lime-shared/arrayBufferToFile/uvue.ts delete mode 100644 uni_modules/lime-shared/arrayBufferToFile/uvue.uts delete mode 100644 uni_modules/lime-shared/arrayBufferToFile/vue.ts delete mode 100644 uni_modules/lime-shared/arrayEqual/index.ts delete mode 100644 uni_modules/lime-shared/assignAtIndex/index.ts delete mode 100644 uni_modules/lime-shared/base64ToArrayBuffer/index.ts delete mode 100644 uni_modules/lime-shared/base64ToPath/index.ts delete mode 100644 uni_modules/lime-shared/base64ToPath/uvue.ts delete mode 100644 uni_modules/lime-shared/base64ToPath/uvue.uts delete mode 100644 uni_modules/lime-shared/base64ToPath/vue.ts delete mode 100644 uni_modules/lime-shared/bem/index.ts delete mode 100644 uni_modules/lime-shared/camelCase/index.ts delete mode 100644 uni_modules/lime-shared/canIUseCanvas2d/index.ts delete mode 100644 uni_modules/lime-shared/capitalizedAmount/index.ts delete mode 100644 uni_modules/lime-shared/changelog.md delete mode 100644 uni_modules/lime-shared/characterLimit/index.ts delete mode 100644 uni_modules/lime-shared/clamp/index.ts delete mode 100644 uni_modules/lime-shared/classNames/index.ts delete mode 100644 uni_modules/lime-shared/cloneDeep/index.ts delete mode 100644 uni_modules/lime-shared/cloneDeep/uvue.ts delete mode 100644 uni_modules/lime-shared/cloneDeep/uvue.uts delete mode 100644 uni_modules/lime-shared/cloneDeep/vue.ts delete mode 100644 uni_modules/lime-shared/closest/index.ts delete mode 100644 uni_modules/lime-shared/coalesce/index.ts delete mode 100644 uni_modules/lime-shared/components/lime-shared/lime-shared.vue delete mode 100644 uni_modules/lime-shared/computed/index.ts delete mode 100644 uni_modules/lime-shared/createAnimation/index.ts delete mode 100644 uni_modules/lime-shared/createAnimation/type.ts delete mode 100644 uni_modules/lime-shared/createAnimation/uvue.ts delete mode 100644 uni_modules/lime-shared/createAnimation/uvue.uts delete mode 100644 uni_modules/lime-shared/createAnimation/vue.ts delete mode 100644 uni_modules/lime-shared/createCanvas/index.ts delete mode 100644 uni_modules/lime-shared/createCanvasContextAsync/index.ts delete mode 100644 uni_modules/lime-shared/createImage/index.ts delete mode 100644 uni_modules/lime-shared/cssToObj/index.ts delete mode 100644 uni_modules/lime-shared/debounce/index.ts delete mode 100644 uni_modules/lime-shared/debounce/uvue.ts delete mode 100644 uni_modules/lime-shared/debounce/uvue.uts delete mode 100644 uni_modules/lime-shared/debounce/vue.ts delete mode 100644 uni_modules/lime-shared/dom/index.ts delete mode 100644 uni_modules/lime-shared/exif/index.ts delete mode 100644 uni_modules/lime-shared/exif/uvue.ts delete mode 100644 uni_modules/lime-shared/exif/uvue.uts delete mode 100644 uni_modules/lime-shared/exif/vue.ts delete mode 100644 uni_modules/lime-shared/fillArray/index.ts delete mode 100644 uni_modules/lime-shared/fillZero/index.ts delete mode 100644 uni_modules/lime-shared/findLastIndex/index.ts delete mode 100644 uni_modules/lime-shared/floatAdd/index.ts delete mode 100644 uni_modules/lime-shared/floatDiv/index.ts delete mode 100644 uni_modules/lime-shared/floatMul/index.ts delete mode 100644 uni_modules/lime-shared/floatSub/index.ts delete mode 100644 uni_modules/lime-shared/getClassStr/index.ts delete mode 100644 uni_modules/lime-shared/getCurrentPage/index.ts delete mode 100644 uni_modules/lime-shared/getCurrentPage/uvue.ts delete mode 100644 uni_modules/lime-shared/getCurrentPage/uvue.uts delete mode 100644 uni_modules/lime-shared/getCurrentPage/vue.ts delete mode 100644 uni_modules/lime-shared/getDeviceInfo/index.ts delete mode 100644 uni_modules/lime-shared/getLocalFilePath/index.ts delete mode 100644 uni_modules/lime-shared/getRect/index.ts delete mode 100644 uni_modules/lime-shared/getRect/uvue.ts delete mode 100644 uni_modules/lime-shared/getRect/uvue.uts delete mode 100644 uni_modules/lime-shared/getRect/vue.ts delete mode 100644 uni_modules/lime-shared/getStyleStr/index.ts delete mode 100644 uni_modules/lime-shared/getWindowInfo/index.ts delete mode 100644 uni_modules/lime-shared/guid/index.ts delete mode 100644 uni_modules/lime-shared/hasOwn/index.ts delete mode 100644 uni_modules/lime-shared/hasOwn/uvue.ts delete mode 100644 uni_modules/lime-shared/hasOwn/uvue.uts delete mode 100644 uni_modules/lime-shared/hasOwn/vue.ts delete mode 100644 uni_modules/lime-shared/index.ts delete mode 100644 uni_modules/lime-shared/index.uts delete mode 100644 uni_modules/lime-shared/isBase64/index.ts delete mode 100644 uni_modules/lime-shared/isBoolean/index.ts delete mode 100644 uni_modules/lime-shared/isBrowser/index.ts delete mode 100644 uni_modules/lime-shared/isByteLength/index.ts delete mode 100644 uni_modules/lime-shared/isDate/index.ts delete mode 100644 uni_modules/lime-shared/isDef/index.ts delete mode 100644 uni_modules/lime-shared/isEmail/index.ts delete mode 100644 uni_modules/lime-shared/isEmpty/index.ts delete mode 100644 uni_modules/lime-shared/isFunction/index.ts delete mode 100644 uni_modules/lime-shared/isIP/index.ts delete mode 100644 uni_modules/lime-shared/isNumber/index.ts delete mode 100644 uni_modules/lime-shared/isNumeric/index.ts delete mode 100644 uni_modules/lime-shared/isObject/index.ts delete mode 100644 uni_modules/lime-shared/isPromise/index.ts delete mode 100644 uni_modules/lime-shared/isRegExp/index.ts delete mode 100644 uni_modules/lime-shared/isString/index.ts delete mode 100644 uni_modules/lime-shared/isURL/index.ts delete mode 100644 uni_modules/lime-shared/isValidDomain/index.ts delete mode 100644 uni_modules/lime-shared/kebabCase/index.ts delete mode 100644 uni_modules/lime-shared/merge/index.ts delete mode 100644 uni_modules/lime-shared/obj2url/index.ts delete mode 100644 uni_modules/lime-shared/objToCss/index.ts delete mode 100644 uni_modules/lime-shared/package.json delete mode 100644 uni_modules/lime-shared/parseStyle/index.ts delete mode 100644 uni_modules/lime-shared/pathToBase64/index.ts delete mode 100644 uni_modules/lime-shared/pathToBase64/uvue.ts delete mode 100644 uni_modules/lime-shared/pathToBase64/uvue.uts delete mode 100644 uni_modules/lime-shared/pathToBase64/vue.ts delete mode 100644 uni_modules/lime-shared/platform/index.ts delete mode 100644 uni_modules/lime-shared/raf/index.ts delete mode 100644 uni_modules/lime-shared/raf/uvue.ts delete mode 100644 uni_modules/lime-shared/raf/uvue.uts delete mode 100644 uni_modules/lime-shared/raf/vue.ts delete mode 100644 uni_modules/lime-shared/random/index.ts delete mode 100644 uni_modules/lime-shared/range/index.ts delete mode 100644 uni_modules/lime-shared/readme.md delete mode 100644 uni_modules/lime-shared/selectAllComponent/index.ts delete mode 100644 uni_modules/lime-shared/selectAllComponent/uvue.ts delete mode 100644 uni_modules/lime-shared/selectAllComponent/uvue.uts delete mode 100644 uni_modules/lime-shared/selectAllComponent/vue.ts delete mode 100644 uni_modules/lime-shared/selectComponent/index.ts delete mode 100644 uni_modules/lime-shared/selectComponent/uvue.ts delete mode 100644 uni_modules/lime-shared/selectComponent/uvue.uts delete mode 100644 uni_modules/lime-shared/selectComponent/vue.ts delete mode 100644 uni_modules/lime-shared/selectElement/index.ts delete mode 100644 uni_modules/lime-shared/shuffle/index.ts delete mode 100644 uni_modules/lime-shared/sleep/index.ts delete mode 100644 uni_modules/lime-shared/stringifyStyle/index.ts delete mode 100644 uni_modules/lime-shared/throttle/index.ts delete mode 100644 uni_modules/lime-shared/throttle/index_old.ts delete mode 100644 uni_modules/lime-shared/toArray/index.ts delete mode 100644 uni_modules/lime-shared/toBoolean/index.ts delete mode 100644 uni_modules/lime-shared/toNumber/index.ts delete mode 100644 uni_modules/lime-shared/uniqid/index.ts delete mode 100644 uni_modules/lime-shared/unitConvert/index.ts delete mode 100644 uni_modules/lime-shared/useVModel/index.ts delete mode 100644 uni_modules/lime-shared/vue/index.ts delete mode 100644 uni_modules/lime-shared/while/index.ts delete mode 100644 uni_modules/lime-style/changelog.md delete mode 100644 uni_modules/lime-style/color/colorPalette.scss delete mode 100644 uni_modules/lime-style/color/colors.scss delete mode 100644 uni_modules/lime-style/functions.scss delete mode 100644 uni_modules/lime-style/hairline.uts delete mode 100644 uni_modules/lime-style/index.scss delete mode 100644 uni_modules/lime-style/index.uts delete mode 100644 uni_modules/lime-style/mixins/bem.scss delete mode 100644 uni_modules/lime-style/mixins/create.scss delete mode 100644 uni_modules/lime-style/mixins/directionalProperty.scss delete mode 100644 uni_modules/lime-style/mixins/ellipsis.scss delete mode 100644 uni_modules/lime-style/mixins/flex.scss delete mode 100644 uni_modules/lime-style/mixins/hairline.scss delete mode 100644 uni_modules/lime-style/mixins/platform.scss delete mode 100644 uni_modules/lime-style/mixins/useTheme.scss delete mode 100644 uni_modules/lime-style/mixins/utilities.scss delete mode 100644 uni_modules/lime-style/package.json delete mode 100644 uni_modules/lime-style/readme.md delete mode 100644 uni_modules/lime-style/theme/dark.scss delete mode 100644 uni_modules/lime-style/theme/default.scss delete mode 100644 uni_modules/lime-style/token/dark.uts delete mode 100644 uni_modules/lime-style/token/genFontMapToken.uts delete mode 100644 uni_modules/lime-style/token/genFontSizes.uts delete mode 100644 uni_modules/lime-style/token/genRadius.uts delete mode 100644 uni_modules/lime-style/token/genSizeMapToken.uts delete mode 100644 uni_modules/lime-style/token/interface.uts delete mode 100644 uni_modules/lime-style/token/light.uts delete mode 100644 uni_modules/lime-style/token/shared.uts delete mode 100644 uni_modules/lime-style/token/useThemeMode.uts delete mode 100644 uni_modules/lime-style/token/useThemeVars.uts delete mode 100644 uni_modules/lime-style/token/vue.ts delete mode 100644 uni_modules/lime-style/var.scss delete mode 100644 uni_modules/uni-wifi/changelog.md delete mode 100644 uni_modules/uni-wifi/package.json delete mode 100644 uni_modules/uni-wifi/readme.md delete mode 100644 uni_modules/uni-wifi/utssdk/app-android/config.json delete mode 100644 uni_modules/uni-wifi/utssdk/app-android/index.uts delete mode 100644 uni_modules/uni-wifi/utssdk/app-ios/Info.plist delete mode 100644 uni_modules/uni-wifi/utssdk/app-ios/UTS.entitlements delete mode 100644 uni_modules/uni-wifi/utssdk/app-ios/config.json delete mode 100644 uni_modules/uni-wifi/utssdk/app-ios/index.uts delete mode 100644 uni_modules/uni-wifi/utssdk/index.d.ts delete mode 100644 uni_modules/uni-wifi/utssdk/interface.uts delete mode 100644 uni_modules/uni-wifi/utssdk/uni.autotest.js delete mode 100644 uni_modules/uni-wifi/utssdk/unierror.uts diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index 7bdd7d6..559d13f 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -3,7 +3,7 @@ "configurations" : [ { "customPlaygroundType" : "local", - "playground" : "custom", + "playground" : "standard", "type" : "uni-app:app-android" }, { diff --git a/App.uvue b/App.vue similarity index 59% rename from App.uvue rename to App.vue index 689a41b..03e555a 100644 --- a/App.uvue +++ b/App.vue @@ -1,47 +1,40 @@ - @@ -97,4 +90,4 @@ import * as McmChannel from "@/src/mcm/McmChannel.uts" .uni-column { flex-direction: column; } - \ No newline at end of file + diff --git a/api/httpInstance.uts b/api/httpInstance.ts similarity index 72% rename from api/httpInstance.uts rename to api/httpInstance.ts index 52d39b9..8b5b209 100644 --- a/api/httpInstance.uts +++ b/api/httpInstance.ts @@ -1,6 +1,9 @@ import { getToken } from "../common/auth" import { clearAllData } from "../common/auth" +// 通用 JSON 对象类型(替代 uts 的 UTSJSONObject) +export type JSONObject = Record + // 可选后台服务器列表 export type ServerItem = { name: string @@ -17,10 +20,10 @@ let recordBaseUrl: string | null = null // 读取当前后台服务器地址(内存 + 本地),未选择过则默认第一个 export function getBaseUrl(): string { - if (recordBaseUrl != null && (recordBaseUrl as string).length > 0) { - return recordBaseUrl as string + if (recordBaseUrl != null && recordBaseUrl.length > 0) { + return recordBaseUrl } - const t = uni.getStorageSync('serverBaseUrl') as string | null + const t = uni.getStorageSync('serverBaseUrl') as string if (t != null && t.length > 0) { recordBaseUrl = t return t @@ -41,33 +44,29 @@ export type HttpRequest = { url: string method?: HttpMethod data?: any - header?: UTSJSONObject // 这里用 UTSJSONObject + header?: JSONObject } // 封装请求 -export function $http(params: HttpRequest): Promise { +export function $http(params: HttpRequest): Promise { return new Promise((resolve, reject) => { // 1. 准备 header - let baseHeader: UTSJSONObject = params.header ?? {} as UTSJSONObject - + let baseHeader: JSONObject = params.header ?? {} as JSONObject + baseHeader["Content-Type"] = "application/json" - + // 2. 读 token,有就加 Authorization const token = getToken() if (token != null && token.length > 0) { baseHeader["Authorization"] = token } - // console.log("url = ", getBaseUrl() + params.url) - // console.log("method = ", params.method) - // console.log("data = ", params.data) - // console.log("header = ", baseHeader) // 3. 发请求 uni.request({ url: getBaseUrl() + params.url, method: params.method ?? "GET", - data: params.data ?? {} as UTSJSONObject, + data: params.data ?? {} as JSONObject, header: baseHeader, success: (res) => { if(res.statusCode == 401) { @@ -76,10 +75,10 @@ export function $http(params: HttpRequest): Promise { url: '/pages/login/login' }) } - const result: UTSJSONObject = { + const result: JSONObject = { statusCode: res.statusCode, - data: res.data - } as UTSJSONObject + data: res.data + } as JSONObject resolve(result) }, fail: (err) => { @@ -87,4 +86,4 @@ export function $http(params: HttpRequest): Promise { } }) }) -} \ No newline at end of file +} diff --git a/api/requestApi.uts b/api/requestApi.ts similarity index 78% rename from api/requestApi.uts rename to api/requestApi.ts index 2a10dad..2940d37 100644 --- a/api/requestApi.uts +++ b/api/requestApi.ts @@ -1,4 +1,4 @@ -import { $http } from "@/api/httpInstance.uts" +import { $http, JSONObject } from "@/api/httpInstance" export type RegisteredUserReq = { userName: string, @@ -6,12 +6,12 @@ export type RegisteredUserReq = { rndcode: string } // 获取pinCode -export async function GetPindCodeReqApi(params: RegisteredUserReq): Promise{ - const body: UTSJSONObject = { +export async function GetPindCodeReqApi(params: RegisteredUserReq): Promise{ + const body: JSONObject = { userName: params.userName, userPassword: params.userPassword, rndcode: params.rndcode - } as UTSJSONObject + } as JSONObject const res = await $http({ url: "/ocpp-mtapp-api/api/v1/users/getPinCode", @@ -22,12 +22,12 @@ export async function GetPindCodeReqApi(params: RegisteredUserReq): Promise{ - const body: UTSJSONObject = { +export async function RegisteredUserReqApi(params: RegisteredUserReq): Promise{ + const body: JSONObject = { userName: params.userName, userPassword: params.userPassword, rndcode: params.rndcode - } as UTSJSONObject + } as JSONObject const res = await $http({ url: "/ocpp-mtapp-api/api/v1/users/add", @@ -42,12 +42,12 @@ export type LoginReq = { password: string } // 登录请求 -export async function LoginReqApi(params: LoginReq): Promise{ - const body: UTSJSONObject = { +export async function LoginReqApi(params: LoginReq): Promise{ + const body: JSONObject = { username: params.username, password: params.password, expirationTime: 0 - } as UTSJSONObject + } as JSONObject const res = await $http({ url: "/ocpp-mtapp-api/api/v1/auth/login", @@ -64,12 +64,12 @@ export type ModifyUserInfoReq = { nickName?: string | null } // 修改用户信息 -export async function ModifyUserInfoReqApi(params: ModifyUserInfoReq): Promise{ - const body: UTSJSONObject = { +export async function ModifyUserInfoReqApi(params: ModifyUserInfoReq): Promise{ + const body: JSONObject = { name: params.name, phone: params.phone, password: params.password - } as UTSJSONObject + } as JSONObject const res = await $http({ url: `/ocpp-mtapp-api/api/v1/users/${params.name}`, diff --git a/api/responseData.uts b/api/responseData.ts similarity index 100% rename from api/responseData.uts rename to api/responseData.ts diff --git a/common/auth.uts b/common/auth.ts similarity index 85% rename from common/auth.uts rename to common/auth.ts index a31b38d..9b7a3b1 100644 --- a/common/auth.uts +++ b/common/auth.ts @@ -2,6 +2,12 @@ let recordToken: string | null = null let recordUserName: string | null = null let recordCharging: string | null = null +// 读取本地存储字符串;vue3 的 getStorageSync 无 key 时返回 "",统一转成 null +function getStorageStr(key: string): string | null { + const t = uni.getStorageSync(key) as string + return (t != null && t.length > 0) ? t : null +} + // 保存 token(内存 + 本地) export function setToken(token: string) { recordToken = token @@ -13,8 +19,7 @@ export function getToken(): string | null { if (recordToken != null) { return recordToken } - const t = uni.getStorageSync('loginToken') as string | null - recordToken = t ?? null + recordToken = getStorageStr('loginToken') return recordToken } @@ -26,7 +31,7 @@ export function clearAllData() { uni.removeStorageSync('loginToken') uni.removeStorageSync('loginUserName') uni.removeStorageSync('ChargingFlag') - + } export function checkToken(): boolean { @@ -49,8 +54,7 @@ export function getUserName(): string | null { if (recordUserName != null) { return recordUserName } - const t = uni.getStorageSync('loginUserName') as string | null - recordUserName = t ?? null + recordUserName = getStorageStr('loginUserName') return recordUserName } @@ -66,8 +70,7 @@ export function getCharging(): string | null { if (recordCharging != null) { return recordCharging } - const t = uni.getStorageSync('ChargingFlag') as string | null - recordCharging = t ?? null + recordCharging = getStorageStr('ChargingFlag') return recordCharging } @@ -85,14 +88,12 @@ export function setSavedAccount(account: string, password: string) { // 读取保存的账号 export function getSavedAccount(): string { - const t = uni.getStorageSync('savedAccount') as string | null - return t ?? "" + return getStorageStr('savedAccount') ?? "" } // 读取保存的密码 export function getSavedPassword(): string { - const t = uni.getStorageSync('savedPassword') as string | null - return t ?? "" + return getStorageStr('savedPassword') ?? "" } // 清除保存的账号密码 @@ -112,12 +113,12 @@ const ACCOUNT_HISTORY_MAX = 5 // 读取历史账号(最新登录的在前) export function getAccountHistory(): AccountRecord[] { const result: AccountRecord[] = [] - const raw = uni.getStorageSync('accountHistory') as string | null - if (raw == null || raw.length == 0) { + const raw = getStorageStr('accountHistory') + if (raw == null) { return result } try { - const arr = JSON.parse(raw) as UTSJSONObject[] | null + const arr = JSON.parse(raw) as Record[] | null if (arr == null) return result for (let i = 0; i < arr.length; i++) { const obj = arr[i] @@ -128,7 +129,7 @@ export function getAccountHistory(): AccountRecord[] { result.push(rec) } } - } catch (e: any) { + } catch (e) { console.log('parse accountHistory error = ', e) } return result @@ -161,4 +162,3 @@ export function removeAccountHistory(account: string) { } uni.setStorageSync('accountHistory', JSON.stringify(list)) } - diff --git a/common/bleInfo.uts b/common/bleInfo.ts similarity index 68% rename from common/bleInfo.uts rename to common/bleInfo.ts index f58fc2a..3870ce1 100644 --- a/common/bleInfo.uts +++ b/common/bleInfo.ts @@ -1,6 +1,12 @@ let bleName: string | null = null let bleMac: string | null = null +// 读取本地存储字符串;vue3 的 getStorageSync 无 key 时返回 "",统一转成 null +function getStorageStr(key: string): string | null { + const t = uni.getStorageSync(key) as string + return (t != null && t.length > 0) ? t : null +} + // 保存蓝牙名字 export function setName(name: string) { bleName = name @@ -12,8 +18,7 @@ export function getName(): string | null { if (bleName != null) { return bleName } - const t = uni.getStorageSync('bleName') as string | null - bleName = t ?? null + bleName = getStorageStr('bleName') return bleName } @@ -28,8 +33,7 @@ export function getMac(): string | null { if (bleMac != null) { return bleMac } - const t = uni.getStorageSync('bleMac') as string | null - bleMac = t ?? null + bleMac = getStorageStr('bleMac') return bleMac } @@ -38,4 +42,4 @@ export function clearAllData() { bleMac = null uni.removeStorageSync('bleName') uni.removeStorageSync('bleMac') -} \ No newline at end of file +} diff --git a/docs/修改记录_2026-09-03_迁移uni-app-vue3与蓝牙去插件.md b/docs/修改记录_2026-09-03_迁移uni-app-vue3与蓝牙去插件.md new file mode 100644 index 0000000..78446c9 --- /dev/null +++ b/docs/修改记录_2026-09-03_迁移uni-app-vue3与蓝牙去插件.md @@ -0,0 +1,62 @@ +# 修改记录 2026-09-03:迁移 uni-app vue3,蓝牙去第三方插件改 uni 内置 API + +## 背景 + +- 原工程为 uni-app x(uvue/uts),蓝牙依赖第三方插件 `uni_modules/android-ble`。 +- 先尝试过"uni-app x 下去插件改 uni 内置 BLE API":不可行——uni-app x 官方未内置 + 蓝牙 API(官方文档明确"蓝牙:见插件市场"),全量编译确认 + `createBLEConnection` 等接口在 app-android 平台不存在。 +- 因对渲染性能要求不高,改为**整体迁移到 uni-app vue3(vue/ts)**: + vue3 App 端内置完整 BLE API,蓝牙彻底去插件化;且标准基座即可运行,无需自定义基座。 + +## 工程骨架 + +- `main.uts` → `main.js`;`App.uvue` → `App.vue`(`onLastPageBackPress` 中 + `uni.exit()` 改 `plus.runtime.quit()`;globalData 保留 `setBleNotity`/`ConnectBle`, + 改走新 `src/BluetoothManager.ts`,流程不变:connect → scanServices → 订阅 notify)。 +- `manifest.json`:删除 `"uni-app-x": {}`;`app-android`/`app-ios` 合并为 vue3 的 + `app-plus` 结构;Android permissions 补 `BLUETOOTH`/`BLUETOOTH_ADMIN`/ + `BLUETOOTH_SCAN`(neverForLocation)/`BLUETOOTH_CONNECT`;iOS 蓝牙隐私描述并入 + `app-plus.distribute.ios.privacyDescription`。 +- `pages.json` 内容不变(globalStyle 标题改为 smartAssister)。 +- 删除 `platformConfig.json`(uni-app x 专用)。 +- uni_modules:删除 `android-ble`、`lime-*`(8 个,页面未使用且为 uts 组件)、 + `uni-wifi`(未使用);保留 `uni-icons`(自带 vue 版本组件)、`uni-scss`。 + +## 蓝牙:`src/BluetoothManager.ts`(替代插件) + +- 基于 uni 内置 BLE API:`openBluetoothAdapter` / `startBluetoothDevicesDiscovery` / + `createBLEConnection` / `getBLEDeviceServices` / `getBLEDeviceCharacteristics` / + `notifyBLECharacteristicValueChange` / `writeBLECharacteristicValue` / + `setBLEMTU` / `getBLEDeviceRSSI` / `closeBLEConnection`。 +- 保持原插件的对外约定:`MyApiResult.type==0` 成功;1000=订阅成功 1001=订阅失败; + 10000=连接失败 10001=已断开 10002=蓝牙未开 10003=无权限; + notify 数据包装为 `{type:0, data:{data:number[], mac}}` 经 `uni.$emit("bleData")` 分发; + 意外断开经 `uni.$emit("bleState", 10001)` 广播(主动断开不广播)。 +- `sendDataBytes` 用 `writeType:"writeNoResponse"`(下行特征仅支持无响应写)。 +- 自动重连未实现(业务恒传 false),`setBtAutoConnectTime`/`cancelAutoConnectBt` 为空实现。 + +## uts → ts 移植 + +- `src/commonFunctions`、`src/mcm/*`(Crc/FrameCodec/McmChannel/McmCommands/McmInfo/ + OtaManager)、`api/*`、`common/*`:机械移植,去 `.uts` import 后缀; + `UTSJSONObject` → `Record`(httpInstance 统一定义 `JSONObject`)。 +- **vue3 的 `uni.getStorageSync` 无 key 返回 `""` 而非 null**:`common/auth.ts`、 + `common/bleInfo.ts` 统一经 `getStorageStr()` 读取(空串转 null)。 + +## 页面 .uvue → .vue(7 个) + +- template 不动;`script setup lang="ts"`;显式 `import { ref } from 'vue'`、 + 生命周期钩子 `import { onLoad, onShow, ... } from '@dcloudio/uni-app'`。 +- `pages/tabbar/ota.vue` 固件读取由 java.io 改为 `plus.io`(FileReader.readAsDataURL → + base64 → `uni.base64ToArrayBuffer` → number[]),`#ifdef APP-PLUS` 包裹。 +- `getApp().globalData.ConnectBle` 调用处加 `as any` 断言。 + +## 验证与注意事项 + +- HBuilderX CLI `launch app-android --compile true` 编译通过(编译器识别为 vue3 工程)。 +- 运行用**标准基座**即可(vue3 基座内置 BLE);原自定义基座配置不再适用。 +- 真机回归重点:扫描/连接/notify/MTU 247、home 轮询与设备信息、CLI 收发与 rssi、 + **OTA 全流程**(高频无响应写,丢包风险最高)。 +- OTA 固件路径 `/sdcard/Download/embeddedSrc.bin` 在 Android 11+ 分区存储下可能读不到 + (与原 java.io 行为一致,未劣化);如不可用,改用应用私有目录或加文件选择器。 diff --git a/main.uts b/main.js similarity index 79% rename from main.uts rename to main.js index 8bdcc86..c32858f 100644 --- a/main.uts +++ b/main.js @@ -1,4 +1,4 @@ -import App from './App.uvue' +import App from './App.vue' import { createSSRApp } from 'vue' export function createApp() { @@ -6,4 +6,4 @@ export function createApp() { return { app } -} \ No newline at end of file +} diff --git a/manifest.json b/manifest.json index 9310805..e4a6d4a 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,6 @@ "description": "", "versionName": "1.0.1", "versionCode": "110", - "uni-app-x": {}, /* 快应用特有相关 */ "quickapp": {}, /* 小程序特有相关 */ @@ -30,65 +29,50 @@ "enable": false }, "vueVersion": "3", - "app": { + "app-plus": { + "usingComponents": true, + "modules": {}, "distribute": { + "android": { + "permissions": [ + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + "ios": { + "privacyDescription": { + "NSBluetoothPeripheralUsageDescription": "Please allow Bluetooth access. It is used to connect to the mother cup device: displaying runtime parameters such as temperature and fan speed, querying device system status, and upgrading the device firmware over Bluetooth.", + "NSBluetoothAlwaysUsageDescription": "Please allow Bluetooth access. It is used to connect to the mother cup device: displaying runtime parameters such as temperature and fan speed, querying device system status, and upgrading the device firmware over Bluetooth.", + "NSLocationWhenInUseUsageDescription": "Please allow the use of location services to identify the position of charging stations. This app promises that this function will not be used for any other purposes.", + "NSLocalNetworkUsageDescription": "Please allow the use of network connectivity for communication between the app and the cloud service backend to enable charging-related features. This app promises that it will only be used to complete charging-related services with the cloud backend and will not be utilized for any other purposes.", + "NSCameraUsageDescription": "Please allow the use of the camera function. This function is solely used for scanning the QR codes on charging piles to obtain information corresponding to the QR codes. This app promises that the function will not be used for any other purposes." + } + }, "icons": { "android": { - "hdpi": "", - "xhdpi": "", - "xxhdpi": "", - "xxxhdpi": "" + "hdpi": "/static/appIcon.png", + "xhdpi": "/static/appIcon.png", + "xxhdpi": "/static/appIcon.png", + "xxxhdpi": "/static/appIcon.png" + }, + "ios": { + "appstore": "/static/appIcon.png" } + }, + "splashscreen": { + "alwaysShowBeforeRender": true, + "waiting": true, + "autoclose": true, + "delay": 0 } } }, - "app-android": { - "distribute": { - "modules": {}, - "icons": { - "hdpi": "/static/appIcon.png", - "xhdpi": "/static/appIcon.png", - "xxhdpi": "/static/appIcon.png", - "xxxhdpi": "/static/appIcon.png" - }, - "splashScreens": { - "default": {} - }, - "permissions": [ - "", - "", - "", - "" - ] - } - }, - "app-ios": { - "distribute": { - "modules": { - "uni-location": {}, - "uni-barcode-scanning": {} - }, - "icons": { - "appstore": "/static/appIcon.png" - }, - "splashScreens": {}, - "privacyDescription": { - "NSBluetoothPeripheralUsageDescription": "Please allow Bluetooth access. It is used to connect to the mother cup device: displaying runtime parameters such as temperature and fan speed, querying device system status, and upgrading the device firmware over Bluetooth.", - "NSBluetoothAlwaysUsageDescription": "Please allow Bluetooth access. It is used to connect to the mother cup device: displaying runtime parameters such as temperature and fan speed, querying device system status, and upgrading the device firmware over Bluetooth.", - "NSLocationWhenInUseUsageDescription": "Please allow the use of location services to identify the position of charging stations. This app promises that this function will not be used for any other purposes.", - "NSLocalNetworkUsageDescription": "Please allow the use of network connectivity for communication between the app and the cloud service backend to enable charging-related features. This app promises that it will only be used to complete charging-related services with the cloud backend and will not be utilized for any other purposes.", - "NSCameraUsageDescription": "Please allow the use of the camera function. This function is solely used for scanning the QR codes on charging piles to obtain information corresponding to the QR codes. This app promises that the function will not be used for any other purposes." - }, - "urltypes": "", - "capabilities": { - "entitlements": { - "com.apple.developer.associated-domains": [] - } - }, - "urlschemewhitelist": "", - "UIBackgroundModes": "" - } - }, "web": { "router": { "mode": "" diff --git a/pages.json b/pages.json index 09b824f..5ef832b 100644 --- a/pages.json +++ b/pages.json @@ -88,7 +88,7 @@ }, "globalStyle": { "navigationBarTextStyle": "black", - "navigationBarTitleText": "uni-app x", + "navigationBarTitleText": "smartAssister", "navigationBarBackgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8", "navigationStyle": "default" diff --git a/pages/bleTest/bluetoothOperation/bluetoothOperation.uvue b/pages/bleTest/bluetoothOperation/bluetoothOperation.vue similarity index 93% rename from pages/bleTest/bluetoothOperation/bluetoothOperation.uvue rename to pages/bleTest/bluetoothOperation/bluetoothOperation.vue index 2587da7..60c8dfd 100644 --- a/pages/bleTest/bluetoothOperation/bluetoothOperation.uvue +++ b/pages/bleTest/bluetoothOperation/bluetoothOperation.vue @@ -44,13 +44,15 @@ - @@ -197,4 +197,4 @@ onUnload(() => { color: #3A6FA1; margin-right: 8rpx; } - \ No newline at end of file + diff --git a/pages/tabbar/ota.uvue b/pages/tabbar/ota.vue similarity index 77% rename from pages/tabbar/ota.uvue rename to pages/tabbar/ota.vue index 6ef9fea..529d925 100644 --- a/pages/tabbar/ota.uvue +++ b/pages/tabbar/ota.vue @@ -70,18 +70,15 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-color/index.ts b/uni_modules/lime-color/index.ts deleted file mode 100644 index eab5e00..0000000 --- a/uni_modules/lime-color/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-nocheck -export * from './common/color' -export * from './common/generate' -export * from './utssdk/interface' -// export {LGenerateOptions} from './utssdk/interface' \ No newline at end of file diff --git a/uni_modules/lime-color/index.uts b/uni_modules/lime-color/index.uts deleted file mode 100644 index 34f7bca..0000000 --- a/uni_modules/lime-color/index.uts +++ /dev/null @@ -1,6 +0,0 @@ -// @ts-nocheck -export * from './common/color' -export * from './common/generate' -// #ifndef APP-NVUE -export * from './utssdk/interface.uts' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-color/interface.uts b/uni_modules/lime-color/interface.uts deleted file mode 100644 index 2681eb2..0000000 --- a/uni_modules/lime-color/interface.uts +++ /dev/null @@ -1,87 +0,0 @@ -export type RGB = { - r : number; - g : number; - b : number; -} -export type RGBA = { - r : number; - g : number; - b : number; - a : number; -} -export type RGBAString = { - r : string; - g : string; - b : string; - a : number; -} -export type HSL = { - h : number; - s : number; - l : number; -} - -export type HSLA = { - h : number; - s : number; - l : number; - a : number; -} -export type HSV = { - h : number; - s : number; - v : number; -} - -export type HSVA = { - h : number; - s : number; - v : number; - a : number; -} - -// 增加部分 -export type HSB = { - h : number; - s : number; - b : number; -} -export type HSBA = { - h : number; - s : number; - b : number; - a : number; -} - -export type LColorInfo = { - ok ?: boolean; - format ?: LColorFormats; - r : number; - g : number; - b : number; - a : number; -} - -export type LColorFormats = - | 'rgb' - | 'prgb' - | 'hex' - | 'hex3' - | 'hex4' - | 'hex6' - | 'hex8' - | 'name' - | 'hsl' - | 'hsb' - | 'hsv'; - -export type LColorOptions = { - format ?: LColorFormats; - gradientType ?: string; -} -export type LColorInput = any //string | number | RGB | RGBA | HSL | HSLA | HSV | HSVA | LimeColor; - -export type LGenerateOptions = { - theme ?: 'dark' | 'default'; - backgroundColor ?: string; -} diff --git a/uni_modules/lime-color/package.json b/uni_modules/lime-color/package.json deleted file mode 100644 index 5705f95..0000000 --- a/uni_modules/lime-color/package.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "id": "lime-color", - "displayName": "lime-color tinycolor颜色转换", - "version": "2.0.0", - "description": "lime-color是tinycolor UTS版的小型库,用于颜色操作和转换,内容Ant Design 的颜色等级生成算法", - "keywords": [ - "lime-color", - "TinyColor", - "color", - "颜色转换", - "uts" -], - "repository": "", - "engines": { - "HBuilderX": "^4.0", - "uni-app": "^4.72", - "uni-app-x": "^4.74" - }, - "dcloudext": { - "type": "uts", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "", - "darkmode": "x", - "i18n": "x", - "widescreen": "x" - }, - "uni_modules": { - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "√", - "aliyun": "√", - "alipay": "√" - }, - "client": { - "uni-app": { - "vue": { - "vue2": "√", - "vue3": "√" - }, - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "vue": "√", - "nvue": "-", - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√", - "alipay": "√", - "toutiao": "√", - "baidu": "√", - "kuaishou": "√", - "jd": "√", - "harmony": "√", - "qq": "√", - "lark": "√", - "xhs": "-" - }, - "quickapp": { - "huawei": "√", - "union": "√" - } - }, - "uni-app-x": { - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√" - } - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/lime-color/readme - 副本.md b/uni_modules/lime-color/readme - 副本.md deleted file mode 100644 index bfbee87..0000000 --- a/uni_modules/lime-color/readme - 副本.md +++ /dev/null @@ -1,557 +0,0 @@ -# lime-color -- 颜色转换 - -## 文档 - 🚀 [color【站点1】](https://limex.qcoon.cn/uts/color.html) - 🌍 [color【站点2】](https://limeui.netlify.app/uts/color.html) - 🔥 [color【站点3】](https://limeui.familyzone.top/uts/color.html) - - - -## 安装 -插件市场导入插件即可 - -## 使用 -```js -import {tinyColor} from '@/uni_modules/lime-color' -``` - -## 接受的字符串输入 - -字符串解析非常宽容。它的目的是使输入颜色尽可能简单。所有的逗号、百分比、括号都是可选的,大多数输入允许使用 0-1、0%-100% 或 0-n(其中 n 取决于值的 100、255 或 360)。 -HSL 和 HSV 都需要 0%-100% 或 0-1 作为 S/L/V 属性。H(色相)可以在 0%-100% 或 0-360 之间取值。 -RGB 输入需要 0-255 或 0%-100%。 -以下是一些字符串输入的示例: - - -### Hex, 8-digit (RGBA) Hex - -```ts -tinyColor('#000'); -tinyColor('000'); -tinyColor('#369C'); -tinyColor('369C'); -tinyColor('#f0f0f6'); -tinyColor('f0f0f6'); -tinyColor('#f0f0f688'); -tinyColor('f0f0f688'); -``` - -### RGB, RGBA - -```ts -tinyColor('rgb (255, 0, 0)'); -tinyColor('rgb 255 0 0'); -tinyColor('rgba (255, 0, 0, .5)'); -tinyColor({ r: 255, g: 0, b: 0 }); -``` - -### HSL, HSLA - -```ts -tinyColor('hsl(0, 100%, 50%)'); -tinyColor('hsla(0, 100%, 50%, .5)'); -tinyColor('hsl(0, 100%, 50%)'); -tinyColor('hsl 0 1.0 0.5'); -tinyColor({ h: 0, s: 1, l: 0.5 }); -``` - -### HSV, HSVA - -```ts -tinyColor('hsv(0, 100%, 100%)'); -tinyColor('hsva(0, 100%, 100%, .5)'); -tinyColor('hsv (0 100% 100%)'); -tinyColor('hsv 0 1 1'); -tinyColor({ h: 0, s: 100, v: 100 }); -``` - -### Named - -```ts -tinyColor('RED'); -tinyColor('blanchedalmond'); -tinyColor('darkblue'); -``` - -### Number -```ts -tinyColor(0x0); -tinyColor(0xaabbcc); -``` - - -## 属性 - -### originalInput -传递到构造函数中用于创建`tinyColor`实例的原始输入。 - -```ts -const color = tinyColor('red'); -color.originalInput; // "red" -const color2 = tinyColor({ r: 255, g: 255, b: 255 }); -color2.originalInput; // "{r: 255, g: 255, b: 255}" -``` - -### format - -返回用于创建`tinyColor`实例的格式 - -```ts -const color = tinyColor('red'); -color.format; // "name" -const color2 = tinyColor({ r: 255, g: 255, b: 255 }); -color2.format; // "rgb" -``` - -### isValid - -一个布尔值,指示颜色是否成功被解析。注意:如果颜色无效,则在与其他方法一起使用时将表现得像“黑色”。 - -```ts -const color1 = tinyColor('red'); -color1.isValid; // true -color1.toHexString(); // "#ff0000" - -const color2 = tinyColor('not a color'); -color2.isValid; // false -color2.toString(); // "#000000" -``` - -## Methods 方法 - -### getBrightness - -返回颜色的感知亮度,范围从 0-255,这是根据 [Web内容无障碍指南(第1版)](http://www.w3.org/TR/AERT#color-contrast) 定义的。 - -```ts -const color1 = tinyColor('#fff'); -color1.getBrightness(); // 255 - -const color2 = tinyColor('#000'); -color2.getBrightness(); // 0 -``` - -### isLight - -返回一个布尔值,指示颜色的感知亮度是否为浅色。 - -```ts -const color1 = tinyColor('#fff'); -color1.isLight(); // true - -const color2 = tinyColor('#000'); -color2.isLight(); // false -``` - -### isDark - -返回一个布尔值,指示颜色的感知亮度是否为深色。 - -```ts -const color1 = tinyColor('#fff'); -color1.isDark(); // false - -const color2 = tinyColor('#000'); -color2.isDark(); // true -``` - -### getLuminance - -返回颜色的感知亮度(luminance),范围从 0-1,这是根据 [Web内容无障碍指南(第2版)](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef) 定义的。 - -```ts -const color1 = tinyColor('#fff'); -color1.getLuminance(); // 1 - -const color2 = tinyColor('#000'); -color2.getLuminance(); // 0 -``` - -### getAlpha - -返回颜色的`alpha`(透明度)值,范围从 `0-1`。 - -```ts -const color1 = tinyColor('rgba(255, 0, 0, .5)'); -color1.getAlpha(); // 0.5 - -const color2 = tinyColor('rgb(255, 0, 0)'); -color2.getAlpha(); // 1 - -const color3 = tinyColor('transparent'); -color3.getAlpha(); // 0 -``` - -### setAlpha - -在当前颜色上设置`alpha`(透明度)值。接受的范围是 `0-1` 之间。 - -```ts -const color = tinyColor('red'); -color.getAlpha(); // 1 -color.setAlpha(0.5); -color.getAlpha(); // .5 -color.toRgbString(); // "rgba(255, 0, 0, .5)" -``` - -### onBackground - -计算颜色在背景上的显示效果。当颜色完全透明(即 `getAlpha() == 0`)时,结果将是背景颜色。当颜色完全不透明(即 `getAlpha() == 1`)时,结果将是颜色本身。否则,你将得到一个计算结果。 - -```ts -const color = tinyColor('rgba(255, 0, 0, .5)'); -const computedColor = color.onBackground('rgb(0, 0, 255)'); -computedColor.toRgbString(); // "rgb(128, 0, 128)" -``` - -### toHsv - -```ts -const color = tinyColor('red'); -color.toHsv(); // { h: 0, s: 1, v: 1, a: 1 } -``` - -### toHsvString - -```ts -const color = tinyColor('red'); -color.toHsvString(); // "hsv(0, 100%, 100%)" -color.setAlpha(0.5); -color.toHsvString(); // "hsva(0, 100%, 100%, 0.5)" -``` - -### toHsl - -```ts -const color = tinyColor('red'); -color.toHsl(); // { h: 0, s: 1, l: 0.5, a: 1 } -``` - -### toHslString - -```ts -const color = tinyColor('red'); -color.toHslString(); // "hsl(0, 100%, 50%)" -color.setAlpha(0.5); -color.toHslString(); // "hsla(0, 100%, 50%, 0.5)" -``` - -### toNumber -```ts -tinyColor('#aabbcc').toNumber() === 0xaabbcc // true -tinyColor('rgb(1, 1, 1)').toNumber() === (1 << 16) + (1 << 8) + 1 // true -``` - -### toHex - -```ts -const color = tinyColor('red'); -color.toHex(); // "ff0000" -``` - -### toHexString - -```ts -const color = tinyColor('red'); -color.toHexString(); // "#ff0000" -``` - -### toHex8 - -```ts -const color = tinyColor('red'); -color.toHex8(); // "ff0000ff" -``` - -### toHex8String - -```ts -const color = tinyColor('red'); -color.toHex8String(); // "#ff0000ff" -``` - -### toHexShortString -根据颜色的透明度(Alpha值)返回较短的十六进制值,并且值前面带有#符号 -```ts -const color1 = tinyColor('#ff000000'); -color1.toHexShortString(); // "#ff000000" -color1.toHexShortString(true); // "#f000" - -const color2 = tinyColor('#ff0000ff'); -color2.toHexShortString(); // "#ff0000" -color2.toHexShortString(true); // "#f00" -``` - -### toRgb - -```ts -const color = tinyColor('red'); -color.toRgb(); // { r: 255, g: 0, b: 0, a: 1 } -``` - -### toRgbString - -```ts -const color = tinyColor('red'); -color.toRgbString(); // "rgb(255, 0, 0)" -color.setAlpha(0.5); -color.toRgbString(); // "rgba(255, 0, 0, 0.5)" -``` - -### toPercentageRgb -将当前颜色转换为百分比表示的 RGB -```ts -const color = tinyColor('red'); -color.toPercentageRgb(); // { r: "100%", g: "0%", b: "0%", a: 1 } -``` - -### toPercentageRgbString - -```ts -const color = tinyColor('red'); -color.toPercentageRgbString(); // "rgb(100%, 0%, 0%)" -color.setAlpha(0.5); -color.toPercentageRgbString(); // "rgba(100%, 0%, 0%, 0.5)" -``` - -### toName - -```ts -const color = tinyColor('red'); -color.toName(); // "red" -``` - - -### toString - -根据输入格式打印成字符串。你也可以通过向函数中传入以下之一来覆盖这个行为:`"rgb", "prgb", "hex6", "hex3", "hex8", "name", "hsl", "hsv"` - -```ts -const color1 = tinyColor('red'); -color1.toString(); // "red" -color1.toString('hsv'); // "hsv(0, 100%, 100%)" - -const color2 = tinyColor('rgb(255, 0, 0)'); -color2.toString(); // "rgb(255, 0, 0)" -color2.setAlpha(0.5); -color2.toString(); // "rgba(255, 0, 0, 0.5)" -``` - -### 颜色修改 - -这些方法操纵当前颜色,并返回它以进行链式调用。例如: - -```ts -tinyColor('red') - .lighten() - .desaturate() - .toHexString(); // '#f53d3d' -``` - -### lighten - -`lighten: function(amount = 10) -> TinyColor`.根据给定的量(从0到100)调亮颜色。提供100将始终返回白色. - -```ts -tinyColor('#f00').lighten().toString(); // '#ff3333' -tinyColor('#f00').lighten(100).toString(); // '#ffffff' -``` - -### brighten - -`brighten: function(amount = 10) -> TinyColor`. 根据给定的量(从0到100)提高颜色的亮度。 - -```ts -tinyColor('#f00').brighten().toString(); // '#ff1919' -``` - -### darken - -`darken: function(amount = 10) -> TinyColor`. 根据给定的量(从0到100)调暗颜色。提供100将始终返回黑色. - -```ts -tinyColor('#f00').darken().toString(); // '#cc0000' -tinyColor('#f00').darken(100).toString(); // '#000000' -``` - -### tint - -将颜色与纯白色混合,范围从0到100。提供0将不进行任何操作,提供100将始终返回白色. - -```ts -tinyColor('#f00').tint().toString(); // "#ff1a1a" -tinyColor('#f00').tint(100).toString(); // "#ffffff" -``` - -### shade - -将颜色与纯黑色混合,范围从0到100。提供0将不进行任何操作,提供100将始终返回黑色。 - -```ts -tinyColor('#f00').shade().toString(); // "#e60000" -tinyColor('#f00').shade(100).toString(); // "#000000" -``` - -### desaturate - -`desaturate: function(amount = 10) -> TinyColor`. 根据给定的量(从0到100)降低颜色的饱和度。提供100将与调用`greyscale`相同。 - - -```ts -tinyColor('#f00').desaturate().toString(); // "#f20d0d" -tinyColor('#f00').desaturate(100).toString(); // "#808080" -``` - -### saturate - -`saturate: function(amount = 10) -> TinyColor`. 根据给定的量(从0到100)增加颜色的饱和度。 - -```ts -tinyColor('hsl(0, 10%, 50%)').saturate().toString(); // "hsl(0, 20%, 50%)" -``` - -### greyscale - -`greyscale: function() -> TinyColor`. 完全降低颜色的饱和度,使其变为灰度。与调用`desaturate(100)`相同。 - -```ts -tinyColor('#f00').greyscale().toString(); // "#808080" -``` - -### spin - -`spin: function(amount = 0) -> TinyColor`. 根据给定的量(从-360到360)旋转色相。调用时使用0、360或-360将不进行任何操作(因为它将色相设置回原来的值)。 - -```ts -tinyColor('#f00').spin(180).toString(); // "#00ffff" -tinyColor('#f00').spin(-90).toString(); // "#7f00ff" -tinyColor('#f00').spin(90).toString(); // "#80ff00" - -// spin(0) and spin(360) do nothing -tinyColor('#f00').spin(0).toString(); // "#ff0000" -tinyColor('#f00').spin(360).toString(); // "#ff0000" -``` - -### mix - -`mix: function(amount = 50) => TinyColor`. 将当前颜色与另一种颜色按给定量(从0到100)混合。0表示不混合(返回当前颜色)。 - -```ts -let color1 = tinyColor('#f0f'); -let color2 = tinyColor('#0f0'); - -color1.mix(color2).toHexString(); // #808080 -``` - -### 颜色组合 - -组合函数除非特别说明,否则返回一个`TinyColor`对象的数组。 - -### analogous -生成一组与当前颜色相似的颜色。 -`analogous: function(results = 6, slices = 30) -> array`. - -```ts -const colors = tinyColor('#f00').analogous(); -colors.map((t):string => t.toHexString()); // [ "#ff0000", "#ff0066", "#ff0033", "#ff0000", "#ff3300", "#ff6600" ] -``` - -### monochromatic -生成一组与当前颜色具有相同色相和饱和度的颜色。 -`monochromatic: function(, results = 6) -> array`. - -```ts -const colors = tinyColor('#f00').monochromatic(); -colors.map((t):string => t.toHexString()); // [ "#ff0000", "#2a0000", "#550000", "#800000", "#aa0000", "#d40000" ] -``` - -### splitcomplement -生成当前颜色的分裂补色。 -`splitcomplement: function() -> array`. - -```ts -const colors = tinyColor('#f00').splitcomplement(); -colors.map((t):string => t.toHexString()); // [ "#ff0000", "#ccff00", "#0066ff" ] -``` - -### triad -生成当前颜色的三色调。 -`triad: function() -> array`. Alias for `polyad(3)`. - -```ts -const colors = tinyColor('#f00').triad(); -colors.map((t):string => t.toHexString()); // [ "#ff0000", "#00ff00", "#0000ff" ] -``` - -### tetrad -生成当前颜色的四色调。 -`tetrad: function() -> array`. Alias for `polyad(4)`. - -```ts -const colors = tinyColor('#f00').tetrad(); -colors.map((t):string => t.toHexString()); // [ "#ff0000", "#80ff00", "#00ffff", "#7f00ff" ] -``` - -### polyad -生成当前颜色的 n 色调。 -`polyad: function(number) -> array`. - -```ts -const colors = tinyColor('#f00').polyad(4); -colors.map((t):string => t.toHexString()); // [ "#ff0000", "#80ff00", "#00ffff", "#7f00ff" ] -``` - -### complement -计算当前颜色的补色。 -`complement: function() -> TinyColor`. - -```ts -tinyColor('#f00').complement().toHexString(); // "#00ffff" -``` - -## 颜色工具 - -### equals -判断两色是否相同 - -```ts -let color1 = tinyColor('red'); -let color2 = tinyColor('#f00'); - -color1.equals(color2); // true -``` - - -## 常见操作 - -### clone - -`clone: function() -> TinyColor`. -使用相同的颜色实例化一个新的`TinyColor`对象。对新的对象的任何更改都不会影响旧的对象。 - -```ts -const color1 = tinyColor('#F00'); -const color2 = color1.clone(); -color2.setAlpha(0.5); - -color1.toString(); // "#ff0000" -color2.toString(); // "rgba(255, 0, 0, 0.5)" -``` - -### generate -通过一个主色生成10个等级的颜色数组,使用 Ant Design 的颜色生成算法。 - -```ts -import {generate, LGenerateOptions} from '@/uni_modules/lime-color' -// 第二个参数为选填,如果不填则默认为 'default' -generate('red',{ theme: 'default'|'dark'} as LGenerateOptions) -// ['#2c1113', '#450f11', '#5b0e0e', '#7e0b0b', '#ad0707', '#dc0303', '#e82d27', '#f3594f', '#f88577', '#faaca0'] -``` - - -## 打赏 - -如果你觉得本插件,解决了你的问题,赠人玫瑰,手留余香。 -![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) -![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) \ No newline at end of file diff --git a/uni_modules/lime-color/readme.md b/uni_modules/lime-color/readme.md deleted file mode 100644 index cdcff14..0000000 --- a/uni_modules/lime-color/readme.md +++ /dev/null @@ -1,342 +0,0 @@ ---- -name: lime-color 颜色工具 -description: 功能丰富、易于使用的颜色处理工具库,支持颜色转换、操作和生成功能。 -tags: - - color - - 颜色 - - tinycolor - - 转换 -plugin: lime-color -category: API 插件 -dependencies: [] ---- - -# lime-color 颜色工具 - -> 一个功能丰富、易于使用的颜色处理工具库,提供全面的颜色转换、操作和生成功能 - -## 📋 功能特性 - -- **多格式支持**:兼容 HEX、RGB、HSL、HSV、HSB 等多种颜色格式 -- **丰富的转换方法**:在不同颜色空间之间自由转换 -- **强大的颜色操作**:支持亮度调整、饱和度修改、色相旋转等操作 -- **智能颜色组合**:生成相似色、互补色、三色组合等多种颜色方案 -- **主题色生成**:基于 Ant Design 颜色算法的主题色系列生成 -- **跨平台兼容**:支持 uni-app 多端开发 - -## 📚 文档链接 - -详细使用文档请访问以下站点: -- [颜色工具文档 - 站点1](https://limex.qcoon.cn/uts/color.html) -- [颜色工具文档 - 站点2](https://limeui.netlify.app/uts/color.html) -- [颜色工具文档 - 站点3](https://limeui.familyzone.top/uts/color.html) - -## 🛠️ 安装方法 - -1. 在 uni-app 插件市场中搜索并导入 `lime-color` -2. 导入后重新编译项目以确保插件正确集成 - -## 🚀 快速开始 - -### 基础用法 - -最简单的颜色工具用法,直接导入并使用: - -```ts -import { tinyColor } from '@/uni_modules/lime-color' -``` - -### 颜色解析 - -tinyColor 接受多种类型的输入,包括字符串、数字、对象等: - -```ts -// Hex 格式 -tinyColor('#000'); // 6位十六进制 -tinyColor('000'); // 无 # 前缀的十六进制 -tinyColor('#369C'); // 4位十六进制(带透明度) -tinyColor('369C'); // 无 # 前缀的4位十六进制 -tinyColor('#f0f0f688'); // 8位十六进制(带透明度) - -// RGB 格式 -tinyColor('rgb (255, 0, 0)'); // 带括号和空格的 RGB -tinyColor('rgb 255 0 0'); // 无括号的 RGB -tinyColor('rgba (255, 0, 0, .5)'); // RGBA 格式 -tinyColor({ r: 255, g: 0, b: 0 }); // RGB 对象 - -// HSL 格式 -tinyColor('hsl(0, 100%, 50%)'); // 标准 HSL 格式 -tinyColor('hsla(0, 100%, 50%, .5)'); // HSLA 格式 -tinyColor('hsl 0 1.0 0.5'); // 无括号的 HSL -tinyColor({ h: 0, s: 1, l: 0.5 }); // HSL 对象 - -// HSV 格式 -tinyColor('hsv(0, 100%, 100%)'); // 标准 HSV 格式 -tinyColor('hsva(0, 100%, 100%, .5)'); // HSVA 格式 -tinyColor('hsv 0 1 1'); // 无括号的 HSV -tinyColor({ h: 0, s: 100, v: 100 }); // HSV 对象 - -// 颜色名称 -tinyColor('RED'); // 大写颜色名称 -tinyColor('blanchedalmond'); // 小写颜色名称 -tinyColor('darkblue'); // 复合颜色名称 - -// 数字格式 -tinyColor(0x0); // 数字 0 -tinyColor(0xaabbcc); // 十六进制数字 -``` - -## 🎨 颜色操作 - -### 颜色转换 - -将颜色转换为不同的格式: - -```ts -const color = tinyColor('red'); - -// 转换为 HSV -color.toHsv(); // { h: 0, s: 1, v: 1, a: 1 } -color.toHsvString(); // "hsv(0, 100%, 100%)" - -// 转换为 HSL -color.toHsl(); // { h: 0, s: 1, l: 0.5, a: 1 } -color.toHslString(); // "hsl(0, 100%, 50%)" - -// 转换为 Hex -color.toHex(); // "ff0000" -color.toHexString(); // "#ff0000" -color.toHex8(); // "ff0000ff" -color.toHex8String(); // "#ff0000ff" - -// 转换为 RGB -color.toRgb(); // { r: 255, g: 0, b: 0, a: 1 } -color.toRgbString(); // "rgb(255, 0, 0)" - -// 转换为百分比 RGB -color.toPercentageRgb(); // { r: "100%", g: "0%", b: "0%", a: 1 } -color.toPercentageRgbString(); // "rgb(100%, 0%, 0%)" - -// 转换为颜色名称 -color.toName(); // "red" -``` - -### 颜色修改 - -修改颜色的亮度、饱和度、色相等属性: - -```ts -const color = tinyColor('red'); - -// 调亮颜色 -color.lighten().toString(); // "#ff3333" -color.lighten(100).toString(); // "#ffffff" - -// 提高亮度 -color.brighten().toString(); // "#ff1919" - -// 调暗颜色 -color.darken().toString(); // "#cc0000" -color.darken(100).toString(); // "#000000" - -// 添加白色 -color.tint().toString(); // "#ff1a1a" -color.tint(100).toString(); // "#ffffff" - -// 添加黑色 -color.shade().toString(); // "#e60000" -color.shade(100).toString(); // "#000000" - -// 降低饱和度 -color.desaturate().toString(); // "#f20d0d" -color.desaturate(100).toString(); // "#808080" - -// 提高饱和度 -tinyColor('hsl(0, 10%, 50%)').saturate().toString(); // "hsl(0, 20%, 50%)" - -// 转为灰度 -color.greyscale().toString(); // "#808080" - -// 旋转色相 -color.spin(180).toString(); // "#00ffff" -color.spin(-90).toString(); // "#7f00ff" -color.spin(90).toString(); // "#80ff00" - -// 混合颜色 -let color1 = tinyColor('#f0f'); -let color2 = tinyColor('#0f0'); -color1.mix(color2).toHexString(); // #808080 -``` - -### 颜色组合 - -生成一组相关的颜色: - -```ts -// 生成相似颜色 -const analogousColors = tinyColor('#f00').analogous(); -analogousColors.map(t => t.toHexString()); -// [ "#ff0000", "#ff0066", "#ff0033", "#ff0000", "#ff3300", "#ff6600" ] - -// 生成单色系列 -const monochromaticColors = tinyColor('#f00').monochromatic(); -monochromaticColors.map(t => t.toHexString()); -// [ "#ff0000", "#2a0000", "#550000", "#800000", "#aa0000", "#d40000" ] - -// 生成三色组合 -const triadColors = tinyColor('#f00').triad(); -triadColors.map(t => t.toHexString()); -// [ "#ff0000", "#00ff00", "#0000ff" ] - -// 生成四色组合 -const tetradColors = tinyColor('#f00').tetrad(); -tetradColors.map(t => t.toHexString()); -// [ "#ff0000", "#80ff00", "#00ffff", "#7f00ff" ] - -// 生成补色 -tinyColor('#f00').complement().toHexString(); // "#00ffff" -``` - -## 🎯 颜色主题生成 - -使用 Ant Design 的颜色生成算法生成主题色系列: - -```ts -import { generate, LimeColorGenerateOptions } from '@/uni_modules/lime-color' - -// 生成默认主题色系列 -generate('red') -// ['#2c1113', '#450f11', '#5b0e0e', '#7e0b0b', '#ad0707', '#dc0303', '#e82d27', '#f3594f', '#f88577', '#faaca0'] - -// 生成暗色主题色系列 -generate('red', { theme: 'dark' }) - -// 生成亮色主题色系列 -generate('blue', { theme: 'light' }) -``` - -## 📖 API 文档 - -### 构造函数 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `tinyColor(color, opts)` | 创建一个 TinyColor 实例 | color: 颜色值, opts: 选项 | TinyColor 实例 | - -### 属性 - -| 属性名 | 说明 | 类型 | -| --- | --- | --- | -| `originalInput` | 传递到构造函数中用于创建实例的原始输入 | any | -| `format` | 用于创建实例的格式 | string | -| `isValid` | 颜色是否成功被解析 | boolean | - -### 颜色判断方法 - -| 方法 | 说明 | 返回值 | -| --- | --- | --- | -| `getBrightness()` | 返回颜色的感知亮度,范围从 0-255 | number | -| `isLight()` | 返回一个布尔值,指示颜色的感知亮度是否为浅色 | boolean | -| `isDark()` | 返回一个布尔值,指示颜色的感知亮度是否为深色 | boolean | -| `getLuminance()` | 返回颜色的感知亮度,范围从 0-1 | number | -| `isMonochrome()` | 判断当前颜色是否为单色 | boolean | - -### 透明度操作 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `getAlpha()` | 返回颜色的透明度值,范围从 0-1 | - | number | -| `setAlpha(alpha)` | 设置颜色的透明度值 | alpha: 0-1 之间的数值 | TinyColor 实例 | -| `onBackground(background)` | 计算颜色在背景上的显示效果 | background: 背景颜色 | TinyColor 实例 | - -### 颜色转换方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `toHsv()` | 转换为 HSV 对象 | - | HSVA 对象 | -| `toHsvString()` | 转换为 HSV 字符串 | - | string | -| `toHsb()` | 转换为 HSB 对象 | - | HSBA 对象 | -| `toHsbString()` | 转换为 HSB 字符串 | - | string | -| `toHsl()` | 转换为 HSL 对象 | - | HSLA 对象 | -| `toHslString()` | 转换为 HSL 字符串 | - | string | -| `toHex(allow3Char)` | 转换为十六进制字符串 | allow3Char: 是否允许3字符简写 | string | -| `toHexString(allow3Char)` | 转换为带#的十六进制字符串 | allow3Char: 是否允许3字符简写 | string | -| `toHex8(allow4Char)` | 转换为8位十六进制字符串 | allow4Char: 是否允许4字符简写 | string | -| `toHex8String(allow4Char)` | 转换为带#的8位十六进制字符串 | allow4Char: 是否允许4字符简写 | string | -| `toHexShortString(allowShortChar)` | 根据透明度返回较短的十六进制值 | allowShortChar: 是否允许简写 | string | -| `toRgb()` | 转换为 RGB 对象 | - | RGBA 对象 | -| `toRgbString()` | 转换为 RGB 字符串 | - | string | -| `toPercentageRgb()` | 转换为百分比表示的 RGB 对象 | - | RGBAString 对象 | -| `toPercentageRgbString()` | 转换为百分比表示的 RGB 字符串 | - | string | -| `toName()` | 转换为颜色名称 | - | string 或 null | -| `toNumber()` | 转换为数字 | - | number | -| `toString(format)` | 根据指定格式转换为字符串 | format: 格式名称 | string | - -### 颜色修改方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `lighten(amount)` | 调亮颜色 | amount: 0-100 之间的数值 | TinyColor 实例 | -| `brighten(amount)` | 提高亮度 | amount: 0-100 之间的数值 | TinyColor 实例 | -| `darken(amount)` | 调暗颜色 | amount: 0-100 之间的数值 | TinyColor 实例 | -| `tint(amount)` | 与白色混合 | amount: 0-100 之间的数值 | TinyColor 实例 | -| `shade(amount)` | 与黑色混合 | amount: 0-100 之间的数值 | TinyColor 实例 | -| `desaturate(amount)` | 降低饱和度 | amount: 0-100 之间的数值 | TinyColor 实例 | -| `saturate(amount)` | 提高饱和度 | amount: 0-100 之间的数值 | TinyColor 实例 | -| `greyscale()` | 转为灰度 | - | TinyColor 实例 | -| `spin(amount)` | 旋转色相 | amount: -360 到 360 之间的数值 | TinyColor 实例 | -| `mix(color, amount)` | 与另一种颜色混合 | color: 颜色值, amount: 0-100 之间的数值 | TinyColor 实例 | - -### 颜色组合方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `analogous(results, slices)` | 生成相似颜色 | results: 结果数量, slices: 分片数量 | TinyColor[] | -| `monochromatic(results)` | 生成单色系列 | results: 结果数量 | TinyColor[] | -| `splitcomplement()` | 生成分裂补色 | - | TinyColor[] | -| `triad()` | 生成三色组合 | - | TinyColor[] | -| `tetrad()` | 生成四色组合 | - | TinyColor[] | -| `polyad(n)` | 生成 n 色组合 | n: 颜色数量 | TinyColor[] | -| `complement()` | 生成补色 | - | TinyColor 实例 | - -### 其他方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `clone()` | 克隆颜色实例 | - | TinyColor 实例 | -| `equals(color)` | 判断两个颜色是否相等 | color: 颜色值 | boolean | - -### 颜色主题生成 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `generate(color, options)` | 生成颜色主题 | color: 颜色值, options: 选项 | string[] | - -## 🌟 应用场景 - -- **颜色选择器**:支持多种颜色格式的输入和输出 -- **主题定制**:生成完整的主题色系列 -- **数据可视化**:创建和谐的颜色方案 -- **UI 设计工具**:提供颜色操作和转换功能 -- **游戏开发**:生成游戏内的颜色方案 - -## 🤝 支持与赞赏 - -如果你觉得本插件解决了你的问题,可以考虑支持作者: - -| 支付宝赞助 | 微信赞助 | -|------------|------------| -| ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) | ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) | - -## 📄 许可证 - -本项目采用 MIT 许可证,详见 LICENSE 文件。 - -## 🔗 相关链接 - -- [uni-app 插件市场](https://ext.dcloud.net.cn/) -- [Ant Design 颜色系统](https://ant.design/docs/spec/colors-cn) - ---- - -**lime-color** - 让颜色处理变得简单而强大! \ No newline at end of file diff --git a/uni_modules/lime-color/utssdk/app-android-o/config.json b/uni_modules/lime-color/utssdk/app-android-o/config.json deleted file mode 100644 index bf95925..0000000 --- a/uni_modules/lime-color/utssdk/app-android-o/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "minSdkVersion": "21" -} \ No newline at end of file diff --git a/uni_modules/lime-color/utssdk/app-android-o/index.uts b/uni_modules/lime-color/utssdk/app-android-o/index.uts deleted file mode 100644 index 720ce4f..0000000 --- a/uni_modules/lime-color/utssdk/app-android-o/index.uts +++ /dev/null @@ -1,2 +0,0 @@ -export * from '../../common/color' -export * from '../../common/generate' \ No newline at end of file diff --git a/uni_modules/lime-color/utssdk/app-js-o/config.json b/uni_modules/lime-color/utssdk/app-js-o/config.json deleted file mode 100644 index 721b81e..0000000 --- a/uni_modules/lime-color/utssdk/app-js-o/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "deploymentTarget": "9" -} \ No newline at end of file diff --git a/uni_modules/lime-color/utssdk/app-js-o/index.uts b/uni_modules/lime-color/utssdk/app-js-o/index.uts deleted file mode 100644 index 720ce4f..0000000 --- a/uni_modules/lime-color/utssdk/app-js-o/index.uts +++ /dev/null @@ -1,2 +0,0 @@ -export * from '../../common/color' -export * from '../../common/generate' \ No newline at end of file diff --git a/uni_modules/lime-color/utssdk/index-o.uts b/uni_modules/lime-color/utssdk/index-o.uts deleted file mode 100644 index 053349f..0000000 --- a/uni_modules/lime-color/utssdk/index-o.uts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '../common/color' -export * from '../common/generate' -export * from './interface' \ No newline at end of file diff --git a/uni_modules/lime-color/utssdk/interface.uts b/uni_modules/lime-color/utssdk/interface.uts deleted file mode 100644 index 4253e81..0000000 --- a/uni_modules/lime-color/utssdk/interface.uts +++ /dev/null @@ -1,93 +0,0 @@ -// @ts-nocheck -export type RGB = { - r : number; - g : number; - b : number; -} -export type RGBA = { - r : number; - g : number; - b : number; - a : number; -} -export type RGBAString = { - r : string; - g : string; - b : string; - a : number; -} -export type HSL = { - h : number; - s : number; - l : number; -} - -export type HSLA = { - h : number; - s : number; - l : number; - a : number; -} -export type HSV = { - h : number; - s : number; - v : number; -} - -export type HSVA = { - h : number; - s : number; - v : number; - a : number; -} - -// 增加部分 -export type HSB = { - h : number; - s : number; - b : number; -} -export type HSBA = { - h : number; - s : number; - b : number; - a : number; -} - -export type LimeColorInfo = { - ok ?: boolean; - format ?: LimeColorFormats; - r : number; - g : number; - b : number; - a : number; -} - -export type LimeColorFormats = - | 'rgb' - | 'prgb' - | 'hex' - | 'hex3' - | 'hex4' - | 'hex6' - | 'hex8' - | 'name' - | 'hsl' - | 'hsb' - | 'hsv'; - -export type LimeColorOptions = { - format ?: LimeColorFormats; - gradientType ?: string; -} - -export type LimeColorInput = string | number | RGB | RGBA | HSL | HSLA | HSV | HSVA | LimeColor; - -export type LimeColorGenerateOptions = { - theme ?: 'dark' | 'default'; - backgroundColor ?: string; -} - -export interface LimeColor { - -} \ No newline at end of file diff --git a/uni_modules/lime-color/utssdk/unierror.uts b/uni_modules/lime-color/utssdk/unierror.uts deleted file mode 100644 index e3bab5c..0000000 --- a/uni_modules/lime-color/utssdk/unierror.uts +++ /dev/null @@ -1,41 +0,0 @@ -/* 此规范为 uni 规范,可以按照自己的需要选择是否实现 */ -import { MyApiErrorCode, MyApiFail } from "./interface.uts" -/** - * 错误主题 - * 注意:错误主题一般为插件名称,每个组件不同,需要使用时请更改。 - * [可选实现] - */ -export const UniErrorSubject = 'uts-api'; - - -/** - * 错误信息 - * @UniError - * [可选实现] - */ -export const UniErrors : Map = new Map([ - /** - * 错误码及对应的错误信息 - */ - [9010001, 'custom error mseeage1'], - [9010002, 'custom error mseeage2'], -]); - - -/** - * 错误对象实现 - */ -export class MyApiFailImpl extends UniError implements MyApiFail { - - /** - * 错误对象构造函数 - */ - constructor(errCode : MyApiErrorCode) { - super(); - this.errSubject = UniErrorSubject; - this.errCode = errCode; - this.errMsg = UniErrors[errCode] ?? ""; - } -} - - diff --git a/uni_modules/lime-date-time-picker/changelog.md b/uni_modules/lime-date-time-picker/changelog.md deleted file mode 100644 index ac2cae2..0000000 --- a/uni_modules/lime-date-time-picker/changelog.md +++ /dev/null @@ -1,30 +0,0 @@ -## 0.1.6(2026-02-09) -- fix: 修复uniappx ios时分秒模式问题 -## 0.1.5(2026-02-09) -- fix: 修复mode判断问题 -## 0.1.4(2026-02-07) -- fix: 修复coalesce缺少返回值 -## 0.1.3(2026-01-27) -- fix: 修复默认值不生效问题 -## 0.1.2(2026-01-24) -- fix: 修复在时分秒模式下无法选中的问题 -## 0.1.1(2025-12-29) -- fix: 修复uniapp缺少`renderLabel` -## 0.1.0(2025-12-09) -- fix: 修复类型问题 -## 0.0.9(2025-08-31) -- chore: 更新文档 -## 0.0.7(2025-04-24) -- fix: 修复uniapp v2 app 报错问题 -## 0.0.6(2025-04-23) -- feat: 兼容uniappx 鸿蒙next -## 0.0.5(2025-04-17) -- fix: 修复uniapp缺少导出onChange -## 0.0.4(2025-03-25) -- fix: 修复空字符时无法使用 -## 0.0.3(2025-01-09) -- feat: 增加`change`事件 -## 0.0.2(2024-12-27) -- feat: 兼容vue2 -## 0.0.1(2024-12-27) -- init diff --git a/uni_modules/lime-date-time-picker/components/l-date-time-picker/constant.ts b/uni_modules/lime-date-time-picker/components/l-date-time-picker/constant.ts deleted file mode 100644 index 5ce658c..0000000 --- a/uni_modules/lime-date-time-picker/components/l-date-time-picker/constant.ts +++ /dev/null @@ -1,56 +0,0 @@ -// @ts-nocheck -import { TimeModeValues } from './type'; -// 使用位运算定义模式 -// const MODES = { -// YEAR: 1 << 0, // 1 -// MONTH: 1 << 1, // 2 -// DATE: 1 << 2, // 4 -// HOUR: 1 << 3, // 8 -// MINUTE: 1 << 4 // 16 -// SECOND : 1 << 4 // 32 -// }; - -export const MODE_YEAR = 1; // 0001 -export const MODE_MONTH = 2; // 0010 -export const MODE_DATE = 4; // 0100 -export const MODE_HOUR = 8; // 1000 -export const MODE_MINUTE = 16; // 10000 -export const MODE_SECOND = 32; // 100000 - -export const MODE_MAP = new Map([ - ['年', MODE_YEAR], - ['月', MODE_MONTH], - ['日', MODE_DATE], - ['时', MODE_HOUR], - ['分', MODE_MINUTE], - ['秒', MODE_SECOND], - ['year', MODE_YEAR], - ['month', MODE_MONTH], - ['date', MODE_DATE], - ['hour', MODE_HOUR], - ['minute', MODE_MINUTE], - ['second', MODE_SECOND], -]) - -export const FORMAT_MAP = new Map([ - ['year', 'YYYY'], - ['month', 'MM'], - ['date', 'DD'], - ['hour', 'HH'], - ['minute', 'mm'], - ['second', 'ss'], -]) - -export const UNIT_MAP = new Map([ - ['year', '年'], - ['month', '月'], - ['date', '日'], - ['hour', '时'], - ['minute', '分'], - ['second', '秒'], -]) - - -// 定义时间列名称数组 -export const MODE_NAMES : TimeModeValues[] = ['year', 'month', 'date', 'hour', 'minute', 'second']; -export const DEFAULT_FORMAT = 'YYYY-MM-DD HH:mm:ss' \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/components/l-date-time-picker/l-date-time-picker.uvue b/uni_modules/lime-date-time-picker/components/l-date-time-picker/l-date-time-picker.uvue deleted file mode 100644 index b8a3515..0000000 --- a/uni_modules/lime-date-time-picker/components/l-date-time-picker/l-date-time-picker.uvue +++ /dev/null @@ -1,313 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/components/l-date-time-picker/l-date-time-picker.vue b/uni_modules/lime-date-time-picker/components/l-date-time-picker/l-date-time-picker.vue deleted file mode 100644 index 419375a..0000000 --- a/uni_modules/lime-date-time-picker/components/l-date-time-picker/l-date-time-picker.vue +++ /dev/null @@ -1,321 +0,0 @@ - - - diff --git a/uni_modules/lime-date-time-picker/components/l-date-time-picker/props.ts b/uni_modules/lime-date-time-picker/components/l-date-time-picker/props.ts deleted file mode 100644 index efe863a..0000000 --- a/uni_modules/lime-date-time-picker/components/l-date-time-picker/props.ts +++ /dev/null @@ -1,140 +0,0 @@ -// @ts-nocheck -export default { - /** 取消按钮文字 */ - cancelBtn: { - type: String, - default: null, - }, - cancelStyle: { - type: String, - default: null - }, - /** 确定按钮文字 */ - confirmBtn: { - type: String, - default: null, - }, - confirmStyle: { - type: String, - default: null - }, - /** 组件国际化语言,目前支持: 简体中文(zh)、(tc)、英文(en)、日语(ja)、韩语(ko)、俄语(ru)等六种语言 */ - customLocale: { - type: String, - default: 'zh', - }, - /** 选择器的最大可选时间,默认为当前时间+10年 */ - end: { - type: [String, Number], - default: null, - }, - /** 列选项过滤函数,支持自定义列内容。(type 值可为: year, month, date, hour, minute, second) */ - customFilter: { - type: Function, - }, - /** 用于格式化 pick、change、confirm 事件返回的值,[详细文档](https://day.js.org/docs/en/display/format) */ - format: { - type: String, - default: 'YYYY-MM-DD HH:mm:ss', - }, - /**1 = year = 年;2 = month = 月;4 = date = 日;8 = hour = 时; 16 = minute = 分; 32 = second = 秒 */ - mode: { - type: [String, Number], - default: 1|2|4, - }, - /** 选择器的最小可选时间,默认为当前时间-10年 */ - start: { - type: [String, Number], - default: null, - }, - /** 时间间隔步数,示例:`{ minute: 5 }` */ - steps: { - type: Object, - }, - /** 标题 */ - title: { - type: String, - default: null, - }, - titleStyle: { - type: String, - default: null - }, - /** 选中值 */ - value: { - type: [String, Number], - default: null, - }, - /** 选中值,非受控属性 */ - defaultValue: { - type: [String, Number], - default: null, - }, - modelValue: { - type: [String, Number], - default: null - }, - itemHeight: { - type: String, - default: null - }, - itemColor: { - type: String, - default: null - }, - itemFontSize: { - type: String, - default: null - }, - itemActiveColor: { - type: String, - default: null - }, - - indicatorStyle: { - type: String, - default: null - }, - bgColor:{ - type: String, - default: null - }, - groupHeight:{ - type: String, - default: null - }, - radius:{ - type: String, - default: null - }, - renderLabel: { - type: Function, - default: null - }, - showUnit: { - type: Boolean, - default: true - }, - resetIndex: { - type: Boolean - }, - minHour: { - type: Number, - default: 0 - }, - maxHour: { - type: Number, - default: 23 - }, - minMinute: { - type: Number, - default: 0 - }, - maxMinute: { - type: Number, - default: 59 - }, - maskColors: { - type: Array, - } -} \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/components/l-date-time-picker/type.ts b/uni_modules/lime-date-time-picker/components/l-date-time-picker/type.ts deleted file mode 100644 index 3914dff..0000000 --- a/uni_modules/lime-date-time-picker/components/l-date-time-picker/type.ts +++ /dev/null @@ -1,67 +0,0 @@ -// @ts-nocheck -import type { PickerColumn, PickerColumnItem, PickerConfirmEvent, PickerPickEvent } from '@/uni_modules/lime-picker'; -export type TimeModeValues = 'year' | 'month' | 'date' | 'hour' | 'minute' | 'second'; -export type DateValue = string | number; -export type DateTimePickerColumn = PickerColumn//DateTimePickerColumnItem[]; - -export type DateTimePickerColumnItem = PickerColumnItem; - -export interface DateTimePickerProps { - /** 取消按钮文字 */ - cancelBtn?: string; - cancelStyle ?: string | UTSJSONObject; - /** 确定按钮文字 */ - confirmBtn?: string; - confirmStyle ?: string | UTSJSONObject; - /** 组件国际化语言,目前支持: 简体中文(zh)、(tc)、英文(en)、日语(ja)、朝鲜语(ko)、俄语(ru)等六种语言 */ - customLocale?: 'zh' | 'tc' | 'en' | 'ja' | 'ko' | 'ru'; - /** 选择器的最大可选时间,默认为当前时间+10年 */ - end?: DateValue;//string; - /** 选择器的最小可选时间,默认为当前时间-10年 */ - start?: DateValue; //string; - /** 时间间隔步数,示例:`{ minute: 5 }` */ - steps?: UTSJSONObject - /** 标题 */ - title?: string; - titleStyle ?: string | UTSJSONObject; - /** 选中值 */ - value?: DateValue; - defaultValue?: DateValue; - modelValue?: DateValue; - /* 用于格式化 pick、change、confirm 事件返回的值,[详细文档](https://day.js.org/docs/en/display/format) - */ - format: string; - /** - * 时间选择器的显示模式,可以是单个模式或多个模式的组合。 - * 使用位运算符来组合多个模式。 - * - * 例如: - * - 单个模式:1 - * - 多个模式组合:4 | 8 - * - 1 -> 年 | 2 -> 月 | 4 -> 日 | 8 -> 时 | 16 -> 分 | 32 -> 秒 - */ - mode: any//number - customFilter?: ((type: TimeModeValues, columns: DateTimePickerColumn) => DateTimePickerColumn); - /** - * 自定义label - */ - renderLabel?: ((type: string, value: string) => string); - showUnit: boolean; - - itemHeight?: string; - itemColor?: string; - itemFontSize?: string; - itemActiveColor?: string; - - indicatorStyle?: string; - maskColors?: string[]; - bgColor?:string; - groupHeight?:string; - radius?:string; - resetIndex: boolean - - minHour:number; - maxHour:number; - minMinute:number; - maxMinute:number; -} \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/components/l-date-time-picker/utils.ts b/uni_modules/lime-date-time-picker/components/l-date-time-picker/utils.ts deleted file mode 100644 index 1870761..0000000 --- a/uni_modules/lime-date-time-picker/components/l-date-time-picker/utils.ts +++ /dev/null @@ -1,89 +0,0 @@ -// @ts-nocheck -import type { TimeModeValues } from './type'; -import { MODE_NAMES, MODE_MAP, MODE_YEAR, MODE_MONTH, MODE_DATE, MODE_HOUR, MODE_MINUTE, MODE_SECOND } from './constant' - -export function coalesce(...values:(T|null)[]) : T | null { - for (let value of values) { - if(value == null) continue; - if(typeof value == 'string' && value == '') continue; - return value - } - return null -} -/** - * 根据给定的模式返回具有意义的时间列数组。 - * @param {number} mode - 表示时间模式的位掩码。 - * @returns {TimeModeValues[]} - 返回具有意义的时间列名称数组。 - */ -export function getMeaningColumn(mode : any) : TimeModeValues[] { - // 初始化结果数组 - const res : TimeModeValues[] = []; - - let _mode : number = 0; - if (typeof mode == 'string') { - // 处理字符串形式的位掩码 - if (mode.includes('|') && /\d/.test(mode)) { - // 如果是 "1|2|3" 这种格式,按位或运算 - const bits = mode.split('|').map((bit):number => parseInt(bit.trim())); - _mode = bits.reduce((result, bit) => result | bit, 0); - } else { - // 如果是模式名称字符串,如 "year-month-date" - MODE_MAP.forEach((value, key) => { - if ((mode as string).includes(key)) { - _mode = _mode | value; - } - }); - } - // MODE_MAP.forEach((value, key) => { - // console.log('key', key) - // if ((mode as string).includes(key)) { - // _mode = _mode | value; - // } - // }) - } else if (typeof mode == 'number') { - _mode = mode as number - } - - if (_mode <= 0) { - return res - } - - - // 定义对应的位掩码数组 - const modeBitmasks = [MODE_YEAR, MODE_MONTH, MODE_DATE, MODE_HOUR, MODE_MINUTE, MODE_SECOND]; - - // 查找被设置的位掩码 - const activeBitmasks = modeBitmasks.filter(bitmask => (_mode & bitmask) != 0); - - // 如果没有位掩码被设置,返回空数组 - if (activeBitmasks.length == 0) { - return []; - } - - // 初始化最长连续子序列和当前连续子序列 - let longestSequence : number[] = []; - let currentSequence : number[] = []; - - // 遍历所有被设置的位掩码 - activeBitmasks.forEach(bitmask => { - // 如果当前序列为空或当前位掩码是前一个位掩码的两倍,则将其加入当前序列 - if (currentSequence.length == 0 || bitmask == currentSequence[currentSequence.length - 1] * 2) { - currentSequence.push(bitmask); - } else { - // 如果当前序列长度大于最长序列长度,则更新最长序列 - if (currentSequence.length > longestSequence.length) { - longestSequence = currentSequence; - } - // 开始新的序列 - currentSequence = [bitmask]; - } - }); - - // 检查最后一个序列是否是最长的 - if (currentSequence.length > longestSequence.length) { - longestSequence = currentSequence; - } - - // 将最长连续子序列的位掩码转换为对应的模式名并返回 - return longestSequence.map(bitmask => MODE_NAMES[modeBitmasks.indexOf(bitmask)]); -} \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/components/lime-date-time-picker/lime-date-time-picker.uvue b/uni_modules/lime-date-time-picker/components/lime-date-time-picker/lime-date-time-picker.uvue deleted file mode 100644 index a946c9c..0000000 --- a/uni_modules/lime-date-time-picker/components/lime-date-time-picker/lime-date-time-picker.uvue +++ /dev/null @@ -1,205 +0,0 @@ - - - - - \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/components/lime-date-time-picker/lime-date-time-picker.vue b/uni_modules/lime-date-time-picker/components/lime-date-time-picker/lime-date-time-picker.vue deleted file mode 100644 index 89235f4..0000000 --- a/uni_modules/lime-date-time-picker/components/lime-date-time-picker/lime-date-time-picker.vue +++ /dev/null @@ -1,179 +0,0 @@ - - - - - \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/index.ts b/uni_modules/lime-date-time-picker/index.ts deleted file mode 100644 index 4aca69f..0000000 --- a/uni_modules/lime-date-time-picker/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -// @ts-nocheck -export * from './components/l-date-time-picker/type' \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/package.json b/uni_modules/lime-date-time-picker/package.json deleted file mode 100644 index 5beb932..0000000 --- a/uni_modules/lime-date-time-picker/package.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "id": "lime-date-time-picker", - "displayName": "lime-date-time-picker 时间选择器", - "version": "0.1.6", - "description": "lime-date-time-picker 用于选择时间,支持日期、时分等时间维度的时间选择,兼容uniapp/uniappx", - "keywords": [ - "date-time-picker", - "datetime-picker", - "时间选择", - "时间" -], - "repository": "", - "engines": { - "HBuilderX": "^4.42", - "uni-app": "^4.74", - "uni-app-x": "^4.75" - }, - "dcloudext": { - "type": "component-vue", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "", - "darkmode": "√", - "i18n": "x", - "widescreen": "x" - }, - "uni_modules": { - "dependencies": [ - "lime-picker", - "lime-dayuts", - "lime-shared" - ], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "x", - "aliyun": "x", - "alipay": "x" - }, - "client": { - "uni-app": { - "vue": { - "vue2": "√", - "vue3": "√" - }, - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "vue": "√", - "nvue": "-", - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√", - "alipay": "-", - "toutiao": "-", - "baidu": "-", - "kuaishou": "-", - "jd": "-", - "harmony": "-", - "qq": "-", - "lark": "-" - }, - "quickapp": { - "huawei": "-", - "union": "-" - } - }, - "uni-app-x": { - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√" - } - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/readme.md b/uni_modules/lime-date-time-picker/readme.md deleted file mode 100644 index 6331774..0000000 --- a/uni_modules/lime-date-time-picker/readme.md +++ /dev/null @@ -1,234 +0,0 @@ -# lime-date-time-picker 时间选择器 -一个功能丰富的时间选择器组件,用于选择时间,支持日期、时分等时间维度。 - -> 插件依赖:`lime-shared`、`lime-picker` - -## 文档链接 -📚 组件详细文档请访问以下站点: -- [时间选择器文档 - 站点1](https://limex.qcoon.cn/components/date-time-picker.html) -- [时间选择器文档 - 站点2](https://limeui.netlify.app/components/date-time-picker.html) -- [时间选择器文档 - 站点3](https://limeui.familyzone.top/components/date-time-picker.html) - -## 安装方法 -1. 在uni-app插件市场中搜索并导入`lime-date-time-picker` -2. 首次导入可能需要重新编译 - -## 代码演示 - -### 基础使用 -通过 `v-model` 绑定当前选中的日期,通过 `start` 和 `end` 属性来设定可选的时间范围。在实际场景中 通常搭配 [Popup](https://ext.dcloud.net.cn/plugin?id=20769)一起使用。 -```html - - -``` -```js -const value = ref('2024-05-02'); - -const onConfirm = (value: string) => { - console.log('onConfirm', value) -} -const onChange = (value: string) => { - console.log('onChange', value) -} - -``` - -### 类型选择 -通过 `mode` 属性可以控制选项的类型,它可以是number,也可以是中文或英文,支持以任意顺序对 `1 = 年 = year` 、 `2 = 月 = month` 、 `4 = 日 = date` 、 `8 = 时 = hour` 、 `16 = 分 = minute` 、 `32 = 秒 = second` 进行排列组合。 - -比如:
- -传入 `1` 来单独选择年份
。 -传入 `2` 来单独选择月份
。 -传入 `1|2` 来选择年份和月份,位运算结果:`3`传入`3`也可以
。 -传入 `2|4` 来选择月份和日期,位运算结果:`6`传入`6`也可以
。 -传入 `1|2|4` 来选择年月日,位运算结果:`7`传入`7`也可以
。 -传入 `4|8` 来选择日时,位运算结果:`12`传入`12`也可以
。 -传入 `8|16` 来选择时分,位运算结果:`24`传入`24`也可以
。 -传入 `8|16|32` 来选择时分秒,位运算结果:`56`传入`56`也可以
。 -传入 `1|2|4|8` 来选择年月日时,位运算结果:`15`传入`15`也可以
。 -传入 `1|2|4|8|16` 来选择年月日时分,位运算结果:`31`传入`31`也可以
。 -传入 `1|2|4|8|16|32` 来选择年月日时分秒,位运算结果:`63`传入`63`也可以
。 -任意组合,但必须是连续的。不能相隔即不能`日`和`分`这种组合,如果觉得数字不够直观,也可以直接写对应的中文或英文 -```html -// 数值 - - -//文本 - - -``` -```js -const value = ref('2024-05-02') -``` - - -### 自定义label -通过传入 `renderLabel` 函数,可以对选项文字进行格式化处理。 -```html - - -``` -```js -import type { TimeModeValues } from '@/uni_modules/lime-date-time-picker' -const renderLabel = (type: TimeModeValues, value: string): string => { - if(type == 'year') { - return `${value}年` - } - return value -} -``` - -### 过滤项 -通过传入 `customFilter` 函数,可以对选项数组进行过滤,实现自定义选项间隔。 -```html - - -``` -```js -import type { DateTimePickerColumn, TimeModeValues } from '@/uni_modules/lime-date-time-picker' -const filter = (type: TimeModeValues, columns: DateTimePickerColumn):DateTimePickerColumn => { - if (type == 'month') { - return columns.filter((option) => parseInt(option.value) % 6 == 0); - } - return columns -} -``` - - -## Vue2使用说明 -本插件使用了`composition-api`,请按照[官方教程](https://uniapp.dcloud.net.cn/tutorial/vue-composition-api.html)配置。 - -关键配置代码(在main.js中添加): -```js -// main.js -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -``` - -## 快速预览 -导入插件后,可以直接使用以下标签查看演示效果: - -```html - - -``` - -## 插件标签说明 -- `l-date-time-picker`:时间选择器组件 -- `lime-date-time-picker`:演示标签 - -## API文档 - -### Props - -| 参数 | 说明 | 类型 | 默认值 | -| --- | --- | --- | --- | -| v-model | 当前选中的日期 | string | - | -| value | 当前选中的日期 | string | - | -| start | 选择器的最小可选时间,默认为当前时间-10年 | string\|number | - | -| end | 选择器的最大可选时间,默认为当前时间+10年 | string\|number | - | -| format | 用于confirm事件参数格式化,详细[文档](https://ext.dcloud.net.cn/plugin?id=17301) | string | - | -| mode | 1=年、2=月、4=日、8=时、16=分、32=秒,任意组合 | string\|number | `1\|2\|4` | -| customFilter | 选项过滤函数(type可能值为year, month, day, hour, minute) | Function | - | -| renderLabel | 选项格式化函数(type可能值为year, month, day, hour, minute) | Function | - | -| showUnit | label后面是否显示单位 | boolean | `true` | -| minHour | 可选的最小小时 | number | `0` | -| maxHour | 可选的最大小时 | number | `23` | -| minMinute | 可选的最小分钟 | number | `0` | -| maxMinute | 可选的最大分钟 | number | `59` | -| cancelBtn | 取消按钮文字 | string | - | -| cancelStyle | 取消按钮样式 | string | - | -| confirmBtn | 确定按钮文字 | string | - | -| confirmStyle | 确定按钮样式 | string | - | -| title | 标题 | string | - | -| titleStyle | 标题样式 | string | - | -| itemHeight | 每项高度 | string | `50px` | -| itemColor | 每项文本颜色 | string | - | -| itemFontSize | 每项文本字体大小 | string | - | -| itemActiveColor | 每项文本选中颜色 | string | - | -| indicatorStyle | 选择器中间选中框的样式 | string | - | -| maskColors | 选择器遮罩颜色样式,`[开始颜色, 结束颜色]` | _string[]_ | `` | -| bgColor | 选择器背景色 | string | - | -| groupHeight | 选项组高度 | string | `400rpx` | -| radius | 圆角 | string | - | - -### Events - -| 事件名 | 说明 | 回调参数 | -| --- | --- | --- | -| cancel | 点击取消按钮时触发 | - | -| change | 选中变化时候触发 | value: string | -| confirm | 点击确认按钮时触发 | value: string | -| pick | 任何一列选中都会触发 | value: string | - -## 主题定制 - -组件提供了下列CSS变量,可用于自定义样式。 - -| 名称 | 默认值 | 描述 | -|--------|--------|------| -| `--l-picker-border-radius` | `$border-radius-xl` | 选择器整体圆角 | -| `--l-picker-bg-color` | `$bg-color-container` | 选择器背景色 | -| `--l-picker-toolbar-height` | `58px` | 工具栏高度 | -| `--l-picker-cancel-color` | `$text-color-2` | 取消按钮文字颜色 | -| `--l-picker-confirm-color` | `$primary-color` | 确认按钮文字颜色 | -| `--l-picker-button-font-size` | `$font-size-md` | 按钮文字大小 | -| `--l-picker-title-font-size` | `18px` | 标题文字大小 | -| `--l-picker-title-font-weight` | `700` | 标题文字粗细 | -| `--l-picker-title-line-height` | `26px` | 标题行高 | -| `--l-picker-title-color` | `$text-color-1` | 标题文字颜色 | -| `--l-picker-group-height` | `200px` | 选择器内容区高度 | -| `--l-picker-indicator-bg-color` | `$fill-4` | 选中指示器背景色 | -| `--l-picker-indicator-border-radius` | `6px` | 选中指示器圆角 | -| `--l-picker-item-height` | `50px` | 每个选项高度 | -| `--l-picker-item-color` | `$text-color-1` | 选项文字颜色 | -| `--l-picker-item-active-color` | `$text-color-1` | 选中项文字颜色 | -| `--l-picker-item-active-font-weight` | `700` | 选中项文字粗细 | -| `--l-picker-item-font-size` | `$font-size-md` | 选项文字大小 | -| `--l-picker-loading-mask-color` | `rgba(255,255,255,.9)` | 加载遮罩颜色 | -| `--l-picker-loading-color` | `$primary-color` | 加载动画颜色 | - -## 支持与赞赏 - -如果你觉得本插件解决了你的问题,可以考虑支持作者: -| 支付宝赞助 | 微信赞助 | -|------------|------------| -| ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) | ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) | \ No newline at end of file diff --git a/uni_modules/lime-date-time-picker/readme_old.md b/uni_modules/lime-date-time-picker/readme_old.md deleted file mode 100644 index c3c71bc..0000000 --- a/uni_modules/lime-date-time-picker/readme_old.md +++ /dev/null @@ -1,136 +0,0 @@ -# lime-date-time-picker 时间选择器 - -## 简介 -lime-date-time-picker是一个功能丰富的时间选择器组件,用于选择时间,支持日期、时分等时间维度。 - -> 插件依赖:`lime-shared`、`lime-picker` - -## 文档链接 -� 组件详细文档请访问以下站点: -- [时间选择器文档 - 站点1](https://limex.qcoon.cn/components/date-time-picker.html) -- [时间选择器文档 - 站点2](https://limeui.netlify.app/components/date-time-picker.html) -- [时间选择器文档 - 站点3](https://limeui.familyzone.top/components/date-time-picker.html) - -## 安装方法 -1. 在uni-app插件市场中搜索并导入`lime-date-time-picker` -2. 首次导入可能需要重新编译 - -## Vue2使用说明 -本插件使用了`composition-api`,请按照[官方教程](https://uniapp.dcloud.net.cn/tutorial/vue-composition-api.html)配置。 - -关键配置代码(在main.js中添加): -```js -// main.js -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -``` - -## 功能特点 - -### 基础使用 -通过 `v-model` 绑定当前选中的日期,通过 `start` 和 `end` 属性来设定可选的时间范围。在实际场景中通常搭配 [Popup](https://ext.dcloud.net.cn/plugin?id=20769)一起使用。 - -### 类型选择 -通过 `mode` 属性可以控制选项的类型,支持以任意顺序对年、月、日、时、分、秒进行排列组合: -- `1` = 年 = year -- `2` = 月 = month -- `4` = 日 = date -- `8` = 时 = hour -- `16` = 分 = minute -- `32` = 秒 = second - -### 自定义label -通过传入 `renderLabel` 函数,可以对选项文字进行格式化处理。 - -### 过滤项 -通过传入 `customFilter` 函数,可以对选项数组进行过滤,实现自定义选项间隔。 - -## 快速预览 -导入插件后,可以直接使用以下标签查看演示效果: - -```html - - -``` - -## 插件标签说明 -- `l-date-time-picker`:时间选择器组件 -- `lime-date-time-picker`:演示标签 - -## API文档 - -### Props - -| 参数 | 说明 | 类型 | 默认值 | -| --- | --- | --- | --- | -| v-model | 当前选中的日期 | string | - | -| value | 当前选中的日期 | string | - | -| start | 选择器的最小可选时间,默认为当前时间-10年 | string\|number | - | -| end | 选择器的最大可选时间,默认为当前时间+10年 | string\|number | - | -| format | 用于confirm事件参数格式化,详细[文档](https://ext.dcloud.net.cn/plugin?id=17301) | string | - | -| mode | 1=年、2=月、4=日、8=时、16=分、32=秒,任意组合 | string\|number | `1\|2\|4` | -| customFilter | 选项过滤函数(type可能值为year, month, day, hour, minute) | Function | - | -| renderLabel | 选项格式化函数(type可能值为year, month, day, hour, minute) | Function | - | -| showUnit | label后面是否显示单位 | boolean | `true` | -| minHour | 可选的最小小时 | number | `0` | -| maxHour | 可选的最大小时 | number | `23` | -| minMinute | 可选的最小分钟 | number | `0` | -| maxMinute | 可选的最大分钟 | number | `59` | -| cancelBtn | 取消按钮文字 | string | - | -| cancelStyle | 取消按钮样式 | string | - | -| confirmBtn | 确定按钮文字 | string | - | -| confirmStyle | 确定按钮样式 | string | - | -| title | 标题 | string | - | -| titleStyle | 标题样式 | string | - | -| itemHeight | 每项高度 | string | `50px` | -| itemColor | 每项文本颜色 | string | - | -| itemFontSize | 每项文本字体大小 | string | - | -| itemActiveColor | 每项文本选中颜色 | string | - | -| indicatorStyle | 选择器中间选中框的样式 | string | - | -| bgColor | 选择器背景色 | string | - | -| groupHeight | 选项组高度 | string | `400rpx` | -| radius | 圆角 | string | - | - -### Events - -| 事件名 | 说明 | 回调参数 | -| --- | --- | --- | -| cancel | 点击取消按钮时触发 | - | -| change | 选中变化时候触发 | value: string | -| confirm | 点击确认按钮时触发 | value: string | -| pick | 任何一列选中都会触发 | value: string | - -## 主题定制 - -### 样式变量 - -组件提供了下列CSS变量,可用于自定义样式,uvue app无效。 - -| 名称 | 默认值 | 描述 | -| --- | --- | --- | -| --l-picker-border-radius | 24rpx | - | -| --l-picker-bg-color | $bg-color-container | - | -| --l-picker-toolbar-height | 116rpx | - | -| --l-picker-cancel-color | text-color-2 | - | -| --l-picker-confirm-color | $primary-color | - | -| --l-picker-button-font-size | 32rpx | - | -| --l-picker-title-font-size | 36rpx | - | -| --l-picker-title-font-weight | 700 | - | -| --l-picker-title-line-height | 52rpx | - | -| --l-picker-title-color | $text-color-1 | - | -| --l-picker-group-height | 400rpx | - | -| --l-picker-indicator-bg-color | $fill-4 | - | -| --l-picker-indicator-border-radius | 12rpx | - | -| --l-picker-item-height | 50px | - | -| --l-picker-item-color | $text-color-1 | - | -| --l-picker-item-active-color | $text-color-1 | - | -| --l-picker-loading-mask-color | rgba(255,255,255,.9) | - | -| --l-picker-item-font-size | $font-size-md | - | - -## 支持与赞赏 - -如果您觉得本插件对您有帮助,欢迎赞赏支持: - -![支付宝](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) -![微信](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) \ No newline at end of file diff --git a/uni_modules/lime-dayuts/changelog.md b/uni_modules/lime-dayuts/changelog.md deleted file mode 100644 index e51b01f..0000000 --- a/uni_modules/lime-dayuts/changelog.md +++ /dev/null @@ -1,43 +0,0 @@ -## 2.0.0(2026-09-01) -- feat: 文档全面重构,符合插件文档规范 -- feat: 完善 API 文档,按功能分类组织(解析、取值/赋值、操作、显示、查询、相对时间、国际化) -- feat: 补充格式化占位符说明(含 `S`、`SS`、`ZZ` 等) -- feat: 新增时间单位速查表 -- feat: 新增注意事项章节,说明与 dayjs 的差异和平台差异 -- docs: 优化代码演示,按基础→进阶组织 -- docs: 完善国际化章节,说明 locale 配置和使用方式 -## 0.1.7(2026-04-27) -- fix: 修复纯数字字符转换问题 -## 0.1.6(2025-08-31) -- chore: 更新文档 -## 0.1.5(2025-06-01) -- feat: 支持传入纯数字的日期 -## 0.1.4(2025-05-22) -- fix: 修复uniapp x 缺少类型问题 -## 0.1.3(2025-04-24) -- fix: 修复uniapp v2 app 导出类型问题 -## 0.1.2(2025-04-24) -- fix: 修复uniapp v2 app报错的问题 -## 0.1.1(2025-04-22) -- fix: 修复uniapp app报错的问题 -- feat: 兼容uniappx 鸿蒙next -## 0.1.0(2025-04-16) -- fix: 修复locale en缺少`DayutsRelativeTime` -## 0.0.9(2025-03-05) -- fix: 修复uniappx ios interface引入问题 -## 0.0.8(2025-01-06) -- fix: 修复uniapp app报错的问题 -## 0.0.7(2024-12-27) -- feat: 支持`hbx4.42` -## 0.0.6(2024-06-19) -- feat: 支持`uniapp` -## 0.0.5(2024-05-02) -- fix: 修复因安卓 `字面量 === 字面量`为`false`导致加减等操作不起作用。 -## 0.0.4(2024-04-19) -- fix: 修复`parseDate`数组长度判断时报错 -## 0.0.3(2024-04-02) -- fix: 因多写f导致运行不起来 -## 0.0.2(2024-04-01) -- chore: 兼容uniapp x ios(app-js) -## 0.0.1(2024-03-30) -- init diff --git a/uni_modules/lime-dayuts/common/constant.ts b/uni_modules/lime-dayuts/common/constant.ts deleted file mode 100644 index bc31bba..0000000 --- a/uni_modules/lime-dayuts/common/constant.ts +++ /dev/null @@ -1,32 +0,0 @@ -// @ts-nocheck -export const SECONDS_A_MINUTE = 60 -export const SECONDS_A_HOUR = SECONDS_A_MINUTE * 60 -export const SECONDS_A_DAY = SECONDS_A_HOUR * 24 -export const SECONDS_A_WEEK = SECONDS_A_DAY * 7 - -export const MILLISECONDS_A_SECOND = 1e3 -export const MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND -export const MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND -export const MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND -export const MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND - -// English locales -export const MS = 'millisecond' -export const S = 'second' -export const MIN = 'minute' -export const H = 'hour' -export const D = 'day' -export const W = 'week' -export const M = 'month' -export const Q = 'quarter' -export const Y = 'year' -export const DATE = 'date' - -export const FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ssZ' - -export const INVALID_DATE_STRING = 'Invalid Date' - -// regex -export const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/ -export const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g -// export const REGEX_FORMAT = /(?:[^\]]+)|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g; diff --git a/uni_modules/lime-dayuts/common/dates.ts b/uni_modules/lime-dayuts/common/dates.ts deleted file mode 100644 index 080a1d3..0000000 --- a/uni_modules/lime-dayuts/common/dates.ts +++ /dev/null @@ -1,194 +0,0 @@ -// @ts-nocheck -import {dayuts, Dayuts} from "./index" -// import {DayutsConfig} from '../../types/date.uts' -import { DayutsConfig } from '../utssdk/interface' -export class Dates { - - /** - * Dayuts实例 - */ - newDate() : Dayuts; - newDate(date : string) : Dayuts; - newDate(date : any[]) : Dayuts; - newDate(date : number) : Dayuts; - newDate(date : UTSJSONObject) : Dayuts; - newDate(date : Date) : Dayuts; - newDate(date : Dayuts) : Dayuts; - // #ifndef UNI-APP-X && APP - newDate(date : any | null, format : string) : Dayuts; - newDate(date : any | null, format : string | null, locale : string | null) : Dayuts; - // #endif - newDate(date : any | null = null, format : string | null = null, locale : string | null = null) : Dayuts { - if (date != null && date instanceof Dayuts) return date.clone() - return new Dayuts({ - date, - format, - locale - } as DayutsConfig) - } - - /** - * 万能转日期对象 - * @param date 时间 - */ - toDate(date : string) : Date { - date = date.split('周')[0].trim().split('星期')[0].trim().split('礼拜')[0].trim() - - if (date == '') { - return new Date() - } - - if (date.length >= 10 && /^\d+$/.test(date)) { - // 时间戳 - let timestamp = parseInt(date) - - // 若为unix秒时间戳,则转为毫秒时间戳 - if (/^\d{10}$/.test(timestamp.toString())) { - return new Date(timestamp * 1000) - } else { - return new Date(timestamp) - } - } else { - if (!date.includes('T')) { - // 容错 - date = date.replace(/\//g, '-'). - replace(/年/g, '-'). - replace(/月/g, '-'). - replace(/日/g, ''). - replace(/时/g, ':'). - replace(/分/g, ':'). - replace(/秒/g, ''). - replace(/^-+|-+$/g, ''). - trim() - - // 补全 - if (date.length == 4) { - date += '-01-01 00:00:00' - } else if (date.length == 7) { - date += '-01 00:00:00' - } else if (date.length == 8) { - date = `${this.today()} ${date}` - } else if (date.length == 10) { - date += ' 00:00:00' - } else if (date.length == 13) { - date += ':00:00' - } else if (date.length == 16) { - date += ':00' - } - - let d = date.split(/[^0-9]/) - - try{ - return new Date(parseInt(d[0]), parseInt(d[1]) - 1, parseInt(d[2]), parseInt(d[3]), parseInt(d[4]), parseInt(d[5])) - }catch(e){ - console.error(`[ux-date]解析失败:${date}`) - return new Date() - } - - } else { - return new Date(date) - } - } - } - - /** - * 万能格式化日期 - * @param date 时间 - * @param format 格式化规则 支持yyyy-MM-dd|yyyy-MM-dd HH:mm:ss|yyyy/MM/dd|yyyy/MM/dd HH:mm:ss|yyyy年MM月dd日等组合 默认yyyy-mm-dd - */ - fmtDate(date : string, format : string) : string { - if(format == '') { - format = 'yyyy-MM-dd' - } - - date = date.split('周')[0].trim().split('星期')[0].trim().split('礼拜')[0].trim() - - let d = this.toDate(date) - - let timeSource = new Map() - timeSource.set('y', d.getFullYear().toString()) - timeSource.set('M', (d.getMonth() + 1).toString().padStart(2, '0')) - timeSource.set('d', d.getDate().toString().padStart(2, '0')) - timeSource.set('H', d.getHours().toString().padStart(2, '0')) - timeSource.set('m', d.getMinutes().toString().padStart(2, '0')) - timeSource.set('s', d.getSeconds().toString().padStart(2, '0')) - - let result = format.split('周')[0].trim().split('星期')[0].trim().split('礼拜')[0].trim() - timeSource.forEach((v : string, key : string) => { - const rets = new RegExp(`${key}+`).exec(result) ?? [] as RegExp[] - if (rets.length > 0) { - result = result.replace(rets[0].toString(), v) - } - }) - - let fmtWeek = format.indexOf('周') != -1 || format.indexOf('星期') != -1 || format.indexOf('礼拜') != -1 - if(fmtWeek) { - result += ` ${this.weekName(this.toDate(result).getDay(), format)}` - } - - return result - } - - /** - * 现在 yyyy-MM-dd HH:mm:ss - */ - now() : string { - let date = new Date() - - let year = date.getFullYear() - let month = `${date.getMonth() + 1}`.padStart(2, '0') - let day = `${date.getDate()}`.padStart(2, '0') - let hour = `${date.getHours()}`.padStart(2, '0') - let minute = `${date.getMinutes()}`.padStart(2, '0') - let second = `${date.getSeconds()}`.padStart(2, '0') - - return `${year}-${month}-${day} ${hour}:${minute}:${second}` - } - - /** - * 今天 - * @param n n为负则代表取前n天,为正则代表取后n天,0则为今天 - */ - today(n : number = 0) : string { - let date = new Date() - date.setDate(date.getDate() + n) - - let year = date.getFullYear() - let month = `${date.getMonth() + 1}`.padStart(2, '0') - let day = `${date.getDate()}`.padStart(2, '0') - - return `${year}-${month}-${day}` - } - - /** - * 本周所有日期 - */ - weeks() : string[] { - const fDate = new Date() - const eDate = new Date() - fDate.setDate(fDate.getDate() - fDate.getDay() + 1) - eDate.setDate(eDate.getDate() - eDate.getDay() + 7) - - const result : string[] = [] - - for (let d = fDate; d.getTime() <= eDate.getTime(); d.setDate(d.getDate() + 1)) { - result.push(d.toISOString().slice(0, 10)) - } - - return result; - } - - /** - * 周几 - */ - weekName(day: number, format: string) : string { - if(format.indexOf('星期') != -1) { - return ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][day] - } else if(format.indexOf('礼拜') != -1 ) { - return ['礼拜天', '礼拜一', '礼拜二', '礼拜三', '礼拜四', '礼拜五', '礼拜六'][day] - } else { - return ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][day] - } - } - -} \ No newline at end of file diff --git a/uni_modules/lime-dayuts/common/index.ts b/uni_modules/lime-dayuts/common/index.ts deleted file mode 100644 index 67121a0..0000000 --- a/uni_modules/lime-dayuts/common/index.ts +++ /dev/null @@ -1,1104 +0,0 @@ -// @ts-nocheck -import { DayutsConfig, type DayutsLocale, DayutsUnit, DayutsObject } from '../utssdk/interface' -import { REGEX_FORMAT, REGEX_PARSE, INVALID_DATE_STRING, M, Y, W, D, DATE, H, MIN, S, MS, Q, MILLISECONDS_A_MINUTE, MILLISECONDS_A_HOUR, MILLISECONDS_A_SECOND, MILLISECONDS_A_WEEK, MILLISECONDS_A_DAY, FORMAT_DEFAULT } from './constant' -import { isNumber, prettyUnit, padStart, padZoneStr, monthDiff, absFloor } from './utils' -import { dayutsIntl, localeState } from './use' - -type Threshold = { - l : string; - r ?: number; - d ?: DayutsUnit; -} - -function parseLocale(preset : string | null) : string | null; -function parseLocale(preset : DayutsLocale | null) : string | null; -function parseLocale(preset : string, object : DayutsLocale | null, isLocal : boolean) : string | null; -function parseLocale(preset : DayutsLocale, object : DayutsLocale, isLocal : boolean) : string | null; -function parseLocale(preset : any | null, object : DayutsLocale | null = null, isLocal : boolean = false) : string | null { - let l : string | null = null - if (preset == null) return dayutsIntl.locale - if (typeof preset == 'string') { - - const presetLower = (preset as string).toLowerCase() - if (dayutsIntl.has(presetLower)) { - l = presetLower - } - if (object != null) { - dayutsIntl.set(presetLower, object) - l = presetLower - } - const presetSplit = preset.split('-') - if (l == null && presetSplit.length > 1) { - return parseLocale(presetSplit[0]) - } - } else if (preset instanceof DayutsLocale) { - // const { name } = preset as DayutsLocale - dayutsIntl.set(preset.name, preset) - l = preset.name - } - if (!isLocal && l != null) { - // L = l - dayutsIntl.locale = l - } - // return l ?? L //(!isLocal && L != null) - return l ?? dayutsIntl.locale //(!isLocal && L != null) -} - -function tryParseNumberAtIndex(digits : (any|null)[], index : number) : number | null { - // 检查索引是否在数组范围内 - if (index >= 0 && index < digits.length) { - if(digits[index] == null) return null - // 尝试解析索引位置的字符串为数字 - const parsedNumber = isNumber(digits[index]) ? digits[index] as number : parseInt(`${digits[index]}`, 10); - - // 检查解析结果是否为有效数字 - if (!isNaN(parsedNumber)) { - return parsedNumber; - } - } - return null -} -// function createDateFromArray(d: number[]):Date -// function createDateFromArray(d: string[]):Date -function createDateFromArray(d : (any|null)[], offset : number = 0) : Date { - const year = tryParseNumberAtIndex(d, 1 - offset) ?? new Date().getFullYear() - const month = (tryParseNumberAtIndex(d, 2 - offset) ?? 1) - 1 - const day = tryParseNumberAtIndex(d, 3 - offset) ?? 1 - const hour = tryParseNumberAtIndex(d, 4 - offset) ?? 0 - const minute = tryParseNumberAtIndex(d, 5 - offset) ?? 0 - const second = tryParseNumberAtIndex(d, 6 - offset) ?? 0 - const millisecond = (tryParseNumberAtIndex(d, 7 - offset) ?? 0).toString().substring(0, 3) //d.length > 7 ? parseInt((d[7] ?? '0').substring(0, 3)) : 0 - - return new Date( - year, - month, - day, - hour, - minute, - second, - parseInt(millisecond)) -} -function parseDate(cfg : DayutsConfig) : Date|null { - const { date } = cfg - if (date == null) return new Date() - if (date instanceof Date) return date as Date - - try { - // if (typeof date == 'string' && /^\d+$/.test(date as string)) { - // return new Date(parseInt(`${date}`.padEnd(13, '0'))) - // } - if (typeof date == 'string' && !/Z$/i.test(date as string)) { - const d = date.match(REGEX_PARSE) - // #ifndef APP-ANDROID || APP-IOS - const isNull = d == null - // #endif - // #ifdef APP-ANDROID || APP-IOS - const isNull = d == null|| Array.isArray(d) && d.length == 0 - // #endif - if (!isNull) { - return createDateFromArray(d as (any|null)[]) - } - } - if (typeof date == 'string') return new Date(date as string) - if (Array.isArray(date)) { - return createDateFromArray(date as (any|null)[], 1) - } - if (isNumber(date)) return new Date(date as number) - return null//new Date() - } catch(err) { - return null//new Date() - } -} - -function wrapper(date : any, instance : Dayuts) : Dayuts { - return dayuts(date, instance.$L) -} - -export class Dayuts { - $L : string - private valid: boolean = true; - private $d : Date = new Date() - private $y : number = 0 - private $M : number = 0 - private $D : number = 0 - private $W : number = 0 - private $H : number = 0 - private $m : number = 0 - private $s : number = 0 - private $ms : number = 0 - private $u : boolean = false - constructor(cfg : DayutsConfig) { - this.$L = parseLocale(cfg.locale) ?? dayutsIntl.locale //'en' - this.parse(cfg) - } - parse(cfg : DayutsConfig) { - const _d = parseDate(cfg) - if(_d != null) { - this.$d = parseDate(cfg)! - this.init() - } else { - this.valid = false - } - } - init() { - const { $d } = this - this.$y = $d.getFullYear() - this.$M = $d.getMonth() - this.$D = $d.getDate() - this.$W = $d.getDay() - this.$H = $d.getHours() - this.$m = $d.getMinutes() - this.$s = $d.getSeconds() - this.$ms = $d.getMilliseconds() - } - /** - * 检查日期对象是否有效。 - * - * @returns {boolean} 如果日期对象有效,则返回true;否则返回false。 - */ - isValid() : boolean { - return this.valid - // return !(this.$d.toString() == INVALID_DATE_STRING) - } - /** - * 检查当前日期是否与给定的日期在指定的时间单位内相同。 - * - * @param {string|number|Date} input - 要比较的日期。 - * @param {string} units - 时间单位,例如'year'、'month'、'day'等。 - * @returns {boolean} 如果当前日期与给定的日期在指定的时间单位内相同,则返回true;否则返回false。 - */ - isSame(input : string) : boolean - isSame(input : number) : boolean - isSame(input : Date) : boolean - isSame(input : Dayuts) : boolean - isSame(input : UTSJSONObject) : boolean - - isSame(input : string, units : DayutsUnit) : boolean - isSame(input : number, units : DayutsUnit) : boolean - isSame(input : Date, units : DayutsUnit) : boolean - isSame(input : Dayuts, units : DayutsUnit) : boolean - isSame(input : UTSJSONObject, units : DayutsUnit) : boolean - isSame(input : any, units : DayutsUnit = 'millisecond') : boolean { - const other = input instanceof Dayuts ? input : dayuts(input) - const date1 = this.startOf(units).valueOf() - const date2 = other.valueOf() - const date3 = this.endOf(units).valueOf() - return date1 <= date2 && date2 <= date3 - } - /** - * 检查给定的日期或时间是否在当前 dayuts 对象的指定时间单位之后。 - * - * @param {string | number | Date | Dayuts} input - 要与当前 dayuts 对象进行比较的日期或时间。 - * @param {string} units - 要比较的时间单位(如 "year"、"month"、"day" 等)。 - * @returns {boolean} 如果给定的日期或时间在当前 dayuts 对象的指定时间单位之后,则返回 `true`,否则返回 `false`。 - */ - isAfter(input : string) : boolean - isAfter(input : number) : boolean - isAfter(input : Date) : boolean - isAfter(input : Dayuts) : boolean - isAfter(input : UTSJSONObject) : boolean - - isAfter(input : string, units : DayutsUnit) : boolean - isAfter(input : number, units : DayutsUnit) : boolean - isAfter(input : Date, units : DayutsUnit) : boolean - isAfter(input : Dayuts, units : DayutsUnit) : boolean - isAfter(input : UTSJSONObject, units : DayutsUnit) : boolean - isAfter(input : any, units : DayutsUnit = 'millisecond') : boolean { - const other = input instanceof Dayuts ? input : dayuts(input) - const date1 = other.valueOf() - const date2 = this.startOf(units).valueOf() - return date1 < date2; - } - /** - * 检查给定的日期或时间是否在当前 dayuts 对象的指定时间单位之前。 - * - * @param {string | number | Date | Dayuts} input - 要与当前 dayuts 对象进行比较的日期或时间。 - * @param {string} units - 要比较的时间单位(如 "year"、"month"、"day" 等)。 - * @returns {boolean} 如果给定的日期或时间在当前 dayuts 对象的指定时间单位之前,则返回 `true`,否则返回 `false`。 - */ - isBefore(input : string) : boolean - isBefore(input : number) : boolean - isBefore(input : Date) : boolean - isBefore(input : Dayuts) : boolean - isBefore(input : UTSJSONObject) : boolean - - isBefore(input : string, units : DayutsUnit) : boolean - isBefore(input : number, units : DayutsUnit) : boolean - isBefore(input : Date, units : DayutsUnit) : boolean - isBefore(input : Dayuts, units : DayutsUnit) : boolean - isBefore(input : UTSJSONObject, units : DayutsUnit) : boolean - isBefore(input : any, units : DayutsUnit = 'millisecond') : boolean { - const other = input instanceof Dayuts ? input : dayuts(input); - const date1 = other.valueOf() - const date2 = this.endOf(units).valueOf() - return date2 < date1; - } - /** - * 判断当前Dayuts对象是否与给定的输入在同一时间或之前,根据指定的时间单位 - * @param {(string | number | Date | Dayuts | UTSJSONObject)} input - 输入的时间 - * @param {DayutsUnit} units - 指定的时间单位 - * @returns {boolean} - 如果当前Dayuts对象与给定的输入在同一时间或之前,则返回true,否则返回false - */ - isSameOrBefore(input : string) : boolean - isSameOrBefore(input : number) : boolean - isSameOrBefore(input : Date) : boolean - isSameOrBefore(input : Dayuts) : boolean - isSameOrBefore(input : UTSJSONObject) : boolean - - isSameOrBefore(input : string, units : DayutsUnit) : boolean - isSameOrBefore(input : number, units : DayutsUnit) : boolean - isSameOrBefore(input : Date, units : DayutsUnit) : boolean - isSameOrBefore(input : Dayuts, units : DayutsUnit) : boolean - isSameOrBefore(input : UTSJSONObject, units : DayutsUnit) : boolean - isSameOrBefore(input : any, units : DayutsUnit = 'millisecond') : boolean { - return this.isSame(input, units) || this.isBefore(input, units) - } - /** - * 判断当前Dayuts对象是否与给定的输入在同一时间或之后,根据指定的时间单位 - * @param {(string | number | Date | Dayuts | UTSJSONObject)} input - 输入的时间 - * @param {DayutsUnit} units - 指定的时间单位 - * @returns {boolean} - 如果当前Dayuts对象与给定的输入在同一时间或之后,则返回true,否则返回false - */ - isSameOrAfter(input : string) : boolean - isSameOrAfter(input : number) : boolean - isSameOrAfter(input : Date) : boolean - isSameOrAfter(input : Dayuts) : boolean - isSameOrAfter(input : UTSJSONObject) : boolean - - isSameOrAfter(input : string, units : DayutsUnit) : boolean - isSameOrAfter(input : number, units : DayutsUnit) : boolean - isSameOrAfter(input : Date, units : DayutsUnit) : boolean - isSameOrAfter(input : Dayuts, units : DayutsUnit) : boolean - isSameOrAfter(input : UTSJSONObject, units : DayutsUnit) : boolean - isSameOrAfter(input : any, units : DayutsUnit = 'millisecond') : boolean { - return this.isSame(input, units) || this.isAfter(input, units) - } - /** - * 判断当前Dayuts对象是否在给定的两个时间之间 - * @param {any} input - 第一个时间输入 - * @param {any} input2 - 第二个时间输入 - * @param {DayutsUnit} units - 指定的时间单位 - * @param {string} interval - 区间符号,表示区间的开闭性,默认为'()',表示开区间 - * @returns {boolean} - 如果当前Dayuts对象在给定的两个时间之间,则返回true,否则返回false - */ - isBetween(input : any, input2 : any, units : DayutsUnit = 'millisecond', interval : string = '()') : boolean { - const dA = dayuts(input) - const dB = dayuts(input2) - const dAi = interval.startsWith('(') - const dBi = interval.endsWith(')') - - return ((dAi ? this.isAfter(dA, units) : !this.isBefore(dA, units)) && - (dBi ? this.isBefore(dB, units) : !this.isAfter(dB, units))) - || ((dAi ? this.isBefore(dA, units) : !this.isAfter(dA, units)) && - (dBi ? this.isAfter(dB, units) : !this.isBefore(dB, units))) - } - /** - * 判断当前Dayuts对象所在的年份是否为闰年 - * @returns {boolean} - 如果当前Dayuts对象所在的年份是闰年,则返回true,否则返回false - */ - isLeapYear():boolean{ - return ((this.$y % 4 == 0) && (this.$y % 100 != 0)) || (this.$y % 400 == 0) - } - isToday():boolean{ - const comparisonTemplate = 'YYYY-MM-DD' - const now = dayuts() - - return this.format(comparisonTemplate) == now.format(comparisonTemplate) - } - /** - * 获取当前 `dayuts` 对象的 Unix 时间戳(以秒为单位)。 - * - * @returns {number} 返回当前 `dayuts` 对象的 Unix 时间戳(以秒为单位)。 - */ - unix() : number { - return Math.floor(this.valueOf() / 1000); - } - /** - * 将当前日期设置为指定时间单位的开始或结束。 - * - * @param {string} units - 时间单位,例如'year'、'month'、'day'等。 - * @param {boolean} startOf - 如果为true,则设置为开始;如果为false,则设置为结束。 - * @returns {Dayuts} 返回一个新的Dayuts对象,表示调整后的日期。 - */ - startOf(units : DayutsUnit, startOf : boolean = true) : Dayuts { - const isStartOf = startOf; - const unit = prettyUnit(units) - // instanceFactory 函数用于创建一个新的 Dayuts 对象,表示给定日期的开始或结束。 - // 参数 d 和 m 分别表示日期和月份。 - const instanceFactory = (d : number, m : number) : Dayuts => { - const ins = dayuts(new Date(this.$y, m, d)) - return isStartOf ? ins : ins.endOf(D) - } - - // instanceFactorySet 函数用于创建一个新的 Dayuts 对象,表示调整后的时间。 - // 参数 method 表示要调用的 Date 对象的方法(如 'setHours'),slice 表示要调整的时间部分的索引。 - const instanceFactorySet = (method : string, slice : number) : Dayuts => { - // 定义表示开始和结束时间的参数数组。 - const argumentStart = [0, 0, 0, 0] - const argumentEnd = [23, 59, 59, 999] - // 根据 isStartOf 的值,选择开始或结束时间的参数数组,并调用 Date 对象的方法。 - const args = (isStartOf ? argumentStart : argumentEnd).slice(slice) - const date = this.toDate() - if (method == 'setHours') { - date.setHours(args[0]); - date.setMinutes(args[1]) - date.setSeconds(args[2]) - date.setMilliseconds(args[3]) - } else if (method == 'setMinutes') { - date.setMinutes(args[0]); - date.setSeconds(args[1]) - date.setMilliseconds(args[2]) - } else if (method == 'setSeconds') { - date.setSeconds(args[0]) - date.setMilliseconds(args[1]) - } else if (method == 'setMilliseconds') { - date.setMilliseconds(args[0]) - } - return dayuts(date) - } - const { $W, $M, $D } = this - const utcPad = `set${this.$u ? 'UTC' : ''}` - if (unit == Y) { - return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11); - } else if (unit == M) { - return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1); - } else if (unit == W) { - const weekStart = this.$locale().weekStart ?? 0; - const gap = ($W < weekStart ? $W + 7 : $W) - weekStart; - return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M); - } else if (unit == D || unit == DATE) { - return instanceFactorySet(`${utcPad}Hours`, 0); - } else if (unit == H) { - return instanceFactorySet(`${utcPad}Minutes`, 1); - } else if (unit == MIN) { - return instanceFactorySet(`${utcPad}Seconds`, 2); - } else if (unit == S) { - return instanceFactorySet(`${utcPad}Milliseconds`, 3); - } else { - return this.clone(); - } - } - /** - * 将当前日期设置为指定时间单位的结束。 - * - * @param {string} arg - 时间单位,例如'year'、'month'、'day'等。 - * @returns {Dayuts} 返回一个新的Dayuts对象,表示调整后的日期。 - */ - endOf(units : DayutsUnit) : Dayuts { - return this.startOf(units, false) - } - /** - * 设置指定的时间单位的值。 - * - * @param {string} units - 要设置的时间单位(如 "year"、"month"、"day" 等)。 - * @param {number} int - 要设置的值。 - * @returns {Dayuts} 返回当前对象。 - */ - private $set(units : DayutsUnit, int : number) : Dayuts { // private set - const unit = prettyUnit(units) - // const utcPad = `set${this.$u ? 'UTC' : ''}` - const arg = unit == D ? this.$D + (int - this.$W) : int - const setDateUnit = (date : Dayuts, unit : DayutsUnit, arg : number) => { - if (unit == D || unit == DATE) { - date.$d.setDate(arg); - } else if (unit == M) { - date.$d.setMonth(arg); - } else if (unit == Y) { - date.$d.setFullYear(arg); - } else if (unit == H) { - date.$d.setHours(arg); - } else if (unit == MIN) { - date.$d.setMinutes(arg); - } else if (unit == S) { - date.$d.setSeconds(arg); - } else if (unit == MS) { - date.$d.setMilliseconds(arg); - } - } - if (unit == M || unit == Y) { - // clone is for badMutable plugin - const date = this.clone().set(DATE, 1) - // date.$d[name](arg) - setDateUnit(date, unit, arg) - date.init() - this.$d = date.set(DATE, Math.min(this.$D, date.daysInMonth())).$d - } else { - setDateUnit(this, unit, arg) - // this.$d[name](arg) - } - - this.init() - return this - } - /** - * 创建一个当前对象的副本,并设置指定的时间单位的值。 - * - * @param {string} string - 要设置的时间单位(如 "year"、"month"、"day" 等)。 - * @param {number} int - 要设置的值。 - * @returns {Dayuts} 返回一个新的 `dayuts` 对象,其值为当前对象的副本,并设置了指定的时间单位的值。 - */ - set(string : DayutsUnit, int : number) : Dayuts { - return this.clone().$set(string, int); - } - /** - * 获取当前 `dayuts` 对象的指定时间单位的值。 - * - * @param {string} units - 要获取的时间单位(如 "year"、"month"、"day" 等)。 - * @returns {number} 返回当前 `dayuts` 对象的指定时间单位的值。 - */ - get(units : DayutsUnit) : number { - const unit = prettyUnit(units) - if (unit == D) { - return this.day() - } else if (unit == DATE) { - return this.date() - } else if (unit == M) { - return this.month() - } else if (unit == Y) { - return this.year() - } else if (unit == H) { - return this.hour() - } else if (unit == MIN) { - return this.minute() - } else if (unit == S) { - return this.second() - } else if (unit == MS) { - return this.millisecond() - } - return 0 - } - /** - * 获取或设置年份。 - * @param {number | null} [input] - 要设置的年份。 - * @returns {number | Dayuts} 年份或 Dayuts 实例。 - */ - year() : number - year(input : number) : Dayuts - year(input : number | null = null) : any { - if (input == null) return this.$y - return this.set(Y, input) - } - /** - * 获取或设置月份。 - * @param {number | null} [input] - 要设置的月份(0-11)。 - * @returns {number | Dayuts} 月份或 Dayuts 实例。 - */ - month() : number - month(input : number) : Dayuts - month(input : number | null = null) : any { - if (input == null) return this.$M - return this.set(M, input) - } - /** - * 获取或设置星期几。 - * @param {number | null} [input] - 要设置的星期几(0-6)。 - * @returns {number | Dayuts} 星期几或 Dayuts 实例。 - */ - day() : number - day(input : number) : Dayuts - day(input : number | null = null) : any { - if (input == null) return this.$W - return this.set(D, input) - } - /** - * 获取或设置月份中的某一天。 - * @param {number | null} [input] - 要设置的月份中的某一天(1-31)。 - * @returns {number | Dayuts} 月份中的某一天或 Dayuts 实例。 - */ - date() : number - date(input : number) : Dayuts - date(input : number | null = null) : any { - if (input == null) return this.$D - return this.set(DATE, input) - } - /** - * 获取或设置小时。 - * @param {number | null} [input] - 要设置的小时(0-23)。 - * @returns {number | Dayuts} 小时或 Dayuts 实例。 - */ - hour() : number - hour(input : number) : Dayuts - hour(input : number | null = null) : any { - if (input == null) return this.$H - return this.set(H, input) - } - /** - * 获取或设置分钟。 - * @param {number | null} [input] - 要设置的分钟(0-59)。 - * @returns {number | Dayuts} 分钟或 Dayuts 实例。 - */ - minute() : number - minute(input : number) : Dayuts - minute(input : number | null = null) : any { - if (input == null) return this.$m - return this.set(MIN, input) - } - /** - * 获取或设置秒。 - * @param {number | null} [input] - 要设置的秒(0-59)。 - * @returns {number | Dayuts} 秒或 Dayuts 实例。 - */ - second() : number - second(input : number) : Dayuts - second(input : number | null = null) : any { - if (input == null) return this.$s - return this.set(S, input) - } - /** - * 获取或设置毫秒。 - * @param {number | null} [input] - 要设置的毫秒(0-999)。 - * @returns {number | Dayuts} 毫秒或 Dayuts 实例。 - */ - millisecond() : number - millisecond(input : number) : Dayuts - millisecond(input : number | null = null) : any { - if (input == null) return this.$ms - return this.set(MS, input) - } - - /** - * 在当前 Dayuts 实例上添加指定的时间长度。 - * @param {number} number - 要添加的时间长度。 - * @param {string} units - 要添加的时间单位(例如,“years”,“months”,“days”等)。 - * @returns {Dayuts} 更新的 Dayuts 实例。 - */ - add(number : number, units : DayutsUnit) : Dayuts { - const unit = prettyUnit(units) - // 创建一个新的 Dayuts 实例,并根据给定的 n 值设置日期。 - // n 值乘以 number 参数,然后加到当前日期上,以设置新的日期。 - const instanceFactorySet = (n : number) : Dayuts => { - // 创建一个新的 Dayuts 实例,它是当前实例的副本 - const d = dayuts(this) - // 设置新的日期并返回更新后的 Dayuts 实例 - return d.date(d.date() + Math.round(n * number)) //Utils.w(d.date(d.date() + Math.round(n * number)), this) - } - if (unit == M) { - return this.set(M, this.$M + number) - } - if (unit == Y) { - return this.set(Y, this.$y + number) - } - if (unit == D) { - return instanceFactorySet(1) - } - if (unit == W) { - return instanceFactorySet(7) - } - - const steps = new Map([ - [MIN, MILLISECONDS_A_MINUTE], - [H, MILLISECONDS_A_HOUR], - [S, MILLISECONDS_A_SECOND], - ]) - const step = steps.get(unit) ?? 1; - const nextTimeStamp = this.$d.getTime() + (number * step) - return wrapper(nextTimeStamp, this) - } - /** - * 从当前 Dayuts 实例中减去指定的时间。 - * @param {number} number - 要减去的时间。 - * @param {string} units - 要减去的时间单位(例如,“years”,“months”,“days”等)。 - * @returns {Dayuts} 更新的 Dayuts 实例。 - */ - subtract(number : number, units : DayutsUnit) : Dayuts { - // 通过将 number 乘以 -1,然后调用 add 方法来实现减法操作 - return this.add(number * -1, units); - } - /** - * 日期格式化 - * @param {string} formatStr - 格式化字符串,包含各种格式化占位符(例如,“YYYY-MM-DD”,“HH:mm:ss”等)。 - * @returns {string} 格式化后的日期字符串。 - */ - format(formatStr : string | null = null) : string { - const locale = this.$locale(); - if (!this.isValid()) return INVALID_DATE_STRING // locale.invalidDate || INVALID_DATE_STRING; - - const str = formatStr ?? FORMAT_DEFAULT; - // @ts-ignore - const zoneStr = padZoneStr(this); - const { $H, $m, $M } = this; - const { weekdays, months, meridiem } = locale; - /** - * 从给定的数组中获取缩写或完整的字符串。 - * @param {Array} arr - 包含缩写字符串的数组。 - * @param {number} index - 数组中要获取的元素的索引。 - * @param {Array} full - 包含完整字符串的数组。 - * @param {number} length - 要返回的字符串的长度。 - * @returns {string} 缩写或完整的字符串。 - */ - function getShort(arr : string[] | null, index : number, full : string[] = [], length : number = 0) : string { - if (arr != null && arr.length >= index) { - return arr[index] - } else if (full.length >= index) { - return full[index].slice(0, length) - } - return '' - }; - /** - * 获取12小时制的小时数。 - * @param {number} num - 小时数的位数。 - * @returns {string} 12小时制的小时数字符串。 - */ - const get$H = (num : number) : string => padStart(($H % 12 == 0 ? 12 : $H % 12).toString(), num, '0') - /** - * 获取上午或下午的字符串表示。 - * @param {number} hour - 小时数。 - * @param {number} minute - 分钟数。 - * @param {boolean} isLowercase - 是否返回小写字符串。 - * @returns {string} 上午或下午的字符串表示。 - */ - const meridiemFunc = meridiem ?? ((hour : number, _ : number, isLowercase : boolean) : string => { - const m = (hour < 12 ? 'AM' : 'PM'); - return isLowercase ? m.toLowerCase() : m; - }); - // #ifdef APP-ANDROID - return str.replace('YYYY', padStart(this.$y.toString(), 4, '0')) - .replace('YY', (this.$y).toString().slice(-2)) - .replace('MMMM', getShort(months, $M)) - .replace('MM', padStart(($M + 1).toString(), 2, '0')) - .replace('M', ($M + 1).toString()) - .replace('DD', padStart(this.$D.toString(), 2, '0')) - .replace('D', this.$D.toString()) - .replace('dddd', weekdays[this.$W]) - .replace('ddd', getShort(locale.weekdaysShort, this.$W, weekdays, 3)) - .replace('dd', getShort(locale.weekdaysMin, this.$W, weekdays, 2)) - .replace('d', this.$W.toString()) - .replace('HH', padStart($H.toString(), 2, '0')) - .replace('H', $H.toString()) - .replace('hh', get$H(2)) - .replace('h', get$H(1)) - .replace('mm', padStart($m.toString(), 2, '0')) - .replace('m', $m.toString()) - .replace('ss', padStart(this.$s.toString(), 2, '0')) - .replace('s', this.$s.toString()) - .replace('SSS', padStart(this.$ms.toString(), 3, '0')) - .replace('A', meridiemFunc($H, $m, false)) - .replace('a', meridiemFunc($H, $m, true)) - .replace('Z', zoneStr) - // #endif - // #ifndef APP-ANDROID - const matches = (match : string) : string | null => { - if (match == 'YY') { - return (this.$y).toString().slice(-2); - } else if (match == 'YYYY') { - return padStart(this.$y.toString(), 4, '0'); - } else if (match == 'M') { - return ($M + 1).toString(); - } else if (match == 'MM') { - return padStart(($M + 1).toString(), 2, '0'); - } else if (match == 'MMM') { - return getShort(locale.monthsShort, $M, months, 3); - } else if (match == 'MMMM') { - return getShort(months, $M); - } else if (match == 'D') { - return this.$D.toString(); - } else if (match == 'DD') { - return padStart(this.$D.toString(), 2, '0'); - } else if (match == 'd') { - return this.$W.toString(); - } else if (match == 'dd') { - return getShort(locale.weekdaysMin, this.$W, weekdays, 2); - } else if (match == 'ddd') { - return getShort(locale.weekdaysShort, this.$W, weekdays, 3); - } else if (match == 'dddd') { - return weekdays[this.$W]; - } else if (match == 'H') { - return $H.toString(); - } else if (match == 'HH') { - return padStart($H.toString(), 2, '0'); - } else if (match == 'h') { - return get$H(1); - } else if (match == 'hh') { - return get$H(2); - } else if (match == 'a') { - return meridiemFunc($H, $m, true); - } else if (match == 'A') { - return meridiemFunc($H, $m, false); - } else if (match == 'm') { - return $m.toString(); - } else if (match == 'mm') { - return padStart($m.toString(), 2, '0'); - } else if (match == 's') { - return this.$s.toString(); - } else if (match == 'ss') { - return padStart(this.$s.toString(), 2, '0'); - } else if (match == 'SSS') { - return padStart(this.$ms.toString(), 3, '0'); - } else if (match == 'Z') { - return zoneStr; // 'ZZ' logic below - } - return null; - }; - return str.replace(REGEX_FORMAT, (match : string, $1 : string, offset : number, string : string) : string => { - return $1 ?? matches(match) ?? zoneStr.replace(':', '') - }) - // #endif - } - /** - * 获取 Dayuts 实例的 UTC 偏移量(以分钟为单位)。 - * @returns {number} UTC 偏移量(以分钟为单位)。 - */ - utcOffset() : number { - // Because a bug at FF24, we're rounding the timezone offset around 15 minutes - // https://github.com/moment/moment/pull/1871 - // #ifndef APP-ANDROID || APP-IOS - return -Math.round(this.$d.getTimezoneOffset() / 15) * 15 - // #endif - // #ifdef APP-ANDROID || APP-IOS - return 0 - // #endif - } - /** - * 计算两个日期之间的差值 - * @param {string|number|Date|Dayuts} input - 要比较的日期 - * @param {string} units - 要计算的时间单位,如 'years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds' - * @param {boolean} float - 是否返回浮点数结果 - * @returns {number} 返回两个日期之间的差值 - */ - diff(input : string) : number - diff(input : number) : number - diff(input : Date) : number - diff(input : Dayuts) : number - diff(input : UTSJSONObject) : number - - diff(input : string, units : DayutsUnit) : number - diff(input : number, units : DayutsUnit) : number - diff(input : Date, units : DayutsUnit) : number - diff(input : Dayuts, units : DayutsUnit) : number - diff(input : UTSJSONObject, units : DayutsUnit) : number - - diff(input : string, units : DayutsUnit, float : boolean) : number - diff(input : number, units : DayutsUnit, float : boolean) : number - diff(input : Date, units : DayutsUnit, float : boolean) : number - diff(input : Dayuts, units : DayutsUnit, float : boolean) : number - diff(input : UTSJSONObject, units : DayutsUnit, float : boolean) : number - diff(input : any, units : DayutsUnit = 'millisecond', float : boolean = false) : number { - const unit = prettyUnit(units) - const that = dayuts(input) - const zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE - const diff = this.valueOf() - that.valueOf() - // @ts-ignore - const getMonth = () : number => monthDiff(this, that) - let result : number; - switch (unit) { - case Y: - result = getMonth() / 12 - break - case M: - result = getMonth() - break - case Q: - result = getMonth() / 3 - break - case W: - result = (diff - zoneDelta) / MILLISECONDS_A_WEEK - break - case D: - result = (diff - zoneDelta) / MILLISECONDS_A_DAY - break - case H: - result = diff / MILLISECONDS_A_HOUR - break - case MIN: - result = diff / MILLISECONDS_A_MINUTE - break - case S: - result = diff / MILLISECONDS_A_SECOND - break - default: - result = diff // milliseconds - break - } - - return float ? result : absFloor(result) - } - /** - * 将当前 Dayuts 对象转换为原生 Date 对象。 - * - * @returns {Date} 返回一个表示当前日期的原生 Date 对象。 - */ - toDate() : Date { - return new Date(this.valueOf()) - } - /** - * 将 Moment 对象转换为 JSON 字符串 - * @returns {string | null} 如果 Moment 对象有效,则返回 ISO 8601 格式的字符串,否则返回 null - */ - toJSON() : string | null { - return this.isValid() ? this.toISOString() : null; - } - /** - * 将 Moment 对象转换为 ISO 8601 格式的字符串 - * @returns {string} 返回 ISO 8601 格式的字符串 - */ - toISOString() : string { - // #ifndef APP-ANDROID || APP-IOS - return this.$d.toISOString(); - // #endif - // #ifdef APP-ANDROID || APP-IOS - return this.$d.toString(); - // #endif - } - toObject() : DayutsObject { - return { - years: this.$y, - months: this.$M, - date: this.$D, - hours: this.$H, - minutes: this.$m, - seconds: this.$s, - milliseconds: this.$ms - } as DayutsObject - } - toArray() : number[] { - return [ - this.$y, - this.$M, - this.$D, - this.$H, - this.$m, - this.$s, - this.$ms - ] - } - /** - * 获取当前日期的毫秒数。 - * - * @returns {number} 返回一个表示当前日期的毫秒数。 - */ - valueOf() : number { - // 使用 Date 对象的 getTime 方法获取当前日期的毫秒数。 - return this.$d.getTime() - } - /** - * 获取当前 `dayuts` 对象所在月份的天数。 - * - * @returns {number} 返回当前 `dayuts` 对象所在月份的天数。 - */ - daysInMonth() : number { - return this.endOf(M).$D; - } - - /** - * 获取当前日期的区域设置对象。 - * - * @returns {Object} 区域设置对象。 - */ - private $locale() : DayutsLocale { // get locale object - // return Ls.get(this.$L)! - return localeState.locales.get(this.$L)! - } - /** - * 设置或获取 Dayuts 实例的本地化配置 - * @param {string|Object} preset - 本地化预设名称或自定义本地化配置对象 - * @param {Object} [DayutsLocale] - 可选的自定义本地化配置对象 - * @returns {Dayuts|string} 如果设置了本地化配置,则返回一个新的 Dayuts 实例;否则返回当前实例的本地化配置名称 - */ - locale(preset : string, object : DayutsLocale) : Dayuts - locale(preset : DayutsLocale, object : DayutsLocale) : Dayuts - locale(preset : any, object : DayutsLocale | null = null) : Dayuts { - // if (!preset) return this.$L - const that = this.clone() - const nextLocaleName = parseLocale(preset, object, true) - if (nextLocaleName != null) that.$L = nextLocaleName - return that - } - clone() : Dayuts { - return wrapper(this.$d.getTime(), this) - } - /** - * 返回当前 dayuts 对象的 UTC 字符串表示。 - * - * @returns {string} 当前 dayuts 对象的 UTC 字符串表示。 - */ - // #ifdef APP-ANDROID && !VUE3-VAPOR - override toString() : string { - // return this.$d.toUTCString(); - // const locale = localeState.locales.get('en')! - // const weekday = locale.weekdays[this.$d.getDay()].substring(0,3); - // const month = locale.months[this.$d.getMonth()].substring(0,3) - // const day = `${this.$D}`.padStart(2, '0'); - // const hours = `${this.$H}`.padStart(2, '0'); - // const minutes = `${this.$m}`.padStart(2, '0'); - // const seconds = `${this.$s}`.padStart(2, '0'); - // return `${weekday}, ${day} ${month} ${this.$y} ${hours}:${minutes}:${seconds} GMT`; - return this.$d.toString(); - } - // #endif - // #ifndef APP-ANDROID && !VUE3-VAPOR - toString() : string { - // return this.$d.toUTCString(); - return this.$d.toString(); - } - // #endif - /** - * 计算给定日期在当年的第几天,或者设置给定日期为当年的第几天。 - * @param {number} [input] - 如果提供了输入值,则将日期设置为当年的第几天。如果没有提供输入值,则返回当前日期在当年的第几天。 - * @returns {number} 如果提供了输入值,则返回调整后的日期。如果没有提供输入值,则返回当前日期在当年的第几天。 - */ - dayOfYear() : number - dayOfYear(input : number) : Dayuts - dayOfYear(input : number | null = null) : any { - const dayOfYear = Math.round((this.startOf('day').valueOf() - this.startOf('year').valueOf()) / 864e5) + 1 - return input == null ? dayOfYear : this.add(input - dayOfYear, 'day') - } - /** - * 根据输入的时间计算与当前时间的相对时间差,并以指定的格式返回。 - * @param {Date|number|string} input - 输入的时间,可以是Date对象、时间戳或符合Date.parse()方法的字符串 - * @param {boolean} withoutSuffix - 是否省略“未来”或“过去”的后缀 - * @param {Object} instance - 当前时间的实例 - * @param {boolean} isFrom - 是否从输入时间计算到当前时间 - * @param {Function} postFormat - 格式化绝对值后的结果的函数 - * @returns {string} 相对时间差的格式化字符串 - */ - // postFormat - fromToBase(input : string, withoutSuffix : boolean, instance : Dayuts, isFrom : boolean) : string - fromToBase(input : number, withoutSuffix : boolean, instance : Dayuts, isFrom : boolean) : string - fromToBase(input : Date, withoutSuffix : boolean, instance : Dayuts, isFrom : boolean) : string - fromToBase(input : Dayuts, withoutSuffix : boolean, instance : Dayuts, isFrom : boolean) : string - fromToBase(input : UTSJSONObject, withoutSuffix : boolean, instance : Dayuts, isFrom : boolean) : string - fromToBase(input : any, withoutSuffix : boolean, instance : Dayuts, isFrom : boolean) : string { - const relObj = localeState.locales.get('en')?.relativeTime - const loc = instance.$locale().relativeTime ?? relObj - if (loc == null) return ''; - const T : Threshold[] = [ - { l: 's', r: 44, d: S }, - { l: 'm', r: 89 }, - { l: 'mm', r: 44, d: MIN }, - { l: 'h', r: 89 }, - { l: 'hh', r: 21, d: H }, - { l: 'd', r: 35 }, - { l: 'dd', r: 25, d: D }, - { l: 'M', r: 45 }, - { l: 'MM', r: 10, d: M }, - { l: 'y', r: 17 }, - { l: 'yy', d: Y } - ] - const Tl = T.length - let result : number = 0; - let out : string = ''; - let isFuture : boolean = false - for (let i = 0; i < Tl; i += 1) { - let t = T[i] - if (t.d != null) { - result = isFrom - ? dayuts(input).diff(instance, t.d!, true) - : instance.diff(input, t.d!, true) - } - let abs = Math.round(Math.abs(result)) - isFuture = result > 0 - if (t.r == null || t.r != null && abs <= t.r!) { - if (abs <= 1 && i > 0) t = T[i - 1] // 1 minutes -> a minute, 0 seconds -> 0 second - const format = loc[t.l] - // if (postFormat) { - // abs = postFormat(`${abs}`) - // } - if (typeof format == 'string') { - out = (format as string).replace('%d', abs.toString()) - } - // else { - // out = format(abs, withoutSuffix, t.l!, isFuture) - // } - break - } - } - if (withoutSuffix) return out - const pastOrFuture = isFuture ? loc.future : loc.past - // if (typeof pastOrFuture == 'function') { - // return pastOrFuture(out) - // } - return pastOrFuture.replace('%s', out) - } - /** - * 相对指定时间(后)。 - * @param {string|number|Date|Dayuts|UTSJSONObject} input - 输入的时间,可以是字符串、数字(时间戳)、Date对象、Dayuts对象或UTSJSONObject。 - * @param {boolean} withoutSuffix - 是否省略“未来”或“过去”的后缀。 - * @returns {string} 相对时间差的格式化字符串。 - */ - to(input : string) : string - to(input : number) : string - to(input : Date) : string - to(input : Dayuts) : string - to(input : UTSJSONObject) : string - - to(input : string, withoutSuffix : boolean) : string - to(input : number, withoutSuffix : boolean) : string - to(input : Date, withoutSuffix : boolean) : string - to(input : Dayuts, withoutSuffix : boolean) : string - to(input : UTSJSONObject, withoutSuffix : boolean) : string - to(input : any, withoutSuffix : boolean = false) : string { - return this.fromToBase(input, withoutSuffix, this, true) - } - /** - * 将当前时间转换为与输入时间的相对时间差,并以指定的格式返回。 - * @param {string|number|Date|Dayuts|UTSJSONObject} input - 输入的时间,可以是字符串、数字(时间戳)、Date对象、Dayuts对象或UTSJSONObject。 - * @param {boolean} withoutSuffix - 是否省略“未来”或“过去”的后缀。 - * @returns {string} 相对时间差的格式化字符串。 - */ - from(input : string) : string - from(input : number) : string - from(input : Date) : string - from(input : Dayuts) : string - from(input : UTSJSONObject) : string - - from(input : string, withoutSuffix : boolean) : string - from(input : number, withoutSuffix : boolean) : string - from(input : Date, withoutSuffix : boolean) : string - from(input : Dayuts, withoutSuffix : boolean) : string - from(input : UTSJSONObject, withoutSuffix : boolean) : string - from(input : any, withoutSuffix : boolean = false) : string { - return this.fromToBase(input, withoutSuffix, this, false) - } - /** - * 获取当前时间与实例时间的相对时间差,并以指定的格式返回。 - * @param {boolean} withoutSuffix - 是否省略“未来”或“过去”的后缀。 - * @returns {string} 相对时间差的格式化字符串。 - */ - toNow() : string - toNow(withoutSuffix : boolean = false) : string { - return this.to(dayuts(), withoutSuffix) - } - /** - * 获取实例时间与当前时间的相对时间差,并以指定的格式返回。 - * @param {boolean} withoutSuffix - 是否省略“未来”或“过去”的后缀。 - * @returns {string} 相对时间差的格式化字符串。 - */ - fromNow() : string - fromNow(withoutSuffix : boolean = false) : string { - return this.from(dayuts(), withoutSuffix) - } -} - -function dayuts() : Dayuts; -function dayuts(date : string) : Dayuts; -function dayuts(date : any[]) : Dayuts; -function dayuts(date : number) : Dayuts; -function dayuts(date : UTSJSONObject) : Dayuts; -function dayuts(date : Date) : Dayuts; -function dayuts(date : Dayuts) : Dayuts; -// #ifndef APP-ANDROID || APP-IOS -function dayuts(date : any | null, format : string) : Dayuts; -function dayuts(date : any | null, format : string | null, locale : string | null) : Dayuts; -// #endif -function dayuts(date : any | null = null, format : string | null = null, locale : string | null = null) : Dayuts { - if (date != null && date instanceof Dayuts) return date.clone() - return new Dayuts({ - date, - format, - locale - } as DayutsConfig) -} - -/** - * 判断给定的对象是否为Dayuts实例 - * @param {(any | null)} date - 输入的对象 - * @returns {boolean} - 如果给定的对象是Dayuts实例,则返回true,否则返回false - */ -function isDayuts(date : any | null = null) : boolean { - return date instanceof Dayuts -} - -export { - dayuts, - isDayuts -} \ No newline at end of file diff --git a/uni_modules/lime-dayuts/common/locale/en/index.ts b/uni_modules/lime-dayuts/common/locale/en/index.ts deleted file mode 100644 index 4d97cef..0000000 --- a/uni_modules/lime-dayuts/common/locale/en/index.ts +++ /dev/null @@ -1,57 +0,0 @@ -// @ts-nocheck -import type { DayutsLocale, DayutsRelativeTime} from '../../../utssdk/interface' -/** - * 英语本地化对象。 - */ -export default { - name: 'en', - /** - * 星期名称数组。 - */ - weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], - /** - * 月份名称数组。 - */ - months: [ - 'January', - 'February', - 'March', - 'April', - 'May', - 'June', - 'July', - 'August', - 'September', - 'October', - 'November', - 'December', - ], - relativeTime: { - future: 'in %s', - past: '%s ago', - s: 'a few seconds', - m: 'a minute', - mm: '%d minutes', - h: 'an hour', - hh: '%d hours', - d: 'a day', - dd: '%d days', - M: 'a month', - MM: '%d months', - y: 'a year', - yy: '%d years' - } as DayutsRelativeTime, - /** - * 序数函数,用于将数字转换为带有序数后缀的字符串。 - * - * @param {number} n - 要转换的数字。 - * @returns {string} 带有序数后缀的字符串。 - */ - ordinal: (n : number, _ : string) : string => { - const s = ['th', 'st', 'nd', 'rd'] - const v = n % 100 - const i = (v - 20) % 10 - const k = i < s.length ? i : v < s.length ? v : 0 - return `[${n}${(s[k])}]` - }, -} as DayutsLocale \ No newline at end of file diff --git a/uni_modules/lime-dayuts/common/locale/zh-cn/index.ts b/uni_modules/lime-dayuts/common/locale/zh-cn/index.ts deleted file mode 100644 index fde6d85..0000000 --- a/uni_modules/lime-dayuts/common/locale/zh-cn/index.ts +++ /dev/null @@ -1,75 +0,0 @@ -// @ts-nocheck -import type { DayutsLocale, DayutsRelativeTime, DayutsFormats } from '../../../utssdk/interface' - -const locale : DayutsLocale = { - name: 'zh-cn', - weekdays: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], - weekdaysShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], - weekdaysMin: ['日', '一', '二', '三', '四', '五', '六'], - months: [ - '一月', '二月', '三月', '四月', '五月', '六月', - '七月', '八月', '九月', '十月', '十一月', '十二月' - ], - monthsShort: [ - '1月', '2月', '3月', '4月', '5月', '6月', - '7月', '8月', '9月', '10月', '11月', '12月' - ], - ordinal: (number:number, period:string):string => { - // switch (period) { - // case 'W': - // return `${number}周`; - // default: - // return `${number}日`; - // } - if(period == 'W'){ - return `${number}周`; - } - return `${number}日` - }, - weekStart: 1, - yearStart: 4, - formats: { - LT: 'HH:mm', - LTS: 'HH:mm:ss', - L: 'YYYY/MM/DD', - LL: 'YYYY年M月D日', - LLL: 'YYYY年M月D日Ah点mm分', - LLLL: 'YYYY年M月D日ddddAh点mm分', - l: 'YYYY/M/D', - ll: 'YYYY年M月D日', - lll: 'YYYY年M月D日 HH:mm', - llll: 'YYYY年M月D日dddd HH:mm' - } as DayutsFormats, - relativeTime: { - future: '%s内', - past: '%s前', - s: '几秒', - m: '1 分钟', - mm: '%d 分钟', - h: '1 小时', - hh: '%d 小时', - d: '1 天', - dd: '%d 天', - M: '1 个月', - MM: '%d 个月', - y: '1 年', - yy: '%d 年' - } as DayutsRelativeTime, - meridiem: (hour:number, minute:number, _ : boolean):string => { - const hm = (hour * 100) + minute; - if (hm < 600) { - return '凌晨'; - } else if (hm < 900) { - return '早上'; - } else if (hm < 1100) { - return '上午'; - } else if (hm < 1300) { - return '中午'; - } else if (hm < 1800) { - return '下午'; - } - return '晚上'; - } -}; - -export default locale; \ No newline at end of file diff --git a/uni_modules/lime-dayuts/common/test.ts b/uni_modules/lime-dayuts/common/test.ts deleted file mode 100644 index 7e51351..0000000 --- a/uni_modules/lime-dayuts/common/test.ts +++ /dev/null @@ -1,110 +0,0 @@ -// @ts-nocheck -// import dayjs from 'dayjs' -import { dayuts } from "./index" -// import { Dates } from "./dates" -import { dayutsIntl } from './use' -console.log('dayuts:::test::12') - -// console.log('dayjs', dayjs('2026').format('YYYY')) -console.log('dayuts', dayuts('2026').format('YYYY')) - -// // console.log('format1', dayuts().format()) -// console.log('string number', dayuts(`${Date.now()}`)) -// console.log('2018-04-04', dayuts('2018-04-04T16:00:00.000Z')) -// // console.log('dayjs 2018-04-04', dayjs('2018-04-04T16:00:00.000Z')) -// console.log('2018 三月 15', dayuts('2018 三月 15', 'YYYY MMMM DD', 'zh-cn')) -// console.log('2010, 1, 14, 15, 25, 50, 125', dayuts([2010, 1, 14, 15, 25, 50, 125])) -// console.log('1970-00-00', dayuts('1970-00-00', 'YYYY-MM-DD')) -// console.log('1318781876406', dayuts(1318781876406)) -// console.log('2018, 8, 18', dayuts(new Date(2018, 8, 18))) -// console.log('2010, 1, 14, 15, 25, 50, 125[]', dayuts([2010, 1, 14, 15, 25, 50, 125])) -// console.log('millisecond2', dayuts().millisecond()) -// console.log('millisecond2', dayuts().millisecond(1)) -// console.log('second2', dayuts().second()) -// console.log('second2', dayuts().second(1)) -// console.log('minute2', dayuts().minute()) -// console.log('minute2', dayuts().minute(1)) -// console.log('hour2', dayuts().hour()) -// console.log('hour2', dayuts().hour(12)) -// console.log('date2', dayuts().date()) -// console.log('date2', dayuts().date(1)) -// console.log('dayOfYear', dayuts().dayOfYear()) -// console.log('dayOfYear', dayuts().dayOfYear(1)) -// console.log('month', dayuts().month()) -// console.log('month', dayuts().month(1)) -// console.log('year', dayuts().year()) -// console.log('year', dayuts().year(2000)) -// console.log(dayuts().get('year')) -// console.log(dayuts().get('month')) // start 0 -// console.log(dayuts().get('date')) -// console.log(dayuts().get('hour')) -// console.log(dayuts().get('minute')) -// console.log(dayuts().get('second')) -// console.log(dayuts().get('millisecond')) -// console.log('add', dayuts().add(7, 'day')) -// // console.log('add1', new Dates().newDate().add(7, 'day').format('YYYY-MM-DD')) -// console.log('subtract', dayuts().subtract(7, 'year')) -// console.log('startOf', dayuts().startOf('year')) -// console.log('endOf', dayuts().endOf('month')) -// console.log('format', dayuts().format()) -// console.log('format', dayuts('2019-01-25').format('[YYYYescape] YYYY-MM-DDTHH:mm:ssZ[Z]')) -// console.log('format', dayuts('2019-01-25').format('DD/MM/YYYY')) -// console.log('fromNow:1', dayuts('1999-01-01').fromNow()) -// console.log('fromNow:1', dayuts('1999-01-01').fromNow(true)) -// console.log('fromNow:1', dayuts('2024-03-29').fromNow(true)) -// console.log('from1', dayuts('1999-01-01').from(dayuts())) -// console.log('from1', dayuts('1999-01-01').from(dayuts(), true)) -// console.log('toNow1', dayuts('1999-01-01').toNow(true)) -// console.log('toNow1', dayuts('1999-01-01').to(dayuts())) -// console.log('diff1', dayuts('2019-01-25').diff(dayuts('2018-06-05'))) -// console.log('diff1', dayuts('2019-01-25').diff(dayuts('2018-06-05'), 'month')) -// console.log('diff1', dayuts('2019-01-25').diff(dayuts('2018-06-05'), 'month', true)) -// console.log('valueOf', dayuts('2019-01-25').valueOf()) -// console.log('unix', dayuts('2019-01-25').unix()) -// console.log('daysInMonth', dayuts('2019-01-25').daysInMonth()) -// console.log('toDate', dayuts().toDate()) -// console.log('toArray', dayuts().toArray()) -// console.log('toJSON', dayuts().toJSON()) -// console.log('toObject', dayuts().toObject()) -// console.log('toString', dayuts().toString()) -// console.log('isBefore', dayuts().isBefore(dayuts('2011-01-01'))) -// console.log('isBefore', dayuts().isBefore('2011-01-01', 'month')) -// console.log('isSame', dayuts().isSame(dayuts('2011-01-01'))) -// console.log('isSame', dayuts().isSame('2011-01-01', 'year')) -// console.log('isAfter', dayuts().isAfter(dayuts('2011-01-01'))) -// console.log('isAfter', dayuts().isAfter('2011-01-01', 'month')) -// console.log('isSameOrBefore', dayuts().isSameOrBefore(dayuts('2011-01-01'))) -// console.log('isSameOrBefore', dayuts().isSameOrBefore('2011-01-01', 'month')) -// console.log('isSameOrBefore', dayuts().isSameOrAfter(dayuts('2011-01-01'))) -// console.log('isSameOrBefore', dayuts().isSameOrAfter('2011-01-01', 'month')) -// console.log('isBetween', dayuts('2010-10-20').isBetween('2010-10-19', dayuts('2010-10-25'))) -// console.log('isBetween', dayuts().isBetween('2010-10-19', '2010-10-25', 'month')) -// console.log('isBetween', dayuts('2016-10-30').isBetween('2016-01-01', '2016-10-30', 'day', '[)')) -// console.log('isLeapYear', dayuts().isLeapYear()) -// console.log('isToday', dayuts().isToday()) - -// const a = dayuts('1999-01-01') -// const b = dayuts() -// console.log('fromNow:1',a.diff(b, 'year', true)) -// console.log('a', a) -// console.log('b', b) -// console.log('fromNow:2',a.diff(b, 'year', true)) - -dayutsIntl.locale = 'zh-cn' -console.log('new::1', dayuts().$L) - -// setTimeout(()=>{ -// console.log('new::23') -// },100) - - -export const test = (n : number) : number => { - switch (n) { - case 1: - return 1 - default: - return 0 - } -} - -console.log('test::::', test(1)) \ No newline at end of file diff --git a/uni_modules/lime-dayuts/common/use.ts b/uni_modules/lime-dayuts/common/use.ts deleted file mode 100644 index 4e67815..0000000 --- a/uni_modules/lime-dayuts/common/use.ts +++ /dev/null @@ -1,63 +0,0 @@ -// @ts-nocheck -import {DayutsLocale} from '../utssdk/interface' -import en from './locale/en' -import zhCn from './locale/zh-cn' - -// #ifndef UNI-APP-X - -// #ifdef VUE2 -import {reactive} from '@vue/composition-api' -// #endif - -// #ifdef VUE3 -import {reactive} from 'vue' -// #endif - -// #endif - - -const localesMap = new Map() -//定义一个大写的State类型 -type LocaleState = { - lang: string; - locales: Map -} -export let localeState = reactive({ - lang: 'en', - locales: localesMap -} as LocaleState) -localeState.locales.set('en', en) -localeState.locales.set('zh-cn', zhCn) - -class DayutsIntl { - constructor(){} - use(locale:DayutsLocale):DayutsIntl{ - localeState.locales.set(locale.name, locale) - return this - } - set locale(locale: string){ - if(localeState.locales.has(locale)){ - localeState.lang = locale - } else { - let list:string[] = [] - localeState.locales.forEach(function(_:any,key:string){ - list.push(key) - }) - console.warn(`未知语言: "${locale}". 请使用以下已知语言之一:${list.join(', ')}`); - } - } - get locale(): string{ - return localeState.lang - } - set(name: string, locale:DayutsLocale){ - localeState.locales.set(name, locale) - } - has(name: string):boolean{ - return localeState.locales.has(name) - } -} -export const dayutsIntl = new DayutsIntl() - - -// const dyauts = use(xx).use(xx).use(xx).use(xx) -// dyauts.locale ='zh' \ No newline at end of file diff --git a/uni_modules/lime-dayuts/common/utils.ts b/uni_modules/lime-dayuts/common/utils.ts deleted file mode 100644 index 215b951..0000000 --- a/uni_modules/lime-dayuts/common/utils.ts +++ /dev/null @@ -1,106 +0,0 @@ -// @ts-nocheck -import { Dayuts } from './index' -import { M, Y, W, D, DATE, H, MIN, S, MS, Q } from './constant' -import {DayutsUnit} from '../utssdk/interface' -/** - * 用指定字符串填充目标字符串的开头,以达到指定的总长度。 - * - * @param {string} string - 需要填充的目标字符串。 - * @param {number} length - 填充后的总长度。 - * @param {string} pad - 用于填充的字符串。 - * @returns {string} 填充后的字符串。 - */ -function padStart(string : string, length : number, pad : string) : string { - const str = string//`${string}` - if (str.length >= length) return str - return str.padStart(length, pad) //`${Array((length + 1) - string.length).join(pad)}${string}` -} -export { - padStart -} -function padZoneStr(instance : Dayuts) : string { - const negMinutes = -instance.utcOffset() - const minutes = Math.abs(negMinutes) - const hourOffset = Math.floor(minutes / 60) - const minuteOffset = minutes % 60 - return `${negMinutes <= 0 ? '+' : '-'}${padStart(hourOffset.toString(), 2, '0')}:${padStart(minuteOffset.toString(), 2, '0')}` -} -export { - padZoneStr -} - -// export function isNull(s): boolean{ -// return s == null -// } - -export function isNumber(value : any | null) : boolean { - // #ifdef APP-ANDROID - return ['Byte', 'UByte', 'Short', 'UShort', 'Int', 'UInt', 'Long', 'ULong', 'Float', 'Double', 'number'].includes(typeof value) - // #endif - // #ifdef APP-IOS - return ['Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', 'Int', 'UInt', 'Float', 'Float16', 'Float32', 'Float64', 'Double', 'number'].includes(typeof value) - // #endif - // #ifndef APP-ANDROID || APP-IOS - return typeof value === 'number' && !isNaN(value); - // #endif -} - - - -/** - * 将给定的时间单位转换为标准格式。 - * - * @param {string} u - 要转换的时间单位。 - * @returns {string} 返回转换后的时间单位。 - */ -export function prettyUnit(u : string) : DayutsUnit { - const special = new Map([ - ['M', M], - ['y', Y], - ['w', W], - ['d', D], - ['D', DATE], - ['h', H], - ['m', MIN], - ['s', S], - ['ms', MS], - ['Q', Q] - ]) - return (special.get(u) ?? `${u}`.toLowerCase().replace(/s$/, '')) as DayutsUnit -} - - -/** - * 计算两个日期之间的月份差值 - * @param {Dayjs} a - 第一个日期 - * @param {Dayjs} b - 第二个日期 - * @returns {number} 返回两个日期之间的月份差值 - */ -export function monthDiff(a : Dayuts, b : Dayuts) : number { - // 该函数来自 moment.js,以保持相同的结果 - if (a.date() < b.date()) return -monthDiff(b, a) - const wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()) - const anchor = a.clone().add(wholeMonthDiff, M).valueOf() - const c = b.valueOf() - anchor < 0 - const anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), M).valueOf() - // return +(-(wholeMonthDiff + ((b.valueOf() - anchor) / (c ? (anchor - anchor2) : - // (anchor2 - anchor)))) || 0) - - const decimalMonthDiff = (b.valueOf() - anchor) / (c ? (anchor - anchor2) : (anchor2 - anchor)); - const result = wholeMonthDiff + decimalMonthDiff; - const negatedResult = -result; - const absResult = +negatedResult; - const finalResult = !isNaN(absResult) ? absResult : 0; - return finalResult; -} - - -/** - * 返回向下取整的绝对值 - * @param {number} n - 输入的数字 - * @returns {number} 返回向下取整的绝对值 - */ -export function absFloor(n : number):number { - // return (n < 0 ? Math.ceil(n) || 0 : Math.floor(n)) - return (n < 0 ? Math.max(Math.ceil(n), 0) : Math.floor(n)) -} \ No newline at end of file diff --git a/uni_modules/lime-dayuts/index.ts b/uni_modules/lime-dayuts/index.ts deleted file mode 100644 index cfa16d5..0000000 --- a/uni_modules/lime-dayuts/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @ts-nocheck -export * from './common' -export * from './common/use' -// #ifndef VUE2 -export * from './utssdk/interface' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-dayuts/package.json b/uni_modules/lime-dayuts/package.json deleted file mode 100644 index ffd40a9..0000000 --- a/uni_modules/lime-dayuts/package.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "id": "lime-dayuts", - "displayName": "lime-dayuts dayjs 日期库", - "version": "2.0.0", - "description": "lime-dayuts 是dayjs的uts版,一个轻量的处理时间和日期的 UTS 库,几乎和dayjs保持一样的API", - "keywords": [ - "lime-dayuts", - "dayjs", - "日期", - "时间格式化" -], - "repository": "", - "engines": { - "HBuilderX": "^4.14", - "uni-app": "^4.72", - "uni-app-x": "^4.74" - }, - "dcloudext": { - "type": "uts", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "", - "darkmode": "x", - "i18n": "x", - "widescreen": "x" - }, - "uni_modules": { - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "√", - "aliyun": "√", - "alipay": "x" - }, - "client": { - "uni-app": { - "vue": { - "vue2": "√", - "vue3": "√" - }, - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "vue": "√", - "nvue": "-", - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√", - "alipay": "√", - "toutiao": "√", - "baidu": "√", - "kuaishou": "√", - "jd": "√", - "harmony": "√", - "qq": "√", - "lark": "√", - "xhs": "-" - }, - "quickapp": { - "huawei": "√", - "union": "√" - } - }, - "uni-app-x": { - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√" - } - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/lime-dayuts/readme - 副本.md b/uni_modules/lime-dayuts/readme - 副本.md deleted file mode 100644 index 587ebb6..0000000 --- a/uni_modules/lime-dayuts/readme - 副本.md +++ /dev/null @@ -1,445 +0,0 @@ -# lime-dayuts 日期库 -- lime-dayuts 是dayjs的uts版,一个轻量的处理时间和日期的 UTS 库,几乎和dayjs保持一样的API - -## 文档 - 🚀 [dayuts【站点1】](https://limex.qcoon.cn/uts/dayuts.html) - 🌍 [dayuts【站点2】](https://limeui.netlify.app/uts/dayuts.html) - 🔥 [dayuts【站点3】](https://limeui.familyzone.top/uts/dayuts.html) - - - -## 安装 -插件市场导入插件即可 - - -## 使用 -```ts -import {dayuts} from '@/uni_modules/lime-dayuts'; -dayuts().format() // 2024-03-25T02:10:16+08:00 -``` - - -## 解析 -接受 `string`、`number`、`Date`、`Dayuts`等值传入,返回 - -### 当前时间 -空值 `dayuts()` 将返回一个包含当前日期和时间的 `Dayuts` 对象。 - -```ts -dayuts() -``` - -### 字符串 - -```ts -dayuts('2024-03-04T16:00:00.000Z') -dayuts('2024-03-13 19:18:17.040+02:00') -dayuts('2024-03-13 19:18') -dayuts('1748750498228') -``` - -### 字符串+格式 - -```ts -dayuts('1970-00-00', 'YYYY-MM-DD') -``` -#### 支持的解析占位符列表 - -| 输入 | 示例 | 描述 | -| ------ | ---------------- | --------------------------------- | -| `YY` | 01 | 两位数的年份 | -| `YYYY` | 2001 | 四位数的年份 | -| `M` | 1-12 | 月份,从1开始计数 | -| `MM` | 01-12 | 月份,两位数 | -| `MMM` | Jan-Dec | 缩写的月份名称 | -| `MMMM` | January-December | 完整的月份名称 | -| `D` | 1-31 | 一个月的某一天 | -| `DD` | 01-31 | 一个月的某一天,两位数 | -| `H` | 0-23 | 小时数 | -| `HH` | 00-23 | 小时数,两位数 | -| `h` | 1-12 | 12小时制的小时数 | -| `hh` | 01-12 | 12小时制的小时数,两位数 | -| `m` | 0-59 | 分钟数 | -| `mm` | 00-59 | 分钟数,两位数 | -| `s` | 0-59 | 秒数 | -| `ss` | 00-59 | 秒数,两位数 | -| `S` | 0-9 | 百毫秒数,一位数 | -| `SS` | 00-99 | 十毫秒数,两位数 | -| `SSS` | 000-999 | 毫秒数,三位数 | -| `Z` | -05:00 | 相对于UTC的偏移量 | -| `ZZ` | -0500 | 相对UTC的紧凑偏移量,两位数 | -| `A` | AM PM | 上午或下午,大写字母 | -| `a` | am pm | 上午或下午,小写字母 | -| `ddd` | 周一 | 周,需要设置`locale = 'zh-cn'` , 默认为英文 | -| `dddd` | 星期一 | 星期 ,需要设置`locale = 'zh-cn'`, 默认为英文 | - - -### Unix 时间戳 (毫秒) - -```ts -dayuts(1318781876406) -``` - -### Date 对象 - -```ts -dayuts(new Date(2018, 8, 18)) -``` - -### 数组 - -```ts -dayuts([2010, 1, 14, 15, 25, 50, 125]); -``` - -## 取值/赋值 -在设计上 Dayuts 的 getter 和 setter 使用了相同的 API,也就是说,不传参数调用方法即为 getter,调用并传入参数为 setter。 - - -### 毫秒 Millisecond -获取或设置毫秒。传入0到999的数字。 如果超出这个范围,它会进位到秒。 -```ts -dayuts().millisecond() // gets current millisecond -dayuts().millisecond(1) // returns new dayuts -``` - -### 秒 Second -获取或设置秒。传入0到59的数字。 如果超出这个范围,它会进位到分钟。 -```ts -dayuts().second() // gets current second -dayuts().second(1) // returns new dayuts -``` - -### 分 Minute -获取或设置分钟。传入0到59的数字。 如果超出这个范围,它会进位到小时。 -```ts -dayuts().minute() // gets current minute -dayuts().minute(1) // returns new dayuts -``` - -### 时 Hour -获取或设置小时。传入0到23的数字。 如果超出这个范围,它会进位到天数。 -```ts -dayuts().hour() // gets current hour -dayuts().hour(12) // returns new dayuts -``` - -### 一个月中的第几天 Date of Month -获取或设置一个月中的某一天。接受从1到31的数字。如果超出范围,它将溢出到月份 -```ts -dayuts().date() // gets current date -dayuts().date(12) // returns new dayuts -``` - -### 一周中的第几天 Day of Week -获取或设置一周中的某一天。接受从0(星期日)到6(星期六)的数字。如果超出范围,它将溢出到其他周 -```ts -dayuts().day() // gets current day -dayuts().day(0) // returns new dayuts -``` - - -### 一年的第几天 Day of Year -获取或设置年份里第几天。传入1到366的数字。如果超出这个范围,它会进位到下一年。 -```ts -dayuts().dayOfYear() -dayuts().dayOfYear(365) // returns new dayuts -``` - -### 月 Month -获取或设置月份。传入0到11的 number。 如果超出这个范围,它会进位到年份。 -```ts -dayuts().month() // gets current month -dayuts().month(0) // returns new dayuts -``` - -### 年 Year -获取或设置年份。 -```ts -dayuts().year() // gets current year -dayuts().year(2000) // returns new dayuts -``` - -### Get/Set -获取和设置相应信息。 -```ts -dayuts().get('year') -dayuts().get('month') // start 0 -dayuts().get('date') -dayuts().get('hour') -dayuts().get('minute') -dayuts().get('second') -dayuts().get('millisecond') - -dayuts().set('date', 1) -dayuts().set('month', 3) // 四月 -dayuts().set('second', 30) -``` - -## 操作 - -### 增加 Add -返回增加一定时间的复制的 dayuts 对象。 -```ts -dayuts().add(7, 'day') -``` - -### 减去 Subtract -返回增加一定时间的复制的 dayuts 对象。 -```ts -dayuts().subtract(7, 'year') -``` - -#### 所有可用单位的列表 - -| 单位 | 缩写 | 描述 | -| ------------- | --------- | ---------------------------------------- | -| `day` | `d` | 日 | -| `week` | `w` | 周 | -| `month` | `M` | 月 | -| `year` | `y` | 年 | -| `hour` | `h` | 小时 | -| `minute` | `m` | 分钟 | -| `second` | `s` | 秒 | -| `millisecond` | `ms` | 毫秒 | - - -### 时间的开始 Start of Time -设置到一个时间的开始。 -```ts -dayuts().startOf('year') -``` - -### 时间的结束 End of Time -设置到一个时间的末尾。 -```ts -dayuts().endOf('month') -``` - -#### 所有可用单位的列表 - -| 单位 | 缩写 | 描述 | -| ------------- | --------- | ----------------------------------------- | -| `year` | `y` | 当年1月1日 00:00 | -| `quarter` | `Q` | 当前季度的开始,月份的第一天,00:00 @>>QuarterOfYear| -| `month` | `M` | 当月的第一天,00:00 | -| `week` | `w` | 当周的第一天,00:00 (根据地区设置) | -| `date` | `D` | 今天 00:00 | -| `day` | `d` | 今天 00:00 | -| `hour` | `h` | 现在,但是分钟、秒和毫秒都为0 | -| `minute` | `m` | 现在,但是秒和毫秒都为0 | -| `second` | `s` | 现在,但是毫秒为0 | - -## 显示 - -### 格式化 Format -根据传入的占位符返回格式化后的日期。 -将字符放在方括号中,即可原样返回而不被格式化替换 (例如, [MM]) -```ts -dayuts().format() // 默认返回的是 ISO8601 格式字符串 '2024-03-28T01:33:29+08:00' - -// app 暂不支持 -dayuts('2019-01-25').format('[YYYYescape] YYYY-MM-DDTHH:mm:ssZ[Z]') -// 'YYYYescape 2019-01-25T00:00:00-02:00Z' - -dayuts('2019-01-25').format('DD/MM/YYYY') // '25/01/2019' -``` - -### 相对当前时间(前) Time from now -返回现在到当前实例的相对时间。 -```ts -dayuts('1999-01-01').fromNow() // 25 years ago -//如果传入 true,则可以获得不带后缀的值。 -dayuts('1999-01-01').fromNow(true) // 25 years -``` - -### 相对指定时间(前) Time from X -返回 X 到当前实例的相对时间。 -```ts -dayuts('1999-01-01').from(dayuts()) // 25 years ago -//如果传入 true,则可以获得不带后缀的值。 -dayuts('1999-01-01').from(dayuts(), true) // 25 years -``` - -### 相对当前时间(后) Time to now -返回当前实例到现在的相对时间。 -```ts -dayuts('1999-01-01').toNow() // in 25 years -//如果传入 true,则可以获得不带后缀的值。 -dayuts('1999-01-01').toNow(true) // 25 years -``` - -### 相对指定时间(后) Time to X -返回当前实例到 X 的相对时间。 -```ts -dayuts('1999-01-01').to(dayuts()) // in 25 years -//如果传入 true,则可以获得不带后缀的值。 -dayuts('1999-01-01').to(true) // 25 years -``` - -### 差异 Diff -返回指定单位下两个日期时间之间的差异。 -```ts -dayuts('2019-01-25') - .diff(dayuts('2018-06-05')) // 20214000000 默认单位是毫秒 - -// 要获取其他单位下的差异,则在第二个参数传入相应的单位。 -dayuts('2019-01-25') - .diff(dayuts('2018-06-05'), 'month') // 7 - -// 如果要得到一个浮点数,将 true 作为第三个参数传入。 -dayuts('2019-01-25') - .diff(dayuts('2018-06-05'), 'month', true) // 7.645161290322581 -``` - -### Unix 时间戳 (毫秒) -返回当前实例的 UNIX 时间戳,13位数字,毫秒 -```ts -dayuts('2019-01-25').valueOf() //1548345600000 -``` - -### Unix 时间戳 -返回当前实例的 UNIX 时间戳,10位数字,秒。 -```ts -dayuts('2019-01-25').unix() // 1548345600 -``` - -### 月份的天数 -获取当前月份包含的天数。 -```ts -dayuts('2019-01-25').daysInMonth() //31 -``` - -### 转Date -从 Dayuts 对象中获取原生的 Date 对象 -```ts -dayuts().toDate() -``` - -### 转Array -返回一个包含各个时间信息的 Array -```ts -dayuts().toArray() //[2024, 2, 29, 2, 57, 28, 775] -``` - -### 转JSON -序列化为 `ISO 8601` 格式的字符串 -```ts -dayuts('2019-01-25').toJSON() // '2019-01-25T02:00:00.000Z' -``` - -### 转Object -返回包含时间信息的 Object -```ts -dayuts('2019-01-25').toObject() // { years: 2019, months: 0, date: 25, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 } -``` - -### 转字符串 -返回包含时间信息的 string -```ts -dayuts('2019-01-25').toString() // Fri Mar 29 2024 03:20:40 GMT+0800 -``` - - -## 查询 - -### 是否在前 Is Before -这表示 Dayuts 对象是否在另一个提供的日期时间之前。 - -```ts -// 默认使用毫秒比较 -dayuts().isBefore(dayuts('2011-01-01')) // false - -// 如果想使用除了毫秒以外的单位进行比较,则将单位作为第二个参数传入。 在这种情况下,会使用传入的单位以及比其范围大的单位进行比较。 -dayuts().isBefore('2011-01-01', 'month') // false -``` - -### 是否在后 Is After -这表示 Dayuts 对象是否在另一个提供的日期时间之后。 - -```ts -// 默认使用毫秒比较 -dayuts().isAfter(dayuts('2011-01-01')) // true - -// 如果想使用除了毫秒以外的单位进行比较,则将单位作为第二个参数传入。 在这种情况下,会使用传入的单位以及比其范围大的单位进行比较。 -dayuts().isAfter('2011-01-01', 'month') // true -``` - - -### 是否相同 Is Same -这表示 Dayuts 对象是否和另一个提供的日期时间相同。 - -```ts -// 默认使用毫秒比较 -dayuts().isSame(dayuts('2011-01-01')) // false - -// 当使用第二个参数时,将会连同去比较更大的单位。 如传入 month 将会比较 month 和 year。 传入 day 将会比较 day、 month和 year。 -dayuts().isSame('2011-01-01', 'year') // false -``` - -### 是否相同或在前 Is Same or Before -这表示 Dayuts 对象是否在另一个提供的日期时间之前。 - -```ts -// 默认使用毫秒比较 -dayuts().isSameOrBefore(dayuts('2011-01-01')) // false - -// 如果想使用除了毫秒以外的单位进行比较,则将单位作为第二个参数传入。 在这种情况下,会使用传入的单位以及比其范围大的单位进行比较。 -dayuts().isSameOrBefore('2011-01-01', 'month') // false -``` - -### 是否相同或在后 Is Same or After -这表示 Dayuts 对象是否和另一个提供的日期时间相同或在其之后。 - -```ts -// 默认使用毫秒比较 -dayuts().isSameOrAfter(dayuts('2011-01-01')) // true - -// 如果想使用除了毫秒以外的单位进行比较,则将单位作为第二个参数传入。 -dayuts().isSameOrAfter('2011-01-01', 'month') // true -``` - -### 区间 Is Between -这表示 Dayuts 对象是否在其他两个的日期时间之间 - -```ts -// 默认使用毫秒比较 -dayuts('2010-10-20').isBetween('2010-10-19', dayuts('2010-10-25'))// true - -// 如果想使用除了毫秒以外的单位进行比较,则将单位作为第三个参数传入。 在这种情况下,会使用传入的单位以及比其范围大的单位进行比较。 -dayuts().isBetween('2010-10-19', '2010-10-25', 'month') // false - -// 第四个参数是设置包容性。 [ 表示包含。 ( 表示排除。 -// 要使用包容性参数,必须同时传入两个指示符。 -dayuts('2016-10-30').isBetween('2016-01-01', '2016-10-30', 'day', '[)') -``` - -### 是否闰年 Is Leap Year -查询 Dayuts 对象的年份是否闰年 - -```ts -dayuts().isLeapYear()// true -``` - -### 今日 Is Today -查询 Dayuts 对象的日期是不是今日 - -```ts -dayuts().isToday()// true -``` - -## 国际化 -目前内置了中英两种语言,欢迎提交 Pull Request 来增加新的语言 - -### 改变语言配置 (全局) -更改全局的语言配置并不会影响之前存在的实例 -```ts -import {dayutsIntl} from '@/uni_modules/lime-dayuts' -dayutsIntl.locale = 'zh-cn' // 全局使用简体中文 -dayutsIntl.locale = 'en' // 全局使用默认的英文 -``` - -### 改变语言配置 (当前实例) -``` -dayuts().locale('zh-cn').format() -``` \ No newline at end of file diff --git a/uni_modules/lime-dayuts/readme.md b/uni_modules/lime-dayuts/readme.md deleted file mode 100644 index 9d3d5c2..0000000 --- a/uni_modules/lime-dayuts/readme.md +++ /dev/null @@ -1,462 +0,0 @@ ---- -name: lime-dayuts 日期库 -description: 轻量的处理时间和日期的 UTS 库,几乎和 dayjs 保持一样的 API,支持日期解析、格式化、比较、操作和查询等。 -tags: - - dayuts - - 日期 - - 时间 - - dayjs -plugin: lime-dayuts -category: API 插件 -dependencies: [] ---- - -# lime-dayuts 日期库 - -一个轻量的处理时间和日期的 UTS 库,几乎和 dayjs 保持一样的 API。lime-dayuts 提供了丰富的日期操作功能,包括日期解析、格式化、比较、操作和查询等,可用于各种需要处理日期和时间的应用场景。 - -## 安装方法 - -1. 在 uni-app 插件市场中搜索并导入 `lime-dayuts` -2. 导入后可能需要重新编译项目 -3. 在页面或组件中按需引入使用 - -::: tip 注意🔔 -lime-dayuts 是 UTS 版本的 dayjs,支持 uni-app x(App 原生、Web、小程序)以及 uni-app(Vue2/Vue3)。在 uni-app x 中编译为 Kotlin/Swift/ArkTS,在 uni-app 中编译为 JavaScript。 -::: - -## 代码演示 - -### 基础使用 - -最简单的日期库用法,直接导入并使用。 - -```ts -import { dayuts } from '@/uni_modules/lime-dayuts' - -// 当前时间 -dayuts().format() // 2024-03-25T02:10:16+08:00 - -// 自定义格式 -dayuts().format('YYYY-MM-DD HH:mm:ss') // 2024-03-25 02:10:16 -``` - -### 解析日期 - -dayuts 接受多种类型的输入,包括字符串、数字、Date 对象、数组等。 - -```ts -// 当前时间 -dayuts() - -// 字符串 -dayuts('2024-03-04T16:00:00.000Z') -dayuts('2024-03-13 19:18:17.040+02:00') -dayuts('2024-03-13 19:18') -dayuts('1748750498228') - -// 字符串 + 格式 -dayuts('1970-00-00', 'YYYY-MM-DD') - -// Unix 时间戳(毫秒) -dayuts(1318781876406) - -// Date 对象 -dayuts(new Date(2018, 8, 18)) - -// 数组 [年, 月, 日, 时, 分, 秒, 毫秒] -dayuts([2010, 1, 14, 15, 25, 50, 125]) -``` - -### 取值与赋值 - -getter 和 setter 使用了相同的 API,不传参数为 getter,传参数为 setter。 - -```ts -// 获取毫秒 -dayuts().millisecond() // 0-999 - -// 设置毫秒(返回新的 dayuts 对象) -dayuts().millisecond(1) - -// 获取秒 -dayuts().second() // 0-59 -dayuts().second(1) - -// 获取分钟 -dayuts().minute() // 0-59 -dayuts().minute(1) - -// 获取小时 -dayuts().hour() // 0-23 -dayuts().hour(12) - -// 获取日期 -dayuts().date() // 1-31 -dayuts().date(12) - -// 获取月份(0-11) -dayuts().month() // 0-11 -dayuts().month(0) - -// 获取年份 -dayuts().year() -dayuts().year(2000) - -// 获取星期几(0-6,0 表示周日) -dayuts().day() - -// 通用 get/set -dayuts().get('year') -dayuts().set('month', 5) -``` - -### 日期操作 - -```ts -// 增加时间 -dayuts().add(7, 'day') -dayuts().add(1, 'month') -dayuts().add(2, 'year') - -// 减去时间 -dayuts().subtract(7, 'year') -dayuts().subtract(1, 'day') - -// 设置到时间开始 -dayuts().startOf('year') -dayuts().startOf('month') -dayuts().startOf('day') - -// 设置到时间末尾 -dayuts().endOf('year') -dayuts().endOf('month') -dayuts().endOf('day') -``` - -### 日期格式化 - -```ts -// 默认格式(ISO8601) -dayuts().format() // 2024-03-28T01:33:29+08:00 - -// 自定义格式 -dayuts('2019-01-25').format('DD/MM/YYYY') // 25/01/2019 -dayuts('2019-01-25').format('YYYY-MM-DD HH:mm:ss') // 2019-01-25 00:00:00 - -// 转义字符(用方括号包裹) -dayuts('2019-01-25').format('[YYYYescape] YYYY-MM-DD') // YYYYescape 2019-01-25 -``` - -### 日期比较 - -```ts -// 是否在前 -dayuts().isBefore(dayuts('2011-01-01')) // false -dayuts().isBefore('2011-01-01', 'month') - -// 是否在后 -dayuts().isAfter(dayuts('2011-01-01')) // true -dayuts().isAfter('2011-01-01', 'year') - -// 是否相同 -dayuts().isSame('2011-01-01', 'year') // false -dayuts().isSame(dayuts(), 'day') // true - -// 是否相同或在前 -dayuts().isSameOrBefore('2011-01-01', 'month') - -// 是否相同或在后 -dayuts().isSameOrAfter('2011-01-01', 'month') - -// 是否在区间内 -dayuts('2010-10-20').isBetween('2010-10-19', dayuts('2010-10-25')) // true -dayuts('2010-10-20').isBetween('2010-10-19', '2010-10-25', 'day', '()') // true -dayuts('2010-10-20').isBetween('2010-10-19', '2010-10-25', 'day', '[)') // true(包含开始) -``` - -### 相对时间 - -```ts -// 相对当前时间(前) -dayuts('1999-01-01').fromNow() // 26 年前 -dayuts('1999-01-01').fromNow(true) // 26 年(不带后缀) - -// 相对指定时间(前) -dayuts('1999-01-01').from(dayuts()) - -// 相对当前时间(后) -dayuts('1999-01-01').toNow() -dayuts('1999-01-01').to(dayuts()) - -// 计算时间差 -dayuts('2019-01-25').diff(dayuts('2018-06-05')) // 毫秒差 -dayuts('2019-01-25').diff(dayuts('2018-06-05'), 'month') // 月份差(整数) -dayuts('2019-01-25').diff(dayuts('2018-06-05'), 'month', true) // 月份差(浮点数) -``` - -### 国际化 - -```ts -import { dayuts, dayutsIntl } from '@/uni_modules/lime-dayuts' - -// 全局设置语言 -dayutsIntl.locale = 'zh-cn' - -// 实例级设置语言 -dayuts().locale('zh-cn').format('dddd') // 星期一 - -// 注册自定义语言 -dayutsIntl.use({ - name: 'ja', - weekdays: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'], - months: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], - ordinal: (n: number, _: string): string => `${n}日`, - // ... 其他配置 -}) -dayutsIntl.locale = 'ja' -``` - -### 其他常用方法 - -```ts -// 是否为闰年 -dayuts().isLeapYear() - -// 是否为今天 -dayuts('2024-03-25').isToday() - -// 获取时间戳(毫秒) -dayuts().valueOf() - -// 获取 Unix 时间戳(秒) -dayuts().unix() - -// 获取月份天数 -dayuts('2024-02-01').daysInMonth() // 29(闰年) - -// 获取一年中的第几天 -dayuts('2024-03-01').dayOfYear() // 61 - -// 转换方法 -dayuts().toDate() // Date 对象 -dayuts().toArray() // [年, 月, 日, 时, 分, 秒, 毫秒] -dayuts().toJSON() // ISO 8601 字符串 -dayuts().toObject() // { years, months, date, hours, minutes, seconds, milliseconds } -dayuts().toString() // 字符串表示 - -// 克隆 -const d = dayuts('2024-03-25') -const d2 = d.clone() - -// 是否有效 -dayuts('invalid').isValid() // false - -// UTC 偏移量(分钟) -dayuts().utcOffset() -``` - -## API 文档 - -### 解析方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `dayuts()` | 创建当前时间的 Dayuts 对象 | - | Dayuts 对象 | -| `dayuts(string)` | 从字符串创建 Dayuts 对象 | 日期字符串 | Dayuts 对象 | -| `dayuts(string, format)` | 从指定格式的字符串创建 Dayuts 对象 | 日期字符串, 格式字符串 | Dayuts 对象 | -| `dayuts(number)` | 从时间戳创建 Dayuts 对象 | 时间戳(毫秒) | Dayuts 对象 | -| `dayuts(Date)` | 从 Date 对象创建 Dayuts 对象 | Date 对象 | Dayuts 对象 | -| `dayuts(array)` | 从数组创建 Dayuts 对象 | `[年, 月, 日, 时, 分, 秒, 毫秒]` | Dayuts 对象 | -| `dayuts(Dayuts)` | 克隆 Dayuts 对象 | Dayuts 对象 | Dayuts 对象 | -| `isDayuts(date)` | 判断是否为 Dayuts 实例 | 任意值 | 布尔值 | - -### 取值/赋值方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `millisecond()` | 获取毫秒 | - | 0-999 | -| `millisecond(value)` | 设置毫秒 | 0-999 | Dayuts 对象 | -| `second()` | 获取秒 | - | 0-59 | -| `second(value)` | 设置秒 | 0-59 | Dayuts 对象 | -| `minute()` | 获取分钟 | - | 0-59 | -| `minute(value)` | 设置分钟 | 0-59 | Dayuts 对象 | -| `hour()` | 获取小时 | - | 0-23 | -| `hour(value)` | 设置小时 | 0-23 | Dayuts 对象 | -| `date()` | 获取日期 | - | 1-31 | -| `date(value)` | 设置日期 | 1-31 | Dayuts 对象 | -| `day()` | 获取星期(0=周日) | - | 0-6 | -| `day(value)` | 设置星期 | 0-6 | Dayuts 对象 | -| `month()` | 获取月份(0=一月) | - | 0-11 | -| `month(value)` | 设置月份 | 0-11 | Dayuts 对象 | -| `year()` | 获取年份 | - | 年份数字 | -| `year(value)` | 设置年份 | 年份数字 | Dayuts 对象 | -| `get(unit)` | 获取指定单位的值 | 时间单位 | 数值 | -| `set(unit, value)` | 设置指定单位的值 | 时间单位, 值 | Dayuts 对象 | - -### 操作方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `add(value, unit)` | 增加时间 | 数值, 单位 | Dayuts 对象 | -| `subtract(value, unit)` | 减少时间 | 数值, 单位 | Dayuts 对象 | -| `startOf(unit)` | 设置为时间单位的开始 | 单位 | Dayuts 对象 | -| `endOf(unit)` | 设置为时间单位的结束 | 单位 | Dayuts 对象 | -| `dayOfYear()` | 获取一年中的第几天 | - | 数值 | -| `dayOfYear(value)` | 设置为一年中的第几天 | 数值 | Dayuts 对象 | -| `clone()` | 克隆当前对象 | - | Dayuts 对象 | -| `locale(name)` | 设置实例语言 | 语言名称 | Dayuts 对象 | - -### 显示方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `format(template)` | 格式化日期 | 格式模板 | 字符串 | -| `fromNow(withoutSuffix)` | 相对当前时间(前) | 是否不带后缀 | 字符串 | -| `from(compared, withoutSuffix)` | 相对指定时间(前) | 比较时间, 是否不带后缀 | 字符串 | -| `toNow(withoutSuffix)` | 相对当前时间(后) | 是否不带后缀 | 字符串 | -| `to(compared, withoutSuffix)` | 相对指定时间(后) | 比较时间, 是否不带后缀 | 字符串 | -| `diff(compared, unit, float)` | 计算时间差 | 比较时间, 单位, 是否返回浮点数 | 数值 | -| `valueOf()` | 获取时间戳(毫秒) | - | 数值 | -| `unix()` | 获取时间戳(秒) | - | 数值 | -| `daysInMonth()` | 获取月份的天数 | - | 数值 | -| `utcOffset()` | 获取 UTC 偏移量(分钟) | - | 数值 | -| `toDate()` | 转换为 Date 对象 | - | Date 对象 | -| `toArray()` | 转换为数组 | - | `number[]` | -| `toJSON()` | 转换为 JSON 字符串 | - | 字符串或 null | -| `toISOString()` | 转换为 ISO 8601 字符串 | - | 字符串 | -| `toObject()` | 转换为对象 | - | DayutsObject | -| `toString()` | 转换为字符串 | - | 字符串 | - -### 查询方法 - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `isBefore(compared, unit)` | 是否在指定时间之前 | 比较时间, 单位 | 布尔值 | -| `isAfter(compared, unit)` | 是否在指定时间之后 | 比较时间, 单位 | 布尔值 | -| `isSame(compared, unit)` | 是否与指定时间相同 | 比较时间, 单位 | 布尔值 | -| `isSameOrBefore(compared, unit)` | 是否相同或之前 | 比较时间, 单位 | 布尔值 | -| `isSameOrAfter(compared, unit)` | 是否相同或之后 | 比较时间, 单位 | 布尔值 | -| `isBetween(from, to, unit, inclusivity)` | 是否在区间内 | 开始, 结束, 单位, 包含性 | 布尔值 | -| `isLeapYear()` | 是否为闰年 | - | 布尔值 | -| `isToday()` | 是否为今天 | - | 布尔值 | -| `isValid()` | 日期是否有效 | - | 布尔值 | - -### 国际化 API - -| 方法 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| `dayutsIntl.locale = 'zh-cn'` | 全局设置语言 | 语言名称 | - | -| `dayutsIntl.locale` | 获取当前语言 | - | 语言名称 | -| `dayutsIntl.use(locale)` | 注册语言 | DayutsLocale 对象 | DayutsIntl | -| `dayutsIntl.set(name, locale)` | 设置语言配置 | 名称, DayutsLocale | - | -| `dayutsIntl.has(name)` | 是否已注册语言 | 名称 | 布尔值 | -| `instance.locale(name)` | 设置实例语言 | 语言名称 | Dayuts 对象 | - -### 格式化占位符 - -| 占位符 | 输出 | 描述 | -| --- | --- | --- | -| `YY` | 01 | 两位数的年份 | -| `YYYY` | 2001 | 四位数的年份 | -| `M` | 1-12 | 月份,从 1 开始计数 | -| `MM` | 01-12 | 月份,两位数 | -| `MMM` | Jan-Dec | 缩写的月份名称 | -| `MMMM` | January-December | 完整的月份名称 | -| `D` | 1-31 | 一个月的某一天 | -| `DD` | 01-31 | 一个月的某一天,两位数 | -| `d` | 0-6 | 一周的某一天(0=周日) | -| `dd` | Su-Sa | 最小缩写的周名 | -| `ddd` | Sun-Sat | 缩写的周名 | -| `dddd` | Sunday-Saturday | 完整的周名 | -| `H` | 0-23 | 小时数(24 小时制) | -| `HH` | 00-23 | 小时数,两位数 | -| `h` | 1-12 | 小时数(12 小时制) | -| `hh` | 01-12 | 小时数,两位数 | -| `m` | 0-59 | 分钟数 | -| `mm` | 00-59 | 分钟数,两位数 | -| `s` | 0-59 | 秒数 | -| `ss` | 00-59 | 秒数,两位数 | -| `S` | 0-9 | 百毫秒数,一位数 | -| `SS` | 00-99 | 十毫秒数,两位数 | -| `SSS` | 000-999 | 毫秒数,三位数 | -| `Z` | -05:00 | 相对于 UTC 的偏移量 | -| `ZZ` | -0500 | 相对 UTC 的紧凑偏移量 | -| `A` | AM/PM | 上午或下午,大写 | -| `a` | am/pm | 上午或下午,小写 | -| `[...]` | 原样输出 | 转义字符,方括号内的内容原样输出 | - -### 时间单位 - -| 单位 | 缩写 | 描述 | -| --- | --- | --- | -| `day` | `d` | 日 | -| `week` | `w` | 周 | -| `month` | `M` | 月 | -| `year` | `y` | 年 | -| `hour` | `h` | 小时 | -| `minute` | `m` | 分钟 | -| `second` | `s` | 秒 | -| `millisecond` | `ms` | 毫秒 | -| `date` | `D` | 日期(与 day 不同,date 表示一个月的某一天) | -| `quarter` | `Q` | 季度(常量已定义,部分方法未完整实现) | - -## Vue2 使用说明 - -lime-dayuts 在 Vue2 项目中使用了 `composition-api`(用于 locale 响应式状态),如需在 Vue2 项目中使用,请按照[官方教程](https://uniapp.dcloud.net.cn/tutorial/vue-composition-api.html)配置。 - -关键配置代码(在 main.js 中添加): - -```js -// vue2 -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -``` - -::: tip 注意🔔 -仅在 Vue2 项目中需要此配置,Vue3 和 uni-app x 项目无需配置。 -::: - -## 文档链接 - -📚 组件详细文档请访问以下站点: -- [日期库文档 - 站点1](https://limex.qcoon.cn/uts/dayuts.html) -- [日期库文档 - 站点2](https://limeui.netlify.app/uts/dayuts.html) -- [日期库文档 - 站点3](https://limeui.familyzone.top/uts/dayuts.html) - -## 注意事项 - -### 与 dayjs 的差异 - -lime-dayuts 虽然尽量保持与 dayjs 一致的 API,但受 UTS 强类型语言限制,存在以下差异: - -1. **不支持 `undefined`**:空值统一使用 `null` -2. **不支持 truthy/falsy 判断**:必须显式比较,如 `if (value != null)` -3. **插件机制**:lime-dayuts 暂未实现 `dayuts.extend(plugin)` 插件机制,所有功能内置 -4. **UTC 模式**:暂未实现 `dayuts.utc()`,`utcOffset()` 在 App 端(Android/iOS)始终返回 0 -5. **时区支持**:暂未实现 `dayuts.tz()` 时区转换 -6. **Duration**:暂未实现 `dayuts.duration()` 时间段对象 - -### 平台差异 - -1. **`toISOString()`**:在 App 端(Android/iOS)由于平台限制,返回 `toString()` 的结果而非标准 ISO 8601 格式 -2. **`utcOffset()`**:在 App 端(Android/iOS)始终返回 0,Web 端正常返回时区偏移 -3. **格式化实现**:Android 端使用链式 `replace` 实现,其他平台使用正则匹配,两者行为一致 -4. **纯数字字符串**:支持 `'1748750498228'` 形式的字符串时间戳解析 - -### 内置语言 - -lime-dayuts 内置以下语言: -- `en` — 英语 -- `zh-cn` — 简体中文 - -可通过 `dayutsIntl.use()` 方法注册其他语言。 - -## 支持与赞赏 - -如果你觉得本插件解决了你的问题,可以考虑支持作者: - -| 支付宝赞助 | 微信赞助 | -|------------|------------| -| ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) | ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) | diff --git a/uni_modules/lime-dayuts/utssdk/app-js/config.json b/uni_modules/lime-dayuts/utssdk/app-js/config.json deleted file mode 100644 index 721b81e..0000000 --- a/uni_modules/lime-dayuts/utssdk/app-js/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "deploymentTarget": "9" -} \ No newline at end of file diff --git a/uni_modules/lime-dayuts/utssdk/app-js/index.uts b/uni_modules/lime-dayuts/utssdk/app-js/index.uts deleted file mode 100644 index e538c34..0000000 --- a/uni_modules/lime-dayuts/utssdk/app-js/index.uts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '../../common' -export * from '../../common/use' -export * from '../interface' \ No newline at end of file diff --git a/uni_modules/lime-dayuts/utssdk/interface.uts b/uni_modules/lime-dayuts/utssdk/interface.uts deleted file mode 100644 index 6bd8d4b..0000000 --- a/uni_modules/lime-dayuts/utssdk/interface.uts +++ /dev/null @@ -1,405 +0,0 @@ -// @ts-nocheck -export type DayutsConfig = { - date: any|null - format : string|null - locale : string|null -} - -export type DayutsUnit = 'year' | 'month' | 'day' | 'week' | 'date' | 'hour' | 'minute' | 'second' | 'millisecond' | 'quarter' - -export type DayutsFormats = { - /** - * 小时和分钟的格式化字符串。 - */ - LT : string; - - /** - * 小时、分钟和秒的格式化字符串。 - */ - LTS : string; - - /** - * 年份、月份和日期的格式化字符串。 - */ - L : string; - - /** - * 年份、月份、日期和星期的格式化字符串。 - */ - LL : string; - - /** - * 年份、月份、日期、星期和小时的格式化字符串。 - */ - LLL : string; - - /** - * 年份、月份、日期、星期、小时和分钟的格式化字符串。 - */ - LLLL : string; - - /** - * 缩小的年份、月份和日期的格式化字符串。 - */ - l : string; - - /** - * 缩小的年份、月份、日期和星期的格式化字符串。 - */ - ll : string; - - /** - * 缩小的年份、月份、日期、星期和小时的格式化字符串。 - */ - lll : string; - - /** - * 缩小的年份、月份、日期、星期、小时和分钟的格式化字符串。 - */ - llll : string; -} -export type DayutsRelativeTime = { - /** - * 时间单位之后的格式化字符串。 - */ - future : string; - - /** - * 时间单位之前的格式化字符串。 - */ - past : string; - - /** - * 秒的格式化字符串。 - */ - s : string; - - /** - * 分钟的格式化字符串。 - */ - m : string; - - /** - * 分钟(带前缀)的格式化字符串。 - */ - mm : string; - - /** - * 小时的格式化字符串。 - */ - h : string; - - /** - * 小时(带前缀)的格式化字符串。 - */ - hh : string; - - /** - * 天的格式化字符串。 - */ - d : string; - - /** - * 天(带前缀)的格式化字符串。 - */ - dd : string; - - /** - * 月的格式化字符串。 - */ - M : string; - - /** - * 月(带前缀)的格式化字符串。 - */ - MM : string; - - /** - * 年的格式化字符串。 - */ - y : string; - - /** - * 年(带前缀)的格式化字符串。 - */ - yy : string; -} - -/** - * 本地化对象接口。 - */ -export type DayutsLocale = { - /** - * 区域设置名称。 - */ - name : string; - - /** - * 一周中每天的完整名称。 - */ - weekdays : string[]; - - /** - * 一周中每天的缩写名称。 - */ - weekdaysShort ?: string[]; - - /** - * 一周中每天的最小缩写名称。 - */ - weekdaysMin ?: string[]; - - /** - * 一年中的每个月份的名称。 - */ - months : string[]; - - /** - * 一年中的每个月份的缩写名称。 - */ - monthsShort ?: string[]; - - /** - * 返回序数词的函数。 - * - * @param number - 要格式化的数字。 - * @param period - 周期类型(如 "W" 表示周)。 - * @returns 返回格式化后的序数词字符串。 - */ - // ordinal : (number : number) => string; - ordinal : (number : number, period : string) => string; - - /** - * 一周的开始日期(星期几)。 - */ - weekStart ?: number; - - /** - * 年的开始月份。 - */ - yearStart ?: number; - - /** - * 日期和时间格式化选项。 - */ - formats ?: DayutsFormats; - - /** - * 相对时间格式化选项。 - */ - relativeTime ?: DayutsRelativeTime; - - /** - * 根据小时和分钟返回上午或下午的函数。 - * - * @param hour - 小时数(0-23)。 - * @param minute - 分钟数(0-59)。 - * @returns 返回上午或下午的字符串。 - */ - meridiem ?: (hour : number, minute : number, isLowercase : boolean) => string; -} - - -export type DayutsObject = { - years : number; - months : number; - date : number; - hours : number; - minutes : number; - seconds : number; - milliseconds : number; -} - - -// 主 Dayuts 类类型定义 -// export interface Dayuts { -// // 公共属性 -// $L: string; - -// // 私有属性 -// $d: Date; -// $y: number; -// $M: number; -// $D: number; -// $W: number; -// $H: number; -// $m: number; -// $s: number; -// $ms: number; -// $u: boolean; - -// // 构造函数 -// // constructor(cfg: DayutsConfig); - -// // 解析配置并初始化日期 -// // private parse(cfg: DayutsConfig): void; - -// // 初始化日期的各个部分 -// // private init(): void; - -// // 检查日期是否有效 -// isValid(): boolean; - -// // 判断当前日期是否与给定日期在指定时间单位内相同 -// // isSame(input: string, units?: DayutsUnit): boolean; -// // isSame(input: number, units?: DayutsUnit): boolean; -// // isSame(input: Date, units?: DayutsUnit): boolean; -// // isSame(input: Dayuts, units?: DayutsUnit): boolean; -// // isSame(input: UTSJSONObject, units?: DayutsUnit): boolean; -// // isSame(input : string) : boolean -// // isSame(input : number) : boolean -// // isSame(input : Date) : boolean -// // isSame(input : Dayuts) : boolean -// // isSame(input : UTSJSONObject) : boolean - -// // isSame(input : string, units : DayutsUnit) : boolean -// // isSame(input : number, units : DayutsUnit) : boolean -// // isSame(input : Date, units : DayutsUnit) : boolean -// // isSame(input : Dayuts, units : DayutsUnit) : boolean -// // isSame(input : UTSJSONObject, units : DayutsUnit) : boolean -// // isSame(input : any, units : DayutsUnit) : boolean - -// // 判断给定日期是否在当前日期指定时间单位之后 -// // isAfter(input: string, units?: DayutsUnit): boolean; -// // isAfter(input: number, units?: DayutsUnit): boolean; -// // isAfter(input: Date, units?: DayutsUnit): boolean; -// // isAfter(input: Dayuts, units?: DayutsUnit): boolean; -// // isAfter(input: UTSJSONObject, units?: DayutsUnit): boolean; -// // isAfter(input : string) : boolean -// // isAfter(input : number) : boolean -// // isAfter(input : Date) : boolean -// // isAfter(input : Dayuts) : boolean -// // isAfter(input : UTSJSONObject) : boolean - -// // isAfter(input : string, units : DayutsUnit) : boolean -// // isAfter(input : number, units : DayutsUnit) : boolean -// // isAfter(input : Date, units : DayutsUnit) : boolean -// // isAfter(input : Dayuts, units : DayutsUnit) : boolean -// // isAfter(input : UTSJSONObject, units : DayutsUnit) : boolean -// // isAfter(input : any, units : DayutsUnit) : boolean - -// // 判断给定日期是否在当前日期指定时间单位之前 -// // isBefore(input: string, units?: DayutsUnit): boolean; -// // isBefore(input: number, units?: DayutsUnit): boolean; -// // isBefore(input: Date, units?: DayutsUnit): boolean; -// // isBefore(input: Dayuts, units?: DayutsUnit): boolean; -// // isBefore(input: UTSJSONObject, units?: DayutsUnit): boolean; - -// // 判断当前日期是否与给定日期在指定时间单位内相同或之前 -// // isSameOrBefore(input: string, units?: DayutsUnit): boolean; -// // isSameOrBefore(input: number, units?: DayutsUnit): boolean; -// // isSameOrBefore(input: Date, units?: DayutsUnit): boolean; -// // isSameOrBefore(input: Dayuts, units?: DayutsUnit): boolean; -// // isSameOrBefore(input: UTSJSONObject, units?: DayutsUnit): boolean; - -// // 判断当前日期是否与给定日期在指定时间单位内相同或之后 -// // isSameOrAfter(input: string, units?: DayutsUnit): boolean; -// // isSameOrAfter(input: number, units?: DayutsUnit): boolean; -// // isSameOrAfter(input: Date, units?: DayutsUnit): boolean; -// // isSameOrAfter(input: Dayuts, units?: DayutsUnit): boolean; -// // isSameOrAfter(input: UTSJSONObject, units?: DayutsUnit): boolean; - -// // 判断当前日期是否在两个给定日期之间 -// // isBetween(input: any, input2: any): boolean; -// // isBetween(input: any, input2: any, units?: DayutsUnit, interval?: string): boolean; - -// // 判断当前年份是否为闰年 -// isLeapYear(): boolean; - -// // 判断当前日期是否为今天 -// isToday(): boolean; - -// // 获取 Unix 时间戳(秒) -// unix(): number; - -// // 设置为指定时间单位的开始或结束 -// // startOf(units: DayutsUnit): Dayuts; -// // startOf(units: DayutsUnit, startOf?: boolean): Dayuts; -// endOf(units: DayutsUnit): Dayuts; - -// // 设置指定时间单位的值 -// set(units: DayutsUnit, int: number): Dayuts; - -// // 获取指定时间单位的值 -// get(units: DayutsUnit): number; - -// // 年、月、日、时、分、秒、毫秒的 getter 和 setter 方法 -// year(): number; -// year(input?: number): Dayuts; -// month(): number -// month(input?: number): Dayuts; -// // day(): number; -// day(input?: number): Dayuts; -// date(): number; -// date(input?: number): Dayuts; -// // hour(): number; -// hour(input?: number): Dayuts; -// // minute(): number; -// minute(input?: number): Dayuts; -// // second(): number; -// second(input?: number): Dayuts; -// // millisecond(): number; -// millisecond(input?: number): Dayuts; - -// // 添加时间 -// add(number: number, units: DayutsUnit): Dayuts; - -// // 减去时间 -// subtract(number: number, units: DayutsUnit): Dayuts; - -// // 格式化日期 -// format(formatStr?: string): string; - -// // 获取 UTC 偏移量(分钟) -// utcOffset(): number; - -// // 计算两个日期之间的差值 -// diff(input: string, units?: DayutsUnit, float?: boolean): number; -// diff(input: number, units?: DayutsUnit, float?: boolean): number; -// diff(input: Date, units?: DayutsUnit, float?: boolean): number; -// diff(input: Dayuts, units?: DayutsUnit, float?: boolean): number; -// diff(input: UTSJSONObject, units?: DayutsUnit, float?: boolean): number; - -// // 转换为原生 Date 对象 -// toDate(): Date; - -// // 转换为 ISO 8601 字符串 -// toJSON(): string | null; -// toISOString(): string; - -// // 转换为对象 -// toObject(): DayutsObject; - -// // 转换为数组 -// toArray(): number[]; - -// // 获取时间戳(毫秒) -// valueOf(): number; - -// // 获取月份的天数 -// daysInMonth(): number; - -// // 获取本地化对象 -// // private $locale(): DayutsLocale; - -// // 设置或获取本地化配置 -// locale(preset: string, object?: DayutsLocale): Dayuts; -// locale(preset: DayutsLocale, object?: DayutsLocale): Dayuts; - -// // 克隆当前实例 -// clone(): Dayuts; - -// // 转换为字符串 -// // toString(): string; - -// // 获取或设置一年中的第几天 -// dayOfYear(): number; -// dayOfYear(input?: number): Dayuts; - -// // 相对时间方法 -// fromToBase(input: any, withoutSuffix: boolean, instance: Dayuts, isFrom: boolean): string; -// to(input: any, withoutSuffix?: boolean): string; -// from(input: any, withoutSuffix?: boolean): string; -// toNow(withoutSuffix?: boolean): string; -// fromNow(withoutSuffix?: boolean): string; -// } \ No newline at end of file diff --git a/uni_modules/lime-dayuts/utssdk/unierror.uts b/uni_modules/lime-dayuts/utssdk/unierror.uts deleted file mode 100644 index 8428bbd..0000000 --- a/uni_modules/lime-dayuts/utssdk/unierror.uts +++ /dev/null @@ -1,39 +0,0 @@ -/* 此规范为 uni 规范,可以按照自己的需要选择是否实现 */ -import { MyApiErrorCode, MyApiFail } from "./interface.uts" -/** - * 错误主题 - * 注意:错误主题一般为插件名称,每个组件不同,需要使用时请更改。 - * [可选实现] - */ -export const UniErrorSubject = 'uts-api'; - - -/** - * 错误信息 - * @UniError - * [可选实现] - */ -export const UniErrors : Map = new Map([ - /** - * 错误码及对应的错误信息 - */ - [9010001, 'custom error mseeage1'], - [9010002, 'custom error mseeage2'], -]); - - -/** - * 错误对象实现 - */ -export class MyApiFailImpl extends UniError implements MyApiFail { - - /** - * 错误对象构造函数 - */ - constructor(errCode : MyApiErrorCode) { - super(); - this.errSubject = UniErrorSubject; - this.errCode = errCode; - this.errMsg = UniErrors[errCode] ?? ""; - } -} \ No newline at end of file diff --git a/uni_modules/lime-loading/changelog.md b/uni_modules/lime-loading/changelog.md deleted file mode 100644 index a7f1991..0000000 --- a/uni_modules/lime-loading/changelog.md +++ /dev/null @@ -1,44 +0,0 @@ -## 0.2.2(2025-12-09) -- chore: 删除多余文件 -## 0.2.1(2025-12-09) -- fix: 修复类型问题 -## 0.2.0(2025-10-21) -- fix: 修复uniappx ios 在弹窗下会导致弹窗无内容。 -## 0.1.9(2025-08-31) -- chore: 更新文档 -## 0.1.8(2025-05-30) -- feat: 重构,针对uniapp x app增加`mode`属性,用于是使用计时器还是元素的animate实现 -## 0.1.7(2025-05-16) -- fix: 修复 uniappx ios 初始化尺寸为0导致不生效的问题 -## 0.1.6(2025-04-21) -- fix: uniappx 鸿蒙next 尺寸从0变化时无法渲染 -## 0.1.5(2025-04-21) -- feat: 兼容uniappx 鸿蒙next -## 0.1.4(2025-04-10) -- feat: 增加暂停 -## 0.1.3(2025-03-12) -- feat: uniappx app使用`requestAnimationFrame` -## 0.1.2(2025-02-13) -- fix: 修复因uniapp x ios监听元素不生效导致不生效问题 -## 0.1.1(2025-02-09) -- chore: 去掉多余console -## 0.1.0(2025-02-09) -- feat: 重构useLoading -## 0.0.9(2025-01-14) -- feat: useLoading 增加color ref -## 0.0.8(2024-12-24) -- feat: 改用监听尺寸方式 -## 0.0.7(2024-12-18) -- fix: 修复vue2 微信小程序不显示加载图标的问题 -## 0.0.6(2024-12-18) -- chore: 更新文档 -## 0.0.5(2024-09-30) -- fix: vue2 app 使用渐变 -## 0.0.4(2024-09-29) -- chore: 非uvue app size使用css变量 -## 0.0.3(2024-09-25) -- fix: useLoading -## 0.0.2(2024-04-05) -- feat: 支持 uniapp x ios(app-js) -## 0.0.1(2023-10-13) -- 首次上传 diff --git a/uni_modules/lime-loading/components/l-loading/index-u.scss b/uni_modules/lime-loading/components/l-loading/index-u.scss deleted file mode 100644 index 4437509..0000000 --- a/uni_modules/lime-loading/components/l-loading/index-u.scss +++ /dev/null @@ -1,252 +0,0 @@ -@import '@/uni_modules/lime-style/index.scss'; - -$use-css-var: true; - -$loading-color: create-var(loading-color, $primary-color); -$loading-size: create-var(loading-size, 20px); -$loading-text-color: create-var(loading-text-color, $text-color-3); -$loading-font-size: create-var(loading-font-size, $font-size); - -/* #ifndef UNI-APP-X && APP || APP-NVUE */ -/* #ifndef MP-ALIPAY */ -$loading-duration: var(--l-loading-duration, 2s); - -@property --l-loading-start { - syntax: ''; - initial-value: 1%; - inherits: false; -} -@property --l-loading-end { - syntax: ''; - initial-value: 1%; - inherits: false; -} -@property --l-left { - syntax: ''; - initial-value: 1%; - inherits: false; -} -@property --l-loadding-ball-size { - syntax: ' | '; - // initial-value: 1%; - inherits: false; -} - -/* #endif */ -/* #ifdef MP-ALIPAY */ -$loading-duration: var(--l-loading-duration, 1s); -/* #endif */ - - -/* #endif */ - - - -.l-loading { - display: flex; - position: relative; - flex-direction: row; - align-items: center; - // align-self: flex-start; - /* #ifndef UNI-APP-X && APP || APP-NVUE */ - color: $loading-color; - &--ball{ - display: inline-flex; - align-items: center; - - .l-loading { - &__ball { - position: relative; - perspective: calc(var(--l-loadding-ball-size) * 4); - transform-style: preserve-3d; - // border: 1px solid; - - &:before{ - background-color: $primary-color; - left: 0%; - // mix-blend-mode: darken; - animation-name: l-ball-before; - } - &:after{ - right: 0; - background-color: red; - // mix-blend-mode: darken; - animation-name: l-ball-after; - } - &:before,&:after{ - top: 0; - content: ''; - position: absolute; - // width: 100%; - height: 100%; - aspect-ratio: 1/1; - border-radius: 50%; - animation-iteration-count: infinite; - animation-delay: -100ms; - animation-duration: 900ms; - mix-blend-mode: darken; - animation-play-state: var(--l-play-state, running); - } - } - } - } - &--circular { - .l-loading { - &__circular { - display: inline-block; - position: relative; - animation: l-rotate $loading-duration linear infinite; - animation-play-state: var(--l-play-state, running); - vertical-align: middle; - &:before { - content: ''; - display: block; - width: 100%; - height: 100%; - border-radius: 50%; - /* #ifndef MP-ALIPAY */ - background: conic-gradient( - transparent 0%, - transparent var(--l-loading-start, 0%), var(--l-loading-color-1, currentColor) var(--l-loading-start, 0%), - var(--l-loading-color-2, currentColor) var(--l-loading-end, 0%), transparent var(--l-loading-end, 0%), - transparent 100%); - /* #endif */ - /* #ifdef MP-ALIPAY */ - background: conic-gradient( - var(--l-loading-color-1, transparent) 0%, - var(--l-loading-color-2, currentColor) 100%); - /* #endif */ - mask: radial-gradient(closest-side, transparent calc(80% - 1px), #fff 80%); - -webkit-mask: radial-gradient(closest-side, transparent calc(80% - 1px), #fff 80%); - animation: l-circular 3s ease-in-out infinite; - animation-play-state: var(--l-play-state, running); - transform: rotate(90deg); - } - } - } - } - &--spinner { - .l-loading { - &__spinner { - position: relative; - box-sizing: border-box; - // width: 100%; - // height: 100%; - // max-width: 100%; - // max-height: 100%; - animation-timing-function: steps(12); - animation: l-rotate 1.5s linear infinite; - animation-play-state: var(--l-play-state, running) - } - &__dot { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - transform: rotate(calc(var(--l-loading-dot, 1) * 30deg)); - opacity: calc(var(--l-loading-dot, 1) / 12); - &::before { - display: block; - width: 5rpx; - height: 25%; - margin: 0 auto; - background-color: currentColor; - border-radius: 40%; - content: ' '; - } - } - } - } - /* #endif */ - /* #ifdef UNI-APP-X && APP || APP-NVUE */ - &__view{ - // background-color: aqua; - // background-color: #1677ff; - // transition-duration: 1.5s; - // transition-property: transform; - // transition-timing-function: linear; - } - /* #endif */ - &__text { - margin-left: $spacer-xs; - color: $loading-text-color; - font-size: $loading-font-size; - } - - - &.is-vertical { - flex-direction: column; - .l-loading__text { - margin: $spacer-tn 0 0; - } - } - &__ball,&__circular,&__spinner { - width: $loading-size; - height: $loading-size; - } -} - - -/* #ifndef UNI-APP-X && APP || APP-NVUE */ -@keyframes l-circular { - 0% { - --l-loading-start: 0%; - --l-loading-end: 0%; - } - 50% { - --l-loading-start: 0%; - --l-loading-end: 100%; - } - 100% { - --l-loading-start: 100%; - --l-loading-end: 100%; - } -} -@keyframes l-rotate { - to { - transform: rotate(1turn) - } -} - -@keyframes l-ball-before { - 0%{ - animation-timing-function: ease-in; - } - 25% { - animation-timing-function: ease-out; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) / 2); - transform: translate3d(var(--l-left), 0, var(--l-loadding-ball-size)); - } - 50% { - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%))); - animation-timing-function:ease-in; - transform: translate3d(var(--l-left), 0, 0); - } - 75% { - animation-timing-function: ease-out; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) / 2); - transform: translate3d(var(--l-left), 0, calc(var(--l-loadding-ball-size) * -1)); - } -} -@keyframes l-ball-after { - 0%{ - animation-timing-function: ease-in; - } - 25% { - animation-timing-function: ease-out; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) / 2 * -1); - transform: translate3d(var(--l-left), 0, calc(var(--l-loadding-ball-size) * -1)); - } - 50% { - animation-timing-function:ease-in; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) * -1); - transform: translate3d(var(--l-left), 0, 0); - } - 75% { - animation-timing-function: ease-out; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) / 2 * -1); - transform: translate3d(var(--l-left), 0, var(--l-loadding-ball-size)); - } -} -/* #endif */ \ No newline at end of file diff --git a/uni_modules/lime-loading/components/l-loading/index.scss b/uni_modules/lime-loading/components/l-loading/index.scss deleted file mode 100644 index 17644ec..0000000 --- a/uni_modules/lime-loading/components/l-loading/index.scss +++ /dev/null @@ -1,246 +0,0 @@ -@import '@/uni_modules/lime-style/index.scss'; - -$loading-color: create-var(loading-color, $primary-color); -$loading-size: create-var(loading-size, 20px); -$loading-text-color: create-var(loading-text-color, $text-color-3); -$loading-font-size: create-var(loading-font-size, $font-size); - -/* #ifndef MP-ALIPAY */ -$loading-duration: create-var(loading-duration, 2s); -/* #endif */ -/* #ifdef MP-ALIPAY */ -$loading-duration: create-var(loading-duration, 1s); -/* #endif */ - -/* #ifndef APP-NVUE */ - - - -/* #ifndef MP-ALIPAY */ -@property --l-loading-start { - syntax: ''; - initial-value: 1%; - inherits: false; -} -@property --l-loading-end { - syntax: ''; - initial-value: 1%; - inherits: false; -} -@property --l-left { - syntax: ''; - initial-value: 1%; - inherits: false; -} -@property --l-loadding-ball-size { - syntax: ' | '; - // initial-value: 1%; - inherits: false; -} -/* #endif */ - -:host { - display: inline-flex; -} -/* #endif */ - - -.l-loading { - position: relative; - // color: #c8c9cc; - color: $loading-color; - font-size: 0; - vertical-align: middle; - &--ball{ - display: inline-flex; - align-items: center; - .l-loading { - &__ball { - position: relative; - perspective: calc(var(--l-loadding-ball-size) * 4); - transform-style: preserve-3d; - // border: 1px solid; - - &:before{ - background-color: $primary-color; - left: 0%; - // mix-blend-mode: darken; - animation-name: l-ball-before; - } - &:after{ - right: 0; - background-color: red; - // mix-blend-mode: darken; - animation-name: l-ball-after; - } - &:before,&:after{ - top: 0; - content: ''; - position: absolute; - // width: 100%; - height: 100%; - aspect-ratio: 1/1; - border-radius: 50%; - animation-iteration-count: infinite; - animation-delay: -100ms; - animation-duration: 900ms; - mix-blend-mode: darken; - animation-play-state: var(--l-play-state, running); - } - } - } - } - &--circular { - .l-loading { - &__circular { - display: inline-block; - position: relative; - /* #ifndef APP-NVUE */ - animation: l-rotate $loading-duration linear infinite; - vertical-align: middle; - animation-play-state: var(--l-play-state, running); - &:before { - content: ''; - display: block; - width: 100%; - height: 100%; - border-radius: 50%; - /* #ifndef MP-ALIPAY || APP-VUE */ - background-image: conic-gradient( - transparent 0%, - transparent var(--l-loading-start, 0%), var(--l-loading-color-1, currentColor) var(--l-loading-start, 0%), - var(--l-loading-color-2, currentColor) var(--l-loading-end, 0%), transparent var(--l-loading-end, 0%), - transparent 100%); - /* #endif */ - /* #ifdef MP-ALIPAY || APP-VUE */ - background-image: conic-gradient( - var(--l-loading-color-1, transparent) 0%, - var(--l-loading-color-2, currentColor) 100%); - /* #endif */ - mask: radial-gradient(closest-side, transparent calc(80% - 1px), #fff 80%); - -webkit-mask: radial-gradient(closest-side, transparent calc(80% - 1px), #fff 80%); - animation: l-circular 2.5s ease-in-out infinite; - transform: rotate(90deg); - animation-play-state: var(--l-play-state, running); - } - /* #endif */ - } - } - } - &--spinner { - .l-loading { - &__spinner { - position: relative; - box-sizing: border-box; - width: 100%; - height: 100%; - max-width: 100%; - max-height: 100%; - animation-timing-function: steps(12); - animation: l-rotate 0.8s linear infinite; - animation-play-state: var(--l-play-state, running); - } - &__dot { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - transform: rotate(calc(var(--l-loading-dot, 1) * 30deg)); - opacity: calc(var(--l-loading-dot, 1) / 12); - &::before { - display: block; - width: 5rpx; - height: 25%; - margin: 0 auto; - background-color: currentColor; - border-radius: 40%; - content: ' '; - } - } - } - - } - &__text{ - display: inline-block; - margin-left: $spacer-xs; - color: $loading-text-color; - font-size: $loading-font-size; - vertical-align: middle; - } - &.is-vertical { - display: inline-flex; - flex-direction: column; - align-items: center; - - .l-loading__text { - margin: $spacer-tn 0 0; - } - } - &__ball,&__circular,&__spinner { - width: $loading-size; - height: $loading-size; - } -} -/* #ifndef APP-NVUE */ -@keyframes l-circular { - 0% { - --l-loading-start: 0%; - --l-loading-end: 0%; - } - 50% { - --l-loading-start: 0%; - --l-loading-end: 100%; - } - 100% { - --l-loading-start: 100%; - --l-loading-end: 100%; - } -} -@keyframes l-rotate { - to { - transform: rotate(1turn) - } -} - -@keyframes l-ball-before { - 0%{ - animation-timing-function: ease-in; - } - 25% { - animation-timing-function: ease-out; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) / 2); - transform: translate3d(var(--l-left), 0, var(--l-loadding-ball-size)); - } - 50% { - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%))); - animation-timing-function:ease-in; - transform: translate3d(var(--l-left), 0, 0); - } - 75% { - animation-timing-function: ease-out; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) / 2); - transform: translate3d(var(--l-left), 0, calc(var(--l-loadding-ball-size) * -1)); - } -} -@keyframes l-ball-after { - 0%{ - animation-timing-function: ease-in; - } - 25% { - animation-timing-function: ease-out; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) / 2 * -1); - transform: translate3d(var(--l-left), 0, calc(var(--l-loadding-ball-size) * -1)); - } - 50% { - animation-timing-function:ease-in; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) * -1); - transform: translate3d(var(--l-left), 0, 0); - } - 75% { - animation-timing-function: ease-out; - --l-left: calc((var(--l-loadding-ball-size,100%) * 2.1 - var(--l-loadding-ball-size,100%)) / 2 * -1); - transform: translate3d(var(--l-left), 0, var(--l-loadding-ball-size)); - } -} -/* #endif */ \ No newline at end of file diff --git a/uni_modules/lime-loading/components/l-loading/l-loading.uvue b/uni_modules/lime-loading/components/l-loading/l-loading.uvue deleted file mode 100644 index 5894814..0000000 --- a/uni_modules/lime-loading/components/l-loading/l-loading.uvue +++ /dev/null @@ -1,122 +0,0 @@ - - - - \ No newline at end of file diff --git a/uni_modules/lime-loading/components/l-loading/l-loading.vue b/uni_modules/lime-loading/components/l-loading/l-loading.vue deleted file mode 100644 index 5e7467e..0000000 --- a/uni_modules/lime-loading/components/l-loading/l-loading.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - - \ No newline at end of file diff --git a/uni_modules/lime-loading/components/l-loading/props.ts b/uni_modules/lime-loading/components/l-loading/props.ts deleted file mode 100644 index c953a54..0000000 --- a/uni_modules/lime-loading/components/l-loading/props.ts +++ /dev/null @@ -1,28 +0,0 @@ -// import {PropType} from 'vue' -export default { - color: { - type: String, - // default: '#c9c9c9' - }, - type: { - type: String, //as PropType<'circular'|'spinner'>, - default: 'circular' - }, - size: { - type: String, - // #ifdef APP-NVUE - default: '40rpx' - // #endif - }, - text: String, - textColor: String, - textSize: { - type: [String, Number] - }, - vertical: Boolean, - inheritColor: Boolean, - animated: { - type: Boolean, - default: true - } -} \ No newline at end of file diff --git a/uni_modules/lime-loading/components/l-loading/type.ts b/uni_modules/lime-loading/components/l-loading/type.ts deleted file mode 100644 index 7d586c0..0000000 --- a/uni_modules/lime-loading/components/l-loading/type.ts +++ /dev/null @@ -1,18 +0,0 @@ -// @ts-nocheck -// 完整类型定义 -export interface LoadingProps { - color?: string; - type: 'circular' | 'spinner' | 'failed'; - // #ifndef APP - size?: string; - // #endif - // #ifdef APP - size: string; - // #endif - text?: string; - textColor?: string; - textSize?: string|number; - mode: 'raf' | 'animate'; - vertical: boolean; - animated: boolean; -} diff --git a/uni_modules/lime-loading/components/lime-loading/lime-loading.uvue b/uni_modules/lime-loading/components/lime-loading/lime-loading.uvue deleted file mode 100644 index c18631d..0000000 --- a/uni_modules/lime-loading/components/lime-loading/lime-loading.uvue +++ /dev/null @@ -1,132 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-loading/components/lime-loading/lime-loading.vue b/uni_modules/lime-loading/components/lime-loading/lime-loading.vue deleted file mode 100644 index 5ccceff..0000000 --- a/uni_modules/lime-loading/components/lime-loading/lime-loading.vue +++ /dev/null @@ -1,52 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-loading/index.uts b/uni_modules/lime-loading/index.uts deleted file mode 100644 index 504f76e..0000000 --- a/uni_modules/lime-loading/index.uts +++ /dev/null @@ -1,439 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -type UTSJSONObject = Record -// #endif -// 引入颜色处理库 -import { tinyColor } from '@/uni_modules/lime-color'; - - -/** - * 操作类型 - * play: 开始动画 - * failed: 显示失败状态 - * clear: 清除动画 - * destroy: 销毁实例 - */ -export type TickType = 'play' | 'failed' | 'clear' | 'destroy' | 'pause' -/** - * 加载动画类型 - * circular: 环形加载动画 - * spinner: 旋转器加载动画 - * failed: 失败状态动画 - */ -export type LoadingType = 'circular' | 'spinner' | 'failed'; -/** - * 加载组件返回接口 - */ -export type UseLoadingReturn = { - ratio : 1; - type : LoadingType; - mode : 'raf' | 'animate'; // - color : string;//Ref; - play : () => void; - failed : () => void; - clear : () => void; - destroy : () => void; - pause : () => void; -} - - -/** - * 计算圆周上指定角度的点的坐标 - * @param centerX 圆心的 X 坐标 - * @param centerY 圆心的 Y 坐标 - * @param radius 圆的半径 - * @param angleDegrees 角度(以度为单位) - * @returns 包含 X 和 Y 坐标的对象 - */ -function getPointOnCircle( - centerX : number, - centerY : number, - radius : number, - angleDegrees : number -) : number[] { - // 将角度转换为弧度 - const angleRadians = (angleDegrees * Math.PI) / 180; - - // 计算点的 X 和 Y 坐标 - const x = centerX + radius * Math.cos(angleRadians); - const y = centerY + radius * Math.sin(angleRadians); - - return [x, y] -} - -export function useLoading(element : Ref) : UseLoadingReturn { - let isPlaying = false - let canvasWidth = ref(0) - let canvasHeight = ref(0) - let canvasSize = ref(0) - - let animationFrameId = -1 - let animation : UniAnimation | null = null - - let drawFrame : (() => void) | null = null - - const tick = ref('pause') - const context = shallowRef(null); - const state = reactive({ - color: '#000', - type: 'circular', - ratio: 1, - mode: 'raf', - play: () => { - tick.value = 'play' - }, - failed: () => { - tick.value = 'failed' - }, - clear: () => { - tick.value = 'clear' - }, - destroy: () => { - tick.value = 'destroy' - cancelAnimationFrame(animationFrameId) - animation?.pause() - animation?.cancel() - context.value?.reset(); - context.value?.update(); - context.value = null - animation = null - isPlaying = false - }, - pause: () => { - tick.value = 'pause' - } - }) - - - // let ctx:DrawableContext|null = null - - // let rotation = 0 - - const size = computed(() : number => state.ratio > 1 ? state.ratio : canvasSize.value * state.ratio) - // 绘制圆形加载 - const drawCircular = () => { - let startAngle = 0; // 起始角度 - let endAngle = 0; // 结束角度 - let rotate = 0; // 旋转角度 - - // const ctx = context.value! - // 动画参数配置 - const MIN_ANGLE = 5; // 最小保持角度 - const ARC_LENGTH = 359.5 // 最大弧长(避免闭合) - const PI = Math.PI / 180 // 角度转弧度系数 - const SPEED = 0.018 / 4 // 动画速度 - const ROTATE_INTERVAL = 0.09 / 4 // 旋转增量 - - const lineWidth = size.value / 10; // 线宽计算 - const x = canvasWidth.value / 2 // 中心点X - const y = canvasHeight.value / 2 // 中心点Y - const radius = size.value / 2 - lineWidth // 实际绘制半径 - try { - drawFrame = () => { - if (context.value == null || !isPlaying) return - let ctx = context.value! - - - // console.log('radius', radius, size.value) - ctx.reset(); - - // 绘制圆弧 - ctx.beginPath(); - ctx.arc( - x, - y, - radius, - startAngle * PI + rotate, - endAngle * PI + rotate - ); - ctx.lineWidth = lineWidth; - ctx.strokeStyle = state.color; - ctx.stroke(); - - // 角度更新逻辑 - if (endAngle < ARC_LENGTH) { - endAngle = Math.min(ARC_LENGTH, endAngle + (ARC_LENGTH - MIN_ANGLE) * SPEED); - } else if (startAngle < ARC_LENGTH) { - startAngle = Math.min(ARC_LENGTH, startAngle + (ARC_LENGTH - MIN_ANGLE) * SPEED); - } else { - // 重置时保留最小可见角度 - startAngle = 0; - endAngle = MIN_ANGLE; - } - - ctx.update() - - - - if (state.mode == 'raf') { - rotate = (rotate + ROTATE_INTERVAL) % 360; // 持续旋转并限制范围 - if (isPlaying && drawFrame != null) { - animationFrameId = requestAnimationFrame(drawFrame!) - } - } - } - } catch(err) { - - } - } - - let lastTime = Date.now(); - const drawSpinner = () => { - const steps = 12; // 旋转线条数量 - // const size = state.ratio > 1 ? state.ratio : canvasSize.value - const lineWidth = size.value / 10; // 线宽 - const x = canvasWidth.value / 2 // 中心坐标 - const y = canvasHeight.value / 2 - - let step = 0; // 当前步数 - // #ifdef APP-HARMONY - const length = size.value / 3.4 - lineWidth; // 线长 - // #endif - // #ifndef APP-HARMONY - const length = size.value / 3.6 - lineWidth; // 线长 - // #endif - const offset = size.value / 4; // 距中心偏移 - - /** 生成颜色渐变数组 */ - function generateColorGradient(hex : string, steps : number) : string[] { - const colors : string[] = [] - const _color = tinyColor(hex) - - for (let i = 1; i <= steps; i++) { - _color.setAlpha(i / steps); - colors.push(_color.toRgbString()); - } - return colors - } - - // 计算颜色渐变 - let colors = computed(() : string[] => generateColorGradient(state.color, steps)) - - /** 帧绘制函数 */ - drawFrame = () => { - if (context.value == null || !isPlaying) return - const delta = Date.now() - lastTime; - - - if (delta >= 1000 / 10) { - lastTime = Date.now(); - let ctx = context.value! - ctx.reset(); - for (let i = 0; i < steps; i++) { - const stepAngle = 360 / steps; // 单步角度 - const angle = stepAngle * i; // 当前角度 - const index = (steps + i - step) % steps // 颜色索引 - // 计算线段坐标 - const radian = angle * Math.PI / 180; - const cos = Math.cos(radian); - const sin = Math.sin(radian); - - // 绘制线段 - ctx.beginPath(); - ctx.moveTo(x + offset * cos, y + offset * sin); - ctx.lineTo(x + (offset + length) * cos, y + (offset + length) * sin); - ctx.lineWidth = lineWidth; - ctx.lineCap = 'round'; - ctx.strokeStyle = colors.value[index]; - ctx.stroke(); - } - - ctx.update() - if(state.mode == 'raf') { - // step += 1 - step = (step + 1) % steps; // 限制step范围 - } - } - - - if (state.mode == 'raf') { - if (isPlaying && drawFrame != null) { - animationFrameId = requestAnimationFrame(drawFrame!) - } - } - } - } - - const drwaFailed = () => { - if (context.value == null) return - let ctx = context.value! - - // const size = state.ratio > 1 ? state.ratio : canvasSize.value - const innerSize = size.value * 0.8 // 内圈尺寸 - const lineWidth = innerSize / 10; // 线宽 - const lineLength = (size.value - lineWidth) / 2 // X长度 - const centerX = canvasWidth.value / 2; - const centerY = canvasHeight.value / 2; - const radius = (size.value - lineWidth) / 2 - - - - const angleRadians1 = 45 * Math.PI / 180 - const angleRadians2 = (45 - 90) * Math.PI / 180 - - ctx.reset() - ctx.lineWidth = lineWidth; - ctx.strokeStyle = state.color; - - // 绘制逐渐显示的圆 - ctx.beginPath(); - ctx.arc(centerX, centerY, radius, 0, Math.PI * 2); - ctx.lineWidth = lineWidth; - ctx.strokeStyle = state.color; - ctx.stroke(); - - const [startX1, startY] = getPointOnCircle(centerX, centerY, lineLength / 2, 180 + 45) - const [startX2] = getPointOnCircle(centerX, centerY, lineLength / 2, 180 + 90 + 45) - - const x2 = Math.sin(angleRadians1) * lineLength + startX1 - const y2 = Math.cos(angleRadians1) * lineLength + startY - - ctx.beginPath(); - ctx.moveTo(startX1, startY) - ctx.lineTo(x2, y2) - ctx.stroke(); - - const x3 = Math.sin(angleRadians2) * lineLength + startX2 - const y3 = Math.cos(angleRadians2) * lineLength + startY - - ctx.beginPath(); - ctx.moveTo(startX2, startY) - ctx.lineTo(x3, y3) - ctx.stroke(); - - - ctx.update() - } - - let currentType : LoadingType | null = null - const useMode = () => { - if (state.mode != 'raf') { - const keyframes = [{ transform: 'rotate(0)' }, { transform: 'rotate(360)' }] - animation = element.value!.animate(keyframes, { - duration: 80000, - easing: 'linear', - // fill: 'forwards', - iterations: Infinity - }) - } - } - const startAnimation = (type : string) => { - if (context.value == null || element.value == null) return - animation?.pause() - - if (currentType == type) { - isPlaying = true - animation?.play() - drawFrame?.() - return - } - - if (type == 'circular') { - currentType = 'circular' - drawCircular() - useMode() - - } - - if (type == 'spinner') { - currentType = 'spinner' - drawSpinner() - useMode() - } - - isPlaying = true - drawFrame?.() - } - - // 监听元素尺寸 - let manualCheckTimer:number|null = null; - const getBoundingClientRect = () => { - if(manualCheckTimer != null){ - clearTimeout(manualCheckTimer!); - } - requestAnimationFrame(()=> { - element.value?.getBoundingClientRectAsync()?.then(rect => { - if (rect.width == 0 || rect.height == 0) return - context.value = element.value!.getDrawableContext() as DrawableContext; - canvasWidth.value = rect.width; - canvasHeight.value = rect.height; - canvasSize.value = Math.min(rect.width, rect.height); - // startAnimation(state.type) - }) - }) - } - - const resizeObserver : UniResizeObserver = new UniResizeObserver((_entries : UniResizeObserverEntry[]) => { - getBoundingClientRect() - }); - - watchEffect(() => { - if (element.value == null) return - resizeObserver.observe(element.value!); - // #ifdef APP-IOS - // nextTick(getBoundingClientRect) - manualCheckTimer = setTimeout(() => { - getBoundingClientRect(); - }, 50); - // #endif - }) - - - - watchEffect(() => { - if (context.value == null) return - if (tick.value == 'play') { - animation?.pause() - isPlaying = false - cancelAnimationFrame(animationFrameId) - startAnimation(state.type) - } - if (tick.value == 'failed') { - cancelAnimationFrame(animationFrameId) - animation?.pause() - animation?.cancel() - drwaFailed() - return - } - if (tick.value == 'clear') { - cancelAnimationFrame(animationFrameId) - animation?.pause() - animation?.cancel() - context.value?.reset(); - context.value?.update(); - isPlaying = false - return - } - if (tick.value == 'destroy') { - cancelAnimationFrame(animationFrameId) - animation?.pause() - animation?.cancel() - context.value?.reset(); - context.value?.update(); - context.value = null - animation = null - isPlaying = false - return - } - if (tick.value == 'pause') { - // 首次需要绘制一帧 - if(animation == null) { - startAnimation(state.type) - } - cancelAnimationFrame(animationFrameId) - isPlaying = false - animation?.pause() - return - } - }) - - watchEffect(()=>{ - if(state.color == '') return - // #ifdef APP-HARMONY - isPlaying = false - cancelAnimationFrame(animationFrameId) - // #endif - }) - - return state -} \ No newline at end of file diff --git a/uni_modules/lime-loading/package.json b/uni_modules/lime-loading/package.json deleted file mode 100644 index 76ad84e..0000000 --- a/uni_modules/lime-loading/package.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "id": "lime-loading", - "displayName": "lime-loading 加载", - "version": "0.2.2", - "description": "lime-loading 全端通用加载插件.用于表示页面或操作的加载状态,给予用户反馈的同时减缓等待的焦虑感。支持uniapp/uniappx", - "keywords": [ - "loading", - "lime-loading", - "加载", - "uvue" -], - "repository": "", - "engines": { - "HBuilderX": "^3.92", - "uni-app": "^4.73", - "uni-app-x": "^4.76" - }, - "dcloudext": { - "type": "component-vue", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "", - "darkmode": "√", - "i18n": "x", - "widescreen": "x" - }, - "uni_modules": { - "dependencies": [ - "lime-shared", - "lime-style", - "lime-color" - ], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "√", - "aliyun": "√", - "alipay": "x" - }, - "client": { - "uni-app": { - "vue": { - "vue2": "√", - "vue3": "√" - }, - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "vue": "√", - "nvue": "-", - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√", - "alipay": "-", - "toutiao": "-", - "baidu": "-", - "kuaishou": "-", - "jd": "-", - "harmony": "-", - "qq": "-", - "lark": "-" - }, - "quickapp": { - "huawei": "-", - "union": "-" - } - }, - "uni-app-x": { - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√" - } - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/lime-loading/readme.md b/uni_modules/lime-loading/readme.md deleted file mode 100644 index cf6cdf3..0000000 --- a/uni_modules/lime-loading/readme.md +++ /dev/null @@ -1,114 +0,0 @@ -# lime-loading 加载动画 - -一个功能丰富的加载动画组件,提供多种加载效果,支持自定义颜色、大小和文本,适用于各种加载场景。 - -> 插件依赖:`lime-shared`、`lime-style` - -## 文档链接 -📚 组件详细文档请访问以下站点: -- [加载动画文档 - 站点1](https://limex.qcoon.cn/components/loading.html) -- [加载动画文档 - 站点2](https://limeui.netlify.app/components/loading.html) -- [加载动画文档 - 站点3](https://limeui.familyzone.top/components/loading.html) - -## 安装方法 -1. 在uni-app插件市场中搜索并导入`lime-loading` -2. 导入后可能需要重新编译项目 -3. 在页面中使用`l-loading`组件 - -## 代码演示 - -### 基础使用 -最简单的加载动画使用方式。 - -```html - -``` - -### 不同类型 -通过 `type` 属性可以设置加载图标的类型,默认为 `circular`,可选值为 `spinner`。nvue只有`circular`,因为其使用的是原生组件。 - - -```html - - -``` - -### 自定义颜色和大小 -可以通过`color`和`size`属性自定义加载动画的颜色和大小。 - -```html - -``` - -### 带文本的加载动画 -通过设置`text`属性可以在加载动画下方显示文本。 - -```html - -``` - -### 垂直排列 -通过`vertical`属性可以设置加载动画和文本的排列方式。 - -```html - -``` - -### 自定义文本样式 -可以通过`textSize`和`textColor`属性自定义文本的大小和颜色。 - -```html - -``` - -## Vue2使用说明 -main.js中添加以下代码: -```js -// vue2项目中使用 -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -``` - -详细配置请参考官方文档:[Vue Composition API](https://uniapp.dcloud.net.cn/tutorial/vue-composition-api.html) - -## 插件标签说明 -`l-loading` 为组件标签 -`lime-loading` 为演示标签 - -## API文档 - -### Props 属性说明 - -| 参数 | 说明 | 类型 | 默认值 | -| ---------- | ----------------------------- | ------------------ | ---------- | -| color | 颜色 | _string_ | `` | -| type | 类型,可选值为 `spinner` | _string_ | `circular` | -| size | 加载图标大小,默认单位为 `px`,uvue只支持string | _number \| string_ | `40rpx` | -| text | 加载文本 | _string_ | `-` | -| textColor | 文本颜色 | _string_ | `-` | -| textSize | 文本大小 `px`,uvue只支持string | _number \| string_ | `-` | -| vertical | 是否垂直排列图标和文字内容 | _boolean_ | `false` | -| mode | 动画实现的模式.只针对APP,可选值有:`animate` | _string_ | `raf` | - -## 主题定制 - -组件提供了丰富的CSS变量,可以通过自定义CSS变量来自定义组件样式: - -| 变量名 | 默认值 | 说明 | -| ---- | ---- | ---- | -| --l-loading-color | #1677ff | 加载动画颜色 | -| --l-loading-size | 20px | 加载动画大小 | -| --l-loading-text-color | `$text-color-3` | 文本颜色 | -| --l-loading-text-size | `$font-size`| 文本大小 | - -由于`uniappx app`是基于canvas故暂时`uniappx app`无效 - - -## 支持与赞赏 - -如果你觉得本插件解决了你的问题,可以考虑支持作者: - -| 支付宝赞助 | 微信赞助 | -|------------|------------| -| ![支付宝赞赏码](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) | ![微信赞赏码](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) | \ No newline at end of file diff --git a/uni_modules/lime-picker/changelog.md b/uni_modules/lime-picker/changelog.md deleted file mode 100644 index f854f3a..0000000 --- a/uni_modules/lime-picker/changelog.md +++ /dev/null @@ -1,76 +0,0 @@ -## 0.3.8(2026-05-11) -- fix: 修复缺失watch -## 0.3.7(2026-01-16) -- fix: 修复uniapp vue2问题 -## 0.3.6(2026-01-16) -- fix:修复uniapp vue2报错问题 -## 0.3.5(2025-12-13) -- fix: 修复uniappx ios鸿蒙显示不全问题 -## 0.3.4(2025-12-12) -- fix: 修复uniappx ios,鸿蒙显示问题 -## 0.3.3(2025-10-09) -- fix: 修复uniapp报错的问题 -## 0.3.2(2025-09-28) -- feat: 暴露`confirm`和`getSelectedOptions`方法 -## 0.3.1(2025-09-15) -- fix: 修复uniappx 安卓无法设置选中项的颜色 -## 0.3.0(2025-09-08) -- fix: 修复uniappx 鸿蒙 使用mask-class会导致选中项下边有阴影 -## 0.2.9(2025-09-01) -- fix:修复uniapp 选项高度问题 -## 0.2.8(2025-06-10) -- fix:鸿蒙当插件在弹窗里的时候,文本没有样式(估计为官方BUG) -## 0.2.7(2025-05-30) -- fix:修复ios报`error: Can't find variable: stop` -## 0.2.6(2025-05-12) -- fix:修复安卓尺寸的问题 -## 0.2.5(2025-05-06) -- fix:修复安卓初始化-1报错的问题 -## 0.2.4(2025-04-24) -- feat:字体由rpx转成px -## 0.2.3(2025-04-23) -- fix:安卓更新问题 -## 0.2.2(2025-04-23) -- feat:优化边界 -## 0.2.1(2025-04-22) -- feat:兼容uniappx 鸿蒙next -## 0.2.0(2025-04-18) -- fix:修复安卓字体无加粗的问题 -## 0.1.9(2025-04-18) -- fix:修复安卓更新数据后绘制尺寸不对的问题 -## 0.1.8(2025-03-25) -- fix:修复安卓设置日期大小不居中的问题 -## 0.1.7(2025-03-25) -- fix:修复安卓单标题时不居中的问题 -## 0.1.6(2025-03-25) -- fix:修复单标题时不居中的问题 -## 0.1.5(2025-02-25) -- chore:更新文档 -## 0.1.4(2025-02-20) -- fix:修复uniapp 级联缺少keys问题 -## 0.1.3(2025-02-13) -- fix:修复ios 默认值问题 -## 0.1.2(2025-02-12) -- fix:修复默认值问题 -## 0.1.1(2025-02-11) -- fix:修复uniapp indicator样式问题 -## 0.1.0(2025-02-10) -- fix:修复uniapp pickerItemInstanceArray缺少.value的问题 -## 0.0.9(2025-01-09) -- feat:更新文档 -## 0.0.8(2025-01-09) -- feat:增加级联`l-cascade`组件 -## 0.0.7(2024-12-31) -- fix:修复缺少resetindex -## 0.0.6(2024-12-27) -- feat:更新样式 -## 0.0.5(2024-12-27) -- feat:更新样式 -## 0.0.4(2024-12-27) -- fix:优化列表数据无法更新的问题 -## 0.0.3(2024-12-24) -- feat:去掉多余文本 -## 0.0.2(2024-12-24) -- feat:兼容vue2 -## 0.0.1(2024-12-24) -- init diff --git a/uni_modules/lime-picker/components/l-cascade/l-cascade.uvue b/uni_modules/lime-picker/components/l-cascade/l-cascade.uvue deleted file mode 100644 index 03b5617..0000000 --- a/uni_modules/lime-picker/components/l-cascade/l-cascade.uvue +++ /dev/null @@ -1,129 +0,0 @@ - - - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-cascade/l-cascade.vue b/uni_modules/lime-picker/components/l-cascade/l-cascade.vue deleted file mode 100644 index 1edc780..0000000 --- a/uni_modules/lime-picker/components/l-cascade/l-cascade.vue +++ /dev/null @@ -1,154 +0,0 @@ - - - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-cascade/type.ts b/uni_modules/lime-picker/components/l-cascade/type.ts deleted file mode 100644 index 257152c..0000000 --- a/uni_modules/lime-picker/components/l-cascade/type.ts +++ /dev/null @@ -1,58 +0,0 @@ -// @ts-nocheck -import {PickerColumn, PickerColumnItem ,PickerValue} from '../l-picker/type'; -export type KeysType = { - value: string; - label: string; - children:string; - disabled?: string; -} -export interface CascadeProps { - /** - * 取消按钮文字 - */ - cancelBtn ?: string; - cancelStyle ?: string; - /** - * 确定按钮文字 - */ - confirmBtn ?: string; - confirmStyle ?: string; - /** - * 标题 - */ - title ?: string; - titleStyle ?: string; - /** - * 用来定义 value / label 在 `options` 中对应的字段别名 - */ - keys?: UTSJSONObject; - /** - * 配置每一列的选项 - */ - columns : UTSJSONObject[]; - /** - * 选中值 - */ - modelValue ?: PickerValue[]; - defaultValue ?: PickerValue[]; - value ?: PickerValue[]; - /** - * 是否为加载状态 - */ - loading: boolean; - loadingColor?: string; - loadingMaskColor ?: string; - loadingSize: string; - - itemHeight?: string; - itemColor?: string; - itemFontSize?: string; - itemActiveColor?: string; - - indicatorStyle?: string; - maskColors?: string[]; - bgColor?: string; - groupHeight?: string; - radius?: string; - resetIndex: boolean -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-cascade/utils.uts b/uni_modules/lime-picker/components/l-cascade/utils.uts deleted file mode 100644 index 8959d97..0000000 --- a/uni_modules/lime-picker/components/l-cascade/utils.uts +++ /dev/null @@ -1,123 +0,0 @@ -// @ts-nocheck -import { clamp } from '@/uni_modules/lime-shared/clamp' -import { PickerValue, PickerColumn, PickerColumnItem, PickerPickEvent } from '../l-picker/type'; -import { KeysType } from './type'; -// #ifndef UNI-APP-X -import type { Ref } from '@/uni_modules/lime-shared/vue' -type UTSJSONObject = Record -// #endif - -/** - * 解析键配置对象,生成用于访问选项属性的键映射。 - * - * @param {UTSJSONObject|null} keys - 配置对象,包含 label、value 和 children 的键名。 - * @returns {KeysType} 包含 label、value 和 children 键名的映射对象。 - */ -export function parseKeys(keys : UTSJSONObject | null) : KeysType { - const _labelKey = `${keys?.['label'] ?? 'label'}` - const _valueKey = `${keys?.['value'] ?? 'value'}` - const _childrenKey = `${keys?.['children'] ?? 'children'}` - - return { - label: _labelKey, - value: _valueKey, - children: _childrenKey, - } as KeysType -} - - -/** - * 获取选项数组中第一个未被禁用的选项。 - * - * @param {UTSJSONObject[]} options - 选项对象数组。 - * @returns {UTSJSONObject|null} 第一个未被禁用的选项对象,如果所有选项都被禁用则返回第一个选项。 - */ -export const getFirstEnabledOption = ( - options : UTSJSONObject[], -) : UTSJSONObject | null => - options.find((option) : boolean => option['disabled'] != true) ?? options[0]; - -/** - * 在选项数组中查找指定索引之后或之前的第一个未被禁用的选项的索引。 - * - * @param {UTSJSONObject[]} options - 选项对象数组。 - * @param {number} index - 当前索引位置。 - * @returns {number} 第一个未被禁用的选项的索引,如果不存在则返回 0。 - */ -export function findIndexOfEnabledOption( - options : UTSJSONObject[], - index : number, -) { - index = clamp(index, 0, options.length); - - // for (let i = index; i < options.length; i++) { - // if (options[i]['disabled'] != true) return i; - // } - // for (let i = index - 1; i >= 0; i--) { - // if (options[i]['disabled'] != true) return i; - // } - - // return 0; - return index -} - -/** - * 根据指定的值在选项数组中查找对应的选项对象。 - * - * @param {UTSJSONObject[]} options - 选项对象数组。 - * @param {PickerValue} value - 要查找的值。 - * @param {KeysType} fields - 包含 label、value 和 children 键名的映射对象。 - * @returns {UTSJSONObject|null} 找到的选项对象,如果未找到则返回 null。 - */ -export function findOptionByValue( - options : UTSJSONObject[], - value : PickerValue, - fields : KeysType, -) : UTSJSONObject | null { - if(options.length == 0) return null - const index = options.findIndex((option) : boolean => option[fields.value] == value); - const enabledIndex = findIndexOfEnabledOption(options, index); - return options[enabledIndex]; -} - -/** - * 格式化级联选择器的列数据。 - * - * @param {UTSJSONObject[]} columns - 初始的列数据数组。 - * @param {KeysType} fields - 包含 label、value 和 children 键名的映射对象。 - * @param {Ref} selectedValues - 当前选中的值数组。 - * @returns {PickerColumn[]} 格式化后的级联列数据数组。 - */ -export function formatCascadeColumns( - columns : UTSJSONObject[], - fields : KeysType, - selectedValues : Ref -) { - const formatted : PickerColumn[] = []; - - let cursor : UTSJSONObject | null = {}; - cursor![fields.children] = columns; - let columnIndex = 0; - - while (cursor != null && cursor[fields.children] != null) { - const options : UTSJSONObject[] = cursor[fields.children]! as UTSJSONObject[]; - const value = selectedValues.value.length > columnIndex ? selectedValues.value[columnIndex] : null; - cursor = value != null - ? findOptionByValue(options, value, fields) - : null; - - if (cursor == null && options.length > 0) { - const firstValue = getFirstEnabledOption(options)![fields.value]!; - cursor = findOptionByValue(options, firstValue, fields); - } - - columnIndex++; - formatted.push( - options.map((option : UTSJSONObject) : PickerColumnItem => ({ - label: `${option['label']}`, - value: `${option['value']}`, - } as PickerColumnItem)) - ); - } - return formatted; -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-item/PickerRenderer.uts b/uni_modules/lime-picker/components/l-picker-item/PickerRenderer.uts deleted file mode 100644 index fb0a5d5..0000000 --- a/uni_modules/lime-picker/components/l-picker-item/PickerRenderer.uts +++ /dev/null @@ -1,187 +0,0 @@ -// @ts-nocheck -import { unitConvert } from '@/uni_modules/lime-shared/unitConvert' -import type { PickerColumnItem, PickerValue } from '../l-picker/type'; -// #ifdef APP-ANDROID || APP-IOS -type PickerCanvasElement = UniElement -type PickerDrawableContext = DrawableContext -// #endif -// #ifdef APP-HARMONY -type PickerCanvasElement = UniElement//UniCanvasElement -type PickerDrawableContext = DrawableContext//CanvasRenderingContext2D -// #endif - - -export type PickerCanvasConfig = { - itemHeight : number; - itemFontSize : number; - itemActiveFontWeight ?: number; - itemColor ?: string; - itemActiveColor ?: string; - canvasWidth : number; - canvasHeight : number; -} - -export class PickerCanvasRenderer { - // private canvas : PickerCanvasElement | null = null; - private ctx : PickerDrawableContext | null = null; - private dpr : number = 1; - private isInitialized : boolean = false; - private canvas : PickerCanvasElement - private lastWidth : number = 0; - private lastHeight : number = 0; - constructor(itemRef : PickerCanvasElement) { - this.canvas = itemRef - this.initCanvas(); - } - - private initCanvas() { - // #ifdef APP-ANDROID||APP-IOS || APP-HARMONY - // this.ctx = this.canvas.getDrawableContext(); - this.isInitialized = true; - return - // #endif - - // #ifdef APP-HARMONY - const rect = this.canvas.getBoundingClientRect() - // this.ctx = this.canvas.getContext('2d'); - this.ctx = this.canvas.getDrawableContext(); - this.dpr = uni.getDeviceInfo().devicePixelRatio ?? 1; - this.isInitialized = true; - // this.canvas.height = rect.height * this.dpr; - // this.canvas.width = rect.width * this.dpr; - // this.ctx.scale(this.dpr, this.dpr); - this.lastWidth = rect.width; - this.lastHeight = rect.height; - // #endif - } - - private setupCanvas(width : number, height : number) { - // if (!this.isInitialized) return; - // #ifdef APP-ANDROID || APP-IOS || APP-HARMONY - // this.canvas.style.setProperty('height', `${height}px`); - // this.ctx?.reset(); - return - // #endif - - // #ifdef APP-HARMONY - if (this.lastWidth == width && this.lastHeight == height) return; - - this.lastWidth = width; - this.lastHeight = height; - // this.canvas.height = height * this.dpr; - // this.canvas.width = width * this.dpr; - // this.ctx?.setTransform(1, 0, 0, 1, 0, 0); - // this.ctx?.scale(this.dpr, this.dpr); - // #endif - } - clearRect(width : number = 1000, height : number = 100000) { - // #ifdef APP-ANDROID || APP-IOS || APP-HARMONY - this.ctx?.reset(); - return - // #endif - // #ifdef APP-HARMONY - this.ctx?.clearRect(0, 0, width, height); - // #endif - } - render(options : PickerColumnItem[], curIndex : number, config : PickerCanvasConfig, isDarkMode : boolean) { - // 安卓不能把ctx存在实例中? - // if(this.ctx == null) return - - const ctx = this.canvas.getDrawableContext()! - const itemHeight = config.itemHeight; - const fontSize = config.itemFontSize; - const canvasWidth = config.canvasWidth - const canvasHeight = config.canvasHeight - // this.ctx = ctx - // 设置容器和Canvas尺寸 - this.setupCanvas(canvasWidth, canvasHeight); - ctx.reset(); - const x = canvasWidth / 2; - const itemActiveFontWeight = config?.itemActiveFontWeight ?? 700; - - const color = config?.itemColor ?? (isDarkMode ? `rgba(255,255,255,0.88)` : 'rgba(0,0,0,0.88)'); - const itemActiveColor = config?.itemActiveColor ?? (isDarkMode ? `rgba(255,255,255,0.88)` : 'rgba(0,0,0,0.88)'); - - - // 设置绘图上下文 - // #ifndef APP-HARMONY - ctx.font = `${fontSize}px`; - // #endif - // #ifdef APP-HARMONY - ctx.font = `${fontSize}px`;// sans-serif - // #endif - ctx.textAlign = 'center'; - // ctx.textBaseline = 'middle'; // 使用中间基线实现垂直居中 - ctx.lineWidth = 0.5; - - // 清空画布 - this.clearRect(canvasWidth, canvasHeight); - - // 绘制所有选项 - options.forEach((item, index) => { - // const y = itemHeight * index + (itemHeight + fontSize) / 2; - let offset = 0.4 - // #ifdef APP-IOS - offset = 0.55 - // #endif - const y = itemHeight * index + fontSize + (itemHeight - fontSize) * offset; - // const y = itemHeight * index + itemHeight / 2; // 垂直居中 - - const isActive = index == curIndex && itemActiveFontWeight > 600; - ctx.fillStyle = isActive ? itemActiveColor : color; - ctx.strokeStyle = isActive ? itemActiveColor : color; - - ctx.fillText(item.label, x, y); - - if (isActive) { - // #ifdef APP-IOS || APP-HARMONY - // ctx.strokeText(item.label, x, y); - ctx.fillText(item.label, x - 0.2, y); - ctx.fillText(item.label, x + 0.2, y); - ctx.fillText(item.label, x, y - 0.2); - ctx.fillText(item.label, x, y + 0.2); - // #endif - // #ifndef APP-IOS|| APP-HARMONY - ctx.strokeText(item.label, x, y); - // #endif - } - }); - - // #ifdef APP-ANDROID || APP-IOS || APP-HARMONY - ctx.update(); - // #endif - } - - destroy() { - // this.canvas = null; - this.ctx = null; - this.isInitialized = false; - } -} - -// // 在组件中使用 -// const canvasRenderer = ref(null); - -// const updateItemStyle = () => { -// if (!itemRef.value) return; - -// // 初始化渲染器(只初始化一次) -// if (!canvasRenderer.value) { -// canvasRenderer.value = new PickerCanvasRenderer( -// itemRef.value, -// isDarkMode.value, -// picker -// ); -// } - -// // 执行渲染 -// canvasRenderer.value.render(props.options, curIndex.value); -// }; - -// // 在组件卸载时清理 -// onBeforeUnmount(() => { -// if (canvasRenderer.value) { -// canvasRenderer.value.destroy(); -// canvasRenderer.value = null; -// } -// }); \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-item/index.scss b/uni_modules/lime-picker/components/l-picker-item/index.scss deleted file mode 100644 index 6bf8613..0000000 --- a/uni_modules/lime-picker/components/l-picker-item/index.scss +++ /dev/null @@ -1,82 +0,0 @@ -@import '~@/uni_modules/lime-style/index.scss'; -/* #ifdef uniVersion >= 4.75 */ -$use-css-var: true; -/* #endif */ - -$item: #{$prefix}-picker-item; - -$picker-group-height: create-var(picker-group-height, 200px); -$picker-indicator-bg-color: create-var(picker-indicator-bg-color, $fill-4); -$picker-indicator-border-radius: create-var(picker-indicator-border-radius, 6px); - -$picker-item-height: create-var(picker-item-height, 50px); -$picker-item-active-color: create-var(picker-item-active-color, $text-color-1); -$picker-item-active-font-weight: create-var(picker-item-active-font-weight, 700); -$picker-item-color: create-var(picker-item-color, $text-color-1); -$picker-item-font-size: create-var(picker-item-font-size, $font-size-md); -$picker-mask-top-color: create-var(picker-mask-top-color, white); -$picker-mask-bottom-color: create-var(picker-mask-bottom-color, rgba(36, 36, 36, 0)); - - -/* #ifndef UNI-APP-X && APP */ -:host { - flex: 1; - display: flex; -} -/* #endif */ - - -.#{$item} { - /* #ifndef UNI-APP-X && APP */ - // uniapp x鸿蒙这个设置导致选中项下边黑影 - &__mask { - background-image: - linear-gradient(180deg, $picker-mask-top-color, $picker-mask-bottom-color), - linear-gradient(0deg, $picker-mask-top-color, $picker-mask-bottom-color) - } - /* #endif */ - &__group { - /* #ifdef WEB */ - :deep(.uni-picker-view-content) { - // 300ms - transition-duration: var(--picker-duration, 0); - } - /* #endif */ - flex: 1; - - // height: $picker-group-height; - &-item { - height: $picker-item-height; - line-height: $picker-item-height; - text-align: center; - /* #ifndef UNI-APP-X && APP */ - display: flex; - justify-content: center; - /* #endif */ - transition-duration: 100ms; - transition-property: font-weight, color; - transition-timing-function: linear; - font-weight: 400; - color: $picker-item-color; - font-size: $picker-item-font-size; - white-space: nowrap; - &--active { - color: $picker-item-active-color; - font-weight: $picker-item-active-font-weight; - } - } - } - &__wrapper { - width: 100%; - // background-color: red; - } - &__indicator { - /* #ifndef UNI-APP-X && APP */ - height: $picker-item-height; - &:after,&:before{ - display: none; - } - /* #endif */ - } -} - diff --git a/uni_modules/lime-picker/components/l-picker-item/l-picker-item-old.uvue b/uni_modules/lime-picker/components/l-picker-item/l-picker-item-old.uvue deleted file mode 100644 index ff4fd36..0000000 --- a/uni_modules/lime-picker/components/l-picker-item/l-picker-item-old.uvue +++ /dev/null @@ -1,324 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-item/l-picker-item.uvue b/uni_modules/lime-picker/components/l-picker-item/l-picker-item.uvue deleted file mode 100644 index 973c3e0..0000000 --- a/uni_modules/lime-picker/components/l-picker-item/l-picker-item.uvue +++ /dev/null @@ -1,297 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-item/l-picker-item.vue b/uni_modules/lime-picker/components/l-picker-item/l-picker-item.vue deleted file mode 100644 index f5ab756..0000000 --- a/uni_modules/lime-picker/components/l-picker-item/l-picker-item.vue +++ /dev/null @@ -1,212 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-item/props.ts b/uni_modules/lime-picker/components/l-picker-item/props.ts deleted file mode 100644 index 3e8cc96..0000000 --- a/uni_modules/lime-picker/components/l-picker-item/props.ts +++ /dev/null @@ -1,15 +0,0 @@ -// @ts-nocheck -export default { - options: { - type: Array, - default: () => [] - }, - value: { - type: [String, Number], - default: null - }, - column: { - type: Number, - default: -1 - } -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-item/type.ts b/uni_modules/lime-picker/components/l-picker-item/type.ts deleted file mode 100644 index 7125295..0000000 --- a/uni_modules/lime-picker/components/l-picker-item/type.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -import type{ PickerColumnItem, PickerValue } from '../l-picker/type'; - -export type ManageChildInList = (child: LPickerItemComponentPublicInstance, shouldAdd: boolean) => void; -export type OnPick = (value: PickerValue, index:number, column: number) => void; -export type UpdateItems = (value: PickerValue, index:number, column: number) => void; - -export interface PickerItemProps { - options: PickerColumnItem[] - value?: PickerValue; - column: number - name?: string|number -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-item/usePickerMask.ts b/uni_modules/lime-picker/components/l-picker-item/usePickerMask.ts deleted file mode 100644 index dc2c846..0000000 --- a/uni_modules/lime-picker/components/l-picker-item/usePickerMask.ts +++ /dev/null @@ -1,86 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -import { computed, ComputedRef, Ref } from '@/uni_modules/lime-shared/vue'; -// #endif -export type MaskConfig = { - maskStartColor : string; - maskEndColor : string; -}; - -export type PlatformMaskStyles = { - common : string; - top : string; - bottom : string; -}; -export type UsePickerMaskReturn = { - maskConfig : ComputedRef; - platformMaskStyles : ComputedRef; -} - -/** - * 生成 Picker 组件顶部与底部的渐变遮罩样式(完全响应式) - * - * @param backgroundColorRef - 背景色 ref 或 computed(可为 null) - * @param isDarkModeRef - 是否暗色模式(响应式) - * @param maskColorsRef - 自定义遮罩颜色 [start, end](响应式) - * @param isInitializedRef - 是否已初始化(响应式) - */ -export const usePickerMask = ( - backgroundColorRef : ComputedRef, - isDarkModeRef :ComputedRef, - maskColorsRef :ComputedRef, - isInitializedRef : Ref -) : UsePickerMaskReturn => { - const maskConfig = computed(() => { - const bgColor = backgroundColorRef.value; - const isDark = isDarkModeRef.value; - const maskColors = maskColorsRef?.value; - - // 优先使用用户提供的 maskColors - if (maskColors != null && maskColors.length >= 1) { - const maskStartColor = maskColors![0] - const maskEndColor = maskColors!.length > 1 ? maskColors[1] : 'rgba(0,0,0,0)' - return { - maskStartColor, - maskEndColor - } as MaskConfig - } - - const bg = bgColor ?? (isDark ? '#242424' : '#ffffff'); - const endColor = isDark - ? 'rgba(36, 36, 36, 0)' - : 'rgba(255, 255, 255, 0)'; - - return { - maskStartColor: bg, - maskEndColor: endColor - } as MaskConfig - }); - - const platformMaskStyles = computed(() => { - const { maskStartColor, maskEndColor } = maskConfig.value; - - const clean = (str : string) => str.replace(/\s+/g, ' ').trim(); - - return { - common: backgroundColorRef.value == null && !isDarkModeRef.value - ? clean(`background-image: - linear-gradient(180deg, ${maskStartColor}, ${maskEndColor}), - linear-gradient(0deg, ${maskStartColor}, ${maskEndColor})`) - : '', - // #ifndef APP-IOS - top: `background-image: linear-gradient(to bottom, ${maskStartColor}, ${maskEndColor})`, - bottom: `background-image: linear-gradient(to top, ${maskStartColor}, ${maskEndColor})`, - // #endif - // #ifdef APP-IOS - top: isInitializedRef.value ? 'background-color: rgba(0,0,0,0)' : '', - bottom: isInitializedRef.value ? 'background-color: rgba(0,0,0,0)' : '' - // #endif - } as PlatformMaskStyles - }); - - return { - maskConfig, - platformMaskStyles - } as UsePickerMaskReturn -}; \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-view/index.scss b/uni_modules/lime-picker/components/l-picker-view/index.scss deleted file mode 100644 index 3f0c17d..0000000 --- a/uni_modules/lime-picker/components/l-picker-view/index.scss +++ /dev/null @@ -1,191 +0,0 @@ -@import '~@/uni_modules/lime-style/index.scss'; - -/* #ifdef uniVersion >= 4.75 */ -$use-css-var: true; -/* #endif */ - -$picker: #{$prefix}-picker-view; - - -$picker-border-radius: create-var(picker-border-radius, $border-radius-xl); -$picker-bg-color: create-var(picker-bg-color, $bg-color-container); -$picker-toolbar-height: create-var(picker-toolbar-height, 58px); - -$picker-cancel-color: create-var(picker-cancel-color, $text-color-2); -$picker-confirm-color: create-var(picker-confirm-color, $primary-color); -$picker-button-font-size: create-var(picker-button-font-size, $font-size-md); - -$picker-title-font-size: create-var(picker-title-font-size, 18px); -$picker-title-font-weight: create-var(picker-title-font-weight, 700); -$picker-title-line-height: create-var(picker-title-line-height, 26px); -$picker-title-color: create-var(picker-title-color, $text-color-1); - - -$picker-group-height: create-var(picker-group-height, 200px); -$picker-indicator-bg-color: create-var(picker-indicator-bg-color, $fill-3); -$picker-indicator-border-radius: create-var(picker-indicator-border-radius, $border-radius); -$picker-indicator-margin: create-var(picker-indicator-margin, 10px); - -$picker-item-height: create-var(picker-item-height, 50px); -$picker-item-active-color: create-var(picker-item-active-color, $text-color-1); - - -$picker-loading-mask-color: create-var(picker-loading-mask-color, rgba(255,255,255,.9)); -$picker-loading-color: create-var(picker-loading-color, $primary-color); - - -// $item: #{$prefix}-picker-item; -$picker-item-active-font-weight: create-var(picker-item-active-font-weight, 700); -$picker-item-color: create-var(picker-item-color, $text-color-1); -$picker-item-font-size: create-var(picker-item-font-size, $font-size-md); -$picker-mask-top-color: create-var(picker-mask-top-color, white); -$picker-mask-bottom-color: create-var(picker-mask-bottom-color, rgba(36, 36, 36, 0)); - - -.#{$picker} { - position: relative; - background-color: $picker-bg-color; - border-top-left-radius: $picker-border-radius; - border-top-right-radius: $picker-border-radius; - - &__toolbar { - display: flex; - align-items: center; - justify-content: space-between; - // overflow: hidden; - height: $picker-toolbar-height; - flex-direction: row; - position: relative; - } - &__title { - /* #ifdef UNI-APP-X && APP */ - position: absolute; - left: 50%; - top: 50%; - transform: translateX(-50%) translateY(-50%); - /* #endif */ - text-align: center; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - color: $picker-title-color; - // line-height: $picker-toolbar-height; - line-height: $picker-title-line-height; - font-weight: $picker-title-font-weight; - font-size: $picker-title-font-size; - } - - &__cancel, - &__confirm { - white-space: nowrap; - // position: absolute; - /* #ifndef UNI-APP-X && APP */ - display: flex; - align-items: center; - justify-content: center; - user-select: none; - /* #endif */ - font-size: $picker-button-font-size; - line-height: $picker-toolbar-height; - height: 100%; - // padding: 0 $spacer; - @include padding(0 $spacer); - } - - &__cancel { - // left: 0; - margin-right: auto; - color: $picker-cancel-color; - } - - &__confirm { - margin-left: auto; - color: $picker-confirm-color; - // right: 0 - } - - - &__main { - position: relative; - display: flex; - height: $picker-group-height; - flex-direction: row; - z-index: 2; - // padding: 0 $spacer-xs; - @include padding(0 $spacer-xs); - } - &__mask { - - } - &__empty { - pointer-events: none; - justify-content: center; - align-items: center; - display: flex; - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - z-index: 3; - } - &__loading { - z-index: 3; - // color: $picker-loading-color; - background-color: $picker-loading-mask-color; - // background-color: red; - justify-content: center; - align-items: center; - display: flex; - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0 - } - &__indicator{ - position: absolute; - background-color: $picker-indicator-bg-color; - top: 50%; - left: $picker-indicator-margin; - right: $picker-indicator-margin; - height: $picker-item-height; - transform: translateY(-50%); - z-index: -1; - @include border-radius($picker-indicator-border-radius); - } - - &__group { - flex: 1; - width: 100%; - - &-item { - height: $picker-item-height; - line-height: $picker-item-height; - text-align: center; - /* #ifndef UNI-APP-X && APP */ - display: flex; - justify-content: center; - /* #endif */ - transition-duration: 100ms; - transition-property: font-weight, color; - transition-timing-function: linear; - font-weight: 400; - color: $picker-item-color; - font-size: $picker-item-font-size; - white-space: nowrap; - &--active { - color: $picker-item-active-color; - font-weight: $picker-item-active-font-weight; - } - } - } - &__indicator { - /* #ifndef UNI-APP-X && APP */ - height: $picker-item-height; - &:after,&:before{ - display: none; - } - /* #endif */ - } -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-view/l-picker-view.uvue b/uni_modules/lime-picker/components/l-picker-view/l-picker-view.uvue deleted file mode 100644 index 891570a..0000000 --- a/uni_modules/lime-picker/components/l-picker-view/l-picker-view.uvue +++ /dev/null @@ -1,285 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-view/l-picker-view.vue b/uni_modules/lime-picker/components/l-picker-view/l-picker-view.vue deleted file mode 100644 index 7a230f4..0000000 --- a/uni_modules/lime-picker/components/l-picker-view/l-picker-view.vue +++ /dev/null @@ -1,173 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-view/props.ts b/uni_modules/lime-picker/components/l-picker-view/props.ts deleted file mode 100644 index 90b128c..0000000 --- a/uni_modules/lime-picker/components/l-picker-view/props.ts +++ /dev/null @@ -1,128 +0,0 @@ -// @ts-nocheck -export default { - /** - * 取消按钮文字 - */ - cancelBtn: { - type: String, - default: null - }, - cancelStyle: { - type: [String, Object], - default: null - }, - /** - * 确定按钮文字 - */ - confirmBtn: { - type: String, - default: null - }, - confirmStyle: { - type: [String, Object], - default: null - }, - keys: { - type: Object, - default: null - }, - /** - * 标题 - */ - title: { - type: String, - default: null - }, - titleStyle: { - type: [String, Object], - default: null - }, - /** - * 配置每一列的选项 - */ - columns: { - type: Array, - default: () => [] - }, - /** - * 选中值 - */ - modelValue: { - type: Array, - default: null - }, - defaultValue: { - type: Array, - default: null - }, - value: { - type: Array, - default: null - }, - /** - * 是否为加载状态 - */ - loading: { - type: Boolean, - default: false - }, - loadingColor: { - type: String, - default: null - }, - loadingMaskColor: { - type: String, - default: null - }, - loadingSize: { - type: String, - default: '64rpx' - }, - - itemHeight: { - type: String - }, - itemColor: { - type: String, - default: '' - }, - itemFontSize: { - type: String, - default: '' - }, - itemActiveColor: { - type: String, - default: '' - }, - itemActiveFontWeight: { - type: Number, - default: null - }, - - indicatorStyle: { - type: String, - default: '' - }, - bgColor: { - type: String, - default: null - }, - groupHeight: { - type: String, - default: '' - }, - radius: { - type: String, - default: null - }, - /** - * 列表更新后,是否归0 - */ - resetIndex: { - type: Boolean, - default: false - }, - maskColors: { - type: Array, - } -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-view/type.ts b/uni_modules/lime-picker/components/l-picker-view/type.ts deleted file mode 100644 index efdb5dd..0000000 --- a/uni_modules/lime-picker/components/l-picker-view/type.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-nocheck -import type{ PickerProps, PickerColumn, PickerValue, PickerColumnItem, PickerConfirmEvent, PickerPickEvent, PickerChangeInfo } from '../l-picker/type'; - -export type ManageChildInList = (child: LPickerItemComponentPublicInstance, shouldAdd: boolean) => void; -export type OnPick = (value: PickerValue, index:number, column: number) => void; -export type UpdateItems = (value: PickerValue, index:number, column: number) => void; - -export interface PickerViewProps extends PickerProps { - // 可以在这里添加l-picker-view特有的属性 -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker-view/usePickerView.ts b/uni_modules/lime-picker/components/l-picker-view/usePickerView.ts deleted file mode 100644 index ad9379c..0000000 --- a/uni_modules/lime-picker/components/l-picker-view/usePickerView.ts +++ /dev/null @@ -1,339 +0,0 @@ -// @ts-nocheck -import type { PickerProps, PickerValue, PickerColumnItem, PickerColumn, PickerConfirmEvent, PickerPickEvent } from '../l-picker/type'; -import { arrayEqual } from '@/uni_modules/lime-shared/arrayEqual'; -import { clamp } from '@/uni_modules/lime-shared/clamp'; -import { assignAtIndex } from '@/uni_modules/lime-shared/assignAtIndex' -// #ifndef UNI-APP-X -import { computed, ref, watch, onMounted, nextTick, onBeforeUnmount, toRaw, WritableComputedOptions, Ref, ComputedRef } from '@/uni_modules/lime-shared/vue'; -// #endif -// #ifdef UNI-APP-X -import type { ComputedRef } from 'vue' -// #endif - -// 定义 usePickerView 钩子的返回类型接口 -export type UsePickerViewReturn = { - // 状态 - defaultValue : Ref; - curIndex : Ref; - curValue : Ref; - curItem : Ref; - - // 计算属性 - modelValue : ComputedRef; - isEmpty : ComputedRef; - innerIndex : ComputedRef; - - // 方法 - getIndexByValue : (val : PickerValue | null, columnIndex : number) => number; - setIndex : (indexes : number[]) => void; - setValue : (values : PickerValue[]) => void; - updatePickerItems : () => void; - handlePick : (e : UniPickerViewChangeEvent) => void; - onCancel : (e : UniPointerEvent) => void; - onConfirm : () => void; - getSelectedOptions : () => PickerConfirmEvent; -} - - -/** - * 检测变化的列索引 - * @param newIndexes 新的索引数组 - * @param oldIndexes 旧的索引数组 - * @returns 变化的列索引,如果没有变化返回-1 - */ -const findChangedColumnIndex = ( - newIndexes : number[], - oldIndexes : number[] -) : number => { - // 比较两个数组的长度,取较长的进行遍历 - const maxLength = Math.max(newIndexes.length, oldIndexes.length); - - for (let i = 0; i < maxLength; i++) { - const newIndex = i < newIndexes.length ? newIndexes[i] : null; - const oldIndex = i < oldIndexes.length ? oldIndexes[i] : null; - - // 如果索引不相等,说明该列发生了变化 - if (newIndex != oldIndex) { - return i; - } - } - - return -1; // 没有变化 -}; - - -export function usePickerView(props : PickerProps) : UsePickerViewReturn { - // 内部状态管理 - const defaultValue = ref(props.value ?? props.modelValue ?? props.defaultValue ?? []); - const curIndex = ref([]); - const curValue = ref([]); - const curItem = ref([]); - // 添加初始化标志 - let isInitialized = false; - let isInternalChange = false; - - const instance = getCurrentInstance()?.proxy - // 计算属性 - const modelValue = computed({ - set(value : PickerValue[]) { - if (arrayEqual(value, defaultValue.value)) return; - defaultValue.value = value; - instance?.$emit('update:modelValue', value); - instance?.$emit('change', value); - }, - get() : PickerValue[] { - return props.value ?? props.modelValue ?? defaultValue.value; - } - } as WritableComputedOptions); - - const isEmpty = computed(() : boolean => { - return props.columns.length == 0 || props.columns.every(column => column.length == 0); - }); - - const innerIndex = computed(() : number[] => { - return curIndex.value; - }); - - // 辅助方法 - const getIndexByValue = (val : PickerValue | null, columnIndex : number) : number => { - let defaultIndex = 0; - if (val != null && props.columns.length > columnIndex) { - defaultIndex = props.columns[columnIndex].findIndex((item) => item.value == val); - - } - - return defaultIndex < 0 ? 0 : defaultIndex; - }; - - const setIndex = (indexes : number[]) => { - const oldIndex = [...curIndex.value] - indexes.forEach((index, columnIndex) => { - if (props.columns.length < columnIndex + 1) return; - // let lastIndex = curIndex.value[columnIndex] || 0; - let _index = clamp(index, 0, props.columns[columnIndex].length - 1); - if (props.columns[columnIndex].length > _index) { - assignAtIndex(curIndex.value, columnIndex, _index) - assignAtIndex(curValue.value, columnIndex, props.columns[columnIndex][_index].value) - assignAtIndex(curItem.value, columnIndex, props.columns[columnIndex][_index]) - } - }); - // 只有创建新的数组 watch才能监听到 - curIndex.value = [...curIndex.value] - curValue.value = [...curValue.value] - curItem.value = [...curItem.value] - }; - - const setValue = (values : PickerValue[]) => { - if (arrayEqual(values, curValue.value)) return; - - const indexes : number[] = []; - values.forEach((value, columnIndex) => { - const index = getIndexByValue(value, columnIndex); - indexes.push(index); - }); - // _changedColumn = -1 - setIndex(indexes); - }; - - const updatePickerItems = () => { - const _indexs : number[] = []; - const _values : PickerValue[] = []; - const _oldIndexs = curIndex.value - props.columns.forEach((column, columnIndex) => { - if (column.length == 0) return; - const value = curValue.value.length > columnIndex ? curValue.value[columnIndex] : null; - const index = value == null ? 0 : getIndexByValue(value, columnIndex); - const item = column[index]; - - _indexs.push(index); - _values.push(item.value); - assignAtIndex(curItem.value, columnIndex, item) - - }); - - if (arrayEqual(curValue.value, _values) && arrayEqual(curIndex.value, _indexs)) return; - curIndex.value = _indexs; - curValue.value = _values; - modelValue.value = [...curValue.value]; - - // #ifdef APP-IOS - - if (_oldIndexs.length != _indexs.length) return - // uniappx ios可能无法滚动到指定项 - // 所以先找到变化的列 让列里的项先前滚动再滚回 - // 找出变化的列 - const changedColumn = findChangedColumnIndex(_indexs, _oldIndexs) - isInternalChange = true - requestAnimationFrame(() => { - const value = curIndex.value[changedColumn] - curIndex.value[changedColumn] = value - 1 - requestAnimationFrame(() => { - curIndex.value[changedColumn] = value - requestAnimationFrame(() => { - isInternalChange = false - }) - }) - }) - // #endif - - - }; - - // 事件处理 - const handlePick = (e : UniPickerViewChangeEvent) => { - // 如果是初始化阶段,不处理 - if (!isInitialized || isInternalChange) return; - const indexes = [...e.detail.value]; - if (arrayEqual(indexes, curIndex.value)) return; - // 处理索引越界问题 - indexes.forEach((v, i) => { - if (i < props.columns.length) { - const n = props.columns[i].length; - - if (v >= n) { - indexes[i] = n - 1; - } - } - }); - // 找出变化的列 - const changedColumn = findChangedColumnIndex(indexes, curIndex.value) - // let changedColumn = -1; - // for (let i = 0; i < indexes.length; i++) { - - // if (i < curIndex.value.length) { - // if (indexes[i] != curIndex.value[i]) { - // changedColumn = i; - // break; - // } - // } else { - // // 如果当前索引不存在,说明是新增的列 - // changedColumn = i; - // break; - // } - // } - setIndex(indexes); - if (changedColumn != -1) { - const column = props.columns[changedColumn]; - const index = indexes[changedColumn]; - const item = column[index]; - - const obj : PickerPickEvent = { - values: curValue.value, - column: changedColumn, - index - }; - - modelValue.value = [...curValue.value]; - instance?.$emit('pick', obj); - } - }; - - const onCancel = (e : UniPointerEvent) => { - updatePickerItems(); - instance?.$emit('cancel', e); - }; - - const onConfirm = () => { - const values = [...curValue.value]; - const indexs = [...curIndex.value]; - const items = curItem.value.map((item) : PickerColumnItem => toRaw(item)); - - if (!arrayEqual(modelValue.value, values)) { - modelValue.value = values; - } - - const obj : PickerConfirmEvent = { - values, - indexs, - items - }; - - instance?.$emit('confirm', obj); - }; - - const getSelectedOptions = () : PickerConfirmEvent => { - const values = [...curValue.value]; - const indexs = [...curIndex.value]; - const items = curItem.value.map((item) : PickerColumnItem => toRaw(item)); - - if (!arrayEqual(modelValue.value, values)) { - modelValue.value = values; - } - - const obj : PickerConfirmEvent = { - values, - indexs, - items - }; - - return obj; - }; - - // 生命周期管理 - const stopModelValue = watch(modelValue, () => { - // 如果是初始化阶段,不处理 - if (!isInitialized) return; - if (arrayEqual(modelValue.value, curValue.value)) return; - curValue.value = modelValue.value.map((item : PickerValue) => item); - updatePickerItems(); - }); - - // const stopColumns = watch(() : PickerColumn[] => props.columns, () => { - // updatePickerItems(); - // }, { deep: true }); - - const stopColumns = watchEffect(() => { - const currentColumns = props.columns; - if (!isInitialized) return - nextTick(() => { - // 可能会跟change发生冲突 - updatePickerItems(); - }) - }) - - onMounted(() => { - if ( - !arrayEqual(modelValue.value, curValue.value) && - modelValue.value.length > 0) { - isInternalChange = true; // 标记为内部变化 - curValue.value = [...modelValue.value]; - } - updatePickerItems(); - // 延迟设置初始化完成标志 - nextTick(() => { - setTimeout(() => { - isInitialized = true; - isInternalChange = false; - }, 300) - }); - }); - - onBeforeUnmount(() => { - stopModelValue(); - stopColumns(); - }); - - // 返回所有需要在模板中使用的状态和方法 - return { - // 状态 - defaultValue, - curIndex, - curValue, - curItem, - - // 计算属性 - modelValue, - isEmpty, - innerIndex, - - // 方法 - getIndexByValue, - setIndex, - setValue, - updatePickerItems, - handlePick, - onCancel, - onConfirm, - getSelectedOptions - } as UsePickerViewReturn; -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker/index.scss b/uni_modules/lime-picker/components/l-picker/index.scss deleted file mode 100644 index 687094c..0000000 --- a/uni_modules/lime-picker/components/l-picker/index.scss +++ /dev/null @@ -1,149 +0,0 @@ -@import '~@/uni_modules/lime-style/index.scss'; - -/* #ifdef uniVersion >= 4.75 */ -$use-css-var: true; -/* #endif */ - -$picker: #{$prefix}-picker; - - -$picker-border-radius: create-var(picker-border-radius, $border-radius-xl); -$picker-bg-color: create-var(picker-bg-color, $bg-color-container); -$picker-toolbar-height: create-var(picker-toolbar-height, 58px); - -$picker-cancel-color: create-var(picker-cancel-color, $text-color-2); -$picker-confirm-color: create-var(picker-confirm-color, $primary-color); -$picker-button-font-size: create-var(picker-button-font-size, $font-size-md); - -$picker-title-font-size: create-var(picker-title-font-size, 18px); -$picker-title-font-weight: create-var(picker-title-font-weight, 700); -$picker-title-line-height: create-var(picker-title-line-height, 26px); -$picker-title-color: create-var(picker-title-color, $text-color-1); - - -$picker-group-height: create-var(picker-group-height, 200px); -$picker-indicator-bg-color: create-var(picker-indicator-bg-color, $fill-3); -$picker-indicator-border-radius: create-var(picker-indicator-border-radius, $border-radius); -$picker-indicator-margin: create-var(picker-indicator-margin, 10px); - -$picker-item-height: create-var(picker-item-height, 50px); -$picker-item-active-color: create-var(picker-item-active-color, $text-color-1); - - -$picker-loading-mask-color: create-var(picker-loading-mask-color, rgba(255,255,255,.9)); -$picker-loading-color: create-var(picker-loading-color, $primary-color); - -.#{$picker} { - position: relative; - background-color: $picker-bg-color; - border-top-left-radius: $picker-border-radius; - border-top-right-radius: $picker-border-radius; - - &__toolbar { - display: flex; - align-items: center; - justify-content: space-between; - // overflow: hidden; - height: $picker-toolbar-height; - flex-direction: row; - position: relative; - } - &__title { - /* #ifdef APP-ANDROID || APP-IOS */ - // 鸿蒙使用定位在弹窗里会导致样式不生效 - position: absolute; - left: 50%; - top: 50%; - transform: translateX(-50%) translateY(-50%); - /* #endif */ - text-align: center; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - color: $picker-title-color; - // line-height: $picker-toolbar-height; - line-height: $picker-title-line-height; - font-weight: $picker-title-font-weight; - font-size: $picker-title-font-size; - } - - &__cancel, - &__confirm { - white-space: nowrap; - // position: absolute; - /* #ifndef UNI-APP-X && APP */ - display: flex; - align-items: center; - justify-content: center; - user-select: none; - /* #endif */ - font-size: $picker-button-font-size; - line-height: $picker-toolbar-height; - height: 100%; - // padding: 0 $spacer; - @include padding(0 $spacer); - } - - &__cancel { - // left: 0; - margin-right: auto; - color: $picker-cancel-color; - } - - &__confirm { - margin-left: auto; - color: $picker-confirm-color; - // right: 0 - } - - - &__main { - position: relative; - display: flex; - height: $picker-group-height; - flex-direction: row; - z-index: 2; - // padding: 0 $spacer-xs; - @include padding(0 $spacer-xs); - } - &__mask { - - } - &__empty { - pointer-events: none; - justify-content: center; - align-items: center; - display: flex; - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - z-index: 3; - } - &__loading { - z-index: 3; - // color: $picker-loading-color; - background-color: $picker-loading-mask-color; - // background-color: red; - justify-content: center; - align-items: center; - display: flex; - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0 - } - &__indicator{ - position: absolute; - background-color: $picker-indicator-bg-color; - top: 50%; - left: $picker-indicator-margin; - right: $picker-indicator-margin; - height: $picker-item-height; - transform: translateY(-50%); - z-index: -1; - @include border-radius($picker-indicator-border-radius); - } -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker/l-picker.uvue b/uni_modules/lime-picker/components/l-picker/l-picker.uvue deleted file mode 100644 index f77c044..0000000 --- a/uni_modules/lime-picker/components/l-picker/l-picker.uvue +++ /dev/null @@ -1,269 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker/l-picker.vue b/uni_modules/lime-picker/components/l-picker/l-picker.vue deleted file mode 100644 index b129e29..0000000 --- a/uni_modules/lime-picker/components/l-picker/l-picker.vue +++ /dev/null @@ -1,271 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker/props.ts b/uni_modules/lime-picker/components/l-picker/props.ts deleted file mode 100644 index b920383..0000000 --- a/uni_modules/lime-picker/components/l-picker/props.ts +++ /dev/null @@ -1,126 +0,0 @@ -// @ts-nocheck -export default { - /** - * 取消按钮文字 - */ - cancelBtn: { - type: String, - default: null - }, - cancelStyle: { - type: [String, Object], - default: null - }, - /** - * 确定按钮文字 - */ - confirmBtn: { - type: String, - default: null - }, - confirmStyle: { - type: [String, Object], - default: null - }, - keys: { - type: Object, - default: null - }, - /** - * 标题 - */ - title: { - type: String, - default: null - }, - titleStyle: { - type: [String, Object], - default: null - }, - /** - * 配置每一列的选项 - */ - columns: { - type: Array, - default: () => [] - }, - /** - * 选中值 - */ - modelValue: { - type: Array, - default: null - }, - defaultValue: { - type: Array, - default: null - }, - value: { - type: Array, - default: null - }, - /** - * 是否为加载状态 - */ - loading: { - type: Boolean, - default: false - }, - loadingColor: { - type: String, - default: null - }, - loadingMaskColor: { - type: String, - default: null - }, - loadingSize: { - type: String, - default: '64rpx' - }, - itemHeight: { - type: String - }, - itemColor: { - type: String, - default: '' - }, - itemFontSize: { - type: String, - default: '' - }, - itemActiveColor: { - type: String, - default: '' - }, - itemActiveFontWeight: { - type: Number, - default: null - }, - indicatorStyle: { - type: String, - default: '' - }, - bgColor: { - type: String, - default: null - }, - groupHeight: { - type: String, - default: '' - }, - radius: { - type: String, - default: null - }, - /** - * 列表更新后,是否归0 - */ - resetIndex: { - type: Boolean, - default: false - }, - maskColors: { - type: Array, - } -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker/type.ts b/uni_modules/lime-picker/components/l-picker/type.ts deleted file mode 100644 index 0325033..0000000 --- a/uni_modules/lime-picker/components/l-picker/type.ts +++ /dev/null @@ -1,87 +0,0 @@ -// @ts-nocheck -export type PickerValue = string | number; -export type LimePickerValue = string | number; -export type PickerColumnItem = { - id: any|null; - label : string; - disabled: boolean | null; - value : string;//string | number; - children : PickerColumn | null -} -export type PickerColumn = PickerColumnItem[]; -export type PickerPickEvent= { - values: PickerValue[]; - column : number; - index : number; -} -export type PickerConfirmEvent = { - values: PickerValue[] - indexs: number[] - items: PickerColumnItem[] -} -/** - * 定义比较数组时返回的变化对象类型。 - */ -export type PickerChangeInfo = { - column: number; // 变化的列索引 - direction: 1 | -1 | 0; // 变化方向:1 表示增加,-1 表示减少, 0表示无变化 - index: number; // 变化后的新值,在列表中表示下标 -} - - -export interface PickerProps { - /** - * 取消按钮文字 - */ - cancelBtn ?: string; - cancelStyle ?: string | UTSJSONObject; - /** - * 确定按钮文字 - */ - confirmBtn ?: string; - confirmStyle ?: string | UTSJSONObject; - /** - * 标题 - */ - title ?: string; - titleStyle ?: string | UTSJSONObject; - /** - * 用来定义 value / label 在 `options` 中对应的字段别名 - */ - keys?: UTSJSONObject; - /** - * 配置每一列的选项 - */ - columns : PickerColumn[]; - /** - * 选中值 - */ - modelValue ?: PickerValue[]; - defaultValue ?: PickerValue[]; - value ?: PickerValue[]; - /** - * 是否为加载状态 - */ - loading: boolean; - loadingColor?: string; - loadingMaskColor?: string; - loadingSize: string; - - itemHeight?: string; - itemColor?: string; - itemFontSize?: string; - itemActiveColor?: string; - itemActiveFontWeight?: number; - - indicatorStyle?: string; - /** - * 遮罩渐变颜色,格式为 [起始颜色, 结束颜色] - * 例如:['#ffffff', 'rgba(255,255,255,0)'] - * 若未提供,则根据主题(明/暗)自动计算 - */ - maskColors?: string[]; - bgColor?:string; - groupHeight?:string; - radius?:string; - resetIndex: boolean -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/l-picker/utils.ts b/uni_modules/lime-picker/components/l-picker/utils.ts deleted file mode 100644 index 00bdab8..0000000 --- a/uni_modules/lime-picker/components/l-picker/utils.ts +++ /dev/null @@ -1,36 +0,0 @@ -// @ts-nocheck -/** - * 在数组的指定位置插入或更新值。 - * 如果指定的索引小于数组的长度,则更新该位置的值。 - * 如果指定的索引大于或等于数组的长度,则将值添加到数组的末尾。 - * - * @param {number[]} arr - 要操作的数字数组。 - * @param {number} index - 要插入或更新值的索引位置。 - * @param {number} value - 要插入或更新的值。 - */ -export function pushAt(arr : T[], index : number, value : T) { - // #ifdef APP-ANDROID - if (index < arr.length) { - arr[index] = value; - } else { - arr.push(value); - } - // #endif - // #ifndef APP-ANDROID - arr[index] = value; - // #endif -}; - - -/** - * 精确比较两个数组是否相等(浅比较) - * @param arr1 数组1 - * @param arr2 数组2 - * @returns 是否相等 - */ -export function arraysEqual(arr1 : T[], arr2 : T[]) : boolean { - return ( - arr1.length == arr2.length && - arr1.every((val, i):boolean => val == arr2[i]) - ) -} \ No newline at end of file diff --git a/uni_modules/lime-picker/components/lime-picker/lime-picker.uvue b/uni_modules/lime-picker/components/lime-picker/lime-picker.uvue deleted file mode 100644 index f2108a3..0000000 --- a/uni_modules/lime-picker/components/lime-picker/lime-picker.uvue +++ /dev/null @@ -1,411 +0,0 @@ - - - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/components/lime-picker/lime-picker.vue b/uni_modules/lime-picker/components/lime-picker/lime-picker.vue deleted file mode 100644 index 978b1b4..0000000 --- a/uni_modules/lime-picker/components/lime-picker/lime-picker.vue +++ /dev/null @@ -1,398 +0,0 @@ - - - \ No newline at end of file diff --git a/uni_modules/lime-picker/index.uts b/uni_modules/lime-picker/index.uts deleted file mode 100644 index 7cfb56a..0000000 --- a/uni_modules/lime-picker/index.uts +++ /dev/null @@ -1,6 +0,0 @@ -// @ts-nocheck -export * from './components/l-picker/type' -// export { LimePickerValue } from './components/l-picker/type' - -// export type PickerValue = string | number; -// export type LimePickerValue = PickerValue; \ No newline at end of file diff --git a/uni_modules/lime-picker/package.json b/uni_modules/lime-picker/package.json deleted file mode 100644 index 0436ffe..0000000 --- a/uni_modules/lime-picker/package.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "id": "lime-picker", - "displayName": "lime-picker 选择器", - "version": "0.3.8", - "description": "lime-picker 用于一组预设数据中的选择。支持单列选择、多列选择,兼容uniapp/uniappx", - "keywords": [ - "lime-picker", - "picker", - "选择器" -], - "repository": "", - "engines": { - "HBuilderX": "^4.36", - "uni-app": "^4.51", - "uni-app-x": "^4.45" - }, - "dcloudext": { - "type": "component-vue", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "", - "darkmode": "x", - "i18n": "x", - "widescreen": "x" - }, - "uni_modules": { - "dependencies": [ - "lime-style", - "lime-shared", - "lime-loading" - ], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "x", - "aliyun": "x", - "alipay": "x" - }, - "client": { - "uni-app": { - "vue": { - "vue2": "√", - "vue3": "√" - }, - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "vue": "√", - "nvue": "-", - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√", - "alipay": "√", - "toutiao": "-", - "baidu": "-", - "kuaishou": "-", - "jd": "-", - "harmony": "-", - "qq": "-", - "lark": "-", - "xhs": "-" - }, - "quickapp": { - "huawei": "-", - "union": "-" - } - }, - "uni-app-x": { - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√" - } - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/lime-picker/readme.md b/uni_modules/lime-picker/readme.md deleted file mode 100644 index 81c499e..0000000 --- a/uni_modules/lime-picker/readme.md +++ /dev/null @@ -1,573 +0,0 @@ -# lime-picker 选择器 -一个功能丰富的选择器组件,用于在一组预设数据中进行选择,支持单列/多列选择、级联选择、多列联动、自定义样式、加载状态和空状态等功能。 - -> 插件依赖:`lime-style`、`lime-shared`、`lime-loading` - -## 文档链接 -📚 组件详细文档请访问以下站点: -- [选择器文档 - 站点1](https://limex.qcoon.cn/components/picker.html) -- [选择器文档 - 站点2](https://limeui.netlify.app/components/picker.html) -- [选择器文档 - 站点3](https://limeui.familyzone.top/components/picker.html) - -## 安装方法 -1. 在uni-app插件市场中搜索并导入`lime-picker` -2. 首次导入可能需要重新编译 -3. 在页面中使用`l-picker`组件(组件)或`lime-picker`(演示) - - -## 代码演示 - -### 基础用法 - -Picker 组件可通过 `columns` 属性配置选项数据,或子组件`l-picker-item`的`options`配置数据,二选一。
-顶部栏包含标题、确认按钮和取消按钮,点击确认按钮触发 `confirm` 事件,点击取消按钮触发 `cancel` 事件。 -```html - - - - - - -``` -```js -// 非TS项目不需要引入类型 -import type { PickerColumn, PickerConfirmEvent } from '@/uni_modules/lime-picker'; - -// 通过`l-picker-item`子组件时,数据结构为单数组 -// PickerColumn -const cityOptions = [ - { - label: '北京市', - value: '北京市', - }, - { - label: '上海市', - value: '上海市', - } -] as PickerColumn - -// 通过 Picker 的 columns 属性的数组结构为[PickerColumn, PickerColumn] - -const columns = [ - // 第一列 - cityOptions, -] - -const onConfirm = ({values} : PickerConfirmEvent) => { - showToast(`当前值: ${values.join(',')}`); -}; -const onChange = ({values, column, index} : PickerPickEvent) => { - showToast(`当前值: ${values.join(',')}`); -}; -const onCancel = () => {console.log('取消')}; -``` - - - - -### 搭配弹出层使用 - -在实际场景中,Picker 通常作为用于辅助表单填写,可以搭配 [Popup](https://ext.dcloud.net.cn/plugin?id=20769)。 - -```html - - - - - -``` -```js -import type { PickerColumn } from '@/uni_modules/lime-picker'; -const showPicker = ref(false) -const cityOptions = [ - [ - { - label: '北京市', - value: '北京市', - }, - { - label: '上海市', - value: '上海市', - } - ] -] as PickerColumn[] -``` - - -### 多列 -`columns` 属性可以通过二维数组的形式配置多列选择。也可以使用`l-picker-item`子组件实现多列。 -```html - - - - - - -``` -```js -import type { PickerColumn } from '@/uni_modules/lime-picker'; -const showPicker = ref(false) -const years = [ - { - label: '2024', - value: '2024', - }, - { - label: '2025', - value: '2025', - } -] as PickerColumn -const seasonOptions = [ - { - label: '春', - value: '春', - }, - { - label: '夏', - value: '夏', - }, - { - label: '秋', - value: '秋', - }, - { - label: '冬', - value: '冬', - }, -] as PickerColumn - -const seasonColumns = [years, seasonOptions] - -``` - -### 双向绑定 - -通过 `v-model` 可以绑定当前选中项的 `values`,修改 `v-model` 绑定的值时,`Picker` 的选中状态也会随之改变。 - -`v-model` 的值是一个数组,数组的第一位对应第一列选中项的 `value`,第二位对应第二列选中项的 `value`,以此类推。 - -```html - - - -``` -```js -import type { PickerColumn } from '@/uni_modules/lime-picker'; -const citys = ref(['上海市']) -const cityOptions = [ - { - label: '北京市', - value: '北京市', - }, - { - label: '上海市', - value: '上海市', - }, - { - label: '广州市', - value: '广州市', - }, - { - label: '深圳市', - value: '深圳市', - }, -] as PickerColumn -``` - - -### 加载状态 - -若选择器数据是异步获取的,可以通过 `loading` 属性显示加载提示。 -```html - -``` -```js -import type { PickerColumn } from '@/uni_modules/lime-picker'; -const cityOptions = [ - [ - { - label: '北京市', - value: '北京市', - }, - { - label: '上海市', - value: '上海市', - }, - { - label: '广州市', - value: '广州市', - }, - { - label: '深圳市', - value: '深圳市', - }, - ] -] as PickerColumn[] -``` - -### 空状态 -当数据为空时,可以使用 `empty` 插槽自定义空状态内容。[empty插件](https://ext.dcloud.net.cn/plugin?id=19563) -```html - - - -``` -```js -import type { PickerColumn } from '@/uni_modules/lime-picker'; -const cityOptions = [] as PickerColumn[] -``` - - -### 多列联动 -通过`pick`事件完成联动操作。 -```html - - - - - -``` -```js -import type { PickerColumn, PickerColumnItem, PickerConfirmEvent, PickerPickEvent } from '@/uni_modules/lime-picker'; -const areaList = { - provinces: { - '110000': '北京市', - '440000': '广东省', - }, - cities: { - '110100': '北京市', - '440100': '广州市', - '440200': '韶关市', - '440300': '深圳市', - '440400': '珠海市', - '440500': '汕头市', - '440600': '佛山市', - }, - counties: { - '110101': '东城区', - '110102': '西城区', - '110105': '朝阳区', - '110106': '丰台区', - '110107': '石景山区', - '110108': '海淀区', - '110109': '门头沟区', - '110111': '房山区', - '110112': '通州区', - '110113': '顺义区', - '110114': '昌平区', - '110115': '大兴区', - '110116': '怀柔区', - '110117': '平谷区', - '110118': '密云区', - '110119': '延庆区', - '440103': '荔湾区', - '440104': '越秀区', - '440105': '海珠区', - '440106': '天河区', - '440111': '白云区', - '440112': '黄埔区', - '440113': '番禺区', - '440114': '花都区', - '440115': '南沙区', - '440117': '从化区', - '440118': '增城区', - '440203': '武江区', - '440204': '浈江区', - '440205': '曲江区', - '440222': '始兴县', - '440224': '仁化县', - '440229': '翁源县', - '440232': '乳源瑶族自治县', - '440233': '新丰县', - '440281': '乐昌市', - '440282': '南雄市', - '440303': '罗湖区', - '440304': '福田区', - '440305': '南山区', - '440306': '宝安区', - '440307': '龙岗区', - '440308': '盐田区', - '440309': '龙华区', - '440310': '坪山区', - '440311': '光明区', - '440402': '香洲区', - '440403': '斗门区', - '440404': '金湾区', - '440507': '龙湖区', - '440511': '金平区', - '440512': '濠江区', - '440513': '潮阳区', - '440514': '潮南区', - '440515': '澄海区', - '440523': '南澳县', - '440604': '禅城区', - '440605': '南海区', - '440606': '顺德区', - '440607': '三水区', - '440608': '高明区', - }, -}; - -// UTSJSONObject 为uniapp x的 object,非uniapp 可使用Object -const getOptions = (obj : UTSJSONObject, filter ?: ((value : PickerColumnItem) => boolean) | null) : PickerColumn => { - const res = UTSJSONObject.keys(obj).map((key) : PickerColumnItem => { - return { - // id: key, - value: `${key}`, - label: `${obj[key]}` - } as PickerColumnItem - }) - if (filter != null) { - return res.filter(filter) - } - return res -} -const match = (v1 : string, v2 : string, size : number) : boolean => { - return v1.slice(0, size) == v2.slice(0, size) -}; -const getCounties = (cityValue : string) : PickerColumn => { - return getOptions(areaList.counties as UTSJSONObject, (county : PickerColumnItem) : boolean => match(county.value, cityValue, 4)); -}; -const getCities = (provinceValue : string) : PickerColumn[] => { - const cities = getOptions(areaList.cities as UTSJSONObject, (city : PickerColumnItem) : boolean => match(city.value, provinceValue, 2)); - const counties = getCounties(cities[0].value); - return [cities, counties]; -}; -// 省 -const provinces = ref([]); -provinces.value = getOptions(areaList.provinces as UTSJSONObject, null) -const data = getCities(provinces.value[0].value); -// 市 -const cities = ref(data[0]); -// 区 -const counties = ref(data[1]); - -const onConfirm = (context : PickerConfirmEvent) => { - console.log('context', context) -} -const onChange = ({values, column, index} : PickerPickEvent) => { - // column 表示第几列 - // index 表示列数组里的下标 - if (column == 0) { - // 更改省份 - const data = getCities(provinces.value[index].value); - cities.value = data[0]; - counties.value = data[1]; - } - - if (column == 1) { - // 更改城市 - counties.value = getCounties(cities.value[index].value); - } - - if (column == 2) { - // 更改区县 - } -} -``` - -### 级联选择 -使用 `l-cascade` 组件 通过`columns` 的 `children` 字段可以实现选项级联的效果。如果级联层级较多,推荐使用 [Cascader 级联选项组件](https://ext.dcloud.net.cn/plugin?id=20880)。 - -```html - -``` -```js - const columns = [ - { - lable: '浙江', - value: 'Zhejiang', - children: [ - { - lable: '杭州', - value: 'Hangzhou', - children: [ - { lable: '西湖区', value: 'Xihu' }, - { lable: '余杭区', value: 'Yuhang' }, - ], - }, - { - lable: '温州', - value: 'Wenzhou', - children: [ - { lable: '鹿城区', value: 'Lucheng' }, - { lable: '瓯海区', value: 'Ouhai' }, - ], - }, - ], - }, - { - lable: '福建', - value: 'Fujian', - children: [ - { - lable: '福州', - value: 'Fuzhou', - children: [ - { lable: '鼓楼区', value: 'Gulou' }, - { lable: '台江区', value: 'Taijiang' }, - ], - }, - { - lable: '厦门', - value: 'Xiamen', - children: [ - { lable: '思明区', value: 'Siming' }, - { lable: '海沧区', value: 'Haicang' }, - ], - }, - ], - }, - ]; -``` - -## 快速预览 -导入后直接使用这个标签查看演示效果 - -```html - - -``` - -## 插件标签说明 -- `l-picker`: 组件标签 -- `lime-picker`: 演示标签 - - -## Vue2使用说明 -本插件使用了`composition-api`,请按照[官方教程](https://uniapp.dcloud.net.cn/tutorial/vue-composition-api.html)配置。 - -```js -// main.js -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -``` - -## API 文档 - -### Picker Props - -| 参数 | 说明 | 类型 | 默认值 | -| --- | --- | --- | --- | -| v-model | 当前选中项对应的值 | _string\|number[]_ | - | -| value | 当前选中项对应的值 | _string\|number[]_ | - | -| columns | 对象数组,配置每一列显示的数据 | _PickerColumn[]_ | `false` | -| cancelBtn | 取消按钮文字 | _string_ | `` | -| cancelStyle | 取消按钮样式 | _string_ | `` | -| confirmBtn | 确定按钮文字 | _string_ | `` | -| confirmStyle | 确定按钮样式 | _string_ | `` | -| title | 标题 | _string_ | `` | -| titleStyle | 标题样式 | _string_ | `` | -| loading | 是否显示加载状态 | _boolean_ | `false` | -| loadingColor | 加载图标颜色 | _string_ | `` | -| loadingMaskColor | 加载遮罩背景颜色 | _string_ | `` | -| loadingSize | 加载图标大小 | _string_ | `` | -| itemHeight | 每项高度 | _string_ | `50px` | -| itemColor | 每项文本颜色 | _string_ | `` | -| itemFontSize | 每项文本字体大小 | _string_ | `` | -| itemActiveColor | 每项文本选中颜色 | _string_ | `` | -| indicatorStyle | 选择器中间选中框的样式 | _string_ | `` | -| maskColors | 选择器遮罩颜色样式,`[开始颜色, 结束颜色]` | _string[]_ | `` | -| bgColor | 选择器背景色 | _string_ | `` | -| groupHeight | 选项组高度 | _string_ | `400rpx` | -| radius | 圆角 | _string_ | | - -### PickerItem Props - -| 参数 | 说明 | 类型 | 默认值 | -| --- | --- | --- | --- | -| options | 对象数组,配置列显示的数据 | _PickerColumnItem[]_ | `false` | -| value | 值 | _string_ | | -| column | 当前为第几列 | _number_ | | - - -### Events -| 事件名 | 说明 | 回调参数 | -| ------ | ------------------------ | ---------------------- | -| cancel | 点击取消按钮时触发 | __ | -| change | 选中变化时候触发 | _value: string\|number[]_ | -| confirm | 点击确认按钮时触发 | _{values: PickerValue[], indexs:number[], items:PickerColumnItem[]}:PickerConfirmEvent_ | -| pick | 任何一列选中都会触发,不同的列参数不同,column 表示第几列变化,index 表示变化那一列的选中项下标 | _{values: PickerValue[], column:number,index:number}:PickerPickEvent_ | - -### Picker Slots -| 插槽名 | 说明 | 回调参数 | -| ------ | ------------------------ | ---------------------- | -| default | | __ | -| header | 头部 | __ | -| footer | 底部 | __ | -| empty | 空数据插槽 | __ | - -### 方法 -通过 ref 可以获取到 Picker 实例并调用实例方法: - -| 方法名 | 说明 | 返回值 | -| ------ | ------------------------ | ---------------------- | -| confirm | 停止惯性滚动并触发 `confirm` 事件 | __ | -| getSelectedOptions | 获取当前选中的选项 | PickerConfirmEvent[] | - -```js -// cascade 组件类型为 LCascadeComponentPublicInstance -// picker 组件类型为 LPickerComponentPublicInstance -const pickerRef = ref(null) -pickerRef.value?.confirm() -const res = pickerRef.value?.getSelectedOptions() -``` - -## 主题定制 - -组件提供了下列 CSS 变量,可用于自定义样式。 - -| 变量名 | 默认值 | 说明 | -|--------|--------|------| -| `--l-picker-border-radius` | `$border-radius-xl` | 选择器整体圆角 | -| `--l-picker-bg-color` | `$bg-color-container` | 选择器背景色 | -| `--l-picker-toolbar-height` | `58px` | 工具栏高度 | -| `--l-picker-cancel-color` | `$text-color-2` | 取消按钮文字颜色 | -| `--l-picker-confirm-color` | `$primary-color` | 确认按钮文字颜色 | -| `--l-picker-button-font-size` | `$font-size-md` | 按钮文字大小 | -| `--l-picker-title-font-size` | `18px` | 标题文字大小 | -| `--l-picker-title-font-weight` | `700` | 标题文字粗细 | -| `--l-picker-title-line-height` | `26px` | 标题行高 | -| `--l-picker-title-color` | `$text-color-1` | 标题文字颜色 | -| `--l-picker-group-height` | `200px` | 选择器内容区高度 | -| `--l-picker-indicator-bg-color` | `$fill-4` | 选中指示器背景色 | -| `--l-picker-indicator-border-radius` | `6px` | 选中指示器圆角 | -| `--l-picker-indicator-margin` | `10px` | 选中指示器边距 | -| `--l-picker-item-height` | `50px` | 每个选项高度 | -| `--l-picker-item-color` | `$text-color-1` | 选项文字颜色 | -| `--l-picker-item-active-color` | `$text-color-1` | 选中项文字颜色 | -| `--l-picker-mask-top-color` | `white` | 遮罩开始颜色 | -| `--l-picker-mask-bottom-color` | `white` | 遮罩结束颜色 | -| `--l-picker-item-active-font-weight` | `700` | 选中项文字粗细 | -| `--l-picker-item-font-size` | `$font-size-md` | 选项文字大小 | -| `--l-picker-loading-mask-color` | `rgba(255,255,255,.9)` | 加载遮罩颜色 | -| `--l-picker-loading-color` | `$primary-color` | 加载动画颜色 | - - -## 支持与赞赏 - -如果你觉得本插件解决了你的问题,可以考虑支持作者: -| 支付宝赞助 | 微信赞助 | -|------------|------------| -| ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) | ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) | \ No newline at end of file diff --git a/uni_modules/lime-picker/readme_old.md b/uni_modules/lime-picker/readme_old.md deleted file mode 100644 index f4d762b..0000000 --- a/uni_modules/lime-picker/readme_old.md +++ /dev/null @@ -1,555 +0,0 @@ -# lime-picker 选择器 -用于一组预设数据中的选择。通常与弹出层组件配合使用。 -插件依赖`lime-style`,`lime-shared`,`lime-loading`不喜勿下 - -## 文档 - 🚀 [picker【站点1】](https://limex.qcoon.cn/components/picker.html) - 🌍 [picker【站点2】](https://limeui.netlify.app/components/picker.html) - 🔥 [picker【站点3】](https://limeui.familyzone.top/components/picker.html) - - -## 安装 -插件市场导入即可。首次导入可能需要重新编译 - - -## 代码演示 - -### 基础用法 - -Picker 组件可通过 `columns` 属性配置选项数据,或子组件`l-picker-item`的`options`配置数据,二选一。
-顶部栏包含标题、确认按钮和取消按钮,点击确认按钮触发 `confirm` 事件,点击取消按钮触发 `cancel` 事件。 -```html - - - - - - -``` -```js -// 非TS项目不需要引入类型 -import type { PickerColumn, PickerConfirmEvent } from '@/uni_modules/lime-picker'; - -// 通过`l-picker-item`子组件时,数据结构为单数组 -// PickerColumn -const cityOptions = [ - { - label: '北京市', - value: '北京市', - }, - { - label: '上海市', - value: '上海市', - } -] as PickerColumn - -// 通过 Picker 的 columns 属性的数组结构为[PickerColumn, PickerColumn] - -const columns = [ - // 第一列 - cityOptions, -] - -const onConfirm = ({values} : PickerConfirmEvent) => { - showToast(`当前值: ${values.join(',')}`); -}; -const onChange = ({values, column, index} : PickerPickEvent) => { - showToast(`当前值: ${values.join(',')}`); -}; -const onCancel = () => {console.log('取消')}; -``` - - - - -### 搭配弹出层使用 - -在实际场景中,Picker 通常作为用于辅助表单填写,可以搭配 [Popup](https://ext.dcloud.net.cn/plugin?id=20769)。 - -```html - - - - - -``` -```js -import { PickerColumn } from '@/uni_modules/lime-picker'; -const showPicker = ref(false) -const cityOptions = [ - [ - { - label: '北京市', - value: '北京市', - }, - { - label: '上海市', - value: '上海市', - } - ] -] as PickerColumn[] -``` - - -### 多列 -`columns` 属性可以通过二维数组的形式配置多列选择。也可以使用`l-picker-item`子组件实现多列。 -```html - - - - - - -``` -```js -import { PickerColumn } from '@/uni_modules/lime-picker'; -const showPicker = ref(false) -const years = [ - { - label: '2024', - value: '2024', - }, - { - label: '2025', - value: '2025', - } -] as PickerColumn -const seasonOptions = [ - { - label: '春', - value: '春', - }, - { - label: '夏', - value: '夏', - }, - { - label: '秋', - value: '秋', - }, - { - label: '冬', - value: '冬', - }, -] as PickerColumn - -const seasonColumns = [years, seasonOptions] - -``` - -### 双向绑定 - -通过 `v-model` 可以绑定当前选中项的 `values`,修改 `v-model` 绑定的值时,`Picker` 的选中状态也会随之改变。 - -`v-model` 的值是一个数组,数组的第一位对应第一列选中项的 `value`,第二位对应第二列选中项的 `value`,以此类推。 - -```html - - - -``` -```js -import { PickerColumn } from '@/uni_modules/lime-picker'; -const citys = ref(['上海市']) -const cityOptions = [ - { - label: '北京市', - value: '北京市', - }, - { - label: '上海市', - value: '上海市', - }, - { - label: '广州市', - value: '广州市', - }, - { - label: '深圳市', - value: '深圳市', - }, -] as PickerColumn -``` - - -### 加载状态 - -若选择器数据是异步获取的,可以通过 `loading` 属性显示加载提示。 -```html - -``` -```js -import { PickerColumn } from '@/uni_modules/lime-picker'; -const cityOptions = [ - [ - { - label: '北京市', - value: '北京市', - }, - { - label: '上海市', - value: '上海市', - }, - { - label: '广州市', - value: '广州市', - }, - { - label: '深圳市', - value: '深圳市', - }, - ] -] as PickerColumn[] -``` - -### 空状态 -当数据为空时,可以使用 `empty` 插槽自定义空状态内容。[empty插件](https://ext.dcloud.net.cn/plugin?id=19563) -```html - - - -``` -```js -import { PickerColumn } from '@/uni_modules/lime-picker'; -const cityOptions = [] as PickerColumn[] -``` - - -### 多列联动 -通过`pick`事件完成联动操作。 -```html - - - - - -``` -```js -import { PickerColumn, PickerColumnItem, PickerConfirmEvent, PickerPickEvent } from '@/uni_modules/lime-picker'; -const areaList = { - provinces: { - '110000': '北京市', - '440000': '广东省', - }, - cities: { - '110100': '北京市', - '440100': '广州市', - '440200': '韶关市', - '440300': '深圳市', - '440400': '珠海市', - '440500': '汕头市', - '440600': '佛山市', - }, - counties: { - '110101': '东城区', - '110102': '西城区', - '110105': '朝阳区', - '110106': '丰台区', - '110107': '石景山区', - '110108': '海淀区', - '110109': '门头沟区', - '110111': '房山区', - '110112': '通州区', - '110113': '顺义区', - '110114': '昌平区', - '110115': '大兴区', - '110116': '怀柔区', - '110117': '平谷区', - '110118': '密云区', - '110119': '延庆区', - '440103': '荔湾区', - '440104': '越秀区', - '440105': '海珠区', - '440106': '天河区', - '440111': '白云区', - '440112': '黄埔区', - '440113': '番禺区', - '440114': '花都区', - '440115': '南沙区', - '440117': '从化区', - '440118': '增城区', - '440203': '武江区', - '440204': '浈江区', - '440205': '曲江区', - '440222': '始兴县', - '440224': '仁化县', - '440229': '翁源县', - '440232': '乳源瑶族自治县', - '440233': '新丰县', - '440281': '乐昌市', - '440282': '南雄市', - '440303': '罗湖区', - '440304': '福田区', - '440305': '南山区', - '440306': '宝安区', - '440307': '龙岗区', - '440308': '盐田区', - '440309': '龙华区', - '440310': '坪山区', - '440311': '光明区', - '440402': '香洲区', - '440403': '斗门区', - '440404': '金湾区', - '440507': '龙湖区', - '440511': '金平区', - '440512': '濠江区', - '440513': '潮阳区', - '440514': '潮南区', - '440515': '澄海区', - '440523': '南澳县', - '440604': '禅城区', - '440605': '南海区', - '440606': '顺德区', - '440607': '三水区', - '440608': '高明区', - }, -}; - -// UTSJSONObject 为uniapp x的 object,非uniapp 可使用Object -const getOptions = (obj : UTSJSONObject, filter ?: ((value : PickerColumnItem) => boolean) | null) : PickerColumn => { - const res = UTSJSONObject.keys(obj).map((key) : PickerColumnItem => { - return { - // id: key, - value: `${key}`, - label: `${obj[key]}` - } as PickerColumnItem - }) - if (filter != null) { - return res.filter(filter) - } - return res -} -const match = (v1 : string, v2 : string, size : number) : boolean => { - return v1.slice(0, size) == v2.slice(0, size) -}; -const getCounties = (cityValue : string) : PickerColumn => { - return getOptions(areaList.counties as UTSJSONObject, (county : PickerColumnItem) : boolean => match(county.value, cityValue, 4)); -}; -const getCities = (provinceValue : string) : PickerColumn[] => { - const cities = getOptions(areaList.cities as UTSJSONObject, (city : PickerColumnItem) : boolean => match(city.value, provinceValue, 2)); - const counties = getCounties(cities[0].value); - return [cities, counties]; -}; -// 省 -const provinces = ref([]); -provinces.value = getOptions(areaList.provinces as UTSJSONObject, null) -const data = getCities(provinces.value[0].value); -// 市 -const cities = ref(data[0]); -// 区 -const counties = ref(data[1]); - -const onConfirm = (context : PickerConfirmEvent) => { - console.log('context', context) -} -const onChange = ({values, column, index} : PickerPickEvent) => { - // column 表示第几列 - // index 表示列数组里的下标 - if (column == 0) { - // 更改省份 - const data = getCities(provinces.value[index].value); - cities.value = data[0]; - counties.value = data[1]; - } - - if (column == 1) { - // 更改城市 - counties.value = getCounties(cities.value[index].value); - } - - if (column == 2) { - // 更改区县 - } -} -``` - -### 级联选择 -使用 `l-cascade` 组件 通过`columns` 的 `children` 字段可以实现选项级联的效果。如果级联层级较多,推荐使用 [Cascader 级联选项组件](https://ext.dcloud.net.cn/plugin?id=20880)。 - -```html - -``` -```js - const columns = [ - { - lable: '浙江', - value: 'Zhejiang', - children: [ - { - lable: '杭州', - value: 'Hangzhou', - children: [ - { lable: '西湖区', value: 'Xihu' }, - { lable: '余杭区', value: 'Yuhang' }, - ], - }, - { - lable: '温州', - value: 'Wenzhou', - children: [ - { lable: '鹿城区', value: 'Lucheng' }, - { lable: '瓯海区', value: 'Ouhai' }, - ], - }, - ], - }, - { - lable: '福建', - value: 'Fujian', - children: [ - { - lable: '福州', - value: 'Fuzhou', - children: [ - { lable: '鼓楼区', value: 'Gulou' }, - { lable: '台江区', value: 'Taijiang' }, - ], - }, - { - lable: '厦门', - value: 'Xiamen', - children: [ - { lable: '思明区', value: 'Siming' }, - { lable: '海沧区', value: 'Haicang' }, - ], - }, - ], - }, - ]; -``` - -### 查看示例 -导入后直接使用这个标签查看演示效果 - -```html - - -``` - - -### 插件标签 -`l-picker` 为 component -`lime-picker` 为 demo - -### Vue2使用 -插件使用了`composition-api`, 如果你希望在vue2中使用请按官方的教程[vue-composition-api](https://uniapp.dcloud.net.cn/tutorial/vue-composition-api.html)配置 -关键代码是: 在main.js中 在vue2部分加上这一段即可 - -```js -// vue2 -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -``` - - - -## API - -### Picker Props - -| 参数 | 说明 | 类型 | 默认值 | -| --- | --- | --- | --- | -| v-model | 当前选中项对应的值 | _string\|number[]_ | - | -| value | 当前选中项对应的值 | _string\|number[]_ | - | -| columns | 对象数组,配置每一列显示的数据 | _PickerColumn[]_ | `false` | -| cancelBtn | 取消按钮文字 | _string_ | `` | -| cancelStyle | 取消按钮样式 | _string_ | `` | -| confirmBtn | 确定按钮文字 | _string_ | `` | -| confirmStyle | 确定按钮样式 | _string_ | `` | -| title | 标题 | _string_ | `` | -| titleStyle | 标题样式 | _string_ | `` | -| loading | 是否显示加载状态 | _boolean_ | `false` | -| loadingColor | 加载图标颜色 | _string_ | `` | -| loadingMaskColor | 加载遮罩背景颜色 | _string_ | `` | -| loadingSize | 加载图标大小 | _string_ | `` | -| itemHeight | 每项高度 | _string_ | `50px` | -| itemColor | 每项文本颜色 | _string_ | `` | -| itemFontSize | 每项文本字体大小 | _string_ | `` | -| itemActiveColor | 每项文本选中颜色 | _string_ | `` | -| indicatorStyle | 选择器中间选中框的样式 | _string_ | `` | -| bgColor | 选择器背景色 | _string_ | `` | -| groupHeight | 选项组高度 | _string_ | `400rpx` | -| radius | 圆角 | _string_ | | - -### PickerItem Props - -| 参数 | 说明 | 类型 | 默认值 | -| --- | --- | --- | --- | -| options | 对象数组,配置列显示的数据 | _PickerColumnItem[]_ | `false` | -| value | 值 | _string_ | | -| column | 当前为第几列 | _number_ | | - - -### Events -| 事件名 | 说明 | 回调参数 | -| ------ | ------------------------ | ---------------------- | -| cancel | 点击取消按钮时触发 | __ | -| change | 选中变化时候触发 | _value: string\|number[]_ | -| confirm | 点击确认按钮时触发 | _{values: PickerValue[], indexs:number[], items:PickerColumnItem[]}:PickerConfirmEvent_ | -| pick | 任何一列选中都会触发,不同的列参数不同,column 表示第几列变化,index 表示变化那一列的选中项下标 | _{values: PickerValue[], column:number,index:number}:PickerPickEvent_ | - -### Picker Slots -| 插槽名 | 说明 | 回调参数 | -| ------ | ------------------------ | ---------------------- | -| default | | __ | -| header | 头部 | __ | -| footer | 底部 | __ | -| empty | 空数据插槽 | __ | - - - -## 主题定制 - -### 样式变量 - -组件提供了下列 CSS 变量,可用于自定义样式,uvue app无效。 - -| 名称 | 默认值 | 描述 | -| ------------------------ | -------------------- | ---- | -| --l-picker-border-radius | _24rpx_ | - | -| --l-picker-bg-color | _$bg-color-container_ | - | -| --l-picker-toolbar-height | _116rpx_ | - | -| --l-picker-cancel-color | _text-color-2_ | - | -| --l-picker-confirm-color | _$primary-color_ | - | -| --l-picker-button-font-size | _32rpx_ | - | -| --l-picker-title-font-size | _36rpx_ | - | -| --l-picker-title-font-weight | _700_ | - | -| --l-picker-title-line-height | _52rpx_ | - | -| --l-picker-title-color | _$text-color-1_ | - | -| --l-picker-group-height | _400rpx_ | - | -| --l-picker-indicator-bg-color | _$fill-4_ | - | -| --l-picker-indicator-border-radius | _12rpx_ | - | -| --l-picker-item-height | _50px_ | - | -| --l-picker-item-color | _$text-color-1_ | - | -| --l-picker-item-active-color | _$text-color-1_ | - | -| --l-picker-item-active-color | _$text-color-1_ | - | -| --l-picker-loading-mask-color | _rgba(255,255,255,.9)_ | - | -| --l-picker-item-font-size | _$font-size-md_ | - | - - -## 打赏 - -如果你觉得本插件,解决了你的问题,赠人玫瑰,手留余香。 -![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) -![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) \ No newline at end of file diff --git a/uni_modules/lime-shared/addSeparator/index.ts b/uni_modules/lime-shared/addSeparator/index.ts deleted file mode 100644 index e2df12b..0000000 --- a/uni_modules/lime-shared/addSeparator/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-nocheck -/** - * 每n位数字添加一个分隔符 - */ -export function addSeparator(num : number | string, separator = ',', digit = 3) { - return `${num}`.replace( - new RegExp(`\\B(?=(\\d{${digit}})+(?!\\d))`, 'g'), - separator, - ) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/addUnit/index.ts b/uni_modules/lime-shared/addUnit/index.ts deleted file mode 100644 index 19a1393..0000000 --- a/uni_modules/lime-shared/addUnit/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -// @ts-nocheck -import {isNumeric} from '../isNumeric' -import {isDef} from '../isDef' -/** - * 给一个值添加单位(像素 px) - * @param value 要添加单位的值,可以是字符串或数字 - * @param unit 单位,默认为 'px' - * @returns 添加了单位的值,如果值为 null 则返回 null - */ - -// #ifndef UNI-APP-X && APP -export function addUnit(value?: string | number, unit: string = 'px'): string | null { - if (!isDef(value)) { - return null; - } - value = String(value); // 将值转换为字符串 - // 如果值是数字,则在后面添加单位 "px",否则保持原始值 - return isNumeric(value) ? `${value}${unit}` : value; -} -// #endif - - -// #ifdef UNI-APP-X && APP -function addUnit(value: string|number|null, unit: string = 'px'): string|null { - if (!isDef(value)) { - return null; - } - value = `${value}` //value.toString(); // 将值转换为字符串 - - // 如果值是数字,则在后面添加单位 "px",否则保持原始值 - return isNumeric(value) ? `${value}${unit}` : value; -} -export {addUnit} -// #endif - - -// console.log(addUnit(100)); // 输出: "100px" -// console.log(addUnit("200")); // 输出: "200px" -// console.log(addUnit("300px")); // 输出: "300px"(已经包含单位) -// console.log(addUnit()); // 输出: undefined(值为 undefined) -// console.log(addUnit(null)); // 输出: undefined(值为 null) \ No newline at end of file diff --git a/uni_modules/lime-shared/animation/bezier.ts b/uni_modules/lime-shared/animation/bezier.ts deleted file mode 100644 index ca9190f..0000000 --- a/uni_modules/lime-shared/animation/bezier.ts +++ /dev/null @@ -1,83 +0,0 @@ -// @ts-nocheck -export function cubicBezier(p1x : number, p1y : number, p2x : number, p2y : number):(x: number)=> number { - const ZERO_LIMIT = 1e-6; - // Calculate the polynomial coefficients, - // implicit first and last control points are (0,0) and (1,1). - const ax = 3 * p1x - 3 * p2x + 1; - const bx = 3 * p2x - 6 * p1x; - const cx = 3 * p1x; - - const ay = 3 * p1y - 3 * p2y + 1; - const by = 3 * p2y - 6 * p1y; - const cy = 3 * p1y; - - function sampleCurveDerivativeX(t : number) : number { - // `ax t^3 + bx t^2 + cx t` expanded using Horner's rule - return (3 * ax * t + 2 * bx) * t + cx; - } - - function sampleCurveX(t : number) : number { - return ((ax * t + bx) * t + cx) * t; - } - - function sampleCurveY(t : number) : number { - return ((ay * t + by) * t + cy) * t; - } - - // Given an x value, find a parametric value it came from. - function solveCurveX(x : number) : number { - let t2 = x; - let derivative : number; - let x2 : number; - - // https://trac.webkit.org/browser/trunk/Source/WebCore/platform/animation - // first try a few iterations of Newton's method -- normally very fast. - // http://en.wikipedia.org/wikiNewton's_method - for (let i = 0; i < 8; i++) { - // f(t) - x = 0 - x2 = sampleCurveX(t2) - x; - if (Math.abs(x2) < ZERO_LIMIT) { - return t2; - } - derivative = sampleCurveDerivativeX(t2); - // == 0, failure - /* istanbul ignore if */ - if (Math.abs(derivative) < ZERO_LIMIT) { - break; - } - t2 -= x2 / derivative; - } - - // Fall back to the bisection method for reliability. - // bisection - // http://en.wikipedia.org/wiki/Bisection_method - let t1 = 1; - /* istanbul ignore next */ - let t0 = 0; - - /* istanbul ignore next */ - t2 = x; - /* istanbul ignore next */ - while (t1 > t0) { - x2 = sampleCurveX(t2) - x; - if (Math.abs(x2) < ZERO_LIMIT) { - return t2; - } - if (x2 > 0) { - t1 = t2; - } else { - t0 = t2; - } - t2 = (t1 + t0) / 2; - } - - // Failure - return t2; - } - - return function (x : number) : number { - return sampleCurveY(solveCurveX(x)); - } - - // return solve; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/animation/ease.ts b/uni_modules/lime-shared/animation/ease.ts deleted file mode 100644 index 49f066b..0000000 --- a/uni_modules/lime-shared/animation/ease.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @ts-nocheck -import {cubicBezier} from './bezier'; -export let ease = cubicBezier(0.25, 0.1, 0.25, 1); -export let linear = cubicBezier(0,0,1,1); \ No newline at end of file diff --git a/uni_modules/lime-shared/animation/index.ts b/uni_modules/lime-shared/animation/index.ts deleted file mode 100644 index 60e56b9..0000000 --- a/uni_modules/lime-shared/animation/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-nocheck -// #ifdef UNI-APP-X && APP -export { Timeline, Animation } from './uvue' -// #endif - - - -// #ifndef UNI-APP-X && APP -export { Timeline, Animation } from './vue' -// #endif diff --git a/uni_modules/lime-shared/animation/useTransition.ts b/uni_modules/lime-shared/animation/useTransition.ts deleted file mode 100644 index 57120b8..0000000 --- a/uni_modules/lime-shared/animation/useTransition.ts +++ /dev/null @@ -1,110 +0,0 @@ -// @ts-nocheck -import type { ComponentPublicInstance, Ref } from 'vue' -import { ease, linear } from './ease'; -import { Timeline, Animation } from './'; -export type UseTransitionOptions = { - duration ?: number - immediate ?: boolean - context ?: ComponentPublicInstance - onChange?: (v: number) => void -} -// #ifndef UNI-APP-X && APP -import { ref, watch } from '@/uni_modules/lime-shared/vue' - -export function useTransition(percent : Ref|(() => number), options : UseTransitionOptions) : Ref { - const current = ref(0) - const { immediate, duration = 300, onChange } = options - let tl:Timeline|null = null; - let timer = -1 - const isFunction = typeof percent === 'function' - watch(isFunction ? percent : () => percent.value, (v) => { - if(tl == null){ - tl = new Timeline() - } - tl.start(); - tl.add( - new Animation( - current.value, - v, - duration, - 0, - ease, - nowValue => { - current.value = nowValue - onChange?.(nowValue) - clearTimeout(timer) - if(current.value == v){ - timer = setTimeout(()=>{ - tl?.pause(); - tl = null - }, duration) - } - } - ) - ); - }, { immediate }) - - return current -} - -// #endif - -// #ifdef UNI-APP-X && APP -type UseTransitionReturnType = Ref -export function useTransition(source : any, options : UseTransitionOptions) : UseTransitionReturnType { - const outputRef : Ref = ref(0) - const immediate = options.immediate ?? false - const duration = options.duration ?? 300 - const context = options.context //as ComponentPublicInstance | null - let tl:Timeline|null = null; - let timer = -1 - const watchFunc = (v : number) => { - if(tl == null){ - tl = new Timeline() - } - tl!.start(); - tl!.add( - new Animation( - outputRef.value, - v, - duration, - 0, - ease, - nowValue => { - outputRef.value = nowValue - clearTimeout(timer) - if(outputRef.value == v){ - timer = setTimeout(()=>{ - tl?.pause(); - tl = null - }, duration) - } - } - ), - null - ); - } - - if (context != null && typeof source == 'string') { - context.$watch(source, watchFunc, { immediate } as WatchOptions) - } else if(typeof source == 'function'){ - watch(source, watchFunc, { immediate }) - } - // #ifdef APP-ANDROID - else if(isRef(source) && source instanceof Ref) { - watch(source as Ref, watchFunc, { immediate }) - } - // #endif - // #ifndef APP-ANDROID - else if(isRef(source) && typeof source.value == 'number') { - watch(source, watchFunc, { immediate }) - } - // #endif - - const stop = ()=>{ - - } - return outputRef //as UseTransitionReturnType -} - -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/animation/uvue.ts b/uni_modules/lime-shared/animation/uvue.ts deleted file mode 100644 index 45a7a23..0000000 --- a/uni_modules/lime-shared/animation/uvue.ts +++ /dev/null @@ -1,119 +0,0 @@ -// @ts-nocheck -import { raf, cancelRaf} from '../raf' -export class Timeline { - state : string - animations : Set = new Set() - delAnimations : Animation[] = [] - startTimes : Map = new Map() - pauseTime : number = 0 - pauseStart : number = Date.now() - tickHandler : number = 0 - tickHandlers : number[] = [] - tick : (() => void) | null = null - constructor() { - this.state = 'Initiated'; - } - start() { - if (!(this.state == 'Initiated')) return; - this.state = 'Started'; - - let startTime = Date.now(); - this.pauseTime = 0; - this.tick = () => { - let now = Date.now(); - this.animations.forEach((animation : Animation) => { - let t:number; - const ani = this.startTimes.get(animation) - if (ani == null) return - if (ani < startTime) { - t = now - startTime - animation.delay - this.pauseTime; - } else { - t = now - ani - animation.delay - this.pauseTime; - } - if (t > animation.duration) { - this.delAnimations.push(animation) - // 不能在 foreach 里面 对 集合进行删除操作 - // this.animations.delete(animation); - t = animation.duration; - } - if (t > 0) animation.run(t); - }) - // 不能在 foreach 里面 对 集合进行删除操作 - while (this.delAnimations.length > 0) { - const animation = this.delAnimations.pop(); - if (animation == null) return - this.animations.delete(animation); - } - // cancelAnimationFrame(this.tickHandler); - if (this.state != 'Started') return - - this.tickHandler = raf(()=>{ - this.tick!() - }) - - this.tickHandlers.push(this.tickHandler) - } - if(this.tick != null) { - this.tick!() - } - - } - pause() { - if (!(this.state === 'Started')) return; - this.state = 'Paused'; - this.pauseStart = Date.now(); - cancelRaf(this.tickHandler); - // cancelRaf(this.tickHandler); - } - resume() { - if (!(this.state === 'Paused')) return; - this.state = 'Started'; - this.pauseTime += Date.now() - this.pauseStart; - this.tick!(); - } - reset() { - this.pause(); - this.state = 'Initiated'; - this.pauseTime = 0; - this.pauseStart = 0; - this.animations.clear() - this.delAnimations.clear() - this.startTimes.clear() - this.tickHandler = 0; - } - add(animation : Animation, startTime ?: number | null) { - if (startTime == null) startTime = Date.now(); - this.animations.add(animation); - this.startTimes.set(animation, startTime); - } -} - -export class Animation { - startValue : number - endValue : number - duration : number - timingFunction : (t : number) => number - delay : number - template : (t : number) => void - constructor( - startValue : number, - endValue : number, - duration : number, - delay : number, - timingFunction : (t : number) => number, - template : (v : number) => void) { - this.startValue = startValue; - this.endValue = endValue; - this.duration = duration; - this.timingFunction = timingFunction; - this.delay = delay; - this.template = template; - } - - run(time : number) { - let range = this.endValue - this.startValue; - let progress = time / this.duration - if(progress != 1) progress = this.timingFunction(progress) - this.template(this.startValue + range * progress) - } -} \ No newline at end of file diff --git a/uni_modules/lime-shared/animation/uvue.uts b/uni_modules/lime-shared/animation/uvue.uts deleted file mode 100644 index 45a7a23..0000000 --- a/uni_modules/lime-shared/animation/uvue.uts +++ /dev/null @@ -1,119 +0,0 @@ -// @ts-nocheck -import { raf, cancelRaf} from '../raf' -export class Timeline { - state : string - animations : Set = new Set() - delAnimations : Animation[] = [] - startTimes : Map = new Map() - pauseTime : number = 0 - pauseStart : number = Date.now() - tickHandler : number = 0 - tickHandlers : number[] = [] - tick : (() => void) | null = null - constructor() { - this.state = 'Initiated'; - } - start() { - if (!(this.state == 'Initiated')) return; - this.state = 'Started'; - - let startTime = Date.now(); - this.pauseTime = 0; - this.tick = () => { - let now = Date.now(); - this.animations.forEach((animation : Animation) => { - let t:number; - const ani = this.startTimes.get(animation) - if (ani == null) return - if (ani < startTime) { - t = now - startTime - animation.delay - this.pauseTime; - } else { - t = now - ani - animation.delay - this.pauseTime; - } - if (t > animation.duration) { - this.delAnimations.push(animation) - // 不能在 foreach 里面 对 集合进行删除操作 - // this.animations.delete(animation); - t = animation.duration; - } - if (t > 0) animation.run(t); - }) - // 不能在 foreach 里面 对 集合进行删除操作 - while (this.delAnimations.length > 0) { - const animation = this.delAnimations.pop(); - if (animation == null) return - this.animations.delete(animation); - } - // cancelAnimationFrame(this.tickHandler); - if (this.state != 'Started') return - - this.tickHandler = raf(()=>{ - this.tick!() - }) - - this.tickHandlers.push(this.tickHandler) - } - if(this.tick != null) { - this.tick!() - } - - } - pause() { - if (!(this.state === 'Started')) return; - this.state = 'Paused'; - this.pauseStart = Date.now(); - cancelRaf(this.tickHandler); - // cancelRaf(this.tickHandler); - } - resume() { - if (!(this.state === 'Paused')) return; - this.state = 'Started'; - this.pauseTime += Date.now() - this.pauseStart; - this.tick!(); - } - reset() { - this.pause(); - this.state = 'Initiated'; - this.pauseTime = 0; - this.pauseStart = 0; - this.animations.clear() - this.delAnimations.clear() - this.startTimes.clear() - this.tickHandler = 0; - } - add(animation : Animation, startTime ?: number | null) { - if (startTime == null) startTime = Date.now(); - this.animations.add(animation); - this.startTimes.set(animation, startTime); - } -} - -export class Animation { - startValue : number - endValue : number - duration : number - timingFunction : (t : number) => number - delay : number - template : (t : number) => void - constructor( - startValue : number, - endValue : number, - duration : number, - delay : number, - timingFunction : (t : number) => number, - template : (v : number) => void) { - this.startValue = startValue; - this.endValue = endValue; - this.duration = duration; - this.timingFunction = timingFunction; - this.delay = delay; - this.template = template; - } - - run(time : number) { - let range = this.endValue - this.startValue; - let progress = time / this.duration - if(progress != 1) progress = this.timingFunction(progress) - this.template(this.startValue + range * progress) - } -} \ No newline at end of file diff --git a/uni_modules/lime-shared/animation/vue.ts b/uni_modules/lime-shared/animation/vue.ts deleted file mode 100644 index 30f89e5..0000000 --- a/uni_modules/lime-shared/animation/vue.ts +++ /dev/null @@ -1,123 +0,0 @@ -// @ts-nocheck -const TICK = Symbol('tick'); -const TICK_HANDLER = Symbol('tick-handler'); -const ANIMATIONS = Symbol('animations'); -const START_TIMES = Symbol('start-times'); -const PAUSE_START = Symbol('pause-start'); -const PAUSE_TIME = Symbol('pause-time'); -const _raf = typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame : function(cb: Function) {return setTimeout(cb, 1000/60)} -const _caf = typeof cancelAnimationFrame !== 'undefined' ? cancelAnimationFrame: function(id: any) {clearTimeout(id)} - -// const TICK = 'tick'; -// const TICK_HANDLER = 'tick-handler'; -// const ANIMATIONS = 'animations'; -// const START_TIMES = 'start-times'; -// const PAUSE_START = 'pause-start'; -// const PAUSE_TIME = 'pause-time'; -// const _raf = function(callback):number|null {return setTimeout(callback, 1000/60)} -// const _caf = function(id: number):void {clearTimeout(id)} - -export class Timeline { - state: string - constructor() { - this.state = 'Initiated'; - this[ANIMATIONS] = new Set(); - this[START_TIMES] = new Map(); - } - start() { - if (!(this.state === 'Initiated')) return; - this.state = 'Started'; - - let startTime = Date.now(); - this[PAUSE_TIME] = 0; - this[TICK] = () => { - let now = Date.now(); - this[ANIMATIONS].forEach((animation) => { - let t: number; - if (this[START_TIMES].get(animation) < startTime) { - t = now - startTime - animation.delay - this[PAUSE_TIME]; - } else { - t = now - this[START_TIMES].get(animation) - animation.delay - this[PAUSE_TIME]; - } - - if (t > animation.duration) { - this[ANIMATIONS].delete(animation); - t = animation.duration; - } - if (t > 0) animation.run(t); - }) - // for (let animation of this[ANIMATIONS]) { - // let t: number; - // console.log('animation', animation) - // if (this[START_TIMES].get(animation) < startTime) { - // t = now - startTime - animation.delay - this[PAUSE_TIME]; - // } else { - // t = now - this[START_TIMES].get(animation) - animation.delay - this[PAUSE_TIME]; - // } - - // if (t > animation.duration) { - // this[ANIMATIONS].delete(animation); - // t = animation.duration; - // } - // if (t > 0) animation.run(t); - // } - this[TICK_HANDLER] = _raf(this[TICK]); - }; - this[TICK](); - } - pause() { - if (!(this.state === 'Started')) return; - this.state = 'Paused'; - - this[PAUSE_START] = Date.now(); - _caf(this[TICK_HANDLER]); - } - resume() { - if (!(this.state === 'Paused')) return; - this.state = 'Started'; - - this[PAUSE_TIME] += Date.now() - this[PAUSE_START]; - this[TICK](); - } - reset() { - this.pause(); - this.state = 'Initiated'; - this[PAUSE_TIME] = 0; - this[PAUSE_START] = 0; - this[ANIMATIONS] = new Set(); - this[START_TIMES] = new Map(); - this[TICK_HANDLER] = null; - } - add(animation: any, startTime?: number) { - if (arguments.length < 2) startTime = Date.now(); - this[ANIMATIONS].add(animation); - this[START_TIMES].set(animation, startTime); - } -} - -export class Animation { - startValue: number - endValue: number - duration: number - timingFunction: (t: number) => number - delay: number - template: (t: number) => void - constructor(startValue: number, endValue: number, duration: number, delay: number, timingFunction: (t: number) => number, template: (v: number) => void) { - timingFunction = timingFunction || (v => v); - template = template || (v => v); - - this.startValue = startValue; - this.endValue = endValue; - this.duration = duration; - this.timingFunction = timingFunction; - this.delay = delay; - this.template = template; - } - - run(time: number) { - let range = this.endValue - this.startValue; - let progress = time / this.duration - if(progress != 1) progress = this.timingFunction(progress) - this.template(this.startValue + range * progress) - } -} \ No newline at end of file diff --git a/uni_modules/lime-shared/areaData/city-china.json b/uni_modules/lime-shared/areaData/city-china.json deleted file mode 100644 index d9872a0..0000000 --- a/uni_modules/lime-shared/areaData/city-china.json +++ /dev/null @@ -1,3888 +0,0 @@ -{ - "province_list": { - "110000": "北京市", - "120000": "天津市", - "130000": "河北省", - "140000": "山西省", - "150000": "内蒙古自治区", - "210000": "辽宁省", - "220000": "吉林省", - "230000": "黑龙江省", - "310000": "上海市", - "320000": "江苏省", - "330000": "浙江省", - "340000": "安徽省", - "350000": "福建省", - "360000": "江西省", - "370000": "山东省", - "410000": "河南省", - "420000": "湖北省", - "430000": "湖南省", - "440000": "广东省", - "450000": "广西壮族自治区", - "460000": "海南省", - "500000": "重庆市", - "510000": "四川省", - "520000": "贵州省", - "530000": "云南省", - "540000": "西藏自治区", - "610000": "陕西省", - "620000": "甘肃省", - "630000": "青海省", - "640000": "宁夏回族自治区", - "650000": "新疆维吾尔自治区", - "710000": "台湾省", - "810000": "香港特别行政区", - "820000": "澳门特别行政区" - }, - "city_list": { - "110100": "北京市", - "120100": "天津市", - "130100": "石家庄市", - "130200": "唐山市", - "130300": "秦皇岛市", - "130400": "邯郸市", - "130500": "邢台市", - "130600": "保定市", - "130700": "张家口市", - "130800": "承德市", - "130900": "沧州市", - "131000": "廊坊市", - "131100": "衡水市", - "140100": "太原市", - "140200": "大同市", - "140300": "阳泉市", - "140400": "长治市", - "140500": "晋城市", - "140600": "朔州市", - "140700": "晋中市", - "140800": "运城市", - "140900": "忻州市", - "141000": "临汾市", - "141100": "吕梁市", - "150100": "呼和浩特市", - "150200": "包头市", - "150300": "乌海市", - "150400": "赤峰市", - "150500": "通辽市", - "150600": "鄂尔多斯市", - "150700": "呼伦贝尔市", - "150800": "巴彦淖尔市", - "150900": "乌兰察布市", - "152200": "兴安盟", - "152500": "锡林郭勒盟", - "152900": "阿拉善盟", - "210100": "沈阳市", - "210200": "大连市", - "210300": "鞍山市", - "210400": "抚顺市", - "210500": "本溪市", - "210600": "丹东市", - "210700": "锦州市", - "210800": "营口市", - "210900": "阜新市", - "211000": "辽阳市", - "211100": "盘锦市", - "211200": "铁岭市", - "211300": "朝阳市", - "211400": "葫芦岛市", - "220100": "长春市", - "220200": "吉林市", - "220300": "四平市", - "220400": "辽源市", - "220500": "通化市", - "220600": "白山市", - "220700": "松原市", - "220800": "白城市", - "222400": "延边朝鲜族自治州", - "230100": "哈尔滨市", - "230200": "齐齐哈尔市", - "230300": "鸡西市", - "230400": "鹤岗市", - "230500": "双鸭山市", - "230600": "大庆市", - "230700": "伊春市", - "230800": "佳木斯市", - "230900": "七台河市", - "231000": "牡丹江市", - "231100": "黑河市", - "231200": "绥化市", - "232700": "大兴安岭地区", - "310100": "上海市", - "320100": "南京市", - "320200": "无锡市", - "320300": "徐州市", - "320400": "常州市", - "320500": "苏州市", - "320600": "南通市", - "320700": "连云港市", - "320800": "淮安市", - "320900": "盐城市", - "321000": "扬州市", - "321100": "镇江市", - "321200": "泰州市", - "321300": "宿迁市", - "330100": "杭州市", - "330200": "宁波市", - "330300": "温州市", - "330400": "嘉兴市", - "330500": "湖州市", - "330600": "绍兴市", - "330700": "金华市", - "330800": "衢州市", - "330900": "舟山市", - "331000": "台州市", - "331100": "丽水市", - "340100": "合肥市", - "340200": "芜湖市", - "340300": "蚌埠市", - "340400": "淮南市", - "340500": "马鞍山市", - "340600": "淮北市", - "340700": "铜陵市", - "340800": "安庆市", - "341000": "黄山市", - "341100": "滁州市", - "341200": "阜阳市", - "341300": "宿州市", - "341500": "六安市", - "341600": "亳州市", - "341700": "池州市", - "341800": "宣城市", - "350100": "福州市", - "350200": "厦门市", - "350300": "莆田市", - "350400": "三明市", - "350500": "泉州市", - "350600": "漳州市", - "350700": "南平市", - "350800": "龙岩市", - "350900": "宁德市", - "360100": "南昌市", - "360200": "景德镇市", - "360300": "萍乡市", - "360400": "九江市", - "360500": "新余市", - "360600": "鹰潭市", - "360700": "赣州市", - "360800": "吉安市", - "360900": "宜春市", - "361000": "抚州市", - "361100": "上饶市", - "370100": "济南市", - "370200": "青岛市", - "370300": "淄博市", - "370400": "枣庄市", - "370500": "东营市", - "370600": "烟台市", - "370700": "潍坊市", - "370800": "济宁市", - "370900": "泰安市", - "371000": "威海市", - "371100": "日照市", - "371300": "临沂市", - "371400": "德州市", - "371500": "聊城市", - "371600": "滨州市", - "371700": "菏泽市", - "410100": "郑州市", - "410200": "开封市", - "410300": "洛阳市", - "410400": "平顶山市", - "410500": "安阳市", - "410600": "鹤壁市", - "410700": "新乡市", - "410800": "焦作市", - "410900": "濮阳市", - "411000": "许昌市", - "411100": "漯河市", - "411200": "三门峡市", - "411300": "南阳市", - "411400": "商丘市", - "411500": "信阳市", - "411600": "周口市", - "411700": "驻马店市", - "419000": "省直辖县", - "420100": "武汉市", - "420200": "黄石市", - "420300": "十堰市", - "420500": "宜昌市", - "420600": "襄阳市", - "420700": "鄂州市", - "420800": "荆门市", - "420900": "孝感市", - "421000": "荆州市", - "421100": "黄冈市", - "421200": "咸宁市", - "421300": "随州市", - "422800": "恩施土家族苗族自治州", - "429000": "省直辖县", - "430100": "长沙市", - "430200": "株洲市", - "430300": "湘潭市", - "430400": "衡阳市", - "430500": "邵阳市", - "430600": "岳阳市", - "430700": "常德市", - "430800": "张家界市", - "430900": "益阳市", - "431000": "郴州市", - "431100": "永州市", - "431200": "怀化市", - "431300": "娄底市", - "433100": "湘西土家族苗族自治州", - "440100": "广州市", - "440200": "韶关市", - "440300": "深圳市", - "440400": "珠海市", - "440500": "汕头市", - "440600": "佛山市", - "440700": "江门市", - "440800": "湛江市", - "440900": "茂名市", - "441200": "肇庆市", - "441300": "惠州市", - "441400": "梅州市", - "441500": "汕尾市", - "441600": "河源市", - "441700": "阳江市", - "441800": "清远市", - "441900": "东莞市", - "442000": "中山市", - "445100": "潮州市", - "445200": "揭阳市", - "445300": "云浮市", - "450100": "南宁市", - "450200": "柳州市", - "450300": "桂林市", - "450400": "梧州市", - "450500": "北海市", - "450600": "防城港市", - "450700": "钦州市", - "450800": "贵港市", - "450900": "玉林市", - "451000": "百色市", - "451100": "贺州市", - "451200": "河池市", - "451300": "来宾市", - "451400": "崇左市", - "460100": "海口市", - "460200": "三亚市", - "460300": "三沙市", - "460400": "儋州市", - "469000": "省直辖县", - "500100": "重庆市", - "500200": "县", - "510100": "成都市", - "510300": "自贡市", - "510400": "攀枝花市", - "510500": "泸州市", - "510600": "德阳市", - "510700": "绵阳市", - "510800": "广元市", - "510900": "遂宁市", - "511000": "内江市", - "511100": "乐山市", - "511300": "南充市", - "511400": "眉山市", - "511500": "宜宾市", - "511600": "广安市", - "511700": "达州市", - "511800": "雅安市", - "511900": "巴中市", - "512000": "资阳市", - "513200": "阿坝藏族羌族自治州", - "513300": "甘孜藏族自治州", - "513400": "凉山彝族自治州", - "520100": "贵阳市", - "520200": "六盘水市", - "520300": "遵义市", - "520400": "安顺市", - "520500": "毕节市", - "520600": "铜仁市", - "522300": "黔西南布依族苗族自治州", - "522600": "黔东南苗族侗族自治州", - "522700": "黔南布依族苗族自治州", - "530100": "昆明市", - "530300": "曲靖市", - "530400": "玉溪市", - "530500": "保山市", - "530600": "昭通市", - "530700": "丽江市", - "530800": "普洱市", - "530900": "临沧市", - "532300": "楚雄彝族自治州", - "532500": "红河哈尼族彝族自治州", - "532600": "文山壮族苗族自治州", - "532800": "西双版纳傣族自治州", - "532900": "大理白族自治州", - "533100": "德宏傣族景颇族自治州", - "533300": "怒江傈僳族自治州", - "533400": "迪庆藏族自治州", - "540100": "拉萨市", - "540200": "日喀则市", - "540300": "昌都市", - "540400": "林芝市", - "540500": "山南市", - "540600": "那曲市", - "542500": "阿里地区", - "610100": "西安市", - "610200": "铜川市", - "610300": "宝鸡市", - "610400": "咸阳市", - "610500": "渭南市", - "610600": "延安市", - "610700": "汉中市", - "610800": "榆林市", - "610900": "安康市", - "611000": "商洛市", - "620100": "兰州市", - "620200": "嘉峪关市", - "620300": "金昌市", - "620400": "白银市", - "620500": "天水市", - "620600": "武威市", - "620700": "张掖市", - "620800": "平凉市", - "620900": "酒泉市", - "621000": "庆阳市", - "621100": "定西市", - "621200": "陇南市", - "622900": "临夏回族自治州", - "623000": "甘南藏族自治州", - "630100": "西宁市", - "630200": "海东市", - "632200": "海北藏族自治州", - "632300": "黄南藏族自治州", - "632500": "海南藏族自治州", - "632600": "果洛藏族自治州", - "632700": "玉树藏族自治州", - "632800": "海西蒙古族藏族自治州", - "640100": "银川市", - "640200": "石嘴山市", - "640300": "吴忠市", - "640400": "固原市", - "640500": "中卫市", - "650100": "乌鲁木齐市", - "650200": "克拉玛依市", - "650400": "吐鲁番市", - "650500": "哈密市", - "652300": "昌吉回族自治州", - "652700": "博尔塔拉蒙古自治州", - "652800": "巴音郭楞蒙古自治州", - "652900": "阿克苏地区", - "653000": "克孜勒苏柯尔克孜自治州", - "653100": "喀什地区", - "653200": "和田地区", - "654000": "伊犁哈萨克自治州", - "654200": "塔城地区", - "654300": "阿勒泰地区", - "659000": "自治区直辖县级行政区划", - "710100": "台北市", - "710200": "高雄市", - "710300": "台南市", - "710400": "台中市", - "710500": "金门县", - "710600": "南投县", - "710700": "基隆市", - "710800": "新竹市", - "710900": "嘉义市", - "711100": "新北市", - "711200": "宜兰县", - "711300": "新竹县", - "711400": "桃园市", - "711500": "苗栗县", - "711700": "彰化县", - "711900": "嘉义县", - "712100": "云林县", - "712400": "屏东县", - "712500": "台东县", - "712600": "花莲县", - "712700": "澎湖县", - "712800": "连江县", - "810100": "香港岛", - "810200": "九龙", - "810300": "新界", - "820100": "澳门半岛", - "820200": "离岛" - }, - "county_list": { - "110101": "东城区", - "110102": "西城区", - "110105": "朝阳区", - "110106": "丰台区", - "110107": "石景山区", - "110108": "海淀区", - "110109": "门头沟区", - "110111": "房山区", - "110112": "通州区", - "110113": "顺义区", - "110114": "昌平区", - "110115": "大兴区", - "110116": "怀柔区", - "110117": "平谷区", - "110118": "密云区", - "110119": "延庆区", - "120101": "和平区", - "120102": "河东区", - "120103": "河西区", - "120104": "南开区", - "120105": "河北区", - "120106": "红桥区", - "120110": "东丽区", - "120111": "西青区", - "120112": "津南区", - "120113": "北辰区", - "120114": "武清区", - "120115": "宝坻区", - "120116": "滨海新区", - "120117": "宁河区", - "120118": "静海区", - "120119": "蓟州区", - "130102": "长安区", - "130104": "桥西区", - "130105": "新华区", - "130107": "井陉矿区", - "130108": "裕华区", - "130109": "藁城区", - "130110": "鹿泉区", - "130111": "栾城区", - "130121": "井陉县", - "130123": "正定县", - "130125": "行唐县", - "130126": "灵寿县", - "130127": "高邑县", - "130128": "深泽县", - "130129": "赞皇县", - "130130": "无极县", - "130131": "平山县", - "130132": "元氏县", - "130133": "赵县", - "130171": "石家庄高新技术产业开发区", - "130172": "石家庄循环化工园区", - "130181": "辛集市", - "130183": "晋州市", - "130184": "新乐市", - "130202": "路南区", - "130203": "路北区", - "130204": "古冶区", - "130205": "开平区", - "130207": "丰南区", - "130208": "丰润区", - "130209": "曹妃甸区", - "130224": "滦南县", - "130225": "乐亭县", - "130227": "迁西县", - "130229": "玉田县", - "130273": "唐山高新技术产业开发区", - "130274": "河北唐山海港经济开发区", - "130281": "遵化市", - "130283": "迁安市", - "130284": "滦州市", - "130302": "海港区", - "130303": "山海关区", - "130304": "北戴河区", - "130306": "抚宁区", - "130321": "青龙满族自治县", - "130322": "昌黎县", - "130324": "卢龙县", - "130371": "秦皇岛市经济技术开发区", - "130372": "北戴河新区", - "130390": "经济技术开发区", - "130402": "邯山区", - "130403": "丛台区", - "130404": "复兴区", - "130406": "峰峰矿区", - "130407": "肥乡区", - "130408": "永年区", - "130423": "临漳县", - "130424": "成安县", - "130425": "大名县", - "130426": "涉县", - "130427": "磁县", - "130430": "邱县", - "130431": "鸡泽县", - "130432": "广平县", - "130433": "馆陶县", - "130434": "魏县", - "130435": "曲周县", - "130471": "邯郸经济技术开发区", - "130473": "邯郸冀南新区", - "130481": "武安市", - "130502": "襄都区", - "130503": "信都区", - "130505": "任泽区", - "130506": "南和区", - "130522": "临城县", - "130523": "内丘县", - "130524": "柏乡县", - "130525": "隆尧县", - "130528": "宁晋县", - "130529": "巨鹿县", - "130530": "新河县", - "130531": "广宗县", - "130532": "平乡县", - "130533": "威县", - "130534": "清河县", - "130535": "临西县", - "130571": "河北邢台经济开发区", - "130581": "南宫市", - "130582": "沙河市", - "130602": "竞秀区", - "130606": "莲池区", - "130607": "满城区", - "130608": "清苑区", - "130609": "徐水区", - "130623": "涞水县", - "130624": "阜平县", - "130626": "定兴县", - "130627": "唐县", - "130628": "高阳县", - "130629": "容城县", - "130630": "涞源县", - "130631": "望都县", - "130632": "安新县", - "130633": "易县", - "130634": "曲阳县", - "130635": "蠡县", - "130636": "顺平县", - "130637": "博野县", - "130638": "雄县", - "130671": "保定高新技术产业开发区", - "130672": "保定白沟新城", - "130681": "涿州市", - "130682": "定州市", - "130683": "安国市", - "130684": "高碑店市", - "130702": "桥东区", - "130703": "桥西区", - "130705": "宣化区", - "130706": "下花园区", - "130708": "万全区", - "130709": "崇礼区", - "130722": "张北县", - "130723": "康保县", - "130724": "沽源县", - "130725": "尚义县", - "130726": "蔚县", - "130727": "阳原县", - "130728": "怀安县", - "130730": "怀来县", - "130731": "涿鹿县", - "130732": "赤城县", - "130772": "张家口市察北管理区", - "130802": "双桥区", - "130803": "双滦区", - "130804": "鹰手营子矿区", - "130821": "承德县", - "130822": "兴隆县", - "130824": "滦平县", - "130825": "隆化县", - "130826": "丰宁满族自治县", - "130827": "宽城满族自治县", - "130828": "围场满族蒙古族自治县", - "130871": "承德高新技术产业开发区", - "130881": "平泉市", - "130902": "新华区", - "130903": "运河区", - "130921": "沧县", - "130922": "青县", - "130923": "东光县", - "130924": "海兴县", - "130925": "盐山县", - "130926": "肃宁县", - "130927": "南皮县", - "130928": "吴桥县", - "130929": "献县", - "130930": "孟村回族自治县", - "130971": "河北沧州经济开发区", - "130972": "沧州高新技术产业开发区", - "130973": "沧州渤海新区", - "130981": "泊头市", - "130982": "任丘市", - "130983": "黄骅市", - "130984": "河间市", - "131002": "安次区", - "131003": "广阳区", - "131022": "固安县", - "131023": "永清县", - "131024": "香河县", - "131025": "大城县", - "131026": "文安县", - "131028": "大厂回族自治县", - "131071": "廊坊经济技术开发区", - "131081": "霸州市", - "131082": "三河市", - "131090": "开发区", - "131102": "桃城区", - "131103": "冀州区", - "131121": "枣强县", - "131122": "武邑县", - "131123": "武强县", - "131124": "饶阳县", - "131125": "安平县", - "131126": "故城县", - "131127": "景县", - "131128": "阜城县", - "131171": "河北衡水经济开发区", - "131172": "衡水滨湖新区", - "131182": "深州市", - "140105": "小店区", - "140106": "迎泽区", - "140107": "杏花岭区", - "140108": "尖草坪区", - "140109": "万柏林区", - "140110": "晋源区", - "140121": "清徐县", - "140122": "阳曲县", - "140123": "娄烦县", - "140181": "古交市", - "140212": "新荣区", - "140213": "平城区", - "140214": "云冈区", - "140215": "云州区", - "140221": "阳高县", - "140222": "天镇县", - "140223": "广灵县", - "140224": "灵丘县", - "140225": "浑源县", - "140226": "左云县", - "140271": "山西大同经济开发区", - "140302": "城区", - "140303": "矿区", - "140311": "郊区", - "140321": "平定县", - "140322": "盂县", - "140403": "潞州区", - "140404": "上党区", - "140405": "屯留区", - "140406": "潞城区", - "140423": "襄垣县", - "140425": "平顺县", - "140426": "黎城县", - "140427": "壶关县", - "140428": "长子县", - "140429": "武乡县", - "140430": "沁县", - "140431": "沁源县", - "140471": "山西长治高新技术产业园区", - "140502": "城区", - "140521": "沁水县", - "140522": "阳城县", - "140524": "陵川县", - "140525": "泽州县", - "140581": "高平市", - "140602": "朔城区", - "140603": "平鲁区", - "140621": "山阴县", - "140622": "应县", - "140623": "右玉县", - "140671": "山西朔州经济开发区", - "140681": "怀仁市", - "140702": "榆次区", - "140703": "太谷区", - "140721": "榆社县", - "140722": "左权县", - "140723": "和顺县", - "140724": "昔阳县", - "140725": "寿阳县", - "140727": "祁县", - "140728": "平遥县", - "140729": "灵石县", - "140781": "介休市", - "140802": "盐湖区", - "140821": "临猗县", - "140822": "万荣县", - "140823": "闻喜县", - "140824": "稷山县", - "140825": "新绛县", - "140826": "绛县", - "140827": "垣曲县", - "140828": "夏县", - "140829": "平陆县", - "140830": "芮城县", - "140881": "永济市", - "140882": "河津市", - "140902": "忻府区", - "140921": "定襄县", - "140922": "五台县", - "140923": "代县", - "140924": "繁峙县", - "140925": "宁武县", - "140926": "静乐县", - "140927": "神池县", - "140928": "五寨县", - "140929": "岢岚县", - "140930": "河曲县", - "140931": "保德县", - "140932": "偏关县", - "140971": "五台山风景名胜区", - "140981": "原平市", - "141002": "尧都区", - "141021": "曲沃县", - "141022": "翼城县", - "141023": "襄汾县", - "141024": "洪洞县", - "141025": "古县", - "141026": "安泽县", - "141027": "浮山县", - "141028": "吉县", - "141029": "乡宁县", - "141030": "大宁县", - "141031": "隰县", - "141032": "永和县", - "141033": "蒲县", - "141034": "汾西县", - "141081": "侯马市", - "141082": "霍州市", - "141102": "离石区", - "141121": "文水县", - "141122": "交城县", - "141123": "兴县", - "141124": "临县", - "141125": "柳林县", - "141126": "石楼县", - "141127": "岚县", - "141128": "方山县", - "141129": "中阳县", - "141130": "交口县", - "141181": "孝义市", - "141182": "汾阳市", - "150102": "新城区", - "150103": "回民区", - "150104": "玉泉区", - "150105": "赛罕区", - "150121": "土默特左旗", - "150122": "托克托县", - "150123": "和林格尔县", - "150124": "清水河县", - "150125": "武川县", - "150172": "呼和浩特经济技术开发区", - "150202": "东河区", - "150203": "昆都仑区", - "150204": "青山区", - "150205": "石拐区", - "150206": "白云鄂博矿区", - "150207": "九原区", - "150221": "土默特右旗", - "150222": "固阳县", - "150223": "达尔罕茂明安联合旗", - "150271": "包头稀土高新技术产业开发区", - "150302": "海勃湾区", - "150303": "海南区", - "150304": "乌达区", - "150402": "红山区", - "150403": "元宝山区", - "150404": "松山区", - "150421": "阿鲁科尔沁旗", - "150422": "巴林左旗", - "150423": "巴林右旗", - "150424": "林西县", - "150425": "克什克腾旗", - "150426": "翁牛特旗", - "150428": "喀喇沁旗", - "150429": "宁城县", - "150430": "敖汉旗", - "150502": "科尔沁区", - "150521": "科尔沁左翼中旗", - "150522": "科尔沁左翼后旗", - "150523": "开鲁县", - "150524": "库伦旗", - "150525": "奈曼旗", - "150526": "扎鲁特旗", - "150571": "通辽经济技术开发区", - "150581": "霍林郭勒市", - "150602": "东胜区", - "150603": "康巴什区", - "150621": "达拉特旗", - "150622": "准格尔旗", - "150623": "鄂托克前旗", - "150624": "鄂托克旗", - "150625": "杭锦旗", - "150626": "乌审旗", - "150627": "伊金霍洛旗", - "150702": "海拉尔区", - "150703": "扎赉诺尔区", - "150721": "阿荣旗", - "150722": "莫力达瓦达斡尔族自治旗", - "150723": "鄂伦春自治旗", - "150724": "鄂温克族自治旗", - "150725": "陈巴尔虎旗", - "150726": "新巴尔虎左旗", - "150727": "新巴尔虎右旗", - "150781": "满洲里市", - "150782": "牙克石市", - "150783": "扎兰屯市", - "150784": "额尔古纳市", - "150785": "根河市", - "150802": "临河区", - "150821": "五原县", - "150822": "磴口县", - "150823": "乌拉特前旗", - "150824": "乌拉特中旗", - "150825": "乌拉特后旗", - "150826": "杭锦后旗", - "150902": "集宁区", - "150921": "卓资县", - "150922": "化德县", - "150923": "商都县", - "150924": "兴和县", - "150925": "凉城县", - "150926": "察哈尔右翼前旗", - "150927": "察哈尔右翼中旗", - "150928": "察哈尔右翼后旗", - "150929": "四子王旗", - "150981": "丰镇市", - "152201": "乌兰浩特市", - "152202": "阿尔山市", - "152221": "科尔沁右翼前旗", - "152222": "科尔沁右翼中旗", - "152223": "扎赉特旗", - "152224": "突泉县", - "152501": "二连浩特市", - "152502": "锡林浩特市", - "152522": "阿巴嘎旗", - "152523": "苏尼特左旗", - "152524": "苏尼特右旗", - "152525": "东乌珠穆沁旗", - "152526": "西乌珠穆沁旗", - "152527": "太仆寺旗", - "152528": "镶黄旗", - "152529": "正镶白旗", - "152530": "正蓝旗", - "152531": "多伦县", - "152571": "乌拉盖管委会", - "152921": "阿拉善左旗", - "152922": "阿拉善右旗", - "152923": "额济纳旗", - "152971": "内蒙古阿拉善经济开发区", - "210102": "和平区", - "210103": "沈河区", - "210104": "大东区", - "210105": "皇姑区", - "210106": "铁西区", - "210111": "苏家屯区", - "210112": "浑南区", - "210113": "沈北新区", - "210114": "于洪区", - "210115": "辽中区", - "210123": "康平县", - "210124": "法库县", - "210181": "新民市", - "210190": "经济技术开发区", - "210202": "中山区", - "210203": "西岗区", - "210204": "沙河口区", - "210211": "甘井子区", - "210212": "旅顺口区", - "210213": "金州区", - "210214": "普兰店区", - "210224": "长海县", - "210281": "瓦房店市", - "210283": "庄河市", - "210302": "铁东区", - "210303": "铁西区", - "210304": "立山区", - "210311": "千山区", - "210321": "台安县", - "210323": "岫岩满族自治县", - "210381": "海城市", - "210390": "高新区", - "210402": "新抚区", - "210403": "东洲区", - "210404": "望花区", - "210411": "顺城区", - "210421": "抚顺县", - "210422": "新宾满族自治县", - "210423": "清原满族自治县", - "210502": "平山区", - "210503": "溪湖区", - "210504": "明山区", - "210505": "南芬区", - "210521": "本溪满族自治县", - "210522": "桓仁满族自治县", - "210602": "元宝区", - "210603": "振兴区", - "210604": "振安区", - "210624": "宽甸满族自治县", - "210681": "东港市", - "210682": "凤城市", - "210702": "古塔区", - "210703": "凌河区", - "210711": "太和区", - "210726": "黑山县", - "210727": "义县", - "210781": "凌海市", - "210782": "北镇市", - "210793": "经济技术开发区", - "210802": "站前区", - "210803": "西市区", - "210804": "鲅鱼圈区", - "210811": "老边区", - "210881": "盖州市", - "210882": "大石桥市", - "210902": "海州区", - "210903": "新邱区", - "210904": "太平区", - "210905": "清河门区", - "210911": "细河区", - "210921": "阜新蒙古族自治县", - "210922": "彰武县", - "211002": "白塔区", - "211003": "文圣区", - "211004": "宏伟区", - "211005": "弓长岭区", - "211011": "太子河区", - "211021": "辽阳县", - "211081": "灯塔市", - "211102": "双台子区", - "211103": "兴隆台区", - "211104": "大洼区", - "211122": "盘山县", - "211202": "银州区", - "211204": "清河区", - "211221": "铁岭县", - "211223": "西丰县", - "211224": "昌图县", - "211281": "调兵山市", - "211282": "开原市", - "211302": "双塔区", - "211303": "龙城区", - "211321": "朝阳县", - "211322": "建平县", - "211324": "喀喇沁左翼蒙古族自治县", - "211381": "北票市", - "211382": "凌源市", - "211402": "连山区", - "211403": "龙港区", - "211404": "南票区", - "211421": "绥中县", - "211422": "建昌县", - "211481": "兴城市", - "220102": "南关区", - "220103": "宽城区", - "220104": "朝阳区", - "220105": "二道区", - "220106": "绿园区", - "220112": "双阳区", - "220113": "九台区", - "220122": "农安县", - "220171": "长春经济技术开发区", - "220172": "长春净月高新技术产业开发区", - "220173": "长春高新技术产业开发区", - "220174": "长春汽车经济技术开发区", - "220182": "榆树市", - "220183": "德惠市", - "220184": "公主岭市", - "220192": "经济技术开发区", - "220202": "昌邑区", - "220203": "龙潭区", - "220204": "船营区", - "220211": "丰满区", - "220221": "永吉县", - "220271": "吉林经济开发区", - "220272": "吉林高新技术产业开发区", - "220281": "蛟河市", - "220282": "桦甸市", - "220283": "舒兰市", - "220284": "磐石市", - "220302": "铁西区", - "220303": "铁东区", - "220322": "梨树县", - "220323": "伊通满族自治县", - "220382": "双辽市", - "220402": "龙山区", - "220403": "西安区", - "220421": "东丰县", - "220422": "东辽县", - "220502": "东昌区", - "220503": "二道江区", - "220521": "通化县", - "220523": "辉南县", - "220524": "柳河县", - "220581": "梅河口市", - "220582": "集安市", - "220602": "浑江区", - "220605": "江源区", - "220621": "抚松县", - "220622": "靖宇县", - "220623": "长白朝鲜族自治县", - "220681": "临江市", - "220702": "宁江区", - "220721": "前郭尔罗斯蒙古族自治县", - "220722": "长岭县", - "220723": "乾安县", - "220771": "吉林松原经济开发区", - "220781": "扶余市", - "220802": "洮北区", - "220821": "镇赉县", - "220822": "通榆县", - "220871": "吉林白城经济开发区", - "220881": "洮南市", - "220882": "大安市", - "222401": "延吉市", - "222402": "图们市", - "222403": "敦化市", - "222404": "珲春市", - "222405": "龙井市", - "222406": "和龙市", - "222424": "汪清县", - "222426": "安图县", - "230102": "道里区", - "230103": "南岗区", - "230104": "道外区", - "230108": "平房区", - "230109": "松北区", - "230110": "香坊区", - "230111": "呼兰区", - "230112": "阿城区", - "230113": "双城区", - "230123": "依兰县", - "230124": "方正县", - "230125": "宾县", - "230126": "巴彦县", - "230127": "木兰县", - "230128": "通河县", - "230129": "延寿县", - "230183": "尚志市", - "230184": "五常市", - "230202": "龙沙区", - "230203": "建华区", - "230204": "铁锋区", - "230205": "昂昂溪区", - "230206": "富拉尔基区", - "230207": "碾子山区", - "230208": "梅里斯达斡尔族区", - "230221": "龙江县", - "230223": "依安县", - "230224": "泰来县", - "230225": "甘南县", - "230227": "富裕县", - "230229": "克山县", - "230230": "克东县", - "230231": "拜泉县", - "230281": "讷河市", - "230302": "鸡冠区", - "230303": "恒山区", - "230304": "滴道区", - "230305": "梨树区", - "230306": "城子河区", - "230307": "麻山区", - "230321": "鸡东县", - "230381": "虎林市", - "230382": "密山市", - "230402": "向阳区", - "230403": "工农区", - "230404": "南山区", - "230405": "兴安区", - "230406": "东山区", - "230407": "兴山区", - "230421": "萝北县", - "230422": "绥滨县", - "230502": "尖山区", - "230503": "岭东区", - "230505": "四方台区", - "230506": "宝山区", - "230521": "集贤县", - "230522": "友谊县", - "230523": "宝清县", - "230524": "饶河县", - "230602": "萨尔图区", - "230603": "龙凤区", - "230604": "让胡路区", - "230605": "红岗区", - "230606": "大同区", - "230621": "肇州县", - "230622": "肇源县", - "230623": "林甸县", - "230624": "杜尔伯特蒙古族自治县", - "230671": "大庆高新技术产业开发区", - "230717": "伊美区", - "230718": "乌翠区", - "230719": "友好区", - "230722": "嘉荫县", - "230723": "汤旺县", - "230724": "丰林县", - "230725": "大箐山县", - "230726": "南岔县", - "230751": "金林区", - "230781": "铁力市", - "230803": "向阳区", - "230804": "前进区", - "230805": "东风区", - "230811": "郊区", - "230822": "桦南县", - "230826": "桦川县", - "230828": "汤原县", - "230881": "同江市", - "230882": "富锦市", - "230883": "抚远市", - "230902": "新兴区", - "230903": "桃山区", - "230904": "茄子河区", - "230921": "勃利县", - "231002": "东安区", - "231003": "阳明区", - "231004": "爱民区", - "231005": "西安区", - "231025": "林口县", - "231081": "绥芬河市", - "231083": "海林市", - "231084": "宁安市", - "231085": "穆棱市", - "231086": "东宁市", - "231102": "爱辉区", - "231123": "逊克县", - "231124": "孙吴县", - "231181": "北安市", - "231182": "五大连池市", - "231183": "嫩江市", - "231202": "北林区", - "231221": "望奎县", - "231222": "兰西县", - "231223": "青冈县", - "231224": "庆安县", - "231225": "明水县", - "231226": "绥棱县", - "231281": "安达市", - "231282": "肇东市", - "231283": "海伦市", - "232701": "漠河市", - "232721": "呼玛县", - "232722": "塔河县", - "232761": "加格达奇区", - "232762": "松岭区", - "232763": "新林区", - "232764": "呼中区", - "310101": "黄浦区", - "310104": "徐汇区", - "310105": "长宁区", - "310106": "静安区", - "310107": "普陀区", - "310109": "虹口区", - "310110": "杨浦区", - "310112": "闵行区", - "310113": "宝山区", - "310114": "嘉定区", - "310115": "浦东新区", - "310116": "金山区", - "310117": "松江区", - "310118": "青浦区", - "310120": "奉贤区", - "310151": "崇明区", - "320102": "玄武区", - "320104": "秦淮区", - "320105": "建邺区", - "320106": "鼓楼区", - "320111": "浦口区", - "320112": "江北新区", - "320113": "栖霞区", - "320114": "雨花台区", - "320115": "江宁区", - "320116": "六合区", - "320117": "溧水区", - "320118": "高淳区", - "320205": "锡山区", - "320206": "惠山区", - "320211": "滨湖区", - "320213": "梁溪区", - "320214": "新吴区", - "320281": "江阴市", - "320282": "宜兴市", - "320302": "鼓楼区", - "320303": "云龙区", - "320305": "贾汪区", - "320311": "泉山区", - "320312": "铜山区", - "320321": "丰县", - "320322": "沛县", - "320324": "睢宁县", - "320371": "徐州经济技术开发区", - "320381": "新沂市", - "320382": "邳州市", - "320391": "工业园区", - "320402": "天宁区", - "320404": "钟楼区", - "320411": "新北区", - "320412": "武进区", - "320413": "金坛区", - "320481": "溧阳市", - "320505": "虎丘区", - "320506": "吴中区", - "320507": "相城区", - "320508": "姑苏区", - "320509": "吴江区", - "320571": "苏州工业园区", - "320581": "常熟市", - "320582": "张家港市", - "320583": "昆山市", - "320585": "太仓市", - "320590": "工业园区", - "320591": "高新区", - "320611": "港闸区", - "320612": "通州区", - "320613": "崇川区", - "320614": "海门区", - "320623": "如东县", - "320681": "启东市", - "320682": "如皋市", - "320685": "海安市", - "320691": "高新区", - "320703": "连云区", - "320706": "海州区", - "320707": "赣榆区", - "320722": "东海县", - "320723": "灌云县", - "320724": "灌南县", - "320771": "连云港经济技术开发区", - "320803": "淮安区", - "320804": "淮阴区", - "320812": "清江浦区", - "320813": "洪泽区", - "320826": "涟水县", - "320830": "盱眙县", - "320831": "金湖县", - "320871": "淮安经济技术开发区", - "320890": "经济开发区", - "320902": "亭湖区", - "320903": "盐都区", - "320904": "大丰区", - "320921": "响水县", - "320922": "滨海县", - "320923": "阜宁县", - "320924": "射阳县", - "320925": "建湖县", - "320971": "盐城经济技术开发区", - "320981": "东台市", - "321002": "广陵区", - "321003": "邗江区", - "321012": "江都区", - "321023": "宝应县", - "321071": "扬州经济技术开发区", - "321081": "仪征市", - "321084": "高邮市", - "321090": "经济开发区", - "321102": "京口区", - "321111": "润州区", - "321112": "丹徒区", - "321150": "镇江新区", - "321181": "丹阳市", - "321182": "扬中市", - "321183": "句容市", - "321202": "海陵区", - "321203": "高港区", - "321204": "姜堰区", - "321271": "泰州医药高新技术产业开发区", - "321281": "兴化市", - "321282": "靖江市", - "321283": "泰兴市", - "321302": "宿城区", - "321311": "宿豫区", - "321322": "沭阳县", - "321323": "泗阳县", - "321324": "泗洪县", - "321371": "宿迁经济技术开发区", - "330102": "上城区", - "330105": "拱墅区", - "330106": "西湖区", - "330108": "滨江区", - "330109": "萧山区", - "330110": "余杭区", - "330111": "富阳区", - "330112": "临安区", - "330113": "临平区", - "330114": "钱塘区", - "330122": "桐庐县", - "330127": "淳安县", - "330182": "建德市", - "330203": "海曙区", - "330205": "江北区", - "330206": "北仑区", - "330211": "镇海区", - "330212": "鄞州区", - "330213": "奉化区", - "330225": "象山县", - "330226": "宁海县", - "330281": "余姚市", - "330282": "慈溪市", - "330302": "鹿城区", - "330303": "龙湾区", - "330304": "瓯海区", - "330305": "洞头区", - "330324": "永嘉县", - "330326": "平阳县", - "330327": "苍南县", - "330328": "文成县", - "330329": "泰顺县", - "330381": "瑞安市", - "330382": "乐清市", - "330383": "龙港市", - "330402": "南湖区", - "330411": "秀洲区", - "330421": "嘉善县", - "330424": "海盐县", - "330481": "海宁市", - "330482": "平湖市", - "330483": "桐乡市", - "330502": "吴兴区", - "330503": "南浔区", - "330521": "德清县", - "330522": "长兴县", - "330523": "安吉县", - "330602": "越城区", - "330603": "柯桥区", - "330604": "上虞区", - "330624": "新昌县", - "330681": "诸暨市", - "330683": "嵊州市", - "330702": "婺城区", - "330703": "金东区", - "330723": "武义县", - "330726": "浦江县", - "330727": "磐安县", - "330781": "兰溪市", - "330782": "义乌市", - "330783": "东阳市", - "330784": "永康市", - "330802": "柯城区", - "330803": "衢江区", - "330822": "常山县", - "330824": "开化县", - "330825": "龙游县", - "330881": "江山市", - "330902": "定海区", - "330903": "普陀区", - "330921": "岱山县", - "330922": "嵊泗县", - "331002": "椒江区", - "331003": "黄岩区", - "331004": "路桥区", - "331022": "三门县", - "331023": "天台县", - "331024": "仙居县", - "331081": "温岭市", - "331082": "临海市", - "331083": "玉环市", - "331102": "莲都区", - "331121": "青田县", - "331122": "缙云县", - "331123": "遂昌县", - "331124": "松阳县", - "331125": "云和县", - "331126": "庆元县", - "331127": "景宁畲族自治县", - "331181": "龙泉市", - "340102": "瑶海区", - "340103": "庐阳区", - "340104": "蜀山区", - "340111": "包河区", - "340121": "长丰县", - "340122": "肥东县", - "340123": "肥西县", - "340124": "庐江县", - "340171": "合肥高新技术产业开发区", - "340172": "合肥经济技术开发区", - "340173": "合肥新站高新技术产业开发区", - "340181": "巢湖市", - "340190": "高新技术开发区", - "340191": "经济技术开发区", - "340202": "镜湖区", - "340207": "鸠江区", - "340209": "弋江区", - "340210": "湾沚区", - "340212": "繁昌区", - "340223": "南陵县", - "340281": "无为市", - "340302": "龙子湖区", - "340303": "蚌山区", - "340304": "禹会区", - "340311": "淮上区", - "340321": "怀远县", - "340322": "五河县", - "340323": "固镇县", - "340371": "蚌埠市高新技术开发区", - "340372": "蚌埠市经济开发区", - "340402": "大通区", - "340403": "田家庵区", - "340404": "谢家集区", - "340405": "八公山区", - "340406": "潘集区", - "340421": "凤台县", - "340422": "寿县", - "340503": "花山区", - "340504": "雨山区", - "340506": "博望区", - "340521": "当涂县", - "340522": "含山县", - "340523": "和县", - "340602": "杜集区", - "340603": "相山区", - "340604": "烈山区", - "340621": "濉溪县", - "340705": "铜官区", - "340706": "义安区", - "340711": "郊区", - "340722": "枞阳县", - "340802": "迎江区", - "340803": "大观区", - "340811": "宜秀区", - "340822": "怀宁县", - "340825": "太湖县", - "340826": "宿松县", - "340827": "望江县", - "340828": "岳西县", - "340881": "桐城市", - "340882": "潜山市", - "341002": "屯溪区", - "341003": "黄山区", - "341004": "徽州区", - "341021": "歙县", - "341022": "休宁县", - "341023": "黟县", - "341024": "祁门县", - "341102": "琅琊区", - "341103": "南谯区", - "341122": "来安县", - "341124": "全椒县", - "341125": "定远县", - "341126": "凤阳县", - "341181": "天长市", - "341182": "明光市", - "341202": "颍州区", - "341203": "颍东区", - "341204": "颍泉区", - "341221": "临泉县", - "341222": "太和县", - "341225": "阜南县", - "341226": "颍上县", - "341271": "阜阳合肥现代产业园区", - "341282": "界首市", - "341302": "埇桥区", - "341321": "砀山县", - "341322": "萧县", - "341323": "灵璧县", - "341324": "泗县", - "341371": "宿州马鞍山现代产业园区", - "341372": "宿州经济技术开发区", - "341390": "经济开发区", - "341502": "金安区", - "341503": "裕安区", - "341504": "叶集区", - "341522": "霍邱县", - "341523": "舒城县", - "341524": "金寨县", - "341525": "霍山县", - "341602": "谯城区", - "341621": "涡阳县", - "341622": "蒙城县", - "341623": "利辛县", - "341702": "贵池区", - "341721": "东至县", - "341722": "石台县", - "341723": "青阳县", - "341802": "宣州区", - "341821": "郎溪县", - "341823": "泾县", - "341824": "绩溪县", - "341825": "旌德县", - "341871": "宣城市经济开发区", - "341881": "宁国市", - "341882": "广德市", - "350102": "鼓楼区", - "350103": "台江区", - "350104": "仓山区", - "350105": "马尾区", - "350111": "晋安区", - "350112": "长乐区", - "350121": "闽侯县", - "350122": "连江县", - "350123": "罗源县", - "350124": "闽清县", - "350125": "永泰县", - "350128": "平潭县", - "350181": "福清市", - "350203": "思明区", - "350205": "海沧区", - "350206": "湖里区", - "350211": "集美区", - "350212": "同安区", - "350213": "翔安区", - "350302": "城厢区", - "350303": "涵江区", - "350304": "荔城区", - "350305": "秀屿区", - "350322": "仙游县", - "350402": "梅列区", - "350404": "三元区", - "350405": "沙县区", - "350421": "明溪县", - "350423": "清流县", - "350424": "宁化县", - "350425": "大田县", - "350426": "尤溪县", - "350428": "将乐县", - "350429": "泰宁县", - "350430": "建宁县", - "350481": "永安市", - "350502": "鲤城区", - "350503": "丰泽区", - "350504": "洛江区", - "350505": "泉港区", - "350521": "惠安县", - "350524": "安溪县", - "350525": "永春县", - "350526": "德化县", - "350527": "金门县", - "350581": "石狮市", - "350582": "晋江市", - "350583": "南安市", - "350602": "芗城区", - "350603": "龙文区", - "350604": "龙海区", - "350605": "长泰区", - "350622": "云霄县", - "350623": "漳浦县", - "350624": "诏安县", - "350626": "东山县", - "350627": "南靖县", - "350628": "平和县", - "350629": "华安县", - "350702": "延平区", - "350703": "建阳区", - "350721": "顺昌县", - "350722": "浦城县", - "350723": "光泽县", - "350724": "松溪县", - "350725": "政和县", - "350781": "邵武市", - "350782": "武夷山市", - "350783": "建瓯市", - "350802": "新罗区", - "350803": "永定区", - "350821": "长汀县", - "350823": "上杭县", - "350824": "武平县", - "350825": "连城县", - "350881": "漳平市", - "350902": "蕉城区", - "350921": "霞浦县", - "350922": "古田县", - "350923": "屏南县", - "350924": "寿宁县", - "350925": "周宁县", - "350926": "柘荣县", - "350981": "福安市", - "350982": "福鼎市", - "360102": "东湖区", - "360103": "西湖区", - "360104": "青云谱区", - "360111": "青山湖区", - "360112": "新建区", - "360113": "红谷滩区", - "360121": "南昌县", - "360123": "安义县", - "360124": "进贤县", - "360190": "经济技术开发区", - "360192": "高新区", - "360202": "昌江区", - "360203": "珠山区", - "360222": "浮梁县", - "360281": "乐平市", - "360302": "安源区", - "360313": "湘东区", - "360321": "莲花县", - "360322": "上栗县", - "360323": "芦溪县", - "360402": "濂溪区", - "360403": "浔阳区", - "360404": "柴桑区", - "360423": "武宁县", - "360424": "修水县", - "360425": "永修县", - "360426": "德安县", - "360428": "都昌县", - "360429": "湖口县", - "360430": "彭泽县", - "360481": "瑞昌市", - "360482": "共青城市", - "360483": "庐山市", - "360490": "经济技术开发区", - "360502": "渝水区", - "360521": "分宜县", - "360602": "月湖区", - "360603": "余江区", - "360681": "贵溪市", - "360702": "章贡区", - "360703": "南康区", - "360704": "赣县区", - "360722": "信丰县", - "360723": "大余县", - "360724": "上犹县", - "360725": "崇义县", - "360726": "安远县", - "360728": "定南县", - "360729": "全南县", - "360730": "宁都县", - "360731": "于都县", - "360732": "兴国县", - "360733": "会昌县", - "360734": "寻乌县", - "360735": "石城县", - "360781": "瑞金市", - "360783": "龙南市", - "360802": "吉州区", - "360803": "青原区", - "360821": "吉安县", - "360822": "吉水县", - "360823": "峡江县", - "360824": "新干县", - "360825": "永丰县", - "360826": "泰和县", - "360827": "遂川县", - "360828": "万安县", - "360829": "安福县", - "360830": "永新县", - "360881": "井冈山市", - "360902": "袁州区", - "360921": "奉新县", - "360922": "万载县", - "360923": "上高县", - "360924": "宜丰县", - "360925": "靖安县", - "360926": "铜鼓县", - "360981": "丰城市", - "360982": "樟树市", - "360983": "高安市", - "361002": "临川区", - "361003": "东乡区", - "361021": "南城县", - "361022": "黎川县", - "361023": "南丰县", - "361024": "崇仁县", - "361025": "乐安县", - "361026": "宜黄县", - "361027": "金溪县", - "361028": "资溪县", - "361030": "广昌县", - "361102": "信州区", - "361103": "广丰区", - "361104": "广信区", - "361123": "玉山县", - "361124": "铅山县", - "361125": "横峰县", - "361126": "弋阳县", - "361127": "余干县", - "361128": "鄱阳县", - "361129": "万年县", - "361130": "婺源县", - "361181": "德兴市", - "370102": "历下区", - "370103": "市中区", - "370104": "槐荫区", - "370105": "天桥区", - "370112": "历城区", - "370113": "长清区", - "370114": "章丘区", - "370115": "济阳区", - "370116": "莱芜区", - "370117": "钢城区", - "370124": "平阴县", - "370126": "商河县", - "370171": "济南高新技术产业开发区", - "370190": "高新区", - "370202": "市南区", - "370203": "市北区", - "370211": "黄岛区", - "370212": "崂山区", - "370213": "李沧区", - "370214": "城阳区", - "370215": "即墨区", - "370271": "青岛高新技术产业开发区", - "370281": "胶州市", - "370283": "平度市", - "370285": "莱西市", - "370290": "开发区", - "370302": "淄川区", - "370303": "张店区", - "370304": "博山区", - "370305": "临淄区", - "370306": "周村区", - "370321": "桓台县", - "370322": "高青县", - "370323": "沂源县", - "370402": "市中区", - "370403": "薛城区", - "370404": "峄城区", - "370405": "台儿庄区", - "370406": "山亭区", - "370481": "滕州市", - "370502": "东营区", - "370503": "河口区", - "370505": "垦利区", - "370522": "利津县", - "370523": "广饶县", - "370571": "东营经济技术开发区", - "370572": "东营港经济开发区", - "370602": "芝罘区", - "370611": "福山区", - "370612": "牟平区", - "370613": "莱山区", - "370614": "蓬莱区", - "370634": "长岛县", - "370671": "烟台高新技术产业开发区", - "370672": "烟台经济技术开发区", - "370681": "龙口市", - "370682": "莱阳市", - "370683": "莱州市", - "370685": "招远市", - "370686": "栖霞市", - "370687": "海阳市", - "370690": "开发区", - "370702": "潍城区", - "370703": "寒亭区", - "370704": "坊子区", - "370705": "奎文区", - "370724": "临朐县", - "370725": "昌乐县", - "370772": "潍坊滨海经济技术开发区", - "370781": "青州市", - "370782": "诸城市", - "370783": "寿光市", - "370784": "安丘市", - "370785": "高密市", - "370786": "昌邑市", - "370790": "开发区", - "370791": "高新区", - "370811": "任城区", - "370812": "兖州区", - "370826": "微山县", - "370827": "鱼台县", - "370828": "金乡县", - "370829": "嘉祥县", - "370830": "汶上县", - "370831": "泗水县", - "370832": "梁山县", - "370871": "济宁高新技术产业开发区", - "370881": "曲阜市", - "370883": "邹城市", - "370890": "高新区", - "370902": "泰山区", - "370911": "岱岳区", - "370921": "宁阳县", - "370923": "东平县", - "370982": "新泰市", - "370983": "肥城市", - "371002": "环翠区", - "371003": "文登区", - "371071": "威海火炬高技术产业开发区", - "371072": "威海经济技术开发区", - "371082": "荣成市", - "371083": "乳山市", - "371091": "经济技术开发区", - "371102": "东港区", - "371103": "岚山区", - "371121": "五莲县", - "371122": "莒县", - "371171": "日照经济技术开发区", - "371302": "兰山区", - "371311": "罗庄区", - "371312": "河东区", - "371321": "沂南县", - "371322": "郯城县", - "371323": "沂水县", - "371324": "兰陵县", - "371325": "费县", - "371326": "平邑县", - "371327": "莒南县", - "371328": "蒙阴县", - "371329": "临沭县", - "371371": "临沂高新技术产业开发区", - "371402": "德城区", - "371403": "陵城区", - "371422": "宁津县", - "371423": "庆云县", - "371424": "临邑县", - "371425": "齐河县", - "371426": "平原县", - "371427": "夏津县", - "371428": "武城县", - "371472": "德州运河经济开发区", - "371481": "乐陵市", - "371482": "禹城市", - "371502": "东昌府区", - "371503": "茌平区", - "371521": "阳谷县", - "371522": "莘县", - "371524": "东阿县", - "371525": "冠县", - "371526": "高唐县", - "371581": "临清市", - "371602": "滨城区", - "371603": "沾化区", - "371621": "惠民县", - "371622": "阳信县", - "371623": "无棣县", - "371625": "博兴县", - "371681": "邹平市", - "371702": "牡丹区", - "371703": "定陶区", - "371721": "曹县", - "371722": "单县", - "371723": "成武县", - "371724": "巨野县", - "371725": "郓城县", - "371726": "鄄城县", - "371728": "东明县", - "371771": "菏泽经济技术开发区", - "371772": "菏泽高新技术开发区", - "410102": "中原区", - "410103": "二七区", - "410104": "管城回族区", - "410105": "金水区", - "410106": "上街区", - "410108": "惠济区", - "410122": "中牟县", - "410171": "郑州经济技术开发区", - "410172": "郑州高新技术产业开发区", - "410173": "郑州航空港经济综合实验区", - "410181": "巩义市", - "410182": "荥阳市", - "410183": "新密市", - "410184": "新郑市", - "410185": "登封市", - "410190": "高新技术开发区", - "410191": "经济技术开发区", - "410202": "龙亭区", - "410203": "顺河回族区", - "410204": "鼓楼区", - "410205": "禹王台区", - "410212": "祥符区", - "410221": "杞县", - "410222": "通许县", - "410223": "尉氏县", - "410225": "兰考县", - "410302": "老城区", - "410303": "西工区", - "410304": "瀍河回族区", - "410305": "涧西区", - "410307": "偃师区", - "410308": "孟津区", - "410311": "洛龙区", - "410323": "新安县", - "410324": "栾川县", - "410325": "嵩县", - "410326": "汝阳县", - "410327": "宜阳县", - "410328": "洛宁县", - "410329": "伊川县", - "410402": "新华区", - "410403": "卫东区", - "410404": "石龙区", - "410411": "湛河区", - "410421": "宝丰县", - "410422": "叶县", - "410423": "鲁山县", - "410425": "郏县", - "410471": "平顶山高新技术产业开发区", - "410481": "舞钢市", - "410482": "汝州市", - "410502": "文峰区", - "410503": "北关区", - "410505": "殷都区", - "410506": "龙安区", - "410522": "安阳县", - "410523": "汤阴县", - "410526": "滑县", - "410527": "内黄县", - "410581": "林州市", - "410590": "开发区", - "410602": "鹤山区", - "410603": "山城区", - "410611": "淇滨区", - "410621": "浚县", - "410622": "淇县", - "410702": "红旗区", - "410703": "卫滨区", - "410704": "凤泉区", - "410711": "牧野区", - "410721": "新乡县", - "410724": "获嘉县", - "410725": "原阳县", - "410726": "延津县", - "410727": "封丘县", - "410771": "新乡高新技术产业开发区", - "410772": "新乡经济技术开发区", - "410781": "卫辉市", - "410782": "辉县市", - "410783": "长垣市", - "410802": "解放区", - "410803": "中站区", - "410804": "马村区", - "410811": "山阳区", - "410821": "修武县", - "410822": "博爱县", - "410823": "武陟县", - "410825": "温县", - "410871": "焦作城乡一体化示范区", - "410882": "沁阳市", - "410883": "孟州市", - "410902": "华龙区", - "410922": "清丰县", - "410923": "南乐县", - "410926": "范县", - "410927": "台前县", - "410928": "濮阳县", - "410971": "河南濮阳工业园区", - "411002": "魏都区", - "411003": "建安区", - "411024": "鄢陵县", - "411025": "襄城县", - "411071": "许昌经济技术开发区", - "411081": "禹州市", - "411082": "长葛市", - "411102": "源汇区", - "411103": "郾城区", - "411104": "召陵区", - "411121": "舞阳县", - "411122": "临颍县", - "411171": "漯河经济技术开发区", - "411202": "湖滨区", - "411203": "陕州区", - "411221": "渑池县", - "411224": "卢氏县", - "411271": "河南三门峡经济开发区", - "411281": "义马市", - "411282": "灵宝市", - "411302": "宛城区", - "411303": "卧龙区", - "411321": "南召县", - "411322": "方城县", - "411323": "西峡县", - "411324": "镇平县", - "411325": "内乡县", - "411326": "淅川县", - "411327": "社旗县", - "411328": "唐河县", - "411329": "新野县", - "411330": "桐柏县", - "411372": "南阳市城乡一体化示范区", - "411381": "邓州市", - "411402": "梁园区", - "411403": "睢阳区", - "411421": "民权县", - "411422": "睢县", - "411423": "宁陵县", - "411424": "柘城县", - "411425": "虞城县", - "411426": "夏邑县", - "411481": "永城市", - "411502": "浉河区", - "411503": "平桥区", - "411521": "罗山县", - "411522": "光山县", - "411523": "新县", - "411524": "商城县", - "411525": "固始县", - "411526": "潢川县", - "411527": "淮滨县", - "411528": "息县", - "411602": "川汇区", - "411603": "淮阳区", - "411621": "扶沟县", - "411622": "西华县", - "411623": "商水县", - "411624": "沈丘县", - "411625": "郸城县", - "411627": "太康县", - "411628": "鹿邑县", - "411671": "河南周口经济开发区", - "411681": "项城市", - "411690": "经济开发区", - "411702": "驿城区", - "411721": "西平县", - "411722": "上蔡县", - "411723": "平舆县", - "411724": "正阳县", - "411725": "确山县", - "411726": "泌阳县", - "411727": "汝南县", - "411728": "遂平县", - "411729": "新蔡县", - "419001": "济源市", - "420102": "江岸区", - "420103": "江汉区", - "420104": "硚口区", - "420105": "汉阳区", - "420106": "武昌区", - "420107": "青山区", - "420111": "洪山区", - "420112": "东西湖区", - "420113": "汉南区", - "420114": "蔡甸区", - "420115": "江夏区", - "420116": "黄陂区", - "420117": "新洲区", - "420202": "黄石港区", - "420203": "西塞山区", - "420204": "下陆区", - "420205": "铁山区", - "420222": "阳新县", - "420281": "大冶市", - "420302": "茅箭区", - "420303": "张湾区", - "420304": "郧阳区", - "420322": "郧西县", - "420323": "竹山县", - "420324": "竹溪县", - "420325": "房县", - "420381": "丹江口市", - "420502": "西陵区", - "420503": "伍家岗区", - "420504": "点军区", - "420505": "猇亭区", - "420506": "夷陵区", - "420525": "远安县", - "420526": "兴山县", - "420527": "秭归县", - "420528": "长阳土家族自治县", - "420529": "五峰土家族自治县", - "420581": "宜都市", - "420582": "当阳市", - "420583": "枝江市", - "420590": "经济开发区", - "420602": "襄城区", - "420606": "樊城区", - "420607": "襄州区", - "420624": "南漳县", - "420625": "谷城县", - "420626": "保康县", - "420682": "老河口市", - "420683": "枣阳市", - "420684": "宜城市", - "420702": "梁子湖区", - "420703": "华容区", - "420704": "鄂城区", - "420802": "东宝区", - "420804": "掇刀区", - "420822": "沙洋县", - "420881": "钟祥市", - "420882": "京山市", - "420902": "孝南区", - "420921": "孝昌县", - "420922": "大悟县", - "420923": "云梦县", - "420981": "应城市", - "420982": "安陆市", - "420984": "汉川市", - "421002": "沙市区", - "421003": "荆州区", - "421022": "公安县", - "421024": "江陵县", - "421081": "石首市", - "421083": "洪湖市", - "421087": "松滋市", - "421088": "监利市", - "421102": "黄州区", - "421121": "团风县", - "421122": "红安县", - "421123": "罗田县", - "421124": "英山县", - "421125": "浠水县", - "421126": "蕲春县", - "421127": "黄梅县", - "421171": "龙感湖管理区", - "421181": "麻城市", - "421182": "武穴市", - "421202": "咸安区", - "421221": "嘉鱼县", - "421222": "通城县", - "421223": "崇阳县", - "421224": "通山县", - "421281": "赤壁市", - "421303": "曾都区", - "421321": "随县", - "421381": "广水市", - "422801": "恩施市", - "422802": "利川市", - "422822": "建始县", - "422823": "巴东县", - "422825": "宣恩县", - "422826": "咸丰县", - "422827": "来凤县", - "422828": "鹤峰县", - "429004": "仙桃市", - "429005": "潜江市", - "429006": "天门市", - "429021": "神农架林区", - "430102": "芙蓉区", - "430103": "天心区", - "430104": "岳麓区", - "430105": "开福区", - "430111": "雨花区", - "430112": "望城区", - "430121": "长沙县", - "430181": "浏阳市", - "430182": "宁乡市", - "430202": "荷塘区", - "430203": "芦淞区", - "430204": "石峰区", - "430211": "天元区", - "430212": "渌口区", - "430223": "攸县", - "430224": "茶陵县", - "430225": "炎陵县", - "430271": "云龙示范区", - "430281": "醴陵市", - "430302": "雨湖区", - "430304": "岳塘区", - "430321": "湘潭县", - "430373": "湘潭九华示范区", - "430381": "湘乡市", - "430382": "韶山市", - "430405": "珠晖区", - "430406": "雁峰区", - "430407": "石鼓区", - "430408": "蒸湘区", - "430412": "南岳区", - "430421": "衡阳县", - "430422": "衡南县", - "430423": "衡山县", - "430424": "衡东县", - "430426": "祁东县", - "430481": "耒阳市", - "430482": "常宁市", - "430502": "双清区", - "430503": "大祥区", - "430511": "北塔区", - "430522": "新邵县", - "430523": "邵阳县", - "430524": "隆回县", - "430525": "洞口县", - "430527": "绥宁县", - "430528": "新宁县", - "430529": "城步苗族自治县", - "430581": "武冈市", - "430582": "邵东市", - "430602": "岳阳楼区", - "430603": "云溪区", - "430611": "君山区", - "430621": "岳阳县", - "430623": "华容县", - "430624": "湘阴县", - "430626": "平江县", - "430681": "汨罗市", - "430682": "临湘市", - "430702": "武陵区", - "430703": "鼎城区", - "430721": "安乡县", - "430722": "汉寿县", - "430723": "澧县", - "430724": "临澧县", - "430725": "桃源县", - "430726": "石门县", - "430781": "津市市", - "430802": "永定区", - "430811": "武陵源区", - "430821": "慈利县", - "430822": "桑植县", - "430902": "资阳区", - "430903": "赫山区", - "430921": "南县", - "430922": "桃江县", - "430923": "安化县", - "430971": "益阳市大通湖管理区", - "430981": "沅江市", - "431002": "北湖区", - "431003": "苏仙区", - "431021": "桂阳县", - "431022": "宜章县", - "431023": "永兴县", - "431024": "嘉禾县", - "431025": "临武县", - "431026": "汝城县", - "431027": "桂东县", - "431028": "安仁县", - "431081": "资兴市", - "431102": "零陵区", - "431103": "冷水滩区", - "431122": "东安县", - "431123": "双牌县", - "431124": "道县", - "431125": "江永县", - "431126": "宁远县", - "431127": "蓝山县", - "431128": "新田县", - "431129": "江华瑶族自治县", - "431181": "祁阳市", - "431202": "鹤城区", - "431221": "中方县", - "431222": "沅陵县", - "431223": "辰溪县", - "431224": "溆浦县", - "431225": "会同县", - "431226": "麻阳苗族自治县", - "431227": "新晃侗族自治县", - "431228": "芷江侗族自治县", - "431229": "靖州苗族侗族自治县", - "431230": "通道侗族自治县", - "431271": "怀化市洪江管理区", - "431281": "洪江市", - "431302": "娄星区", - "431321": "双峰县", - "431322": "新化县", - "431381": "冷水江市", - "431382": "涟源市", - "433101": "吉首市", - "433122": "泸溪县", - "433123": "凤凰县", - "433124": "花垣县", - "433125": "保靖县", - "433126": "古丈县", - "433127": "永顺县", - "433130": "龙山县", - "440103": "荔湾区", - "440104": "越秀区", - "440105": "海珠区", - "440106": "天河区", - "440111": "白云区", - "440112": "黄埔区", - "440113": "番禺区", - "440114": "花都区", - "440115": "南沙区", - "440117": "从化区", - "440118": "增城区", - "440203": "武江区", - "440204": "浈江区", - "440205": "曲江区", - "440222": "始兴县", - "440224": "仁化县", - "440229": "翁源县", - "440232": "乳源瑶族自治县", - "440233": "新丰县", - "440281": "乐昌市", - "440282": "南雄市", - "440303": "罗湖区", - "440304": "福田区", - "440305": "南山区", - "440306": "宝安区", - "440307": "龙岗区", - "440308": "盐田区", - "440309": "龙华区", - "440310": "坪山区", - "440311": "光明区", - "440402": "香洲区", - "440403": "斗门区", - "440404": "金湾区", - "440507": "龙湖区", - "440511": "金平区", - "440512": "濠江区", - "440513": "潮阳区", - "440514": "潮南区", - "440515": "澄海区", - "440523": "南澳县", - "440604": "禅城区", - "440605": "南海区", - "440606": "顺德区", - "440607": "三水区", - "440608": "高明区", - "440703": "蓬江区", - "440704": "江海区", - "440705": "新会区", - "440781": "台山市", - "440783": "开平市", - "440784": "鹤山市", - "440785": "恩平市", - "440802": "赤坎区", - "440803": "霞山区", - "440804": "坡头区", - "440811": "麻章区", - "440823": "遂溪县", - "440825": "徐闻县", - "440881": "廉江市", - "440882": "雷州市", - "440883": "吴川市", - "440890": "经济技术开发区", - "440902": "茂南区", - "440904": "电白区", - "440981": "高州市", - "440982": "化州市", - "440983": "信宜市", - "441202": "端州区", - "441203": "鼎湖区", - "441204": "高要区", - "441223": "广宁县", - "441224": "怀集县", - "441225": "封开县", - "441226": "德庆县", - "441284": "四会市", - "441302": "惠城区", - "441303": "惠阳区", - "441322": "博罗县", - "441323": "惠东县", - "441324": "龙门县", - "441402": "梅江区", - "441403": "梅县区", - "441422": "大埔县", - "441423": "丰顺县", - "441424": "五华县", - "441426": "平远县", - "441427": "蕉岭县", - "441481": "兴宁市", - "441502": "城区", - "441521": "海丰县", - "441523": "陆河县", - "441581": "陆丰市", - "441602": "源城区", - "441621": "紫金县", - "441622": "龙川县", - "441623": "连平县", - "441624": "和平县", - "441625": "东源县", - "441702": "江城区", - "441704": "阳东区", - "441721": "阳西县", - "441781": "阳春市", - "441802": "清城区", - "441803": "清新区", - "441821": "佛冈县", - "441823": "阳山县", - "441825": "连山壮族瑶族自治县", - "441826": "连南瑶族自治县", - "441881": "英德市", - "441882": "连州市", - "441901": "中堂镇", - "441903": "南城街道", - "441904": "长安镇", - "441905": "东坑镇", - "441906": "樟木头镇", - "441907": "莞城街道", - "441908": "石龙镇", - "441909": "桥头镇", - "441910": "万江街道", - "441911": "麻涌镇", - "441912": "虎门镇", - "441913": "谢岗镇", - "441914": "石碣镇", - "441915": "茶山镇", - "441916": "东城街道", - "441917": "洪梅镇", - "441918": "道滘镇", - "441919": "高埗镇", - "441920": "企石镇", - "441921": "凤岗镇", - "441922": "大岭山镇", - "441923": "松山湖", - "441924": "清溪镇", - "441925": "望牛墩镇", - "441926": "厚街镇", - "441927": "常平镇", - "441928": "寮步镇", - "441929": "石排镇", - "441930": "横沥镇", - "441931": "塘厦镇", - "441932": "黄江镇", - "441933": "大朗镇", - "441934": "东莞港", - "441935": "东莞生态园", - "441990": "沙田镇", - "442001": "南头镇", - "442002": "神湾镇", - "442003": "东凤镇", - "442004": "五桂山街道", - "442005": "黄圃镇", - "442006": "小榄镇", - "442007": "石岐街道", - "442008": "横栏镇", - "442009": "三角镇", - "442010": "三乡镇", - "442011": "港口镇", - "442012": "沙溪镇", - "442013": "板芙镇", - "442015": "东升镇", - "442016": "阜沙镇", - "442017": "民众镇", - "442018": "东区街道", - "442019": "火炬开发区街道办事处", - "442020": "西区街道", - "442021": "南区街道", - "442022": "古镇镇", - "442023": "坦洲镇", - "442024": "大涌镇", - "442025": "南朗镇", - "445102": "湘桥区", - "445103": "潮安区", - "445122": "饶平县", - "445202": "榕城区", - "445203": "揭东区", - "445222": "揭西县", - "445224": "惠来县", - "445281": "普宁市", - "445302": "云城区", - "445303": "云安区", - "445321": "新兴县", - "445322": "郁南县", - "445381": "罗定市", - "450102": "兴宁区", - "450103": "青秀区", - "450105": "江南区", - "450107": "西乡塘区", - "450108": "良庆区", - "450109": "邕宁区", - "450110": "武鸣区", - "450123": "隆安县", - "450124": "马山县", - "450125": "上林县", - "450126": "宾阳县", - "450181": "横州市", - "450202": "城中区", - "450203": "鱼峰区", - "450204": "柳南区", - "450205": "柳北区", - "450206": "柳江区", - "450222": "柳城县", - "450223": "鹿寨县", - "450224": "融安县", - "450225": "融水苗族自治县", - "450226": "三江侗族自治县", - "450302": "秀峰区", - "450303": "叠彩区", - "450304": "象山区", - "450305": "七星区", - "450311": "雁山区", - "450312": "临桂区", - "450321": "阳朔县", - "450323": "灵川县", - "450324": "全州县", - "450325": "兴安县", - "450326": "永福县", - "450327": "灌阳县", - "450328": "龙胜各族自治县", - "450329": "资源县", - "450330": "平乐县", - "450332": "恭城瑶族自治县", - "450381": "荔浦市", - "450403": "万秀区", - "450405": "长洲区", - "450406": "龙圩区", - "450421": "苍梧县", - "450422": "藤县", - "450423": "蒙山县", - "450481": "岑溪市", - "450502": "海城区", - "450503": "银海区", - "450512": "铁山港区", - "450521": "合浦县", - "450602": "港口区", - "450603": "防城区", - "450621": "上思县", - "450681": "东兴市", - "450702": "钦南区", - "450703": "钦北区", - "450721": "灵山县", - "450722": "浦北县", - "450802": "港北区", - "450803": "港南区", - "450804": "覃塘区", - "450821": "平南县", - "450881": "桂平市", - "450902": "玉州区", - "450903": "福绵区", - "450921": "容县", - "450922": "陆川县", - "450923": "博白县", - "450924": "兴业县", - "450981": "北流市", - "451002": "右江区", - "451003": "田阳区", - "451022": "田东县", - "451024": "德保县", - "451026": "那坡县", - "451027": "凌云县", - "451028": "乐业县", - "451029": "田林县", - "451030": "西林县", - "451031": "隆林各族自治县", - "451081": "靖西市", - "451082": "平果市", - "451102": "八步区", - "451103": "平桂区", - "451121": "昭平县", - "451122": "钟山县", - "451123": "富川瑶族自治县", - "451202": "金城江区", - "451203": "宜州区", - "451221": "南丹县", - "451222": "天峨县", - "451223": "凤山县", - "451224": "东兰县", - "451225": "罗城仫佬族自治县", - "451226": "环江毛南族自治县", - "451227": "巴马瑶族自治县", - "451228": "都安瑶族自治县", - "451229": "大化瑶族自治县", - "451302": "兴宾区", - "451321": "忻城县", - "451322": "象州县", - "451323": "武宣县", - "451324": "金秀瑶族自治县", - "451381": "合山市", - "451402": "江州区", - "451421": "扶绥县", - "451422": "宁明县", - "451423": "龙州县", - "451424": "大新县", - "451425": "天等县", - "451481": "凭祥市", - "460105": "秀英区", - "460106": "龙华区", - "460107": "琼山区", - "460108": "美兰区", - "460202": "海棠区", - "460203": "吉阳区", - "460204": "天涯区", - "460205": "崖州区", - "460321": "西沙区", - "460322": "南沙区", - "460401": "那大镇", - "460402": "和庆镇", - "460403": "南丰镇", - "460404": "大成镇", - "460405": "雅星镇", - "460406": "兰洋镇", - "460407": "光村镇", - "460408": "木棠镇", - "460409": "海头镇", - "460410": "峨蔓镇", - "460411": "王五镇", - "460412": "白马井镇", - "460413": "中和镇", - "460414": "排浦镇", - "460415": "东成镇", - "460416": "新州镇", - "460417": "洋浦经济开发区", - "460418": "华南热作学院", - "469001": "五指山市", - "469002": "琼海市", - "469005": "文昌市", - "469006": "万宁市", - "469007": "东方市", - "469021": "定安县", - "469022": "屯昌县", - "469023": "澄迈县", - "469024": "临高县", - "469025": "白沙黎族自治县", - "469026": "昌江黎族自治县", - "469027": "乐东黎族自治县", - "469028": "陵水黎族自治县", - "469029": "保亭黎族苗族自治县", - "469030": "琼中黎族苗族自治县", - "500101": "万州区", - "500102": "涪陵区", - "500103": "渝中区", - "500104": "大渡口区", - "500105": "江北区", - "500106": "沙坪坝区", - "500107": "九龙坡区", - "500108": "南岸区", - "500109": "北碚区", - "500110": "綦江区", - "500111": "大足区", - "500112": "渝北区", - "500113": "巴南区", - "500114": "黔江区", - "500115": "长寿区", - "500116": "江津区", - "500117": "合川区", - "500118": "永川区", - "500119": "南川区", - "500120": "璧山区", - "500151": "铜梁区", - "500152": "潼南区", - "500153": "荣昌区", - "500154": "开州区", - "500155": "梁平区", - "500156": "武隆区", - "500229": "城口县", - "500230": "丰都县", - "500231": "垫江县", - "500233": "忠县", - "500235": "云阳县", - "500236": "奉节县", - "500237": "巫山县", - "500238": "巫溪县", - "500240": "石柱土家族自治县", - "500241": "秀山土家族苗族自治县", - "500242": "酉阳土家族苗族自治县", - "500243": "彭水苗族土家族自治县", - "510104": "锦江区", - "510105": "青羊区", - "510106": "金牛区", - "510107": "武侯区", - "510108": "成华区", - "510112": "龙泉驿区", - "510113": "青白江区", - "510114": "新都区", - "510115": "温江区", - "510116": "双流区", - "510117": "郫都区", - "510118": "新津区", - "510121": "金堂县", - "510129": "大邑县", - "510131": "蒲江县", - "510181": "都江堰市", - "510182": "彭州市", - "510183": "邛崃市", - "510184": "崇州市", - "510185": "简阳市", - "510191": "高新区", - "510302": "自流井区", - "510303": "贡井区", - "510304": "大安区", - "510311": "沿滩区", - "510321": "荣县", - "510322": "富顺县", - "510402": "东区", - "510403": "西区", - "510411": "仁和区", - "510421": "米易县", - "510422": "盐边县", - "510502": "江阳区", - "510503": "纳溪区", - "510504": "龙马潭区", - "510521": "泸县", - "510522": "合江县", - "510524": "叙永县", - "510525": "古蔺县", - "510603": "旌阳区", - "510604": "罗江区", - "510623": "中江县", - "510681": "广汉市", - "510682": "什邡市", - "510683": "绵竹市", - "510703": "涪城区", - "510704": "游仙区", - "510705": "安州区", - "510722": "三台县", - "510723": "盐亭县", - "510725": "梓潼县", - "510726": "北川羌族自治县", - "510727": "平武县", - "510781": "江油市", - "510791": "高新区", - "510802": "利州区", - "510811": "昭化区", - "510812": "朝天区", - "510821": "旺苍县", - "510822": "青川县", - "510823": "剑阁县", - "510824": "苍溪县", - "510903": "船山区", - "510904": "安居区", - "510921": "蓬溪县", - "510923": "大英县", - "510981": "射洪市", - "511002": "市中区", - "511011": "东兴区", - "511024": "威远县", - "511025": "资中县", - "511083": "隆昌市", - "511102": "市中区", - "511111": "沙湾区", - "511112": "五通桥区", - "511113": "金口河区", - "511123": "犍为县", - "511124": "井研县", - "511126": "夹江县", - "511129": "沐川县", - "511132": "峨边彝族自治县", - "511133": "马边彝族自治县", - "511181": "峨眉山市", - "511302": "顺庆区", - "511303": "高坪区", - "511304": "嘉陵区", - "511321": "南部县", - "511322": "营山县", - "511323": "蓬安县", - "511324": "仪陇县", - "511325": "西充县", - "511381": "阆中市", - "511402": "东坡区", - "511403": "彭山区", - "511421": "仁寿县", - "511423": "洪雅县", - "511424": "丹棱县", - "511425": "青神县", - "511502": "翠屏区", - "511503": "南溪区", - "511504": "叙州区", - "511523": "江安县", - "511524": "长宁县", - "511525": "高县", - "511526": "珙县", - "511527": "筠连县", - "511528": "兴文县", - "511529": "屏山县", - "511602": "广安区", - "511603": "前锋区", - "511621": "岳池县", - "511622": "武胜县", - "511623": "邻水县", - "511681": "华蓥市", - "511702": "通川区", - "511703": "达川区", - "511722": "宣汉县", - "511723": "开江县", - "511724": "大竹县", - "511725": "渠县", - "511781": "万源市", - "511802": "雨城区", - "511803": "名山区", - "511822": "荥经县", - "511823": "汉源县", - "511824": "石棉县", - "511825": "天全县", - "511826": "芦山县", - "511827": "宝兴县", - "511902": "巴州区", - "511903": "恩阳区", - "511921": "通江县", - "511922": "南江县", - "511923": "平昌县", - "511971": "巴中经济开发区", - "512002": "雁江区", - "512021": "安岳县", - "512022": "乐至县", - "513201": "马尔康市", - "513221": "汶川县", - "513222": "理县", - "513223": "茂县", - "513224": "松潘县", - "513225": "九寨沟县", - "513226": "金川县", - "513227": "小金县", - "513228": "黑水县", - "513230": "壤塘县", - "513231": "阿坝县", - "513232": "若尔盖县", - "513233": "红原县", - "513301": "康定市", - "513322": "泸定县", - "513323": "丹巴县", - "513324": "九龙县", - "513325": "雅江县", - "513326": "道孚县", - "513327": "炉霍县", - "513328": "甘孜县", - "513329": "新龙县", - "513330": "德格县", - "513331": "白玉县", - "513332": "石渠县", - "513333": "色达县", - "513334": "理塘县", - "513335": "巴塘县", - "513336": "乡城县", - "513337": "稻城县", - "513338": "得荣县", - "513401": "西昌市", - "513402": "会理市", - "513422": "木里藏族自治县", - "513423": "盐源县", - "513424": "德昌县", - "513426": "会东县", - "513427": "宁南县", - "513428": "普格县", - "513429": "布拖县", - "513430": "金阳县", - "513431": "昭觉县", - "513432": "喜德县", - "513433": "冕宁县", - "513434": "越西县", - "513435": "甘洛县", - "513436": "美姑县", - "513437": "雷波县", - "520102": "南明区", - "520103": "云岩区", - "520111": "花溪区", - "520112": "乌当区", - "520113": "白云区", - "520115": "观山湖区", - "520121": "开阳县", - "520122": "息烽县", - "520123": "修文县", - "520181": "清镇市", - "520201": "钟山区", - "520203": "六枝特区", - "520204": "水城区", - "520281": "盘州市", - "520302": "红花岗区", - "520303": "汇川区", - "520304": "播州区", - "520322": "桐梓县", - "520323": "绥阳县", - "520324": "正安县", - "520325": "道真仡佬族苗族自治县", - "520326": "务川仡佬族苗族自治县", - "520327": "凤冈县", - "520328": "湄潭县", - "520329": "余庆县", - "520330": "习水县", - "520381": "赤水市", - "520382": "仁怀市", - "520402": "西秀区", - "520403": "平坝区", - "520422": "普定县", - "520423": "镇宁布依族苗族自治县", - "520424": "关岭布依族苗族自治县", - "520425": "紫云苗族布依族自治县", - "520502": "七星关区", - "520521": "大方县", - "520523": "金沙县", - "520524": "织金县", - "520525": "纳雍县", - "520526": "威宁彝族回族苗族自治县", - "520527": "赫章县", - "520581": "黔西市", - "520602": "碧江区", - "520603": "万山区", - "520621": "江口县", - "520622": "玉屏侗族自治县", - "520623": "石阡县", - "520624": "思南县", - "520625": "印江土家族苗族自治县", - "520626": "德江县", - "520627": "沿河土家族自治县", - "520628": "松桃苗族自治县", - "522301": "兴义市", - "522302": "兴仁市", - "522323": "普安县", - "522324": "晴隆县", - "522325": "贞丰县", - "522326": "望谟县", - "522327": "册亨县", - "522328": "安龙县", - "522601": "凯里市", - "522622": "黄平县", - "522623": "施秉县", - "522624": "三穗县", - "522625": "镇远县", - "522626": "岑巩县", - "522627": "天柱县", - "522628": "锦屏县", - "522629": "剑河县", - "522630": "台江县", - "522631": "黎平县", - "522632": "榕江县", - "522633": "从江县", - "522634": "雷山县", - "522635": "麻江县", - "522636": "丹寨县", - "522701": "都匀市", - "522702": "福泉市", - "522722": "荔波县", - "522723": "贵定县", - "522725": "瓮安县", - "522726": "独山县", - "522727": "平塘县", - "522728": "罗甸县", - "522729": "长顺县", - "522730": "龙里县", - "522731": "惠水县", - "522732": "三都水族自治县", - "530102": "五华区", - "530103": "盘龙区", - "530111": "官渡区", - "530112": "西山区", - "530113": "东川区", - "530114": "呈贡区", - "530115": "晋宁区", - "530124": "富民县", - "530125": "宜良县", - "530126": "石林彝族自治县", - "530127": "嵩明县", - "530128": "禄劝彝族苗族自治县", - "530129": "寻甸回族彝族自治县", - "530181": "安宁市", - "530302": "麒麟区", - "530303": "沾益区", - "530304": "马龙区", - "530322": "陆良县", - "530323": "师宗县", - "530324": "罗平县", - "530325": "富源县", - "530326": "会泽县", - "530381": "宣威市", - "530402": "红塔区", - "530403": "江川区", - "530423": "通海县", - "530424": "华宁县", - "530425": "易门县", - "530426": "峨山彝族自治县", - "530427": "新平彝族傣族自治县", - "530428": "元江哈尼族彝族傣族自治县", - "530481": "澄江市", - "530502": "隆阳区", - "530521": "施甸县", - "530523": "龙陵县", - "530524": "昌宁县", - "530581": "腾冲市", - "530602": "昭阳区", - "530621": "鲁甸县", - "530622": "巧家县", - "530623": "盐津县", - "530624": "大关县", - "530625": "永善县", - "530626": "绥江县", - "530627": "镇雄县", - "530628": "彝良县", - "530629": "威信县", - "530681": "水富市", - "530702": "古城区", - "530721": "玉龙纳西族自治县", - "530722": "永胜县", - "530723": "华坪县", - "530724": "宁蒗彝族自治县", - "530802": "思茅区", - "530821": "宁洱哈尼族彝族自治县", - "530822": "墨江哈尼族自治县", - "530823": "景东彝族自治县", - "530824": "景谷傣族彝族自治县", - "530825": "镇沅彝族哈尼族拉祜族自治县", - "530826": "江城哈尼族彝族自治县", - "530827": "孟连傣族拉祜族佤族自治县", - "530828": "澜沧拉祜族自治县", - "530829": "西盟佤族自治县", - "530902": "临翔区", - "530921": "凤庆县", - "530922": "云县", - "530923": "永德县", - "530924": "镇康县", - "530925": "双江拉祜族佤族布朗族傣族自治县", - "530926": "耿马傣族佤族自治县", - "530927": "沧源佤族自治县", - "532301": "楚雄市", - "532302": "禄丰市", - "532322": "双柏县", - "532323": "牟定县", - "532324": "南华县", - "532325": "姚安县", - "532326": "大姚县", - "532327": "永仁县", - "532328": "元谋县", - "532329": "武定县", - "532501": "个旧市", - "532502": "开远市", - "532503": "蒙自市", - "532504": "弥勒市", - "532523": "屏边苗族自治县", - "532524": "建水县", - "532525": "石屏县", - "532527": "泸西县", - "532528": "元阳县", - "532529": "红河县", - "532530": "金平苗族瑶族傣族自治县", - "532531": "绿春县", - "532532": "河口瑶族自治县", - "532601": "文山市", - "532622": "砚山县", - "532623": "西畴县", - "532624": "麻栗坡县", - "532625": "马关县", - "532626": "丘北县", - "532627": "广南县", - "532628": "富宁县", - "532801": "景洪市", - "532822": "勐海县", - "532823": "勐腊县", - "532901": "大理市", - "532922": "漾濞彝族自治县", - "532923": "祥云县", - "532924": "宾川县", - "532925": "弥渡县", - "532926": "南涧彝族自治县", - "532927": "巍山彝族回族自治县", - "532928": "永平县", - "532929": "云龙县", - "532930": "洱源县", - "532931": "剑川县", - "532932": "鹤庆县", - "533102": "瑞丽市", - "533103": "芒市", - "533122": "梁河县", - "533123": "盈江县", - "533124": "陇川县", - "533301": "泸水市", - "533323": "福贡县", - "533324": "贡山独龙族怒族自治县", - "533325": "兰坪白族普米族自治县", - "533401": "香格里拉市", - "533422": "德钦县", - "533423": "维西傈僳族自治县", - "540102": "城关区", - "540103": "堆龙德庆区", - "540104": "达孜区", - "540121": "林周县", - "540122": "当雄县", - "540123": "尼木县", - "540124": "曲水县", - "540127": "墨竹工卡县", - "540202": "桑珠孜区", - "540221": "南木林县", - "540222": "江孜县", - "540223": "定日县", - "540224": "萨迦县", - "540225": "拉孜县", - "540226": "昂仁县", - "540227": "谢通门县", - "540228": "白朗县", - "540229": "仁布县", - "540230": "康马县", - "540231": "定结县", - "540232": "仲巴县", - "540233": "亚东县", - "540234": "吉隆县", - "540235": "聂拉木县", - "540236": "萨嘎县", - "540237": "岗巴县", - "540302": "卡若区", - "540321": "江达县", - "540322": "贡觉县", - "540323": "类乌齐县", - "540324": "丁青县", - "540325": "察雅县", - "540326": "八宿县", - "540327": "左贡县", - "540328": "芒康县", - "540329": "洛隆县", - "540330": "边坝县", - "540402": "巴宜区", - "540421": "工布江达县", - "540423": "墨脱县", - "540424": "波密县", - "540425": "察隅县", - "540426": "朗县", - "540481": "米林市", - "540502": "乃东区", - "540521": "扎囊县", - "540522": "贡嘎县", - "540523": "桑日县", - "540524": "琼结县", - "540525": "曲松县", - "540526": "措美县", - "540527": "洛扎县", - "540528": "加查县", - "540529": "隆子县", - "540531": "浪卡子县", - "540581": "错那市", - "540602": "色尼区", - "540621": "嘉黎县", - "540622": "比如县", - "540623": "聂荣县", - "540624": "安多县", - "540625": "申扎县", - "540626": "索县", - "540627": "班戈县", - "540628": "巴青县", - "540629": "尼玛县", - "540630": "双湖县", - "542521": "普兰县", - "542522": "札达县", - "542523": "噶尔县", - "542524": "日土县", - "542525": "革吉县", - "542526": "改则县", - "542527": "措勤县", - "610102": "新城区", - "610103": "碑林区", - "610104": "莲湖区", - "610111": "灞桥区", - "610112": "未央区", - "610113": "雁塔区", - "610114": "阎良区", - "610115": "临潼区", - "610116": "长安区", - "610117": "高陵区", - "610118": "鄠邑区", - "610122": "蓝田县", - "610124": "周至县", - "610202": "王益区", - "610203": "印台区", - "610204": "耀州区", - "610222": "宜君县", - "610302": "渭滨区", - "610303": "金台区", - "610304": "陈仓区", - "610305": "凤翔区", - "610323": "岐山县", - "610324": "扶风县", - "610326": "眉县", - "610327": "陇县", - "610328": "千阳县", - "610329": "麟游县", - "610330": "凤县", - "610331": "太白县", - "610402": "秦都区", - "610403": "杨陵区", - "610404": "渭城区", - "610422": "三原县", - "610423": "泾阳县", - "610424": "乾县", - "610425": "礼泉县", - "610426": "永寿县", - "610428": "长武县", - "610429": "旬邑县", - "610430": "淳化县", - "610431": "武功县", - "610481": "兴平市", - "610482": "彬州市", - "610502": "临渭区", - "610503": "华州区", - "610522": "潼关县", - "610523": "大荔县", - "610524": "合阳县", - "610525": "澄城县", - "610526": "蒲城县", - "610527": "白水县", - "610528": "富平县", - "610581": "韩城市", - "610582": "华阴市", - "610602": "宝塔区", - "610603": "安塞区", - "610621": "延长县", - "610622": "延川县", - "610625": "志丹县", - "610626": "吴起县", - "610627": "甘泉县", - "610628": "富县", - "610629": "洛川县", - "610630": "宜川县", - "610631": "黄龙县", - "610632": "黄陵县", - "610681": "子长市", - "610702": "汉台区", - "610703": "南郑区", - "610722": "城固县", - "610723": "洋县", - "610724": "西乡县", - "610725": "勉县", - "610726": "宁强县", - "610727": "略阳县", - "610728": "镇巴县", - "610729": "留坝县", - "610730": "佛坪县", - "610802": "榆阳区", - "610803": "横山区", - "610822": "府谷县", - "610824": "靖边县", - "610825": "定边县", - "610826": "绥德县", - "610827": "米脂县", - "610828": "佳县", - "610829": "吴堡县", - "610830": "清涧县", - "610831": "子洲县", - "610881": "神木市", - "610902": "汉滨区", - "610921": "汉阴县", - "610922": "石泉县", - "610923": "宁陕县", - "610924": "紫阳县", - "610925": "岚皋县", - "610926": "平利县", - "610927": "镇坪县", - "610929": "白河县", - "610981": "旬阳市", - "611002": "商州区", - "611021": "洛南县", - "611022": "丹凤县", - "611023": "商南县", - "611024": "山阳县", - "611025": "镇安县", - "611026": "柞水县", - "620102": "城关区", - "620103": "七里河区", - "620104": "西固区", - "620105": "安宁区", - "620111": "红古区", - "620121": "永登县", - "620122": "皋兰县", - "620123": "榆中县", - "620171": "兰州新区", - "620201": "市辖区", - "620290": "雄关区", - "620291": "长城区", - "620292": "镜铁区", - "620293": "新城镇", - "620294": "峪泉镇", - "620295": "文殊镇", - "620302": "金川区", - "620321": "永昌县", - "620402": "白银区", - "620403": "平川区", - "620421": "靖远县", - "620422": "会宁县", - "620423": "景泰县", - "620502": "秦州区", - "620503": "麦积区", - "620521": "清水县", - "620522": "秦安县", - "620523": "甘谷县", - "620524": "武山县", - "620525": "张家川回族自治县", - "620602": "凉州区", - "620621": "民勤县", - "620622": "古浪县", - "620623": "天祝藏族自治县", - "620702": "甘州区", - "620721": "肃南裕固族自治县", - "620722": "民乐县", - "620723": "临泽县", - "620724": "高台县", - "620725": "山丹县", - "620802": "崆峒区", - "620821": "泾川县", - "620822": "灵台县", - "620823": "崇信县", - "620825": "庄浪县", - "620826": "静宁县", - "620881": "华亭市", - "620902": "肃州区", - "620921": "金塔县", - "620922": "瓜州县", - "620923": "肃北蒙古族自治县", - "620924": "阿克塞哈萨克族自治县", - "620981": "玉门市", - "620982": "敦煌市", - "621002": "西峰区", - "621021": "庆城县", - "621022": "环县", - "621023": "华池县", - "621024": "合水县", - "621025": "正宁县", - "621026": "宁县", - "621027": "镇原县", - "621102": "安定区", - "621121": "通渭县", - "621122": "陇西县", - "621123": "渭源县", - "621124": "临洮县", - "621125": "漳县", - "621126": "岷县", - "621202": "武都区", - "621221": "成县", - "621222": "文县", - "621223": "宕昌县", - "621224": "康县", - "621225": "西和县", - "621226": "礼县", - "621227": "徽县", - "621228": "两当县", - "622901": "临夏市", - "622921": "临夏县", - "622922": "康乐县", - "622923": "永靖县", - "622924": "广河县", - "622925": "和政县", - "622926": "东乡族自治县", - "622927": "积石山保安族东乡族撒拉族自治县", - "623001": "合作市", - "623021": "临潭县", - "623022": "卓尼县", - "623023": "舟曲县", - "623024": "迭部县", - "623025": "玛曲县", - "623026": "碌曲县", - "623027": "夏河县", - "630102": "城东区", - "630103": "城中区", - "630104": "城西区", - "630105": "城北区", - "630106": "湟中区", - "630121": "大通回族土族自治县", - "630123": "湟源县", - "630202": "乐都区", - "630203": "平安区", - "630222": "民和回族土族自治县", - "630223": "互助土族自治县", - "630224": "化隆回族自治县", - "630225": "循化撒拉族自治县", - "632221": "门源回族自治县", - "632222": "祁连县", - "632223": "海晏县", - "632224": "刚察县", - "632301": "同仁市", - "632322": "尖扎县", - "632323": "泽库县", - "632324": "河南蒙古族自治县", - "632521": "共和县", - "632522": "同德县", - "632523": "贵德县", - "632524": "兴海县", - "632525": "贵南县", - "632621": "玛沁县", - "632622": "班玛县", - "632623": "甘德县", - "632624": "达日县", - "632625": "久治县", - "632626": "玛多县", - "632701": "玉树市", - "632722": "杂多县", - "632723": "称多县", - "632724": "治多县", - "632725": "囊谦县", - "632726": "曲麻莱县", - "632801": "格尔木市", - "632802": "德令哈市", - "632803": "茫崖市", - "632821": "乌兰县", - "632822": "都兰县", - "632823": "天峻县", - "632857": "大柴旦行政委员会", - "640104": "兴庆区", - "640105": "西夏区", - "640106": "金凤区", - "640121": "永宁县", - "640122": "贺兰县", - "640181": "灵武市", - "640202": "大武口区", - "640205": "惠农区", - "640221": "平罗县", - "640302": "利通区", - "640303": "红寺堡区", - "640323": "盐池县", - "640324": "同心县", - "640381": "青铜峡市", - "640402": "原州区", - "640422": "西吉县", - "640423": "隆德县", - "640424": "泾源县", - "640425": "彭阳县", - "640502": "沙坡头区", - "640521": "中宁县", - "640522": "海原县", - "650102": "天山区", - "650103": "沙依巴克区", - "650104": "新市区", - "650105": "水磨沟区", - "650106": "头屯河区", - "650107": "达坂城区", - "650109": "米东区", - "650121": "乌鲁木齐县", - "650202": "独山子区", - "650203": "克拉玛依区", - "650204": "白碱滩区", - "650205": "乌尔禾区", - "650402": "高昌区", - "650421": "鄯善县", - "650422": "托克逊县", - "650502": "伊州区", - "650521": "巴里坤哈萨克自治县", - "650522": "伊吾县", - "652301": "昌吉市", - "652302": "阜康市", - "652323": "呼图壁县", - "652324": "玛纳斯县", - "652325": "奇台县", - "652327": "吉木萨尔县", - "652328": "木垒哈萨克自治县", - "652701": "博乐市", - "652702": "阿拉山口市", - "652722": "精河县", - "652723": "温泉县", - "652801": "库尔勒市", - "652822": "轮台县", - "652823": "尉犁县", - "652824": "若羌县", - "652825": "且末县", - "652826": "焉耆回族自治县", - "652827": "和静县", - "652828": "和硕县", - "652829": "博湖县", - "652901": "阿克苏市", - "652902": "库车市", - "652922": "温宿县", - "652924": "沙雅县", - "652925": "新和县", - "652926": "拜城县", - "652927": "乌什县", - "652928": "阿瓦提县", - "652929": "柯坪县", - "653001": "阿图什市", - "653022": "阿克陶县", - "653023": "阿合奇县", - "653024": "乌恰县", - "653101": "喀什市", - "653121": "疏附县", - "653122": "疏勒县", - "653123": "英吉沙县", - "653124": "泽普县", - "653125": "莎车县", - "653126": "叶城县", - "653127": "麦盖提县", - "653128": "岳普湖县", - "653129": "伽师县", - "653130": "巴楚县", - "653131": "塔什库尔干塔吉克自治县", - "653201": "和田市", - "653221": "和田县", - "653222": "墨玉县", - "653223": "皮山县", - "653224": "洛浦县", - "653225": "策勒县", - "653226": "于田县", - "653227": "民丰县", - "654002": "伊宁市", - "654003": "奎屯市", - "654004": "霍尔果斯市", - "654021": "伊宁县", - "654022": "察布查尔锡伯自治县", - "654023": "霍城县", - "654024": "巩留县", - "654025": "新源县", - "654026": "昭苏县", - "654027": "特克斯县", - "654028": "尼勒克县", - "654201": "塔城市", - "654202": "乌苏市", - "654203": "沙湾市", - "654221": "额敏县", - "654224": "托里县", - "654225": "裕民县", - "654226": "和布克赛尔蒙古自治县", - "654301": "阿勒泰市", - "654321": "布尔津县", - "654322": "富蕴县", - "654323": "福海县", - "654324": "哈巴河县", - "654325": "青河县", - "654326": "吉木乃县", - "659001": "石河子市", - "659002": "阿拉尔市", - "659003": "图木舒克市", - "659004": "五家渠市", - "659005": "北屯市", - "659006": "铁门关市", - "659007": "双河市", - "659008": "可克达拉市", - "659009": "昆玉市", - "659010": "胡杨河市", - "659011": "新星市", - "659012": "白杨市", - "710101": "中正区", - "710102": "大同区", - "710103": "中山区", - "710104": "松山区", - "710105": "大安区", - "710106": "万华区", - "710107": "信义区", - "710108": "士林区", - "710109": "北投区", - "710110": "内湖区", - "710111": "南港区", - "710112": "文山区", - "710199": "其它区", - "710201": "新兴区", - "710202": "前金区", - "710203": "芩雅区", - "710204": "盐埕区", - "710205": "鼓山区", - "710206": "旗津区", - "710207": "前镇区", - "710208": "三民区", - "710209": "左营区", - "710210": "楠梓区", - "710211": "小港区", - "710241": "苓雅区", - "710242": "仁武区", - "710243": "大社区", - "710244": "冈山区", - "710245": "路竹区", - "710246": "阿莲区", - "710247": "田寮区", - "710248": "燕巢区", - "710249": "桥头区", - "710250": "梓官区", - "710251": "弥陀区", - "710252": "永安区", - "710253": "湖内区", - "710254": "凤山区", - "710255": "大寮区", - "710256": "林园区", - "710257": "鸟松区", - "710258": "大树区", - "710259": "旗山区", - "710260": "美浓区", - "710261": "六龟区", - "710262": "内门区", - "710263": "杉林区", - "710264": "甲仙区", - "710265": "桃源区", - "710266": "那玛夏区", - "710267": "茂林区", - "710268": "茄萣区", - "710299": "其它区", - "710301": "中西区", - "710302": "东区", - "710303": "南区", - "710304": "北区", - "710305": "安平区", - "710306": "安南区", - "710339": "永康区", - "710340": "归仁区", - "710341": "新化区", - "710342": "左镇区", - "710343": "玉井区", - "710344": "楠西区", - "710345": "南化区", - "710346": "仁德区", - "710347": "关庙区", - "710348": "龙崎区", - "710349": "官田区", - "710350": "麻豆区", - "710351": "佳里区", - "710352": "西港区", - "710353": "七股区", - "710354": "将军区", - "710355": "学甲区", - "710356": "北门区", - "710357": "新营区", - "710358": "后壁区", - "710359": "白河区", - "710360": "东山区", - "710361": "六甲区", - "710362": "下营区", - "710363": "柳营区", - "710364": "盐水区", - "710365": "善化区", - "710366": "大内区", - "710367": "山上区", - "710368": "新市区", - "710369": "安定区", - "710399": "其它区", - "710401": "中区", - "710402": "东区", - "710403": "南区", - "710404": "西区", - "710405": "北区", - "710406": "北屯区", - "710407": "西屯区", - "710408": "南屯区", - "710431": "太平区", - "710432": "大里区", - "710433": "雾峰区", - "710434": "乌日区", - "710435": "丰原区", - "710436": "后里区", - "710437": "石冈区", - "710438": "东势区", - "710439": "和平区", - "710440": "新社区", - "710441": "潭子区", - "710442": "大雅区", - "710443": "神冈区", - "710444": "大肚区", - "710445": "沙鹿区", - "710446": "龙井区", - "710447": "梧栖区", - "710448": "清水区", - "710449": "大甲区", - "710450": "外埔区", - "710451": "大安区", - "710499": "其它区", - "710507": "金沙镇", - "710508": "金湖镇", - "710509": "金宁乡", - "710510": "金城镇", - "710511": "烈屿乡", - "710512": "乌坵乡", - "710614": "南投市", - "710615": "中寮乡", - "710616": "草屯镇", - "710617": "国姓乡", - "710618": "埔里镇", - "710619": "仁爱乡", - "710620": "名间乡", - "710621": "集集镇", - "710622": "水里乡", - "710623": "鱼池乡", - "710624": "信义乡", - "710625": "竹山镇", - "710626": "鹿谷乡", - "710701": "仁爱区", - "710702": "信义区", - "710703": "中正区", - "710704": "中山区", - "710705": "安乐区", - "710706": "暖暖区", - "710707": "七堵区", - "710799": "其它区", - "710801": "东区", - "710802": "北区", - "710803": "香山区", - "710899": "其它区", - "710901": "东区", - "710902": "西区", - "710999": "其它区", - "711130": "万里区", - "711132": "板桥区", - "711133": "汐止区", - "711134": "深坑区", - "711135": "石碇区", - "711136": "瑞芳区", - "711137": "平溪区", - "711138": "双溪区", - "711139": "贡寮区", - "711140": "新店区", - "711141": "坪林区", - "711142": "乌来区", - "711143": "永和区", - "711144": "中和区", - "711145": "土城区", - "711146": "三峡区", - "711147": "树林区", - "711148": "莺歌区", - "711149": "三重区", - "711150": "新庄区", - "711151": "泰山区", - "711152": "林口区", - "711153": "芦洲区", - "711154": "五股区", - "711155": "八里区", - "711156": "淡水区", - "711157": "三芝区", - "711158": "石门区", - "711287": "宜兰市", - "711288": "头城镇", - "711289": "礁溪乡", - "711290": "壮围乡", - "711291": "员山乡", - "711292": "罗东镇", - "711293": "三星乡", - "711294": "大同乡", - "711295": "五结乡", - "711296": "冬山乡", - "711297": "苏澳镇", - "711298": "南澳乡", - "711299": "钓鱼台", - "711387": "竹北市", - "711388": "湖口乡", - "711389": "新丰乡", - "711390": "新埔镇", - "711391": "关西镇", - "711392": "芎林乡", - "711393": "宝山乡", - "711394": "竹东镇", - "711395": "五峰乡", - "711396": "横山乡", - "711397": "尖石乡", - "711398": "北埔乡", - "711399": "峨眉乡", - "711414": "中坜区", - "711415": "平镇区", - "711417": "杨梅区", - "711418": "新屋区", - "711419": "观音区", - "711420": "桃园区", - "711421": "龟山区", - "711422": "八德区", - "711423": "大溪区", - "711425": "大园区", - "711426": "芦竹区", - "711487": "中坜市", - "711488": "平镇市", - "711489": "龙潭乡", - "711490": "杨梅市", - "711491": "新屋乡", - "711492": "观音乡", - "711493": "桃园市", - "711494": "龟山乡", - "711495": "八德市", - "711496": "大溪镇", - "711497": "复兴乡", - "711498": "大园乡", - "711499": "芦竹乡", - "711520": "头份市", - "711582": "竹南镇", - "711583": "头份镇", - "711584": "三湾乡", - "711585": "南庄乡", - "711586": "狮潭乡", - "711587": "后龙镇", - "711588": "通霄镇", - "711589": "苑里镇", - "711590": "苗栗市", - "711591": "造桥乡", - "711592": "头屋乡", - "711593": "公馆乡", - "711594": "大湖乡", - "711595": "泰安乡", - "711596": "铜锣乡", - "711597": "三义乡", - "711598": "西湖乡", - "711599": "卓兰镇", - "711736": "员林市", - "711774": "彰化市", - "711775": "芬园乡", - "711776": "花坛乡", - "711777": "秀水乡", - "711778": "鹿港镇", - "711779": "福兴乡", - "711780": "线西乡", - "711781": "和美镇", - "711782": "伸港乡", - "711783": "员林镇", - "711784": "社头乡", - "711785": "永靖乡", - "711786": "埔心乡", - "711787": "溪湖镇", - "711788": "大村乡", - "711789": "埔盐乡", - "711790": "田中镇", - "711791": "北斗镇", - "711792": "田尾乡", - "711793": "埤头乡", - "711794": "溪州乡", - "711795": "竹塘乡", - "711796": "二林镇", - "711797": "大城乡", - "711798": "芳苑乡", - "711799": "二水乡", - "711982": "番路乡", - "711983": "梅山乡", - "711984": "竹崎乡", - "711985": "阿里山乡", - "711986": "中埔乡", - "711987": "大埔乡", - "711988": "水上乡", - "711989": "鹿草乡", - "711990": "太保市", - "711991": "朴子市", - "711992": "东石乡", - "711993": "六脚乡", - "711994": "新港乡", - "711995": "民雄乡", - "711996": "大林镇", - "711997": "溪口乡", - "711998": "义竹乡", - "711999": "布袋镇", - "712180": "斗南镇", - "712181": "大埤乡", - "712182": "虎尾镇", - "712183": "土库镇", - "712184": "褒忠乡", - "712185": "东势乡", - "712186": "台西乡", - "712187": "仑背乡", - "712188": "麦寮乡", - "712189": "斗六市", - "712190": "林内乡", - "712191": "古坑乡", - "712192": "莿桐乡", - "712193": "西螺镇", - "712194": "二仑乡", - "712195": "北港镇", - "712196": "水林乡", - "712197": "口湖乡", - "712198": "四湖乡", - "712199": "元长乡", - "712451": "崁顶乡", - "712467": "屏东市", - "712468": "三地门乡", - "712469": "雾台乡", - "712470": "玛家乡", - "712471": "九如乡", - "712472": "里港乡", - "712473": "高树乡", - "712474": "盐埔乡", - "712475": "长治乡", - "712476": "麟洛乡", - "712477": "竹田乡", - "712478": "内埔乡", - "712479": "万丹乡", - "712480": "潮州镇", - "712481": "泰武乡", - "712482": "来义乡", - "712483": "万峦乡", - "712484": "莰顶乡", - "712485": "新埤乡", - "712486": "南州乡", - "712487": "林边乡", - "712488": "东港镇", - "712489": "琉球乡", - "712490": "佳冬乡", - "712491": "新园乡", - "712492": "枋寮乡", - "712493": "枋山乡", - "712494": "春日乡", - "712495": "狮子乡", - "712496": "车城乡", - "712497": "牡丹乡", - "712498": "恒春镇", - "712499": "满州乡", - "712584": "台东市", - "712585": "绿岛乡", - "712586": "兰屿乡", - "712587": "延平乡", - "712588": "卑南乡", - "712589": "鹿野乡", - "712590": "关山镇", - "712591": "海端乡", - "712592": "池上乡", - "712593": "东河乡", - "712594": "成功镇", - "712595": "长滨乡", - "712596": "金峰乡", - "712597": "大武乡", - "712598": "达仁乡", - "712599": "太麻里乡", - "712686": "花莲市", - "712687": "新城乡", - "712688": "太鲁阁", - "712689": "秀林乡", - "712690": "吉安乡", - "712691": "寿丰乡", - "712692": "凤林镇", - "712693": "光复乡", - "712694": "丰滨乡", - "712695": "瑞穗乡", - "712696": "万荣乡", - "712697": "玉里镇", - "712698": "卓溪乡", - "712699": "富里乡", - "712794": "马公市", - "712795": "西屿乡", - "712796": "望安乡", - "712797": "七美乡", - "712798": "白沙乡", - "712799": "湖西乡", - "712896": "南竿乡", - "712897": "北竿乡", - "712898": "东引乡", - "712899": "莒光乡", - "810101": "中西区", - "810102": "湾仔区", - "810103": "东区", - "810104": "南区", - "810201": "九龙城区", - "810202": "油尖旺区", - "810203": "深水埗区", - "810204": "黄大仙区", - "810205": "观塘区", - "810301": "北区", - "810302": "大埔区", - "810303": "沙田区", - "810304": "西贡区", - "810305": "元朗区", - "810306": "屯门区", - "810307": "荃湾区", - "810308": "葵青区", - "810309": "离岛区", - "820102": "花地玛堂区", - "820103": "花王堂区", - "820104": "望德堂区", - "820105": "大堂区", - "820106": "风顺堂区", - "820202": "嘉模堂区", - "820203": "路氹填海区", - "820204": "圣方济各堂区" - } -} \ No newline at end of file diff --git a/uni_modules/lime-shared/areaData/index.ts b/uni_modules/lime-shared/areaData/index.ts deleted file mode 100644 index 401f77f..0000000 --- a/uni_modules/lime-shared/areaData/index.ts +++ /dev/null @@ -1,71 +0,0 @@ -// @ts-nocheck -import _areaList from './city-china.json'; -export const areaList = _areaList -// #ifndef UNI-APP-X -type UTSJSONObject = Record -// #endif -// #ifdef UNI-APP-X -type Object = UTSJSONObject -// #endif -type AreaList = { - province_list : Map; - city_list : Map; - county_list : Map; -} -// type CascaderOption = { -// text : string; -// value : string; -// children ?: CascaderOption[]; -// }; - -const makeOption = ( - label : string, - value : string, - children ?: UTSJSONObject[], -) : UTSJSONObject => ({ - label, - value, - children, -}); - - - -export function useCascaderAreaData() : UTSJSONObject[] { - const city = areaList['city_list'] as UTSJSONObject - const county = areaList['county_list'] as UTSJSONObject - const province = areaList['province_list'] as UTSJSONObject - const provinceMap = new Map(); - Object.keys(province).forEach((code) => { - provinceMap.set(code.slice(0, 2), makeOption(`${province[code]}`, code, [])); - }); - - const cityMap = new Map(); - - Object.keys(city).forEach((code) => { - const option = makeOption(`${city[code]}`, code, []); - cityMap.set(code.slice(0, 4), option); - - const _province = provinceMap.get(code.slice(0, 2)); - if (_province != null) { - (_province['children'] as UTSJSONObject[]).push(option) - } - }); - - Object.keys(county).forEach((code) => { - const _city = cityMap.get(code.slice(0, 4)); - if (_city != null) { - (_city['children'] as UTSJSONObject[]).push(makeOption(`${county[code]}`, code, null)); - } - }); - - // #ifndef APP-ANDROID || APP-IOS - return Array.from(provinceMap.values()); - // #endif - // #ifdef APP-ANDROID || APP-IOS - const obj : UTSJSONObject[] = [] - provinceMap.forEach((value, code) => { - obj.push(value) - }) - return obj - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/arrayBufferToFile/index.ts b/uni_modules/lime-shared/arrayBufferToFile/index.ts deleted file mode 100644 index d40e0d0..0000000 --- a/uni_modules/lime-shared/arrayBufferToFile/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X && APP -// export * from './vue.ts' -export { arrayBufferToFile } from './vue' -// #endif - -// #ifdef UNI-APP-X && APP -// export * from './uvue.uts' -export { arrayBufferToFile } from './uvue' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/arrayBufferToFile/uvue.ts b/uni_modules/lime-shared/arrayBufferToFile/uvue.ts deleted file mode 100644 index 65c7b14..0000000 --- a/uni_modules/lime-shared/arrayBufferToFile/uvue.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-nocheck -// import {platform} from '../platform' -/** - * buffer转路径 - * @param {Object} buffer - */ -// @ts-nocheck -export function arrayBufferToFile(buffer: ArrayBuffer, name?: string, format?:string):Promise<(File|string)> { - console.error('[arrayBufferToFile] 当前环境不支持') -} \ No newline at end of file diff --git a/uni_modules/lime-shared/arrayBufferToFile/uvue.uts b/uni_modules/lime-shared/arrayBufferToFile/uvue.uts deleted file mode 100644 index 65c7b14..0000000 --- a/uni_modules/lime-shared/arrayBufferToFile/uvue.uts +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-nocheck -// import {platform} from '../platform' -/** - * buffer转路径 - * @param {Object} buffer - */ -// @ts-nocheck -export function arrayBufferToFile(buffer: ArrayBuffer, name?: string, format?:string):Promise<(File|string)> { - console.error('[arrayBufferToFile] 当前环境不支持') -} \ No newline at end of file diff --git a/uni_modules/lime-shared/arrayBufferToFile/vue.ts b/uni_modules/lime-shared/arrayBufferToFile/vue.ts deleted file mode 100644 index 9760b20..0000000 --- a/uni_modules/lime-shared/arrayBufferToFile/vue.ts +++ /dev/null @@ -1,63 +0,0 @@ -// @ts-nocheck -import {platform} from '../platform' -/** - * buffer转路径 - * @param {Object} buffer - */ -// @ts-nocheck -export function arrayBufferToFile(buffer: ArrayBuffer | Blob, name?: string, format?:string):Promise<(File|string)> { - return new Promise((resolve, reject) => { - // #ifdef MP - const fs = uni.getFileSystemManager() - //自定义文件名 - if (!name && !format) { - reject(new Error('ERROR_NAME_PARSE')) - } - const fileName = `${name || new Date().getTime()}.${format.replace(/(.+)?\//,'')}`; - let pre = platform() - const filePath = `${pre.env.USER_DATA_PATH}/${fileName}` - fs.writeFile({ - filePath, - data: buffer, - success() { - resolve(filePath) - }, - fail(err) { - console.error(err) - reject(err) - } - }) - // #endif - - // #ifdef H5 - const file = new File([buffer], name, { - type: format, - }); - resolve(file) - // #endif - - // #ifdef APP-PLUS - const bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now()) - const base64 = uni.arrayBufferToBase64(buffer) - bitmap.loadBase64Data(base64, () => { - if (!name && !format) { - reject(new Error('ERROR_NAME_PARSE')) - } - const fileNmae = `${name || new Date().getTime()}.${format.replace(/(.+)?\//,'')}`; - const filePath = `_doc/uniapp_temp/${fileNmae}` - bitmap.save(filePath, {}, - () => { - bitmap.clear() - resolve(filePath) - }, - (error) => { - bitmap.clear() - reject(error) - }) - }, (error) => { - bitmap.clear() - reject(error) - }) - // #endif - }) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/arrayEqual/index.ts b/uni_modules/lime-shared/arrayEqual/index.ts deleted file mode 100644 index 58d7788..0000000 --- a/uni_modules/lime-shared/arrayEqual/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -/** - * 精确比较两个数组是否相等(浅比较) - * @param arr1 数组1 - * @param arr2 数组2 - * @returns 是否相等 - */ -export function arrayEqual(arr1 : T[], arr2 : T[]) : boolean { - return ( - arr1.length == arr2.length && - arr1.every((val, i) : boolean => val == arr2[i]) - ) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/assignAtIndex/index.ts b/uni_modules/lime-shared/assignAtIndex/index.ts deleted file mode 100644 index 7de9b2b..0000000 --- a/uni_modules/lime-shared/assignAtIndex/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -// @ts-nocheck -/** - * 安全地在数组指定索引处赋值,兼容 Android 平台对稀疏数组的限制。 - * - * 行为说明: - * - 非 Android:等同于 arr[index] = value(可能产生稀疏数组) - * - Android:若 index >= length,则先用 undefined 填充至 index,再赋值(紧凑数组,无空槽) - * - * @param arr - 目标数组(会被修改) - * @param index - 非负整数索引 - * @param value - 要设置的值 - * @throws {Error} 如果 index 不是非负整数 - */ -export function assignAtIndex(arr : T[], index : number, value : T) : void { - - // 输入校验 - if (index < 0) { - throw new Error(`Index must be a non-negative integer, got ${index}`); - } - - // #ifndef APP-ANDROID - // 标准环境:直接赋值(允许稀疏数组) - arr[index] = value; - // #endif - - // #ifdef APP-ANDROID - // Android 环境:安全赋值,避免稀疏数组导致的异常 - if (index < arr.length) { - arr[index] = value; - } else { - // 手动扩展数组,中间填充 undefined - // 注意:使用 push(undefined) 而不是 arr[length++] = undefined, - // 因为某些 Android 引擎对直接 length 赋值也敏感 - while (arr.length <= index) { - arr.push(null as T); - } - - // arr.set(index, value) - arr[index] = value; - } - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/base64ToArrayBuffer/index.ts b/uni_modules/lime-shared/base64ToArrayBuffer/index.ts deleted file mode 100644 index f83b640..0000000 --- a/uni_modules/lime-shared/base64ToArrayBuffer/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -// 未完成 -export function base64ToArrayBuffer(base64 : string) { - const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || []; - if (!format) { - new Error('ERROR_BASE64SRC_PARSE') - } - if(uni.base64ToArrayBuffer) { - return uni.base64ToArrayBuffer(bodyData) - } else { - - } -} \ No newline at end of file diff --git a/uni_modules/lime-shared/base64ToPath/index.ts b/uni_modules/lime-shared/base64ToPath/index.ts deleted file mode 100644 index 2bd01df..0000000 --- a/uni_modules/lime-shared/base64ToPath/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X && APP -// export * from './vue.ts' -export { base64ToPath } from './vue' -// #endif - - -// #ifdef UNI-APP-X && APP -// export * from './uvue.uts' -export { base64ToPath } from './uvue' -// #endif diff --git a/uni_modules/lime-shared/base64ToPath/uvue.ts b/uni_modules/lime-shared/base64ToPath/uvue.ts deleted file mode 100644 index 364b494..0000000 --- a/uni_modules/lime-shared/base64ToPath/uvue.ts +++ /dev/null @@ -1,22 +0,0 @@ -// @ts-nocheck -import { processFile, type ProcessFileOptions } from '@/uni_modules/lime-file-utils' - -/** - * base64转路径 - * @param {Object} base64 - */ -export function base64ToPath(base64: string, filename: string | null = null):Promise { - return new Promise((resolve,reject) => { - processFile({ - type: 'toDataURL', - path: base64, - filename, - success(res: string){ - resolve(res) - }, - fail(err){ - reject(err) - } - } as ProcessFileOptions) - }) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/base64ToPath/uvue.uts b/uni_modules/lime-shared/base64ToPath/uvue.uts deleted file mode 100644 index 364b494..0000000 --- a/uni_modules/lime-shared/base64ToPath/uvue.uts +++ /dev/null @@ -1,22 +0,0 @@ -// @ts-nocheck -import { processFile, type ProcessFileOptions } from '@/uni_modules/lime-file-utils' - -/** - * base64转路径 - * @param {Object} base64 - */ -export function base64ToPath(base64: string, filename: string | null = null):Promise { - return new Promise((resolve,reject) => { - processFile({ - type: 'toDataURL', - path: base64, - filename, - success(res: string){ - resolve(res) - }, - fail(err){ - reject(err) - } - } as ProcessFileOptions) - }) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/base64ToPath/vue.ts b/uni_modules/lime-shared/base64ToPath/vue.ts deleted file mode 100644 index 735000f..0000000 --- a/uni_modules/lime-shared/base64ToPath/vue.ts +++ /dev/null @@ -1,75 +0,0 @@ -// @ts-nocheck -import {platform} from '../platform' -/** - * base64转路径 - * @param {Object} base64 - */ -export function base64ToPath(base64: string, filename?: string):Promise { - const [, format] = /^data:image\/(\w+);base64,/.exec(base64) || []; - return new Promise((resolve, reject) => { - // #ifdef MP - const fs = uni.getFileSystemManager() - //自定义文件名 - if (!filename && !format) { - reject(new Error('ERROR_BASE64SRC_PARSE')) - } - // const time = new Date().getTime(); - const name = filename || `${new Date().getTime()}.${format}`; - let pre = platform() - const filePath = `${pre.env.USER_DATA_PATH}/${name}` - fs.writeFile({ - filePath, - data: base64.split(',')[1], - encoding: 'base64', - success() { - resolve(filePath) - }, - fail(err) { - console.error(err) - reject(err) - } - }) - // #endif - - // #ifdef H5 - // mime类型 - let mimeString = base64.split(',')[0].split(':')[1].split(';')[0]; - //base64 解码 - let byteString = atob(base64.split(',')[1]); - //创建缓冲数组 - let arrayBuffer = new ArrayBuffer(byteString.length); - //创建视图 - let intArray = new Uint8Array(arrayBuffer); - for (let i = 0; i < byteString.length; i++) { - intArray[i] = byteString.charCodeAt(i); - } - resolve(URL.createObjectURL(new Blob([intArray], { - type: mimeString - }))) - // #endif - - // #ifdef APP-PLUS - const bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now()) - bitmap.loadBase64Data(base64, () => { - if (!filename && !format) { - reject(new Error('ERROR_BASE64SRC_PARSE')) - } - // const time = new Date().getTime(); - const name = filename || `${new Date().getTime()}.${format}`; - const filePath = `_doc/uniapp_temp/${name}` - bitmap.save(filePath, {}, - () => { - bitmap.clear() - resolve(filePath) - }, - (error) => { - bitmap.clear() - reject(error) - }) - }, (error) => { - bitmap.clear() - reject(error) - }) - // #endif - }) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/bem/index.ts b/uni_modules/lime-shared/bem/index.ts deleted file mode 100644 index f4451af..0000000 --- a/uni_modules/lime-shared/bem/index.ts +++ /dev/null @@ -1,289 +0,0 @@ -// @ts-nocheck -/** - * BEM 配置类型定义 - * @description 定义 BEM 命名规范中的命名空间和分隔符配置 - */ -export type BemConfig = { - /** 命名空间,用于所有 BEM 类名的前缀 */ - namespace : string - /** Block 和命名空间之间的分隔符 */ - blockSeparator : string - /** Element 和 Block 之间的分隔符 */ - elementSeparator : string - /** Modifier 和 Block/Element 之间的分隔符 */ - modifierSeparator : string -} - -/** - * 默认 BEM 配置 - * @description 使用 'l' 作为命名空间,'-' 作为 block 分隔符,'__' 作为 element 分隔符,'--' 作为 modifier 分隔符 - */ -const defaultBem : BemConfig = { - namespace: 'l', - blockSeparator: '-', - elementSeparator: '__', - modifierSeparator: '--', -} - -/** - * 条件类型,用于判断是否需要生成类名 - * @description 支持布尔值、数字、字符串和 null 类型 - */ -type IsType = boolean | number | string | null// | undefined - -/** - * BEM 类 - * @description 用于生成符合 BEM 命名规范的 CSS 类名 - * @example - * const bem = createBem('button') - * bem.b() // 'l-button' - * bem.e('text') // 'l-button__text' - * bem.m('primary') // 'l-button--primary' - * bem.em('text', 'small') // 'l-button__text--small' - */ -export class Bem { - /** 命名空间 */ - private namespace : string - /** Block 分隔符 */ - private blockSeparator : string - /** Element 分隔符 */ - private elementSeparator : string - /** Modifier 分隔符 */ - private modifierSeparator : string - /** 前缀,由命名空间和 block 组成 */ - private prefix : string - - /** - * 构造函数 - * @param config BEM 配置对象 - * @param block Block 名称,可以是字符串或数字 - */ - constructor( - config : BemConfig, - block : string, - ) { - this.namespace = config.namespace - this.blockSeparator = config.blockSeparator - this.elementSeparator = config.elementSeparator - this.modifierSeparator = config.modifierSeparator - this.prefix = this.namespace + this.blockSeparator + block - } - - /** - * 判断是否需要生成类名 - * @description 当 is 参数为 false、0 或空字符串时,返回 false,表示不需要生成类名;否则返回 true - * @param is 条件参数,默认为 true - * @returns 是否需要生成类名 - * @example - * shouldGenerate() // true - * shouldGenerate(true) // true - * shouldGenerate(false) // false - * shouldGenerate(0) // false - * shouldGenerate('') // false - */ - private shouldGenerate(is : IsType = true) : boolean { - return !(is == false || is == 0 || is == '') - } - - /** - * 生成 Block 类名 - * @description 返回当前 block 的完整类名 - * @returns Block 类名字符串 - * @example - * const bem = createBem('button') - * bem.b() // 'l-button' - */ - b() : string { - return this.prefix - } - - /** - * 生成 Element 类名 - * @description 生成 Block__Element 格式的类名,当 is 参数为 false、0 或空字符串时返回空字符串,当 element 为 null 时返回 Block 类名 - * @param element Element 名称,可以是字符串,为 null 时返回 Block 类名 - * @param is 条件参数,默认为 true,当为 false、0 或空字符串时不生成类名 - * @returns Element 类名字符串或空字符串 - * @example - * const bem = createBem('button') - * bem.e('text') // 'l-button__text' - * bem.e('text', true) // 'l-button__text' - * bem.e('text', false) // '' - * bem.e('text', 0) // '' - * bem.e(null) // 'l-button' - */ - e(element : string | null, is : IsType = true) : string { - if (!this.shouldGenerate(is)) { - return '' - } - if (element == null) { - return this.prefix - } - return this.prefix + this.elementSeparator + element - } - - /** - * 生成 Modifier 类名 - * @description 生成 Block--modifier 格式的类名,当 is 参数为 false、0 或空字符串时返回空字符串,当 modifier 为 null 时返回 Block 类名 - * @param modifier Modifier 名称,可以是字符串或数字,为 null 时返回 Block 类名 - * @param is 条件参数,默认为 true,当为 false、0 或空字符串时不生成类名 - * @returns Modifier 类名字符串或空字符串 - * @example - * const bem = createBem('button') - * bem.m('primary') // 'l-button--primary' - * bem.m('primary', true) // 'l-button--primary' - * bem.m('primary', false) // '' - * bem.m('primary', 0) // '' - * bem.m(null) // 'l-button' - */ - m(modifier : string | number | null, is : IsType = true) : string { - if (!this.shouldGenerate(is)) { - return '' - } - if (modifier == null || modifier == '') { - return this.prefix - } - return this.prefix + this.modifierSeparator + modifier - } - - /** - * 生成 Element-Modifier 类名 - * @description 生成 Block__Element--modifier 格式的类名,当 is 参数为 false、0 或空字符串时返回空字符串,当 modifier 为 null 时返回 Element 类名 - * @param element Element 名称,可以是字符串 - * @param modifier Modifier 名称,可以是字符串或数字,为 null 时返回 Element 类名 - * @param is 条件参数,默认为 true,当为 false、0 或空字符串时不生成类名 - * @returns Element-Modifier 类名字符串或空字符串 - * @example - * const bem = createBem('button') - * bem.em('text', 'small') // 'l-button__text--small' - * bem.em('text', 'small', true) // 'l-button__text--small' - * bem.em('text', 'small', false) // '' - * bem.em('text', 'small', 0) // '' - * bem.em('text', null) // 'l-button__text' - */ - em( - element : string, - modifier : string | number | null, - is : IsType = true, - ) : string { - if (!this.shouldGenerate(is)) { - return '' - } - if (modifier == null || modifier == '') { - return this.prefix + this.elementSeparator + element - } - return ( - this.prefix + this.elementSeparator + element + this.modifierSeparator + modifier - ) - } - - /** - * 生成变体 Modifier 类名 - * @description 生成 Block--modifier1-modifier2 格式的类名,当 is 参数为 false、0 或空字符串时返回空字符串 - * @param modifiers Modifier 名称数组,可以是字符串或数字 - * @param is 条件参数,默认为 true,当为 false、0 或空字符串时不生成类名 - * @returns Modifier 类名字符串或空字符串 - * @example - * const bem = createBem('button') - * bem.v(['active', 'primary']) // 'l-button--active-primary' - * bem.v(['active', 'primary'], true) // 'l-button--active-primary' - * bem.v(['active', 'primary'], false) // '' - */ - v(modifiers : Array, is : IsType = true) : string { - if (!this.shouldGenerate(is) || modifiers.length == 0) { - return '' - } - const joinedModifier = modifiers.join('-') - return this.prefix + this.modifierSeparator + joinedModifier - } - - /** - * 生成变体 Element-Modifier 类名 - * @description 生成 Block__Element--modifier1-modifier2 格式的类名,当 is 参数为 false、0 或空字符串时返回空字符串 - * @param element Element 名称,可以是字符串 - * @param modifiers Modifier 名称数组,可以是字符串或数字 - * @param is 条件参数,默认为 true,当为 false、0 或空字符串时不生成类名 - * @returns Element-Modifier 类名字符串或空字符串 - * @example - * const bem = createBem('button') - * bem.ev('text', ['active', 'small']) // 'l-button__text--active-small' - * bem.ev('text', ['active', 'small'], true) // 'l-button__text--active-small' - * bem.ev('text', ['active', 'small'], false) // '' - */ - ev( - element : string, - modifiers : Array, - is : IsType = true, - ) : string { - if (!this.shouldGenerate(is) || modifiers.length == 0) { - return '' - } - const joinedModifier = modifiers.join('-') - return ( - this.prefix + this.elementSeparator + element + this.modifierSeparator + joinedModifier - ) - } - - /** - * 生成完整的 BEM 类名(Block-Element-Modifier) - * @description 生成完整的 BEM 类名,支持 Block、Block__Element、Block--modifier、Block__Element--modifier 四种格式 - * @param block Block 名称,可以是字符串或数字 - * @param element Element 名称,可以是字符串,为 null 时不拼接 - * @param modifier Modifier 名称,可以是字符串或数字,为 null 时不拼接 - * @param is 条件参数,默认为 true,当为 false、0 或空字符串时不生成类名 - * @returns BEM 类名字符串或空字符串 - * @example - * const bem = createBem('button') - * bem.bem('button') // 'l-button' - * bem.bem('button', 'text') // 'l-button__text' - * bem.bem('button', null, 'primary') // 'l-button--primary' - * bem.bem('button', 'text', 'small') // 'l-button__text--small' - * bem.bem('button', 'text', 'small', false) // '' - */ - bem( - block : string, - element : string | null, - modifier : string | number | null, - is : boolean | number | string | null = true, - ) : string { - if (!this.shouldGenerate(is)) { - return '' - } - - let className = this.namespace + this.blockSeparator + block - if (element != null) { - className += this.elementSeparator + element - } - if (modifier != null) { - className += this.modifierSeparator + modifier - } - return className - } -} - -/** - * 创建 BEM 结构函数 - * @description 根据配置创建一个 BEM 类生成器函数 - * @param config BEM 配置对象 - * @returns 返回一个函数,该函数接收 block 名称并返回 Bem 实例 - * @example - * const createBem = createBemStruct({ namespace: 'l', blockSeparator: '-', elementSeparator: '__', modifierSeparator: '--' }) - * const bem = createBem('button') - * bem.b() // 'l-button' - */ -export function createBemStruct(config : BemConfig) : (block : string) => Bem { - return (block : string) => { - return new Bem(config, block) - } -} - -/** - * 使用默认配置创建 BEM 函数 - * @description 使用默认配置(namespace: 'l', blockSeparator: '-', elementSeparator: '__', modifierSeparator: '--')创建 BEM 类生成器 - * @example - * const bem = createBem('button') - * bem.b() // 'l-button' - * bem.e('text') // 'l-button__text' - * bem.m('primary') // 'l-button--primary' - * bem.em('text', 'small') // 'l-button__text--small' - */ -export const createBem = createBemStruct(defaultBem) \ No newline at end of file diff --git a/uni_modules/lime-shared/camelCase/index.ts b/uni_modules/lime-shared/camelCase/index.ts deleted file mode 100644 index c0efd7f..0000000 --- a/uni_modules/lime-shared/camelCase/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -// @ts-nocheck -/** - * 将字符串转换为 camelCase 或 PascalCase 风格的命名约定 - * @param str 要转换的字符串 - * @param isPascalCase 指示是否转换为 PascalCase 的布尔值,默认为 false - * @returns 转换后的字符串 - */ -export function camelCase(str: string, isPascalCase: boolean = false): string { - // 将字符串分割成单词数组 - let words: string[] = str.split(/[\s_-]+/); - - // 将数组中的每个单词首字母大写(除了第一个单词) - let camelCased: string[] = words.map((word, index):string => { - if (index == 0 && !isPascalCase) { - return word.toLowerCase(); // 第一个单词全小写 - } - return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); - }); - - // 将数组中的单词拼接成一个字符串 - return camelCased.join(''); -}; \ No newline at end of file diff --git a/uni_modules/lime-shared/canIUseCanvas2d/index.ts b/uni_modules/lime-shared/canIUseCanvas2d/index.ts deleted file mode 100644 index be5623a..0000000 --- a/uni_modules/lime-shared/canIUseCanvas2d/index.ts +++ /dev/null @@ -1,67 +0,0 @@ -// @ts-nocheck - -// #ifndef UNI-APP-X && APP - -// #ifdef MP-ALIPAY -interface My { - SDKVersion: string -} -declare var my: My -// #endif - -function compareVersion(v1:string, v2:string) { - let a1 = v1.split('.'); - let a2 = v2.split('.'); - const len = Math.max(a1.length, a2.length); - - while (a1.length < len) { - a1.push('0'); - } - while (a2.length < len) { - a2.push('0'); - } - - for (let i = 0; i < len; i++) { - const num1 = parseInt(a1[i], 10); - const num2 = parseInt(a2[i], 10); - - if (num1 > num2) { - return 1; - } - if (num1 < num2) { - return -1; - } - } - - return 0; -} - -function gte(version: string) { - let {SDKVersion} = uni.getSystemInfoSync(); - // #ifdef MP-ALIPAY - SDKVersion = my.SDKVersion - // #endif - return compareVersion(SDKVersion, version) >= 0; -} -// #endif - - -/** 环境是否支持canvas 2d */ -export function canIUseCanvas2d(): boolean { - // #ifdef MP-WEIXIN - return gte('2.9.0'); - // #endif - // #ifdef MP-ALIPAY - return gte('2.7.0'); - // #endif - // #ifdef MP-TOUTIAO - return gte('1.78.0'); - // #endif - // #ifdef UNI-APP-X && WEB || UNI-APP-X && APP - return true; - // #endif - // #ifndef MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO - return false - // #endif - -} diff --git a/uni_modules/lime-shared/capitalizedAmount/index.ts b/uni_modules/lime-shared/capitalizedAmount/index.ts deleted file mode 100644 index 317e0af..0000000 --- a/uni_modules/lime-shared/capitalizedAmount/index.ts +++ /dev/null @@ -1,111 +0,0 @@ -// @ts-nocheck -import { isString } from "../isString"; -import { isNumber } from "../isNumber"; -/** - * 将金额转换为中文大写形式 - * @param {number | string} amount - 需要转换的金额,可以是数字或字符串 - * @returns {string} 转换后的中文大写金额 - */ -export function capitalizedAmount(amount : number) : string -export function capitalizedAmount(amount : string) : string -export function capitalizedAmount(amount : any | null) : string { - try { - let _amountStr :string; - let _amountNum :number = 0; - // 如果输入是字符串,先将其转换为数字,并去除逗号 - if (typeof amount == 'string') { - _amountNum = parseFloat((amount as string).replace(/,/g, '')); - } - if(isNumber(amount)) { - _amountNum = amount as number - } - // 判断输入是否为有效的金额 || isNaN(amount) - if (amount == null) throw new Error('不是有效的金额!'); - - let result = ''; - - // 处理负数情况 - if (_amountNum < 0) { - result = '欠'; - _amountNum = Math.abs(_amountNum); - } - - // 金额不能超过千亿以上 - if (_amountNum >= 10e11) throw new Error('计算金额过大!'); - - // 保留两位小数并转换为字符串 - _amountStr = _amountNum.toFixed(2); - - // 定义数字、单位和小数单位的映射 - const digits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']; - const units = ['', '拾', '佰', '仟']; - const bigUnits = ['', '万', '亿']; - const decimalUnits = ['角', '分']; - - // 分离整数部分和小数部分 - const amountArray = _amountStr.split('.'); - let integerPart = amountArray[0]; // string| number[] - const decimalPart = amountArray[1]; - - // 处理整数部分 - if (integerPart != '0') { - let _integerPart = integerPart.split('').map((item):number => parseInt(item)); - - // 将整数部分按四位一级进行分组 - const levels = _integerPart.reverse().reduce((prev:string[][], item, index):string[][] => { - // const level = prev?.[0]?.length < 4 ? prev[0] : []; - const level = prev.length > 0 && prev[0].length < 4 ? prev[0]: [] - - const value = item == 0 ? digits[item] : digits[item] + units[index % 4]; - - level.unshift(value); - - if (level.length == 1) { - prev.unshift(level); - } else { - prev[0] = level; - } - - return prev; - }, [] as string[][]); - // 将分组后的整数部分转换为中文大写形式 - result += levels.reduce((prev, item, index):string => { - let _level = bigUnits[levels.length - index - 1]; - let _item = item.join('').replace(/(零)\1+/g, '$1'); - - if (_item == '零') { - _level = ''; - _item = ''; - } else if (_item.endsWith('零')) { - _item = _item.slice(0, _item.length - 1); - } - - return prev + _item + _level; - }, ''); - } else { - result += '零'; - } - - // 添加元 - result += '元'; - - // 处理小数部分 - if (decimalPart != '00') { - if (result == '零元') result = ''; - - for (let i = 0; i < decimalPart.length; i++) { - const digit = parseInt(decimalPart.charAt(i)); - - if (digit != 0) { - result += digits[digit] + decimalUnits[i]; - } - } - } else { - result += '整'; - } - - return result; - } catch (error : Error) { - return error.message; - } -}; \ No newline at end of file diff --git a/uni_modules/lime-shared/changelog.md b/uni_modules/lime-shared/changelog.md deleted file mode 100644 index 8bc96bd..0000000 --- a/uni_modules/lime-shared/changelog.md +++ /dev/null @@ -1,126 +0,0 @@ -## 2.0.4(2026-08-26) -- fix: 修复非蒸版缺少getClassStr -## 2.0.3(2026-08-03) -- fix: 恢复obj2css -## 2.0.2(2026-08-03) -- fix: 恢复旧版css2obj -## 2.0.1(2026-07-29) -- fix: 恢复useVModel -## 2.0.0(2026-07-21) -- refactor: 全面兼容 uni-app x 蒸汽模式(uvue/uts) -- feat: 新增 `useTransition`、`Timeline`、`Animation` 动画过渡能力 -- feat: 新增 `createCanvasContextAsync` 统一 Canvas 上下文创建 -- feat: 新增 `selectElement`、`findClosestElementWithStyle` DOM 查询工具 -- feat: 新增 `getDeviceInfo`、`getWindowInfo` 平台信息获取 -- feat: 新增 `obj2url`、`guid`、`uniqid`、`coalesce`、`merge` 等工具函数 -- feat: 新增 `isIP`、`isByteLength`、`isRegExp`、`isURL`、`isValidDomain` 等验证器 -- feat: 新增 `areaData` 中国省市区数据及级联选择器数据 -- feat: 新增 `Bem` 类与 `stringifyStyle`、`parseStyle`、`classNames` 样式工具 -- feat: 新增 `arrayEqual`、`findLastIndex`、`assignAtIndex`、`fillArray`、`toArray` 等数组工具 -- feat: 新增 `addSeparator`、`characterLimit`、`toBoolean` 等字符串/类型工具 -- refactor: `getRect` 重构为支持节点查询、视口滚动、滚动定位计算 -- refactor: `selectComponent`/`selectAllComponent` 支持 class/id/ref/component 多种选择器 -- docs: 文档按插件文档规范重构 -## 0.4.8(2026-03-05) -- feat: 更新uniappx vue的实现 -## 0.4.7(2025-12-27) -- feat: 增加`getWindowInfo` -## 0.4.6(2025-12-26) -- fix: 修复useVModel可选问题 -## 0.4.5(2025-12-10) -- feat: 增加useVModel -## 0.4.4(2025-12-07) -- fix: 修复csstoobj uniappx安卓正则问题 -## 0.4.3(2025-12-02) -- feat: 增加`arrayEqual`,`findLastIndex` -## 0.4.2(2025-09-26) -- feat: 增加`cssToObj` -## 0.4.1(2025-06-13) -- fix:测试hbx4.71更新 -## 0.4.0(2025-06-04) -- fix:测试hbx4.71更新 -## 0.3.9(2025-06-04) - - fix: 因hbx4.71更新导致mac用户下载的文件被重命名,故退回4.66 -## 0.3.8(2025-06-03) -- fix: 修复`while`在vue2报错的问题 -## 0.3.7(2025-05-21) -- fix: 修复`merge`在vue2报错的问题 -## 0.3.6(2025-05-17) -- fix: 修复`raf`导错目录的问题 -## 0.3.5(2025-05-16) -- feat: 增加`isIP` -- feat: 增加`merge` -- feat: 增加`isByteLength` -- feat: 增加`isRegExp` -## 0.3.4(2025-04-27) -- fix: 修复exif缺少isBase64的问题 -## 0.3.3(2025-04-14) -- fix: 修复4.61上的类型问题 -## 0.3.2(2025-04-14) -- fix: 修复4.61上的类型问题 -## 0.3.1(2025-03-28) -- fix: 修复getRect在nvue上的问题 -## 0.3.0(2025-02-27) -- fix: 修复部分函数无法在uniappx上运行的问题 -## 0.2.9(2025-02-19) -- chore: 更新文档 -## 0.2.8(2025-02-11) -- chore: 更新文档 -## 0.2.7(2025-01-17) -- fix: 针对canvas 平台判断优化 -## 0.2.6(2025-01-09) -- feat: 增加`areaData`中国省市区数据 -## 0.2.5(2025-01-07) -- fix: animation在app上类型问题 -## 0.2.4(2025-01-04) -- feat: getRect类型问题 -## 0.2.3(2025-01-01) -- chore: unitConvert使用uni.rpx2px -## 0.2.2(2024-12-11) -- chore: 动画使用`requestAnimationFrame` -## 0.2.1(2024-11-20) -- feat: 增加`characterLimit` -## 0.2.0(2024-11-14) -- fix: vue2的类型问题 -## 0.1.9(2024-11-14) -- feat: 增加`shuffle` -## 0.1.8(2024-10-08) -- fix: vue2 条件编译 // #ifdef APP-IOS || APP-ANDROID 会生效 -## 0.1.7(2024-09-23) -- fix: raf 类型跟随版本变更 -## 0.1.6(2024-07-24) -- fix: vue2 app ts需要明确的后缀,所有补全 -- chore: 减少依赖 -## 0.1.5(2024-07-21) -- feat: 删除 Hooks -- feat: 兼容uniappx -## 0.1.4(2023-09-05) -- feat: 增加 Hooks `useIntersectionObserver` -- feat: 增加 `floatAdd` -- feat: 因为本人插件兼容 vue2 需要使用 `composition-api`,故增加vue文件代码插件的条件编译 -## 0.1.3(2023-08-13) -- feat: 增加 `camelCase` -## 0.1.2(2023-07-17) -- feat: 增加 `getClassStr` -## 0.1.1(2023-07-06) -- feat: 增加 `isNumeric`, 区别于 `isNumber` -## 0.1.0(2023-06-30) -- fix: `clamp`忘记导出了 -## 0.0.9(2023-06-27) -- feat: 增加`arrayBufferToFile` -## 0.0.8(2023-06-19) -- feat: 增加`createAnimation`、`clamp` -## 0.0.7(2023-06-08) -- chore: 更新注释 -## 0.0.6(2023-06-08) -- chore: 增加`createImage`为`lime-watermark`和`lime-qrcode`提供依赖 -## 0.0.5(2023-06-03) -- chore: 更新注释 -## 0.0.4(2023-05-22) -- feat: 增加`range`,`exif`,`selectComponent` -## 0.0.3(2023-05-08) -- feat: 增加`fillZero`,`debounce`,`throttle`,`random` -## 0.0.2(2023-05-05) -- chore: 更新文档 -## 0.0.1(2023-05-05) -- 无 diff --git a/uni_modules/lime-shared/characterLimit/index.ts b/uni_modules/lime-shared/characterLimit/index.ts deleted file mode 100644 index 215de23..0000000 --- a/uni_modules/lime-shared/characterLimit/index.ts +++ /dev/null @@ -1,63 +0,0 @@ -// @ts-nocheck -/** - * 计算字符串字符的长度并可以截取字符串。 - * @param char 传入字符串(maxcharacter条件下,一个汉字表示两个字符) - * @param max 规定最大字符串长度 - * @returns 当没有传入maxCharacter/maxLength 时返回字符串字符长度,当传入maxCharacter/maxLength时返回截取之后的字符串和长度。 - */ -export type CharacterLengthResult = { - length : number; - characters : string; -} -// #ifdef APP-ANDROID -type ChartType = any -// #endif -// #ifndef APP-ANDROID -type ChartType = string | number -// #endif - -export function characterLimit(type : string, char : ChartType, max : number) : CharacterLengthResult { - const str = `${char}`; - - if (str.length == 0) { - return { - length: 0, - characters: '', - } as CharacterLengthResult - } - - if (type == 'maxcharacter') { - let len = 0; - for (let i = 0; i < str.length; i += 1) { - let currentStringLength : number// = 0; - const code = str.charCodeAt(i)! - if (code > 127 || code == 94) { - currentStringLength = 2; - } else { - currentStringLength = 1; - } - if (len + currentStringLength > max) { - return { - length: len, - characters: str.slice(0, i), - } as CharacterLengthResult - } - len += currentStringLength; - } - return { - length: len, - characters: str, - } as CharacterLengthResult - } else if (type == 'maxlength') { - const length = str.length > max ? max : str.length; - return { - length: length, - characters: str.slice(0, length), - } as CharacterLengthResult - } - - return { - length: str.length, - characters: str, - } as CharacterLengthResult -}; \ No newline at end of file diff --git a/uni_modules/lime-shared/clamp/index.ts b/uni_modules/lime-shared/clamp/index.ts deleted file mode 100644 index 0e16358..0000000 --- a/uni_modules/lime-shared/clamp/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// @ts-nocheck -/** - * 将一个值限制在指定的范围内 - * @param val 要限制的值 - * @param min 最小值 - * @param max 最大值 - * @returns 限制后的值 - */ -export function clamp(val: number, min: number, max: number): number { - return Math.max(min, Math.min(max, val)); -} - - -// console.log(clamp(5 ,0, 10)); // 输出: 5(在范围内,不做更改) -// console.log(clamp(-5 ,0, 10)); // 输出: 0(小于最小值,被限制为最小值) -// console.log(clamp(15 ,0, 10)); // 输出: 10(大于最大值,被限制为最大值) \ No newline at end of file diff --git a/uni_modules/lime-shared/classNames/index.ts b/uni_modules/lime-shared/classNames/index.ts deleted file mode 100644 index 931228d..0000000 --- a/uni_modules/lime-shared/classNames/index.ts +++ /dev/null @@ -1,96 +0,0 @@ -// @ts-nocheck -/** - * 类名属性类型 - * @description 支持 string、number、null、undefined、对象和数组类型 - */ -// #ifndef UNI-APP-X -type UTSJSONObject = Record -// #endif - -export type ClassProp = - | string - | number - | null - | undefined - | UTSJSONObject - | ClassProp[] - -/** - * 把各种类型的参数拼接成字符串类名,以便解决小程序不支持 classObject 的问题 - * @description 支持多种参数类型的类名拼接,包括字符串、数字、数组和对象 - * @param args 类名参数,可以是字符串、数字、null、undefined、对象或数组 - * @returns 拼接后的类名字符串 - * @example - * classNames('foo', 'bar') // 'foo bar' - * classNames('foo', { bar: true, baz: false }) // 'foo bar' - * classNames('foo', ['bar', 'baz']) // 'foo bar baz' - * classNames('foo', null, 'bar') // 'foo bar' - * classNames({ foo: true, bar: false, baz: true }) // 'foo baz' - */ -// export function classNames(args:ClassProp[]): string -export function classNames(...args : ClassProp[]) : string { - return classNamesArray(args) -} - -/** - * 处理数组的类名 - * @description 用于内部递归处理数组类型的类名 - * @param args 类名数组 - * @returns 拼接后的类名字符串 - */ -export function classNamesArray(args : ClassProp[]) : string { - const result : string[] = [] - - for (let i = 0; i < args.length; i++) { - const arg = args[i] - if (arg == null) { - continue - } - - if (typeof arg == 'string') { - const trimmed = (arg as string).trim() - if (trimmed != '') { - result.push(trimmed) - } - } else if (typeof arg == 'number') { - if (isFinite(arg as number)) { - result.push(`${arg}`) - } - } else if (Array.isArray(arg)) { - if ((arg as ClassProp[]).length > 0) { - const className = classNamesArray(arg) - if (className != '') { - result.push(className) - } - } - } else if (typeof arg == 'object') { - // #ifndef UNI-APP-X && APP - for (const key in arg) { - const value = arg[key] - if (value == true) { - result.push(key) - } - } - // #endif - // #ifdef UNI-APP-X && APP - // #ifdef VUE3-VAPOR - for (const key in arg) { - const value = arg[key] - if (value == true) { - result.push(key) - } - } - // #endif - // #ifndef VUE3-VAPOR - UTSJSONObject.assign({}, arg as UTSJSONObject).toMap().forEach((value, key) => { - if (value == true) { - result.push(key) - } - }) - // #endif - // #endif - } - } - - return result.join(' ') -} \ No newline at end of file diff --git a/uni_modules/lime-shared/cloneDeep/index.ts b/uni_modules/lime-shared/cloneDeep/index.ts deleted file mode 100644 index d7be272..0000000 --- a/uni_modules/lime-shared/cloneDeep/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-nocheck - -// #ifdef APP-ANDROID -export { cloneDeep } from './uvue' -// #endif - - -// #ifndef APP-ANDROID -export { cloneDeep } from './vue' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/cloneDeep/uvue.ts b/uni_modules/lime-shared/cloneDeep/uvue.ts deleted file mode 100644 index 49570f8..0000000 --- a/uni_modules/lime-shared/cloneDeep/uvue.ts +++ /dev/null @@ -1,44 +0,0 @@ -// @ts-nocheck -/** - * 深度克隆一个对象或数组 - * @param obj 要克隆的对象或数组 - * @returns 克隆后的对象或数组 - */ -export function cloneDeep(obj : any) : T { - if (obj instanceof Set) { - const set = new Set(); - obj.forEach((item : any) => { - set.add(item) - }) - return set as T; - } - if (obj instanceof Map) { - const map = new Map(); - obj.forEach((value : any, key : any) => { - map.set(key, value) - }) - return map as T; - } - - if (obj instanceof RegExp) { - return new RegExp(obj) as T; - } - - if (Array.isArray(obj)) { - return (obj as any[]).map((item : any):any => item) as T; - } - - if (obj instanceof Date) { - return new Date(obj.getTime()) as T; - } - - if (typeof obj == 'object') { - // #ifdef VUE3-VAPOR - return Object.assign({}, toRaw(obj))! - // #endif - // #ifndef VUE3-VAPOR - return UTSJSONObject.assign({}, toRaw(obj))! - // #endif - } - return obj as T -} \ No newline at end of file diff --git a/uni_modules/lime-shared/cloneDeep/uvue.uts b/uni_modules/lime-shared/cloneDeep/uvue.uts deleted file mode 100644 index 9ee42d9..0000000 --- a/uni_modules/lime-shared/cloneDeep/uvue.uts +++ /dev/null @@ -1,39 +0,0 @@ -// @ts-nocheck -/** - * 深度克隆一个对象或数组 - * @param obj 要克隆的对象或数组 - * @returns 克隆后的对象或数组 - */ -export function cloneDeep(obj : any) : T { - if (obj instanceof Set) { - const set = new Set(); - obj.forEach((item : any) => { - set.add(item) - }) - return set as T; - } - if (obj instanceof Map) { - const map = new Map(); - obj.forEach((value : any, key : any) => { - map.set(key, value) - }) - return map as T; - } - - if (obj instanceof RegExp) { - return new RegExp(obj) as T; - } - - if (Array.isArray(obj)) { - return (obj as any[]).map((item : any):any => item) as T; - } - - if (obj instanceof Date) { - return new Date(obj.getTime()) as T; - } - - if (typeof obj == 'object') { - return UTSJSONObject.assign({}, toRaw(obj))! - } - return obj as T -} \ No newline at end of file diff --git a/uni_modules/lime-shared/cloneDeep/vue.ts b/uni_modules/lime-shared/cloneDeep/vue.ts deleted file mode 100644 index ded334d..0000000 --- a/uni_modules/lime-shared/cloneDeep/vue.ts +++ /dev/null @@ -1,103 +0,0 @@ -// @ts-nocheck -/** - * 深度克隆一个对象或数组 - * @param obj 要克隆的对象或数组 - * @returns 克隆后的对象或数组 - */ -export function cloneDeep(obj: any): T { - // 如果传入的对象为空,返回空 - if (obj === null) { - return null as unknown as T; - } - - // 如果传入的对象是 Set 类型,则将其转换为数组,并通过新的 Set 构造函数创建一个新的 Set 对象 - if (obj instanceof Set) { - return new Set([...obj]) as unknown as T; - } - - // 如果传入的对象是 Map 类型,则将其转换为数组,并通过新的 Map 构造函数创建一个新的 Map 对象 - if (obj instanceof Map) { - return new Map([...obj]) as unknown as T; - } - - // 如果传入的对象是 WeakMap 类型,则直接用传入的 WeakMap 对象进行赋值 - if (obj instanceof WeakMap) { - let weakMap = new WeakMap(); - weakMap = obj; - return weakMap as unknown as T; - } - - // 如果传入的对象是 WeakSet 类型,则直接用传入的 WeakSet 对象进行赋值 - if (obj instanceof WeakSet) { - let weakSet = new WeakSet(); - weakSet = obj; - return weakSet as unknown as T; - } - - // 如果传入的对象是 RegExp 类型,则通过新的 RegExp 构造函数创建一个新的 RegExp 对象 - if (obj instanceof RegExp) { - return new RegExp(obj) as unknown as T; - } - - // 如果传入的对象是 undefined 类型,则返回 undefined - if (typeof obj === 'undefined') { - return undefined as unknown as T; - } - - // 如果传入的对象是数组,则递归调用 cloneDeep 函数对数组中的每个元素进行克隆 - if (Array.isArray(obj)) { - return obj.map(cloneDeep) as unknown as T; - } - - // 如果传入的对象是 Date 类型,则通过新的 Date 构造函数创建一个新的 Date 对象 - if (obj instanceof Date) { - return new Date(obj.getTime()) as unknown as T; - } - - // 如果传入的对象是普通对象,则使用递归调用 cloneDeep 函数对对象的每个属性进行克隆 - if (typeof obj === 'object') { - const newObj: any = {}; - for (const [key, value] of Object.entries(obj)) { - newObj[key] = cloneDeep(value); - } - const symbolKeys = Object.getOwnPropertySymbols(obj); - for (const key of symbolKeys) { - newObj[key] = cloneDeep(obj[key]); - } - return newObj; - } - - // 如果传入的对象是基本数据类型(如字符串、数字等),则直接返回 - return obj; -} - -// 示例使用 - -// // 克隆一个对象 -// const obj = { name: 'John', age: 30 }; -// const clonedObj = cloneDeep(obj); - -// console.log(clonedObj); // 输出: { name: 'John', age: 30 } -// console.log(clonedObj === obj); // 输出: false (副本与原对象是独立的) - -// // 克隆一个数组 -// const arr = [1, 2, 3]; -// const clonedArr = cloneDeep(arr); - -// console.log(clonedArr); // 输出: [1, 2, 3] -// console.log(clonedArr === arr); // 输出: false (副本与原数组是独立的) - -// // 克隆一个包含嵌套对象的对象 -// const person = { -// name: 'Alice', -// age: 25, -// address: { -// city: 'New York', -// country: 'USA', -// }, -// }; -// const clonedPerson = cloneDeep(person); - -// console.log(clonedPerson); // 输出: { name: 'Alice', age: 25, address: { city: 'New York', country: 'USA' } } -// console.log(clonedPerson === person); // 输出: false (副本与原对象是独立的) -// console.log(clonedPerson.address === person.address); // 输出: false (嵌套对象的副本也是独立的) \ No newline at end of file diff --git a/uni_modules/lime-shared/closest/index.ts b/uni_modules/lime-shared/closest/index.ts deleted file mode 100644 index e6e79c2..0000000 --- a/uni_modules/lime-shared/closest/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -// @ts-nocheck - -/** - * 在给定数组中找到最接近目标数字的元素。 - * @param arr 要搜索的数字数组。 - * @param target 目标数字。 - * @returns 最接近目标数字的数组元素。 - */ -export function closest(arr: number[], target: number):number { - return arr.reduce((pre: number, cur: number):number => - Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur - ); -} - -// 示例 -// // 定义一个数字数组 -// const numbers = [1, 3, 5, 7, 9]; - -// // 在数组中找到最接近目标数字 6 的元素 -// const closestNumber = closest(numbers, 6); - -// console.log(closestNumber); // 输出结果: 5 \ No newline at end of file diff --git a/uni_modules/lime-shared/coalesce/index.ts b/uni_modules/lime-shared/coalesce/index.ts deleted file mode 100644 index bfaa1a6..0000000 --- a/uni_modules/lime-shared/coalesce/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// @ts-nocheck -/** - * 返回第一个非空值。 - * - 跳过 null、undefined - * - 对字符串类型,额外跳过空字符串 '' - * - 保留 0、false 等类型合法值 - */ -// #ifdef UNI-APP-X && APP -export function coalesce(...values : (any | null)[]) : T | null { - for (const value of values) { - if (value == null) continue; - if (typeof value == 'string' && value == '') continue; - return value as T; - } - return null; -} -// #endif -// #ifndef UNI-APP-X && APP -export function coalesce(...values : (T | null | undefined)[]) : T | null { - for (const value of values) { - if (value == null || value === undefined) continue; - if (typeof value === 'string' && value === '') continue; - return value as T; - } - return null; -} -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/components/lime-shared/lime-shared.vue b/uni_modules/lime-shared/components/lime-shared/lime-shared.vue deleted file mode 100644 index edbf6e8..0000000 --- a/uni_modules/lime-shared/components/lime-shared/lime-shared.vue +++ /dev/null @@ -1,407 +0,0 @@ - - - - - \ No newline at end of file diff --git a/uni_modules/lime-shared/computed/index.ts b/uni_modules/lime-shared/computed/index.ts deleted file mode 100644 index 7b31651..0000000 --- a/uni_modules/lime-shared/computed/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// @ts-nocheck -// #ifndef VUE2 && APP -export { computed } from '../vue'; -// #endif - -// #ifdef VUE2 && APP -import { watchEffect, onScopeDispose, ref } from '../vue'; - -export function computed(getter) { - const result = ref(); - watchEffect(() => { - result.value = getter(); - }); - return result; -} -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/createAnimation/index.ts b/uni_modules/lime-shared/createAnimation/index.ts deleted file mode 100644 index db81f5c..0000000 --- a/uni_modules/lime-shared/createAnimation/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -export * from './type' -// export * from './vue.ts' -export { createAnimation } from './vue' -// #endif - -// #ifdef UNI-APP-X -// export * from './uvue' -export { createAnimation } from './uvue' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/createAnimation/type.ts b/uni_modules/lime-shared/createAnimation/type.ts deleted file mode 100644 index 0f8ad34..0000000 --- a/uni_modules/lime-shared/createAnimation/type.ts +++ /dev/null @@ -1,25 +0,0 @@ -export type CreateAnimationOptions = { - /** - * 动画持续时间,单位ms - */ - duration ?: number; - /** - * 定义动画的效果 - * - linear: 动画从头到尾的速度是相同的 - * - ease: 动画以低速开始,然后加快,在结束前变慢 - * - ease-in: 动画以低速开始 - * - ease-in-out: 动画以低速开始和结束 - * - ease-out: 动画以低速结束 - * - step-start: 动画第一帧就跳至结束状态直到结束 - * - step-end: 动画一直保持开始状态,最后一帧跳到结束状态 - */ - timingFunction ?: string //'linear' | 'ease' | 'ease-in' | 'ease-in-out' | 'ease-out' | 'step-start' | 'step-end'; - /** - * 动画延迟时间,单位 ms - */ - delay ?: number; - /** - * 设置transform-origin - */ - transformOrigin ?: string; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/createAnimation/uvue.ts b/uni_modules/lime-shared/createAnimation/uvue.ts deleted file mode 100644 index 96d8263..0000000 --- a/uni_modules/lime-shared/createAnimation/uvue.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-nocheck -// export * from '@/uni_modules/lime-animateIt' -export function createAnimation() { - console.error('当前环境不支持,请使用:lime-animateIt') -} \ No newline at end of file diff --git a/uni_modules/lime-shared/createAnimation/uvue.uts b/uni_modules/lime-shared/createAnimation/uvue.uts deleted file mode 100644 index 96d8263..0000000 --- a/uni_modules/lime-shared/createAnimation/uvue.uts +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-nocheck -// export * from '@/uni_modules/lime-animateIt' -export function createAnimation() { - console.error('当前环境不支持,请使用:lime-animateIt') -} \ No newline at end of file diff --git a/uni_modules/lime-shared/createAnimation/vue.ts b/uni_modules/lime-shared/createAnimation/vue.ts deleted file mode 100644 index 6934f27..0000000 --- a/uni_modules/lime-shared/createAnimation/vue.ts +++ /dev/null @@ -1,148 +0,0 @@ -// @ts-nocheck -// nvue 需要在节点上设置ref或在export里传入 -// const animation = createAnimation({ -// ref: this.$refs['xxx'], -// duration: 0, -// timingFunction: 'linear' -// }) -// animation.opacity(1).translate(x, y).step({duration}) -// animation.export(ref) - -// 抹平nvue 与 uni.createAnimation的使用差距 -// 但是nvue动画太慢 - - - -import { type CreateAnimationOptions } from './type' -// #ifdef APP-NVUE -const nvueAnimation = uni.requireNativePlugin('animation') - -type AnimationTypes = 'matrix' | 'matrix3d' | 'rotate' | 'rotate3d' | 'rotateX' | 'rotateY' | 'rotateZ' | 'scale' | 'scale3d' | 'scaleX' | 'scaleY' | 'scaleZ' | 'skew' | 'skewX' | 'skewY' | 'translate' | 'translate3d' | 'translateX' | 'translateY' | 'translateZ' - | 'opacity' | 'backgroundColor' | 'width' | 'height' | 'left' | 'right' | 'top' | 'bottom' - -interface Styles { - [key : string] : any -} - -interface StepConfig { - duration?: number - timingFunction?: string - delay?: number - needLayout?: boolean - transformOrigin?: string -} -interface StepAnimate { - styles?: Styles - config?: StepConfig -} -interface StepAnimates { - [key: number]: StepAnimate -} -// export interface CreateAnimationOptions extends UniApp.CreateAnimationOptions { -// ref?: string -// } - -type Callback = (time: number) => void -const animateTypes1 : AnimationTypes[] = ['matrix', 'matrix3d', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scale3d', - 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'translate', 'translate3d', 'translateX', 'translateY', - 'translateZ' -] -const animateTypes2 : AnimationTypes[] = ['opacity', 'backgroundColor'] -const animateTypes3 : AnimationTypes[] = ['width', 'height', 'left', 'right', 'top', 'bottom'] - -class LimeAnimation { - ref : any - context : any - options : UniApp.CreateAnimationOptions - // stack : any[] = [] - next : number = 0 - currentStepAnimates : StepAnimates = {} - duration : number = 0 - constructor(options : CreateAnimationOptions) { - const {ref} = options - this.ref = ref - this.options = options - } - addAnimate(type : AnimationTypes, args: (string | number)[]) { - let aniObj = this.currentStepAnimates[this.next] - let stepAnimate:StepAnimate = {} - if (!aniObj) { - stepAnimate = {styles: {}, config: {}} - } else { - stepAnimate = aniObj - } - - if (animateTypes1.includes(type)) { - if (!stepAnimate.styles.transform) { - stepAnimate.styles.transform = '' - } - let unit = '' - if (type === 'rotate') { - unit = 'deg' - } - stepAnimate.styles.transform += `${type}(${args.map((v: number) => v + unit).join(',')}) ` - } else { - stepAnimate.styles[type] = `${args.join(',')}` - } - this.currentStepAnimates[this.next] = stepAnimate - } - animateRun(styles: Styles = {}, config:StepConfig = {}, ref: any) { - const el = ref || this.ref - if (!el) return - return new Promise((resolve) => { - const time = +new Date() - nvueAnimation.transition(el, { - styles, - ...config - }, () => { - resolve(+new Date() - time) - }) - }) - } - nextAnimate(animates: StepAnimates, step: number = 0, ref: any, cb: Callback) { - let obj = animates[step] - if (obj) { - let { styles, config } = obj - // this.duration += config.duration - this.animateRun(styles, config, ref).then((time: number) => { - step += 1 - this.duration += time - this.nextAnimate(animates, step, ref, cb) - }) - } else { - this.currentStepAnimates = {} - cb && cb(this.duration) - } - } - step(config:StepConfig = {}) { - this.currentStepAnimates[this.next].config = Object.assign({}, this.options, config) - this.currentStepAnimates[this.next].styles.transformOrigin = this.currentStepAnimates[this.next].config.transformOrigin - this.next++ - return this - } - export(ref: any, cb?: Callback) { - ref = ref || this.ref - if(!ref) return - this.duration = 0 - this.next = 0 - this.nextAnimate(this.currentStepAnimates, 0, ref, cb) - return null - } -} - - -animateTypes1.concat(animateTypes2, animateTypes3).forEach(type => { - LimeAnimation.prototype[type] = function(...args: (string | number)[]) { - this.addAnimate(type, args) - return this - } -}) -// #endif -export function createAnimation(options : CreateAnimationOptions) { - // #ifndef APP-NVUE - return uni.createAnimation({ ...options }) - // #endif - // #ifdef APP-NVUE - return new LimeAnimation(options) - // #endif -} diff --git a/uni_modules/lime-shared/createCanvas/index.ts b/uni_modules/lime-shared/createCanvas/index.ts deleted file mode 100644 index 49c3242..0000000 --- a/uni_modules/lime-shared/createCanvas/index.ts +++ /dev/null @@ -1,72 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X && APP -import type { ComponentInternalInstance } from '@/uni_modules/lime-shared/vue' -import { getRect } from '@/uni_modules/lime-shared/getRect' -import { canIUseCanvas2d } from '@/uni_modules/lime-shared/canIUseCanvas2d' -export const isCanvas2d = canIUseCanvas2d() -// #endif - - -export function createCanvas(canvasId : string, component : ComponentInternalInstance) { - // #ifdef UNI-APP-X - uni.createCanvasContextAsync({ - canvasId, - component, - success(context : CanvasContext) { - - }, - fail(error : UniError) { - - } - }) - // #endif - // #ifndef UNI-APP-X - const isCanvas2d = canIUseCanvas2d() - getRect('#' + canvasId, context, isCanvas2d).then(res => { - if (res.node) { - res.node.width = res.width - res.node.height = res.height - return res.node - } else { - const ctx = uni.createCanvasContext(canvasId, context) - if (!ctx._drawImage) { - ctx._drawImage = ctx.drawImage - ctx.drawImage = function (...args) { - const { path } = args.shift() - ctx._drawImage(path, ...args) - } - } - if (!ctx.getImageData) { - ctx.getImageData = function () { - return new Promise((resolve, reject) => { - uni.canvasGetImageData({ - canvasId, - x: parseInt(arguments[0]), - y: parseInt(arguments[1]), - width: parseInt(arguments[2]), - height: parseInt(arguments[3]), - success(res) { - resolve(res) - }, - fail(err) { - reject(err) - } - }, context) - }) - - } - return { - getContext(type: string) { - if(type == '2d') { - return ctx - } - }, - width: res.width, - height: res.height, - createImage - } - } - } - }) - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/createCanvasContextAsync/index.ts b/uni_modules/lime-shared/createCanvasContextAsync/index.ts deleted file mode 100644 index b6e5cf9..0000000 --- a/uni_modules/lime-shared/createCanvasContextAsync/index.ts +++ /dev/null @@ -1,329 +0,0 @@ -// @ts-nocheck -/** - * Canvas上下文创建结果类型 - * 包含创建Canvas上下文时返回的各个组件 - */ -export type LimeCanvasInstance = { - canvasContext : CanvasContext, - node : UniCanvasElement, - renderContext : CanvasRenderingContext2D, - isCanvas2d : boolean, - width : number, - height : number, - toDataURL : (type?: string, quality?: number) => Promise, - flush : (reserve?: boolean) => Promise, - getImageData : (x: number, y: number, width: number, height: number) => Promise -} - - - -/** - * 异步创建Canvas上下文 - * 这个函数封装了uni-app不同平台下的Canvas创建逻辑: - * 1. 在uni-app X中使用uni.createCanvasContextAsync API - * 2. 在非uni-app X中使用uni.createSelectorQuery查询Canvas元素 - * - * @param canvasId - Canvas元素的id选择器 - * @param component - Vue组件实例 - * @returns Promise 包含Canvas上下文、元素和渲染上下文 - * - */ -export function createCanvasContextAsync( - canvasId : string, - component : ComponentPublicInstance -) : Promise { - return new Promise((resolve, reject) => { - // 条件编译:uni-app X平台 - // uni-app X使用新的Canvas API - // #ifdef UNI-APP-X - nextTick(() => { - uni.createCanvasContextAsync({ - id: canvasId, - component, - success(canvasContext : CanvasContext) { - // 从CanvasContext中获取2D渲染上下文 - const ctx = canvasContext.getContext('2d')!; - // 获取Canvas DOM元素 - const node = ctx.canvas; - // 确保获取有效的尺寸 - const width = node.offsetWidth; - const height = node.offsetHeight; - resolve({ - canvasContext: canvasContext, - node, - renderContext: ctx, - isCanvas2d: true, - width, - height, - toDataURL: (type?: string, quality?: number) : Promise => { - return new Promise((resolve) => { - const dataURL = canvasContext.toDataURL(type ?? 'image/png', quality ?? 1.0) - resolve(dataURL) - }) - }, - flush: (_reserve?: boolean):Promise => { - return Promise.resolve() - }, - getImageData: (x: number, y: number, w: number, h: number) : Promise => { - return new Promise((resolve, reject) => { - try { - const imageData = ctx.getImageData(x, y, w, h) - resolve(imageData) - } catch (error) { - reject(error) - } - }) - } - } as LimeCanvasInstance) - }, - fail(error) { - // uni-app X中创建失败时reject错误 - reject(error) - } - }) - }) - - // #endif - - // 条件编译:非uni-app X平台 - // 包括H5、小程序等平台,使用传统的Canvas查询方式 - // #ifndef UNI-APP-X - // 创建选择器查询 - uni.createSelectorQuery() - // 限定在指定组件内查询 - .in(component) - // 选择指定的Canvas元素 - .select(`#${canvasId}`) - // 指定需要查询的字段 - .fields({ - node: true, // 需要获取Canvas节点 - size: true, // 需要获取尺寸信息 - rect: true // 需要获取位置信息 - }, (queryResult) => { - // 成功查询到Canvas节点 - if (queryResult.node && queryResult.node.getContext) { - // 获取Canvas的2D渲染上下文 - const renderContext = queryResult.node.getContext('2d')!; - - let isCanvas2d = true; - - // #ifdef WEB - isCanvas2d = ![...queryResult.node.classList].includes('uni-canvas-canvas') - // #endif - - const canvasContext = { - createImage: () => { - if(queryResult.node.createImage) { - return queryResult.node.createImage() - } - return new LimeCanvasImage() - }, - requestAnimationFrame: (callback: (time: number) => void) : number => { - // #ifdef WEB - return requestAnimationFrame(callback) - // #endif - // #ifndef WEB - if (queryResult.node.requestAnimationFrame) { - return queryResult.node.requestAnimationFrame(callback) - } - // return setTimeout(callback, Math.floor(1000 / 60)) as unknown as number - return setTimeout(() => callback(Date.now()), Math.floor(1000 / 60)) as unknown as number - // #endif - }, - cancelAnimationFrame: (id: number) : void => { - // #ifdef WEB - cancelAnimationFrame(id) - // #endif - // #ifndef WEB - if (queryResult.node.cancelAnimationFrame) { - queryResult.node.cancelAnimationFrame(id) - } else { - clearTimeout(id) - } - // #endif - } - } - - resolve({ - renderContext, - node: queryResult.node, - canvasContext, - isCanvas2d, - width: queryResult.width, - height: queryResult.height, - toDataURL: (type?: string, quality?: number) : Promise => { - return new Promise((resolve) => { - if (queryResult.node != null && typeof queryResult.node.toDataURL == 'function') { - const dataURL = queryResult.node.toDataURL(type ?? 'image/png', quality ?? 1.0) - resolve(dataURL) - } else { - uni.canvasToTempFilePath({ - canvas: queryResult.node, - success: (res) => { - resolve(res.tempFilePath) - }, - fail: () => { - resolve('') - } - }) - } - }) - }, - flush: (_reserve?: boolean) => { - return Promise.resolve() - }, - getImageData: (x: number, y: number, w: number, h: number) : Promise => { - return new Promise((resolve, reject) => { - try { - const result = renderContext.getImageData(x, y, w, h) - if (result && typeof result.then === 'function') { - result.then((imageData : ImageData) => { - resolve(imageData) - }).catch(reject) - } else { - resolve(result as ImageData) - } - } catch(e) { - reject(e) - } - }) - } - } as LimeCanvasInstance) - } else { - // 未能获取到Canvas节点,回退到旧的API - // 使用uni.createCanvasContext创建绘图上下文 - const renderContext = uni.createCanvasContext(canvasId, component) - if (!renderContext._drawImage) { - renderContext._drawImage = renderContext.drawImage - renderContext.drawImage = function (...args) { - const {path} = args.shift(); - renderContext._drawImage(path, ...args) - } - } - - // 创建模拟的CanvasContext对象以保持接口一致 - const canvasContext = { - /** - * 模拟CanvasContext的getContext方法 - * 在旧版本API中返回绘图上下文 - */ - getContext(type : string) { - return renderContext - }, - createImage(){ - return new LimeCanvasImage() - }, - requestAnimationFrame: (callback: (time: number) => void) : number => { - return setTimeout(() => callback(Date.now()), Math.floor(1000 / 60)) as unknown as number - }, - cancelAnimationFrame: (id: number) : void => { - clearTimeout(id) - } - } - const node = { - ...canvasContext, - } - // 在回退方案中,无法获取到Canvas DOM元素 - resolve({ - renderContext, - node, - canvasContext, - isCanvas2d: false, - width: queryResult.width || 300, - height: queryResult.height || 150, - toDataURL: (type?: string, quality?: number) : Promise => { - return new Promise((resolve) => { - renderContext.draw(true, () => { - const fileType = type == 'image/jpeg' ? 'jpg' : 'png' - uni.canvasToTempFilePath({ - canvasId: canvasId, - fileType: fileType, - quality: quality ?? 1.0, - success: (res) => { - resolve(res.tempFilePath) - }, - fail: (err) => { - console.log('[createCanvasContextAsync]:生成图片失败', err) - resolve('') - } - }, component) - }) - }) - }, - flush: (reserve?: boolean) => { - return new Promise((resolve)=> { - renderContext.draw(reserve ?? true, resolve) - }) - }, - getImageData: (x: number, y: number, w: number, h: number) : Promise => { - return new Promise((resolve, reject) => { - renderContext.draw(true, () => { - uni.canvasGetImageData({ - canvasId: canvasId, - x: Math.round(x), - y: Math.round(y), - width: Math.round(w), - height: Math.round(h), - success(res : any) { - resolve(res as ImageData) - }, - fail(err : any) { - reject(err) - } - }, component) - }) - }) - } - } as LimeCanvasInstance) - } - }).exec() // 执行查询 - // #endif - }) -} - - -// #ifndef UNI-APP-X -// #ifndef WEB -class LimeCanvasImage { - currentSrc: string | null = null - naturalHeight: number = 0 - naturalWidth: number = 0 - width: number = 0 - height: number = 0 - tagName: string = 'IMG' - path: string = '' - crossOrigin: string = '' - referrerPolicy: string = '' - onload: () => void = () => {} - onerror: () => void = () => {} - complete: boolean = false - constructor() {} - set src(src: string) { - if(!src) { - return this.onerror() - } - src = src.replace(/^@\//,'/') - this.currentSrc = src - // this.path = src - // uniapp 好像不需要下载 - // this.onload() - uni.getImageInfo({ - src, - success: (res: any) => { - this.path = res.path - this.naturalWidth = this.width = res.width - this.naturalHeight = this.height = res.height - this.onload() - }, - fail: () => { this.onerror() } - }) - } - get src() { - return this.currentSrc - } -} -// #endif -// #ifdef WEB -const LimeCanvasImage = Image -// #endif -// #endif diff --git a/uni_modules/lime-shared/createImage/index.ts b/uni_modules/lime-shared/createImage/index.ts deleted file mode 100644 index 96ab11c..0000000 --- a/uni_modules/lime-shared/createImage/index.ts +++ /dev/null @@ -1,70 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X && APP -import {isBrowser} from '../isBrowser' -class Image { - currentSrc: string | null = null - naturalHeight: number = 0 - naturalWidth: number = 0 - width: number = 0 - height: number = 0 - tagName: string = 'IMG' - path: string = '' - crossOrigin: string = '' - referrerPolicy: string = '' - onload: () => void = () => {} - onerror: () => void = () => {} - complete: boolean = false - constructor() {} - set src(src: string) { - if(!src) { - return this.onerror() - } - src = src.replace(/^@\//,'/') - this.currentSrc = src - uni.getImageInfo({ - src, - success: (res) => { - const localReg = /^\.|^\/(?=[^\/])/; - // #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ || MP-TOUTIAO - res.path = localReg.test(src) ? `/${res.path}` : res.path; - // #endif - this.complete = true - this.path = res.path - this.naturalWidth = this.width = res.width - this.naturalHeight = this.height = res.height - this.onload() - }, - fail: () => { - this.onerror() - } - }) - } - get src() { - return this.currentSrc - } -} -interface UniImage extends WechatMiniprogram.Image { - complete?: boolean - naturalHeight?: number - naturalWidth?: number -} -/** 创建用于 canvas 的 img */ -export function createImage(canvas?: any): HTMLImageElement | UniImage { - if(canvas && canvas.createImage) { - return (canvas as WechatMiniprogram.Canvas).createImage() - } else if(this && this['tagName'] == 'canvas' && !('toBlob' in this) || canvas && !('toBlob' in canvas)){ - return new Image() - } else if(isBrowser) { - return new window.Image() - } - return new Image() -} -// #endif - - -// #ifdef UNI-APP-X && APP -export function createImage():Image{ - // console.error('当前环境不支持') - return new Image() -} -// #endif diff --git a/uni_modules/lime-shared/cssToObj/index.ts b/uni_modules/lime-shared/cssToObj/index.ts deleted file mode 100644 index 74411af..0000000 --- a/uni_modules/lime-shared/cssToObj/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -type UTSJSONObject = Record -// #endif - - -/** - * 将 CSS 字符串转换为样式对象 - * @param css CSS 字符串,例如 "color: red; font-size: 16px;" - * @returns CSSProperties 对象 - */ -export function cssToObj(css : string | UTSJSONObject | null) : UTSJSONObject { - // #ifdef APP-ANDROID - if(css == null) return {} - // #endif - // #ifndef APP-ANDROID - if(!css) return {} - // #endif - if(typeof css == 'object') return css as UTSJSONObject - - - const style : UTSJSONObject = {}; - - (css as string).split(';').forEach(decl => { - // #ifdef APP-ANDROID - const res = decl.split(':').map(s => s.trim()); - if(res.length > 1) { - const [prop, val] = res; - if (prop != '' && val != '') { - const camelProp = prop!.replace(/-([a-z])/g, (_a: string|null, b: string|null, _c: number, _d: string):string => { - return b?.toUpperCase() ?? '' - }); - style[camelProp] = val!; - } - } - // #endif - - // #ifndef APP-ANDROID - const [prop, val] = decl.split(':').map(s => s.trim()); - if (prop && val) { - const camelProp = prop.replace(/-([a-z])/g, (_, c) => { - return c.toUpperCase() - }); - style[camelProp] = val; - } - // #endif - }); - - return style; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/debounce/index.ts b/uni_modules/lime-shared/debounce/index.ts deleted file mode 100644 index c7aa7cb..0000000 --- a/uni_modules/lime-shared/debounce/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// @ts-nocheck - -// #ifdef UNI-APP-X && APP -// export * from './uvue.uts' -export { debounce } from './uvue' -// #endif - -// #ifndef UNI-APP-X && APP -// export * from './vue.ts' -export { debounce } from './vue' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/debounce/uvue.ts b/uni_modules/lime-shared/debounce/uvue.ts deleted file mode 100644 index f1fc29d..0000000 --- a/uni_modules/lime-shared/debounce/uvue.ts +++ /dev/null @@ -1,36 +0,0 @@ -// @ts-nocheck -/** - * 防抖函数,通过延迟一定时间来限制函数的执行频率。 - * @param fn 要防抖的函数。 - * @param wait 触发防抖的等待时间,单位为毫秒。 - * @returns 防抖函数。 - */ -export function debounce(fn : (args: A)=> void, wait = 300): (args: A)=> void { - let timer = -1 - - return (args: A) => { - if (timer >-1) {clearTimeout(timer)}; - - timer = setTimeout(()=>{ - fn(args) - }, wait) - } -}; - - - -// 示例 -// 定义一个函数 -// function saveData(data: string) { -// // 模拟保存数据的操作 -// console.log(`Saving data: ${data}`); -// } - -// // 创建一个防抖函数,延迟 500 毫秒后调用 saveData 函数 -// const debouncedSaveData = debounce(saveData, 500); - -// // 连续调用防抖函数 -// debouncedSaveData('Data 1'); // 不会立即调用 saveData 函数 -// debouncedSaveData('Data 2'); // 不会立即调用 saveData 函数 - -// 在 500 毫秒后,只会调用一次 saveData 函数,输出结果为 "Saving data: Data 2" \ No newline at end of file diff --git a/uni_modules/lime-shared/debounce/uvue.uts b/uni_modules/lime-shared/debounce/uvue.uts deleted file mode 100644 index f1fc29d..0000000 --- a/uni_modules/lime-shared/debounce/uvue.uts +++ /dev/null @@ -1,36 +0,0 @@ -// @ts-nocheck -/** - * 防抖函数,通过延迟一定时间来限制函数的执行频率。 - * @param fn 要防抖的函数。 - * @param wait 触发防抖的等待时间,单位为毫秒。 - * @returns 防抖函数。 - */ -export function debounce(fn : (args: A)=> void, wait = 300): (args: A)=> void { - let timer = -1 - - return (args: A) => { - if (timer >-1) {clearTimeout(timer)}; - - timer = setTimeout(()=>{ - fn(args) - }, wait) - } -}; - - - -// 示例 -// 定义一个函数 -// function saveData(data: string) { -// // 模拟保存数据的操作 -// console.log(`Saving data: ${data}`); -// } - -// // 创建一个防抖函数,延迟 500 毫秒后调用 saveData 函数 -// const debouncedSaveData = debounce(saveData, 500); - -// // 连续调用防抖函数 -// debouncedSaveData('Data 1'); // 不会立即调用 saveData 函数 -// debouncedSaveData('Data 2'); // 不会立即调用 saveData 函数 - -// 在 500 毫秒后,只会调用一次 saveData 函数,输出结果为 "Saving data: Data 2" \ No newline at end of file diff --git a/uni_modules/lime-shared/debounce/vue.ts b/uni_modules/lime-shared/debounce/vue.ts deleted file mode 100644 index 694b44d..0000000 --- a/uni_modules/lime-shared/debounce/vue.ts +++ /dev/null @@ -1,40 +0,0 @@ -// @ts-nocheck -type Timeout = ReturnType | null; -/** - * 防抖函数,通过延迟一定时间来限制函数的执行频率。 - * @param fn 要防抖的函数。 - * @param wait 触发防抖的等待时间,单位为毫秒。 - * @returns 防抖函数。 - */ -export function debounce( - fn : (...args : A) => R, - wait : number = 300) : (...args : A) => void { - let timer : Timeout = null; - - return function (...args : A) { - if (timer) clearTimeout(timer); // 如果上一个 setTimeout 存在,则清除它 - - // 设置一个新的 setTimeout,在指定的等待时间后调用防抖函数 - timer = setTimeout(() => { - fn.apply(this, args); // 使用提供的参数调用原始函数 - }, wait); - }; -}; - - - -// 示例 -// 定义一个函数 -// function saveData(data: string) { -// // 模拟保存数据的操作 -// console.log(`Saving data: ${data}`); -// } - -// // 创建一个防抖函数,延迟 500 毫秒后调用 saveData 函数 -// const debouncedSaveData = debounce(saveData, 500); - -// // 连续调用防抖函数 -// debouncedSaveData('Data 1'); // 不会立即调用 saveData 函数 -// debouncedSaveData('Data 2'); // 不会立即调用 saveData 函数 - -// 在 500 毫秒后,只会调用一次 saveData 函数,输出结果为 "Saving data: Data 2" \ No newline at end of file diff --git a/uni_modules/lime-shared/dom/index.ts b/uni_modules/lime-shared/dom/index.ts deleted file mode 100644 index 9c82e09..0000000 --- a/uni_modules/lime-shared/dom/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -// @ts-nocheck -export function findClosestElementWithStyle(startEl: UniElement | null, styleProperty: string): UniElement | null { - let currentEl: UniElement | null = startEl; - - while (currentEl != null) { - // Check if the current element has the style property with a non-empty value - const styleValue = currentEl?.style.getPropertyValue(styleProperty) ?? ''; - if (styleValue.trim() != '') { - return currentEl; - } - - // Move to parent element - currentEl = currentEl.parentElement; - } - - // Return null if no element with the specified style was found - return null; -}; \ No newline at end of file diff --git a/uni_modules/lime-shared/exif/index.ts b/uni_modules/lime-shared/exif/index.ts deleted file mode 100644 index c9f3206..0000000 --- a/uni_modules/lime-shared/exif/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X && APP -// export * from './vue' -export { exif } from './vue' -// #endif - - -// #ifdef UNI-APP-X && APP -// export * from './uvue.uts' -export { exif } from './uvue' -// #endif diff --git a/uni_modules/lime-shared/exif/uvue.ts b/uni_modules/lime-shared/exif/uvue.ts deleted file mode 100644 index 01d21a2..0000000 --- a/uni_modules/lime-shared/exif/uvue.ts +++ /dev/null @@ -1,7 +0,0 @@ -class EXIF { - constructor(){ - console.error('当前环境不支持') - } -} - -export const exif = new EXIF() \ No newline at end of file diff --git a/uni_modules/lime-shared/exif/uvue.uts b/uni_modules/lime-shared/exif/uvue.uts deleted file mode 100644 index 01d21a2..0000000 --- a/uni_modules/lime-shared/exif/uvue.uts +++ /dev/null @@ -1,7 +0,0 @@ -class EXIF { - constructor(){ - console.error('当前环境不支持') - } -} - -export const exif = new EXIF() \ No newline at end of file diff --git a/uni_modules/lime-shared/exif/vue.ts b/uni_modules/lime-shared/exif/vue.ts deleted file mode 100644 index 6862263..0000000 --- a/uni_modules/lime-shared/exif/vue.ts +++ /dev/null @@ -1,1057 +0,0 @@ -// @ts-nocheck -import { base64ToArrayBuffer } from '../base64ToArrayBuffer'; -import { pathToBase64 } from '../pathToBase64'; -// import { isBase64 } from '../isBase64'; -import { isDataURI } from '../isBase64'; -import { isString } from '../isString'; - -interface File { - exifdata : any - iptcdata : any - xmpdata : any - src : string -} -class EXIF { - isXmpEnabled = false - debug = false - Tags = { - // version tags - 0x9000: "ExifVersion", // EXIF version - 0xA000: "FlashpixVersion", // Flashpix format version - - // colorspace tags - 0xA001: "ColorSpace", // Color space information tag - - // image configuration - 0xA002: "PixelXDimension", // Valid width of meaningful image - 0xA003: "PixelYDimension", // Valid height of meaningful image - 0x9101: "ComponentsConfiguration", // Information about channels - 0x9102: "CompressedBitsPerPixel", // Compressed bits per pixel - - // user information - 0x927C: "MakerNote", // Any desired information written by the manufacturer - 0x9286: "UserComment", // Comments by user - - // related file - 0xA004: "RelatedSoundFile", // Name of related sound file - - // date and time - 0x9003: "DateTimeOriginal", // Date and time when the original image was generated - 0x9004: "DateTimeDigitized", // Date and time when the image was stored digitally - 0x9290: "SubsecTime", // Fractions of seconds for DateTime - 0x9291: "SubsecTimeOriginal", // Fractions of seconds for DateTimeOriginal - 0x9292: "SubsecTimeDigitized", // Fractions of seconds for DateTimeDigitized - - // picture-taking conditions - 0x829A: "ExposureTime", // Exposure time (in seconds) - 0x829D: "FNumber", // F number - 0x8822: "ExposureProgram", // Exposure program - 0x8824: "SpectralSensitivity", // Spectral sensitivity - 0x8827: "ISOSpeedRatings", // ISO speed rating - 0x8828: "OECF", // Optoelectric conversion factor - 0x9201: "ShutterSpeedValue", // Shutter speed - 0x9202: "ApertureValue", // Lens aperture - 0x9203: "BrightnessValue", // Value of brightness - 0x9204: "ExposureBias", // Exposure bias - 0x9205: "MaxApertureValue", // Smallest F number of lens - 0x9206: "SubjectDistance", // Distance to subject in meters - 0x9207: "MeteringMode", // Metering mode - 0x9208: "LightSource", // Kind of light source - 0x9209: "Flash", // Flash status - 0x9214: "SubjectArea", // Location and area of main subject - 0x920A: "FocalLength", // Focal length of the lens in mm - 0xA20B: "FlashEnergy", // Strobe energy in BCPS - 0xA20C: "SpatialFrequencyResponse", // - 0xA20E: "FocalPlaneXResolution", // Number of pixels in width direction per FocalPlaneResolutionUnit - 0xA20F: "FocalPlaneYResolution", // Number of pixels in height direction per FocalPlaneResolutionUnit - 0xA210: "FocalPlaneResolutionUnit", // Unit for measuring FocalPlaneXResolution and FocalPlaneYResolution - 0xA214: "SubjectLocation", // Location of subject in image - 0xA215: "ExposureIndex", // Exposure index selected on camera - 0xA217: "SensingMethod", // Image sensor type - 0xA300: "FileSource", // Image source (3 == DSC) - 0xA301: "SceneType", // Scene type (1 == directly photographed) - 0xA302: "CFAPattern", // Color filter array geometric pattern - 0xA401: "CustomRendered", // Special processing - 0xA402: "ExposureMode", // Exposure mode - 0xA403: "WhiteBalance", // 1 = auto white balance, 2 = manual - 0xA404: "DigitalZoomRation", // Digital zoom ratio - 0xA405: "FocalLengthIn35mmFilm", // Equivalent foacl length assuming 35mm film camera (in mm) - 0xA406: "SceneCaptureType", // Type of scene - 0xA407: "GainControl", // Degree of overall image gain adjustment - 0xA408: "Contrast", // Direction of contrast processing applied by camera - 0xA409: "Saturation", // Direction of saturation processing applied by camera - 0xA40A: "Sharpness", // Direction of sharpness processing applied by camera - 0xA40B: "DeviceSettingDescription", // - 0xA40C: "SubjectDistanceRange", // Distance to subject - - // other tags - 0xA005: "InteroperabilityIFDPointer", - 0xA420: "ImageUniqueID" // Identifier assigned uniquely to each image - } - TiffTags = { - 0x0100: "ImageWidth", - 0x0101: "ImageHeight", - 0x8769: "ExifIFDPointer", - 0x8825: "GPSInfoIFDPointer", - 0xA005: "InteroperabilityIFDPointer", - 0x0102: "BitsPerSample", - 0x0103: "Compression", - 0x0106: "PhotometricInterpretation", - 0x0112: "Orientation", - 0x0115: "SamplesPerPixel", - 0x011C: "PlanarConfiguration", - 0x0212: "YCbCrSubSampling", - 0x0213: "YCbCrPositioning", - 0x011A: "XResolution", - 0x011B: "YResolution", - 0x0128: "ResolutionUnit", - 0x0111: "StripOffsets", - 0x0116: "RowsPerStrip", - 0x0117: "StripByteCounts", - 0x0201: "JPEGInterchangeFormat", - 0x0202: "JPEGInterchangeFormatLength", - 0x012D: "TransferFunction", - 0x013E: "WhitePoint", - 0x013F: "PrimaryChromaticities", - 0x0211: "YCbCrCoefficients", - 0x0214: "ReferenceBlackWhite", - 0x0132: "DateTime", - 0x010E: "ImageDescription", - 0x010F: "Make", - 0x0110: "Model", - 0x0131: "Software", - 0x013B: "Artist", - 0x8298: "Copyright" - } - GPSTags = { - 0x0000: "GPSVersionID", - 0x0001: "GPSLatitudeRef", - 0x0002: "GPSLatitude", - 0x0003: "GPSLongitudeRef", - 0x0004: "GPSLongitude", - 0x0005: "GPSAltitudeRef", - 0x0006: "GPSAltitude", - 0x0007: "GPSTimeStamp", - 0x0008: "GPSSatellites", - 0x0009: "GPSStatus", - 0x000A: "GPSMeasureMode", - 0x000B: "GPSDOP", - 0x000C: "GPSSpeedRef", - 0x000D: "GPSSpeed", - 0x000E: "GPSTrackRef", - 0x000F: "GPSTrack", - 0x0010: "GPSImgDirectionRef", - 0x0011: "GPSImgDirection", - 0x0012: "GPSMapDatum", - 0x0013: "GPSDestLatitudeRef", - 0x0014: "GPSDestLatitude", - 0x0015: "GPSDestLongitudeRef", - 0x0016: "GPSDestLongitude", - 0x0017: "GPSDestBearingRef", - 0x0018: "GPSDestBearing", - 0x0019: "GPSDestDistanceRef", - 0x001A: "GPSDestDistance", - 0x001B: "GPSProcessingMethod", - 0x001C: "GPSAreaInformation", - 0x001D: "GPSDateStamp", - 0x001E: "GPSDifferential" - } - // EXIF 2.3 Spec - IFD1Tags = { - 0x0100: "ImageWidth", - 0x0101: "ImageHeight", - 0x0102: "BitsPerSample", - 0x0103: "Compression", - 0x0106: "PhotometricInterpretation", - 0x0111: "StripOffsets", - 0x0112: "Orientation", - 0x0115: "SamplesPerPixel", - 0x0116: "RowsPerStrip", - 0x0117: "StripByteCounts", - 0x011A: "XResolution", - 0x011B: "YResolution", - 0x011C: "PlanarConfiguration", - 0x0128: "ResolutionUnit", - 0x0201: "JpegIFOffset", // When image format is JPEG, this value show offset to JPEG data stored.(aka "ThumbnailOffset" or "JPEGInterchangeFormat") - 0x0202: "JpegIFByteCount", // When image format is JPEG, this value shows data size of JPEG image (aka "ThumbnailLength" or "JPEGInterchangeFormatLength") - 0x0211: "YCbCrCoefficients", - 0x0212: "YCbCrSubSampling", - 0x0213: "YCbCrPositioning", - 0x0214: "ReferenceBlackWhite" - } - StringValues = { - ExposureProgram: { - 0: "Not defined", - 1: "Manual", - 2: "Normal program", - 3: "Aperture priority", - 4: "Shutter priority", - 5: "Creative program", - 6: "Action program", - 7: "Portrait mode", - 8: "Landscape mode" - }, - MeteringMode: { - 0: "Unknown", - 1: "Average", - 2: "CenterWeightedAverage", - 3: "Spot", - 4: "MultiSpot", - 5: "Pattern", - 6: "Partial", - 255: "Other" - }, - LightSource: { - 0: "Unknown", - 1: "Daylight", - 2: "Fluorescent", - 3: "Tungsten (incandescent light)", - 4: "Flash", - 9: "Fine weather", - 10: "Cloudy weather", - 11: "Shade", - 12: "Daylight fluorescent (D 5700 - 7100K)", - 13: "Day white fluorescent (N 4600 - 5400K)", - 14: "Cool white fluorescent (W 3900 - 4500K)", - 15: "White fluorescent (WW 3200 - 3700K)", - 17: "Standard light A", - 18: "Standard light B", - 19: "Standard light C", - 20: "D55", - 21: "D65", - 22: "D75", - 23: "D50", - 24: "ISO studio tungsten", - 255: "Other" - }, - Flash: { - 0x0000: "Flash did not fire", - 0x0001: "Flash fired", - 0x0005: "Strobe return light not detected", - 0x0007: "Strobe return light detected", - 0x0009: "Flash fired, compulsory flash mode", - 0x000D: "Flash fired, compulsory flash mode, return light not detected", - 0x000F: "Flash fired, compulsory flash mode, return light detected", - 0x0010: "Flash did not fire, compulsory flash mode", - 0x0018: "Flash did not fire, auto mode", - 0x0019: "Flash fired, auto mode", - 0x001D: "Flash fired, auto mode, return light not detected", - 0x001F: "Flash fired, auto mode, return light detected", - 0x0020: "No flash function", - 0x0041: "Flash fired, red-eye reduction mode", - 0x0045: "Flash fired, red-eye reduction mode, return light not detected", - 0x0047: "Flash fired, red-eye reduction mode, return light detected", - 0x0049: "Flash fired, compulsory flash mode, red-eye reduction mode", - 0x004D: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", - 0x004F: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", - 0x0059: "Flash fired, auto mode, red-eye reduction mode", - 0x005D: "Flash fired, auto mode, return light not detected, red-eye reduction mode", - 0x005F: "Flash fired, auto mode, return light detected, red-eye reduction mode" - }, - SensingMethod: { - 1: "Not defined", - 2: "One-chip color area sensor", - 3: "Two-chip color area sensor", - 4: "Three-chip color area sensor", - 5: "Color sequential area sensor", - 7: "Trilinear sensor", - 8: "Color sequential linear sensor" - }, - SceneCaptureType: { - 0: "Standard", - 1: "Landscape", - 2: "Portrait", - 3: "Night scene" - }, - SceneType: { - 1: "Directly photographed" - }, - CustomRendered: { - 0: "Normal process", - 1: "Custom process" - }, - WhiteBalance: { - 0: "Auto white balance", - 1: "Manual white balance" - }, - GainControl: { - 0: "None", - 1: "Low gain up", - 2: "High gain up", - 3: "Low gain down", - 4: "High gain down" - }, - Contrast: { - 0: "Normal", - 1: "Soft", - 2: "Hard" - }, - Saturation: { - 0: "Normal", - 1: "Low saturation", - 2: "High saturation" - }, - Sharpness: { - 0: "Normal", - 1: "Soft", - 2: "Hard" - }, - SubjectDistanceRange: { - 0: "Unknown", - 1: "Macro", - 2: "Close view", - 3: "Distant view" - }, - FileSource: { - 3: "DSC" - }, - - Components: { - 0: "", - 1: "Y", - 2: "Cb", - 3: "Cr", - 4: "R", - 5: "G", - 6: "B" - } - } - enableXmp() { - this.isXmpEnabled = true - } - disableXmp() { - this.isXmpEnabled = false; - } - /** - * 获取图片数据 - * @param img 图片地址 - * @param callback 回调 返回图片数据 - * */ - getData(img : any, callback : Function) { - // if (((self.Image && img instanceof self.Image) || (self.HTMLImageElement && img instanceof self.HTMLImageElement)) && !img.complete) - // return false; - let file : File = { - src: '', - exifdata: null, - iptcdata: null, - xmpdata: null, - } - if (isDataURI(img)) { - file.src = img - } else if (img.path) { - file.src = img.path - } else if (isString(img)) { - file.src = img - } else { - return false; - } - - - if (!imageHasData(file)) { - getImageData(file, callback); - } else { - if (callback) { - callback.call(file); - } - } - return true; - } - /** - * 获取图片tag - * @param img 图片数据 - * @param tag tag 类型 - * */ - getTag(img : File, tag : string) { - if (!imageHasData(img)) return; - return img.exifdata[tag]; - } - getIptcTag(img : File, tag : string) { - if (!imageHasData(img)) return; - return img.iptcdata[tag]; - } - getAllTags(img : File) { - if (!imageHasData(img)) return {}; - let a, - data = img.exifdata, - tags = {}; - for (a in data) { - if (data.hasOwnProperty(a)) { - tags[a] = data[a]; - } - } - return tags; - } - getAllIptcTags(img : File) { - if (!imageHasData(img)) return {}; - let a, - data = img.iptcdata, - tags = {}; - for (a in data) { - if (data.hasOwnProperty(a)) { - tags[a] = data[a]; - } - } - return tags; - } - pretty(img : File) { - if (!imageHasData(img)) return ""; - let a, - data = img.exifdata, - strPretty = ""; - for (a in data) { - if (data.hasOwnProperty(a)) { - if (typeof data[a] == "object") { - if (data[a] instanceof Number) { - strPretty += a + " : " + data[a] + " [" + data[a].numerator + "/" + data[a] - .denominator + "]\r\n"; - } else { - strPretty += a + " : [" + data[a].length + " values]\r\n"; - } - } else { - strPretty += a + " : " + data[a] + "\r\n"; - } - } - } - return strPretty; - } - readFromBinaryFile(file: ArrayBuffer) { - return findEXIFinJPEG(file); - } -} - -export const exif = new EXIF() -// export function getData(img, callback) { -// const exif = new EXIF() -// exif.getData(img, callback) -// } - -// export default {getData} -const ExifTags = exif.Tags -const TiffTags = exif.TiffTags -const IFD1Tags = exif.IFD1Tags -const GPSTags = exif.GPSTags -const StringValues = exif.StringValues - - -function imageHasData(img : File) : boolean { - return !!(img.exifdata); -} - -function objectURLToBlob(url : string, callback : Function) { - try { - const http = new XMLHttpRequest(); - http.open("GET", url, true); - http.responseType = "blob"; - http.onload = function (e) { - if (this.status == 200 || this.status === 0) { - callback(this.response); - } - }; - http.send(); - } catch (e) { - console.warn(e) - } -} - - -function getImageData(img : File, callback : Function) { - function handleBinaryFile(binFile: ArrayBuffer) { - const data = findEXIFinJPEG(binFile); - img.exifdata = data ?? {}; - const iptcdata = findIPTCinJPEG(binFile); - img.iptcdata = iptcdata ?? {}; - if (exif.isXmpEnabled) { - const xmpdata = findXMPinJPEG(binFile); - img.xmpdata = xmpdata ?? {}; - } - if (callback) { - callback.call(img); - } - } - - if (img.src) { - if (/^data\:/i.test(img.src)) { // Data URI - // var arrayBuffer = base64ToArrayBuffer(img.src); - handleBinaryFile(base64ToArrayBuffer(img.src)); - - } else if (/^blob\:/i.test(img.src) && typeof FileReader !== 'undefined') { // Object URL - var fileReader = new FileReader(); - fileReader.onload = function (e) { - handleBinaryFile(e.target.result); - }; - objectURLToBlob(img.src, function (blob : Blob) { - fileReader.readAsArrayBuffer(blob); - }); - } else if (typeof XMLHttpRequest !== 'undefined') { - var http = new XMLHttpRequest(); - http.onload = function () { - if (this.status == 200 || this.status === 0) { - handleBinaryFile(http.response); - } else { - throw "Could not load image"; - } - http = null; - }; - http.open("GET", img.src, true); - http.responseType = "arraybuffer"; - http.send(null); - } else { - pathToBase64(img.src).then(res => { - handleBinaryFile(base64ToArrayBuffer(res)); - }) - } - } else if (typeof FileReader !== 'undefined' && self.FileReader && (img instanceof self.Blob || img instanceof self.File)) { - var fileReader = new FileReader(); - fileReader.onload = function (e : any) { - if (exif.debug) console.log("Got file of length " + e.target.result.byteLength); - handleBinaryFile(e.target.result); - }; - - fileReader.readAsArrayBuffer(img); - } -} - -function findEXIFinJPEG(file: ArrayBuffer) { - const dataView = new DataView(file); - - if (exif.debug) console.log("Got file of length " + file.byteLength); - if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { - if (exif.debug) console.log("Not a valid JPEG"); - return false; // not a valid jpeg - } - - let offset = 2, - length = file.byteLength, - marker; - - while (offset < length) { - if (dataView.getUint8(offset) != 0xFF) { - if (exif.debug) console.log("Not a valid marker at offset " + offset + ", found: " + dataView.getUint8( - offset)); - return false; // not a valid marker, something is wrong - } - - marker = dataView.getUint8(offset + 1); - if (exif.debug) console.log(marker); - - // we could implement handling for other markers here, - // but we're only looking for 0xFFE1 for EXIF data - - if (marker == 225) { - if (exif.debug) console.log("Found 0xFFE1 marker"); - - return readEXIFData(dataView, offset + 4, dataView.getUint16(offset + 2) - 2); - - // offset += 2 + file.getShortAt(offset+2, true); - - } else { - offset += 2 + dataView.getUint16(offset + 2); - } - - } - -} - -function findIPTCinJPEG(file: ArrayBuffer) { - const dataView = new DataView(file); - - if (exif.debug) console.log("Got file of length " + file.byteLength); - if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { - if (exif.debug) console.log("Not a valid JPEG"); - return false; // not a valid jpeg - } - - let offset = 2, - length = file.byteLength; - - - const isFieldSegmentStart = function (dataView, offset: number) { - return ( - dataView.getUint8(offset) === 0x38 && - dataView.getUint8(offset + 1) === 0x42 && - dataView.getUint8(offset + 2) === 0x49 && - dataView.getUint8(offset + 3) === 0x4D && - dataView.getUint8(offset + 4) === 0x04 && - dataView.getUint8(offset + 5) === 0x04 - ); - }; - - while (offset < length) { - - if (isFieldSegmentStart(dataView, offset)) { - - // Get the length of the name header (which is padded to an even number of bytes) - var nameHeaderLength = dataView.getUint8(offset + 7); - if (nameHeaderLength % 2 !== 0) nameHeaderLength += 1; - // Check for pre photoshop 6 format - if (nameHeaderLength === 0) { - // Always 4 - nameHeaderLength = 4; - } - - var startOffset = offset + 8 + nameHeaderLength; - var sectionLength = dataView.getUint16(offset + 6 + nameHeaderLength); - - return readIPTCData(file, startOffset, sectionLength); - - break; - - } - - - // Not the marker, continue searching - offset++; - - } - -} - -const IptcFieldMap = { - 0x78: 'caption', - 0x6E: 'credit', - 0x19: 'keywords', - 0x37: 'dateCreated', - 0x50: 'byline', - 0x55: 'bylineTitle', - 0x7A: 'captionWriter', - 0x69: 'headline', - 0x74: 'copyright', - 0x0F: 'category' -}; - -function readIPTCData(file: ArrayBuffer, startOffset: number, sectionLength: number) { - const dataView = new DataView(file); - let data = {}; - let fieldValue, fieldName, dataSize, segmentType, segmentSize; - let segmentStartPos = startOffset; - while (segmentStartPos < startOffset + sectionLength) { - if (dataView.getUint8(segmentStartPos) === 0x1C && dataView.getUint8(segmentStartPos + 1) === 0x02) { - segmentType = dataView.getUint8(segmentStartPos + 2); - if (segmentType in IptcFieldMap) { - dataSize = dataView.getInt16(segmentStartPos + 3); - segmentSize = dataSize + 5; - fieldName = IptcFieldMap[segmentType]; - fieldValue = getStringFromDB(dataView, segmentStartPos + 5, dataSize); - // Check if we already stored a value with this name - if (data.hasOwnProperty(fieldName)) { - // Value already stored with this name, create multivalue field - if (data[fieldName] instanceof Array) { - data[fieldName].push(fieldValue); - } else { - data[fieldName] = [data[fieldName], fieldValue]; - } - } else { - data[fieldName] = fieldValue; - } - } - - } - segmentStartPos++; - } - return data; -} - -function readTags(file: DataView, tiffStart: number, dirStart: number, strings: any[], bigEnd: number) { - let entries = file.getUint16(dirStart, !bigEnd), - tags = {}, - entryOffset, tag; - - for (let i = 0; i < entries; i++) { - entryOffset = dirStart + i * 12 + 2; - tag = strings[file.getUint16(entryOffset, !bigEnd)]; - if (!tag && exif.debug) console.log("Unknown tag: " + file.getUint16(entryOffset, !bigEnd)); - tags[tag] = readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd); - } - return tags; -} - -function readTagValue(file: DataView, entryOffset: number, tiffStart: number, dirStart: number, bigEnd: number) { - let type = file.getUint16(entryOffset + 2, !bigEnd), - numValues = file.getUint32(entryOffset + 4, !bigEnd), - valueOffset = file.getUint32(entryOffset + 8, !bigEnd) + tiffStart, - offset, - vals, val, n, - numerator, denominator; - - switch (type) { - case 1: // byte, 8-bit unsigned int - case 7: // undefined, 8-bit byte, value depending on field - if (numValues == 1) { - return file.getUint8(entryOffset + 8, !bigEnd); - } else { - offset = numValues > 4 ? valueOffset : (entryOffset + 8); - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getUint8(offset + n); - } - return vals; - } - - case 2: // ascii, 8-bit byte - offset = numValues > 4 ? valueOffset : (entryOffset + 8); - return getStringFromDB(file, offset, numValues - 1); - - case 3: // short, 16 bit int - if (numValues == 1) { - return file.getUint16(entryOffset + 8, !bigEnd); - } else { - offset = numValues > 2 ? valueOffset : (entryOffset + 8); - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getUint16(offset + 2 * n, !bigEnd); - } - return vals; - } - - case 4: // long, 32 bit int - if (numValues == 1) { - return file.getUint32(entryOffset + 8, !bigEnd); - } else { - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getUint32(valueOffset + 4 * n, !bigEnd); - } - return vals; - } - - case 5: // rational = two long values, first is numerator, second is denominator - if (numValues == 1) { - numerator = file.getUint32(valueOffset, !bigEnd); - denominator = file.getUint32(valueOffset + 4, !bigEnd); - val = new Number(numerator / denominator); - val.numerator = numerator; - val.denominator = denominator; - return val; - } else { - vals = []; - for (n = 0; n < numValues; n++) { - numerator = file.getUint32(valueOffset + 8 * n, !bigEnd); - denominator = file.getUint32(valueOffset + 4 + 8 * n, !bigEnd); - vals[n] = new Number(numerator / denominator); - vals[n].numerator = numerator; - vals[n].denominator = denominator; - } - return vals; - } - - case 9: // slong, 32 bit signed int - if (numValues == 1) { - return file.getInt32(entryOffset + 8, !bigEnd); - } else { - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getInt32(valueOffset + 4 * n, !bigEnd); - } - return vals; - } - - case 10: // signed rational, two slongs, first is numerator, second is denominator - if (numValues == 1) { - return file.getInt32(valueOffset, !bigEnd) / file.getInt32(valueOffset + 4, !bigEnd); - } else { - vals = []; - for (n = 0; n < numValues; n++) { - vals[n] = file.getInt32(valueOffset + 8 * n, !bigEnd) / file.getInt32(valueOffset + 4 + 8 * - n, !bigEnd); - } - return vals; - } - } -} -/** - * Given an IFD (Image File Directory) start offset - * returns an offset to next IFD or 0 if it's the last IFD. - */ -function getNextIFDOffset(dataView: DataView, dirStart: number, bigEnd: number) { - //the first 2bytes means the number of directory entries contains in this IFD - var entries = dataView.getUint16(dirStart, !bigEnd); - - // After last directory entry, there is a 4bytes of data, - // it means an offset to next IFD. - // If its value is '0x00000000', it means this is the last IFD and there is no linked IFD. - - return dataView.getUint32(dirStart + 2 + entries * 12, !bigEnd); // each entry is 12 bytes long -} - -function readThumbnailImage(dataView: DataView, tiffStart: number, firstIFDOffset: number, bigEnd: number) { - // get the IFD1 offset - const IFD1OffsetPointer = getNextIFDOffset(dataView, tiffStart + firstIFDOffset, bigEnd); - - if (!IFD1OffsetPointer) { - // console.log('******** IFD1Offset is empty, image thumb not found ********'); - return {}; - } else if (IFD1OffsetPointer > dataView.byteLength) { // this should not happen - // console.log('******** IFD1Offset is outside the bounds of the DataView ********'); - return {}; - } - // console.log('******* thumbnail IFD offset (IFD1) is: %s', IFD1OffsetPointer); - - let thumbTags : any = readTags(dataView, tiffStart, tiffStart + IFD1OffsetPointer, IFD1Tags, bigEnd) - - // EXIF 2.3 specification for JPEG format thumbnail - - // If the value of Compression(0x0103) Tag in IFD1 is '6', thumbnail image format is JPEG. - // Most of Exif image uses JPEG format for thumbnail. In that case, you can get offset of thumbnail - // by JpegIFOffset(0x0201) Tag in IFD1, size of thumbnail by JpegIFByteCount(0x0202) Tag. - // Data format is ordinary JPEG format, starts from 0xFFD8 and ends by 0xFFD9. It seems that - // JPEG format and 160x120pixels of size are recommended thumbnail format for Exif2.1 or later. - - if (thumbTags['Compression'] && typeof Blob !== 'undefined') { - // console.log('Thumbnail image found!'); - - switch (thumbTags['Compression']) { - case 6: - // console.log('Thumbnail image format is JPEG'); - if (thumbTags.JpegIFOffset && thumbTags.JpegIFByteCount) { - // extract the thumbnail - var tOffset = tiffStart + thumbTags.JpegIFOffset; - var tLength = thumbTags.JpegIFByteCount; - thumbTags['blob'] = new Blob([new Uint8Array(dataView.buffer, tOffset, tLength)], { - type: 'image/jpeg' - }); - } - break; - - case 1: - console.log("Thumbnail image format is TIFF, which is not implemented."); - break; - default: - console.log("Unknown thumbnail image format '%s'", thumbTags['Compression']); - } - } else if (thumbTags['PhotometricInterpretation'] == 2) { - console.log("Thumbnail image format is RGB, which is not implemented."); - } - return thumbTags; -} - -function getStringFromDB(buffer: DataView, start: number, length: number) { - let outstr = ""; - for (let n = start; n < start + length; n++) { - outstr += String.fromCharCode(buffer.getUint8(n)); - } - return outstr; -} - -function readEXIFData(file: DataView, start: number) { - if (getStringFromDB(file, start, 4) != "Exif") { - if (exif.debug) console.log("Not valid EXIF data! " + getStringFromDB(file, start, 4)); - return false; - } - - let bigEnd, - tags, tag, - exifData, gpsData, - tiffOffset = start + 6; - - // test for TIFF validity and endianness - if (file.getUint16(tiffOffset) == 0x4949) { - bigEnd = false; - } else if (file.getUint16(tiffOffset) == 0x4D4D) { - bigEnd = true; - } else { - if (exif.debug) console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"); - return false; - } - - if (file.getUint16(tiffOffset + 2, !bigEnd) != 0x002A) { - if (exif.debug) console.log("Not valid TIFF data! (no 0x002A)"); - return false; - } - - const firstIFDOffset = file.getUint32(tiffOffset + 4, !bigEnd); - - if (firstIFDOffset < 0x00000008) { - if (exif.debug) console.log("Not valid TIFF data! (First offset less than 8)", file.getUint32(tiffOffset + 4, - !bigEnd)); - return false; - } - - tags = readTags(file, tiffOffset, tiffOffset + firstIFDOffset, TiffTags, bigEnd); - - if (tags.ExifIFDPointer) { - exifData = readTags(file, tiffOffset, tiffOffset + tags.ExifIFDPointer, ExifTags, bigEnd); - for (tag in exifData) { - switch (tag) { - case "LightSource": - case "Flash": - case "MeteringMode": - case "ExposureProgram": - case "SensingMethod": - case "SceneCaptureType": - case "SceneType": - case "CustomRendered": - case "WhiteBalance": - case "GainControl": - case "Contrast": - case "Saturation": - case "Sharpness": - case "SubjectDistanceRange": - case "FileSource": - exifData[tag] = StringValues[tag][exifData[tag]]; - break; - - case "ExifVersion": - case "FlashpixVersion": - exifData[tag] = String.fromCharCode(exifData[tag][0], exifData[tag][1], exifData[tag][2], - exifData[tag][3]); - break; - - case "ComponentsConfiguration": - exifData[tag] = - StringValues.Components[exifData[tag][0]] + - StringValues.Components[exifData[tag][1]] + - StringValues.Components[exifData[tag][2]] + - StringValues.Components[exifData[tag][3]]; - break; - } - tags[tag] = exifData[tag]; - } - } - - if (tags.GPSInfoIFDPointer) { - gpsData = readTags(file, tiffOffset, tiffOffset + tags.GPSInfoIFDPointer, GPSTags, bigEnd); - for (tag in gpsData) { - switch (tag) { - case "GPSVersionID": - gpsData[tag] = gpsData[tag][0] + - "." + gpsData[tag][1] + - "." + gpsData[tag][2] + - "." + gpsData[tag][3]; - break; - } - tags[tag] = gpsData[tag]; - } - } - - // extract thumbnail - tags['thumbnail'] = readThumbnailImage(file, tiffOffset, firstIFDOffset, bigEnd); - - return tags; -} - -function findXMPinJPEG(file: ArrayBuffer) { - - if (!('DOMParser' in self)) { - // console.warn('XML parsing not supported without DOMParser'); - return; - } - const dataView = new DataView(file); - - if (exif.debug) console.log("Got file of length " + file.byteLength); - if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { - if (exif.debug) console.log("Not a valid JPEG"); - return false; // not a valid jpeg - } - - let offset = 2, - length = file.byteLength, - dom = new DOMParser(); - - while (offset < (length - 4)) { - if (getStringFromDB(dataView, offset, 4) == "http") { - const startOffset = offset - 1; - const sectionLength = dataView.getUint16(offset - 2) - 1; - let xmpString = getStringFromDB(dataView, startOffset, sectionLength) - const xmpEndIndex = xmpString.indexOf('xmpmeta>') + 8; - xmpString = xmpString.substring(xmpString.indexOf(' 0) { - json['@attributes'] = {}; - for (var j = 0; j < xml.attributes.length; j++) { - var attribute = xml.attributes.item(j); - json['@attributes'][attribute.nodeName] = attribute.nodeValue; - } - } - } else if (xml.nodeType == 3) { // text node - return xml.nodeValue; - } - - // deal with children - if (xml.hasChildNodes()) { - for (var i = 0; i < xml.childNodes.length; i++) { - var child = xml.childNodes.item(i); - var nodeName = child.nodeName; - if (json[nodeName] == null) { - json[nodeName] = xml2json(child); - } else { - if (json[nodeName].push == null) { - var old = json[nodeName]; - json[nodeName] = []; - json[nodeName].push(old); - } - json[nodeName].push(xml2json(child)); - } - } - } - - return json; -} - -function xml2Object(xml: any) { - try { - var obj = {}; - if (xml.children.length > 0) { - for (var i = 0; i < xml.children.length; i++) { - var item = xml.children.item(i); - var attributes = item.attributes; - for (var idx in attributes) { - var itemAtt = attributes[idx]; - var dataKey = itemAtt.nodeName; - var dataValue = itemAtt.nodeValue; - - if (dataKey !== undefined) { - obj[dataKey] = dataValue; - } - } - var nodeName = item.nodeName; - - if (typeof (obj[nodeName]) == "undefined") { - obj[nodeName] = xml2json(item); - } else { - if (typeof (obj[nodeName].push) == "undefined") { - var old = obj[nodeName]; - - obj[nodeName] = []; - obj[nodeName].push(old); - } - obj[nodeName].push(xml2json(item)); - } - } - } else { - obj = xml.textContent; - } - return obj; - } catch (e) { - console.log(e.message); - } -} \ No newline at end of file diff --git a/uni_modules/lime-shared/fillArray/index.ts b/uni_modules/lime-shared/fillArray/index.ts deleted file mode 100644 index 9f40008..0000000 --- a/uni_modules/lime-shared/fillArray/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -// @ts-nocheck -export function fillArray(length: number, value: T): T[] { - - // #ifdef APP-ANDROID - const result:T[] = [] - for (let i = 0; i < length; i++) { - result.push(value) - } - // #endif - - // #ifndef APP-ANDROID - const result = new Array(length).fill(value) - // #endif - - - - return result -} \ No newline at end of file diff --git a/uni_modules/lime-shared/fillZero/index.ts b/uni_modules/lime-shared/fillZero/index.ts deleted file mode 100644 index 9952c45..0000000 --- a/uni_modules/lime-shared/fillZero/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// @ts-nocheck -/** - * 在数字前填充零,返回字符串形式的结果 - * @param number 要填充零的数字 - * @param length 填充零后的字符串长度,默认为2 - * @returns 填充零后的字符串 - */ -export function fillZero(number: number, length: number = 2): string { - // 将数字转换为字符串,然后使用 padStart 方法填充零到指定长度 - return `${number}`.padStart(length, '0'); -} \ No newline at end of file diff --git a/uni_modules/lime-shared/findLastIndex/index.ts b/uni_modules/lime-shared/findLastIndex/index.ts deleted file mode 100644 index 620750f..0000000 --- a/uni_modules/lime-shared/findLastIndex/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -// @/uni_modules/lime-shared/arrayUtils.ts - -/** - * 兼容版 findLastIndex(ES2023 polyfill) - */ -export function findLastIndex( - array : T[], - predicate : (value : T, index : number, obj : T[]) => boolean) : number { - - // #ifndef UNI-APP-X && APP-ANDROID - if (typeof array.findLastIndex == 'function') { - // 如果原生支持,直接用(未来兼容) - return array.findLastIndex(predicate); - } - // #endif - // 否则降级到 for 循环 - for (let i = array.length - 1; i >= 0; i--) { - if (predicate(array[i], i, array)) { - return i; - } - } - return -1; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/floatAdd/index.ts b/uni_modules/lime-shared/floatAdd/index.ts deleted file mode 100644 index 13557f8..0000000 --- a/uni_modules/lime-shared/floatAdd/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { isNumber } from '../isNumber' -/** - * 返回两个浮点数相加的结果 - * @param num1 第一个浮点数 - * @param num2 第二个浮点数 - * @returns 两个浮点数的相加结果 - */ -export function floatAdd(num1 : number, num2 : number) : number { - // 检查 num1 和 num2 是否为数字类型 - if (!isNumber(num1) || !isNumber(num2)) { - console.warn('Please pass in the number type'); - return NaN; - } - - const getDecimalLen = (n: number):number => { - const arr = n.toString().split('.') - if(arr.length > 0) return arr[1].length - return 0 - }; - const r1 = getDecimalLen(num1); - const r2 = getDecimalLen(num2); - - // 计算需要扩大的倍数 - const m = Math.pow(10, Math.max(r1, r2)); - // 返回相加结果 - return Math.round((num1 * m + num2 * m)) / m; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/floatDiv/index.ts b/uni_modules/lime-shared/floatDiv/index.ts deleted file mode 100644 index 195d4ab..0000000 --- a/uni_modules/lime-shared/floatDiv/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { floatMul } from '../floatMul'; -import { isNumber } from '../isNumber'; - -/** - * 除法函数,用于处理浮点数除法并保持精度。 - * @param {number} num1 - 被除数。 - * @param {number} num2 - 除数。 - * @returns {number} 除法运算的结果,保留正确的精度。 - */ -export function floatDiv(num1:number, num2:number):number { - // 如果传入的不是数字类型,则打印警告并返回NaN - if (!isNumber(num1) || !isNumber(num2)) { - console.warn('请传入数字类型'); - return NaN; - } - - let m1 = 0, // 被除数小数点后的位数 - m2 = 0, // 除数小数点后的位数 - s1 = num1.toString(), // 将被除数转换为字符串 - s2 = num2.toString(); // 将除数转换为字符串 - - // 计算被除数小数点后的位数 - try { - m1 += s1.split('.')[1].length; - } catch (error) {} - - // 计算除数小数点后的位数 - try { - m2 += s2.split('.')[1].length; - } catch (error) {} - - // 进行除法运算并处理小数点后的位数,使用之前定义的乘法函数保持精度 - // #ifdef APP-ANDROID - return floatMul( - parseFloat(s1.replace('.', '')) / parseFloat(s2.replace('.', '')), - Math.pow(10, m2 - m1), - ); - // #endif - // #ifndef APP-ANDROID - return floatMul( - Number(s1.replace('.', '')) / Number(s2.replace('.', '')), - Math.pow(10, m2 - m1), - ); - // #endif -} diff --git a/uni_modules/lime-shared/floatMul/index.ts b/uni_modules/lime-shared/floatMul/index.ts deleted file mode 100644 index 51a867e..0000000 --- a/uni_modules/lime-shared/floatMul/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -// @ts-nocheck -import {isNumber} from '../isNumber'; -// #ifdef APP-ANDROID -import BigDecimal from 'java.math.BigDecimal' -// import BigDecimal from 'java.math.BigDecimal' -// import StringBuilder from 'java.lang.StringBuilder' -// import java.math.BigDecimal; -// #endif - -/** - * 乘法函数,用于处理浮点数乘法并保持精度。 - * @param {number} num1 - 第一个乘数。 - * @param {number} num2 - 第二个乘数。 - * @returns {number} 乘法运算的结果,保留正确的精度。 - */ -export function floatMul(num1 : number, num2 : number) : number { - if (!(isNumber(num1) || isNumber(num2))) { - console.warn('Please pass in the number type'); - return NaN; - } - let m = 0; - // #ifdef APP-ANDROID - let s1 = BigDecimal.valueOf(num1.toDouble()).toPlainString(); //new UTSNumber(num1).toString() // //`${num1.toFloat()}`// num1.toString(), - let s2 = BigDecimal.valueOf(num2.toDouble()).toPlainString(); //new UTSNumber(num2).toString() //`${num2.toFloat()}`//.toString(); - // #endif - // #ifndef APP-ANDROID - let s1:string = `${num1}`// num1.toString(), - let s2:string = `${num2}`//.toString(); - // #endif - - try { - m += s1.split('.')[1].length; - } catch (error) { } - try { - m += s2.split('.')[1].length; - } catch (error) { } - - // #ifdef APP-ANDROID - return parseFloat(s1.replace('.', '')) * parseFloat(s2.replace('.', '')) / Math.pow(10, m); - // #endif - // #ifndef APP-ANDROID - return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m); - // #endif -} diff --git a/uni_modules/lime-shared/floatSub/index.ts b/uni_modules/lime-shared/floatSub/index.ts deleted file mode 100644 index 9bc25cb..0000000 --- a/uni_modules/lime-shared/floatSub/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { isNumber } from '../isNumber'; -/** - * 减法函数,用于处理浮点数减法并保持精度。 - * @param {number} num1 - 被减数。 - * @param {number} num2 - 减数。 - * @returns {number} 减法运算的结果,保留正确的精度。 - */ -export function floatSub(num1 : number, num2 : number) : number { - if (!(isNumber(num1) || isNumber(num2))) { - console.warn('Please pass in the number type'); - return NaN; - } - let r1:number, r2:number, m:number, n:number; - try { - r1 = num1.toString().split('.')[1].length; - } catch (error) { - r1 = 0; - } - try { - r2 = num2.toString().split('.')[1].length; - } catch (error) { - r2 = 0; - } - m = Math.pow(10, Math.max(r1, r2)); - n = r1 >= r2 ? r1 : r2; - // #ifndef APP-ANDROID - return Number(((num1 * m - num2 * m) / m).toFixed(n)); - // #endif - // #ifdef APP-ANDROID - return parseFloat(((num1 * m - num2 * m) / m).toFixed(n)); - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/getClassStr/index.ts b/uni_modules/lime-shared/getClassStr/index.ts deleted file mode 100644 index 34a26d2..0000000 --- a/uni_modules/lime-shared/getClassStr/index.ts +++ /dev/null @@ -1,53 +0,0 @@ -// @ts-nocheck - -// #ifdef UNI-APP-X && APP -import { isNumber } from '../isNumber' -import { isString } from '../isString' -import { isDef } from '../isDef' -// #endif - -/** - * 获取对象的类名字符串 - * @param obj - 需要处理的对象 - * @returns 由对象属性作为类名组成的字符串 - */ -export function getClassStr(obj : T) : string { - let classNames : string[] = []; - // #ifdef APP-ANDROID - if (obj instanceof UTSJSONObject) { - (obj as UTSJSONObject).toMap().forEach((value, key) => { - if (isDef(value)) { - if (isNumber(value)) { - classNames.push(key); - } - if (isString(value) && value !== '') { - classNames.push(key); - } - if (typeof value == 'boolean' && (value as boolean)) { - classNames.push(key); - } - } - }) - } - // #endif - // #ifndef APP-ANDROID - // 遍历对象的属性 - for (let key in obj) { - // 检查属性确实属于对象自身且其值为true - if ((obj as any).hasOwnProperty(key) && obj[key]) { - // 将属性名添加到类名数组中 - classNames.push(key); - } - } - // #endif - - - // 将类名数组用空格连接成字符串并返回 - return classNames.join(' '); -} - - -// 示例 -// const obj = { foo: true, bar: false, baz: true }; -// const classNameStr = getClassStr(obj); -// console.log(classNameStr); // 输出: "foo baz" \ No newline at end of file diff --git a/uni_modules/lime-shared/getCurrentPage/index.ts b/uni_modules/lime-shared/getCurrentPage/index.ts deleted file mode 100644 index dd8dcb5..0000000 --- a/uni_modules/lime-shared/getCurrentPage/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X && APP -export { getCurrentPage } from './vue' -// #endif - - -// #ifdef UNI-APP-X && APP -export { getCurrentPage } from './uvue' -// #endif diff --git a/uni_modules/lime-shared/getCurrentPage/uvue.ts b/uni_modules/lime-shared/getCurrentPage/uvue.ts deleted file mode 100644 index 9e96d2b..0000000 --- a/uni_modules/lime-shared/getCurrentPage/uvue.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-nocheck -export const getCurrentPage = ():Page => { - const pages = getCurrentPages(); - return pages[pages.length - 1] -}; \ No newline at end of file diff --git a/uni_modules/lime-shared/getCurrentPage/uvue.uts b/uni_modules/lime-shared/getCurrentPage/uvue.uts deleted file mode 100644 index 9e96d2b..0000000 --- a/uni_modules/lime-shared/getCurrentPage/uvue.uts +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-nocheck -export const getCurrentPage = ():Page => { - const pages = getCurrentPages(); - return pages[pages.length - 1] -}; \ No newline at end of file diff --git a/uni_modules/lime-shared/getCurrentPage/vue.ts b/uni_modules/lime-shared/getCurrentPage/vue.ts deleted file mode 100644 index 79ecac8..0000000 --- a/uni_modules/lime-shared/getCurrentPage/vue.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @ts-nocheck -/** 获取当前页 */ -export const getCurrentPage = () => { - const pages = getCurrentPages(); - return pages[pages.length - 1] //as T & WechatMiniprogram.Page.TrivialInstance; -}; \ No newline at end of file diff --git a/uni_modules/lime-shared/getDeviceInfo/index.ts b/uni_modules/lime-shared/getDeviceInfo/index.ts deleted file mode 100644 index cdeee18..0000000 --- a/uni_modules/lime-shared/getDeviceInfo/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -export function getDeviceInfo():GetDeviceInfoResult { - // #ifndef UNI-APP-X && APP - if (uni.getDeviceInfo || uni.canIUse('getDeviceInfo')) { - return uni.getDeviceInfo(); - } else { - return uni.getSystemInfoSync(); - } - // #endif - // #ifdef UNI-APP-X && APP - return uni.getDeviceInfo() - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/getLocalFilePath/index.ts b/uni_modules/lime-shared/getLocalFilePath/index.ts deleted file mode 100644 index 373ece2..0000000 --- a/uni_modules/lime-shared/getLocalFilePath/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -// @ts-nocheck -// #ifdef APP-NVUE || APP-VUE -export const getLocalFilePath = (path : string) => { - if (typeof plus == 'undefined') return path - if (/^(_www|_doc|_documents|_downloads|file:\/\/|\/storage\/emulated\/0\/)/.test(path)) return path - console.log(/^\//.test(path)) - if (/^\//.test(path)) { - const localFilePath = plus.io.convertAbsoluteFileSystem(path) - console.log('localFilePath', localFilePath) - if (localFilePath !== path) { - return localFilePath - } else { - path = path.slice(1) - } - } - return '_www/' + path -} -// #endif - - -// #ifdef UNI-APP-X && APP -export { getResourcePath as getLocalFilePath } from '@/uni_modules/lime-file-utils' -// export const getLocalFilePath = (path : string) : string => { -// let uri = path -// if (uri.startsWith("http") || uri.startsWith(" { -// try { -// let uri = path -// if (uri.startsWith("http") || uri.startsWith(" { - return new Promise(resolve => { - uni.createSelectorQuery() - .selectViewport() - .scrollOffset((res) => { - resolve(res); - }).exec(); - }) -} - -/** -``` - page - ╱ - ╭───────────────╮ viewport - ╭─│─ ─ ─ ─ ─ ─ ─ ─│─╮ ╱ - │ │ ╭───────────╮ │ │ - │ │ │ element │ │ │ - │ │ ╰───────────╯ │ │ - ╰─│─ ─ ─ ─ ─ ─ ─ ─│─╯ - │ │ - │ │ - ╰───────────────╯ -``` - -# 参数 -- viewportHeight: viewport 高度 -- viewportScrollTop: viewport 垂直滚动值 -- elementHeight: element 高度 -- elementOffsetTop: element 距离页面顶部距离 - -# 选项 -- position: element 在视窗中的位置(start, center, end, nearest) -- startOffset: element 距离视窗顶部的偏移量 -- endOffset: element 距离视窗底部的偏移量 - -# 结果值 -- viewportScrollTop: viewport 新的垂直滚动值 - -*/ - -export type ScrollIntoViewOptions = { - /** 元素顶部需要保留的缓冲距离(默认 0) */ - startOffset ?: number; - /** 元素底部需要保留的缓冲距离(默认 0) */ - endOffset ?: number; - /** 滚动对齐方式:start/center/end/nearest(默认 nearest) */ - position ?: 'start' | 'center' | 'end' | 'nearest'; -} - -/** - * 计算元素需要滚动到可视区域的目标滚动位置 - * @param viewportHeight 视口高度(像素) - * @param viewportScrollTop 当前滚动位置(像素) - * @param elementHeight 元素高度(像素) - * @param elementOffsetTop 元素相对于父容器顶部的偏移量(像素) - * @param options 配置选项 - * @returns 计算后的目标滚动位置(像素) - * - * @example - * // 示例:将元素滚动到视口顶部对齐 - * const scrollTop = getScrollIntoViewValue( - * 500, // 视口高度 - * 200, // 当前滚动位置 - * 100, // 元素高度 - * 300, // 元素偏移量 - * { position: 'start' } - * ); - */ -export function getScrollIntoViewValue( - viewportHeight : number, - viewportScrollTop : number, - elementHeight : number, - elementOffsetTop : number, - options : ScrollIntoViewOptions = {} -) : number { - let { startOffset = 0, endOffset = 0, position = 'nearest'} = options; - - // 计算元素相对于视口的上下偏移量 - const elementToViewportTopOffset = elementOffsetTop - viewportScrollTop - startOffset; - const elementToViewportBottomOffset = - elementOffsetTop + - elementHeight - - viewportScrollTop - - viewportHeight + - endOffset; - - // 处理 nearest 模式,自动选择最近边缘 - if (position == 'nearest') { - if (elementToViewportTopOffset >= 0 && elementToViewportBottomOffset <= 0) { - return viewportScrollTop; - } - position = - Math.abs(elementToViewportTopOffset) > Math.abs(elementToViewportBottomOffset) - ? 'end' - : 'start'; - } - - // 根据不同的对齐位置计算目标滚动位置 - let nextScrollTop = 0; - switch (position) { - case 'start': - // 顶部对齐:元素顶部对齐视口顶部(考虑顶部缓冲) - nextScrollTop = elementOffsetTop - startOffset; - break; - case 'center': - // 居中对齐:元素中心对齐视口中心(考虑上下缓冲) - nextScrollTop = - elementOffsetTop - - (viewportHeight - elementHeight - endOffset - startOffset) / 2 + - startOffset; - break; - case 'end': - // 底部对齐:元素底部对齐视口底部(考虑底部缓冲) - nextScrollTop = - elementOffsetTop + elementHeight - viewportHeight + endOffset; - break; - } - - return nextScrollTop; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/getRect/uvue.ts b/uni_modules/lime-shared/getRect/uvue.ts deleted file mode 100644 index bcdaccc..0000000 --- a/uni_modules/lime-shared/getRect/uvue.ts +++ /dev/null @@ -1,35 +0,0 @@ -// @ts-nocheck -/** - * 获取节点信息 - * @param selector 选择器字符串 - * @param context ComponentPublicInstance 对象,传 null 时自动使用页面级 context - * @returns 包含节点信息的 Promise 对象 - */ -export function getRect(selector : string, context: ComponentPublicInstance|null=null):Promise { - return new Promise((resolve)=>{ - if(context != null) { - uni.createSelectorQuery().in(context!).select(selector).boundingClientRect(res =>{ - resolve(res as NodeInfo) - }).exec(); - } else { - uni.createSelectorQuery().select(selector).boundingClientRect(res =>{ - resolve(res as NodeInfo) - }).exec(); - } - - }) -} - -export function getAllRect(selector : string, context: ComponentPublicInstance|null=null):Promise { - return new Promise((resolve)=>{ - if(context != null){ - uni.createSelectorQuery().in(context!).selectAll(selector).boundingClientRect(res =>{ - resolve(res as NodeInfo[]) - }).exec(); - } else { - uni.createSelectorQuery().selectAll(selector).boundingClientRect(res =>{ - resolve(res as NodeInfo[]) - }).exec(); - } - }) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/getRect/uvue.uts b/uni_modules/lime-shared/getRect/uvue.uts deleted file mode 100644 index 05f16ee..0000000 --- a/uni_modules/lime-shared/getRect/uvue.uts +++ /dev/null @@ -1,17 +0,0 @@ -// @ts-nocheck -export function getRect(selector : string, context: ComponentPublicInstance):Promise { - return new Promise((resolve)=>{ - uni.createSelectorQuery().in(context).select(selector).boundingClientRect(res =>{ - resolve(res as NodeInfo) - }).exec(); - }) -} - -export function getAllRect(selector : string, context: ComponentPublicInstance):Promise { - return new Promise((resolve)=>{ - uni.createSelectorQuery().in(context).selectAll(selector).boundingClientRect(res =>{ - resolve(res as NodeInfo[]) - }).exec(); - }) -} - diff --git a/uni_modules/lime-shared/getRect/vue.ts b/uni_modules/lime-shared/getRect/vue.ts deleted file mode 100644 index 240b510..0000000 --- a/uni_modules/lime-shared/getRect/vue.ts +++ /dev/null @@ -1,130 +0,0 @@ -// @ts-nocheck - -// #ifdef APP-NVUE -// 当编译环境是 APP-NVUE 时,引入 uni.requireNativePlugin('dom'),具体插件用途未知 -const dom = uni.requireNativePlugin('dom') -// #endif - -/** - * 获取节点信息 - * @param selector 选择器字符串 - * @param context ComponentInternalInstance 对象,传 null 时自动使用页面级查询 - * @param node 是否获取node - * @returns 包含节点信息的 Promise 对象 - */ -export function getRect(selector : string, context : ComponentInternalInstance|ComponentPublicInstance|null = null, node: boolean = false) { - if(context != null) { - if(context.context){ - context = context.context - } - // #ifdef MP || VUE2 - if (context.proxy) context = context.proxy - // #endif - } - - return new Promise((resolve, reject) => { - // #ifndef APP-NVUE - let dom = context != null - ? uni.createSelectorQuery().in(context) - : uni.createSelectorQuery(); - // #ifndef MP-TOUTIAO - // #endif - dom = dom.select(selector); - const result = (rect: UniNamespace.NodeInfo) => { - if (rect) { - resolve(rect) - } else { - reject('no rect') - } - } - - if (!node) { - dom.boundingClientRect(result).exec() - } else { - dom.fields({ - node: true, - size: true, - rect: true - }, result).exec() - } - // #endif - // #ifdef APP-NVUE - if (context == null) { - reject('context is null') - return - } - const refs = context.refs || context.$refs - if (/#|\./.test(selector) && refs) { - selector = selector.replace(/#|\./, '') - if (refs[selector]) { - selector = refs[selector] - if(Array.isArray(selector)) { - selector = selector[0] - } - } - } - dom.getComponentRect(selector, (res) => { - if (res.size) { - resolve(res.size) - } else { - reject('no rect') - } - }) - // #endif - }); -}; - - -export function getAllRect(selector : string, context: ComponentInternalInstance|ComponentPublicInstance|null = null, node:boolean = false) { - if(context != null) { - // #ifdef MP || VUE2 - if (context.proxy) context = context.proxy - // #endif - } - return new Promise((resolve, reject) => { - // #ifndef APP-NVUE - const dom = context != null - ? uni.createSelectorQuery().in(context).selectAll(selector) - : uni.createSelectorQuery().selectAll(selector); - const result = (rect: UniNamespace.NodeInfo[]) => { - if (rect) { - resolve(rect) - } else { - reject('no rect') - } - } - if (!node) { - dom.boundingClientRect(result).exec() - } else { - dom.fields({ - node: true, - size: true, - rect: true - }, result).exec() - } - // #endif - // #ifdef APP-NVUE - if (context == null) { - reject('context is null') - return - } - let { context } = options - if (/#|\./.test(selector) && context.refs) { - selector = selector.replace(/#|\./, '') - if (context.refs[selector]) { - selector = context.refs[selector] - if(Array.isArray(selector)) { - selector = selector[0] - } - } - } - dom.getComponentRect(selector, (res) => { - if (res.size) { - resolve([res.size]) - } else { - reject('no rect') - } - }) - // #endif - }); -}; \ No newline at end of file diff --git a/uni_modules/lime-shared/getStyleStr/index.ts b/uni_modules/lime-shared/getStyleStr/index.ts deleted file mode 100644 index 665941c..0000000 --- a/uni_modules/lime-shared/getStyleStr/index.ts +++ /dev/null @@ -1,54 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X && APP -interface CSSProperties { - [key : string] : string | number | null -} -// #endif - -// #ifdef VUE3 -// #ifdef UNI-APP-X && APP -type CSSProperties = UTSJSONObject -// #endif -// #endif -/** - * 将字符串转换为带有连字符分隔的小写形式 - * @param key - 要转换的字符串 - * @returns 转换后的字符串 - */ -export function toLowercaseSeparator(key : string):string { - return key.replace(/([A-Z])/g, '-$1').toLowerCase(); -} - -/** - * 获取样式对象对应的样式字符串 - * @param style - CSS样式对象 - * @returns 由非空有效样式属性键值对组成的字符串 - */ -export function getStyleStr(style : CSSProperties) : string { - - // #ifdef UNI-APP-X && APP - let styleStr = ''; - style.toMap().forEach((value, key) => { - if(value !== null && value != '') { - styleStr += `${toLowercaseSeparator(key as string)}: ${value};` - } - }) - return styleStr - // #endif - // #ifndef UNI-APP-X && APP - return Object.keys(style) - .filter( - (key) => - style[key] !== undefined && - style[key] !== null && - style[key] !== '') - .map((key : string) => `${toLowercaseSeparator(key)}: ${style[key]};`) - .join(' '); - // #endif -} - -// 示例 -// const style = { color: 'red', fontSize: '16px', backgroundColor: '', border: null }; -// const styleStr = getStyleStr(style); -// console.log(styleStr); -// 输出: "color: red; font-size: 16px;" \ No newline at end of file diff --git a/uni_modules/lime-shared/getWindowInfo/index.ts b/uni_modules/lime-shared/getWindowInfo/index.ts deleted file mode 100644 index 550f37f..0000000 --- a/uni_modules/lime-shared/getWindowInfo/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -export function getWindowInfo():GetWindowInfoResult { - // #ifndef UNI-APP-X && APP - if (uni.getWindowInfo || uni.canIUse('getWindowInfo')) { - return uni.getWindowInfo(); - } else { - return uni.getSystemInfoSync(); - } - // #endif - // #ifdef UNI-APP-X && APP - return uni.getWindowInfo() - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/guid/index.ts b/uni_modules/lime-shared/guid/index.ts deleted file mode 100644 index f963cb3..0000000 --- a/uni_modules/lime-shared/guid/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -// @ts-nocheck -/** - * 生成指定长度的伪随机字符串,通常用作唯一标识符(非标准GUID) - * - * 此函数使用Math.random()生成基于36进制(数字+小写字母)的随机字符串。当长度超过11位时, - * 会通过递归拼接多个随机段实现。注意:该方法生成的并非标准GUID/UUID,不适合高安全性场景。 - * - * @param {number} [len=32] - 要生成的字符串长度,默认32位 - * @returns {string} 生成的伪随机字符串,包含0-9和a-z字符 - * - * @example - * guid(); // 返回32位字符串,例如"3zyf6a5f3kb4ayy9jq9v1a70z0qdm0bk" - * guid(5); // 返回5位字符串,例如"kf3a9" - * guid(20); // 返回20位字符串,由两段随机字符串拼接而成 - * - * @note - * 1. 由于使用Math.random(),随机性存在安全缺陷,不适用于密码学用途 - * 2. 当长度>11时采用递归拼接,可能略微影响性能(在极端大长度情况下) - * 3. 字符串补全时使用'0'填充,可能略微降低末尾字符的随机性 - */ -export function guid(len : number = 32) : string { - // crypto.randomUUID(); - // #ifdef WEB - if (typeof crypto !== 'undefined' && crypto.randomUUID) { - const uuid = crypto.randomUUID().replace(/-/g, ''); - return len === 32 ? uuid : uuid.substring(0, len); - } - // #endif - - return len <= 11 - ? Math.random() - .toString(36) - .substring(2, 2 + len) - .padEnd(len, '0') - : guid(11) + guid(len - 11); -} \ No newline at end of file diff --git a/uni_modules/lime-shared/hasOwn/index.ts b/uni_modules/lime-shared/hasOwn/index.ts deleted file mode 100644 index 4d677d5..0000000 --- a/uni_modules/lime-shared/hasOwn/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @ts-nocheck -// #ifdef UNI-APP-X && APP -export { hasOwn } from './uvue' -// #endif - - -// #ifndef UNI-APP-X && APP -export { hasOwn } from './vue' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/hasOwn/uvue.ts b/uni_modules/lime-shared/hasOwn/uvue.ts deleted file mode 100644 index 553ccdd..0000000 --- a/uni_modules/lime-shared/hasOwn/uvue.ts +++ /dev/null @@ -1,43 +0,0 @@ -// @ts-nocheck -/** - * 检查对象或数组是否具有指定的属性或键 - * @param obj 要检查的对象或数组 - * @param key 指定的属性或键 - * @returns 如果对象或数组具有指定的属性或键,则返回true;否则返回false - */ -function hasOwn(obj: UTSJSONObject, key: string): boolean -function hasOwn(obj: Map, key: string): boolean -function hasOwn(obj: any, key: string): boolean { - if(obj instanceof UTSJSONObject){ - return obj[key] != null - } - if(obj instanceof Map){ - return (obj as Map).has(key) - } - if(typeof obj == 'object') { - const obj2 = {...toRaw(obj)} - return obj2[key] != null - } - return false -} -export { - hasOwn -} -// 示例 -// const obj = { name: 'John', age: 30 }; - -// if (hasOwn(obj, 'name')) { -// console.log("对象具有 'name' 属性"); -// } else { -// console.log("对象不具有 'name' 属性"); -// } -// // 输出: 对象具有 'name' 属性 - -// const arr = [1, 2, 3]; - -// if (hasOwn(arr, 'length')) { -// console.log("数组具有 'length' 属性"); -// } else { -// console.log("数组不具有 'length' 属性"); -// } -// 输出: 数组具有 'length' 属性 \ No newline at end of file diff --git a/uni_modules/lime-shared/hasOwn/uvue.uts b/uni_modules/lime-shared/hasOwn/uvue.uts deleted file mode 100644 index 553ccdd..0000000 --- a/uni_modules/lime-shared/hasOwn/uvue.uts +++ /dev/null @@ -1,43 +0,0 @@ -// @ts-nocheck -/** - * 检查对象或数组是否具有指定的属性或键 - * @param obj 要检查的对象或数组 - * @param key 指定的属性或键 - * @returns 如果对象或数组具有指定的属性或键,则返回true;否则返回false - */ -function hasOwn(obj: UTSJSONObject, key: string): boolean -function hasOwn(obj: Map, key: string): boolean -function hasOwn(obj: any, key: string): boolean { - if(obj instanceof UTSJSONObject){ - return obj[key] != null - } - if(obj instanceof Map){ - return (obj as Map).has(key) - } - if(typeof obj == 'object') { - const obj2 = {...toRaw(obj)} - return obj2[key] != null - } - return false -} -export { - hasOwn -} -// 示例 -// const obj = { name: 'John', age: 30 }; - -// if (hasOwn(obj, 'name')) { -// console.log("对象具有 'name' 属性"); -// } else { -// console.log("对象不具有 'name' 属性"); -// } -// // 输出: 对象具有 'name' 属性 - -// const arr = [1, 2, 3]; - -// if (hasOwn(arr, 'length')) { -// console.log("数组具有 'length' 属性"); -// } else { -// console.log("数组不具有 'length' 属性"); -// } -// 输出: 数组具有 'length' 属性 \ No newline at end of file diff --git a/uni_modules/lime-shared/hasOwn/vue.ts b/uni_modules/lime-shared/hasOwn/vue.ts deleted file mode 100644 index 7317879..0000000 --- a/uni_modules/lime-shared/hasOwn/vue.ts +++ /dev/null @@ -1,30 +0,0 @@ -// @ts-nocheck -const hasOwnProperty = Object.prototype.hasOwnProperty -/** - * 检查对象或数组是否具有指定的属性或键 - * @param obj 要检查的对象或数组 - * @param key 指定的属性或键 - * @returns 如果对象或数组具有指定的属性或键,则返回true;否则返回false - */ -export function hasOwn(obj: Object | Array, key: string): boolean { - return hasOwnProperty.call(obj, key); -} - -// 示例 -// const obj = { name: 'John', age: 30 }; - -// if (hasOwn(obj, 'name')) { -// console.log("对象具有 'name' 属性"); -// } else { -// console.log("对象不具有 'name' 属性"); -// } -// // 输出: 对象具有 'name' 属性 - -// const arr = [1, 2, 3]; - -// if (hasOwn(arr, 'length')) { -// console.log("数组具有 'length' 属性"); -// } else { -// console.log("数组不具有 'length' 属性"); -// } -// 输出: 数组具有 'length' 属性 \ No newline at end of file diff --git a/uni_modules/lime-shared/index.ts b/uni_modules/lime-shared/index.ts deleted file mode 100644 index 2eb1d94..0000000 --- a/uni_modules/lime-shared/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -// @ts-nocheck -// validator -// export * from './isString' -// export * from './isNumber' -// export * from './isNumeric' -// export * from './isDef' -// export * from './isFunction' -// export * from './isObject' -// export * from './isPromise' -// export * from './isBase64' - -// export * from './hasOwn' - -// // 单位转换 -// export * from './addUnit' -// export * from './unitConvert' -// export * from './toNumber' - -// export * from './random' -// export * from './range' -// export * from './fillZero' - -// // image -// export * from './base64ToPath' -// export * from './pathToBase64' -// export * from './exif' - -// // canvas -// export * from './canIUseCanvas2d' - -// // page -// export * from './getCurrentPage' - -// // dom -// export * from './getRect' -// export * from './selectComponent' -// export * from './createAnimation' - -// // delay -// export * from './sleep' -// export * from './debounce' -// export * from './throttle' - diff --git a/uni_modules/lime-shared/index.uts b/uni_modules/lime-shared/index.uts deleted file mode 100644 index e69de29..0000000 diff --git a/uni_modules/lime-shared/isBase64/index.ts b/uni_modules/lime-shared/isBase64/index.ts deleted file mode 100644 index 53e065d..0000000 --- a/uni_modules/lime-shared/isBase64/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -// @ts-nocheck - -/** - * 判断一个字符串是否为Base64编码。 - * Base64编码的字符串只包含A-Z、a-z、0-9、+、/ 和 = 这些字符。 - * @param {string} str - 要检查的字符串。 - * @returns {boolean} 如果字符串是Base64编码,返回true,否则返回false。 - */ -export function isBase64(str: string): boolean { - const base64Regex = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; - return base64Regex.test(str); -} - -/** - * 判断一个字符串是否为Base64编码的data URI。 - * Base64编码的data URI通常以"data:"开头,后面跟着MIME类型和编码信息,然后是Base64编码的数据。 - * @param {string} str - 要检查的字符串。 - * @returns {boolean} 如果字符串是Base64编码的data URI,返回true,否则返回false。 - */ -export function isDataURI(str: string): boolean { - const dataUriRegex = /^data:([a-zA-Z]+\/[a-zA-Z0-9-+.]+)(;base64)?,([a-zA-Z0-9+/]+={0,2})$/; - return dataUriRegex.test(str); -} \ No newline at end of file diff --git a/uni_modules/lime-shared/isBoolean/index.ts b/uni_modules/lime-shared/isBoolean/index.ts deleted file mode 100644 index 93db565..0000000 --- a/uni_modules/lime-shared/isBoolean/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// @ts-nocheck -/** - * 检查一个值是否为严格的布尔值(仅限 `true` 或 `false`) - * - * @example - * isBoolean(true); // true - * isBoolean(false); // true - * isBoolean(0); // false - * isBoolean(null); // false - * - * @param {unknown} value - 要检查的值 - * @returns {value is boolean} 如果值是 `true` 或 `false` 则返回 `true`,否则返回 `false` - * - * @description - * 此函数使用严格相等(`===`)检查,避免隐式类型转换。 - * 注意:不适用于 `Boolean` 包装对象(如 `new Boolean(true)`)。 - */ -export function isBoolean(value: any|null): boolean { - // #ifdef APP-ANDROID - return value == true || value == false - // #endif - // #ifndef APP-ANDROID - return value === true || value === false - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/isBrowser/index.ts b/uni_modules/lime-shared/isBrowser/index.ts deleted file mode 100644 index 6baee2b..0000000 --- a/uni_modules/lime-shared/isBrowser/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-nocheck -// #ifdef WEB -export const isBrowser = typeof window !== 'undefined'; -// #endif - -// #ifndef WEB -export const isBrowser = false; -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/isByteLength/index.ts b/uni_modules/lime-shared/isByteLength/index.ts deleted file mode 100644 index 73774d8..0000000 --- a/uni_modules/lime-shared/isByteLength/index.ts +++ /dev/null @@ -1,86 +0,0 @@ -// @ts-nocheck -// import assertString from './util/assertString'; - -/** - * 字节长度验证配置选项 - */ -export type IsByteLengthOptions = { - /** 允许的最小字节长度 */ - min ?: number; - /** 允许的最大字节长度 */ - max ?: number; -} - -/** - * 检查字符串字节长度是否在指定范围内 - * @function - * @overload 使用配置对象 - * @param str - 要检查的字符串 - * @param options - 配置选项对象 - * @returns 是否满足字节长度要求 - * - * @overload 使用独立参数 - * @param str - 要检查的字符串 - * @param min - 最小字节长度 - * @param max - 最大字节长度(可选) - * @returns 是否满足字节长度要求 - * - * @example - * // 使用配置对象 - * isByteLength('🇨🇳', { min: 4, max: 8 }); // true(unicode 国旗符号占 8 字节) - * - * @example - * // 旧式参数调用 - * isByteLength('hello', 3, 7); // true(实际字节长度 5) - * - * @description - * 1. 使用 URL 编码计算字节长度(更准确处理多字节字符) - * 2. 同时支持两种参数格式: - * - 配置对象格式 { min, max } - * - 独立参数格式 (min, max) - * 3. 不传 max 参数时只验证最小长度 - * 4. 严格空值处理,允许设置 0 值 - */ -export function isByteLength(str : string, optionsOrMin ?: IsByteLengthOptions) : boolean; -export function isByteLength(str : string, optionsOrMin ?: number) : boolean; -export function isByteLength(str : string, optionsOrMin : number, maxParam : number | null) : boolean; -export function isByteLength( - str : string, - optionsOrMin ?: IsByteLengthOptions | number, - maxParam : number | null = null -) : boolean { - // assertString(str); - - /** 最终计算的最小长度 */ - let min: number; - - /** 最终计算的最大长度 */ - let max : number | null; - - // 参数逻辑处理 - if (optionsOrMin != null && typeof optionsOrMin == 'object') { - // 使用对象配置的情况 - const options = optionsOrMin as IsByteLengthOptions; - min = Math.max(options.min ?? 0, 0); // 确保最小值为正整数 - max = options.max; - } else { - // 使用独立参数的情况 - min = Math.max( - typeof optionsOrMin == 'number' ? optionsOrMin : 0, - 0 - ); - max = maxParam; - } - - // URL 编码后的字节长度计算 - const encoded = encodeURI(str); - const len = (encoded?.split(/%..|./).length ?? 0) - 1; - - // 执行验证逻辑 - // #ifndef APP-ANDROID - return len >= min && (typeof max == 'undefined' || len <= (max ?? 0)); - // #endif - // #ifdef APP-ANDROID - return len >= min && (max == null || len <= max); - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/isDate/index.ts b/uni_modules/lime-shared/isDate/index.ts deleted file mode 100644 index 7ed893c..0000000 --- a/uni_modules/lime-shared/isDate/index.ts +++ /dev/null @@ -1,189 +0,0 @@ -// @ts-nocheck - -/** - * 日期验证配置选项 - */ -export type IsDateOptions = { - /** 日期格式字符串,默认 'YYYY/MM/DD' */ - format ?: string; - /** 允许的分隔符数组,默认 ['/', '-'] */ - delimiters ?: string[]; - /** 是否严格匹配格式,默认 false */ - strictMode ?: boolean; -} - -/** - * 验证日期格式字符串是否合法 - * @param format - 需要验证的格式字符串 - * @returns 是否合法格式 - */ -function isValidFormat(format : string) : boolean { - return /(^(y{4}|y{2})[年./-](m{1,2})[月./-](d{1,2}(日)?)$)|(^(m{1,2})[./-](d{1,2})[./-]((y{4}|y{2})$))|(^(d{1,2})[./-](m{1,2})[./-]((y{4}|y{2})$))/i.test(format); -} - -/** - * 将日期部分和格式部分组合成键值对数组 - * @param date - 分割后的日期部分数组 - * @param format - 分割后的格式部分数组 - * @returns 组合后的二维数组 - */ -function zip(date : string[], format : string[]) : string[][] { - const zippedArr : string[][] = []; - const len = Math.max(date.length, format.length); - - for (let i = 0; i < len; i++) { - const key = i < date.length ? date[i] : '' - const value = i < format.length ? format[i] : '' - - zippedArr.push([key, value]) - } - - return zippedArr; -} - - -/** 验证日期对象 */ -function validateDateObject(date : Date, strictMode : boolean) : boolean { - // #ifndef APP-ANDROID - return !strictMode && Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime()); - // #endif - // #ifdef APP-ANDROID - return !strictMode && !isNaN(date.getTime()) - // #endif -} - - -function escapeRegExp(str: string): string { - return str//.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); -} - -function enhancedSplit( - str: string, - delimiters: string[] -): string[] { - // 构建动态分隔符正则表达式 - const escapedDelimiters = delimiters.map(d => escapeRegExp(d)); - const pattern = new RegExp( - `[${escapedDelimiters.join('')}]+`, // 匹配任意允许的分隔符 - 'g' - ); - - return str.split(pattern).filter(p => p != ''); -} - -/** - * 验证输入是否为有效日期 - * @param input - 输入值,可以是字符串或 Date 对象 - * @param options - 配置选项,可以是字符串(简写格式)或配置对象 - * @returns 是否为有效日期 - * - * @example - * isDate('2023/12/31'); // true - * isDate(new Date()); // true - * isDate('02-29-2023', { strictMode: true }); // false(2023年不是闰年) - */ -export function isDate(input : Date, options ?: IsDateOptions) : boolean; -export function isDate(input : string, options ?: string | IsDateOptions) : boolean; -export function isDate(input : string | Date, options : string | IsDateOptions | null = null) : boolean { - // 处理参数重载:允许第二个参数直接传格式字符串 - // Date对象验证 - - - let format = 'YYYY/MM/DD' - let delimiters = ['/', '-'] - let strictMode = false - - - if (options != null) { - if (typeof options == 'string') { - format = options as string - } else { - format = (options as IsDateOptions).format ?? format - delimiters = (options as IsDateOptions).delimiters ?? delimiters - strictMode = (options as IsDateOptions).strictMode ?? strictMode - } - } - if (input instanceof Date) { - return validateDateObject(input, strictMode); - } - - - // 字符串类型验证 - if (!isValidFormat(format)) return false; - // 严格模式长度检查 - if (strictMode && input.length != format.length) { - return false; - } - // 获取格式中的分隔符 - const formatDelimiter = delimiters.find((d) : boolean => format.indexOf(d) != -1); - // 获取实际使用的分隔符 - const dateDelimiter = strictMode - ? formatDelimiter - : delimiters.find((d) : boolean => input.indexOf(d) != -1); - // 分割日期和格式 - const dateParts = strictMode ? enhancedSplit(input, delimiters) : input.split(dateDelimiter ?? ''); - const formatParts = strictMode ? enhancedSplit(format.toLowerCase(), delimiters) : format.toLowerCase().split(formatDelimiter ?? ''); - // 组合成键值对 - const dateAndFormat = zip(dateParts, formatParts); - const dateObj = new Map(); - - - // 解析日期组成部分 - for (const [dateWord, formatWord] of dateAndFormat) { - if (dateWord == '' || formatWord == '' || dateWord.length != formatWord.length) { - return false; - } - dateObj.set(formatWord.charAt(0), dateWord) - } - - // 年份处理 - let fullYear = dateObj.get('y'); - - if (fullYear == null) return false; - - // 检查年份前导负号 - if (fullYear.startsWith('-')) return false; - - // 两位年份转四位 - if (fullYear.length == 2) { - const parsedYear = parseInt(fullYear, 10); - - if (isNaN(parsedYear)) { - return false; - } - - const currentYear = new Date().getFullYear(); - const century = currentYear - (currentYear % 100); - fullYear = (parseInt(fullYear, 10) < (currentYear % 100)) - ? `${century + 100 + parseInt(fullYear, 10)}` - : `${century + parseInt(fullYear, 10)}`; - } - - // 月份补零 - const month = dateObj.get('m')?.padStart(2, '0') ?? ''; - // 日期补零 - const day = dateObj.get('d')?.padStart(2, '0') ?? ''; - - const isoDate = `${fullYear}-${month}-${day}T00:00:00.000Z`; - - // return new Date(time).getDate() == parseInt(day); - - // 构造 ISO 日期字符串验证 - try { - // #ifndef APP-ANDROID - const date = new Date(isoDate); - return date.getUTCDate() === parseInt(day, 10) && - (date.getUTCMonth() + 1) === parseInt(month, 10) && - date.getUTCFullYear() === parseInt(fullYear, 10); - // #endif - // #ifdef APP-ANDROID - const date = new Date(isoDate); - return date.getDate() == parseInt(day, 10) && - (date.getMonth() + 1) == parseInt(month, 10) && - date.getFullYear() == parseInt(fullYear, 10); - // #endif - } catch(e) { - return false; - } - -} \ No newline at end of file diff --git a/uni_modules/lime-shared/isDef/index.ts b/uni_modules/lime-shared/isDef/index.ts deleted file mode 100644 index f8ca9bc..0000000 --- a/uni_modules/lime-shared/isDef/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -// @ts-nocheck -/** - * 检查一个值是否已定义(不为 undefined)且不为 null - * @param value 要检查的值 - * @returns 如果值已定义且不为 null,则返回 true;否则返回 false - */ -// #ifndef UNI-APP-X -export function isDef(value: unknown): boolean { - return value !== undefined && value !== null; -} -// #endif - - -// #ifdef UNI-APP-X -export function isDef(value : any|null) : boolean { - // #ifdef UNI-APP-X && APP - return value != null; - // #endif - // #ifndef UNI-APP-X && APP - return value != null && value != undefined; - // #endif -} -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/isEmail/index.ts b/uni_modules/lime-shared/isEmail/index.ts deleted file mode 100644 index 01f78d4..0000000 --- a/uni_modules/lime-shared/isEmail/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// @ts-nocheck - -/** - * 验证电子邮件地址格式 - * @param email - 要验证的字符串 - * @returns 是否通过验证 - */ -export function isEmail(email : string) : boolean { - const emailRegex = /\S+@\S+\.\S+/; - return emailRegex.test(email); -} \ No newline at end of file diff --git a/uni_modules/lime-shared/isEmpty/index.ts b/uni_modules/lime-shared/isEmpty/index.ts deleted file mode 100644 index 2e89acb..0000000 --- a/uni_modules/lime-shared/isEmpty/index.ts +++ /dev/null @@ -1,81 +0,0 @@ -// @ts-nocheck -import {isDef} from '../isDef' -import {isString} from '../isString' -import {isNumber} from '../isNumber' -/** - * 判断一个值是否为空。 - * - * 对于字符串,去除首尾空格后判断长度是否为0。 - * 对于数组,判断长度是否为0。 - * 对于对象,判断键的数量是否为0。 - * 对于null或undefined,直接返回true。 - * 其他类型(如数字、布尔值等)默认不为空。 - * - * @param {any} value - 要检查的值。 - * @returns {boolean} 如果值为空,返回true,否则返回false。 - */ - - -// #ifdef UNI-APP-X && APP -export function isEmpty(value : any | null) : boolean { - // 为null - if(!isDef(value)){ - return true - } - // 为空字符 - if(isString(value)){ - return value.toString().trim().length == 0 - } - // 为数值 - if(isNumber(value)){ - return false - } - if(typeof value == 'object'){ - // 数组 - if(Array.isArray(value)){ - return (value as Array).length == 0 - } - // Map - if(value instanceof Map) { - return value.size == 0 - } - // Set - if(value instanceof Set) { - return value.size == 0 - } - if(value instanceof UTSJSONObject) { - return value.toMap().size == 0 - } - return JSON.stringify(value) == '{}' - } - return false -} -// #endif - - -// #ifndef UNI-APP-X && APP -export function isEmpty(value: any): boolean { - // 检查是否为null或undefined - if (value == null || value == undefined || value == '') { - return true; - } - - // 检查字符串是否为空 - if (typeof value === 'string') { - return value.trim().length === 0; - } - - // 检查数组是否为空 - if (Array.isArray(value)) { - return value.length === 0; - } - - // 检查对象是否为空 - if (typeof value === 'object') { - return Object.keys(value).length === 0; - } - - // 其他类型(如数字、布尔值等)不为空 - return false; -} -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/isFunction/index.ts b/uni_modules/lime-shared/isFunction/index.ts deleted file mode 100644 index 12605c3..0000000 --- a/uni_modules/lime-shared/isFunction/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// @ts-nocheck -/** - * 检查一个值是否为函数类型 - * @param val 要检查的值 - * @returns 如果值的类型是函数类型,则返回 true;否则返回 false - */ - -// #ifdef UNI-APP-X && APP -export const isFunction = (val: any):boolean => typeof val == 'function'; - // #endif - - -// #ifndef UNI-APP-X && APP -export const isFunction = (val: unknown): val is Function => - typeof val === 'function'; -// #endif diff --git a/uni_modules/lime-shared/isIP/index.ts b/uni_modules/lime-shared/isIP/index.ts deleted file mode 100644 index 6f4e964..0000000 --- a/uni_modules/lime-shared/isIP/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -// @ts-nocheck - -// #ifndef UNI-APP-X && APP -type UTSJSONObject = { - version : string | number | null; -}; -// #endif -// #ifdef UNI-APP-X && APP -// type Options = UTSJSONObject -// #endif - -const IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; -const IPv4AddressFormat = `(${IPv4SegmentFormat}\\.){3}${IPv4SegmentFormat}`; -const IPv4AddressRegExp = new RegExp(`^${IPv4AddressFormat}$`); - -const IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})'; -const IPv6AddressRegExp = new RegExp( - '^(' + - `(?:${IPv6SegmentFormat}:){7}(?:${IPv6SegmentFormat}|:)|` + - `(?:${IPv6SegmentFormat}:){6}(?:${IPv4AddressFormat}|:${IPv6SegmentFormat}|:)|` + - `(?:${IPv6SegmentFormat}:){5}(?::${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,2}|:)|` + - `(?:${IPv6SegmentFormat}:){4}(?:(:${IPv6SegmentFormat}){0,1}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,3}|:)|` + - `(?:${IPv6SegmentFormat}:){3}(?:(:${IPv6SegmentFormat}){0,2}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,4}|:)|` + - `(?:${IPv6SegmentFormat}:){2}(?:(:${IPv6SegmentFormat}){0,3}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,5}|:)|` + - `(?:${IPv6SegmentFormat}:){1}(?:(:${IPv6SegmentFormat}){0,4}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,6}|:)|` + - `(?::((?::${IPv6SegmentFormat}){0,5}:${IPv4AddressFormat}|(?::${IPv6SegmentFormat}){1,7}|:))` + - ')(%[0-9a-zA-Z.]{1,})?$' -); - - -/** - * 验证IP地址格式 - * @param {string} ipAddress - 要验证的IP地址 - * @param {Options|string|number} options - 配置选项或版本号 - * @returns {boolean} 是否匹配有效的IP地址格式 - */ -export function isIP(ipAddress : string | null, options : UTSJSONObject | string | number | null = null) : boolean { - // assertString(ipAddress); - if(ipAddress == null) return false - let version : string | number | null; - - if (typeof options == 'object') { - version = (options as UTSJSONObject|null)?.['version']; - } else { - version = options; - } - - const versionStr = version != null ? `${version}` : ''; - - if (versionStr == '') { - return isIP(ipAddress, 4) || isIP(ipAddress, 6); - } - - if (versionStr == '4') { - return IPv4AddressRegExp.test(ipAddress.trim()); - } - - if (versionStr == '6') { - return IPv6AddressRegExp.test(ipAddress.trim()); - } - - return false; -} - diff --git a/uni_modules/lime-shared/isNumber/index.ts b/uni_modules/lime-shared/isNumber/index.ts deleted file mode 100644 index 040bc11..0000000 --- a/uni_modules/lime-shared/isNumber/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -// @ts-nocheck -/** - * 检查一个值是否为数字类型 - * @param value 要检查的值,可以是 number 类型或 string 类型的数字 - * @returns 如果值是数字类型且不是 NaN,则返回 true;否则返回 false - */ - -// #ifndef UNI-APP-X -export function isNumber(value: number | string | null): boolean { - return typeof value === 'number' && !isNaN(value); -} -// #endif - -// #ifdef UNI-APP-X -export function isNumber(value: any|null): boolean { - // #ifdef APP-ANDROID - return ['Byte', 'UByte','Short','UShort','Int','UInt','Long','ULong','Float','Double','number'].includes(typeof value) - // #endif - // #ifdef APP-IOS - return ['Int8', 'UInt8','Int16','UInt16','Int32','UInt32','Int64','UInt64','Int','UInt','Float','Float16','Float32','Float64','Double', 'number'].includes(typeof value) - // #endif - // #ifndef APP-ANDROID || APP-IOS - return typeof value === 'number' && !isNaN(value); - // #endif -} -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/isNumeric/index.ts b/uni_modules/lime-shared/isNumeric/index.ts deleted file mode 100644 index af5020e..0000000 --- a/uni_modules/lime-shared/isNumeric/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -// @ts-nocheck - -/** - * 检查一个值是否为数字类型或表示数字的字符串 - * @param value 要检查的值,可以是 string 类型或 number 类型 - * @returns 如果值是数字类型或表示数字的字符串,则返回 true;否则返回 false - */ - -// #ifndef UNI-APP-X && APP -export function isNumeric(value: string | number | undefined | null): boolean { - return /^(-)?\d+(\.\d+)?$/.test(value); -} -// #endif - - -// #ifdef UNI-APP-X && APP -import {isNumber} from '../isNumber'; -import {isString} from '../isString'; -export function isNumeric(value : any|null) : boolean { - if(value == null) { - return false - } - if(isNumber(value)) { - return true - } else if(isString(value)) { - // const regex = "-?\\d+(\\.\\d+)?".toRegex() - const regex = new RegExp("^(-)?\\d+(\\.\\d+)?$") - return regex.test(value as string) //regex.matches(value as string) - } - return false - // return /^(-)?\d+(\.\d+)?$/.test(value); -} -// #endif diff --git a/uni_modules/lime-shared/isObject/index.ts b/uni_modules/lime-shared/isObject/index.ts deleted file mode 100644 index 26fec28..0000000 --- a/uni_modules/lime-shared/isObject/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// @ts-nocheck -/** - * 检查一个值是否为对象类型 - * @param val 要检查的值 - * @returns 如果值的类型是对象类型,则返回 true;否则返回 false - */ - -// #ifndef APP-ANDROID -export const isObject = (val : unknown) : val is Record => - val !== null && typeof val === 'object'; - -// #endif - - -// #ifdef APP-ANDROID -export const isObject = (val : any | null) : boolean =>{ - return val != null && typeof val == 'object'; -} -// #endif diff --git a/uni_modules/lime-shared/isPromise/index.ts b/uni_modules/lime-shared/isPromise/index.ts deleted file mode 100644 index b13c10b..0000000 --- a/uni_modules/lime-shared/isPromise/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -// @ts-nocheck -import {isFunction} from '../isFunction' -import {isObject} from '../isObject' -/** - * 检查一个值是否为 Promise 类型 - * @param val 要检查的值 - * @returns 如果值的类型是 Promise 类型,则返回 true;否则返回 false - */ -// #ifndef APP-ANDROID -export const isPromise = (val: unknown): val is Promise => { - // 使用 isObject 函数判断值是否为对象类型 - // 使用 isFunction 函数判断值是否具有 then 方法和 catch 方法 - return isObject(val) && isFunction(val.then) && isFunction(val.catch); -}; -// #endif - - -// #ifdef APP-ANDROID -export const isPromise = (val: any): boolean => { - return val instanceof Promise -}; -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/isRegExp/index.ts b/uni_modules/lime-shared/isRegExp/index.ts deleted file mode 100644 index 8aaefdf..0000000 --- a/uni_modules/lime-shared/isRegExp/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -// @ts-nocheck -/** - * 检测输入值是否为正则表达式对象 - * @param obj - 需要检测的任意类型值 - * @returns 如果检测值是正则表达式返回 true,否则返回 false - * - * @example - * // 基础检测 - * isRegExp(/abc/); // true - * isRegExp(new RegExp('abc')); // true - * - * @example - * // 非正则表达式检测 - * isRegExp('hello'); // false - * isRegExp({}); // false - * isRegExp(null); // false - * - * @description - * 1. 通过 Object.prototype.toString 的可靠类型检测 - * 2. 支持跨执行环境的可靠检测: - * - 浏览器多 iframe 环境 - * - Node.js 的 vm 模块 - * 3. 比 instanceof 检测更可靠 - * 4. 支持 ES3+ 全环境兼容 - */ -export function isRegExp(obj : any) : boolean { - // #ifndef APP-ANDROID - return Object.prototype.toString.call(obj) === '[object RegExp]'; - // #endif - // #ifdef APP-ANDROID - return obj instanceof RegExp//Object.prototype.toString.call(obj) === '[object RegExp]'; - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/isString/index.ts b/uni_modules/lime-shared/isString/index.ts deleted file mode 100644 index 143f876..0000000 --- a/uni_modules/lime-shared/isString/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// @ts-nocheck -/** - * 检查一个值是否为字符串类型 - * @param str 要检查的值 - * @returns 如果值的类型是字符串类型,则返回 true;否则返回 false - */ -// #ifndef UNI-APP-X && APP -// export const isString = (str: unknown): str is string => typeof str === 'string'; -export function isString (str: unknown): str is string { - return typeof str == 'string' -} -// #endif - - -// #ifdef UNI-APP-X && APP -export function isString (str: any|null): boolean { - return typeof str == 'string' -} -// #endif diff --git a/uni_modules/lime-shared/isURL/index.ts b/uni_modules/lime-shared/isURL/index.ts deleted file mode 100644 index 4121143..0000000 --- a/uni_modules/lime-shared/isURL/index.ts +++ /dev/null @@ -1,198 +0,0 @@ -// @ts-nocheck -import { isValidDomain, type IsValidDomainOptions } from '../isValidDomain'; -import { isIP } from '../isIP'; -import { isRegExp } from '../isRegExp'; -// import {merge} from '../merge'; - -/** URL 验证配置选项 */ -export type IsURLOptions = { - /** 允许的协议列表(默认 ['http', 'https', 'ftp']) */ - protocols ?: string[]; - /** 需要顶级域名(默认 true) */ - requireTld ?: boolean; - /** 需要协议头(默认 false) */ - requireProtocol ?: boolean; - /** 需要主机地址(默认 true) */ - requireHost ?: boolean; - /** 需要端口号(默认 false) */ - requirePort ?: boolean; - /** 需要有效协议(默认 true) */ - requireValidProtocol ?: boolean; - /** 允许下划线(默认 false) */ - allowUnderscores ?: boolean; - /** 允许结尾点号(默认 false) */ - allowTrailingDot ?: boolean; - /** 允许协议相对地址(默认 false) */ - allowProtocolRelativeUrls ?: boolean; - /** 允许片段标识(默认 true) */ - allowFragments ?: boolean; - /** 允许查询参数(默认 true) */ - allowQueryComponents ?: boolean; - /** 禁用认证信息(默认 false) */ - disallowAuth ?: boolean; - /** 验证长度(默认 true) */ - validateLength ?: boolean; - /** 最大允许长度(默认 2084) */ - maxAllowedLength ?: number; - /** 白名单主机列表 */ - hostWhitelist ?: Array; - /** 黑名单主机列表 */ - hostBlacklist ?: Array; -} - -export function checkHost(host : string, matches : any[]) : boolean { - for (let i = 0; i < matches.length; i++) { - let match = matches[i]; - if (host == match || (isRegExp(match) && (match as RegExp).test(host))) { - return true; - } - } - return false; -} - -// 辅助函数 -function isValidPort(port : number | null) : boolean { - return port != null && !isNaN(port) && port > 0 && port <= 65535; -} - -function validateHost(host : string, options : IsURLOptions | null, isIPv6 : boolean) : boolean { - if (isIPv6) return isIP(host, 6); - return isIP(host) || isValidDomain(host, { - requireTld: options?.requireTld ?? true, - allowUnderscore: options?.allowUnderscores ?? true, - allowTrailingDot: options?.allowTrailingDot ?? false - } as IsValidDomainOptions); -} - - - - -/** 匹配 IPv6 地址的正则表达式 */ -const WRAPPED_IPV6_REGEX = /^\[([^\]]+)\](?::([0-9]+))?$/; - -/** - * 验证字符串是否为有效的 URL - * @param url - 需要验证的字符串 - * @param options - 配置选项 - * @returns 是否为有效 URL - * - * @example - * ```typescript - * isURL('https://example.com'); // true - * isURL('user:pass@example.com', { disallowAuth: true }); // false - * ``` - */ -export function isURL(url : string | null, options : IsURLOptions | null = null) : boolean { - // assertString(url); - - // 1. 基础格式校验 - if (url == null || url == '' || url.length == 0 || /[\s<>]/.test(url) || url.startsWith('mailto:')) { - return false; - } - // 合并配置选项 - let protocols = options?.protocols ?? ['http', 'https', 'ftp'] - // let requireTld = options?.requireTld ?? true - let requireProtocol = options?.requireProtocol ?? false - let requireHost = options?.requireHost ?? true - let requirePort = options?.requirePort ?? false - let requireValidProtocol = options?.requireValidProtocol ?? true - // let allowUnderscores = options?.allowUnderscores ?? false - // let allowTrailingDot = options?.allowTrailingDot ?? false - let allowProtocolRelativeUrls = options?.allowProtocolRelativeUrls ?? false - let allowFragments = options?.allowFragments ?? true - let allowQueryComponents = options?.allowQueryComponents ?? true - let validateLength = options?.validateLength ?? true - let maxAllowedLength = options?.maxAllowedLength ?? 2084 - let hostWhitelist = options?.hostWhitelist - let hostBlacklist = options?.hostBlacklist - let disallowAuth = options?.disallowAuth ?? false - - - // 2. 长度校验 - if (validateLength && url!.length > maxAllowedLength) { - return false; - } - // 3. 片段和查询参数校验 - if (!allowFragments && url.includes('#')) return false; - if (!allowQueryComponents && (url.includes('?') || url.includes('&'))) return false; - - // 处理 URL 组成部分 - const [urlWithoutFragment] = url.split('#'); - const [baseUrl] = urlWithoutFragment.split('?'); - // 4. 协议处理 - const protocolParts = baseUrl.split('://'); - let protocol:string; - let remainingUrl = baseUrl; - - if (protocolParts.length > 1) { - protocol = protocolParts.shift()!.toLowerCase(); - if (requireValidProtocol && !protocols!.includes(protocol)) { - return false; - } - remainingUrl = protocolParts.join('://'); - } else if (requireProtocol) { - return false; - } else if (baseUrl.startsWith('//')) { - if (!allowProtocolRelativeUrls) return false; - remainingUrl = baseUrl.slice(2); - } - - if (remainingUrl == '') return false; - - // 5. 处理主机部分 - const [hostPart] = remainingUrl.split('/', 1); - const authParts = hostPart.split('@'); - - // 认证信息校验 - if (authParts.length > 1) { - if (disallowAuth || authParts[0] == '') return false; - const auth = authParts.shift()!; - if (auth.split(':').length > 2) return false; - const [user, password] = auth.split(':'); - if (user == '' && password == '') return false; - } - - const hostname = authParts.join('@'); - - // 6. 解析主机和端口 - type HostInfo = { - host ?: string; - ipv6 ?: string; - port ?: number; - }; - - const hostInfo : HostInfo = {}; - const ipv6Match = hostname.match(WRAPPED_IPV6_REGEX); - if (ipv6Match != null) { - hostInfo.ipv6 = ipv6Match.length > 1 ? ipv6Match[1] : null; - const portStr = ipv6Match.length > 2 ? ipv6Match[2] : null; - if (portStr != null) { - hostInfo.port = parseInt(portStr); - if (!isValidPort(hostInfo.port)) return false; - } - } else { - const [host, ...portParts] = hostname.split(':'); - hostInfo.host = host; - if (portParts.length > 0) { - const portStr = portParts.join(':'); - hostInfo.port = parseInt(portStr); - if (!isValidPort(hostInfo.port)) return false; - } - } - - // 7. 端口校验 - if (requirePort && hostInfo.port == null) return false; - // 8. 主机验证逻辑 - const finalHost = hostInfo.host ?? hostInfo.ipv6; - if (finalHost == null) return requireHost ? false : true; - // 白名单/黑名单检查 - if (hostWhitelist != null && !checkHost(finalHost!, hostWhitelist!)) return false; - if (hostBlacklist != null && checkHost(finalHost!, hostBlacklist!)) return false; - - // 9. 综合校验 - return validateHost( - finalHost, - options, - !(hostInfo.ipv6 == null || hostInfo.ipv6 == '') - ); -} \ No newline at end of file diff --git a/uni_modules/lime-shared/isValidDomain/index.ts b/uni_modules/lime-shared/isValidDomain/index.ts deleted file mode 100644 index 40c717f..0000000 --- a/uni_modules/lime-shared/isValidDomain/index.ts +++ /dev/null @@ -1,90 +0,0 @@ -// @ts-nocheck -/** - * 域名验证配置选项 - */ -export type IsValidDomainOptions = { - /** - * 是否要求必须包含顶级域名(TLD) - * @default true - * @example - * true -> "example.com" 有效 - * false -> "localhost" 有效 - */ - requireTld : boolean; - - /** - * 是否允许域名部分包含下划线(_) - * @default false - * @example - * true -> "my_site.com" 有效 - * false -> "my_site.com" 无效 - */ - allowUnderscore : boolean; - - /** - * 是否允许域名以点号(.)结尾 - * @default false - * @example - * true -> "example.com." 有效 - * false -> "example.com." 无效 - */ - allowTrailingDot : boolean; -} - - -/** - * 验证字符串是否为合法域名 - * @param str 要验证的字符串 - * @param options 配置选项,默认 { - * requireTld: true, // 需要顶级域名 - * allowUnderscore: false,// 允许下划线 - * allowTrailingDot: false// 允许结尾点号 - * } - * @returns 验证结果 - * - * 示例: - * isValidDomain("example.com") // true - * isValidDomain("my_site.com", { allowUnderscore: true }) // true - */ -export function isValidDomain( - str : string, - options : IsValidDomainOptions = { - requireTld: true, - allowUnderscore: false, - allowTrailingDot: false - } -) : boolean { - // 预处理字符串 - let domain = str; - - // 处理结尾点号 - if (options.allowTrailingDot && domain.endsWith('.')) { - domain = domain.slice(0, -1); - } - - // 分割域名部分 - const parts = domain.split('.'); - if (parts.length == 1 && options.requireTld) return false; - - // 验证顶级域名 - const tld = parts[parts.length - 1]; - if (options.requireTld) { - if (!/^[a-z\u00A1-\uFFFF]{2,}$/i.test(tld) || /\s/.test(tld)) { - return false; - } - } - - // 验证每个部分 - const domainRegex = options.allowUnderscore - ? /^[a-z0-9\u00A1-\uFFFF](?:[a-z0-9-\u00A1-\uFFFF_]*[a-z0-9\u00A1-\uFFFF])?$/i - : /^[a-z0-9\u00A1-\uFFFF](?:[a-z0-9-\u00A1-\uFFFF]*[a-z0-9\u00A1-\uFFFF])?$/i; - - return parts.every(part => { - // 长度校验 - if (part.length > 63) return false; - // 格式校验 - if (!domainRegex.test(part)) return false; - // 禁止开头/结尾连字符 - return !(part.startsWith('-') || part.endsWith('-')); - }); -} \ No newline at end of file diff --git a/uni_modules/lime-shared/kebabCase/index.ts b/uni_modules/lime-shared/kebabCase/index.ts deleted file mode 100644 index bed6b1f..0000000 --- a/uni_modules/lime-shared/kebabCase/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -// @ts-nocheck -// export function toLowercaseSeparator(key: string) { -// return key.replace(/([A-Z])/g, '-$1').toLowerCase(); -// } - -/** - * 将字符串转换为指定连接符的命名约定 - * @param str 要转换的字符串 - * @param separator 指定的连接符,默认为 "-" - * @returns 转换后的字符串 - */ -export function kebabCase(str : string, separator : string = "-") : string { - return str - - // #ifdef APP-ANDROID - .replace(/[A-Z]/g, (match : string, _ : number, _ : string) : string => `${separator}${match.toLowerCase()}`) // 将大写字母替换为连接符加小写字母 - // #endif - // #ifndef APP-ANDROID - .replace(/[A-Z]/g, (match : string) : string => `${separator}${match.toLowerCase()}`) // 将大写字母替换为连接符加小写字母 - // #endif - .replace(/[\s_-]+/g, separator) // 将空格、下划线和短横线替换为指定连接符 - .replace(new RegExp(`^${separator}|${separator}$`, "g"), "") // 删除开头和结尾的连接符 - .toLowerCase(); // 将结果转换为全小写 -} \ No newline at end of file diff --git a/uni_modules/lime-shared/merge/index.ts b/uni_modules/lime-shared/merge/index.ts deleted file mode 100644 index b4dcf14..0000000 --- a/uni_modules/lime-shared/merge/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -// @ts-nocheck -/** - * 深度合并两个对象,用默认值填充目标对象中未定义的属性 - * - * @template T - 合并对象的泛型类型 - * @param {T} obj - 目标对象(将被修改) - * @param {T} defaults - 包含默认值的对象 - * @returns {T} 合并后的对象(即修改后的obj参数) - */ - -export function merge(obj : T, defaults : T) : T { - // #ifdef APP-ANDROID - try { - if(obj instanceof UTSJSONObject && defaults instanceof UTSJSONObject) { - return UTSJSONObject.assign(obj, defaults)!// as T - } - const obj1 = { ...toRaw(obj) } - const obj2 = { ...toRaw(defaults) } - return UTSJSONObject.assign(obj1, obj2)! - } catch (error) { - return defaults - } - // #endif - - // #ifndef APP-ANDROID - for (const key in defaults) { - if (obj[key] === undefined || obj[key] === null) { - obj[key] = defaults[key]; - } - } - return obj; - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/obj2url/index.ts b/uni_modules/lime-shared/obj2url/index.ts deleted file mode 100644 index d0125cf..0000000 --- a/uni_modules/lime-shared/obj2url/index.ts +++ /dev/null @@ -1,61 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -type UTSJSONObject = Record -// #endif - -/** - * 将对象转换为URL查询字符串 - * @param data - 需要转换的键值对对象 - * @param isPrefix - 是否添加问号前缀,默认为false - * @returns 格式化后的URL查询参数字符串 - * - * @example - * // 基础用法 - * obj2url({ name: '张三', age: 25 }); - * // => "name=%E5%BC%A0%E4%B8%89&age=25" - * - * @example - * // 数组参数处理 - * obj2url({ tags: ['js', 'ts'] }); - * // => "tags[]=js&tags[]=ts" - * - * @example - * // 包含空值的过滤 - * obj2url({ name: '', age: null, city: undefined }); - * // => "" - * - * @description - * 1. 自动过滤空值(空字符串、null、undefined) - * 2. 支持数组参数转换(自动添加[]后缀) - * 3. 自动进行URI编码 - * 4. 支持自定义是否添加问号前缀 - */ -export function obj2url(data : UTSJSONObject, isPrefix : boolean = false) : string { - const prefix = isPrefix ? '?' : ''; - - const _result:string[] = []; - const empty:(any|null)[] = ['', null] - - // #ifndef APP-ANDROID - empty.push(undefined) - // #endif - - for (const key in data) { - const value = data[key]; - - // 去掉为空的参数 - if (empty.includes(value)) { - continue; - } - if (Array.isArray(value)) { - (value as any[]).forEach((_value) => { - _result.push( - encodeURIComponent(key) + '[]=' + encodeURIComponent(`${_value}`), - ); - }); - } else { - _result.push(encodeURIComponent(key) + '=' + encodeURIComponent(`${value}`)); - } - } - return _result.length > 0 ? prefix + _result.join('&') : ''; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/objToCss/index.ts b/uni_modules/lime-shared/objToCss/index.ts deleted file mode 100644 index 2175269..0000000 --- a/uni_modules/lime-shared/objToCss/index.ts +++ /dev/null @@ -1,49 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -interface UTSJSONObject { - [key : string] : string | number | null -} -// #endif - -/** - * 将字符串转换为带有连字符分隔的小写形式 - * @param key - 要转换的字符串 - * @returns 转换后的字符串 - */ -export function toLowercaseSeparator(key : string):string { - return key.replace(/([A-Z])/g, '-$1').toLowerCase(); -} - -/** - * 获取样式对象对应的样式字符串 - * @param style - CSS样式对象 - * @returns 由非空有效样式属性键值对组成的字符串 - */ -export function objToCss(style : UTSJSONObject) : string { - - // #ifdef APP-ANDROID - let styleStr = ''; - style.toMap().forEach((value, key) => { - if(value != null && value != '') { - styleStr += `${toLowercaseSeparator(key as string)}: ${value};` - } - }) - return styleStr - // #endif - // #ifndef APP-ANDROID - return Object.keys(style) - .filter( - (key) => - style[key] !== undefined && - style[key] !== null && - style[key] !== '') - .map((key : string) => `${toLowercaseSeparator(key)}: ${style[key]};`) - .join(' '); - // #endif -} - -// 示例 -// const style = { color: 'red', fontSize: '16px', backgroundColor: '', border: null }; -// const styleStr = objToCss(style); -// console.log(styleStr); -// 输出: "color: red; font-size: 16px;" \ No newline at end of file diff --git a/uni_modules/lime-shared/package.json b/uni_modules/lime-shared/package.json deleted file mode 100644 index fae6c22..0000000 --- a/uni_modules/lime-shared/package.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "id": "lime-shared", - "displayName": "lime-shared", - "version": "2.0.4", - "description": "本人插件的几个公共函数,获取当前页,图片的base64转临时路径,图片的exif信息等", - "keywords": [ - "lime-shared", - "exif" -], - "repository": "", - "engines": { - "HBuilderX": "^3.1.0", - "uni-app": "^4.55", - "uni-app-x": "^4.55" - }, - "dcloudext": { - "type": "sdk-js", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "", - "darkmode": "x", - "i18n": "x", - "widescreen": "x" - }, - "uni_modules": { - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "√", - "aliyun": "√", - "alipay": "√" - }, - "client": { - "uni-app": { - "vue": { - "vue2": "√", - "vue3": "√" - }, - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "vue": "√", - "nvue": "-", - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√", - "alipay": "√", - "toutiao": "√", - "baidu": "√", - "kuaishou": "-", - "jd": "-", - "harmony": "-", - "qq": "-", - "lark": "-", - "xhs": "-" - }, - "quickapp": { - "huawei": "-", - "union": "-" - } - }, - "uni-app-x": { - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "android": { - "extVersion": "", - "minVersion": "21" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√" - } - }, - "App": { - "app-harmony": "u", - "app-nvue": "u", - "app-uvue": "y", - "app-vue": "u" - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/lime-shared/parseStyle/index.ts b/uni_modules/lime-shared/parseStyle/index.ts deleted file mode 100644 index e7a9583..0000000 --- a/uni_modules/lime-shared/parseStyle/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -type UTSJSONObject = Record -// #endif - - -/** - * 将 CSS 字符串转换为样式对象 - * @param css CSS 字符串,例如 "color: red; font-size: 16px;" - * @returns CSSProperties 对象 - */ -export function parseStyle(css : string | UTSJSONObject | null) : UTSJSONObject { - // #ifdef APP-ANDROID - if(css == null) return {} - // #endif - // #ifndef APP-ANDROID - if(!css) return {} - // #endif - if(typeof css == 'object') return css as UTSJSONObject - - - const style : UTSJSONObject = {}; - - (css as string).split(';').forEach(decl => { - // #ifdef APP-ANDROID - const res = decl.split(':').map(s => s.trim()); - if(res.length > 1) { - const [prop, val] = res; - if (prop != '' && val != '') { - const camelProp = prop!.replace(/-([a-z])/g, (_a: string|null, b: string, _c: number, _d: string):string => { - return b.toUpperCase() - }); - style[camelProp] = val!; - } - } - // #endif - - // #ifndef APP-ANDROID - const [prop, val] = decl.split(':').map(s => s.trim()); - if (prop && val) { - const camelProp = prop.replace(/-([a-z])/g, (_, c) => { - return c.toUpperCase() - }); - style[camelProp] = val; - } - // #endif - }); - - return style; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/pathToBase64/index.ts b/uni_modules/lime-shared/pathToBase64/index.ts deleted file mode 100644 index e0d02c6..0000000 --- a/uni_modules/lime-shared/pathToBase64/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X && APP -export { pathToBase64 } from './vue' -// #endif - - -// #ifdef UNI-APP-X && APP -export { pathToBase64 } from './uvue' -// #endif diff --git a/uni_modules/lime-shared/pathToBase64/uvue.ts b/uni_modules/lime-shared/pathToBase64/uvue.ts deleted file mode 100644 index d5bbdb1..0000000 --- a/uni_modules/lime-shared/pathToBase64/uvue.ts +++ /dev/null @@ -1,17 +0,0 @@ -// @ts-nocheck -// import { processFile, ProcessFileOptions } from '@/uni_modules/lime-file-utils' -export function pathToBase64(path : string) : Promise { - console.error('pathToBase64: 当前环境不支持,请使用 【lime-file-utils】') - // return new Promise((resolve, reject) => { - // processFile({ - // type: 'toDataURL', - // path, - // success(res : string) { - // resolve(res) - // }, - // fail(err: any){ - // reject(err) - // } - // } as ProcessFileOptions) - // }) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/pathToBase64/uvue.uts b/uni_modules/lime-shared/pathToBase64/uvue.uts deleted file mode 100644 index d5bbdb1..0000000 --- a/uni_modules/lime-shared/pathToBase64/uvue.uts +++ /dev/null @@ -1,17 +0,0 @@ -// @ts-nocheck -// import { processFile, ProcessFileOptions } from '@/uni_modules/lime-file-utils' -export function pathToBase64(path : string) : Promise { - console.error('pathToBase64: 当前环境不支持,请使用 【lime-file-utils】') - // return new Promise((resolve, reject) => { - // processFile({ - // type: 'toDataURL', - // path, - // success(res : string) { - // resolve(res) - // }, - // fail(err: any){ - // reject(err) - // } - // } as ProcessFileOptions) - // }) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/pathToBase64/vue.ts b/uni_modules/lime-shared/pathToBase64/vue.ts deleted file mode 100644 index 5b7d561..0000000 --- a/uni_modules/lime-shared/pathToBase64/vue.ts +++ /dev/null @@ -1,142 +0,0 @@ -// @ts-nocheck - -// #ifdef APP-PLUS -import { getLocalFilePath } from '../getLocalFilePath' -// #endif -function isImage(extension : string) { - const imageExtensions = ["jpg", "jpeg", "png", "gif", "bmp", "svg"]; - return imageExtensions.includes(extension.toLowerCase()); -} -function isVideo(extension : string) { - const videoExtensions = ["mp4", "webm", "mov", "avi", "mkv", "flv", "wmv", "3gp", "ogg", "m4v"]; - return videoExtensions.includes(extension.toLowerCase()); -} -// #ifdef H5 -function getSVGFromURL(url: string) { - return new Promise((resolve, reject) => { - const xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.responseType = 'text'; - - xhr.onload = function () { - if (xhr.status === 200) { - const svg = xhr.responseText; - resolve(svg); - } else { - reject(new Error(xhr.statusText)); - } - }; - - xhr.onerror = function () { - reject(new Error('Network error')); - }; - - xhr.send(); - }); -} -// #endif -/** - * 路径转base64 - * @param {Object} string - */ -export function pathToBase64(path : string) : Promise { - if (/^data:/.test(path)) return path - let extension = path.substring(path.lastIndexOf('.') + 1); - const isImageFile = isImage(extension) - const isVideoFile = isVideo(extension) - let prefix = '' - if (isImageFile) { - prefix = 'image/'; - if(extension == 'svg') { - extension += '+xml' - } - } else if (isVideoFile) { - prefix = 'video/'; - } else if (extension === 'pdf') { - prefix = 'application/pdf'; - } else if (extension === 'txt') { - prefix = 'text/plain'; - } else { - prefix = 'application/octet-stream'; - } - return new Promise((resolve, reject) => { - // #ifdef H5 - if (isImageFile) { - if(extension == 'svg') { - getSVGFromURL(path).then(svg => { - const base64 = btoa(svg); - resolve(`data:image/svg+xml;base64,${base64}`); - }) - } else { - let image = new Image(); - image.setAttribute("crossOrigin", 'Anonymous'); - image.onload = function () { - let canvas = document.createElement('canvas'); - canvas.width = this.naturalWidth; - canvas.height = this.naturalHeight; - canvas.getContext('2d').drawImage(image, 0, 0); - let result = canvas.toDataURL(`${prefix}${extension}`) - resolve(result); - canvas.height = canvas.width = 0 - } - image.src = path + '?v=' + Math.random() - image.onerror = (error) => { - reject(error); - }; - } - } else { - // 通用文件处理:使用 fetch + blob + FileReader - fetch(path) - .then(response => { - if (!response.ok) { - throw new Error('HTTP error ' + response.status); - } - return response.blob(); - }) - .then(blob => { - return new Promise((resolve2, reject2) => { - const reader = new FileReader(); - reader.onload = () => resolve2(reader.result); - reader.onerror = reject2; - reader.readAsDataURL(blob); - }); - }) - .then(resolve) - .catch(reject); - } - - // #endif - - // #ifdef MP - if (uni.canIUse('getFileSystemManager')) { - uni.getFileSystemManager().readFile({ - filePath: path, - encoding: 'base64', - success: (res) => { - resolve(`data:${prefix}${extension};base64,${res.data}`) - }, - fail: (error) => { - console.error({ error, path }) - reject(error) - } - }) - } - // #endif - - // #ifdef APP-PLUS - plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), (entry) => { - entry.file((file : any) => { - const fileReader = new plus.io.FileReader() - fileReader.onload = (data) => { - resolve(data.target.result) - } - fileReader.onerror = (error) => { - console.error({ error, path }) - reject(error) - } - fileReader.readAsDataURL(file) - }, reject) - }, reject) - // #endif - }) -} diff --git a/uni_modules/lime-shared/platform/index.ts b/uni_modules/lime-shared/platform/index.ts deleted file mode 100644 index 55fd412..0000000 --- a/uni_modules/lime-shared/platform/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -// @ts-nocheck -export function getPlatform():Uni { - // #ifdef MP-WEIXIN - return wx - // #endif - // #ifdef MP-BAIDU - return swan - // #endif - // #ifdef MP-ALIPAY - return my - // #endif - // #ifdef MP-JD - return jd - // #endif - // #ifdef MP-QQ - return qq - // #endif - // #ifdef MP-360 - return qh - // #endif - // #ifdef MP-KUAISHOU - return ks - // #endif - // #ifdef MP-LARK||MP-TOUTIAO - return tt - // #endif - // #ifdef MP-DINGTALK - return dd - // #endif - // #ifdef QUICKAPP-WEBVIEW || QUICKAPP-WEBVIEW-UNION || QUICKAPP-WEBVIEW-HUAWEI - return qa - // #endif - return uni -} \ No newline at end of file diff --git a/uni_modules/lime-shared/raf/index.ts b/uni_modules/lime-shared/raf/index.ts deleted file mode 100644 index 876efd4..0000000 --- a/uni_modules/lime-shared/raf/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -// @ts-nocheck - -// #ifdef UNI-APP-X && APP -// export * from './uvue' -export { raf, doubleRaf, cancelRaf } from './uvue' -// #endif - - -// #ifndef UNI-APP-X && APP -// export * from './vue' -export { raf, doubleRaf, cancelRaf } from './vue' -// #endif diff --git a/uni_modules/lime-shared/raf/uvue.ts b/uni_modules/lime-shared/raf/uvue.ts deleted file mode 100644 index 6d5b4bb..0000000 --- a/uni_modules/lime-shared/raf/uvue.ts +++ /dev/null @@ -1,26 +0,0 @@ -// @ts-nocheck -// 是否支持被动事件监听 -export const supportsPassive = true; - -// 请求动画帧 -export function raf(fn: UniAnimationFrameCallback): number -export function raf(fn: UniAnimationFrameCallbackWithNoArgument): number -export function raf(fn: any): number { - if(typeof fn == 'UniAnimationFrameCallback') { - return requestAnimationFrame(fn as UniAnimationFrameCallback); - } else { - return requestAnimationFrame(fn as UniAnimationFrameCallbackWithNoArgument); - } -} - -// 取消动画帧 -export function cancelRaf(id: number) { - cancelAnimationFrame(id); -} - -// 双倍动画帧 -export function doubleRaf(fn: UniAnimationFrameCallback): void -export function doubleRaf(fn: UniAnimationFrameCallbackWithNoArgument): void -export function doubleRaf(fn: any): void { - raf(():number => raf(fn)); // 在下一帧回调中再次请求动画帧,实现双倍动画帧效果 -} diff --git a/uni_modules/lime-shared/raf/uvue.uts b/uni_modules/lime-shared/raf/uvue.uts deleted file mode 100644 index 1b0d9f2..0000000 --- a/uni_modules/lime-shared/raf/uvue.uts +++ /dev/null @@ -1,48 +0,0 @@ -// @ts-nocheck -// 是否支持被动事件监听 -export const supportsPassive = true; - -// #ifdef uniVersion < 4.25 -// 请求动画帧 -export function raf(fn: TimerCallback): number { - return setTimeout(fn, 1000 / 60); -} - -// 取消动画帧 -export function cancelRaf(id: number) { - clearTimeout(id); -} - - -// 双倍动画帧 -export function doubleRaf(fn: TimerCallback): void { - raf(():number => raf(fn)); // 在下一帧回调中再次请求动画帧,实现双倍动画帧效果 -} -// #endif - - -// #ifdef uniVersion >= 4.25 -// 请求动画帧 -export function raf(fn: UniAnimationFrameCallback): number -export function raf(fn: UniAnimationFrameCallbackWithNoArgument): number -export function raf(fn: any): number { - if(typeof fn == 'UniAnimationFrameCallback') { - return requestAnimationFrame(fn as UniAnimationFrameCallback); - } else { - return requestAnimationFrame(fn as UniAnimationFrameCallbackWithNoArgument); - } -} - -// 取消动画帧 -export function cancelRaf(id: number) { - cancelAnimationFrame(id); -} - -// 双倍动画帧 -export function doubleRaf(fn: UniAnimationFrameCallback): void -export function doubleRaf(fn: UniAnimationFrameCallbackWithNoArgument): void -export function doubleRaf(fn: any): void { - raf(():number => raf(fn)); // 在下一帧回调中再次请求动画帧,实现双倍动画帧效果 -} -// #endif - diff --git a/uni_modules/lime-shared/raf/vue.ts b/uni_modules/lime-shared/raf/vue.ts deleted file mode 100644 index 98a364e..0000000 --- a/uni_modules/lime-shared/raf/vue.ts +++ /dev/null @@ -1,32 +0,0 @@ -// @ts-nocheck -type Callback = () => void//Function -// 是否支持被动事件监听 -export const supportsPassive = true; - -// 请求动画帧 -export function raf(fn : Callback) : number { - // #ifndef WEB - return setTimeout(fn, 1000 / 60); // 请求动画帧 - // #endif - // #ifdef WEB - return requestAnimationFrame(fn); // 请求动画帧 - // #endif -} - -// 取消动画帧 -export function cancelRaf(id : number) { - // 如果是在浏览器环境下,使用 cancelAnimationFrame 方法 - // #ifdef WEB - cancelAnimationFrame(id); // 取消动画帧 - // #endif - // #ifndef WEB - clearTimeout(id); // 取消动画帧 - // #endif -} - -// 双倍动画帧 -export function doubleRaf(fn : Callback) : void { - raf(() => { - raf(fn) - }); // 在下一帧回调中再次请求动画帧,实现双倍动画帧效果 -} \ No newline at end of file diff --git a/uni_modules/lime-shared/random/index.ts b/uni_modules/lime-shared/random/index.ts deleted file mode 100644 index 49a21ed..0000000 --- a/uni_modules/lime-shared/random/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -// @ts-nocheck -/** - * 生成一个指定范围内的随机数 - * @param min 随机数的最小值 - * @param max 随机数的最大值 - * @param fixed 随机数的小数位数,默认为 0 - * @returns 生成的随机数 - */ - -export function random(min: number, max: number, fixed: number = 0):number { - // 将 min 和 max 转换为数字类型 - // min = +min || 0; - // max = +max || 0; - // 计算随机数范围内的一个随机数 - const num = Math.random() * (max - min) + min; - // 如果 fixed 参数为 0,则返回四舍五入的整数随机数;否则保留固定小数位数 - // Number - return fixed == 0 ? Math.round(num) : parseFloat(num.toFixed(fixed)); -} - -// 示例 -// console.log(random(0, 10)); // 输出:在 0 和 10 之间的一个整数随机数 -// console.log(random(0, 1, 2)); // 输出:在 0 和 1 之间的一个保留两位小数的随机数 -// console.log(random(1, 100, 3)); // 输出:在 1 和 100 之间的一个保留三位小数的随机数 \ No newline at end of file diff --git a/uni_modules/lime-shared/range/index.ts b/uni_modules/lime-shared/range/index.ts deleted file mode 100644 index 483b7d1..0000000 --- a/uni_modules/lime-shared/range/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -// @ts-nocheck -/** - * 生成一个数字范围的数组 - * @param start 范围的起始值 - * @param end 范围的结束值 - * @param step 步长,默认为 1 - * @param fromRight 是否从右侧开始生成,默认为 false - * @returns 生成的数字范围数组 - */ -export function range(start : number, end : number, step : number = 1, fromRight : boolean = false) : number[] { - let index = -1; - // 计算范围的长度 - let length = Math.max(Math.ceil((end - start) / step), 0); - // 创建一个长度为 length 的数组 - // #ifdef APP-ANDROID - const result = Array.fromNative(new IntArray(length.toInt())); - // #endif - // #ifndef APP-ANDROID - const result = new Array(length); - // #endif - - // 使用循环生成数字范围数组 - let _start = start - while (length-- > 0) { - // 根据 fromRight 参数决定从左侧还是右侧开始填充数组 - result[fromRight ? length : ++index] = _start; - _start += step; - } - return result; -} - - -// 示例 -// console.log(range(0, 5)); // 输出: [0, 1, 2, 3, 4] -// console.log(range(1, 10, 2, true)); // 输出: [9, 7, 5, 3, 1] -// console.log(range(5, 0, -1)); // 输出: [5, 4, 3, 2, 1] \ No newline at end of file diff --git a/uni_modules/lime-shared/readme.md b/uni_modules/lime-shared/readme.md deleted file mode 100644 index a5a0f0c..0000000 --- a/uni_modules/lime-shared/readme.md +++ /dev/null @@ -1,353 +0,0 @@ ---- -name: lime-shared 常用函数库 -description: 专为 uni-app / uni-app x 组件开发设计的轻量级工具集,提供验证器、单位转换、DOM 查询、动画过渡、BEM 命名等辅助能力。 -tags: - - shared - - 工具 - - BEM - - 工具函数 -plugin: lime-shared -category: SDK 工具库 -dependencies: [] ---- - -# lime-shared 常用函数库 - -专为 uni-app / uni-app x 组件开发设计的轻量级工具集,提供验证器、单位转换、图片处理、Canvas、DOM 查询、动画过渡、BEM 命名等高效便捷的辅助能力,全面兼容蒸汽模式(uvue/uts)跨平台编译。 - -> 插件依赖:无 - -## 安装方法 - -1. 在 uni-app 插件市场中搜索并导入 `lime-shared` -2. 导入后可能需要重新编译项目 -3. 在代码中按需引入所需函数即可使用 - -::: tip 注意🔔 -本插件为函数库,不提供组件标签,仅通过 `import` 方式按需引入工具函数。 -::: - -## 代码演示 - -### 基础使用 - -按需引入工具函数即可使用,无需全局注册。 - -```js -// 引入单个函数 -import { addUnit } from '@/uni_modules/lime-shared/addUnit' -import { classNames } from '@/uni_modules/lime-shared/classNames' -import { stringifyStyle } from '@/uni_modules/lime-shared/stringifyStyle' - -// 在组件中使用 -const style = stringifyStyle({ color: 'red', fontSize: '14px' }) -const className = classNames('btn', { 'btn--disabled': true }) -const size = addUnit(100) // '100px' -``` - -### 验证器使用 - -提供一系列类型与格式验证函数,统一返回布尔值。 - -```js -import { isNumber } from '@/uni_modules/lime-shared/isNumber' -import { isEmail } from '@/uni_modules/lime-shared/isEmail' -import { isURL } from '@/uni_modules/lime-shared/isURL' -import { isIP } from '@/uni_modules/lime-shared/isIP' - -isNumber(42) // true -isNumber('42') // false -isEmail('a@b.com') // true -isURL('https://a.com') // true -isIP('192.168.1.1') // true -isIP('::1', { version: 6 }) // true -``` - -### BEM 命名与样式工具 - -配合 `lime-style` 提供扁平化 BEM 类名生成与样式字符串拼接。 - -```js -import { createBem } from '@/uni_modules/lime-shared/bem' -import { classNames } from '@/uni_modules/lime-shared/classNames' -import { stringifyStyle } from '@/uni_modules/lime-shared/stringifyStyle' - -const bem = createBem('avatar') - -// 生成 BEM 类名 -bem.b() // 'l-avatar' -bem.e('icon') // 'l-avatar__icon' -bem.m('small') // 'l-avatar--small' -bem.em('icon', 'round') // 'l-avatar__icon--round' -bem.m('small', true) // 'l-avatar--small' -bem.ev('icon', ['active', 'border']) // 'l-avatar__icon--active-border' - -// 合并类名(自动过滤空值) -const cls = classNames(bem.b(), bem.m('disabled', isDisabled), props.lClass) - -// 拼接样式字符串(自动过滤 null/undefined) -const style = stringifyStyle({ color: 'red' }, props.lStyle) -``` - -### DOM 查询与节点信息 - -跨平台获取节点位置尺寸、查询组件实例。 - -```js -import { getRect, getAllRect } from '@/uni_modules/lime-shared/getRect' -import { getCurrentInstance } from 'vue' - -const instance = getCurrentInstance() -// 获取单个节点 -getRect('.item', instance).then((rect) => { - console.log(rect.width, rect.height) -}) -// 获取多个节点 -getAllRect('.item', instance).then((rects) => { - console.log(rects.length) -}) -``` - -### Canvas 异步上下文 - -统一封装不同平台 Canvas 创建逻辑,返回一致的接口。 - -```js -import { createCanvasContextAsync } from '@/uni_modules/lime-shared/createCanvasContextAsync' - -const canvas = await createCanvasContextAsync('myCanvas', instance.proxy) -const ctx = canvas.renderContext -ctx.fillStyle = '#ff0000' -ctx.fillRect(0, 0, 100, 100) -canvas.flush() -const dataURL = await canvas.toDataURL('image/png', 1.0) -``` - -### 动画与过渡 - -提供 `raf` 动画帧、`sleep` 延时、`Timeline`/`Animation` 时间轴及 `useTransition` 过渡能力。 - -```js -import { raf, cancelRaf, doubleRaf } from '@/uni_modules/lime-shared/raf' -import { sleep } from '@/uni_modules/lime-shared/sleep' -import { Timeline, Animation } from '@/uni_modules/lime-shared/animation' - -// 动画帧 -const id = raf(() => console.log('frame')) -cancelRaf(id) - -// 延时 -await sleep(300) - -// 时间轴 -const timeline = new Timeline() -timeline.add(new Animation(0, 100, 300, 0), 0) -timeline.start() -``` - -## API 文档 - -> 以下按功能分类列出全部可用函数。除特别说明外,所有函数均支持 uni-app / uni-app x 跨平台。 - -### 验证器 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `isBase64(str)` | `isBase64` | 判断字符串是否为 Base64 编码 | -| `isDataURI(str)` | `isBase64` | 判断字符串是否为 Base64 编码的 data URI | -| `isBoolean(value)` | `isBoolean` | 严格判断值是否为布尔值 | -| `isByteLength(str, options)` | `isByteLength` | 验证字符串字节长度是否在范围内 | -| `isDate(input, options)` | `isDate` | 验证字符串或 Date 是否为有效日期 | -| `isDef(value)` | `isDef` | 检查值是否已定义(非 undefined/null) | -| `isEmail(email)` | `isEmail` | 验证电子邮件地址格式 | -| `isEmpty(value)` | `isEmpty` | 判断值是否为空(null/空串/空数组/空对象) | -| `isFunction(val)` | `isFunction` | 检查值是否为函数类型 | -| `isIP(ip, options)` | `isIP` | 验证 IP 地址(支持 IPv4/IPv6) | -| `isNumber(value)` | `isNumber` | 检查值是否为数字类型 | -| `isNumeric(value)` | `isNumeric` | 检查值是否为数字或可解析为数字的字符串 | -| `isObject(val)` | `isObject` | 检查值是否为对象类型 | -| `isPromise(val)` | `isPromise` | 检查值是否为 Promise | -| `isRegExp(obj)` | `isRegExp` | 检测值是否为正则表达式对象 | -| `isString(str)` | `isString` | 检查值是否为字符串类型 | -| `isURL(url, options)` | `isURL` | 综合验证 URL(支持协议白名单、TLD、端口等) | -| `isValidDomain(str, options)` | `isValidDomain` | 验证字符串是否为合法域名 | - -### 单位转换 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `addUnit(value, unit='px')` | `addUnit` | 给值添加单位,已含单位则原样返回 | -| `unitConvert(value, base=0)` | `unitConvert` | 将 rpx/px/% 字符串转换为像素数字 | -| `parseUnit(value, base=0)` | `unitConvert` | 包装 `unitConvert`,NaN 返回 null | -| `toNumber(val)` | `toNumber` | 将字符串转换为数字,无法转换返回原值或 null | - -### 图片处理 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `arrayBufferToFile(buffer, name, format)` | `arrayBufferToFile` | 将 ArrayBuffer 转为临时文件路径 | -| `base64ToArrayBuffer(base64)` | `base64ToArrayBuffer` | 从 data URI 解析 base64 并转为 ArrayBuffer | -| `base64ToPath(base64, filename)` | `base64ToPath` | 将 base64 数据转为临时文件路径 | -| `pathToBase64(path)` | `pathToBase64` | 将文件路径转为 base64 data URI | -| `exif` | `exif` | 图片 EXIF 信息读取对象(不支持 uni-app x App) | -| `createImage(canvas)` | `createImage` | 创建用于 canvas 的 Image 对象 | - -### Canvas - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `canIUseCanvas2d()` | `canIUseCanvas2d` | 判断当前环境是否支持 canvas 2d | -| `createCanvas(canvasId, component)` | `createCanvas` | 创建 canvas 上下文 | -| `createCanvasContextAsync(canvasId, component)` | `createCanvasContextAsync` | 异步创建 canvas 上下文,返回统一接口 | - -### 页面与 DOM - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `getCurrentPage()` | `getCurrentPage` | 返回当前页面实例 | -| `getRect(selector, context, node)` | `getRect` | 获取单个节点位置尺寸信息 | -| `getAllRect(selector, context, node)` | `getRect` | 获取所有匹配节点位置尺寸信息 | -| `getViewportScrollInfo()` | `getRect` | 获取视口滚动条位置信息 | -| `getScrollIntoViewValue(...)` | `getRect` | 计算元素滚动到可视区域的目标位置 | -| `getDeviceInfo()` | `getDeviceInfo` | 获取设备信息 | -| `getWindowInfo()` | `getWindowInfo` | 获取窗口信息 | -| `selectComponent(selector)` | `selectComponent` | 链式查询器,查找组件实例 | -| `selectAllComponent(selector, options)` | `selectAllComponent` | 批量选择组件 | -| `selectElement(selector)` | `selectElement` | 链式 DOM 查询器(uni-app x 专用) | -| `findClosestElementWithStyle(el, prop)` | `dom` | 向上查找具有指定 style 的祖先元素 | - -### 动画与延时 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `sleep(delay=300)` | `sleep` | 延时指定毫秒后 resolve 的 Promise | -| `raf(fn)` | `raf` | 请求动画帧 | -| `cancelRaf(id)` | `raf` | 取消动画帧 | -| `doubleRaf(fn)` | `raf` | 双倍动画帧 | -| `createAnimation(options)` | `createAnimation` | 创建动画对象(NVUE 链式调用) | -| `Timeline` | `animation` | 动画时间轴类 | -| `Animation` | `animation` | 单个动画对象类 | -| `useTransition(source, options)` | `animation/useTransition` | 数值过渡动画 composable | - -### 数学与数字 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `clamp(val, min, max)` | `clamp` | 将值限制在范围内 | -| `closest(arr, target)` | `closest` | 在数组中找到最接近目标数字的元素 | -| `floatAdd(num1, num2)` | `floatAdd` | 浮点数加法(精度修复) | -| `floatDiv(num1, num2)` | `floatDiv` | 浮点数除法(精度修复) | -| `floatMul(num1, num2)` | `floatMul` | 浮点数乘法(精度修复) | -| `floatSub(num1, num2)` | `floatSub` | 浮点数减法(精度修复) | -| `random(min, max, fixed=0)` | `random` | 生成指定范围内的随机数 | -| `range(start, end, step=1, fromRight=false)` | `range` | 生成数字范围数组 | - -### 字符串与数组 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `addSeparator(num, separator=',', digit=3)` | `addSeparator` | 每隔 n 位数字添加分隔符 | -| `arrayEqual(arr1, arr2)` | `arrayEqual` | 浅比较两个数组是否相等 | -| `assignAtIndex(arr, index, value)` | `assignAtIndex` | 安全在数组指定索引赋值 | -| `camelCase(str, isPascalCase=false)` | `camelCase` | 转换为 camelCase 或 PascalCase | -| `characterLimit(type, char, max)` | `characterLimit` | 按字符/字节计算长度并截断 | -| `fillArray(length, value)` | `fillArray` | 生成指定长度并用指定值填充的数组 | -| `fillZero(number, length=2)` | `fillZero` | 在数字前补零至指定长度 | -| `findLastIndex(array, predicate)` | `findLastIndex` | 兼容版 findLastIndex polyfill | -| `kebabCase(str, separator='-')` | `kebabCase` | 转换为指定连接符命名 | -| `shuffle(arr)` | `shuffle` | Fisher-Yates 算法随机打乱数组 | -| `toArray(item)` | `toArray` | 将单个元素包装为数组 | -| `toBoolean(value)` | `toBoolean` | 将值转为布尔 | - -### 对象工具 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `cloneDeep(obj)` | `cloneDeep` | 深度克隆对象/数组 | -| `coalesce(...values)` | `coalesce` | 返回第一个非空值(保留 0/false) | -| `hasOwn(obj, key)` | `hasOwn` | 检查对象是否具有指定属性 | -| `merge(obj, defaults)` | `merge` | 深度合并,用 defaults 填充 obj 的空值 | - -### BEM 命名与样式 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `createBem` | `bem` | 默认配置 BEM 工厂函数(namespace=`l`) | -| `createBemStruct(config)` | `bem` | 自定义配置 BEM 工厂函数 | -| `Bem` | `bem` | BEM 类生成器类 | -| `classNames(...args)` | `classNames` | 拼接类名字符串,自动过滤空值 | -| `parseStyle(css)` | `parseStyle` | 将 CSS 字符串转为样式对象 | -| `stringifyStyle(...args)` | `stringifyStyle` | 拼接样式字符串,自动过滤空值 | -| `toCssVars(obj, prefix='--l-')` | `stringifyStyle` | 将对象转换为 CSS 自定义属性字符串 | - -### 平台与杂项 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `getLocalFilePath(path)` | `getLocalFilePath` | 将路径转换为本地绝对路径 | -| `getPlatform()` | `platform` | 返回当前平台的根对象(wx/my/uni 等) | -| `obj2url(data, isPrefix=false)` | `obj2url` | 将对象转换为 URL 查询字符串 | -| `guid(len=32)` | `guid` | 生成指定长度的伪随机字符串 | -| `uniqid(prefix='lime')` | `uniqid` | 生成带前缀的唯一 ID | -| `isBrowser` | `isBrowser` | 是否为 Web 环境常量 | -| `vue` | `vue` | Vue API 重导出(VUE3/VUE2 兼容) | - -### 省市区数据 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `areaList` | `areaData` | 中国省市区原始数据(province/city/county) | -| `useCascaderAreaData()` | `areaData` | 转换为级联选择器树形结构 | - -### 节流防抖 - -| 函数名 | 路径 | 说明 | -| --- | --- | --- | -| `debounce(fn, wait=300)` | `debounce` | 防抖函数 | -| `throttle(func, wait, options)` | `throttle` | 节流函数(支持 leading/trailing) | - -## Vue2 使用说明 - -插件在 Vue2 项目中通过 `@vue/composition-api` 提供 `computed`、`ref`、`watch` 等组合式 API 能力,需按以下方式配置。 - -关键配置代码(在 main.js 中添加): - -```js -// vue2 -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -``` - -## 快速预览 - -本插件为函数库,不提供可视化演示组件。可直接在任意 uni-app 项目中按需引入函数进行使用。 - -## 插件标签说明 - -| 标签类型 | 示例 | 说明 | -|---------|------|------| -| 函数库 | `import { ... } from '@/uni_modules/lime-shared/...'` | 仅通过 import 方式按需引入,无组件标签 | - -## 文档链接 - -📚 函数库详细文档请访问以下站点: -- [常用函数库文档 - 站点1](https://limex.qcoon.cn/uts/shared.html) -- [常用函数库文档 - 站点2](https://limeui.netlify.app/uts/shared.html) -- [常用函数库文档 - 站点3](https://limeui.familyzone.top/uts/shared.html) - -## 注意事项 - -1. 本插件为函数库,所有函数均按需引入,无需全局注册 -2. `exif` 图片信息读取不支持 uni-app x App 环境 -3. `createAnimation` 在 uni-app x(uvue)环境下请使用 `lime-animateIt` 插件 -4. `getLocalFilePath` 在 uni-app x(uvue)环境下重新导出为 `getResourcePath`(来自 `lime-file-utils`) -5. 部分函数在不同平台有不同实现,但导出名称与签名保持一致,无需关心平台差异 - -## 支持与赞赏 - -如果你觉得本插件解决了你的问题,可以考虑支持作者: - -| 支付宝赞助 | 微信赞助 | -|------------|------------| -| ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) | ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) | diff --git a/uni_modules/lime-shared/selectAllComponent/index.ts b/uni_modules/lime-shared/selectAllComponent/index.ts deleted file mode 100644 index f95036a..0000000 --- a/uni_modules/lime-shared/selectAllComponent/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-nocheck -// #ifdef UNI-APP-X -export { selectAllComponent } from './uvue' -// #endif - -// #ifndef UNI-APP-X -export { selectAllComponent } from './vue' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/selectAllComponent/uvue.ts b/uni_modules/lime-shared/selectAllComponent/uvue.ts deleted file mode 100644 index 9701614..0000000 --- a/uni_modules/lime-shared/selectAllComponent/uvue.ts +++ /dev/null @@ -1,39 +0,0 @@ -// @ts-nocheck -import { type ComponentPublicInstance } from 'vue'; - -type SelectOptions = { - context : ComponentPublicInstance, - needAll : boolean | null, - -} - -export function selectAllComponent(selector : string, options : UTSJSONObject) : ComponentPublicInstance[]|null { - const context = options['context']! as ComponentPublicInstance; - let needAll = options['needAll'] as boolean; - let result:ComponentPublicInstance[] = [] - - if(needAll == null) { needAll = true }; - - if(context.$children.length > 0) { - const queue:ComponentPublicInstance[] = [...context.$children]; - while(queue.length > 0) { - const child = queue.shift(); - const name = child?.$options?.name; - if(name == selector) { - result.push(child as ComponentPublicInstance) - } else { - const children = child?.$children - if(children !== null) { - queue.push(...children) - } - } - if(result.length > 0 && !needAll) { - break; - } - } - } - if(result.length > 0) { - return result - } - return null -} \ No newline at end of file diff --git a/uni_modules/lime-shared/selectAllComponent/uvue.uts b/uni_modules/lime-shared/selectAllComponent/uvue.uts deleted file mode 100644 index 07c9fcd..0000000 --- a/uni_modules/lime-shared/selectAllComponent/uvue.uts +++ /dev/null @@ -1,39 +0,0 @@ -// @ts-nocheck -import { type ComponentPublicInstance } from 'vue'; - -type SelectOptions = { - context : ComponentPublicInstance, - needAll : boolean | null, - -} - -export function selectAllComponent(selector : string, options : UTSJSONObject) : ComponentPublicInstance[]|null { - const context = options.get('context')! as ComponentPublicInstance; - let needAll = options.get('needAll') as boolean; - let result:ComponentPublicInstance[] = [] - - if(needAll == null) { needAll = true }; - - if(context.$children.length > 0) { - const queue:ComponentPublicInstance[] = [...context.$children]; - while(queue.length > 0) { - const child = queue.shift(); - const name = child?.$options?.name; - if(name == selector) { - result.push(child as ComponentPublicInstance) - } else { - const children = child?.$children - if(children !== null) { - queue.push(...children) - } - } - if(result.length > 0 && !needAll) { - break; - } - } - } - if(result.length > 0) { - return result - } - return null -} \ No newline at end of file diff --git a/uni_modules/lime-shared/selectAllComponent/vue.ts b/uni_modules/lime-shared/selectAllComponent/vue.ts deleted file mode 100644 index 380bd7a..0000000 --- a/uni_modules/lime-shared/selectAllComponent/vue.ts +++ /dev/null @@ -1,151 +0,0 @@ -// @ts-nocheck -interface SelectOptions { - context?: any - needAll?: boolean - node?: boolean -} -// #ifdef MP -function selectMPComponent(key: string, name: string, context: any, needAll: boolean) { - const {proxy, $vm} = context - context = $vm || proxy - if(!['ref','component'].includes(key)) { - const queue = [context] - let result = null - const selector = (key == 'id' ? '#': '.') + name; - while(queue.length > 0) { - const child = queue.shift(); - const flag = child?.selectComponent(selector) - if(flag) { - if(!needAll) {return result = flag.$vm} - return result = child.selectAllComponents(selector).map(item => item.$vm) - } else { - child.$children && (queue.push(...child.$children)); - } - } - return result - } else { - const {$templateRefs} = context.$ - const nameMap = {} - for (var i = 0; i < $templateRefs.length; i++) { - const item = $templateRefs[i] - nameMap[item.i] = item.r - } - let result = [] - if(context.$children.length) { - const queue = [...context.$children] - while(queue.length > 0) { - const child = queue.shift(); - if(key == 'component' && (child.type?.name === name || child.$?.type?.name === name)) { - result.push(child) - } else if(child.$refs && child.$refs[name]) { - result = child.$refs[name] - } else if(nameMap[child.id] === name){ - result.push(child) - } else { - child.$children && (queue.push(...child.$children)); - } - if(result.length && !needAll) { - return; - } - } - } - return needAll ? result : result[0] - } -} -// #endif -// #ifdef H5 -function selectH5Component(key: string, name: string, context: any, needAll: boolean) { - const {_, component } = context - const child = {component: _ || component || context, children: null , subTree: null, props: null} - let result = [] - let queue = [child] - while(queue.length > 0 ) { - const child = queue.shift() - const {component, children , props, subTree} = child - if(key === 'component' && component?.type?.name == name) { - result.push(component) - } else if(key === 'ref' && component && (props?.ref == name || component[key][name])) { - if(props?.ref == name) { - //exposed - result.push(component) - } else if(component[key][name]) { - result.push(component[key][name]) - } - } else if(key !== 'ref' && component?.exposed && new RegExp(`\\b${name}\\b`).test(component.attrs[key])) { - // exposed - result.push(component) - } else if(children && Array.isArray(children)) { - queue.push(...children) - } else if(!component && subTree) { - queue.push(subTree) - } else if(component?.subTree) { - queue.push(component.subTree) - } - if(result.length && !needAll) { - break - } - } - return needAll ? result : result[0] -} -// #endif -// #ifdef APP -function selectAPPComponent(key: string, name: string, context: any, needAll: boolean, node: boolean) { - let result = [] - // const {_, component} = context - // const child = {component: _ || component || context, children: null, props: null, subTree: null} - const queue = [context] - while(queue.length > 0) { - const child = queue.shift() - const {component, children, props, subTree} = child - const isComp = component && props && component.exposed && !node - if(key == 'component' && child.type && child.type.name === name) { - result.push(component) - } else if(props?.[key] === name && node) { - result.push(child) - } else if(key === 'ref' && isComp && (props.ref === name || props.ref_key === name)) { - // exposed - result.push(component) - } else if(key !== 'ref' && isComp && new RegExp(`\\b${name}\\b`).test(props[key])) { - // exposed - result.push(component) - } - // else if(component && component.subTree && Array.isArray(component.subTree.children)){ - // queue.push(...component.subTree.children) - // } - else if(subTree) { - queue.push(subTree) - } else if(component && component.subTree){ - queue.push(component.subTree) - } - else if(children && Array.isArray(children)) { - queue.push(...children) - } - if(result.length && !needAll) { - break; - } - } - return needAll ? result : result[0] -} -// #endif -export function selectAllComponent(selector: string, options: SelectOptions = {}) { - // . class - // # id - // $ ref - // @ component name - const reg = /^(\.|#|@|\$)([a-zA-Z_0-9\-]+)$/; - if(!reg.test(selector)) return null - let { context, needAll = true, node} = options - const [,prefix, name] = selector.match(reg) - const symbolMappings = {'.': 'class', '#': 'id', '$':'ref', '@':'component'} - - const key = symbolMappings [prefix] //prefix === '.' ? 'class' : prefix === '#' ? 'id' : 'ref'; - // #ifdef MP - return selectMPComponent(key, name, context, needAll) - // #endif - // #ifdef H5 - return selectH5Component(key, name, context, needAll) - // #endif - // #ifdef APP - return selectAPPComponent(key, name, context, needAll, node) - // #endif -} \ No newline at end of file diff --git a/uni_modules/lime-shared/selectComponent/index.ts b/uni_modules/lime-shared/selectComponent/index.ts deleted file mode 100644 index 1e571c5..0000000 --- a/uni_modules/lime-shared/selectComponent/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -export { selectComponent } from './vue' -// #endif -// #ifdef UNI-APP-X -export { selectComponent } from './uvue' -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/selectComponent/uvue.ts b/uni_modules/lime-shared/selectComponent/uvue.ts deleted file mode 100644 index c2aa2bc..0000000 --- a/uni_modules/lime-shared/selectComponent/uvue.ts +++ /dev/null @@ -1,75 +0,0 @@ -// @ts-nocheck -import { type ComponentPublicInstance } from 'vue'; -// #ifdef APP -function findChildren(selector: string, context: ComponentPublicInstance, needAll: boolean): ComponentPublicInstance [] | null{ - let result:ComponentPublicInstance[] = [] - - if(context !== null && context.$children.length > 0) { - const queue:ComponentPublicInstance[] = [...context.$children]; - while(queue.length > 0) { - const child = queue.shift(); - const name = child?.$options?.name; - if(name == selector) { - result.push(child as ComponentPublicInstance) - } else { - const children = child?.$children - if(children !== null) { - queue.push(...children) - } - } - if(result.length > 0 && !needAll) { - break; - } - } - } - if(result.length > 0) { - return result - } - return null -} - -class Query { - context : ComponentPublicInstance | null = null - selector : string = '' - // components : ComponentPublicInstance[] = [] - constructor(selector : string, context : ComponentPublicInstance | null) { - this.selector = selector - this.context = context - } - in(context : ComponentPublicInstance) : Query { - return new Query(this.selector, context) - } - find(): ComponentPublicInstance | null { - const selector = this.selector - if(selector == '') return null - const component = findChildren(selector, this.context!, false) - return component != null ? component[0]: null - } - findAll():ComponentPublicInstance[] | null { - const selector = this.selector - if(selector == '') return null - return findChildren(selector, this.context!, true) - } - closest(): ComponentPublicInstance | null { - const selector = this.selector - if(selector == '') return null - let parent = this.context!.$parent - let name = parent?.$options?.name; - while (parent != null && (name == null || selector != name)) { - parent = parent.$parent - if (parent != null) { - name = parent.$options.name - } - } - return parent - } -} - -export function selectComponent(selector: string): Query{ - return new Query(selector, null) -} -// #endif - -// selectComponent('selector').in(this).find() -// selectComponent('selector').in(this).findAll() -// selectComponent('selector').in(this).closest() diff --git a/uni_modules/lime-shared/selectComponent/uvue.uts b/uni_modules/lime-shared/selectComponent/uvue.uts deleted file mode 100644 index c2aa2bc..0000000 --- a/uni_modules/lime-shared/selectComponent/uvue.uts +++ /dev/null @@ -1,75 +0,0 @@ -// @ts-nocheck -import { type ComponentPublicInstance } from 'vue'; -// #ifdef APP -function findChildren(selector: string, context: ComponentPublicInstance, needAll: boolean): ComponentPublicInstance [] | null{ - let result:ComponentPublicInstance[] = [] - - if(context !== null && context.$children.length > 0) { - const queue:ComponentPublicInstance[] = [...context.$children]; - while(queue.length > 0) { - const child = queue.shift(); - const name = child?.$options?.name; - if(name == selector) { - result.push(child as ComponentPublicInstance) - } else { - const children = child?.$children - if(children !== null) { - queue.push(...children) - } - } - if(result.length > 0 && !needAll) { - break; - } - } - } - if(result.length > 0) { - return result - } - return null -} - -class Query { - context : ComponentPublicInstance | null = null - selector : string = '' - // components : ComponentPublicInstance[] = [] - constructor(selector : string, context : ComponentPublicInstance | null) { - this.selector = selector - this.context = context - } - in(context : ComponentPublicInstance) : Query { - return new Query(this.selector, context) - } - find(): ComponentPublicInstance | null { - const selector = this.selector - if(selector == '') return null - const component = findChildren(selector, this.context!, false) - return component != null ? component[0]: null - } - findAll():ComponentPublicInstance[] | null { - const selector = this.selector - if(selector == '') return null - return findChildren(selector, this.context!, true) - } - closest(): ComponentPublicInstance | null { - const selector = this.selector - if(selector == '') return null - let parent = this.context!.$parent - let name = parent?.$options?.name; - while (parent != null && (name == null || selector != name)) { - parent = parent.$parent - if (parent != null) { - name = parent.$options.name - } - } - return parent - } -} - -export function selectComponent(selector: string): Query{ - return new Query(selector, null) -} -// #endif - -// selectComponent('selector').in(this).find() -// selectComponent('selector').in(this).findAll() -// selectComponent('selector').in(this).closest() diff --git a/uni_modules/lime-shared/selectComponent/vue.ts b/uni_modules/lime-shared/selectComponent/vue.ts deleted file mode 100644 index 9fca0cd..0000000 --- a/uni_modules/lime-shared/selectComponent/vue.ts +++ /dev/null @@ -1,149 +0,0 @@ -// @ts-nocheck -// #ifdef MP -function findChildren(selector : string, context : ComponentPublicInstance, needAll : boolean) { - const { proxy, $vm } = context - context = $vm || proxy - if ((selector.startsWith('.') || selector.startsWith('#'))) { - const queue = [context] - let result = null - while (queue.length > 0) { - const child = queue.shift(); - const flag = child?.selectComponent(selector) - if (flag) { - if (!needAll) { return result = flag.$vm } - return result = child.selectAllComponents(selector).map(item => item.$vm) - } else { - child.$children && (queue.push(...child.$children)); - } - } - return result - } else { - const { $templateRefs } = context.$ - const selectorValue = /#|\.|@|$/.test(selector) ? selector.substring(1) : selector - const nameMap = {} - for (var i = 0; i < $templateRefs.length; i++) { - const item = $templateRefs[i] - nameMap[item.i] = item.r - } - let result = [] - if (context.$children.length) { - const queue = [...context.$children] - while (queue.length > 0) { - const child = queue.shift(); - if (child.type?.name === selectorValue || child.$?.type?.name === selectorValue) { - result.push(child) - } else if (child.$refs && child.$refs[selectorValue]) { - result = child.$refs[selectorValue] - } else if (nameMap[child.id] === selectorValue) { - result.push(child) - } else { - child.$children && (queue.push(...child.$children)); - } - if (result.length && !needAll) { - return; - } - } - } - return needAll ? result : result[0] - } -} -// #endif - -// #ifdef H5 -function findChildren(selector : string, context : ComponentPublicInstance, needAll : boolean){ - const {_, component } = context - const child = {component: _ || component || context, children: null , subTree: null, props: null} - let result = [] - let queue = [child] - const selectorValue = /#|\.|@|$/.test(selector) ? selector.substring(1) : selector - while(queue.length > 0 ) { - const child = queue.shift() - const {component, children , props, subTree} = child - if(component?.type?.name == selectorValue) { - result.push(component) - } else if(selector.startsWith('$') && component && (props?.ref == selectorValue || component[key][selectorValue])) { - if(props?.ref == selectorValue) { - //exposed - result.push(component) - } else if(component[key][selectorValue]) { - result.push(component[key][selectorValue]) - } - } else if(!selector.startsWith('$') && component?.exposed && new RegExp(`\\b${selectorValue}\\b`).test(component.attrs[key])) { - // exposed - result.push(component) - } else if(children && Array.isArray(children)) { - queue.push(...children) - } else if(!component && subTree) { - queue.push(subTree) - } else if(component?.subTree) { - queue.push(component.subTree) - } - if(result.length && !needAll) { - break - } - } - return needAll ? result : result[0] -} -// #endif - -// #ifdef APP -function findChildren(selector : string, context : ComponentPublicInstance, needAll : boolean){ - let result = [] - const selectorValue = /#|\.|@|$/.test(selector) ? selector.substring(1) : selector - const queue = [context] - while(queue.length > 0) { - const child = queue.shift() - const {component, children, props, subTree} = child - const isComp = component && props && component.exposed && !node - if(child.type && child.type.name === selectorValue) { - result.push(component) - } else if(props?.[key] === selectorValue && node) { - result.push(child) - } else if(selector.startsWith('$') && isComp && (props.ref === selectorValue || props.ref_key === selectorValue)) { - // exposed - result.push(component) - } else if(!selector.startsWith('$') && isComp && new RegExp(`\\b${selectorValue}\\b`).test(props[key])) { - // exposed - result.push(component) - } - else if(subTree) { - queue.push(subTree) - } else if(component && component.subTree){ - queue.push(component.subTree) - } - else if(children && Array.isArray(children)) { - queue.push(...children) - } - if(result.length && !needAll) { - break; - } - } - return needAll ? result : result[0] -} -// #endif - -class Query { - context : ComponentPublicInstance | null = null - selector : string = '' - // components : ComponentPublicInstance[] = [] - constructor(selector : string, context : ComponentPublicInstance | null) { - this.selector = selector - this.context = context - } - in(context : ComponentPublicInstance) : Query { - return new Query(this.selector, context) - } - find() : ComponentPublicInstance | null { - return findChildren(this.selector, this.context, false) - } - findAll() : ComponentPublicInstance[] | null { - return findChildren(this.selector, this.context, true) - } - closest() : ComponentPublicInstance | null { - return null - } -} - -export function selectComponent(selector: string) { - return new Query(selector) -} \ No newline at end of file diff --git a/uni_modules/lime-shared/selectElement/index.ts b/uni_modules/lime-shared/selectElement/index.ts deleted file mode 100644 index fbe5fb4..0000000 --- a/uni_modules/lime-shared/selectElement/index.ts +++ /dev/null @@ -1,277 +0,0 @@ -// @ts-nocheck -import {isDef} from '../isDef' -// #ifdef UNI-APP-X -import {type ComponentPublicInstance} from '../vue' -// #endif - -type HasSelectorFunc = (selector : string, element : UniElement) => boolean - -const hasSelectorClassName : HasSelectorFunc = (selector : string, element : UniElement) : boolean => { - return element.classList.includes(selector) -} -const hasSelectorId : HasSelectorFunc = (selector : string, element : UniElement) : boolean => { - return element.getAttribute("id") == selector -} -const hasSelectorTagName : HasSelectorFunc = (selector : string, element : UniElement) : boolean => { - return element.tagName!.toLowerCase() == selector.toLowerCase() -} - -type ProcessSelectorResult = { - selectorValue : string - hasSelector : HasSelectorFunc -} -const processSelector = (selector : string) : ProcessSelectorResult => { - - const selectorValue = /#|\./.test(selector) ? selector.substring(1) : selector - let hasSelector : HasSelectorFunc - - if (selector.startsWith('.')) { - hasSelector = hasSelectorClassName - } else if (selector.startsWith('#')) { - hasSelector = hasSelectorId - } else { - hasSelector = hasSelectorTagName - } - - return { - selectorValue, - hasSelector - } as ProcessSelectorResult -} - - -function isNotEmptyString(str:string): boolean { - return str.length > 0; -} - -function isElement(element:UniElement|null):boolean { - return isDef(element) && element?.tagName != 'COMMENT'; -} - -type ElementArray = Array -class Query { - context : ComponentPublicInstance | null = null - selector : string = '' - elements : ElementArray = [] - constructor(selector : string | null, context : ComponentPublicInstance | null) { - this.context = context - if(selector != null){ - this.selector = selector - } - this.find(this.selector) - } - in(context : ComponentPublicInstance) : Query { - return new Query(this.selector, context) - } - findAll(selector : string): Query { - if (isDef(this.context)) { - const root = this.context?.$el //as Element | null; - if (isDef(root)) { - this.elements = [root!] //as ElementArray - } - const { selectorValue, hasSelector } = processSelector(selector) - const foundElements : ElementArray = []; - - function findChildren(element : UniElement) { - element.children.forEach((child : UniElement) => { - if (hasSelector(selectorValue, child)) { - foundElements.push(child) - } - }) - } - this.elements.forEach(el => { - findChildren(el!); - }); - this.elements = foundElements - } else if (selector.startsWith('#')) { - const element = uni.getElementById(selector) - if (isElement(element!)) { - this.elements = [element] - } - } - return this; - } - /** - * 在当前元素集合中查找匹配的元素 - */ - find(selector : string) : Query { - if (isDef(this.context)) { - const root = this.context?.$el //as Element | null; - if (isElement(root)) { - this.elements = [root] //as ElementArray - } - if(isNotEmptyString(selector) && this.elements.length > 0){ - const { selectorValue, hasSelector } = processSelector(selector) - const foundElements : ElementArray = []; - function findChildren(element : UniElement) { - element.children.forEach((child : UniElement) => { - if (hasSelector(selectorValue, child) && foundElements.length < 1) { - foundElements.push(child) - } - if (foundElements.length < 1) { - findChildren(child); - } - }) - } - this.elements.forEach(el => { - findChildren(el!); - }); - this.elements = foundElements - } - - } else if (selector.startsWith('#')) { - const element = uni.getElementById(selector) - if (isElement(element!)) { - this.elements = [element] - } - } - return this; - } - /** - * 获取当前元素集合的直接子元素 - */ - children() : Query { - // if (this.elements.length > 0) { - // const children = this.elements.reduce((acc, el) => [...acc, ...Array.from(el.children)], []); - // this.elements = children; - // } - return this; - } - /** - * 获取当前元素集合的父元素 - */ - parent() : Query { - // if (this.elements.length > 0) { - // const parents = this.elements.map(el => el.parentElement).filter(parent => parent !== null) as ElementArray; - // this.elements = parents - // // this.elements = Array.from(new Set(parents)); - // } - return this; - } - /** - * 获取当前元素集合的兄弟元素 - */ - siblings() : Query { - // if (this.elements.length > 0) { - // const siblings = this.elements.reduce((acc, el) => [...acc, ...Array.from(el.parentElement?.children || [])], []); - // this.elements = siblings.filter(sibling => sibling !== null && !this.elements?.includes(sibling)); - // } - return this; - } - /** - * 获取当前元素集合的下一个兄弟元素 - */ - next() : Query { - // if (this.elements.length > 0) { - // const nextElements = this.elements.map(el => el.nextElementSibling).filter(next => next !== null) as ElementArray; - // this.elements = nextElements; - // } - return this; - } - /** - * 获取当前元素集合的上一个兄弟元素 - */ - prev() : Query { - // if (this.elements.length > 0) { - // const prevElements = this.elements.map(el => el.previousElementSibling).filter(prev => prev !== null) as ElementArray; - // this.elements = prevElements; - // } - return this; - } - /** - * 从当前元素开始向上查找匹配的元素 - */ - closest(selector : string) : Query { - if (isDef(this.context)) { - // && this.context.$parent != null && this.context.$parent.$el !== null - if(this.elements.length == 0 && isDef(this.context?.$parent) && isElement(this.context!.$parent?.$el)){ - this.elements = [this.context!.$parent?.$el!] - } - - const selectorsArray = selector.split(',') - // const { selectorValue, hasSelector } = processSelector(selector) - const processedSelectors = selectorsArray.map((selector: string):ProcessSelectorResult => processSelector(selector)) - const closestElements = this.elements.map((el) : UniElement | null => { - let closestElement : UniElement | null = el - while (closestElement !== null) { - // if (hasSelector(selectorValue, closestElement)) { - // break; - // } - const isMatchingSelector = processedSelectors.some(({selectorValue, hasSelector}):boolean => { - return hasSelector(selectorValue, closestElement!) - }) - if(isMatchingSelector){ - break; - } - closestElement = closestElement.parentElement; - } - return closestElement - }) - this.elements = closestElements.filter((closest : UniElement | null) : boolean => isDef(closest))// as ElementArray - - } - return this; - } - - /** - * 从当前元素集合中过滤出匹配的元素 - */ - filter() : Query { - - return this; - } - /** - * 从当前元素集合中排除匹配的元素 - */ - not() { } - /** - * 从当前元素集合中查找包含匹配元素的元素 - */ - has() { } - /** - * 获取当前元素集合的第一个 - */ - first() : Query { - if (this.elements.length > 0) { - // this.elements = [this.elements[0]]; - } - return this; - } - /** - * 最后一个元素 - */ - last() : Query { - if (this.elements.length > 0) { - // this.elements = [this.elements[this.elements.length - 1]]; - } - return this; - } - /** - * 获取当前元素在其兄弟元素中的索引 - */ - index() : number | null { - // if (this.elements.length > 0 && this.elements.length > 0 && this.elements[0].parentElement !== null) { - // return Array.from(this.elements[0].parentElement.children).indexOf(this.elements[0]); - // } - return null; - } - get(index : number) : UniElement | null { - if (this.elements.length > index) { - return this.elements[index] //as Element - } - return null - } -} - -export function selectElement(selector : string | null = null) : Query { - // if(typeof selector == 'string' || selector == null){ - // return new Query(selector as string | null, null) - // } - // else if(selector instanceof ComponentPublicInstance){ - // return new Query(null, selector) - // } - return new Query(selector, null) -} - -// $('xxx').in(this).find('xxx') -// $('xxx').in(this).get() \ No newline at end of file diff --git a/uni_modules/lime-shared/shuffle/index.ts b/uni_modules/lime-shared/shuffle/index.ts deleted file mode 100644 index 5b3ab51..0000000 --- a/uni_modules/lime-shared/shuffle/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// @ts-nocheck -/** - * 随机化数组中元素的顺序,使用 Fisher-Yates 算法 - * @description 函数接受一个数组作为参数,返回一个新的数组,其中包含原数组随机化顺序后的元素。 - * @param arr 要随机化的数组 - * @returns 一个新的数组,其中包含原数组随机化顺序后的元素。 - */ -export function shuffle(arr : T[]) : T[] { - for (let i = arr.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)) - const temp = arr[i] - arr[i] = arr[j] - arr[j] = temp - } - return arr -} \ No newline at end of file diff --git a/uni_modules/lime-shared/sleep/index.ts b/uni_modules/lime-shared/sleep/index.ts deleted file mode 100644 index e93cc1b..0000000 --- a/uni_modules/lime-shared/sleep/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -// @ts-nocheck -/** - * 延迟指定时间后解析的 Promise - * @param delay 延迟的时间(以毫秒为单位),默认为 300 毫秒 - * @returns 一个 Promise,在延迟结束后解析 - */ - - -// #ifdef UNI-APP-X && APP -function sleep(delay: number = 300):Promise { - return new Promise((resolve):void => {setTimeout(() => {resolve()}, delay)}); -} -export { - sleep -} - -// #endif - -// #ifndef UNI-APP-X && APP -export const sleep = (delay: number = 300) => - new Promise(resolve => setTimeout(resolve, delay)); - -// #endif - -// 示例 -// async function example() { -// console.log("Start"); - -// // 延迟 1 秒后执行 -// await sleep(1000); -// console.log("1 second later"); - -// // 延迟 500 毫秒后执行 -// await sleep(500); -// console.log("500 milliseconds later"); - -// // 延迟 2 秒后执行 -// await sleep(2000); -// console.log("2 seconds later"); - -// console.log("End"); -// } - -// example(); \ No newline at end of file diff --git a/uni_modules/lime-shared/stringifyStyle/index.ts b/uni_modules/lime-shared/stringifyStyle/index.ts deleted file mode 100644 index 1836ca9..0000000 --- a/uni_modules/lime-shared/stringifyStyle/index.ts +++ /dev/null @@ -1,158 +0,0 @@ -// @ts-nocheck -/** - * 驼峰命名转短横线命名 - * @param str - 需要转换的字符串 - * @returns 转换后的短横线命名字符串 - */ -function toKebabCase(str : string) : string { - return str - // 1. 字母+数字+连续大写视为整体:"e2XL" → "e-2XL" - .replace(/([a-z])(\d+[A-Z]{2,})/g, '$1-$2') - // 2. 字母+连续大写视为整体:"eSM" → "e-SM", "sXS" → "s-XS" - .replace(/([a-z])([A-Z]{2,})/g, '$1-$2') - // 3. 小写+大写常规边界:"tS" → "t-S", "eB" → "e-B" - .replace(/([a-z])([A-Z])/g, '$1-$2') - // 4. 字母+数字边界:"y50" → "y-50" - .replace(/([a-zA-Z])(\d+)/g, '$1-$2') - .toLowerCase() -} - -// #ifndef UNI-APP-X -type UTSJSONObject = Record -// #endif - -export type StyleProp = - | string - | UTSJSONObject - | null - | undefined - | false - | StyleProp[] - -/** - * 把样式对象拼接成字符串,解决小程序不支持 styleObject 的问题 - * @description 支持多种参数类型的样式拼接,包括字符串、对象和数组 - * @param args 样式参数,可以是字符串、对象、null、undefined、false 或数组 - * @returns 拼接后的样式字符串 - * @example - * stringifyStyle('color: red') // 'color: red;' - * stringifyStyle({ color: 'red', fontSize: '14px' }) // 'color: red;font-size: 14px;' - * stringifyStyle(['color: red', 'background: blue']) // 'color: red;background: blue;' - * stringifyStyle('color: red', null, 'background: blue') // 'color: red;background: blue;' - * stringifyStyle({ color: 'red', display: false, opacity: 0 }) // 'color: red;opacity: 0;' - */ -export function stringifyStyle(...args : StyleProp[]) : string { - return stringifyStyleArray(args) -} - -function isValidStyleValue(value : StyleProp) : boolean { - if (value == null) return false; // 排除 null/undefined - if (typeof value == 'boolean') return false // 排除所有布尔值 - if (value == 0) return true - if (value == '') return false; // 排除空字符串 - if (typeof value == 'number') { - return isFinite(value as number); // 允许有效数字,排除 NaN/Infinity - } - - return true; // 字符串和其他情况 -} - - -/** - * 处理数组的样式 - * @description 用于内部递归处理数组类型的样式 - * @param args 样式数组 - * @returns 拼接后的样式字符串 - */ -function stringifyStyleArray(args : StyleProp[]) : string { - const result : string[] = [] - for (let i = 0; i < args.length; i++) { - const arg = args[i] - if (!isValidStyleValue(arg)) continue - if (typeof arg == 'string') { - result.push(arg as string) - } else if (Array.isArray(arg)) { - if ((arg as StyleProp[]).length > 0) { - const style = stringifyStyleArray(arg) - if (style != '') { - result.push(style) - } - } - } else if (typeof arg == 'object') { - // #ifndef APP-ANDROID - for (const key in arg) { - const value = arg[key] - if (isValidStyleValue(value)) { - result.push(`${toKebabCase(key)}:${value}`) - } - } - // #endif - // #ifdef APP-ANDROID - // #ifdef VUE3-VAPOR - for (const key in arg) { - const value = arg[key] - if (isValidStyleValue(value)) { - result.push(`${toKebabCase(key)}:${value}`) - } - } - // #endif - // #ifndef VUE3-VAPOR - (arg as UTSJSONObject).toMap().forEach((value, key) => { - if (isValidStyleValue(value)) { - result.push(`${toKebabCase(key)}:${value}`) - } - }) - // #endif - // #endif - } - } - - return result.join(';') -} - -/** - * 将对象转换为 CSS 自定义属性字符串 - * @param obj - 包含主题变量的对象 - * @param prefix - CSS 变量的前缀,默认为 '--l-' - * @returns CSS 变量字符串,例如 '--l-image-color: red; --l-bg: blue;' - */ -export function toCssVars(obj : UTSJSONObject, prefix = '--l-') : string { - const cssVars : string[] = []; - - if (typeof obj == 'object') { - // #ifndef APP-ANDROID - for (const key in obj) { - const value = obj[key] - if (isValidStyleValue(value)) { - const cssVarName = prefix + toKebabCase(key); - cssVars.push(`${cssVarName}:${value}`) - } - - } - // #endif - // #ifdef APP-ANDROID - // #ifdef VUE3-VAPOR - for (const key in obj) { - const value = obj[key] - if (isValidStyleValue(value)) { - const cssVarName = prefix + toKebabCase(key); - cssVars.push(`${cssVarName}:${value}`) - } - - } - // #endif - // #ifndef VUE3-VAPOR - (obj as UTSJSONObject).toMap().forEach((value, key) => { - if (isValidStyleValue(value)) { - const cssVarName = prefix + toKebabCase(key); - cssVars.push(`${cssVarName}:${value}`) - } - }) - // #endif - // #endif - - } - - - return cssVars.join(';') + ';'; // 加上最后的分号以符合 CSS 规范 -} \ No newline at end of file diff --git a/uni_modules/lime-shared/throttle/index.ts b/uni_modules/lime-shared/throttle/index.ts deleted file mode 100644 index 65604cb..0000000 --- a/uni_modules/lime-shared/throttle/index.ts +++ /dev/null @@ -1,89 +0,0 @@ -// @ts-nocheck -/** - * 节流函数,用于限制函数的调用频率 - * @param fn 要进行节流的函数 - * @param interval 两次调用之间的最小间隔时间 - * @returns 节流后的函数 - */ -export type ThrottleOptions = { - /** - * 是否在节流开始时立即执行 - * @default true - */ - leading ?: boolean; - - /** - * 是否在节流结束后执行最后一次调用 - * @default true - */ - trailing ?: boolean; -} - - - -/** - * 节流函数,限制函数在一定时间内只能执行一次 - * @param func 需要节流的函数 - * @param wait 节流间隔时间(毫秒) - * @param options 配置选项 - * @param options.leading 是否在节流开始时立即执行(默认 true) - * @param options.trailing 是否在节流结束时执行最后一次调用(默认 true) - * @returns 返回节流后的函数 - */ -// #ifndef APP-ANDROID -export function throttle any>( - func : T, - wait : number, - options : ThrottleOptions = {} -) : (...args : Parameters) => void { - let lastCallTime = 0; - let timerId : ReturnType | null = null; - const { leading = true, trailing = true } = options; - return function (...args : Parameters) { - const now = Date.now(); - const timeSinceLastCall = now - lastCallTime; - // 1. 如果 leading=true 且距离上次调用超过 wait,立即执行 - if (leading && timeSinceLastCall >= wait) { - lastCallTime = now; - func.apply(this, args); - } - // 2. 如果 trailing=true,设置定时器在 wait 时间后执行最后一次调用 - else if (trailing && !timerId) { - timerId = setTimeout(() => { - lastCallTime = Date.now(); - func.apply(this, args); - timerId = null; - }, wait - timeSinceLastCall); - } - }; -} -// #endif - -// #ifdef APP-ANDROID -export function throttle( - func: (args : T) => void, - wait : number, - options : ThrottleOptions = {} -) : (args : T) => void { - let lastCallTime = 0; - let timerId = -1; - const { leading = true, trailing = true } = options; - return function (args : T) { - const now = Date.now(); - const timeSinceLastCall = now - lastCallTime; - // 1. 如果 leading=true 且距离上次调用超过 wait,立即执行 - if (leading && timeSinceLastCall >= wait) { - lastCallTime = now; - func(args); - } - // 2. 如果 trailing=true,设置定时器在 wait 时间后执行最后一次调用 - else if (trailing && timerId > -1) { - timerId = setTimeout(() => { - lastCallTime = Date.now(); - func(args); - timerId = -1; - }, wait - timeSinceLastCall); - } - }; -} -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/throttle/index_old.ts b/uni_modules/lime-shared/throttle/index_old.ts deleted file mode 100644 index 914be49..0000000 --- a/uni_modules/lime-shared/throttle/index_old.ts +++ /dev/null @@ -1,112 +0,0 @@ -// @ts-nocheck -/** - * 节流函数,用于限制函数的调用频率 - * @param fn 要进行节流的函数 - * @param delay 两次调用之间的最小间隔时间 - * @returns 节流后的函数 - */ - -// #ifndef UNI-APP-X && APP -// export function throttle(fn: (...args: any[]) => void, delay: number, options) { -// let flag = true; // 标记是否可以执行函数 - -// return (...args: any[]) => { -// if (flag) { -// flag = false; // 设置为不可执行状态 -// fn(...args); // 执行传入的函数 - -// setTimeout(() => { -// flag = true; // 经过指定时间后,设置为可执行状态 -// }, delay); -// } -// }; -// } - -export function throttle void>( - fn: T, - delay: number, - { leading = true, trailing = true }: { leading?: boolean; trailing?: boolean } = {} -): (...args: Parameters) => void { - let isCoolingDown = false; - let lastArgs: Parameters | null = null; - let timerId: ReturnType | null = null; - - const executeTrailing = () => { - if (trailing && lastArgs) { - fn(...lastArgs); - lastArgs = null; - } - isCoolingDown = false; - timerId = null; - }; - - return function (...args: Parameters) { - // 1. 如果不在冷却期,且 leading=true,立即执行 - if (!isCoolingDown && leading) { - fn(...args); - isCoolingDown = true; - timerId = setTimeout(executeTrailing, delay); - } - // 2. 如果在冷却期,记录最后一次调用的参数(用于 trailing) - else if (trailing) { - lastArgs = args; - } - }; -} -// #endif - - -// #ifdef UNI-APP-X && APP -// type Rfun = (...args: any[]) => void -// type Rfun = (...args: any[]) => void - -export function throttle( - fn: (args : T) => void, - delay: number):(args : T) => void { - let flag = true; // 标记是否可以执行函数 - - return (args : T) =>{ - if(flag){ - flag = false; - fn(args); - - setTimeout(()=>{ - flag = true; - }, delay) - } - } - // return (...args: any[]) => { - // // if (flag) { - // // flag = false; // 设置为不可执行状态 - // // fn(...args); // 执行传入的函数 - - // // setTimeout(() => { - // // flag = true; // 经过指定时间后,设置为可执行状态 - // // }, delay); - // // } - // }; -} - -// #endif - -// // 示例 -// // 定义一个被节流的函数 -// function handleScroll() { -// console.log("Scroll event handled!"); -// } - -// // 使用节流函数对 handleScroll 进行节流,间隔时间为 500 毫秒 -// const throttledScroll = throttle(handleScroll, 500); - -// // 模拟多次调用 handleScroll -// throttledScroll(); // 输出 "Scroll event handled!" -// throttledScroll(); // 不会输出 -// throttledScroll(); // 不会输出 - -// // 经过 500 毫秒后,再次调用 handleScroll -// setTimeout(() => { -// throttledScroll(); // 输出 "Scroll event handled!" -// }, 500); - - - diff --git a/uni_modules/lime-shared/toArray/index.ts b/uni_modules/lime-shared/toArray/index.ts deleted file mode 100644 index e0840d2..0000000 --- a/uni_modules/lime-shared/toArray/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -// @ts-nocheck -/** - * 将一个或多个元素转换为数组 - * @param item 要转换为数组的元素 - * @returns 转换后的数组 - */ -// #ifndef UNI-APP-X && APP -export const toArray = (item: T | T[]): T[] => Array.isArray(item) ? item : [item]; -// #endif - - -// #ifdef UNI-APP-X && APP -export function toArray(item: any): T[] { - return Array.isArray(item) ? item as T[] : [item as T]// as T[] -}; -// #endif -// 示例 -// console.log(toArray(5)); // 输出: [5] -// console.log(toArray("hello")); // 输出: ["hello"] -// console.log(toArray([1, 2, 3])); // 输出: [1, 2, 3] -// console.log(toArray(["apple", "banana"])); // 输出: ["apple", "banana"] \ No newline at end of file diff --git a/uni_modules/lime-shared/toBoolean/index.ts b/uni_modules/lime-shared/toBoolean/index.ts deleted file mode 100644 index 1af7395..0000000 --- a/uni_modules/lime-shared/toBoolean/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -// @ts-nocheck -import { isNumber } from '../isNumber' -import { isString } from '../isString' -// 函数重载,定义多个函数签名 -// function toBoolean(value : any) : boolean; -// function toBoolean(value : string) : boolean; -// function toBoolean(value : number) : boolean; -// function toBoolean(value : boolean) : boolean; - -// #ifdef UNI-APP-X && APP -export function toBoolean(value : any | null) : boolean { - // 根据输入值的类型,返回相应的布尔值 - // if (isNumber(value)) { - // return (value as number) != 0; - // } - // if (isString(value)) { - // return `${value}`.length > 0; - // } - // if (typeof value == 'boolean') { - // return value as boolean; - // } - // #ifdef APP-IOS || APP-HARMONY - return value != null && value != undefined - // #endif - // #ifdef APP-ANDROID - return value != null - // #endif -} -// #endif - - -// #ifndef UNI-APP-X && APP -export function toBoolean(value : any | null) : value is NonNullable { - return !!value//value !== null && value !== undefined; -} -// #endif diff --git a/uni_modules/lime-shared/toNumber/index.ts b/uni_modules/lime-shared/toNumber/index.ts deleted file mode 100644 index a8e1b1d..0000000 --- a/uni_modules/lime-shared/toNumber/index.ts +++ /dev/null @@ -1,28 +0,0 @@ -// @ts-nocheck -/** - * 将字符串转换为数字 - * @param val 要转换的字符串 - * @returns 转换后的数字或原始字符串 - */ - -// #ifdef UNI-APP-X && APP -// function toNumber(val: string): number -// function toNumber(val: string): string -function toNumber(val: string): number|null { - const n = parseFloat(val); // 使用 parseFloat 函数将字符串转换为浮点数 - return isNaN(n) ? null : n; // 使用 isNaN 函数判断是否为非数字,返回转换后的数字或原始字符串 -} -export {toNumber} -// #endif - -// #ifndef UNI-APP-X && APP -export function toNumber(val: string): number | string { - const n = parseFloat(val); // 使用 parseFloat 函数将字符串转换为浮点数 - return isNaN(n) ? val : n; // 使用 isNaN 函数判断是否为非数字,返回转换后的数字或原始字符串 -} -// #endif - -// 示例 -// console.log(toNumber("123")); // 输出: 123 -// console.log(toNumber("3.14")); // 输出: 3.14 -// console.log(toNumber("hello")); // 输出: "hello" \ No newline at end of file diff --git a/uni_modules/lime-shared/uniqid/index.ts b/uni_modules/lime-shared/uniqid/index.ts deleted file mode 100644 index b9ac5f8..0000000 --- a/uni_modules/lime-shared/uniqid/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -// @ts-nocheck -let counter = 0; -export function uniqid(prefix : string = 'lime') { - // #ifdef WEB - if (typeof crypto !== 'undefined' && crypto.randomUUID) { - const uuid = crypto.randomUUID().replace(/-/g, '_'); - return `${prefix}_${uuid}`; - } - // #endif - - // fallback:时间戳 + 随机 + 计数器 - const time = Date.now().toString(36); // 时间戳(毫秒),确保跨刷新唯一 - const random = Math.random().toString(36).substring(2, 10).padEnd(8, '0'); // 随机部分,取前8位足够 - const count = (++counter).toString(36).padStart(4, '0'); // 计数器补零,避免太短 - - return `${prefix}_${time}_${random}_${count}`; -} \ No newline at end of file diff --git a/uni_modules/lime-shared/unitConvert/index.ts b/uni_modules/lime-shared/unitConvert/index.ts deleted file mode 100644 index 7a049a3..0000000 --- a/uni_modules/lime-shared/unitConvert/index.ts +++ /dev/null @@ -1,94 +0,0 @@ -// @ts-nocheck -import { isString } from '../isString' -import { isNumeric } from '../isNumeric' - -/** - * 单位转换函数,将字符串数字或带有单位的字符串转换为数字 - * @param value 要转换的值,可以是字符串数字或带有单位的字符串 - * @returns 转换后的数字,如果无法转换则返回0 - */ -// #ifndef UNI-APP-X && APP -export function unitConvert(value : string | number | null | undefined, base : number = 0) : number { - if (value == null) return NaN - // 如果是字符串数字 - if (isNumeric(value)) { - return Number(value); - } - // 如果有单位 - if (isString(value)) { - const reg = /^-?([0-9]+)?([.]{1}[0-9]+){0,1}(em|rpx|px|%)$/g; - const results = reg.exec(value); - if (!value || !results) { - return NaN; - } - const unit = results[3]; - const _value = parseFloat(value); - if (unit === 'rpx') { - return uni.upx2px(_value); - } - if (unit === 'px') { - return _value * 1; - } - if (unit == '%') { - return _value / 100 * base - } - // 如果是其他单位,可以继续添加对应的转换逻辑 - } - return NaN; -} -// #endif - - -// #ifdef UNI-APP-X && APP -import { isNumber } from '../isNumber' -export function unitConvert(value : any | null, base : number = 0) : number { - if (value == null) return NaN - if (isNumber(value)) { - return value as number - } - // 如果是字符串数字 - if (isNumeric(value)) { - return parseFloat(value as string); - } - // 如果有单位 - if (isString(value)) { - const reg = /^-?([0-9]+)?([.]{1}[0-9]+){0,1}(em|rpx|px|%)$/g; - const results = reg.exec(value as string); - if (results == null) { - return NaN; - } - const unit = results[3]; - const _value = parseFloat(value); - if (unit == 'rpx') { - return uni.rpx2px(_value) - } - if (unit == 'px') { - return _value; - } - if (unit == '%') { - return _value / 100 * base - } - // 如果是其他单位,可以继续添加对应的转换逻辑 - } - return NaN; -} -// #endif - -export function parseUnit( - // #ifndef UNI-APP-X && APP - value : string | number | null | undefined, - // #endif - // #ifdef UNI-APP-X && APP - value : string | number | null, - // #endif - base : number = 0 -) : number | null { - const result = unitConvert(value, base); - return isNaN(result) ? null : result; -} - -// 示例 -// console.log(unitConvert("123")); // 输出: 123 (字符串数字转换为数字) -// console.log(unitConvert("3.14em")); // 输出: 0 (无法识别的单位) -// console.log(unitConvert("20rpx")); // 输出: 根据具体情况而定 (根据单位进行转换) -// console.log(unitConvert(10)); // 输出: 10 (数字不需要转换) \ No newline at end of file diff --git a/uni_modules/lime-shared/useVModel/index.ts b/uni_modules/lime-shared/useVModel/index.ts deleted file mode 100644 index 270bca9..0000000 --- a/uni_modules/lime-shared/useVModel/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// @ts-nocheck -import {ref, watch, type Ref, ComputedRef } from '../vue' -type UseVModelOptions = { - value: ComputedRef | (() => T) - // 默认值 - defaultValue: T - // 变化回调 - onChange?: (value: T) => void - // 格式化函数(用于get时格式化返回值) - onFormat?: (value: T) => T - // 是否深度监听 - deep?: boolean - // 是否立即触发监听 - immediate?: boolean - // 事件名称 - eventName?: string - // 属性名称 - propName?: string -} - -export function useVModel(options: UseVModelOptions):Ref { - const { value, defaultValue, onChange, onFormat } = options - const innerValue = ref(value.value || defaultValue); - - watch(value, (newVal:T) => { - innerValue.value = onFormat?.(newVal) ?? newVal - }, - { immediate: true } - ) - watch( - innerValue, - (newVal: T) => { - onChange?.(newVal) - } - ) - - return innerValue -} \ No newline at end of file diff --git a/uni_modules/lime-shared/vue/index.ts b/uni_modules/lime-shared/vue/index.ts deleted file mode 100644 index 6428fca..0000000 --- a/uni_modules/lime-shared/vue/index.ts +++ /dev/null @@ -1,105 +0,0 @@ -// @ts-nocheck - -// #ifdef VUE3 -export * from 'vue'; -// #endif - -// #ifndef VUE3 -// #ifndef VUE2 && APP -export * from '@vue/composition-api'; -// #endif - -// #ifdef VUE2 -export * from '@vue/composition-api'; -import * as _vue from '@vue/composition-api'; - -export function toValue(source) { - // 处理函数 - if (typeof source === 'function') { - return source(); - } - - // 处理 ref - if (_vue.isRef(source)) { - return source.value; - } - - // reactive 对象直接返回 - return source; -} - -// #endif - -// #ifdef VUE2 && APP -/** - * 在 Vue 2 中模拟 onScopeDispose - * 原理:利用组件的 beforeDestroy 钩子来执行清理函数 - */ -// export function onScopeDispose(fn) { -// if(_vue.onScopeDispose) { -// _vue.onScopeDispose(fn) -// } -// } - -// vue2 app computed无法响应 -export function computed(getterOrOptions) { - const isGetter = typeof getterOrOptions === 'function'; - const getter = isGetter ? getterOrOptions : getterOrOptions.get; - const setter = !isGetter ? getterOrOptions.set : undefined; - - if (typeof getter !== 'function') { - throw new Error('computed 的 getter 必须是一个函数'); - } - - if (!isGetter) { - if (!getterOrOptions || typeof getterOrOptions !== 'object') { - throw new Error('computed 参数必须是函数或包含 get 方法的对象'); - } - if (!getterOrOptions.get) { - throw new Error('computed 对象必须包含 get 方法'); - } - if (setter !== undefined && typeof setter !== 'function') { - throw new Error('computed 的 setter 必须是函数'); - } - } - - const internalValue = _vue.ref(getter()); - const result = _vue.customRef((track, trigger) => { - return { - get() { - track(); - return internalValue.value; - }, - set(newValue) { - internalValue.value = newValue - if (setter) { - setter(newValue) - } - trigger() - } - }; - }); - - const stop = _vue.watchEffect(() => { - const newValue = getter(); - internalValue.value = newValue - }) - - if(_vue.getCurrentScope()){ - _vue.onScopeDispose(() => { - stop(); - }); - } - - return result; -} -// #endif - - -// #ifdef APP-NVUE -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -// #endif - -// #endif \ No newline at end of file diff --git a/uni_modules/lime-shared/while/index.ts b/uni_modules/lime-shared/while/index.ts deleted file mode 100644 index 1b8a96b..0000000 --- a/uni_modules/lime-shared/while/index.ts +++ /dev/null @@ -1,55 +0,0 @@ -// @ts-nocheck - -// 来自kux大佬的神之一手 -// 原地址 https://ext.dcloud.net.cn/plugin?id=23291 -export type ControlCommand = 'continue' | 'break' | null; - -export type ControllableWhileReturn = { - start: () => void; - abort: () => void; - execContinue: () => 'continue'; - execBreak: () => 'break'; -}; - -export type Controller = { - abort: () => void; -}; - -export function controllableWhile( - condition : () => boolean, - body: (controller: Controller) => ControlCommand -): ControllableWhileReturn { - let isActive = true; - - const controller: Controller = { - abort: () => { - isActive = false; - } - }; - - const execContinue = () => 'continue'; - const execBreak = () => 'break'; - - return { - start: () => { - // #ifdef APP-ANDROID - UTSAndroid.getDispatcher('io').async((_) => { - // #endif - while (isActive && condition()) { - const result = body(controller); - if (result == 'break') { - controller.abort(); - break; - } else if (result == 'continue') { - continue; - } - } - // #ifdef APP-ANDROID - }, null); - // #endif - }, - abort: controller.abort, - execContinue: execContinue, - execBreak: execBreak - } as ControllableWhileReturn; -} \ No newline at end of file diff --git a/uni_modules/lime-style/changelog.md b/uni_modules/lime-style/changelog.md deleted file mode 100644 index 1404b4f..0000000 --- a/uni_modules/lime-style/changelog.md +++ /dev/null @@ -1,50 +0,0 @@ -## 0.2.5(2025-12-15) -- chore: 更新函数 -## 0.2.4(2025-11-14) -- feat: 优化create-var -## 0.2.3(2025-10-19) -- fix: 修复非uts环境使用set的问题 -## 0.2.2(2025-10-15) -- fix: 去掉版本判断 -## 0.2.1(2025-10-15) -- fix: 修复条件判断问题 -## 0.2.0(2025-10-01) -- fix: 修复uniapp主题变化报错问题 -## 0.1.9(2025-09-26) -- feat: 更新宫格暗黑hover颜色 -## 0.1.8(2025-09-08) -- feat: 去掉vue2的判断 -## 0.1.7(2025-08-15) -更新变量 -## 0.1.6(2025-06-20) -- feat: 放弃使用rpx -## 0.1.5(2025-06-20) -- fix: 修复 vue2 rpx转成px的问题 -## 0.1.4(2025-06-12) -- feat: 增加一些函数 -## 0.1.3(2025-05-07) -- feat: 增加`hairline`函数 -## 0.1.2(2025-04-24) -- feat: 根据官方建议,字体使用px -## 0.1.1(2025-03-25) -- feat: 更换rbgToHsv算法 -## 0.1.0(2025-03-13) -- feat: hbx4.56 Vue2 scss 预编译器默认已由 node-sass 更换为 dart-sass -## 0.0.9(2025-01-16) -- feat: 更新 -## 0.0.8(2024-12-15) -- fix: 修复vue2 不支持rgba(0,0,0,1%) -## 0.0.7(2024-12-11) -- feat: 增加除法 -## 0.0.6(2024-12-04) -- fix: 除法问题 -## 0.0.5(2024-11-20) -- feat: 增加flex -## 0.0.4(2024-11-20) -- feat: 增加flex -## 0.0.3(2024-09-30) -- fix: 由于 vue2 h5 css变量不支持rpx,故转成px -## 0.0.2(2024-09-23) -- fix: 修复 vue2 math.div 问题 -## 0.0.1(2024-09-02) -- init diff --git a/uni_modules/lime-style/color/colorPalette.scss b/uni_modules/lime-style/color/colorPalette.scss deleted file mode 100644 index 6408e72..0000000 --- a/uni_modules/lime-style/color/colorPalette.scss +++ /dev/null @@ -1,236 +0,0 @@ -/* #ifdef VUE3 */ -@use "sass:math"; -/* #endif */ - - - -$hueStep: 2; -$saturationStep1: 0.16; -$saturationStep2: 0.05; -$brightnessStep1: 0.05; -$brightnessStep2: 0.15; -$lightColorCount: 5; -$darkColorCount: 4; - -$darkColorMap: ( - (index: 7, opacity: 0.15), - (index: 6, opacity: 0.25), - (index: 5, opacity: 0.3), - (index: 5, opacity: 0.45), - (index: 5, opacity: 0.65), - (index: 5, opacity: 0.85), - (index: 4, opacity: 0.9), - (index: 3, opacity: 0.95), - (index: 2, opacity: 0.97), - (index: 1, opacity: 0.98) -); - -@function div($dividend, $divisor) { - /* #ifdef VUE3 */ - @return math.div($dividend, $divisor); - /* #endif - /* #ifndef VUE3 */ - @return $dividend / $divisor; - /* #endif */ -} - -// 求一个数的n次幂 -@function pow($number, $n) { - $ret: 1; - @if $n >= 0 { - @for $i from 1 through $n { - $ret: $ret * $number; - } - } @else { - @for $i from $n to 0 { - $ret: $ret / $number; - } - } - @return $ret; -} - -// 浮点数保留小数位 -@function toFixed($float, $digits: 2) { - $pow: pow(10, $digits); - @return div(round($float * $pow) , $pow); -} - - -// 根据颜色获取对应的hsv,在tinycolor中首先进行了归一化处理,这里没有 -// 返回的结果h是0~360,代表的是色相的角度, sv的范围0-1 -@function rbgToHsv($limeColor) { - $r: red($limeColor); - $g: green($limeColor); - $b: blue($limeColor); - $max: max($r, $g, $b); - $min: min($r, $g, $b); - $diff: $max - $min; - $h: 0; - - @if $max == $min { - $h: 0 - } @else if $max == $r { - $h: div(60 * ($g - $b) , $diff) + if($g >= $b, 0, 360); - } @else if $max == $g { - $h: 60 * div($b - $r , $diff) + 120 //($b - $r) / $diff + 120; - } @else if $max == $b{ - $h: div(60 * ($r - $g) , $diff) + 240; - } - - $s: if($max == 0, 0, div($diff , $max)); - $v: div($max , 255); - - @return $h, $s, $v; -} -// hsv转化成rgb,借鉴了tinycolor的做法,避免通过$th的值判断来获取对应的rgb的取值 -// $t1~4的计算目前不清楚为什么这样做 -@function hsvTorgb($h, $s, $v) { - // $th: floor(div($h , 60)); - // $t1: div($h , 60) - $th; - // $t2: $v * (1 - $s); - // $t3: $v * (1 - $t1 * $s); - // $t4: $v * (1 - (1 - $t1) * $s); - // $i: $th + 1; - // $r: nth(($v, $t3, $t2, $t2, $t4, $v), $i); - // $g: nth(($t4, $v, $v, $t3, $t2, $t2), $i); - // $b: nth(($t2, $t2, $t4, $v, $v, $t3), $i); - - // @return rgb($r * 255, $g * 255, $b * 255); - $h: $h % 360; - - // 2. 计算色相区域 (0~5),对应6个60度区间 - $th: floor(div($h, 60)) % 6; // 强制th在0~5之间 - - // 3. 计算中间变量 - $t1: div($h, 60) - $th; - $t2: $v * (1 - $s); - $t3: $v * (1 - $t1 * $s); - $t4: $v * (1 - (1 - $t1) * $s); - - // 4. 根据色相区域选择RGB分量 - $i: $th + 1; // 索引范围锁定为1~6 - - // 定义各区域对应的RGB系数 - $r-values: ($v, $t3, $t2, $t2, $t4, $v); - $g-values: ($t4, $v, $v, $t3, $t2, $t2); - $b-values: ($t2, $t2, $t4, $v, $v, $t3); - - // 5. 获取RGB分量并转换为0~255整数 - $r: nth($r-values, $i) * 255; - $g: nth($g-values, $i) * 255; - $b: nth($b-values, $i) * 255; - - // 6. 返回RGB颜色值 - @return rgb(round($r), round($g), round($b)); -} - -//转换色相 -@function getHue($h, $i, $isLight) { - $hue: null; - @if $h >= 60 and $h <= 240 { - $hue: if($isLight, $h - $hueStep * $i, $h + $hueStep * $i); - } @else { - $hue: if($isLight, $h + $hueStep * $i, $h - $hueStep * $i); - } - - $hue: ($hue + 360) % 360; - - @return round($hue); -} - -// 转换饱和度 -@function getSaturation($s, $i, $isLight) { - $saturation: null; - @if $isLight { - $saturation: $s - $saturationStep1 * $i; - } @else if $i == $darkColorCount { - $saturation: $s + $saturationStep1; - } @else { - $saturation: $s + $saturationStep2 * $i; - } - $saturation: min($saturation, 1); - - @if $isLight and $i == $lightColorCount and $saturation > 0.1 { - $saturation: 0.1; - } - - $saturation: max($saturation, 0.06); - - @return toFixed($saturation, 2); -} - -// 转换明度 -@function getValue($v, $i, $isLight) { - $value: min( - if( - $isLight, - $v + $brightnessStep1 * $i, - $v - $brightnessStep2 * $i - ), - 1); - - @return toFixed($value, 2); -} - - -@function mix($rgb1, $rgb2, $amount){ - $p: $amount; - $r: (red($rgb2) - red($rgb1)) * $p + red($rgb1); - $g: (green($rgb2) - green($rgb1)) * $p + green($rgb1); - $b: (blue($rgb2) - blue($rgb1)) * $p + blue($rgb1); - - @return rgb($r, $g, $b) -} - -// 根据颜色和对应的色板位置,计算出对应的色板颜色 -@function genColor($color, $index, $theme: 'default' , $bgColor: #242424) { - $isLight: if($index <= 6, true, false); - $hsv: rbgToHsv($color); - //这里将i转换成以主色为中心,两侧的i值逐渐增大 - $i: if($isLight, $lightColorCount + 1 - $index, $index - $lightColorCount - 1); - - @if $theme == 'dark' { - $item: nth($darkColorMap, $index); - $index2: map-get($item, index); - $opacity: map-get($item, opacity); - - $rgb: genColor($color, $index2 + 1); - - // @return $rgb; - @return mix( - $bgColor, - $rgb, - $opacity - ) - } - - @return hsvTorgb( - getHue(nth($hsv, 1), $i, $isLight), - getSaturation(nth($hsv, 2), $i, $isLight), - getValue(nth($hsv, 3), $i, $isLight) - ); -} - -@function getSolidColor($base-color, $brightness) { - // 验证输入参数 - @if type-of($base-color) != 'color' { - @error "Expected color for $base-color, but got #{type-of($base-color)}: #{$base-color}"; - } - - @if type-of($brightness) != 'number' { - @error "Expected number for $brightness, but got #{type-of($brightness)}: #{$brightness}"; - } - - // 获取基础颜色的HSL值 - $hue: hue($base-color); - $saturation: saturation($base-color); - $lightness: lightness($base-color); - - // 计算新的亮度值 (限制在0-100%范围内) - $new-lightness: clamp(0%, $lightness + $brightness, 100%); - - // 使用HSL函数创建新颜色 - $new-color: hsl($hue, $saturation, $new-lightness); - - @return $new-color; -} \ No newline at end of file diff --git a/uni_modules/lime-style/color/colors.scss b/uni_modules/lime-style/color/colors.scss deleted file mode 100644 index 2f1a1d5..0000000 --- a/uni_modules/lime-style/color/colors.scss +++ /dev/null @@ -1,18 +0,0 @@ -// 品牌色-主色 -$primary-color: #3283ff!default; -// 错误色 -$error-color: #FF4D4F!default; -// 警告色 -$warning-color: #ffb400!default;// #FF7D00!default; -// 信息色 -$info-color: $primary-color!default; -// 成功色 -$success-color: #34c471!default; - -$blue: #3283ff!default; -$red: #FF4D4F!default; -$orange: #ffb400!default; -$yellow: #fcd53f!default; -$green: #34c471 !default; -$white: #fff; -$black: #000; diff --git a/uni_modules/lime-style/functions.scss b/uni_modules/lime-style/functions.scss deleted file mode 100644 index 8332c1a..0000000 --- a/uni_modules/lime-style/functions.scss +++ /dev/null @@ -1,11 +0,0 @@ -/* #ifdef VUE3 */ -@use "sass:math"; -// #endif -@function divide($dividend, $divisor) { - /* #ifdef VUE3 */ - @return math.div($dividend, $divisor); - /* #endif - /* #ifndef VUE3 */ - @return $dividend / $divisor; - /* #endif -} diff --git a/uni_modules/lime-style/hairline.uts b/uni_modules/lime-style/hairline.uts deleted file mode 100644 index 8dc0d89..0000000 --- a/uni_modules/lime-style/hairline.uts +++ /dev/null @@ -1,153 +0,0 @@ -import { unitConvert } from '@/uni_modules/lime-shared/unitConvert'; - -export type DrawBorderOptions = { - direction : 'top' | 'bottom' | 'left' | 'right'; - color ?: string; - colorKey ?: string; // 在dom中获取颜色 - startOffsetKey?: string; // 在dom哪个属性获取 - startOffset ?: number | string; // 支持数字或 CSS 字符串(如 '10px') - endOffset ?: number | string; - lineWidth ?: number; - watchSize ?: boolean; // 是否监听尺寸变化自动重绘 - immediate ?: boolean; // 是否立即绘制 - bordered?: boolean; - -} - -export type UseDrawBorderReturn = { - color: Ref, - renderBorder: () => void, - clearBorder: () => void; - dispose: () => void, -} -/** - * 在元素上绘制边框,并支持动态监听尺寸变化 - * @param elementRef 目标元素的 Ref - * @param options 边框配置 - * @returns 清理函数(用于卸载时取消监听) - */ -export function useDrawBorder( - elementRef : Ref, - options : DrawBorderOptions -):UseDrawBorderReturn { - let resizeObserver : UniResizeObserver | null = null; - const { watchSize = true, immediate = true } = options; - const defalutColor = '#e7e7e7' - const color = ref(options.color ?? defalutColor) - const bordered = ref(options.bordered ?? true) - let computedStartOffset = 0 - let computedEndOffset = 0 - - // 绘制边框 - const renderBorder = () => { - if (elementRef.value == null) return; - const ctx = elementRef.value!.getDrawableContext(); - if (ctx == null) return; - - const rect = elementRef.value!.getBoundingClientRect(); - ctx.reset(); - - const { - direction, - startOffset = 0, - endOffset = 0, - lineWidth = 0.5, - colorKey, - startOffsetKey, - } = options; - - - // 转换单位(如果是字符串,如 '10px') - if(computedStartOffset == 0) { - computedStartOffset = unitConvert((startOffsetKey != null ? elementRef.value?.style.getPropertyValue(startOffsetKey!) ?? startOffset : startOffset)) - } - if(computedEndOffset == 0) { - computedEndOffset = unitConvert(endOffset) - } - - if(color.value == defalutColor && colorKey != null) { - color.value = elementRef.value?.style.getPropertyValue(colorKey!) ?? defalutColor - // if(color.value.length == 0) { - // color.value = defalutColor - // } - } - ctx.strokeStyle = color.value; - ctx.lineWidth = lineWidth; - - // 根据方向计算坐标 - switch (direction) { - case 'top': - ctx.moveTo(computedStartOffset, 0); - ctx.lineTo(rect.width - computedEndOffset, 0); - break; - case 'bottom': - ctx.moveTo(computedStartOffset, rect.height - 0.25); - ctx.lineTo(rect.width - computedEndOffset, rect.height - 0.25); - break; - case 'left': - ctx.moveTo(0, computedStartOffset); - ctx.lineTo(0, rect.height - computedEndOffset); - break; - case 'right': - ctx.moveTo(rect.width, computedStartOffset); - ctx.lineTo(rect.width, rect.height - computedEndOffset); - break; - } - - ctx.stroke(); - ctx.update(); - }; - - const setupResizeObserver = () => { - // 监听尺寸变化(如果启用) - if (watchSize) { - if (resizeObserver == null) { - resizeObserver = new UniResizeObserver((entries : Array) => { - if(!bordered.value) return - renderBorder(); - }) - } - watchEffect(()=>{ - if (elementRef.value != null) { - resizeObserver!.observe(elementRef.value!); - } - }) - } - } - - - // 清理函数(卸载时取消监听) - const dispose = () => { - if (resizeObserver != null && elementRef.value != null) { - // resizeObserver.unobserve(elementRef.value!); - resizeObserver!.disconnect(); - resizeObserver = null; - } - }; - - const clearBorder = ()=> { - if (elementRef.value == null) return; - const ctx = elementRef.value!.getDrawableContext(); - if (ctx == null) return; - bordered.value = false - ctx.reset() - ctx.update() - } - - setupResizeObserver() - // 初始绘制 - if(immediate) { - renderBorder(); - } - - - - - return { - renderBorder, // 手动触发绘制 - dispose, // 清理监听 - clearBorder, - color - } as UseDrawBorderReturn - -} \ No newline at end of file diff --git a/uni_modules/lime-style/index.scss b/uni_modules/lime-style/index.scss deleted file mode 100644 index b9711c7..0000000 --- a/uni_modules/lime-style/index.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import './theme/default'; -@import './var'; -@import './mixins/ellipsis'; -@import './mixins/hairline'; -@import './mixins/create'; -@import './mixins/directionalProperty'; -// @import './mixins/useTheme'; \ No newline at end of file diff --git a/uni_modules/lime-style/index.uts b/uni_modules/lime-style/index.uts deleted file mode 100644 index 208438f..0000000 --- a/uni_modules/lime-style/index.uts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './token/useThemeMode' -export * from './token/useThemeVars' -export * from './token/interface' \ No newline at end of file diff --git a/uni_modules/lime-style/mixins/bem.scss b/uni_modules/lime-style/mixins/bem.scss deleted file mode 100644 index e69de29..0000000 diff --git a/uni_modules/lime-style/mixins/create.scss b/uni_modules/lime-style/mixins/create.scss deleted file mode 100644 index ea313a9..0000000 --- a/uni_modules/lime-style/mixins/create.scss +++ /dev/null @@ -1,235 +0,0 @@ -/* #ifdef VUE3 */ -@use "sass:math"; -/* #endif */ - -/* #ifndef UNI-APP-X && APP || APP-NVUE */ -$use-css-var: true !default; -/* #endif */ -/* #ifdef UNI-APP-X && APP || APP-NVUE */ -$use-css-var: false !default; -/* #endif */ - - -@function div($dividend, $divisor) { - /* #ifdef VUE3 */ - @return math.div($dividend, $divisor); - /* #endif */ - /* #ifndef VUE3 */ - @return $dividend / $divisor; - /* #endif */ -} - -@function rpx-to-px($value) { - // 递归处理列表 - @if type-of($value) == list { - $new-list: (); - @each $item in $value { - $new-list: append($new-list, rpx-to-px($item)); - } - @return $new-list; - } - - // 处理数字类型 - 带 rpx 单位 - @if type-of($value) == number and unit($value) == 'rpx' { - // 安全处理单位转换 - @return calc-strip-unit($value) * 0.5 * 1px; - } - - // 处理字符串类型 - @if type-of($value) == string { - $string: $value; - $rpx-index: str-index($string, 'rpx'); - - // 如果字符串以数字开头并以 rpx 结尾,转换为数值 - @if $rpx-index == (str-length($string) - 2) { - $num-str: str-slice($string, 1, $rpx-index - 1); - $number: to-number($num-str); - @if type-of($number) == number { - @return $number * 0.5 * 1px; - } - } - - // 字符串中可能包含多个 rpx 值 - @if $rpx-index { - $result: ''; - @while $rpx-index { - // 找到数字部分起点 - $num-end: $rpx-index - 1; - $num-start: $num-end; - @while $num-start > 0 and is-numeric-char(str-slice($string, $num-start, $num-start)) { - $num-start: $num-start - 1; - } - - // 提取数字部分 - $num-str: str-slice($string, $num-start + 1, $num-end); - $number: to-number($num-str); - - // 转换为 px 数值 - $px-value: $number * 0.5 * 1px; - - // 构建结果字符串 - $result: $result + str-slice($string, 1, $num_start) + '#{$px_value}'; - - // 更新剩余字符串 - $string: str-slice($string, $rpx-index + 3); - $rpx-index: str-index($string, 'rpx'); - } - @return #{$result + $string}; - } - } - - // 其他类型直接返回 - @return $value; -} - -// 辅助函数:安全去除单位并返回数值 -@function calc-strip-unit($number) { - @if type-of($number) == number { - $unit: unit($number); - $units: ("px": 1px, "rpx": 1rpx, "em": 1em, "rem": 1rem, "%": 1%); - - @if map-has-key($units, $unit) { - @return div($number , map-get($units, $unit)); - } - - @if unitless($number) { - @return $number; - } - } - - @return $number; -} - -// 辅助函数:检查字符是否为数字 -@function is-numeric-char($char) { - $chars: "-.0123456789"; - @return str-index($chars, $char) != null; -} - -// 辅助函数:将字符串安全转换为数字 -@function to-number($string) { - // 如果输入已经是数字,直接返回 - @if type-of($string) == number { - @return $string; - } - - // 处理带符号的数字 - $is-negative: false; - $numeric: ""; - $found-number: false; - - // 提取所有数字字符 - @for $i from 1 through str-length($string) { - $char: str-slice($string, $i, $i); - - @if $char == "-" and $numeric == "" { - $is-negative: true; - } - @else if $char == "." and str-index($numeric, ".") == null { - $numeric: $numeric + $char; - } - @else if $char >= "0" and $char <= "9" { - $numeric: $numeric + $char; - $found-number: true; - } - } - - // 如果有实际数字内容,转换为数值 - @if $found-number { - $result: 0; - $decimal-index: str-index($numeric, "."); - - @if $decimal-index { - // 处理带小数的数字 - $integer-part: str-slice($numeric, 1, $decimal-index - 1); - $decimal-part: str-slice($numeric, $decimal-index + 1); - - @if $integer-part == "" { $integer-part: "0"; } - - $result: to-integer($integer-part); - - $divisor: 1; - @for $i from 1 through str-length($decimal-part) { - $divisor: $divisor * 10; - $digit: to-integer(str-slice($decimal-part, $i, $i)); - $result: $result + ($digit / $divisor); - } - } @else { - // 处理整数 - $result: to-integer($numeric); - } - - @return if($is-negative, -$result, $result); - } - - // 无法转换则返回原字符串 - @return $string; -} - -// 辅助函数:将整数字符串转换为数字 -@function to-integer($string) { - $result: 0; - - @for $i from 1 through str-length($string) { - $char: str-slice($string, $i, $i); - $result: $result * 10 + (str-index("0123456789", $char) - 1); - } - - @return $result; -} - -@function create-var($name, $values...) { - // 将不定数量的参数转换为列表 - $value-list: $values; - $css-value: null; - - @if length($value-list) == 0 { - // @warn "The list must have at least 1 values."; - @return ''; - } @else { - // 初始化CSS变量的值为列表中的第一个值 - /* #ifndef VUE2 */ - $css-value: nth($value-list, 1); - /* #endif */ - /* #ifdef VUE2 */ - $css-value: rpx-to-px(nth($value-list, 1)); - /* #endif */ - } - // 检查列表长度是否大于等于2 - @if length($value-list) >= 2 { - // 使用@for循环遍历剩余的值,并构建CSS变量的完整值 - @for $i from 2 through length($value-list) { - /* #ifndef VUE2 */ - $css-value: $css-value + ", " + nth($value-list, $i); - /* #endif */ - /* #ifdef VUE2 */ - $css-value: $css-value + ", " + rpx-to-px(nth($value-list, $i)); - /* #endif */ - } - } - - // /* #ifndef UNI-APP-X */ - // @return var(--l-#{$name}, #{$css-value}); - // /* #endif */ - - // /* #ifdef UNI-APP-X && APP */ - // @if $use-css-var { - // @return var(--l-#{$name}, #{$css-value}); - // } @else { - // @return $css-value; - // } - // /* #endif */ - - - // /* #ifdef APP-NVUE */ - // @return $css-value; - // /* #endif */ - - // @return var(--l-#{$name}, #{$css-value}); - - @if $use-css-var { - @return var(--l-#{$name}, #{$css-value}); - } @else { - @return $css-value; - } -} diff --git a/uni_modules/lime-style/mixins/directionalProperty.scss b/uni_modules/lime-style/mixins/directionalProperty.scss deleted file mode 100644 index 6d23d1a..0000000 --- a/uni_modules/lime-style/mixins/directionalProperty.scss +++ /dev/null @@ -1,401 +0,0 @@ -// ======================================================================= -// 方向属性核心生成器 (支持所有方向相关属性) -// ======================================================================= -@mixin directional-property( - $property, - $values, - $exclude: () -) { - // 属性类型分组 - $group-standard: padding, margin; // 标准方向属性 - $group-radius: border-radius; // 圆角属性 - $group-border: border, border-top, border-right, border-bottom, border-left; // 边框属性 - $group-outline: outline, outline-top, outline-right, outline-bottom, outline-left; // 轮廓属性 - $group-position: inset, inset-block, inset-inline, top, right, bottom, left; // 定位属性 - $group-size: block-size, inline-size; // 块/行尺寸属性 - - // 定义每个方向的值 - $top: null; - $right: null; - $bottom: null; - $left: null; - - // 确定处理模式 - $is-standard: index($group-standard, $property); - $is-radius: index($group-radius, $property); - $is-border: index($group-border, $property); - $is-outline: index($group-outline, $property); - $is-position: index($group-position, $property); - $is-size: index($group-size, $property); - - // ===================================================================== - // 解析输入值 - 根据属性类型处理 - // ===================================================================== - @if type-of($values) == 'list' { - $length: length($values); - - // 单个值 - 所有方向相同值 - @if $length == 1 { - $top: nth($values, 1); - $right: nth($values, 1); - $bottom: nth($values, 1); - $left: nth($values, 1); - } - - // 两个值 - @else if $length == 2 { - // 特殊处理:border-radius - @if $is-radius { - $top: nth($values, 1); - $right: nth($values, 2); - $bottom: nth($values, 1); - $left: nth($values, 2); - } - // 标准处理:上下 | 左右 - @else if $is-standard or $is-border or $is-outline or $is-position { - $top: nth($values, 1); - $bottom: nth($values, 1); - $right: nth($values, 2); - $left: nth($values, 2); - } - // 块/行尺寸处理 - @else if $is-size { - $top: nth($values, 1); - $right: nth($values, 2); - } - } - - // 三个值 - @else if $length == 3 { - // border-radius特殊处理 - @if $is-radius { - $top: nth($values, 1); - $right: nth($values, 2); - $bottom: nth($values, 3); - $left: nth($values, 2); - } - // 标准处理 - @else if $is-standard or $is-border or $is-outline or $is-position { - $top: nth($values, 1); - $right: nth($values, 2); - $left: nth($values, 2); - $bottom: nth($values, 3); - } - } - - // 四个值 - @else if $length == 4 { - $top: nth($values, 1); - $right: nth($values, 2); - $bottom: nth($values, 3); - $left: nth($values, 4); - } - } - @else { - // 单个值传递 - $top: $values; - $right: $values; - $bottom: $values; - $left: $values; - } - - // ===================================================================== - // 生成CSS属性(排除指定方向) - // ===================================================================== - - // 1. 圆角处理 - @if $is-radius { - @if not index($exclude, top-left) and $top != null { - border-top-left-radius: $top; - } - @if not index($exclude, top-right) and $right != null { - border-top-right-radius: $right; - } - @if not index($exclude, bottom-right) and $bottom != null { - border-bottom-right-radius: $bottom; - } - @if not index($exclude, bottom-left) and $left != null { - border-bottom-left-radius: $left; - } - } - - // 2. 标准方向处理 (padding, margin) - @else if $is-standard { - @if not index($exclude, top) and $top != null { - #{$property}-top: $top; - } - @if not index($exclude, right) and $right != null { - #{$property}-right: $right; - } - @if not index($exclude, bottom) and $bottom != null { - #{$property}-bottom: $bottom; - } - @if not index($exclude, left) and $left != null { - #{$property}-left: $left; - } - } - - // 3. 边框处理 - @else if $is-border { - // 完整边框设置 - @if $property == 'border' { - @if not index($exclude, top) and $top != null { - border-top-width: nth($values, 1); - border-top-style: nth($values, 2); - border-top-color: nth($values, 3); - } - @if not index($exclude, right) and $right != null { - border-right-width: nth($values, 1); - border-right-style: nth($values, 2); - border-right-color: nth($values, 3); - } - @if not index($exclude, bottom) and $bottom != null { - // border-bottom: $bottom; - border-bottom-width: nth($values, 1); - border-bottom-style: nth($values, 2); - border-bottom-color: nth($values, 3); - } - @if not index($exclude, left) and $left != null { - // border-left: $left; - border-left-width: nth($values, 1); - border-left-style: nth($values, 2); - border-left-color: nth($values, 3); - } - } - // 单边边框 - @else { - $direction: str-slice($property, 8); // 提取方向 - @if not index($exclude, $direction) { - // #{$property}: $top; - #{$property}-width: nth($values, 1); - #{$property}-style: nth($values, 2); - #{$property}-color: nth($values, 3); - } - } - } - - // 4. 轮廓处理 - @else if $is-outline { - // 完整轮廓设置 - @if $property == 'outline' { - @if not index($exclude, top) and $top != null { - outline-top: $top; - } - @if not index($exclude, right) and $right != null { - outline-right: $right; - } - @if not index($exclude, bottom) and $bottom != null { - outline-bottom: $bottom; - } - @if not index($exclude, left) and $left != null { - outline-left: $left; - } - } - // 单边轮廓 - @else { - $direction: str-slice($property, 8); // 提取方向 - @if not index($exclude, $direction) { - #{$property}: $top; - } - } - } - - // 5. 定位处理 - @else if $is-position { - // inset简写处理 - @if $property == 'inset' { - @if not index($exclude, top) and $top != null { - top: $top; - } - @if not index($exclude, right) and $right != null { - right: $right; - } - @if not index($exclude, bottom) and $bottom != null { - bottom: $bottom; - } - @if not index($exclude, left) and $left != null { - left: $left; - } - } - // inset-block 和 inset-inline - @else if $property == 'inset-block' { - @if not index($exclude, top) and $top != null { - top: $top; - } - @if not index($exclude, bottom) and $bottom != null { - bottom: $bottom; - } - } - @else if $property == 'inset-inline' { - @if not index($exclude, left) and $left != null { - left: $left; - } - @if not index($exclude, right) and $right != null { - right: $right; - } - } - // 单一定位 - @else { - @if not index($exclude, $property) { - #{$property}: $top; - } - } - } - - // 6. 尺寸处理 - @else if $is-size { - @if $property == 'block-size' { - @if not index($exclude, top) and $top != null { - height: $top; - } - } - @else if $property == 'inline-size' { - @if not index($exclude, left) and $left != null { - width: $left; - } - } - } -} - -// ======================================================================= -// 快捷混合宏:标准属性 -// ======================================================================= -@mixin padding($values, $exclude: ()) { - @include directional-property(padding, $values, $exclude); -} - -@mixin margin($values, $exclude: ()) { - @include directional-property(margin, $values, $exclude); -} - -@mixin border-radius($values, $exclude: ()) { - @include directional-property(border-radius, $values, $exclude); -} - -// ======================================================================= -// 快捷混合宏:边框属性 -// ======================================================================= -@mixin border($value, $exclude: ()) { - @include directional-property(border, $value, $exclude); -} - -@mixin border-top($value, $exclude: ()) { - @include directional-property(border-top, $value, $exclude); -} - -@mixin border-right($value, $exclude: ()) { - @include directional-property(border-right, $value, $exclude); -} - -@mixin border-bottom($value, $exclude: ()) { - @include directional-property(border-bottom, $value, $exclude); -} - -@mixin border-left($value, $exclude: ()) { - @include directional-property(border-left, $value, $exclude); -} - -// ======================================================================= -// 快捷混合宏:轮廓属性 -// ======================================================================= -@mixin outline($value, $exclude: ()) { - @include directional-property(outline, $value, $exclude); -} - -@mixin outline-top($value, $exclude: ()) { - @include directional-property(outline-top, $value, $exclude); -} - -@mixin outline-right($value, $exclude: ()) { - @include directional-property(outline-right, $value, $exclude); -} - -@mixin outline-bottom($value, $exclude: ()) { - @include directional-property(outline-bottom, $value, $exclude); -} - -@mixin outline-left($value, $exclude: ()) { - @include directional-property(outline-left, $value, $exclude); -} - -// ======================================================================= -// 快捷混合宏:定位属性 -// ======================================================================= -@mixin inset($values, $exclude: ()) { - @include directional-property(inset, $values, $exclude); -} - -@mixin inset-block($values, $exclude: ()) { - @include directional-property(inset-block, $values, $exclude); -} - -@mixin inset-inline($values, $exclude: ()) { - @include directional-property(inset-inline, $values, $exclude); -} - -@mixin top($value, $exclude: ()) { - @include directional-property(top, $value, $exclude); -} - -@mixin right($value, $exclude: ()) { - @include directional-property(right, $value, $exclude); -} - -@mixin bottom($value, $exclude: ()) { - @include directional-property(bottom, $value, $exclude); -} - -@mixin left($value, $exclude: ()) { - @include directional-property(left, $value, $exclude); -} - -// ======================================================================= -// 快捷混合宏:尺寸属性 -// ======================================================================= -@mixin block-size($value, $exclude: ()) { - @include directional-property(block-size, $value, $exclude); -} - -@mixin inline-size($value, $exclude: ()) { - @include directional-property(inline-size, $value, $exclude); -} - -// ======================================================================= -// 组合混合宏 -// ======================================================================= -// 带圆角的边框 -@mixin bordered($border-value, $radius-value) { - @include border($border-value); - @include border-radius($radius-value); -} - -// 绝对定位容器 -@mixin absolute-container($inset: 0) { - position: absolute; - @include inset($inset); -} - -// 固定定位容器 -@mixin fixed-container($inset: 0) { - position: fixed; - @include inset($inset); -} - -// ======================================================================= -// 圆角辅助混合宏 -// ======================================================================= -@mixin border-top-radius($value) { - @include border-radius($value 0 0, (bottom-right, bottom-left)); -} - -@mixin border-right-radius($value) { - @include border-radius(0 $value 0 0, (top-left, bottom-left)); -} - -@mixin border-bottom-radius($value) { - @include border-radius(0 0 $value, (top-right, top-left)); -} - -@mixin border-left-radius($value) { - @include border-radius(0 0 0 $value, (top-right, bottom-right)); -} \ No newline at end of file diff --git a/uni_modules/lime-style/mixins/ellipsis.scss b/uni_modules/lime-style/mixins/ellipsis.scss deleted file mode 100644 index 97e762a..0000000 --- a/uni_modules/lime-style/mixins/ellipsis.scss +++ /dev/null @@ -1,22 +0,0 @@ -@mixin ellipsis { - // overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - /* #ifndef UNI-APP-X && APP || APP-NVUE */ - word-wrap: normal; - /* #endif */ -} - - -@mixin ellipsisLn($line) { - // overflow: hidden; - text-overflow: ellipsis; - /* #ifdef UNI-APP-X && APP || APP-NVUE */ - lines: $line; - /* #endif */ - /* #ifndef UNI-APP-X && APP || APP-NVUE */ - -webkit-line-clamp: $line; - display: -webkit-box; - -webkit-box-orient: vertical; - /* #endif */ -} \ No newline at end of file diff --git a/uni_modules/lime-style/mixins/flex.scss b/uni_modules/lime-style/mixins/flex.scss deleted file mode 100644 index 0c3dd84..0000000 --- a/uni_modules/lime-style/mixins/flex.scss +++ /dev/null @@ -1,20 +0,0 @@ -@mixin flex { - /* #ifndef UNI-APP-X */ - display: flex; - /* #endif */ -} -@mixin flex-column { - /* #ifndef UNI-APP-X */ - flex-direction: column; - /* #endif */ -} -@mixin flex-row { - flex-direction: row; -} - -@mixin universal { - position: relative; - box-sizing: border-box; - display: flex; - flex-direction: column; -} diff --git a/uni_modules/lime-style/mixins/hairline.scss b/uni_modules/lime-style/mixins/hairline.scss deleted file mode 100644 index 5044518..0000000 --- a/uni_modules/lime-style/mixins/hairline.scss +++ /dev/null @@ -1,66 +0,0 @@ -// @import '../theme/default.scss'; - -@mixin hairline-base { - position: absolute; - box-sizing: border-box; - content: ' '; - pointer-events: none; - transform-origin: center; /* cover wechat button:after default transforn-origin */ -} - -@mixin hairline($color: $border-color-2) { - @include hairline-base; - top: -50%; - right: -50%; - bottom: -50%; - left: -50%; - border: 1px solid $color; - transform: scale(.5); -} - -@mixin hairline-top($color: $border-color-1, $left: 0, $right: 0) { - @include hairline-base; - top: 0; - right: $right; - left: $left; - border-top: 1px solid $color; - transform: scaleY(0.5); -} - -@mixin hairline-bottom($color: $border-color-1, $left: 0, $right: 0) { - @include hairline-base; - right: $right; - bottom: 0; - left: $left; - border-bottom: 1px solid $color; - transform: scaleY(0.5); -} - -@mixin hairline-left($color: $border-bolor-1) { - @include hairline-base; - top: 0; - bottom: 0; - left: 0; - border-left: 1px solid $color; - transform: scaleX(.5); -} - -@mixin hairline-right($color: $border-bolor-1) { - @include hairline-base; - top: 0; - bottom: 0; - right: 0; - border-right: 1px solid $color; - transform: scaleX(.5); -} - -// @mixin border { -// /* #ifndef UNI-APP-X && APP */ -// &:after { -// @content; -// } -// /* #endif */ -// /* #ifdef UNI-APP-X && APP */ -// @content; -// /* #endif */ -// } \ No newline at end of file diff --git a/uni_modules/lime-style/mixins/platform.scss b/uni_modules/lime-style/mixins/platform.scss deleted file mode 100644 index ebd3c8f..0000000 --- a/uni_modules/lime-style/mixins/platform.scss +++ /dev/null @@ -1,17 +0,0 @@ -/* #ifdef APP-NVUE || UNI-APP-X && APP */ -$is-app: true; -/* #endif */ -/* #ifndef APP-NVUE || UNI-APP-X && APP */ -$is-app: false; -/* #endif */ - -@mixin is-app { - @if $is-app { - @content; - } -} -@mixin not-app { - @if not($is-app) { - @content; - } -} diff --git a/uni_modules/lime-style/mixins/useTheme.scss b/uni_modules/lime-style/mixins/useTheme.scss deleted file mode 100644 index 83df7ca..0000000 --- a/uni_modules/lime-style/mixins/useTheme.scss +++ /dev/null @@ -1,60 +0,0 @@ -$limeThemes: light, dark; -$theme: light; - -@mixin use-theme($mode: null) { - @if $mode != null { - /* #ifndef UNI-APP-X && APP || APP-NVUE */ - @media (prefers-color-scheme: $mode) { - @content; - } - /* #endif */ - /* #ifdef UNI-APP-X && APP || APP-NVUE */ - &.#{$mode} { - @content; - } - /* #endif */ - } @else { - @each $mode in $limeThemes { - $theme: $mode !global; - /* #ifndef UNI-APP-X && APP || APP-NVUE */ - @media (prefers-color-scheme: $mode) { - @content; - } - /* #endif */ - - /* #ifdef UNI-APP-X && APP || APP-NVUE */ - &.#{$mode} { - @content; - } - /* #endif */ - } - } - -} - -@mixin theme-dark { - /* #ifndef UNI-APP-X && APP || APP-NVUE */ - @media (prefers-color-scheme: dark) { - page { - @content; - } - } - /* #endif */ - /* #ifdef UNI-APP-X && APP || APP-NVUE */ - .dark { - @content; - } - /* #endif */ - /* #ifdef WEB */ - :root[data-lime-theme='dark'] page { - @content; - } - /* #endif */ -} - - -@function get-var($themes, $key) { - @return map-get($themes, $key) -} - - diff --git a/uni_modules/lime-style/mixins/utilities.scss b/uni_modules/lime-style/mixins/utilities.scss deleted file mode 100644 index 3a4ea4a..0000000 --- a/uni_modules/lime-style/mixins/utilities.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import './flex'; - -@mixin resize-none { - /* #ifndef UNI-APP-X && APP */ - resize: none; - /* #endif */ -} diff --git a/uni_modules/lime-style/package.json b/uni_modules/lime-style/package.json deleted file mode 100644 index c378f80..0000000 --- a/uni_modules/lime-style/package.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "id": "lime-style", - "displayName": "lime-style", - "version": "0.2.5", - "description": "lime-style", - "keywords": [ - "lime-style" -], - "repository": "", - "engines": { - "HBuilderX": "^3.1.0", - "uni-app": "^4.44", - "uni-app-x": "^4.61" - }, - "dcloudext": { - "type": "sdk-js", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "", - "darkmode": "x", - "i18n": "x", - "widescreen": "x" - }, - "uni_modules": { - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "√", - "aliyun": "√", - "alipay": "√" - }, - "client": { - "uni-app": { - "vue": { - "vue2": "√", - "vue3": "√" - }, - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "vue": "√", - "nvue": "√", - "android": { - "extVersion": "", - "minVersion": "22" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√", - "alipay": "√", - "toutiao": "√", - "baidu": "√", - "kuaishou": "√", - "jd": "√", - "harmony": "-", - "qq": "-", - "lark": "-" - }, - "quickapp": { - "huawei": "-", - "union": "-" - } - }, - "uni-app-x": { - "web": { - "safari": "√", - "chrome": "√" - }, - "app": { - "android": { - "extVersion": "", - "minVersion": "22" - }, - "ios": "√", - "harmony": "√" - }, - "mp": { - "weixin": "√" - } - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/lime-style/readme.md b/uni_modules/lime-style/readme.md deleted file mode 100644 index 0f53a25..0000000 --- a/uni_modules/lime-style/readme.md +++ /dev/null @@ -1,16 +0,0 @@ -# lime-style - -## 更换色系 -在uni.scss中增加 -```css -// 品牌色-主色 -$primary-color: #3283ff; -// 错误色 -$error-color: #FF4D4F; -// 警告色 -$warning-color: #ffb400; -// 成功色 -$success-color: #34c471; - -$blue: #3283ff; -``` \ No newline at end of file diff --git a/uni_modules/lime-style/theme/dark.scss b/uni_modules/lime-style/theme/dark.scss deleted file mode 100644 index 49be837..0000000 --- a/uni_modules/lime-style/theme/dark.scss +++ /dev/null @@ -1,638 +0,0 @@ -@import '../mixins/create.scss'; -@import '../color/colorPalette.scss'; -@import '../color/colors.scss'; -@import '../mixins/useTheme'; - -$blue-1: #{genColor($blue, 1, dark)}; -$blue-2: #{genColor($blue, 2, dark)}; -$blue-3: #{genColor($blue, 3, dark)}; -$blue-4: #{genColor($blue, 4, dark)}; -$blue-5: #{genColor($blue, 5, dark)}; -$blue-6: #{genColor($blue, 6, dark)}; -$blue-7: #{genColor($blue, 7, dark)}; -$blue-8: #{genColor($blue, 8, dark)}; -$blue-9: #{genColor($blue, 9, dark)}; -$blue-10: #{genColor($blue, 10, dark)}; - -$info-color-1: #{genColor($info-color, 1, dark)}; -$info-color-2: #{genColor($info-color, 2, dark)}; -$info-color-3: #{genColor($info-color, 3, dark)}; -$info-color-4: #{genColor($info-color, 4, dark)}; -$info-color-5: #{genColor($info-color, 5, dark)}; -$info-color-6: #{genColor($info-color, 6, dark)}; -$info-color-7: #{genColor($info-color, 7, dark)}; -$info-color-8: #{genColor($info-color, 8, dark)}; -$info-color-9: #{genColor($info-color, 9, dark)}; -$info-color-10: #{genColor($info-color, 10, dark)}; - -$primary-color-1: #{genColor($primary-color, 1, dark)}; // 浅色/白底悬浮 -$primary-color-2: #{genColor($primary-color, 2, dark)}; // 文字禁用 -$primary-color-3: #{genColor($primary-color, 3, dark)}; // 一般禁用 -$primary-color-4: #{genColor($primary-color, 4, dark)}; // 特殊场景 禁用 -$primary-color-5: #{genColor($primary-color, 5, dark)}; // 悬浮 -$primary-color-6: #{genColor($primary-color, 6, dark)}; // 常规 -$primary-color-7: #{genColor($primary-color, 7, dark)}; // 点击 -$primary-color-8: #{genColor($primary-color, 8, dark)}; // -$primary-color-9: #{genColor($primary-color, 9, dark)}; -$primary-color-10: #{genColor($primary-color, 10, dark)}; - -$error-color-1: #{genColor($error-color, 1, dark)}; -$error-color-2: #{genColor($error-color, 2, dark)}; -$error-color-3: #{genColor($error-color, 3, dark)}; -$error-color-4: #{genColor($error-color, 4, dark)}; -$error-color-5: #{genColor($error-color, 5, dark)}; -$error-color-6: #{genColor($error-color, 6, dark)}; -$error-color-7: #{genColor($error-color, 7, dark)}; -$error-color-8: #{genColor($error-color, 8, dark)}; -$error-color-9: #{genColor($error-color, 9, dark)}; -$error-color-10: #{genColor($error-color, 10, dark)}; - -$warning-color-1: #{genColor($warning-color, 1, dark)}; -$warning-color-2: #{genColor($warning-color, 2, dark)}; -$warning-color-3: #{genColor($warning-color, 3, dark)}; -$warning-color-4: #{genColor($warning-color, 4, dark)}; -$warning-color-5: #{genColor($warning-color, 5, dark)}; -$warning-color-6: #{genColor($warning-color, 6, dark)}; -$warning-color-7: #{genColor($warning-color, 7, dark)}; -$warning-color-8: #{genColor($warning-color, 8, dark)}; -$warning-color-9: #{genColor($warning-color, 9, dark)}; -$warning-color-10: #{genColor($warning-color, 10, dark)}; - -$success-color-1: #{genColor($success-color, 1, dark)}; // 浅色/白底悬浮 -$success-color-2: #{genColor($success-color, 2, dark)}; // 文字禁用 -$success-color-3: #{genColor($success-color, 3, dark)}; // 一般禁用 -$success-color-4: #{genColor($success-color, 4, dark)}; // 特殊场景 -$success-color-5: #{genColor($success-color, 5, dark)}; // 悬浮 -$success-color-6: #{genColor($success-color, 6, dark)}; // 常规 -$success-color-7: #{genColor($success-color, 7, dark)}; // 点击 -$success-color-8: #{genColor($success-color, 8, dark)}; -$success-color-9: #{genColor($success-color, 9, dark)}; -$success-color-10: #{genColor($success-color, 10, dark)}; - -// $gray-1: #f3f3f3; -// $gray-2: #eeeeee; -// $gray-3: #e7e7e7; -// $gray-4: #dcdcdc; -// $gray-5: #c5c5c5; -// $gray-6: #a6a6a6; -// $gray-7: #8b8b8b; -// $gray-8: #777777; -// $gray-9: #5e5e5e; -// $gray-10: #4b4b4b; -// $gray-11: #383838; -// $gray-12: #2c2c2c; -// $gray-13: #242424; -// $gray-14: #181818; - -// 暗色模式的灰度 -$gray-1: #181818; // 最深 -$gray-2: #242424; -$gray-3: #2c2c2c; -$gray-4: #383838; -$gray-5: #4b4b4b; -$gray-6: #5e5e5e; -$gray-7: #777777; -$gray-8: #8b8b8b; -$gray-9: #a6a6a6; -$gray-10: #c5c5c5; -$gray-11: #dcdcdc; -$gray-12: #e7e7e7; -$gray-13: #eeeeee; -$gray-14: #f3f3f3; // 最浅 - -$text-color-1: rgba(255,255,255,0.85); //primary -$text-color-2: rgba(255,255,255,0.65); //secondary -$text-color-3: rgba(255,255,255,0.45); //placeholder -$text-color-4: rgba(255,255,255,0.25); //disabled - -// 容器 -$bg-color-page: $gray-1;//#000000; // 整体背景色 布局 -$bg-color-container: $gray-2;//#1d1d1d; // 一级容器背景 组件 -$bg-color-elevated: $gray-2;//#1f1f1f; // 二级容器背景 浮层 -$bg-color-spotlight: $gray-5; // 引起注意的如 Tooltip -$bg-color-mask: rgba(0, 0, 0, 0.65); // 蒙层 - -// 填充 -$fill-1: rgba(255,255,255,0.18); -$fill-2: rgba(255,255,255,0.12); -$fill-3: rgba(255,255,255,0.08); -$fill-4: rgba(255,255,255,0.04); - -// 描边 -$border-color-1: $gray-3;//#{getSolidColor(#000, 26%)}; //#424242; // 浅色 -$border-color-2: $gray-4;//#{getSolidColor(#000, 19%)}; //#303030; // 一般 -$border-color-3: $gray-5;//#{getSolidColor(#000, 15%)}; //$gray-4; // 深/悬浮 -$border-color-4: $gray-6;//#{getSolidColor(#000, 12%)}; //$gray-6; // 重/按钮描边 - - -@mixin theme-dark { - // 蓝色系 - --l-blue-1: #{$blue-1}; - --l-blue-2: #{$blue-2}; - --l-blue-3: #{$blue-3}; - --l-blue-4: #{$blue-4}; - --l-blue-5: #{$blue-5}; - --l-blue-6: #{$blue-6}; - --l-blue-7: #{$blue-7}; - --l-blue-8: #{$blue-8}; - --l-blue-9: #{$blue-9}; - --l-blue-10: #{$blue-10}; - - --l-info-color-1: #{$info-color-1}; - --l-info-color-2: #{$info-color-2}; - --l-info-color-3: #{$info-color-3}; - --l-info-color-4: #{$info-color-4}; - --l-info-color-5: #{$info-color-5}; - --l-info-color-6: #{$info-color-6}; - --l-info-color-7: #{$info-color-7}; - --l-info-color-8: #{$info-color-8}; - --l-info-color-9: #{$info-color-9}; - --l-info-color-10: #{$info-color-10}; - - // 主色系 - --l-primary-color-1: #{$primary-color-1}; - --l-primary-color-2: #{$primary-color-2}; - --l-primary-color-3: #{$primary-color-3}; - --l-primary-color-4: #{$primary-color-4}; - --l-primary-color-5: #{$primary-color-5}; - --l-primary-color-6: #{$primary-color-6}; - --l-primary-color-7: #{$primary-color-7}; - --l-primary-color-8: #{$primary-color-8}; - --l-primary-color-9: #{$primary-color-9}; - --l-primary-color-10: #{$primary-color-10}; - - // 错误色系 - --l-error-color-1: #{$error-color-1}; - --l-error-color-2: #{$error-color-2}; - --l-error-color-3: #{$error-color-3}; - --l-error-color-4: #{$error-color-4}; - --l-error-color-5: #{$error-color-5}; - --l-error-color-6: #{$error-color-6}; - --l-error-color-7: #{$error-color-7}; - --l-error-color-8: #{$error-color-8}; - --l-error-color-9: #{$error-color-9}; - --l-error-color-10: #{$error-color-10}; - - // 警告色系 - --l-warning-color-1: #{$warning-color-1}; - --l-warning-color-2: #{$warning-color-2}; - --l-warning-color-3: #{$warning-color-3}; - --l-warning-color-4: #{$warning-color-4}; - --l-warning-color-5: #{$warning-color-5}; - --l-warning-color-6: #{$warning-color-6}; - --l-warning-color-7: #{$warning-color-7}; - --l-warning-color-8: #{$warning-color-8}; - --l-warning-color-9: #{$warning-color-9}; - --l-warning-color-10: #{$warning-color-10}; - - // 成功色系 - --l-success-color-1: #{$success-color-1}; - --l-success-color-2: #{$success-color-2}; - --l-success-color-3: #{$success-color-3}; - --l-success-color-4: #{$success-color-4}; - --l-success-color-5: #{$success-color-5}; - --l-success-color-6: #{$success-color-6}; - --l-success-color-7: #{$success-color-7}; - --l-success-color-8: #{$success-color-8}; - --l-success-color-9: #{$success-color-9}; - --l-success-color-10: #{$success-color-10}; - - // 灰色系 - --l-gray-1: #{$gray-1}; - --l-gray-2: #{$gray-2}; - --l-gray-3: #{$gray-3}; - --l-gray-4: #{$gray-4}; - --l-gray-5: #{$gray-5}; - --l-gray-6: #{$gray-6}; - --l-gray-7: #{$gray-7}; - --l-gray-8: #{$gray-8}; - --l-gray-9: #{$gray-9}; - --l-gray-10: #{$gray-10}; - --l-gray-11: #{$gray-11}; - --l-gray-12: #{$gray-12}; - --l-gray-13: #{$gray-13}; - --l-gray-14: #{$gray-14}; - - // 文字颜色 - --l-text-color-1: #{$text-color-1}; - --l-text-color-2: #{$text-color-2}; - --l-text-color-3: #{$text-color-3}; - --l-text-color-4: #{$text-color-4}; - - // 容器背景色 - --l-bg-color-page: #{$bg-color-page}; - --l-bg-color-container: #{$bg-color-container}; - --l-bg-color-elevated: #{$bg-color-elevated}; - --l-bg-color-spotlight: #{$bg-color-spotlight}; - --l-bg-color-mask: #{$bg-color-mask}; - - // 填充色 - --l-fill-1: #{$fill-1}; - --l-fill-2: #{$fill-2}; - --l-fill-3: #{$fill-3}; - --l-fill-4: #{$fill-4}; - - // 描边色 - --l-border-color-1: #{$border-color-1}; - --l-border-color-2: #{$border-color-2}; - --l-border-color-3: #{$border-color-3}; - --l-border-color-4: #{$border-color-4}; - - // loading - --l-loading-text-color: #{$text-color-3}; - - // load-more - --l-load-more-text-color: #{$text-color-3}; - --l-load-more-color: #{$text-color-4}; - - // 按钮 - --l-button-default-solid-text-color: #000; - --l-button-default-border-color: #{$gray-5}; - --l-button-default-color: #{$gray-14}; - --l-button-default-light-color: #{$gray-4}; - --l-button-default-light-hover-color: #{$gray-5}; - --l-button-primary-light-color: #{$primary-color-2}; - --l-button-primary-light-hover-color: #{$primary-color-3}; - --l-button-danger-light-color: #{$error-color-2}; - --l-button-danger-light-hover-color: #{$error-color-3}; - --l-button-warning-light-color: #{$warning-color-2}; - --l-button-warning-light-hover-color: #{$warning-color-3}; - --l-button-success-light-color: #{$success-color-2}; - --l-button-success-light-hover-color: #{$success-color-3}; - --l-button-info-light-color: #{$info-color-1}; - --l-button-info-light-hover-color: #{$info-color-2}; - --l-button-primary-color: #{$primary-color-6}; - --l-button-danger-color: #{$error-color-6}; - --l-button-warning-color: #{$warning-color-6}; - --l-button-info-color: #{$info-color-6}; - - // 遮罩 - // --l-overlay-bg-color: #{$bg-color-mask}; - // 弹窗 - --l-popup-bg-color: #{$bg-color-elevated}; - --l-popup-close-icon-color: #{$text-color-2}; - - // 单元格 - --l-cell-group-title-color: #{$text-color-3}; - --l-cell-group-border-color: #{$border-color-3}; - --l-cell-bg-color: #{$bg-color-container}; - --l-cell-hover-color: #{$gray-3}; - --l-cell-border-color: #{$border-color-2}; - --l-cell-note-color: #{$text-color-3}; - --l-cell-description-color: #{$text-color-2}; - --l-cell-title-color: #{$text-color-1}; - --l-cell-right-icon-color: #{$text-color-3}; - - // 步进器 - --l-stepper-button-bg-color: #{$gray-4}; - --l-stepper-input-disabled-bg: #{$gray-3}; - --l-stepper-input-color: #{$text-color-1}; - --l-stepper-input-disabled-color: #{$text-color-4}; - --l-stepper-border-color: #{$gray-4}; - - // tabbar - --l-tabbar-bg-color: #{$bg-color-container}; - --l-tabbar-border-color: #{$border-color-1}; - --l-tabbar-color: #{$text-color-1}; - --l-tabbar-active-color: #{$primary-color-6}; - --l-tabbar-active-bg-color: #{$primary-color-1}; - - // link - --l-link-default-color: #{$text-color-1}; - - // image - --l-image-loading-bg-color: #{$fill-3}; - --l-image-color: #{$text-color-3}; - - // divider 分割线 - --l-divider-color: #{$border-color-2}; - --l-divider-text-color: #{$text-color-2}; - - // card 卡片 - --l-card-bg-color: #{$bg-color-container}; - --l-card-title-color: #{$text-color-1}; - --l-card-extra-color: #{$text-color-3}; - --l-card-note-color: #{$text-color-3}; - --l-card-border-color: #{$border-color-2}; - - // grid 宫格 - --l-grid-item-bg-color: #{$bg-color-container}; - --l-grid-item-image-bg-color: #{$fill-4}; - --l-grid-item-text-color: #{$text-color-1}; - --l-grid-item-hover-bg-color: #{$fill-3}; - --l-grid-item-description-color: #{$text-color-3}; - --l-grid-item-border-color: #{$border-color-2}; - --l-grid-item-icon-color: #{$text-color-1}; - - // cascader 级联 - --l-cascader-title-color: #{$text-color-1}; - --l-cascader-bg-color: #{$bg-color-container}; - --l-cascader-cell-title-color: #{$text-color-1}; - --l-cascader-disabled-color: #{$text-color-3}; - --l-cascader-options-title-color: #{$text-color-3}; - --l-cascader-close-icon-color: #{$text-color-2}; - - // tabs 标签页 - --l-tab-nav-bg-color: #{$bg-color-container}; - --l-tab-content-bg-color: #{$bg-color-container}; - --l-tab-split-color: #{$border-color-1}; - --l-tab-item-color: #{$text-color-2}; - --l-tab-item-disabled-color: #{$text-color-4}; - - // checkbox 复选框 - --l-checkbox-border-icon-color: #{$gray-8}; - --l-checkbox-icon-bg-color: #{$bg-color-container}; - --l-checkbox-text-color: #{$text-color-1}; - --l-checkbox-icon-disabled-bg-color: #{$gray-3}; - --l-checkbox-icon-disabled-color: #{$gray-6}; - - // radio 单选框 - --l-radio-border-icon-color: #{$gray-8}; - --l-radio-icon-bg-color: #{$bg-color-container}; - --l-radio-text-color: #{$text-color-1}; - --l-radio-icon-disabled-bg-color: #{$gray-3}; - --l-radio-icon-disabled-color: #{$gray-6}; - - // search 搜索 - --l-search-bg-color: #{$fill-3}; - --l-search-icon-color: #{$text-color-4}; - --l-search-clear-icon-color: #{$text-color-4}; - --l-search-text-color: #{$text-color-1}; - --l-search-label-color: #{$text-color-1}; - --l-search-placeholder-color: #{$text-color-3}; - - // switch - --l-switch-checked-disabled-color: #{$primary-color-3}; - --l-switch-unchecked-color: #{$gray-5}; - --l-switch-unchecked-disabled-color: #{$gray-4}; - - // input 输入框 - --l-input-text-color: #{$text-color-1}; - --l-input-tips-color: #{$text-color-3}; - --l-input-bg-color: #{$bg-color-container}; - --l-input-border-color: #{$border-color-2}; - --l-input-placeholder-text-color: #{$text-color-3}; - --l-input-prefix-icon-color: #{$text-color-1}; - --l-input-suffix-icon-color: #{$text-color-3}; - --l-input-label-text-color: #{$text-color-1}; - --l-input-suffix-text-color: #{$text-color-1}; - --l-input-disabled-text-color: #{$text-color-4}; - --l-input-disabled-bg-color: #{$fill-3}; - --l-input-border-color: #{$border-color-2}; - - // textarea - --l-textarea-bg-color: #{$bg-color-container}; - --l-textarea-placeholder-color: #{$text-color-3}; - --l-textarea-text-color: #{$text-color-1}; - --l-textarea-label-color: #{$text-color-1}; - --l-textarea-indicator-text-color: #{$text-color-3}; - --l-textarea-border-color: #{$border-color-2}; - --l-textarea-disabled-text-color: #{$text-color-4}; - - // upload - --l-upload-bg-color: #{$gray-4}; - --l-upload-add-bg-color: #{$gray-4}; - --l-upload-add-color: #{$text-color-3}; - - // picker - --l-picker-bg-color: #{$bg-color-container}; - --l-picker-cancel-color: #{$text-color-2}; - --l-picker-title-color: #{$text-color-1}; - --l-picker-item-active-color: #{$text-color-1}; - --l-picker-mask-top-color: #{$gray-2}; - --l-picker-loading-mask-color: rgba(0,0,0,.6); - --l-picker-item-color: #{$text-color-1}; - --l-picker-indicator-bg-color: #{$fill-3}; - - // empty - --l-empty-opacity: 0.6; - - // segmented - --l-segmented-bg-color: #{$gray-4}; - --l-segmented-text-color: #{$text-color-2}; - --l-segmented-active-bg-color: #{$gray-5}; - - // keyboard - --l-keyboard-bg-color: #{$bg-color-elevated}; - --l-keyboard-color: #{$text-color-1}; - --l-keyboard-key-bg-color: #{$gray-5}; - --l-keyboard-key-hover-bg-color: #{$gray-4}; - --l-keyboard-icon-bg-color: #{$gray-5}; - --l-keyboard-icon-color: #{$text-color-3}; - - // code-input - --l-code-input-bg-color: #{$gray-4}; - --l-code-input-active-bg-color: #{$gray-5}; - --l-code-input-info-color: #{$text-color-3}; - --l-code-input-dot-color: #{$text-color-1}; - --l-code-input-text-color: #{$text-color-1}; - --l-code-input-cursor-color: #{$text-color-1}; - --l-code-input-active-border-color: #{$gray-6}; - - // steps - --l-step-description-color: #{$text-color-3}; - --l-step-wait-circle-bg-color: #{$gray-4}; - --l-step-wait-circle-color: #{$text-color-3}; - --l-step-wait-title-color: #{$text-color-3}; - --l-step-wait-icon-color: #{$text-color-3}; - --l-step-wait-dot-border-color: #{$gray-5}; - --l-step-line-color: #{$gray-5}; - --l-step-finish-title-color: #{$text-color-1}; - --l-step-finish-circle-bg-color: #{$primary-color-2}; - --l-step-error-circle-bg-color: #{$error-color-2}; - - // date-strip - --l-date-strip-bg-color: #{$bg-color-container}; - --l-date-strip-color: #{$text-color-1}; - --l-date-strip-prefix-color: #{$text-color-3}; - --l-date-strip-color: #{$text-color-2}; - - // slider - --l-slider-rail-color: #{$gray-5}; - --l-slider-thumb-border-color: #{$gray-11}; - - // form - --l-form-item-border-color: #{$border-color-2}; - --l-form-bg-color: #{$bg-color-container}; - --l-form-item-label-color: #{$text-color-1}; - - // color-picker - --l-color-picker-color: #{$text-color-1}; - --l-color-picker-label-color: #{$text-color-2}; - --l-color-picker-field-bg-color: #{$fill-2}; - --l-color-picker-divider-color: #{$border-color-2}; - - // calendar - --l-calendar-bg-color: #{$bg-color-container}; - --l-calendar-title-color: #{$text-color-1}; - --l-calendar-days-color: #{$text-color-2}; - --l-calendar-item-color: #{$text-color-1}; - --l-calendar-item-disabled-color: #{$text-color-4}; - --l-calendar-item-centre-color: #{$primary-color-2}; - --l-calendar-month-mark-color: #{$fill-3}; - --l-calendar-switch-mode-icon-color: #{$text-color-2}; - --l-calendar-switch-mode-icon-disabled-color: #{$text-color-4}; - --l-calendar-header-border-color: #{$border-color-2}; - - // loading - --l-loading-text-color: #{$text-color-3}; - - // dialog - --l-dialog-title-color: #{$text-color-1}; - --l-dialog-content-color: #{$text-color-2}; - --l-dialog-close-color: #{$text-color-3}; - // --l-dialog-bg-color: #{$bg-color-container}; - --l-dialog-bg-color: #{$gray-3}; - --l-dialog-split-color: #{$border-color-2}; - - // action-sheet - --l-action-sheet-item-disabled-color: #{$text-color-4}; - --l-action-sheet-hover-color: #{$gray-3}; - --l-action-sheet-border-color: #{$border-color-1}; - --l-action-sheet-gap-color: #{$bg-color-page}; - --l-action-sheet-color: #{$text-color-1}; - --l-action-sheet-description-color: #{$text-color-3}; - --l-action-sheet-cancel-color: #{$text-color-1}; - --l-action-sheet-cancel-bg-color: #{$bg-color-container}; - --l-action-sheet-image-bg-color: #{$fill-3}; - --l-action-sheet-title-color: #{$text-color-1}; - --l-action-sheet-close-btn-color: #{$text-color-1}; - - // sorter - --l-sorter-color: #{$text-color-1}; - - // floating-panel - --l-floating-panel-bg-color: #{$bg-color-elevated}; - --l-floating-panel-bar-color: #{$fill-1}; - - // dropdown-menu - --l-dropdown-menu-color: #{$text-color-1}; - --l-dropdown-menu-bg-color: #{$bg-color-container}; - --l-dropdown-menu-border-color: #{$border-color-1}; - --l-dropdown-menu-disabled-color: #{$border-color-3}; - --l-dropdown-menu-arrow-color: #{$gray-6}; - --l-dropdown-menu-arrow-active-color: #{$gray-4}; - --l-dropdown-item-cell-title-color: #{$text-color-1}; - - // pull-refresh - --l-pull-refresh-refresher-color: #{$text-color-2}; - - // circle - --l-circle-trail-color: #{$gray-5}; - - // collapse - --l-collapse-panel-bg-color: #{$bg-color-container}; - --l-collapse-content-text-color: #{$text-color-1}; - --l-collapse-right-icon-color: #{$text-color-4}; - --l-collapse-border-color: #{$border-color-2}; - - // count-down - --l-count-down-text-color: #{$text-color-1}; - - // empty - --l-empty-description-color: #{$text-color-3}; - // progress - --l-progress-trail-color: #{$gray-5}; - --l-progress-text-color: #{$text-color-2}; - - // tag - // --l-tag-default-solid-text-color: #000; - --l-tag-text-color: #{$gray-14}; - --l-tag-default-color: #{$gray-6}; - --l-tag-default-light-color: #{$gray-4}; - --l-tag-default-border-color: #{$gray-5}; - --l-tag-primary-light-color: #{$primary-color-2}; - --l-tag-danger-light-color: #{$error-color-2}; - --l-tag-warning-light-color: #{$warning-color-2}; - --l-tag-success-light-color: #{$success-color-2}; - - // amount - --l-amount-color: #{$text-color-1}; - - // avatar - --l-avatar-bg-color: #{$primary-color-1}; - --l-avatar-border-color: #{$gray-2}; - - // highlight - --l-highlight-normal-color: #{$text-color-1}; - - // text-ellipsis - --l-text-ellipsis-color: #{$text-color-1}; - - // read-more - --l-read-more-handle-color: #{$text-color-2}; - --l-read-more-read-start: rgba(36, 36, 36, 0.9); - --l-read-more-read-end: rgba(36, 36, 36, 0.3); - --l-read-more-mask-bg-color: linear-gradient( - to top, - rgba(0,0,0,0), - rgba(0,0,0,1), - ); - // notice-bar - --l-notice-bar-info-bg-color: #{$info-color-1}; - --l-notice-bar-success-bg-color: #{$success-color-1}; - --l-notice-bar-warning-bg-color: #{$warning-color-1}; - --l-notice-bar-danger-bg-color: #{$error-color-1}; - - // scrollx - --l-scrollx-track-color: #{$gray-4}; - - // dateformat - --l-dateformat-color: #{$text-color-1}; - - // footer - --l-footer-text-color: #{$text-color-3}; - --l-footer-link-dividing-line-color: #{$text-color-3}; - --l-footer-logo-title-color: #{$text-color-1}; - - // tree - --l-tree-node-text-color: #{$text-color-1}; - --l-tree-arrow-color: #{$gray-6}; - - // table - --l-table-bg-color: #{$bg-color-container}; - --l-table-border-color: #{$border-color-2}; - --l-table-td-fixed-bg-color: #{$bg-color-container}; - --l-table-tr-fixed-bg-color: #{$bg-color-container}; - - // sidebar - --l-sidebar-bg-color: #{$gray-3}; - --l-sidebar-selected-bg-color: #{$bg-color-container}; - --l-sidebar-text-color: #{$text-color-2}; - --l-sidebar-disabled-text-color: #{$text-color-4}; - - // back-top - --l-back-top-bg-color: #{$bg-color-elevated}; - --l-back-top-border-color: #{$border-color-2}; - --l-back-top-text-color: #{$text-color-2}; - - // navbar - --l-navbar-bg-color: #{$bg-color-container}; - --l-navbar-color: #{$text-color-1}; - --l-navbar-capsule-border-color: #{$border-color-2}; - - // pagination - --l-pagination-bg-color: #{$gray-4}; - --l-pagination-disabled-bg-color: #{$gray-3}; - --l-pagination-hover-bg-color: #{$gray-5}; - --l-pagination-text-color: #{$text-color-2}; - --l-pagination-disabled-color: #{$text-color-4}; - --l-pagination-simple-text-color: #{$text-color-1}; - - // indexes - --l-indexes-sidebar-color: #{$text-color-1}; - --l-indexes-anchor-color: #{$text-color-1}; - --l-indexes-anchor-bg-color: #{$gray-4}; - --l-indexes-anchor-active-bg-color: #{$gray-4}; - --l-indexes-sidebar-tips-bg-color: #{$primary-color-1}; - - // typing - --l-typing-bg-color: #{$bg-color-container}; - --l-typing-text-color: #{$text-color-1}; - - // fit-swiper - --l-fit-swiper-indicator-color: #{$gray-5}; - - // skeleton - --l-skeleton-bg-color: #{$fill-2} -} diff --git a/uni_modules/lime-style/theme/default.scss b/uni_modules/lime-style/theme/default.scss deleted file mode 100644 index 90aaba7..0000000 --- a/uni_modules/lime-style/theme/default.scss +++ /dev/null @@ -1,181 +0,0 @@ -@import '../mixins/create.scss'; -@import '../color/colorPalette.scss'; -@import '../color/colors.scss'; - -$blue-1: genColor($blue, 1); -$blue-2: genColor($blue, 2); -$blue-3: genColor($blue, 3); -$blue-4: genColor($blue, 4); -$blue-5: genColor($blue, 5); -$blue-6: $blue; -$blue-7: genColor($blue, 7); -$blue-8: genColor($blue, 8); -$blue-9: genColor($blue, 9); -$blue-10: genColor($blue, 10); - -$info-color-1: genColor($info-color, 1); -$info-color-2: genColor($info-color, 2); -$info-color-3: genColor($info-color, 3); -$info-color-4: genColor($info-color, 4); -$info-color-5: genColor($info-color, 5); -$info-color-6: $info-color; -$info-color-7: genColor($info-color, 7); -$info-color-8: genColor($info-color, 8); -$info-color-9: genColor($info-color, 9); -$info-color-10: genColor($info-color, 10); - -$primary-color-1: create-var('primary-color-1', genColor($primary-color, 1)); // 浅色/白底悬浮 -$primary-color-2: create-var('primary-color-2', genColor($primary-color, 2)); // 文字禁用 -$primary-color-3: create-var('primary-color-3', genColor($primary-color, 3)); // 一般禁用 -$primary-color-4: create-var('primary-color-4', genColor($primary-color, 4)); // 特殊场景 禁用 -$primary-color-5: create-var('primary-color-5', genColor($primary-color, 5)); // 悬浮 -$primary-color-6: create-var('primary-color-6', $primary-color); // 常规 -$primary-color-7: create-var('primary-color-7', genColor($primary-color, 7)); // 点击 -$primary-color-8: create-var('primary-color-8', genColor($primary-color, 8)); // -$primary-color-9: create-var('primary-color-9', genColor($primary-color, 9)); -$primary-color-10: create-var('primary-color-10', genColor($primary-color, 10)); - -$error-color-1: create-var('error-color-1', genColor($error-color, 1)); -$error-color-2: create-var('error-color-2', genColor($error-color, 2)); -$error-color-3: create-var('error-color-3', genColor($error-color, 3)); -$error-color-4: create-var('error-color-4', genColor($error-color, 4)); -$error-color-5: create-var('error-color-5', genColor($error-color, 5)); -$error-color-6: create-var('error-color-6', $error-color); -$error-color-7: create-var('error-color-7', genColor($error-color, 7)); -$error-color-8: create-var('error-color-8', genColor($error-color, 8)); -$error-color-9: create-var('error-color-9', genColor($error-color, 9)); -$error-color-10: create-var('error-color-10', genColor($error-color, 10)); - -$warning-color-1: create-var('warning-color-1', genColor($warning-color, 1)); -$warning-color-2: create-var('warning-color-2', genColor($warning-color, 2)); -$warning-color-3: create-var('warning-color-3', genColor($warning-color, 3)); -$warning-color-4: create-var('warning-color-4', genColor($warning-color, 4)); -$warning-color-5: create-var('warning-color-5', genColor($warning-color, 5)); -$warning-color-6: create-var('warning-color-6', $warning-color); -$warning-color-7: create-var('warning-color-7', genColor($warning-color, 7)); -$warning-color-8: create-var('warning-color-8', genColor($warning-color, 8)); -$warning-color-9: create-var('warning-color-9', genColor($warning-color, 9)); -$warning-color-10: create-var('warning-color-10', genColor($warning-color, 10)); - -$success-color-1: create-var('success-color-1', genColor($success-color, 1)); // 浅色/白底悬浮 -$success-color-2: create-var('success-color-2', genColor($success-color, 2)); // 文字禁用 -$success-color-3: create-var('success-color-3', genColor($success-color, 3)); // 一般禁用 -$success-color-4: create-var('success-color-4', genColor($success-color, 4)); // 特殊场景 -$success-color-5: create-var('success-color-5', genColor($success-color, 5)); // 悬浮 -$success-color-6: create-var('success-color-6', $success-color); // 常规 -$success-color-7: create-var('success-color-7', genColor($success-color, 7)); // 点击 -$success-color-8: create-var('success-color-8', genColor($success-color, 8)); -$success-color-9: create-var('success-color-9', genColor($success-color, 9)); -$success-color-10: create-var('success-color-10', genColor($success-color, 10)); - -$white: create-var('white', #fff); -$gray-1: create-var('gray-1', #f3f3f3); -$gray-2: create-var('gray-2', #eeeeee); -$gray-3: create-var('gray-3', #e7e7e7); -$gray-4: create-var('gray-4', #dcdcdc); -$gray-5: create-var('gray-5', #c5c5c5); -$gray-6: create-var('gray-6', #a6a6a6); -$gray-7: create-var('gray-7', #8b8b8b); -$gray-8: create-var('gray-8', #777777); -$gray-9: create-var('gray-9', #5e5e5e); -$gray-10: create-var('gray-10', #4b4b4b); -$gray-11: create-var('gray-11', #383838); -$gray-12: create-var('gray-12', #2c2c2c); -$gray-13: create-var('gray-13', #242424); -$gray-14: create-var('gray-14', #181818); -$black: create-var('black', #000); - -// $text-color-1: create-var('text-color-1', rgba(0,0,0,0.88)); //primary -// $text-color-2: create-var('text-color-2', rgba(0,0,0,0.65)); //secondary -// $text-color-3: create-var('text-color-3', rgba(0,0,0,0.45)); //placeholder -// $text-color-4: create-var('text-color-4', rgba(0,0,0,0.25)); //disabled -$text-color-1: create-var('text-color-1', #000000E0); // primary (rgba(0,0,0,0.88)) -$text-color-2: create-var('text-color-2', #000000A6); // secondary (rgba(0,0,0,0.65)) -$text-color-3: create-var('text-color-3', #00000073); // placeholder (rgba(0,0,0,0.45)) -$text-color-4: create-var('text-color-4', #00000040); // disabled (rgba(0,0,0,0.25)) - -// 容器 -$bg-color-page: create-var('bg-color-page', $gray-1); // 整体背景色 布局 -$bg-color-container: create-var('bg-color-container', #fff); // 一级容器背景 组件 -$bg-color-elevated: create-var('bg-color-elevated', #fff); // 二级容器背景 浮层 -$bg-color-spotlight: create-var('bg-color-spotlight', rgba(0, 0, 0, 0.85)); // 引起注意的如 Tooltip -$bg-color-mask: create-var('bg-color-mask', rgba(0, 0, 0, 0.45)); // 蒙层 - -// 填充 -// $fill-1: create-var('fill-1', rgba(0, 0, 0, 0.15)); -// $fill-2: create-var('fill-2', rgba(0, 0, 0, 0.06)); -// $fill-3: create-var('fill-3', rgba(0, 0, 0, 0.04)); -// $fill-4: create-var('fill-4', rgba(0, 0, 0, 0.02)); -$fill-1: create-var('fill-1', #00000026); // rgba(0,0,0,0.15) -$fill-2: create-var('fill-2', #0000000F); // rgba(0,0,0,0.06) -$fill-3: create-var('fill-3', #0000000A); // rgba(0,0,0,0.04) -$fill-4: create-var('fill-4', #00000005); // rgba(0,0,0,0.02) - - -// 描边 -$border-color-1: create-var('border-color-1', $gray-2); // 浅色 -$border-color-2: create-var('border-color-2', $gray-3); // 一般 -$border-color-3: create-var('border-color-3', $gray-4); // 深/悬浮 -$border-color-4: create-var('border-color-4', $gray-6); // 重/按钮描边 - - -$alpha-disabled: create-var('alpha-disabled', 0.5); -$alpha-pressed: create-var('alpha-pressed', 0.07); - -// 投影 -/* #ifndef UNI-APP-X && APP */ -$shadow-1: create-var( - shadow-1, - 0 1px 10px rgba(0, 0, 0, 0.05), - 0 4px 5px rgba(0, 0, 0, 0.08), - 0 2px 4px -1px rgba(0, 0, 0, 0.12) -); - -$shadow-2: create-var( - 'shadow-2', - 0 1px 10px rgba(0, 0, 0, 0.05), - 0 4px 5px rgba(0, 0, 0, 0.08), - 0 2px 4px -1px rgba(0, 0, 0, 0.12) -); -$shadow-3: create-var( - shadow-3, - 0 6px 30px 5px rgba(0, 0, 0, 0.05), - 0 16px 24px 2px rgba(0, 0, 0, 0.04), - 0 8px 10px -5px rgba(0, 0, 0, 0.08) -); - -/* #endif */ -/* #ifdef UNI-APP-X && APP */ -$shadow-1: create-var( - shadow-1, - 0 1px 10px rgba(0, 0, 0, 0.05) -); -$shadow-2: create-var( - 'shadow-2', - 0 1px 10px rgba(0, 0, 0, 0.05) -); -$shadow-3: create-var( - shadow-3, - /* #ifdef APP-HARMONY - 0 6px 30px 5px $gray-3 - /* #endif */ - /* #ifndef APP-HARMONY - 0 6px 30px 5px rgba(0, 0, 0, 0.05) - /* #endif */ - -); -/* #endif */ -$shadow-4: create-var(shadow-4, 0 2px 8px 0 rgba(0, 0, 0, .06)); - -// 基础颜色的扩展 用于 聚焦 / 禁用 / 点击 等状态 -$primary-color-focus: create-var('primary-color-focus', $primary-color-1);// focus态,包括鼠标和键盘 -$primary-color-active: create-var('primary-color-active', $primary-color-8);// 点击态 -$primary-color-disabled: create-var('primary-color-disabled', $primary-color-3); -$primary-color-light: create-var('primary-color-light', $primary-color-1); // 浅色的选中态 -$primary-color-light-active: create-var('primary-color-light-active', $primary-color-2); // 浅色的选中态 - -$primary-color: create-var(primary-color, $primary-color); -$error-color: create-var(error-color, $error-color); -$warning-color: create-var(warning-color, $warning-color); -$success-color: create-var(success-color, $success-color); -$info-color: create-var(info-color, $info-color); \ No newline at end of file diff --git a/uni_modules/lime-style/token/dark.uts b/uni_modules/lime-style/token/dark.uts deleted file mode 100644 index bb373af..0000000 --- a/uni_modules/lime-style/token/dark.uts +++ /dev/null @@ -1,67 +0,0 @@ -import { TinyColor, generate, LGenerateOptions } from '@/uni_modules/lime-color'; -import { getAlphaColor, getSolidColor, generateColorPalettes } from './shared' -import { SeedToken } from './interface' -// #ifndef UNI-APP-X -export type UTSJSONObject = Record -const UTSJSONObject = Object -// #endif - -export function generateNeutralColorPalettes( - bgBaseColor : string | null, - textBaseColor : string | null) : UTSJSONObject { - const colorBgBase = bgBaseColor ?? '#000'; - const colorTextBase = textBaseColor ?? '#fff'; - - return { - 'bgColorBase': colorBgBase, - 'textColorBase': colorTextBase, - - 'textColor1': getAlphaColor(colorTextBase, 0.85), - 'textColor2': getAlphaColor(colorTextBase, 0.65), - 'textColor3': getAlphaColor(colorTextBase, 0.45), - 'textColor4': getAlphaColor(colorTextBase, 0.25), - - 'fill1': getAlphaColor(colorTextBase, 0.18), - 'fill2': getAlphaColor(colorTextBase, 0.12), - 'fill3': getAlphaColor(colorTextBase, 0.08), - 'fill4': getAlphaColor(colorTextBase, 0.04), - - 'bgColorElevated': getSolidColor(colorBgBase, 12), - 'bgColorContainer': getSolidColor(colorBgBase, 8), - 'bgColorPage': getSolidColor(colorBgBase, 0), - 'bgColorSpotlight': getSolidColor(colorBgBase, 26), - // 'bgColor5': getAlphaColor(colorTextBase, 0.04), - 'bgColorMask': getAlphaColor(colorBgBase, 0.45), - 'bgColorBlur': getAlphaColor(colorTextBase, 0.04), - - 'borderColor1': getSolidColor(colorBgBase, 26), - 'borderColor2': getSolidColor(colorBgBase, 19) - } -} - - -export function genColorMapToken(token : SeedToken) : UTSJSONObject { - const colorPrimaryBase = token.primaryColor - const colorSuccessBase = token.successColor - const colorWarningBase = token.warningColor - const colorErrorBase = token.errorColor - const colorInfoBase = token.infoColor - const colorBgBase = token.bgColorBase - const colorTextBase = token.textColorBase - - const primaryColors = generateColorPalettes(colorPrimaryBase, 'primaryColor', 'dark'); - const successColors = generateColorPalettes(colorSuccessBase, 'successColor', 'dark'); - const warningColors = generateColorPalettes(colorWarningBase, 'warningColor', 'dark'); - const errorColors = generateColorPalettes(colorErrorBase, 'errorColor', 'dark'); - const infoColors = generateColorPalettes(colorInfoBase, 'infoColor', 'dark'); - const neutralColors = generateNeutralColorPalettes(colorBgBase, colorTextBase); - - return UTSJSONObject.assign( - {}, - primaryColors, - successColors, - warningColors, - errorColors, - infoColors, - neutralColors) -} \ No newline at end of file diff --git a/uni_modules/lime-style/token/genFontMapToken.uts b/uni_modules/lime-style/token/genFontMapToken.uts deleted file mode 100644 index ccd7256..0000000 --- a/uni_modules/lime-style/token/genFontMapToken.uts +++ /dev/null @@ -1,49 +0,0 @@ -// import type { FontMapToken } from '../../interface'; -import { getFontSizes } from './genFontSizes'; - -export const genFontMapToken = (fontSize : number | null) : UTSJSONObject => { - if (fontSize == null) return {} - const fontSizePairs = getFontSizes(fontSize); - const fontSizes = fontSizePairs.map((pair) : number => pair.size); - const lineHeights = fontSizePairs.map((pair) : number => pair.lineHeight); - - const fontSizeXS = fontSizes[0]; - const fontSizeSM = fontSizes[1]; - const fontSizeMD = fontSizes[3]; - const fontSizeLG = fontSizes[4]; - - const lineHeight = lineHeights[2]; - const lineHeightSM = lineHeights[1]; - const lineHeightMD = lineHeights[3]; - const lineHeightLG = lineHeights[4]; - - return { - fontSize, - fontSizeXS, - fontSizeSM, - fontSizeMD, - fontSizeLG, - fontSizeXL: fontSizes[5], - - fontSizeHeading1: fontSizes[7], - fontSizeHeading2: fontSizes[6], - fontSizeHeading3: fontSizes[5], - fontSizeHeading4: fontSizes[4], - fontSizeHeading5: fontSizes[3], - - lineHeight, - lineHeightLG, - lineHeightMD, - lineHeightSM, - - fontHeight: Math.round(lineHeight * fontSizeMD), - fontHeightLG: Math.round(lineHeightLG * fontSizeLG), - fontHeightSM: Math.round(lineHeightSM * fontSizeSM), - - lineHeightHeading1: lineHeights[7], - lineHeightHeading2: lineHeights[6], - lineHeightHeading3: lineHeights[5], - lineHeightHeading4: lineHeights[4], - lineHeightHeading5: lineHeights[3], - }; -}; \ No newline at end of file diff --git a/uni_modules/lime-style/token/genFontSizes.uts b/uni_modules/lime-style/token/genFontSizes.uts deleted file mode 100644 index c294b54..0000000 --- a/uni_modules/lime-style/token/genFontSizes.uts +++ /dev/null @@ -1,30 +0,0 @@ -import { FontSize } from './interface'; - -export function getLineHeight(fontSize : number) : number { - return (fontSize + 8) / fontSize; -} - -// https://zhuanlan.zhihu.com/p/32746810 -export function getFontSizes(base : number) : FontSize[] { - const length = 11 // 10 - const offset = 2 // 1 - // #ifdef APP-ANDROID - const arr = Array.fromNative(new IntArray(length.toInt())); - // #endif - // #ifndef APP-ANDROID - const arr = Array.from({ length }); - // #endif - const fontSizes = arr.map((_, index) : number => { - const i = index - offset; - const baseSize = base * Math.pow(Math.E, i / 5); - const intSize = index > 1 ? Math.floor(baseSize) : Math.ceil(baseSize); - - // Convert to even - return Math.floor(intSize / 2) * 2; - }); - fontSizes[offset] = base; - return fontSizes.map((size) : FontSize => ({ - size, - lineHeight: getLineHeight(size), - } as FontSize)); -} \ No newline at end of file diff --git a/uni_modules/lime-style/token/genRadius.uts b/uni_modules/lime-style/token/genRadius.uts deleted file mode 100644 index f4378d1..0000000 --- a/uni_modules/lime-style/token/genRadius.uts +++ /dev/null @@ -1,63 +0,0 @@ -export function genRadius(radiusBase : number):Map { - let radiusXL = radiusBase; - let radiusLG = radiusBase; - let radiusMD = radiusBase; - let radiusSM = radiusBase; - let radiusXS = radiusBase; - let radiusOuter = radiusBase; - - - // radiusSM = radiusBase - 3 - // radiusXS = radiusSM - 1 - // radiusLG = radiusBase + 3 - // radiusXL = radiusLG + 3 - - - // radiusXL - if (radiusBase < 6 && radiusBase >= 5) { - radiusXL = radiusBase + 3; - } else if (radiusBase < 16 && radiusBase >= 6) { - radiusXL = radiusBase + 6; - } else if (radiusBase >= 16) { - radiusXL = 16; - } - - // radiusLG - if (radiusBase < 6 && radiusBase >= 5) { - radiusLG = radiusBase + 1; - } else if (radiusBase < 16 && radiusBase >= 6) { - radiusLG = radiusBase + 3; - } else if (radiusBase >= 16) { - radiusLG = 16; - } - - // radiusSM - if (radiusBase < 7 && radiusBase >= 5) { - radiusSM = 3; - } else if (radiusBase < 8 && radiusBase >= 7) { - radiusSM = 4; - } else if (radiusBase < 14 && radiusBase >= 8) { - radiusSM = 5; - } else if (radiusBase < 16 && radiusBase >= 14) { - radiusSM = 6; - } else if (radiusBase >= 16) { - radiusSM = 8; - } - - // radiusXS - if (radiusBase < 6 && radiusBase >= 2) { - radiusXS = 1; - } else if (radiusBase >= 6) { - radiusXS = 2; - } - - - return new Map([ - ['borderRadius', radiusBase], - ['borderRadiusXS', radiusXS], - ['borderRadiusSM', radiusSM], - ['borderRadiusMD', radiusMD], - ['borderRadiusLG', radiusLG], - ['borderRadiusXL', radiusXL], - ]) -} \ No newline at end of file diff --git a/uni_modules/lime-style/token/genSizeMapToken.uts b/uni_modules/lime-style/token/genSizeMapToken.uts deleted file mode 100644 index f7832ab..0000000 --- a/uni_modules/lime-style/token/genSizeMapToken.uts +++ /dev/null @@ -1,20 +0,0 @@ -// import {SizeMapToken} from './interface' - -/** - * sizeUnit 尺寸变化单位 - * sizeStep 尺寸步长 - */ -export function genSizeMapToken(sizeUnit : number | null = 4, sizeStep : number | null = 4) : UTSJSONObject { - if (sizeUnit == null || sizeStep == null) return {} - return { - spacerHG: sizeUnit * (sizeStep + 16), // 80 - spacerXL: sizeUnit * (sizeStep + 8), // 48 - spacerLG: sizeUnit * (sizeStep + 4), // 32 - spacerMD: sizeUnit * (sizeStep + 2), // 24 - spacerMS: sizeUnit * sizeStep, // 16 - spacer: sizeUnit * sizeStep, // 16 - spacerSM: sizeUnit * (sizeStep - 1), // 12 - spacerXS: sizeUnit * (sizeStep - 2), // 8 - spacerTN: sizeUnit * (sizeStep - 3), // 4 - }; -} \ No newline at end of file diff --git a/uni_modules/lime-style/token/interface.uts b/uni_modules/lime-style/token/interface.uts deleted file mode 100644 index 9f93daf..0000000 --- a/uni_modules/lime-style/token/interface.uts +++ /dev/null @@ -1,184 +0,0 @@ - -export type SeedToken = { - // ---------- Color ---------- // - /** - * @nameZH 是否生成深色色板 - * @nameEN GenerateDarkPalette - * @desc 是否生成一套完整的深色阶梯色板,以支持深色模式的应用 - * @descEN Whether to generate a complete set of dark color palettes to support dark mode applications - */ - useDark ?: boolean; - - /** - * @nameZH 品牌主色 - * @nameEN Brand Color - * @desc 品牌色是体现产品特性和传播理念最直观的视觉元素之一。在你完成品牌主色的选取之后,我们会自动帮你生成一套完整的色板,并赋予它们有效的设计语义 - * @descEN Brand color is one of the most direct visual elements to reflect the characteristics and communication of the product. After you have selected the brand color, we will automatically generate a complete color palette and assign it effective design semantics. - */ - primaryColor ?: string; - /** - * @nameZH 成功色 - * @nameEN Success Color - * @desc 用于表示操作成功的 Token 序列,如 Result、Progress 等组件会使用该组梯度变量。 - * @descEN Used to represent the token sequence of operation success, such as Result, Progress and other components will use these map tokens. - */ - successColor ?: string; - - /** - * @nameZH 警戒色 - * @nameEN Warning Color - * @desc 用于表示操作警告的 Token 序列,如 Notification、 Alert等警告类组件或 Input 输入类等组件会使用该组梯度变量。 - * @descEN Used to represent the warning map token, such as Notification, Alert, etc. Alert or Control component(like Input) will use these map tokens. - */ - warningColor ?: string; - /** - * @nameZH 错误色 - * @nameEN Error Color - * @desc 用于表示操作失败的 Token 序列,如失败按钮、错误状态提示(Result)组件等。 - * @descEN Used to represent the visual elements of the operation failure, such as the error Button, error Result component, etc. - */ - errorColor ?: string; - /** - * @nameZH 信息色 - * @nameEN Info Color - * @desc 用于表示操作信息的 Token 序列,如 Alert 、Tag、 Progress 等组件都有用到该组梯度变量。 - * @descEN Used to represent the operation information of the Token sequence, such as Alert, Tag, Progress, and other components use these map tokens. - */ - infoColor ?: string; - /** - * @nameZH 基础文本色 - * @nameEN Seed Text Color - * @desc 用于派生文本色梯度的基础变量,v5 中我们添加了一层文本色的派生算法可以产出梯度明确的文本色的梯度变量。但请不要在代码中直接使用该 Seed Token ! - * @descEN Used to derive the base variable of the text color gradient. In v5, we added a layer of text color derivation algorithm to produce gradient variables of text color gradient. But please do not use this Seed Token directly in the code! - */ - textColorBase ?: string; - - /** - * @nameZH 基础背景色 - * @nameEN Seed Background Color - * @desc 用于派生背景色梯度的基础变量,v5 中我们添加了一层背景色的派生算法可以产出梯度明确的背景色的梯度变量。但请不要在代码中直接使用该 Seed Token ! - * @descEN Used to derive the base variable of the background color gradient. In v5, we added a layer of background color derivation algorithm to produce map token of background color. But PLEASE DO NOT USE this Seed Token directly in the code! - */ - bgColorBase ?: string; - - /** - * @nameZH 超链接颜色 - * @nameEN Hyperlink color - * @desc 控制超链接的颜色。 - * @descEN Control the color of hyperlink. - */ - linkColor ?: string; - - // ---------- Font ---------- // - - /** - * @nameZH 字体 - * @nameEN Font family for default text - * @desc Lime Ui 的字体家族中优先使用系统默认的界面字体,同时提供了一套利于屏显的备用字体库,来维护在不同平台以及浏览器的显示下,字体始终保持良好的易读性和可读性,体现了友好、稳定和专业的特性。 - * @descEN The font family of Lime Ui prioritizes the default interface font of the system, and provides a set of alternative font libraries that are suitable for screen display to maintain the readability and readability of the font under different platforms and browsers, reflecting the friendly, stable and professional characteristics. - */ - fontFamily ?: string; - - /** - * @nameZH 代码字体 - * @nameEN Font family for code text - * @desc 代码字体,用于 Typography 内的 code、pre 和 kbd 类型的元素 - * @descEN Code font, used for code, pre and kbd elements in Typography - */ - fontFamilyCode ?: string; - - /** - * @nameZH 默认字号 - * @nameEN Default Font Size - * @desc 设计系统中使用最广泛的字体大小,文本梯度也将基于该字号进行派生。 - * @descEN The most widely used font size in the design system, from which the text gradient will be derived. - * @default 14 - */ - fontSize ?: number; - - - // ---------- BorderRadius ---------- // - - /** - * @nameZH 基础圆角 - * @nameEN Base Border Radius - * @descEN Border radius of base components - * @desc 基础组件的圆角大小,例如按钮、输入框、卡片等 - */ - borderRadius ?: number; - - // ---------- Size ---------- // - - /** - * @nameZH 尺寸变化单位 - * @nameEN Size Change Unit - * @desc 用于控制组件尺寸的变化单位,在 Lime Ui 中我们的基础单位为 4 ,便于更加细致地控制尺寸梯度 - * @descEN The unit of size change, in Lime Ui, our base unit is 4, which is more fine-grained control of the size step - * @default 4 - */ - sizeUnit ?: number; - - /** - * @nameZH 尺寸步长 - * @nameEN Size Base Step - * @desc 用于控制组件尺寸的基础步长,尺寸步长结合尺寸变化单位,就可以派生各种尺寸梯度。通过调整步长即可得到不同的布局模式,例如 V5 紧凑模式下的尺寸步长为 2 - * @descEN The base step of size change, the size step combined with the size change unit, can derive various size steps. By adjusting the step, you can get different layout modes, such as the size step of the compact mode of V5 is 2 - * @default 4 - */ - sizeStep ?: number; -} -export type FontSize = { - size : number - lineHeight : number -} -export type SizeMapToken = { - /** - * @nameZH Huge - * @default 80 - */ - sizeHG : number; - /** - * @nameZH XL - * @default 48 - */ - sizeXL : number; - /** - * @nameZH LG - * @default 32 - */ - sizeLG : number; - /** - * @nameZH MD - * @default 24 - */ - sizeMD : number; - /** Same as size by default, but could be larger in compact mode */ - sizeMS : number; - /** - * @nameZH 默认 - * @desc 默认尺寸 - * @default 16 - */ - size : number; - /** - * @nameZH SM - * @default 12 - */ - sizeSM : number; - /** - * @nameZH XS - * @default 8 - */ - sizeXS : number; - /** - * @nameZH Tiny - * @default 4 - */ - sizeTN : number; -} - - -// #ifndef UNI-APP-X -export type VueApp = any -export type UTSJSONObject = Record -// #endif diff --git a/uni_modules/lime-style/token/light.uts b/uni_modules/lime-style/token/light.uts deleted file mode 100644 index 8e3155a..0000000 --- a/uni_modules/lime-style/token/light.uts +++ /dev/null @@ -1,66 +0,0 @@ -import { TinyColor, generate } from '@/uni_modules/lime-color'; -import { getAlphaColor, getSolidColor, generateColorPalettes } from './shared' -import { SeedToken } from './interface' -// #ifndef UNI-APP-X -export type UTSJSONObject = Record -const UTSJSONObject = Object -// #endif - -export function generateNeutralColorPalettes( - bgBaseColor : string | null, - textBaseColor : string | null -) : UTSJSONObject { - const colorBgBase = bgBaseColor ?? '#fff'; - const colorTextBase = textBaseColor ?? '#000'; - - return { - 'bgColorBase': bgBaseColor, - 'textColorBase': textBaseColor, - - 'textColor1': getAlphaColor(colorTextBase, 0.88), - 'textColor2': getAlphaColor(colorTextBase, 0.65), - 'textColor3': getAlphaColor(colorTextBase, 0.45), - 'textColor4': getAlphaColor(colorTextBase, 0.25), - - 'fill1': getAlphaColor(colorTextBase, 0.15), - 'fill2': getAlphaColor(colorTextBase, 0.06), - 'fill3': getAlphaColor(colorTextBase, 0.04), - 'fill4': getAlphaColor(colorTextBase, 0.02), - - 'bgColorPage': getSolidColor(colorBgBase, 4), - 'bgColorContainer': getSolidColor(colorBgBase, 0), - 'bgColorElevated': getSolidColor(colorBgBase, 0), - 'bgColorMask': getAlphaColor(colorTextBase, 0.45), - 'bgColorSpotlight': getAlphaColor(colorTextBase, 0.85), - 'bgColorBlur': 'transparent', - - 'borderColor1': getSolidColor(colorBgBase, 15), - 'borderColor2': getSolidColor(colorBgBase, 6) - } -}; - -export function genColorMapToken(token : SeedToken) : UTSJSONObject { - const colorPrimaryBase = token.primaryColor - const colorSuccessBase = token.successColor - const colorWarningBase = token.warningColor - const colorErrorBase = token.errorColor - const colorInfoBase = token.infoColor - const colorBgBase = token.bgColorBase - const colorTextBase = token.textColorBase - - const primaryColors = generateColorPalettes(colorPrimaryBase, 'primaryColor'); - const successColors = generateColorPalettes(colorSuccessBase, 'successColor'); - const warningColors = generateColorPalettes(colorWarningBase, 'warningColor'); - const errorColors = generateColorPalettes(colorErrorBase, 'errorColor'); - const infoColors = generateColorPalettes(colorInfoBase, 'infoColor'); - const neutralColors = generateNeutralColorPalettes(colorBgBase, colorTextBase); - - return UTSJSONObject.assign( - {}, - primaryColors, - successColors, - warningColors, - errorColors, - infoColors, - neutralColors) -} \ No newline at end of file diff --git a/uni_modules/lime-style/token/shared.uts b/uni_modules/lime-style/token/shared.uts deleted file mode 100644 index 45ed035..0000000 --- a/uni_modules/lime-style/token/shared.uts +++ /dev/null @@ -1,24 +0,0 @@ -import { TinyColor, generate } from '@/uni_modules/lime-color'; -import { LGenerateOptions } from '@/uni_modules/lime-color/utssdk/interface'; - -export const getAlphaColor = (baseColor : string, alpha : number) : string => - new TinyColor(baseColor).setAlpha(alpha).toRgbString(); - -export const getSolidColor = (baseColor : string, brightness : number) : string => { - const instance = new TinyColor(baseColor); - return instance.lighten(brightness).toHexString(); -}; - -export function generateColorPalettes(baseColor : string | null, name : string, theme: string = 'default') : UTSJSONObject { - if (baseColor == null) return {} - const colors = generate(baseColor, { theme } as LGenerateOptions); - const colorPalettes = colors.reduce((prev:UTSJSONObject, color:string, index:number) : UTSJSONObject => { - prev[`${name}${index + 1}`] = color; - return prev - }, {}) - - // 默认为中间色 - colorPalettes[name] = colorPalettes[`${name}${6}`] - return colorPalettes -} - diff --git a/uni_modules/lime-style/token/useThemeMode.uts b/uni_modules/lime-style/token/useThemeMode.uts deleted file mode 100644 index ffd9de4..0000000 --- a/uni_modules/lime-style/token/useThemeMode.uts +++ /dev/null @@ -1,126 +0,0 @@ -// @ts-nocheck -// #ifndef UNI-APP-X -import { type ComputedRef, ref, watch, getCurrentScope, onScopeDispose, computed, reactive } from './vue'; -// #endif - -type ThemeMode = 'light' | 'dark' | 'auto' -const THEME_LOCAL_STORAGE_KEY = 'app-theme-preference' - -let limeThemeId = -1 -const limeThemeMode = ref('auto') -const limeTheme = ref(getTheme()) - - -function setWeb (theme: ThemeMode) { - // #ifdef WEB - const pageHead = document.querySelector(".uni-page-head"); - if(!pageHead) return - if (theme == 'dark') { - pageHead.style.backgroundColor = '#181818' - pageHead.style.color = '' - } else { - pageHead.style.backgroundColor = 'rgb(245, 245, 245)' - pageHead.style.color = 'rgb(0, 0, 0)' - } - // #endif -} - - -export function getTheme(): 'dark' | 'light' { - // #ifndef UNI-APP-X && APP - let mode = uni.getStorageSync(THEME_LOCAL_STORAGE_KEY) - limeThemeMode.value = (mode || 'auto') - const hostTheme = uni.getAppBaseInfo().hostTheme; - return limeThemeMode.value === 'auto' ? (hostTheme || 'light') : limeThemeMode.value - // #endif - - // #ifdef UNI-APP-X && APP - let { osTheme, appTheme } = uni.getSystemInfoSync(); - return appTheme == "auto" ? osTheme! : appTheme! - // #endif - - -} - -// #ifndef UNI-APP-X -let limeThemeCallBack = (result) => { - limeTheme.value = result.theme -}; -// #endif - -export function stop() { - // #ifndef UNI-APP-X - uni.offThemeChange(limeThemeCallBack) - // #endif - // #ifdef UNI-APP-X - // #ifndef UNI-APP-X && APP - uni.offHostThemeChange(limeThemeId) - - // #endif - // #ifdef UNI-APP-X && APP - uni.offAppThemeChange(limeThemeId) - // #endif - // #endif -} - - -// 检查系统主题 -export const checkSystemTheme = () => { - stop() - limeTheme.value = getTheme() - // #ifndef UNI-APP-X - uni.onThemeChange(limeThemeCallBack); - // #endif - // #ifdef UNI-APP-X - // #ifndef UNI-APP-X && APP - limeThemeId = uni.onHostThemeChange((result) => { - limeTheme.value = result.hostTheme - }); - // #endif - // #ifdef UNI-APP-X && APP - limeThemeId = uni.onAppThemeChange((res : AppThemeChangeResult) => { - limeTheme.value = res.appTheme.trim() - }) - // #endif - // #endif -} - - -export const isDarkMode = computed(() => { - return limeTheme.value == "dark"; -}); - -export function setThemeMode(theme: 'dark' | 'light' | 'auto') { - // #ifdef UNI-APP-X && APP - if (limeTheme.value == theme) return; - uni.setAppTheme({ - theme, - success: function (result: SetAppThemeSuccessResult) { - console.log("设置appTheme为"+ result.theme +"成功") - limeTheme.value = result.theme - }, - fail: function (e : IAppThemeFail) { - console.log("设置appTheme为 auto 失败,原因:", e.errMsg) - } - }) - // #endif - // #ifndef UNI-APP-X && APP - limeThemeMode.value = theme - uni.setStorageSync(THEME_LOCAL_STORAGE_KEY, theme) - limeTheme.value = getTheme() - // #endif - // #ifdef WEB - setWeb(limeTheme.value ) - // #endif -} - - -export function toggleTheme() { - setThemeMode(isDarkMode.value ? 'light' : 'dark') -} - -// #ifdef WEB -watch(isDarkMode, ()=>{ - setWeb(limeTheme.value) -}) -// #endif \ No newline at end of file diff --git a/uni_modules/lime-style/token/useThemeVars.uts b/uni_modules/lime-style/token/useThemeVars.uts deleted file mode 100644 index d5ceb23..0000000 --- a/uni_modules/lime-style/token/useThemeVars.uts +++ /dev/null @@ -1,123 +0,0 @@ -// @ts-nocheck -import { isDarkMode } from './useThemeMode' -import type { SeedToken } from './interface'; -import { genFontMapToken } from './genFontMapToken'; -import { genSizeMapToken } from './genSizeMapToken'; -import { genColorMapToken as genLightColorMapToken } from './light'; -import { genColorMapToken as genDarkColorMapToken } from './dark'; -import { computed, reactive } from 'vue'; // 或相应的响应式系统 - - - -// #ifndef UNI-APP-X -export type VueApp = any -export type UTSJSONObject = Record -const UTSJSONObject = Object -// #endif - - -// 内部存储的 tokens -type LimeTokens = { - light : UTSJSONObject - dark : UTSJSONObject -} - -// 默认的基础 token -const DEFAULT_SEED_TOKEN : SeedToken = { - primaryColor: '#3283ff' -}; - -export const themeTokenMaps = reactive({ - light: {}, - dark: {}, -}) - - -// 初始化默认 tokens -function initDefaultTokens() { - // Light 主题颜色 - const lightColors = { - white: '#fff', - gray1: '#f3f3f3', - gray2: '#eeeeee', - gray3: '#e7e7e7', - gray4: '#dcdcdc', - gray5: '#c5c5c5', - gray6: '#a6a6a6', - gray7: '#8b8b8b', - gray8: '#777777', - gray9: '#5e5e5e', - gray10: '#4b4b4b', - gray11: '#383838', - gray12: '#2c2c2c', - gray13: '#242424', - gray14: '#181818', - black: '#000', - ...genLightColorMapToken(DEFAULT_SEED_TOKEN) - }; - // Dark 主题颜色 - const darkColors = { - white: '#000', // 在暗黑模式下反转 - gray1: '#181818', - gray2: '#242424', - gray3: '#2c2c2c', - gray4: '#383838', - gray5: '#4b4b4b', - gray6: '#5e5e5e', - gray7: '#777777', - gray8: '#8b8b8b', - gray9: '#a6a6a6', - gray10: '#c5c5c5', - gray11: '#dcdcdc', - gray12: '#e7e7e7', - gray13: '#eeeeee', - gray14: '#f3f3f3', - black: '#fff', // 在暗黑模式下反转 - ...genDarkColorMapToken(DEFAULT_SEED_TOKEN) - }; - - themeTokenMaps.light = UTSJSONObject.assign({}, lightColors, lightColors) - themeTokenMaps.dark = UTSJSONObject.assign({}, darkColors, darkColors) -} - -initDefaultTokens(); - -// 导出的 themeTokens 是计算属性,自动返回当前主题的 tokens -export const themeTokens = computed(():UTSJSONObject => { - return isDarkMode.value ? themeTokenMaps.dark : themeTokenMaps.light; -}); - - - -export function useThemeToken(token : SeedToken | null = null) { - if (token != null) { - const lightColors = genLightColorMapToken(token!); - const darkColors = genDarkColorMapToken(token!); - - // 只有在提供了相关属性时才重新生成 fonts 和 sizes - const fonts = genFontMapToken(token!.fontSize) - const sizes = genSizeMapToken(token!.sizeUnit, token.sizeStep) - - themeTokenMaps.light = UTSJSONObject.assign({}, themeTokenMaps.light, lightColors, fonts, sizes) - themeTokenMaps.dark = UTSJSONObject.assign({}, themeTokenMaps.dark, darkColors, fonts, sizes) - } -} - -export function useThemeVars(options : UTSJSONObject | null = null) { - if (options != null) { - const currentTheme = isDarkMode.value ? themeTokenMaps.dark : themeTokenMaps.light; - - // #ifdef UNI-APP-X && APP - options.toMap().forEach((value, key) => { - currentTheme.set(key, value); - }); - // #endif - - // #ifndef UNI-APP-X && APP - Object.entries(options).forEach(([key, value]) => { - // currentTheme.set(key, value); - currentTheme[key] = value - }); - // #endif - } -} \ No newline at end of file diff --git a/uni_modules/lime-style/token/vue.ts b/uni_modules/lime-style/token/vue.ts deleted file mode 100644 index d8ded83..0000000 --- a/uni_modules/lime-style/token/vue.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -// #ifndef VUE3 -import Vue from 'vue' -import VueCompositionAPI from '@vue/composition-api' -Vue.use(VueCompositionAPI) -export * from '@vue/composition-api' -// #endif -// #ifdef VUE3 -export * from 'vue'; -// #endif -// #ifdef APP-IOS || APP-ANDROID -export type ComputedRef = ComputedRefImpl -// #endif \ No newline at end of file diff --git a/uni_modules/lime-style/var.scss b/uni_modules/lime-style/var.scss deleted file mode 100644 index 3b107f8..0000000 --- a/uni_modules/lime-style/var.scss +++ /dev/null @@ -1,64 +0,0 @@ -@import './mixins/create.scss'; -// 公共前缀 -$prefix: l !default; - -// Spacer -$spacer: create-var('spacer', 16px) !default; // base -$spacer-tn: create-var('spacer-tn', 4px) !default; // Tiny -$spacer-xs: create-var('spacer-xs', 8px) !default; // Extra Small -$spacer-sm: create-var('spacer-sm', 12px) !default; // Small -$spacer-md: create-var('spacer-md', 24px) !default; // Medium -$spacer-lg: create-var('spacer-lg', 32px) !default; // Large -$spacer-xl: create-var('spacer-xl', 48px) !default; // Extra Large -$spacer-hg: create-var('spacer-hg', 80px) !default; // Huge //Ultra Big - -// Font 官方建议字体不跟随页面变化 -$font-size: create-var('font-size', 14px) !default; -$font-size-xs: create-var('font-size-xs', 10px) !default; -$font-size-sm: create-var('font-size-sm', 12px) !default; -$font-size-md: create-var('font-size-md', 16px) !default; -$font-size-lg: create-var('font-size-lg',20px) !default; -$font-size-xl: create-var('font-size-xl', 36px) !default; - -$font-size-heading-1: create-var('font-size-heading-1', 38px) !default; -$font-size-heading-2: create-var('font-size-heading-2', 30px) !default; -$font-size-heading-3: create-var('font-size-heading-3', 24px) !default; -$font-size-heading-4: create-var('font-size-heading-4', 20px) !default; -$font-size-heading-5: create-var('font-size-heading-5', 16px) !default; - - -$font-family: create-var('font-family', PingFang SC, Microsoft YaHei, Arial Regular) !default; // 字体-磅数-常规 -$font-family-md: create-var('font-family-md', PingFang SC, Microsoft YaHei, Arial Medium) !default; // 字体-磅数-粗体 - - -// 行高 -$line-height: create-var('line-height', 1.5714285714285714) !default; -$line-height-sm: create-var('line-height-sm', 1.6666666666666667) !default; -$line-height-md: create-var('line-height-lg', 1.5) !default; -$line-height-lg: create-var('line-height-lg', 1.4) !default; - -$line-height-heading-1: create-var('line-height-heading-1', 1.2105263157894737) !default; -$line-height-heading-2: create-var('line-height-heading-2', 1.2666666666666666) !default; -$line-height-heading-3: create-var('line-height-heading-3', 1.3333333333333333) !default; -$line-height-heading-4: create-var('line-height-heading-4', 1.4) !default; -$line-height-heading-5: create-var('line-height-heading-5', 1.5) !default; - - -// 圆角 -$border-radius: create-var('border-radius', 6px) !default; -$border-radius-xs: create-var('border-radius-xs', 2px) !default; -$border-radius-sm: create-var('border-radius-sm', 3px) !default; -$border-radius-md: create-var('border-radius-md', 6px) !default; -$border-radius-lg: create-var('border-radius-lg', 9px) !default; -$border-radius-xl: create-var('border-radius-xl', 12px) !default; -$border-radius-hg: create-var('border-radius-hg', 999px) !default; -// $border-radius-circle: var(--l-border-radius-circle, 50%); - - -// 动画 -$anim-time-fn-easing: create-var('anim-time-fn-easing', cubic-bezier(0.38, 0, 0.24, 1)) !default; -$anim-time-fn-ease-out: create-var('anim-time-fn-ease-out', cubic-bezier(0, 0, 0.15, 1)) !default; -$anim-time-fn-ease-in: create-var('anim-time-fn-ease-in', cubic-bezier(0.82, 0, 1, 0.9)) !default; -$anim-duration-base: create-var('anim-duration-base', 0.2s) !default; -$anim-duration-moderate: create-var('anim-duration-moderate', 0.24s) !default; -$anim-duration-slow: create-var('anim-duration-slow', 0.28s) !default; \ No newline at end of file diff --git a/uni_modules/uni-wifi/changelog.md b/uni_modules/uni-wifi/changelog.md deleted file mode 100644 index 8bdfcde..0000000 --- a/uni_modules/uni-wifi/changelog.md +++ /dev/null @@ -1,14 +0,0 @@ -## 1.1.0(2026-04-03) -修复iOS端iOS14及以上系统getConnectedWifi函数部分字段错误的bug -## 1.0.10(2026-03-30) -iOS 平台适配iOS 26及以上系统,修复getConnectedWifi 报错的bug -## 1.0.9(2025-10-30) -iOS平台统一参数类型 -## 1.0.8(2025-09-29) -+ 修复Android平台 getConnectedWifi 方法partialInfo参数不生效的问题 -## 1.0.6(2023-11-13) -+ 统一错误码格式 -+ 修复部分真机未链接wifi可能卡死的bug -## 1.0.0(2022-12-05) -实现Android/iOS平台Wi-Fi功能模块 -注:iOS平台仅支持获取已连接的 Wi-Fi 信息 diff --git a/uni_modules/uni-wifi/package.json b/uni_modules/uni-wifi/package.json deleted file mode 100644 index e8581a6..0000000 --- a/uni_modules/uni-wifi/package.json +++ /dev/null @@ -1,147 +0,0 @@ -{ - "id": "uni-wifi", - "displayName": "uni-wifi", - "version": "1.1.0", - "description": "wifi管理", - "keywords": [ - "wifi" -], - "repository": "", - "engines": { - "HBuilderX": "^3.96", - "uni-app": "^4.75", - "uni-app-x": "^4.75" - }, - "dcloudext": { - "type": "uts", - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "插件不采集任何数据", - "permissions": "Android平台:\n\n\n\n\niOS平台:\niOS13及以上平台获取Wifi信息需要定位权限" - }, - "npmurl": "", - "darkmode": "x", - "i18n": "x", - "widescreen": "x" - }, - "uni_modules": { - "uni-ext-api": { - "uni": { - "startWifi": { - "web": false - }, - "stopWifi": { - "web": false - }, - "connectWifi": { - "web": false - }, - "getConnectedWifi": { - "web": false - }, - "getWifiList": { - "web": false - }, - "onGetWifiList": { - "web": false - }, - "offGetWifiList": { - "web": false - }, - "onWifiConnected": { - "web": false - }, - "offWifiConnected": { - "web": false - }, - "onWifiConnectedWithPartialInfo": { - "web": false - }, - "offWifiConnectedWithPartialInfo": { - "web": false - } - } - }, - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "√", - "aliyun": "√", - "alipay": "x" - }, - "client": { - "uni-app": { - "vue": { - "vue2": { - "extVersion": "1.0.7", - "minVersion": "" - }, - "vue3": { - "extVersion": "1.0.7", - "minVersion": "" - } - }, - "web": { - "safari": "x", - "chrome": "x" - }, - "app": { - "vue": "√", - "nvue": "√", - "android": { - "extVersion": "1.0.7", - "minVersion": "19" - }, - "ios": { - "extVersion": "1.0.7", - "minVersion": "12" - }, - "harmony": "x" - }, - "mp": { - "weixin": "x", - "alipay": "x", - "toutiao": "x", - "baidu": "x", - "kuaishou": "x", - "jd": "x", - "harmony": "x", - "qq": "x", - "lark": "x", - "xhs": "-" - }, - "quickapp": { - "huawei": "x", - "union": "x" - } - }, - "uni-app-x": { - "web": { - "safari": "-", - "chrome": "-" - }, - "app": { - "android": "-", - "ios": "-", - "harmony": "-" - }, - "mp": { - "weixin": "-" - } - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/uni-wifi/readme.md b/uni_modules/uni-wifi/readme.md deleted file mode 100644 index 047a8f2..0000000 --- a/uni_modules/uni-wifi/readme.md +++ /dev/null @@ -1,145 +0,0 @@ -## 使用说明 - -Wi-Fi功能模块 - - -### App-iOS平台注意事项 -- iOS平台App获取Wi-Fi信息需要开启“Access WiFi information”能力 - 登录苹果开发者网站,在“Certificates, Identifiers & Profiles”页面选择“Identifiers”中选择对应的App ID,确保开启“Access WiFi information”,保存后重新生成profile文件 -- iOS13及以上系统,获取当前连接的Wi-Fi信息需要先获取系统定位权限,因此在iOS13及以上系统使用此接口时,会触发定位权限申请的弹窗 - -### App-Android平台注意事项 -- 如果是自定义基座,需要具备下面的权限 - -``` - - - - -``` - - -###uni.startWifi(OBJECT) - -初始化Wi-Fi模块。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#startwifi](https://uniapp.dcloud.net.cn/api/system/wifi.html#startwifi) - - -### uni.stopWifi(OBJECT) - -关闭 Wi-Fi 模块。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#stopwifi](https://uniapp.dcloud.net.cn/api/system/wifi.html#stopwifi) - - -### uni.getConnectedWifi(OBJECT) - -获取已连接的 Wi-Fi 信息 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#getconnectedwifi](https://uniapp.dcloud.net.cn/api/system/wifi.html#getconnectedwifi) - - -### uni.getWifiList(OBJECT) - -请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#getWifiList](https://uniapp.dcloud.net.cn/api/system/wifi.html#getWifiList) - -**平台差异说明** - -|App-Android|App-iOS| -|:-:|:-:| -|√|x| - - -### uni.onGetWifiList(CALLBACK) - -监听获取到 Wi-Fi 列表数据事件。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#onGetWifiList](https://uniapp.dcloud.net.cn/api/system/wifi.html#onGetWifiList) - -**平台差异说明** - -|App-Android|App-iOS| -|:-:|:-:| -|√|x| - - -### uni.offGetWifiList(CALLBACK) - -移除获取到 Wi-Fi 列表数据事件的监听函数。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#offGetWifiList](https://uniapp.dcloud.net.cn/api/system/wifi.html#offGetWifiList) - -**平台差异说明** - -|App-Android|App-iOS| -|:-:|:-:| -|√|x| - - -### uni.connectWifi(OBJECT) - -连接 Wi-Fi。若已知 Wi-Fi 信息,可以直接利用该接口连接。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi](https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi) - -**平台差异说明** - -|App-Android|App-iOS| -|:-:|:-:| -|√|x| - - -### uni.onWifiConnected(CALLBACK) - -监听连接上 Wi-Fi 的事件。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnected](https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnected) - -**平台差异说明** - -|App-Android|App-iOS| -|:-:|:-:| -|√|x| - - -### uni.offWifiConnected(CALLBACK) - -移除连接上 Wi-Fi 的事件的监听函数。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnected](https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnected) - -**平台差异说明** - -|App-Android|App-iOS| -|:-:|:-:| -|√|x| - - -### uni.onWifiConnectedWithPartialInfo(CALLBACK) - -监听连接上 Wi-Fi 的事件。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnectedWithPartialInfo](https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnectedWithPartialInfo) - -**平台差异说明** - -|App-Android|App-iOS| -|:-:|:-:| -|√|x| - - -### uni.offWifiConnectedWithPartialInfo(CALLBACK) - -移除连接上 Wi-Fi 的事件的监听函数。 - -> 使用文档:[https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnectedWithPartialInfo](https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnectedWithPartialInfo) - -**平台差异说明** - -|App-Android|App-iOS| -|:-:|:-:| -|√|x| - diff --git a/uni_modules/uni-wifi/utssdk/app-android/config.json b/uni_modules/uni-wifi/utssdk/app-android/config.json deleted file mode 100644 index 7ed4299..0000000 --- a/uni_modules/uni-wifi/utssdk/app-android/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "minSdkVersion": "19" -} \ No newline at end of file diff --git a/uni_modules/uni-wifi/utssdk/app-android/index.uts b/uni_modules/uni-wifi/utssdk/app-android/index.uts deleted file mode 100644 index e0ff318..0000000 --- a/uni_modules/uni-wifi/utssdk/app-android/index.uts +++ /dev/null @@ -1,803 +0,0 @@ -import Context from "android.content.Context"; -import WifiManager from "android.net.wifi.WifiManager"; -import WifiInfo from "android.net.wifi.WifiInfo"; -import Manifest from "android.Manifest"; -import PackageManager from "android.content.pm.PackageManager"; -import ScanResult from "android.net.wifi.ScanResult"; -import BroadcastReceiver from "android.content.BroadcastReceiver"; -import ActivityCompat from "androidx.core.app.ActivityCompat"; -import IntentFilter from "android.content.IntentFilter"; -import Intent from "android.content.Intent"; - -import WifiConfiguration from 'android.net.wifi.WifiConfiguration'; -import AuthAlgorithm from 'android.net.wifi.WifiConfiguration.AuthAlgorithm'; -import KeyMgmt from 'android.net.wifi.WifiConfiguration.KeyMgmt'; -import TextUtils from 'android.text.TextUtils'; -import Build from 'android.os.Build'; - -import { UniWifiResult, UniWifiInfoWithPartialInfo,GetConnectedWifiOptions, WifiConnectOption, GetWifiListOptions, -StartWifiOptions, StopWifiOptions,UniWifiInfo,UniWifiCallback ,UniWifiResultCallback,UniWifiResultCallbackWithPartialInfo,UniGetWifiListCallback} from "../interface.uts" -import { WifiFailImpl, getErrcode,UniErrorSubject } from '../unierror'; - - -/** - * 全局数据储存 - */ -class Global { - static mReceiver : CustomBroadcastReceiver | null = null; - static WIFI_AUTH_OPEN : string = ""; - static WIFI_AUTH_ROAM : String = "[ESS]"; - // 扫描wifi结果 - static scanList : AndroidUniWifiInfo[] = [] - // 获取wifi列表监听 - static onGetWifiListCallback : UniGetWifiListCallback|null = null - static supendGetWifiSuccess : UniWifiResultCallback|null = null - static supendGetWifiComplete :UniWifiResultCallback|null = null - // wifi链接监听 - static onWifiConnectCallbackList : UniWifiResultCallback[] = [] - static onWifiConnectWithPartialInfoCallbackList : UniWifiResultCallbackWithPartialInfo[] = [] -} - - -/** - * 是否是标准的16进制字符 - */ -function isHex(key : string) : boolean { - for (var i = key.length - 1; i >= 0; i--) { - let c = key.charAt(i); - if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' - && c <= 'f')) { - return false; - } - } - - return true; -} - -/** - * 判断是否是wep格式的key - */ -function isHexWepKey(wepKey : string) : boolean { - let len = wepKey.length; - - // WEP-40, WEP-104, and some vendors using 256-bit WEP (WEP-232?) - if (len != 10 && len != 26 && len != 58) { - return false; - } - - return isHex(wepKey); -} -/** - * android 平台特有的Wifi信息对象,主要是加了加密信息这个字段 - */ -export type AndroidUniWifiInfo = { - SSID : string; - BSSID ?: string; - secure : boolean; - signalStrength : number; - frequency : number; - securityType : string; -} - -function wrapUniWifiInfoFromAndroid(androidInfo : AndroidUniWifiInfo) : UniWifiInfo { - let ret : UniWifiInfo = { - SSID: androidInfo.SSID, - BSSID: androidInfo.BSSID, - secure: androidInfo.secure, - signalStrength: androidInfo.signalStrength, - frequency: androidInfo.frequency, - } - return ret -} -/** - * 从扫描结果中提取统一的wifi数据结构 - */ -function wrapUniWifiInfoFromScan(scanResult : ScanResult) : AndroidUniWifiInfo { - - let ret : AndroidUniWifiInfo = { - SSID: "", - secure: false, - signalStrength: 0, - frequency: 0, - securityType: "NONE" - } - if (scanResult != null) { - // 如果是通过扫描列表得到的数据,进行封装 - ret.BSSID = scanResult.BSSID; - ret.SSID = scanResult.SSID; - - ret.signalStrength = scanResult.level; - ret.frequency = scanResult.frequency; - - // 是否安全,微信的标准是是否需要密码。 来源:https://developers.weixin.qq.com/community/develop/doc/00064cf1790458db19cddf9925ac00?highLine=WifiInfo - ret.secure = false; - let capabilities = scanResult.capabilities.trim(); - if ((capabilities.equals(Global.WIFI_AUTH_OPEN) || capabilities.equals(Global.WIFI_AUTH_ROAM))) { - ret.secure = false; - } else { - ret.secure = true; - } - - /*扩展字段*/ - ret.securityType = getSecurityType(scanResult); - } - - return ret -} -/** - * 从链接信息中提取统一的wifi数据结构 - */ -function wrapUniWifiInfoFromConnectInfo(connectInfo : WifiInfo) : UniWifiInfo { - let ret : UniWifiInfo = { - SSID: "", - secure: false, - signalStrength: 0, - frequency: 0, - } - - - if (connectInfo.getSSID() != null) { - let s = connectInfo.getSSID(); - // 微信不带,这里需要去掉引号 - if (s.length > 2 && s.charAt(0) == '"' && s.charAt(s.length - 1) == '"') { - s = s.substring(1, s.length - 1); - } - ret.SSID = s; - } - - ret.BSSID = connectInfo.getBSSID(); - //Android返回的值是-100~0,而微信API规范是0~100,值越大信号越好,需要+100拉齐 - ret.signalStrength = connectInfo.getRssi() + 100; - ret.frequency = connectInfo.getFrequency(); - - - return ret -} - - -/** - * 连接wifi时使用,根据用户输入内容包装为系统需要的wifi配置对象 - **/ -@Suppress("DEPRECATION") -function wrapWifiConfiguration(SSID : string, password ?: string, passwordType : string) : WifiConfiguration { - - let config = new WifiConfiguration(); - config.status = WifiConfiguration.Status.ENABLED; - config.allowedAuthAlgorithms.clear(); - config.allowedGroupCiphers.clear(); - config.allowedKeyManagement.clear(); - config.allowedPairwiseCiphers.clear(); - config.allowedProtocols.clear(); - config.SSID = "\"".concat(SSID).concat("\""); - - - // nopass - if ("NONE".equals(passwordType) || password == null) { - config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); - } - // wep - else if ("WEP".equals(passwordType)) { - if (password != null && !TextUtils.isEmpty(password)) { - if (isHexWepKey(password)) { - config.wepKeys[0] = password; - } else { - config.wepKeys[0] = "\"".concat(password).concat("\""); - } - } - config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN); - config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED); - config.allowedKeyManagement.set(KeyMgmt.NONE); - config.wepTxKeyIndex = 0; - } - // wpa - else if ("WPA".equals(passwordType)) { - config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); - config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); - config.preSharedKey = "\"".concat(password).concat("\""); - } - - return config; -} - - -/** - * 判断当前wifi的加密类型 - */ -function getSecurityType(result : ScanResult) : string { - if (result.capabilities.contains("WEP")) { - return "WEP"; - } else if (result.capabilities.contains("PSK")) { - return "WPA"; - } else if (result.capabilities.contains("EAP")) { - return "EAP"; - } - return "NONE"; -} - - -function zeroCountNum(source ?: string) : number { - if (source == null) { - return 0 - } - var splitted = source.split(":") - var countNum = 0; - for (perItem in splitted) { - if (perItem == "00") { - countNum += 1 - } - } - return countNum -} - - -/** - * 自定义wifi变化广播监听器 - */ -@Suppress("UNUSED_PARAMETER", "DEPRECATION") -class CustomBroadcastReceiver extends BroadcastReceiver { - - mWifiManager : WifiManager | null = null; - - constructor(wifiManager : WifiManager) { - super(); - this.mWifiManager = wifiManager; - } - - override onReceive(_context : Context, intent : Intent) : void { - - - if (intent.action == WifiManager.WIFI_STATE_CHANGED_ACTION) { - - let state = - intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN) - - if (state == WifiManager.WIFI_STATE_ENABLED) { - // 获取当前的connectInfo 并且进行数据封装 - let uniWifiInfo = new UniWifiInfo("","",false,0,0) - //做一些异步操作 - setTimeout(function () { - // BroadcastReceiver 中不能执行耗时任务,需要使用setTimeout - // @ts-ignore - let winfo = this.mWifiManager!.getConnectionInfo(); - - if(winfo != null && winfo.bssid != null && zeroCountNum(winfo.bssid) < 3){ - // 当前设备链接到了某个具体的wifi.封装成数据对象 - uniWifiInfo = wrapUniWifiInfoFromConnectInfo(winfo) - let res = new UniWifiResult(0,UniErrorSubject,'onWifiConnected:ok',uniWifiInfo) - - // wifi状态可用了,分发当前的链接状态给已注册的监听集合 - for (let perCallback in Global.onWifiConnectCallbackList) { - perCallback(res); - } - // 封装仅SSID 数据对象 - let connectedWithPartialInfo = new UniWifiInfoWithPartialInfo(uniWifiInfo.SSID) - - for (let perCallback in Global.onWifiConnectWithPartialInfoCallbackList) { - perCallback(connectedWithPartialInfo); - } - } else { - // 开启了wifi 开关,但是尚未链接到某个具体的wifi - } - - }, 100); - } - - } - - - if (intent.action == WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) { - startWifiScaning = false; - // wifi 扫描结果回调 - let results = this.mWifiManager!.scanResults; - - if (results != null) { - Global.scanList = [] - for (let scanResult in results) { - if (scanResult.SSID == null) { - continue; - } - Global.scanList.push(wrapUniWifiInfoFromScan(scanResult)); - } - - // 挨个通知,所有的监听器 - if(Global.onGetWifiListCallback != null){ - const data = new UTSJSONObject(); - data["wifiList"] = Global.scanList - Global.onGetWifiListCallback?.(data); - /** - * 确保onGetWifiList 只会被执行一次 - */ - Global.onGetWifiListCallback = null - } - - } - - let ret = new UniWifiResult(0,UniErrorSubject,"getWifiList:ok",null) - if(Global.supendGetWifiSuccess != null){ - Global.supendGetWifiSuccess?.(ret) - Global.supendGetWifiSuccess = null - } - if(Global.supendGetWifiComplete != null){ - Global.supendGetWifiComplete?.(ret) - Global.supendGetWifiComplete = null - } - } - } - -} - - - -/************************* 下面是对外提供的函数 *************************/ -/** - * start wifi是否正在扫描 - */ -var startWifiScaning = false - -/** - * 开启wifi - */ -@Suppress("DEPRECATION") -export function startWifiImpl(option : StartWifiOptions) { - - - // 具备了权限,继续前进 - let wifiManager : WifiManager = - UTSAndroid.getAppContext()!.getSystemService(Context.WIFI_SERVICE) as WifiManager - // 用户没有开启wifi 总开关 - if (!wifiManager.isWifiEnabled()) { - // wifi 没开启 - let failResult = new WifiFailImpl(getErrcode(12005)); - option.fail?.(failResult); - option.complete?.(failResult); - return; - } - // 初始化wifi 状态广播监听,后续所有的api,均基于此 - if(Global.mReceiver != null){ - // 说明已经注册过了 - let result = UniWifiResult(0,UniErrorSubject,"startWifi:ok",null) - - option.success?.(result) - option.complete?.(result) - return - } - - - Global.mReceiver = new CustomBroadcastReceiver(wifiManager) - - let filter = new IntentFilter() - filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) - // @ts-ignore - filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION) - // @ts-ignore - filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); - - UTSAndroid.getUniActivity()!.registerReceiver(Global.mReceiver, filter) - - /** - * activity 被销毁时,取消注册 - */ - UTSAndroid.onAppActivityDestroy(function () { - - if (Global.mReceiver != null) { - UTSAndroid.getUniActivity()!.unregisterReceiver(Global.mReceiver) - Global.mReceiver = null - - Global.scanList = [] - Global.onGetWifiListCallback = null - Global.onWifiConnectCallbackList = [] - Global.onWifiConnectWithPartialInfoCallbackList = [] - } - - }); - startWifiScaning = true - // 开始扫描 - wifiManager.startScan() - - let result = UniWifiResult(0,UniErrorSubject,"startWifi:ok",null) - option.success?.(result) - option.complete?.(result) - -} - -@Suppress("DEPRECATION") -export function startWifi(option : StartWifiOptions) { - - /** - * 准备权限 - */ - let permissionNeed = ["android.permission.ACCESS_FINE_LOCATION"]; - UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight:boolean,_grantedList:string[]) { - if (allRight) { - // 交给目前的location 引擎,真实执行 - startWifiImpl(option) - } - }, function (_doNotAskAgain:boolean,_grantedList:string[]) { - let err = new WifiFailImpl(getErrcode(12001)); - option.fail?.(err) - option.complete?.(err) - }) - -} - -/** - * 获取wifi列表 - */ -@Suppress("DEPRECATION") -export function getWifiList(option : GetWifiListOptions) { - - - if (Global.mReceiver == null) { - // 还没调用startWifi 提示报错 - let err = new WifiFailImpl(getErrcode(12000)); - option.fail?.(err) - option.complete?.(err) - - return - } - - let wifiManager : WifiManager = - UTSAndroid.getAppContext()!.getSystemService(Context.WIFI_SERVICE) as WifiManager - - if(option.success != null){ - Global.supendGetWifiSuccess = option.success - } - if(option.complete != null){ - Global.supendGetWifiComplete = option.complete - } - - wifiManager.startScan() - -} - - - -/** - * wifi 链接成功的回调注册 - */ -export function onWifiConnected(callback : UniWifiResultCallback) { - Global.onWifiConnectCallbackList.push(callback) -} - - -export function onWifiConnectedWithPartialInfo(callback : UniWifiResultCallbackWithPartialInfo) { - Global.onWifiConnectWithPartialInfoCallbackList.push(callback) -} - - -/** - * wifi 链接成功的回调取消注册 - */ -export function offWifiConnected(callback? : UniWifiResultCallback) { - - if(callback == null){ - Global.onWifiConnectCallbackList = [] - return - } - - let callbackIndex = Global.onWifiConnectCallbackList.indexOf(callback) - if (callbackIndex >= 0) { - Global.onWifiConnectCallbackList.splice(callbackIndex, 1); - } -} - -/** - * 不具备详细信息的wifi 反注册 - */ -export function offWifiConnectedWithPartialInfo(callback? : UniWifiResultCallbackWithPartialInfo) { - - if(callback == null){ - Global.onWifiConnectWithPartialInfoCallbackList = [] - return - } - - let callbackIndex = Global.onWifiConnectWithPartialInfoCallbackList.indexOf(callback) - if (callbackIndex >= 0) { - Global.onWifiConnectWithPartialInfoCallbackList.splice(callbackIndex, 1); - } -} - -/** - * 注册Wifi列表的监听事件 - */ -export function onGetWifiList(callback : UniGetWifiListCallback) { - Global.onGetWifiListCallback = callback -} - -/** - * 取消注册Wifi列表的监听事件 - */ -export function offGetWifiList(callback? : UniWifiCallback) { - Global.onGetWifiListCallback = null - Global.supendGetWifiComplete = null - Global.supendGetWifiSuccess = null -} - - -/** - * 真正执行wifi链接逻辑 - */ -function realWifiConnect(option : WifiConnectOption){ - - if (Global.mReceiver == null || Global.scanList.length < 1) { - - let err = new WifiFailImpl(getErrcode(12000)); - option.fail?.(err) - option.complete?.(err) - - return - } - - // 执行后续的逻辑 - let scanWifiInfo : AndroidUniWifiInfo | null = null - for (let scanResult in Global.scanList) { - if (scanResult.SSID.equals(option.SSID)) { - scanWifiInfo = scanResult - } - } - - if (scanWifiInfo == null) { - // 不在扫描列表中返回错误 - let err = new WifiFailImpl(getErrcode(12000)); - option.fail?.(err) - option.complete?.(err) - return - } - - let wifiConfigration = wrapWifiConfiguration(scanWifiInfo.SSID, option.password, scanWifiInfo.securityType); - wifiConfigration.BSSID = scanWifiInfo.BSSID - let wifiManager : WifiManager = - UTSAndroid.getAppContext()!.getSystemService(Context.WIFI_SERVICE) as WifiManager - - // 如果已经存在了指定wifi 配置,移除之 - let targetExistConfig : WifiConfiguration | null = null - let existingConfigs = wifiManager.getConfiguredNetworks(); - for (let existingConfig in existingConfigs) { - if (existingConfig.SSID.equals("\"" + option.SSID + "\"")) { - targetExistConfig = existingConfig - } - } - // 如果wifi已经保存了当前ssid的配置,可能是别的应用添加的。android系统要求,需要删除掉重新添加 - if (targetExistConfig != null) { - let removeRet = wifiManager.removeNetwork(targetExistConfig.networkId); - - if (!removeRet) { - - // add since 2023-03-28,如果当前系统大于等于android10, 则明确当前系统不支持 - if(Build.VERSION.SDK_INT > 28){ - // 系统大于android 9 - let err = new WifiFailImpl(getErrcode(12001)); - option.fail?.(err) - option.complete?.(err) - }else{ - // 移除之前的配置失败了,返回错误,需要用户手动取消保存一下 - let err = new WifiFailImpl(getErrcode(12013)); - option.fail?.(err) - option.complete?.(err) - } - - - return - } - - } - - let currentConnect = wifiManager.getConnectionInfo() - if (currentConnect.networkId >= 0) { - wifiManager.disableNetwork(currentConnect.networkId) - } else { - wifiManager.removeNetwork(currentConnect.networkId) - } - wifiManager.disconnect() - - let connected = false; - try { - - let netID = wifiManager.addNetwork(wifiConfigration); - // 如果-1 说明没添加上,报错即可 - if (netID < 0) { - let err = new WifiFailImpl(getErrcode(12002)); - option.fail?.(err) - option.complete?.(err) - - return - } - - - let enabled = wifiManager.enableNetwork(netID, true); - if (!enabled) { - let err = new WifiFailImpl(getErrcode(12007)); - option.fail?.(err) - option.complete?.(err) - - return - } - connected = wifiManager.reconnect(); - - } catch (e) { - connected = false; - console.log(e); - } - - if (!connected) { - // 出错了,返回错误 - // 兜底的报错 - let err = new WifiFailImpl(getErrcode(12010)); - option.fail?.(err) - option.complete?.(err) - return - } - - let result = new UniWifiResult(0,UniErrorSubject,"getWifiList:ok",null) - - wifiManager.saveConfiguration() - //scanWifiInfo 根据 partialInfo 填充给返回字段 - if (option.partialInfo != null && option.partialInfo == true) { - let wifiPartialInfo : UniWifiInfo = { - SSID: scanWifiInfo.SSID - } - result.wifi = wifiPartialInfo - } else { - result.wifi = wrapUniWifiInfoFromAndroid(scanWifiInfo) - } - - - option.success?.(result) - option.complete?.(result) -} - -/** - * 链接指定wifi - */ -@Suppress("UNUSED_PARAMETER", "DEPRECATION") -export function connectWifi(option : WifiConnectOption) { - - if (option.maunal == true) { - // 指定了手动模式 - let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS); - UTSAndroid.getUniActivity()!.startActivity(manunalIntent); - - - let result = new UniWifiResult(0,UniErrorSubject,"connectWifi:ok",null) - - option.success?.(result) - option.complete?.(result) - return - } - - - - // add since 2022-03-28 ,增加逻辑,如果正在扫描中,则可以等待5s - if(startWifiScaning){ - let taskCount = 0 - let taskId:number = 0 - taskId = setInterval(function(){ - - taskCount += 1; - if(taskCount >= 5 || startWifiScaning == false){ - // 超过10s了。或者扫描过程结束了 - clearInterval(taskId) - realWifiConnect(option) - } - },2000) - - UTSAndroid.onAppActivityDestroy(function () { - clearInterval(taskId) - }); - }else{ - realWifiConnect(option) - } - - - -} - - -/** - * 关闭wifi - */ -export function stopWifi(option : StopWifiOptions) { - // 需要先开启wifi,才能使用后续的功能 - if (Global.mReceiver == null) { - let err = new WifiFailImpl(getErrcode(12000)); - option.fail?.(err) - option.complete?.(err) - - return - } - try { - UTSAndroid.getUniActivity()!.unregisterReceiver(Global.mReceiver) - } catch (e) { - // 多次调用 - //TODO handle the exception - } - - Global.onGetWifiListCallback = null - Global.onWifiConnectWithPartialInfoCallbackList = [] - Global.onWifiConnectCallbackList = [] - Global.mReceiver = null - - let ret = new UniWifiResult(0,UniErrorSubject,"stopWifi:ok",null) - option.success?.(ret) - option.complete?.(ret) - -} - -/** - * 获取当前连接中的wifi信息 - */ -@Suppress("DEPRECATION") -export function getConnectedWifi(option : GetConnectedWifiOptions) { - - let wifiInfo : UniWifiInfo = { - SSID: "" - } - - - if (Global.mReceiver == null) { - // 还没调用startWifi 提示报错 - let err = new WifiFailImpl(getErrcode(12000)); - option.fail?.(err) - option.complete?.(err) - - return - } - - // 需要先校验权限,没有位置权限无法获取wifi - if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - // 尚不具备权限,返回错误 - let err = new WifiFailImpl(getErrcode(12001)); - option.fail?.(err) - option.complete?.(err) - return; - } - - - - const context = UTSAndroid.getAppContext(); - if (context != null) { - const wm = context.getSystemService( - Context.WIFI_SERVICE - ) as WifiManager; - // 测试android 12上可以使用 - //@ts-ignore - const winfo = wm.getConnectionInfo(); - - wifiInfo = wrapUniWifiInfoFromConnectInfo(winfo); - - let res = new UniWifiResult(0,UniErrorSubject,"getConnectedWifi:ok",null) - - // 判断一下是否wifi 关闭了 - if (option.partialInfo!= null && option.partialInfo == true) { - let ret : UniWifiInfo = { - SSID: wifiInfo.SSID - } - res.wifi = ret; - } else { - if (wifiInfo.BSSID == null || zeroCountNum(wifiInfo.BSSID) > 3) { - let err = new WifiFailImpl(getErrcode(12005)); - option.fail?.(err) - option.complete?.(err) - return - } - res.wifi = wifiInfo; - } - - - option.success?.(res) - option.complete?.(res) - return - } - - let err = new WifiFailImpl(getErrcode(12000)); - option.fail?.(err) - option.complete?.(err) - } - diff --git a/uni_modules/uni-wifi/utssdk/app-ios/Info.plist b/uni_modules/uni-wifi/utssdk/app-ios/Info.plist deleted file mode 100644 index f8fc457..0000000 --- a/uni_modules/uni-wifi/utssdk/app-ios/Info.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - NSLocationWhenInUseUsageDescription - 需要访问定位权限以获取当前连接的 Wi‑Fi 信息。 - - \ No newline at end of file diff --git a/uni_modules/uni-wifi/utssdk/app-ios/UTS.entitlements b/uni_modules/uni-wifi/utssdk/app-ios/UTS.entitlements deleted file mode 100644 index 240b91f..0000000 --- a/uni_modules/uni-wifi/utssdk/app-ios/UTS.entitlements +++ /dev/null @@ -1,8 +0,0 @@ - - - - - com.apple.developer.networking.wifi-info - - - \ No newline at end of file diff --git a/uni_modules/uni-wifi/utssdk/app-ios/config.json b/uni_modules/uni-wifi/utssdk/app-ios/config.json deleted file mode 100644 index 2058545..0000000 --- a/uni_modules/uni-wifi/utssdk/app-ios/config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "frameworks": [ - "CoreLocation.framework", - "SystemConfiguration.framework" - ], - "deploymentTarget": "12" -} \ No newline at end of file diff --git a/uni_modules/uni-wifi/utssdk/app-ios/index.uts b/uni_modules/uni-wifi/utssdk/app-ios/index.uts deleted file mode 100644 index dbb5497..0000000 --- a/uni_modules/uni-wifi/utssdk/app-ios/index.uts +++ /dev/null @@ -1,322 +0,0 @@ -import { CLLocationManager, CLAuthorizationStatus, CLLocationManagerDelegate } from 'CoreLocation' -import { CaptiveNetwork, kCNNetworkInfoKeySSID, kCNNetworkInfoKeyBSSID } from 'SystemConfiguration.CaptiveNetwork'; -import { NSArray, NSDictionary } from 'Foundation'; -import { CFString } from 'CoreFoundation'; -import { UIDevice } from 'UIKit'; -import { NEHotspotNetwork } from 'NetworkExtension'; -import { UniWifiResultCallbackWithPartialInfo, UniGetWifiListCallback, UniWifiResultCallback, WifiConnectOption, GetConnectedWifiOptions, UniWifiInfo, UniWifiResult, UniWifiCallback, StartWifi, StopWifi, GetWifiList, OnGetWifiList, OffGetWifiList, GetConnectedWifi, ConnectWifi, OnWifiConnected, OnWifiConnectedWithPartialInfo, OffWifiConnected, OffWifiConnectedWithPartialInfo, SetWifiList, - StartWifiOptions, StopWifiOptions, GetWifiListOptions, SetWifiListOptions} from "../interface.uts" -import { WifiFailImpl, getErrcode } from '../unierror'; - -/* - * 系统定位权限获取类 - */ -class LocationPromiseService implements CLLocationManagerDelegate { - static promiseCompletionHandler: ((res: boolean)=>void)[] = [] - - manager?: CLLocationManager - - constructor(manager?: CLLocationManager) { - this.manager = manager - } - - initlizeManager(): boolean { - if (this.manager == null) { - this.manager = new CLLocationManager() - this.manager!.delegate = this - } - return true - } - @UTSiOS.available("iOS 14.0, *") - locationManagerDidChangeAuthorization(manager: CLLocationManager) { - if (UTSiOS.available("iOS 14.0, *")) { - let status = manager.authorizationStatus; - if (status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse) { - LocationPromiseService.promiseCompletionHandler.forEach((handler): void => { - handler(true) - }) - } else if (status == CLAuthorizationStatus.notDetermined) { - manager.requestWhenInUseAuthorization() - } else if (status == CLAuthorizationStatus.denied) { - LocationPromiseService.promiseCompletionHandler.forEach((handler): void => { - handler(false) - }) - } - } - } - - locationManager(manager: CLLocationManager, @argumentLabel("didChangeAuthorization") status: CLAuthorizationStatus) { - if (UIDevice.current.systemVersion < "14.0") - if (status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse) { - LocationPromiseService.promiseCompletionHandler.forEach((handler): void => { - handler(true) - }) - } else if (status == CLAuthorizationStatus.notDetermined) { - manager.requestWhenInUseAuthorization() - } else if (status == CLAuthorizationStatus.denied) { - LocationPromiseService.promiseCompletionHandler.forEach((handler): void => { - handler(false) - }) - } - } - requestPromise(@escaping completion: (res: boolean)=>void) { - let status: CLAuthorizationStatus = CLLocationManager.authorizationStatus() - if (status == CLAuthorizationStatus.notDetermined) { - if (this.initlizeManager() == true) { - this.manager!.requestWhenInUseAuthorization() - LocationPromiseService.promiseCompletionHandler.push(completion) - } - } else if (status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse) { - completion(true) - } else if (status == CLAuthorizationStatus.denied) { - if (CLLocationManager.locationServicesEnabled() == false && this.initlizeManager() == true) { - this.manager!.requestWhenInUseAuthorization() - LocationPromiseService.promiseCompletionHandler.push(completion) - } - } - } -} - -const locationPromiseService: LocationPromiseService = new LocationPromiseService(null) - -/* - * 获取系统定位权限 - */ -function requestLocationPromise(@escaping completion: (res: boolean)=>void) { - locationPromiseService.requestPromise(completion) -} - -/* - * 获取当前连接的wifi信息(通过定位权限) - */ -function fetchConnectedWifiWithLocationPromise(option: GetConnectedWifiOptions) { - - if (UTSiOS.available("iOS 14.0, *")) { - NEHotspotNetwork.fetchCurrent(completionHandler = (network): void => { - if (network != null) { - let wifiInfo: UniWifiInfo = { - BSSID: network!.bssid, - SSID: network!.ssid, - secure: network!.isSecure, - signalStrength: network!.signalStrength, - frequency: 0 - } - if (wifiInfo.BSSID!.length > 0 && wifiInfo.SSID.length > 0) { - let res: UniWifiResult = { - errSubject: "uni-getConnectedWifi", - errCode: 0, - errMsg: "getConnectedWifi:ok", - wifi: wifiInfo, - } - option.success?.(res) - option.complete?.(res) - }else { - let err = new WifiFailImpl(getErrcode(12010)); - option.fail?.(err) - option.complete?.(err) - } - }else { - let err = new WifiFailImpl(getErrcode(12010)); - option.fail?.(err) - option.complete?.(err) - } - }) - }else { - let arr = CNCopySupportedInterfaces() - let wifiInfo: UniWifiInfo = { - BSSID: "", - SSID: "", - secure: false, - signalStrength: 0, - frequency: 0 - } - - if (arr != null) { - let list = arr! as NSArray - let index: Int = 0 - while (index < list.count) { - let item = list[index] - let interfaceName = item as string - let dic = CNCopyCurrentNetworkInfo(interfaceName as CFString) - if (dic != null) { - let dict = dic! as NSDictionary - let SSID = dict[kCNNetworkInfoKeySSID as string] - let BSSID = dict[kCNNetworkInfoKeyBSSID as string] - - if (SSID != null && BSSID != null) { - let ssid = SSID! as string - let bssid = BSSID! as string - wifiInfo.SSID = ssid - wifiInfo.BSSID = bssid - wifiInfo.secure = false - wifiInfo.signalStrength = 0 - wifiInfo.frequency = 0 - break; - } - } - index++ - } - - if (wifiInfo.BSSID!.length > 0 && wifiInfo.SSID.length > 0) { - let res: UniWifiResult = { - errSubject: "uni-getConnectedWifi", - errCode: 0, - errMsg: "getConnectedWifi:ok", - wifi: wifiInfo, - } - option.success?.(res) - option.complete?.(res) - }else { - let err = new WifiFailImpl(getErrcode(12010)); - option.fail?.(err) - option.complete?.(err) - } - }else { - let err = new WifiFailImpl(getErrcode(12010)); - option.fail?.(err) - option.complete?.(err) - } - } - -} - - - -/* - * 保存全局数据信息 - */ -class UniWiFiModuleGloabInfo { - static alreadyStartWifi: boolean = false -} - -/* =================================== 对外暴露的接口 ==============================================*/ - - - -/* - * 初始化wifi模块 - */ -export const startWifi: StartWifi = function (option: StartWifiOptions) { - UniWiFiModuleGloabInfo.alreadyStartWifi = true - let res: UniWifiResult = { - errSubject: "uni-startWifi", - errCode: 0, - errMsg: "startWifi:ok", - wifi: null - } - option.success?.(res) - option.complete?.(res) -} - -/* - * 停止wifi模块 - */ -export const stopWifi: StopWifi = function (option: StopWifiOptions) { - UniWiFiModuleGloabInfo.alreadyStartWifi = false - LocationPromiseService.promiseCompletionHandler = [] - let res: UniWifiResult = { - errSubject: "uni-stopWifi", - errCode: 0, - errMsg: "stopWifi:ok", - wifi: null - } - option.success?.(res) - option.complete?.(res) -} - -/* - * 获取wifi列表, 在调用之前需要引导用户跳转到系统设置-WIFI设置页面,系统搜索周边wifi后app才能接收到回调 - */ -export const getWifiList: GetWifiList = function (option: GetWifiListOptions) { - let err = new WifiFailImpl(getErrcode(12001)); - option.fail?.(err) - option.complete?.(err) -} - -/* 获取wifi列表的回调 - * note: 请在getWifiList方法的回调里调用该方法 - */ -export const onGetWifiList: OnGetWifiList = function (callback: UniGetWifiListCallback) { - -} - -/* - * 注销获取wifi列表的回调 - */ -export const offGetWifiList: OffGetWifiList = function (callback: UniWifiCallback) { - -} - - -/* - * 获取当前连接的wifi信息 - */ -export const getConnectedWifi: GetConnectedWifi = function (option: GetConnectedWifiOptions) { - if (UniWiFiModuleGloabInfo.alreadyStartWifi == false) { - let err = new WifiFailImpl(getErrcode(12000)); - option.fail?.(err) - option.complete?.(err) - } else{ - if (UIDevice.current.systemVersion >= "13.0") { - requestLocationPromise((success) => { - if (success == true) { - fetchConnectedWifiWithLocationPromise(option) - }else { - let err = new WifiFailImpl(getErrcode(12007)); - option.fail?.(err) - option.complete?.(err) - } - }) - } else{ - fetchConnectedWifiWithLocationPromise(option) - } - } -} - -/* - * 连接wifi - */ -export const connectWifi: ConnectWifi = function (option: WifiConnectOption) { - - let err = new WifiFailImpl(getErrcode(12001)); - option.fail?.(err) - option.complete?.(err) -} - - -/* - * 连上wifi事件的监听函数 - */ -export const onWifiConnected: OnWifiConnected = function (callback: UniWifiResultCallback) { - -} - -/* - * 连上wifi事件的监听函数, wifiInfo仅包含ssid - */ -export const onWifiConnectedWithPartialInfo: OnWifiConnectedWithPartialInfo = function (callback: UniWifiResultCallbackWithPartialInfo) { - -} - -/* - * 移除连接上wifi的事件的监听函数,不传此参数则移除所有监听函数。 - */ -export const offWifiConnected: OffWifiConnected = function (callback: UniWifiCallback | null) { - -} - -/* - * 移除连接上wifi的事件的监听函数,不传此参数则移除所有监听函数。 - */ -export const offWifiConnectedWithPartialInfo: OffWifiConnectedWithPartialInfo = function (callback: UniWifiResultCallbackWithPartialInfo | null) { - -} - -/* - * 设置 wifiList 中 AP 的相关信息。在 onGetWifiList 回调后调用,iOS特有接口。 - */ -export const setWifiList: SetWifiList = function (option: SetWifiListOptions) { - let err = new WifiFailImpl(getErrcode(12001)); - option.fail?.(err) - option.complete?.(err) -} diff --git a/uni_modules/uni-wifi/utssdk/index.d.ts b/uni_modules/uni-wifi/utssdk/index.d.ts deleted file mode 100644 index 64f0829..0000000 --- a/uni_modules/uni-wifi/utssdk/index.d.ts +++ /dev/null @@ -1,388 +0,0 @@ -declare namespace UniNamespace { - - type UniWifiComplete = any - type WifiSuccessCallback = (res : UniWifiResult) => void - type WifiFailCallback = (err : UniWifiFail) => void - type WifiCompleteCallback = (res : UniWifiComplete) => void - type UniWifiCallback = () => void - - - type WifiErrorCode = 1300002 - - interface UniWifiInfo { - SSID : string; - BSSID ?: string; - secure ?: boolean; - signalStrength ?: number; - frequency ?: number; - } - - interface UniWifiResult { - errCode : number, - errSubject : string, - errMsg : string, - wifi : UniWifiInfo | null - } - - interface UniWifiFail { - errCode : WifiErrorCode - } - - interface WifiConnectOption { - SSID : string | null; - BSSID : string | null; - password : string | null; - maunal : boolean | null; - partialInfo : boolean | null; //ios不生效 - success : WifiSuccessCallback | null; - fail : WifiFailCallback | null; - complete : WifiCompleteCallback | null; - } - - interface GetConnectedWifiOptions { - partialInfo : boolean | null; - success : WifiSuccessCallback | null; - fail : WifiFailCallback | null; - complete ?: WifiCompleteCallback | null; - } - - - interface WifiOption { - success : WifiSuccessCallback | null, - fail : WifiFailCallback | null, - complete : InstallApkCompleteCallback | null - } - - interface UniWifiInfoWithPartialInfo { - SSID : string; - } - - type UniGetWifiListCallback = (wifiInfo:UTSJSONObject) => void - - type UniWifiResultCallback = (wifiInfo:UniWifiResult) => void - - type UniWifiResultCallbackWithPartialInfo = (wifiInfo:UniWifiInfoWithPartialInfo) => void - -} - -declare interface Uni { - - /** - * 初始化Wi-Fi模块 - * - * @param {WifiOption} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#startwifi - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { after: 'stopWifi' } - */ - startWifi(option : UniNamespace.WifiOption): void, - - /** - * 关闭 Wi-Fi 模块 - * - * @param {WifiOption} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#stopwifi - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { before: 'startWifi' } - */ - stopWifi(option : UniNamespace.WifiOption) : void, - /** - * @param {WifiConnectOption} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi - * @uniPlatform { - * "app": { - * "android": { - * "osVer": ">=4.4 && <10.0", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { - generated: false, - pollution: false, - cases:[ - { - before: 'startWifi', - after: 'stopWifi', - input: [{ - maunal:false, - SSID:"Xiaomi_20D0", - password:"streamApp!2016", - }], - output:{ - callbackType: 'success', - value: { errCode: 12013 ,errMsg: "connectWifi:wifi config may be expired",errSubject: "uni-connectWifi"} - } - } - ] - } - */ - connectWifi(option : UniNamespace.WifiConnectOption) : void, - /** - * 请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。 - * @param {WifiOption} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#getWifiList - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { before: 'startWifi', after: 'stopWifi' } - */ - getWifiList(option : UniNamespace.WifiOption) : void, - /** - * 监听获取到 Wi-Fi 列表数据事件。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onGetWifiList - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - * @autotest { - generated: false, - pollution: false, - expectCallback: true, - before: 'startWifi', - after: 'onGetWifiListAfter', - cases: [ - { - output: { - value: 0, - returnKey: '.wifiList.length', - jestExpectSyntax: 'toBeGreaterThan' - }, - } - ] - } - */ - onGetWifiList(callback : UniNamespace.UniGetWifiListCallback) : void, - /** - * 移除获取到 Wi-Fi 列表数据事件的监听函数。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offGetWifiList - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - offGetWifiList(callback : UniNamespace.UniWifiCallback) : void, - /** - * 获取已连接的 Wi-Fi 信息 - * - * @param {GetConnectedWifiOptions} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#getConnectedWifi - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { before: 'startWifi', after: 'stopWifi' } - */ - getConnectedWifi(option : UniNamespace.GetConnectedWifiOptions) : void, - /** - * 监听连接上 Wi-Fi 的事件 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnected - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - onWifiConnected(callback : UniNamespace.UniWifiResultCallback) : void, - /** - * 监听连接上 Wi-Fi 的事件。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnectedWithPartialInfo - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - onWifiConnectedWithPartialInfo(callback : UniNamespace.UniWifiResultCallbackWithPartialInfo) : void, - /** - * 移除连接上 Wi-Fi 的事件的监听函数。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnected - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - offWifiConnected(callback ?: UniNamespace.UniWifiCallback) : void, - - /** - * 移除连接上 Wi-Fi 的事件的监听函数。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnectedWithPartialInfo - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - offWifiConnectedWithPartialInfo(callback ?: UniNamespace.UniWifiResultCallbackWithPartialInfo) : void, - /** - * SetWifiList 暂未实现 - * - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * } - * } - */ - setWifiList(option : UniNamespace.WifiOption) : void, - - -} diff --git a/uni_modules/uni-wifi/utssdk/interface.uts b/uni_modules/uni-wifi/utssdk/interface.uts deleted file mode 100644 index 206b214..0000000 --- a/uni_modules/uni-wifi/utssdk/interface.uts +++ /dev/null @@ -1,444 +0,0 @@ -/** - * Wifi 函数通用入参封装 - */ -export type StartWifiOptions = { - success ?: (res : UniWifiResult) => void; - fail ?: (res : UniError) => void; - complete ?: (res : any) => void; -}; - -export type StopWifiOptions = { - success ?: (res : UniWifiResult) => void; - fail ?: (res : UniError) => void; - complete ?: (res : any) => void; -}; - - -export type GetWifiListOptions = { - success ?: (res : UniWifiResult) => void; - fail ?: (res : UniError) => void; - complete ?: (res : any) => void; -}; - -export type SetWifiListOptions = { - success ?: (res : UniWifiResult) => void; - fail ?: (res : UniError) => void; - complete ?: (res : any) => void; -}; - - -/** - * Wifi 链接参数封装 - */ -export type WifiConnectOption = { - SSID ?: string; - BSSID ?: string; - password ?: string; - maunal ?: boolean; - partialInfo ?: boolean; //ios不生效 - success ?: (res : UniWifiResult) => void; - fail ?: (res : UniError) => void; - complete ?: (res : any) => void; -} - -/** - * 获取当前链接的wifi信息 - */ -export type GetConnectedWifiOptions = { - partialInfo ?: boolean - success ?: (res : UniWifiResult) => void - fail ?: (res : UniError) => void - complete ?: (res : any) => void -} - -/* - * 对外暴露的wifi信息 - */ -export type UniWifiInfo = { - SSID : string; - BSSID ?: string; - secure ?: boolean; - signalStrength ?: number; - frequency ?: number; -} - -export type UniWifiInfoWithPartialInfo = { - SSID : string; -} - - -export type UniWifiResult = { - errCode : number, - errSubject : string, - errMsg : string, - wifi : UniWifiInfo | null -} - -export type UniWifiCallback = () => void - -export type UniGetWifiListCallback = (wifiInfo:UTSJSONObject) => void - -export type UniWifiResultCallback = (wifiInfo:UniWifiResult) => void - -export type UniWifiResultCallbackWithPartialInfo = (wifiInfo:UniWifiInfoWithPartialInfo) => void - - -export type StartWifi = (option : StartWifiOptions) => void - -export type StopWifi = (option : StopWifiOptions) => void - -export type GetWifiList = (option : GetWifiListOptions) => void - -export type OnGetWifiList = (callback : UniGetWifiListCallback) => void - -export type OffGetWifiList = (callback : UniWifiCallback) => void - -export type GetConnectedWifi = (option : GetConnectedWifiOptions) => void - -export type ConnectWifi = (option : WifiConnectOption) => void - -export type OnWifiConnected = (callback : UniWifiResultCallback) => void - -export type OnWifiConnectedWithPartialInfo = (callback : UniWifiResultCallbackWithPartialInfo) => void - -export type OffWifiConnected = (callback : UniWifiCallback | null) => void - -export type OffWifiConnectedWithPartialInfo = (callback : UniWifiResultCallbackWithPartialInfo | null) => void - -export type SetWifiList = (option : SetWifiListOptions) => void - - -/** - * 错误码 - * - 12000 尚未初始化 - * - 12001 当前系统不支持相关能力 - * - 12002 密码错误 - * - 12005 Android 特有,未打开 Wi-Fi 开关 - * - 12007 用户拒绝授权链接 Wi-Fi - * - 12010 系统其他错误 - * - 12013 系统保存的 Wi-Fi 配置过期,建议忘记 Wi-Fi 后重试,仅 Android 支持 - */ -export type WifiErrorCode = 12000 |12001 | 12002 | 12005 | 12007 | 12010 | 12013; - -export interface WifiFail extends IUniError{ - errCode: WifiErrorCode -}; - - - -interface Uni { - /** - * 初始化Wi-Fi模块 - * - * @param {WifiOption} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#startwifi - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { after: 'stopWifi' } - */ - startWifi(option : StartWifiOptions): void, - /** - * 关闭 Wi-Fi 模块 - * - * @param {WifiOption} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#stopwifi - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { before: 'startWifi' } - */ - stopWifi(option : StopWifiOptions) : void, - /** - * @param {WifiConnectOption} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi - * @uniPlatform { - * "app": { - * "android": { - * "osVer": ">=4.4 && <10.0", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { - generated: false, - pollution: false, - cases:[ - { - before: 'startWifi', - after: 'stopWifi', - input: [{ - maunal:false, - SSID:"Xiaomi_20D0", - password:"streamApp!2016", - }], - output:{ - callbackType: 'success', - value: { errCode: 12013 ,errMsg: "connectWifi:wifi config may be expired",errSubject: "uni-connectWifi"} - } - } - ] - } - */ - connectWifi(option : WifiConnectOption) : void, - /** - * 请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。 - * @param {WifiOption} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#getWifiList - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { before: 'startWifi', after: 'stopWifi' } - */ - getWifiList(option : GetWifiListOptions) : void, - /** - * 监听获取到 Wi-Fi 列表数据事件。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onGetWifiList - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - * @autotest { - generated: false, - pollution: false, - expectCallback: true, - before: 'startWifi', - after: 'onGetWifiListAfter', - cases: [ - { - output: { - value: 0, - returnKey: '.wifiList.length', - jestExpectSyntax: 'toBeGreaterThan' - }, - } - ] - } - */ - onGetWifiList(callback : UniGetWifiListCallback) : void, - /** - * 移除获取到 Wi-Fi 列表数据事件的监听函数。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offGetWifiList - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - offGetWifiList(callback : UniWifiCallback) : void, - /** - * 获取已连接的 Wi-Fi 信息 - * - * @param {GetConnectedWifiOptions} option - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#getConnectedWifi - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { before: 'startWifi', after: 'stopWifi' } - */ - getConnectedWifi(option : GetConnectedWifiOptions) : void, - /** - * 监听连接上 Wi-Fi 的事件 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnected - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - onWifiConnected(callback : UniWifiResultCallback) : void, - /** - * 监听连接上 Wi-Fi 的事件。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnectedWithPartialInfo - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - onWifiConnectedWithPartialInfo(callback : UniWifiResultCallbackWithPartialInfo) : void, - /** - * 移除连接上 Wi-Fi 的事件的监听函数。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnected - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.7.0", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.7.7", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - offWifiConnected(callback : UniWifiCallback | null) : void, - /** - * 移除连接上 Wi-Fi 的事件的监听函数。 - * - * @param {UniWifiCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnectedWithPartialInfo - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * } - * } - * @uniVersion 3.7.7 - * @uniVueVersion 2,3 //支持的vue版本 - * @autotest { expectCallback: true } - */ - offWifiConnectedWithPartialInfo(callback : UniWifiResultCallbackWithPartialInfo | null) : void, - /** - * SetWifiList 暂未实现 - * - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * } - * } - */ - setWifiList(option : SetWifiListOptions) : void, -} diff --git a/uni_modules/uni-wifi/utssdk/uni.autotest.js b/uni_modules/uni-wifi/utssdk/uni.autotest.js deleted file mode 100644 index 7f0ac09..0000000 --- a/uni_modules/uni-wifi/utssdk/uni.autotest.js +++ /dev/null @@ -1,35 +0,0 @@ -export function startWifi() { - return new Promise((resolve, reject) => { - uni.startWifi({ - success: () => { - console.log('startWifi success'); - resolve() - }, - complete: () => { - console.log('startWifi fail'); - resolve() - } - }) - }) -} - -export function stopWifi() { - return new Promise((resolve, reject) => { - uni.stopWifi({ - complete: resolve - }) - }) -} - -export function onGetWifiListAfter() { - return new Promise((resolve, reject) => { - uni.getWifiList({ - success() { - setTimeout(resolve, 500) - }, - complete() { - stopWifi().finally(resolve) - } - }) - }) -} \ No newline at end of file diff --git a/uni_modules/uni-wifi/utssdk/unierror.uts b/uni_modules/uni-wifi/utssdk/unierror.uts deleted file mode 100644 index 023c2de..0000000 --- a/uni_modules/uni-wifi/utssdk/unierror.uts +++ /dev/null @@ -1,59 +0,0 @@ -import { WifiErrorCode, WifiFail} from "./interface.uts" - -/** - * 错误主题 - */ -export const UniErrorSubject = 'uni-wifi'; -/** - * 错误码 - * @UniError - */ -export const WifiUniErrors : Map = new Map([ - - /** - * 未先调用 startWifi 接口 - */ - [12000, 'not init.'], - /** - * 当前系统不支持相关能力 - */ - [12001, 'system not support'], - /** - * 密码错误 - */ - [12002, 'password error Wi-Fi'], - /** - * Android 特有,未打开 Wi-Fi 开关 - */ - [12005, 'wifi not turned on'], - /** - * 用户拒绝授权链接 Wi-Fi - */ - [12007, 'user denied'], - /** - * 系统其他错误,需要在 errmsg 打印具体的错误原因 - */ - [12010, 'unknown error'], - /** - * 系统保存的 Wi-Fi 配置过期,建议忘记 Wi-Fi 后重试,仅 Android 支持 - */ - [12013, 'wifi config may be expired'], - -]); - - -export function getErrcode(errCode : number) : WifiErrorCode { - const res = WifiUniErrors[errCode]; - return res == null ? 12000 : errCode; -} - - -export class WifiFailImpl extends UniError implements WifiFail { - constructor(errCode : WifiErrorCode) { - super(); - this.errSubject = UniErrorSubject; - this.errCode = errCode; - this.errMsg = WifiUniErrors[errCode] ?? ""; - } -} -