diff --git a/README.md b/README.md index 73544ecb..2db864b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ +
@@ -19,7 +20,7 @@

-[查看文档](https://novlan1.github.io/press-ui/) | [查看示例](https://novlan1.github.io/press-ui-demo-vue2/) +[查看文档](https://novlan1.github.io/press-ui/) | [查看示例](https://novlan1.github.io/press-ui/h5/) ### 1. 介绍 diff --git a/package.json b/package.json index fc98dbfc..3cc574b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "press-ui", - "version": "2.2.7", + "version": "2.2.11", "description": "简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目", "private": true, "repository": { @@ -25,7 +25,7 @@ "build:mp": "rm -rf dist && cd packages/press-ui && npm run build:mp && cp -r dist ../../", "build:mp-qq": "rm -rf dist && cd packages/press-ui && npm run build:mp-qq && cp -r dist ../../", "build:mp-alipay": "rm -rf dist && cd packages/press-ui && npm run build:mp-alipay && cp -r dist ../../", - "build:igame": "rm -rf dist && cd packages/press-ui && npm run build:igame && cp -r dist ../../", + "build:igame": "NODE_OPTIONS=--openssl-legacy-provider rm -rf dist && cd packages/press-ui && npm run build:igame && cp -r dist ../../", "dev": "cd packages/press-ui && npm run dev", "dev:mp": "cd packages/press-ui && npm run dev:mp", "dev:mp-qq": "cd packages/press-ui && npm run dev:mp-qq", diff --git a/packages/press-ui-vue3-pure/README.md b/packages/press-ui-vue3-pure/README.md index d2cd6152..92b6ed29 100644 --- a/packages/press-ui-vue3-pure/README.md +++ b/packages/press-ui-vue3-pure/README.md @@ -6,7 +6,7 @@ --- -[查看文档](https://novlan1.github.io/press-ui/) | [查看示例](https://novlan1.github.io/press-ui-demo-vue2/) +[查看文档](https://novlan1.github.io/press-ui/) | [查看示例](https://novlan1.github.io/press-ui/h5/) ### 1. 介绍 diff --git a/packages/press-ui/CHANGELOG.md b/packages/press-ui/CHANGELOG.md index 76c03aa0..70f6c5dc 100644 --- a/packages/press-ui/CHANGELOG.md +++ b/packages/press-ui/CHANGELOG.md @@ -2,6 +2,55 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [2.2.11](https://github.com/novlan1/press-ui/compare/v2.2.10...v2.2.11) (2024-12-05) + + +### ✏️ Documentation | 文档 + +* update docs ([abc684f](https://github.com/novlan1/press-ui/commit/abc684fa0f6df7a9271f5ad454e2412f6c424c82)) + + +### 🚀 Chore | 构建/工程依赖/工具 + +* lint ([4984334](https://github.com/novlan1/press-ui/commit/49843344d0fd1572c7310e8642a25ff5d1696ea7)) + + +### ✨ Features | 新功能 + +* add getVMInVue3 ([e28f15a](https://github.com/novlan1/press-ui/commit/e28f15a6c57f21a61a59dc5befe3db92b2b62756)) + +### [2.2.10](https://github.com/novlan1/press-ui/compare/v2.2.9...v2.2.10) (2024-12-02) + + +### ♻️ Code Refactoring | 代码重构 + +* 不使用wx.getSystemInfoSync ([0abefc0](https://github.com/novlan1/press-ui/commit/0abefc0fc92193955b70497d7bcfc66ec318a285)) + + +### 🚀 Chore | 构建/工程依赖/工具 + +* lint ([a6717a5](https://github.com/novlan1/press-ui/commit/a6717a5a6d9862dc4304a050e7c1cdb3c14443e5)) + +### [2.2.9](https://github.com/novlan1/press-ui/compare/v2.2.8...v2.2.9) (2024-11-28) + + +### ✨ Features | 新功能 + +* **functional-component:** 支持selector为函数 ([27d3dbb](https://github.com/novlan1/press-ui/commit/27d3dbb6f28f77178b6dbd1f7d0e2ecc5a6e7f50)) + +### [2.2.8](https://github.com/novlan1/press-ui/compare/v2.2.7...v2.2.8) (2024-11-26) + + +### 🚀 Chore | 构建/工程依赖/工具 + +* update github workflow ([bc13c15](https://github.com/novlan1/press-ui/commit/bc13c159cfb1df7253cbdabb0108f838d881f23f)) +* update github workflow ([3ddeadb](https://github.com/novlan1/press-ui/commit/3ddeadba8e7c652653f73060da35c4deda37b1e2)) + + +### ✨ Features | 新功能 + +* **uploader:** emit chooseFile ([a085f4b](https://github.com/novlan1/press-ui/commit/a085f4b74a3f1517b29d9296b5248559d9023be3)) + ### [2.2.7](https://github.com/novlan1/press-ui/compare/v2.2.6...v2.2.7) (2024-11-18) diff --git a/packages/press-ui/README.md b/packages/press-ui/README.md index ff2e6445..7c4fbb7f 100644 --- a/packages/press-ui/README.md +++ b/packages/press-ui/README.md @@ -6,4 +6,4 @@ --- -[查看文档](https://novlan1.github.io/press-ui/) | [查看示例](https://novlan1.github.io/press-ui-demo-vue2/) +[查看文档](https://novlan1.github.io/press-ui/) | [查看示例](https://novlan1.github.io/press-ui/h5/) diff --git a/packages/press-ui/docs/README.md b/packages/press-ui/docs/README.md index fd549230..3555902a 100644 --- a/packages/press-ui/docs/README.md +++ b/packages/press-ui/docs/README.md @@ -1,4 +1,5 @@ +
@@ -19,7 +20,6 @@

- ### 1. 介绍 `Press UI`是一套易用、灵活,基于`uni-app`的跨端组件库。 @@ -110,12 +110,12 @@ module.exports = { } ``` + #### 4.2. uni_modules 方式 [插件市场](https://ext.dcloud.net.cn/plugin?id=18798)直接导入即可 - ### 5. 立即体验 下图是示例二维码,第一行分别为基于 `uni-app` 的 `Vue2.x` 版本的 H5、微信小程序、QQ小程序、支付宝小程序、安卓项目。 diff --git a/packages/press-ui/docs/changelog.md b/packages/press-ui/docs/changelog.md index 49c72253..82a0dc5d 100644 --- a/packages/press-ui/docs/changelog.md +++ b/packages/press-ui/docs/changelog.md @@ -1,5 +1,54 @@ # 更新日志 +### [2.2.11](https://github.com/novlan1/press-ui/compare/v2.2.10...v2.2.11) (2024-12-05) + + +### Documentation 📖 + +* update docs ([abc684f](https://github.com/novlan1/press-ui/commit/abc684fa0f6df7a9271f5ad454e2412f6c424c82)) + + +### Chore 🚀 + +* lint ([4984334](https://github.com/novlan1/press-ui/commit/49843344d0fd1572c7310e8642a25ff5d1696ea7)) + + +### Features 🎉 + +* add getVMInVue3 ([e28f15a](https://github.com/novlan1/press-ui/commit/e28f15a6c57f21a61a59dc5befe3db92b2b62756)) + +### [2.2.10](https://github.com/novlan1/press-ui/compare/v2.2.9...v2.2.10) (2024-12-02) + + +### Code Refactoring ♻️ + +* 不使用wx.getSystemInfoSync ([0abefc0](https://github.com/novlan1/press-ui/commit/0abefc0fc92193955b70497d7bcfc66ec318a285)) + + +### Chore 🚀 + +* lint ([a6717a5](https://github.com/novlan1/press-ui/commit/a6717a5a6d9862dc4304a050e7c1cdb3c14443e5)) + +### [2.2.9](https://github.com/novlan1/press-ui/compare/v2.2.8...v2.2.9) (2024-11-28) + + +### Features 🎉 + +* **functional-component:** 支持selector为函数 ([27d3dbb](https://github.com/novlan1/press-ui/commit/27d3dbb6f28f77178b6dbd1f7d0e2ecc5a6e7f50)) + +### [2.2.8](https://github.com/novlan1/press-ui/compare/v2.2.7...v2.2.8) (2024-11-26) + + +### Chore 🚀 + +* update github workflow ([bc13c15](https://github.com/novlan1/press-ui/commit/bc13c159cfb1df7253cbdabb0108f838d881f23f)) +* update github workflow ([3ddeadb](https://github.com/novlan1/press-ui/commit/3ddeadba8e7c652653f73060da35c4deda37b1e2)) + + +### Features 🎉 + +* **uploader:** emit chooseFile ([a085f4b](https://github.com/novlan1/press-ui/commit/a085f4b74a3f1517b29d9296b5248559d9023be3)) + ### [2.2.7](https://github.com/novlan1/press-ui/compare/v2.2.6...v2.2.7) (2024-11-18) diff --git a/packages/press-ui/docs/quickstart.md b/packages/press-ui/docs/quickstart.md index ab18292e..e0f547d3 100644 --- a/packages/press-ui/docs/quickstart.md +++ b/packages/press-ui/docs/quickstart.md @@ -163,6 +163,14 @@ export default { ``` +另外,对于以下组件,在 Vue3 下做了 `v-model` 相关的适配,具体使用变化为: `value` 属性改为 `modelValue`,`input` 事件改为 `update:modelValue`。如果是使用的 `v-model`,则无需改变。 + +- [field](./components/press/press-field.html) +- [list](./components/press/press-list.html) +- [number-keyboard](./components/press/press-number-keyboard.html) +- [popover-plus](./components/press/press-popover-plus.html) +- [pull-refresh](./components/press/press-pull-refresh.html) + [点此查看](https://github.com/novlan1/press-ui-demo-vue3) Vue3 的 uni-app 示例项目。 ## 4. 普通 Vue3 项目 diff --git a/packages/press-ui/package.json b/packages/press-ui/package.json index fc92c7b5..a1341f08 100644 --- a/packages/press-ui/package.json +++ b/packages/press-ui/package.json @@ -1,6 +1,6 @@ { "name": "press-ui", - "version": "2.2.7", + "version": "2.2.11", "description": "简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目", "private": true, "repository": { diff --git a/packages/press-ui/public/index.html b/packages/press-ui/public/index.html index 6b39e6f5..dc7ba82f 100644 --- a/packages/press-ui/public/index.html +++ b/packages/press-ui/public/index.html @@ -4,6 +4,7 @@ + diff --git a/packages/press-ui/src/packages/common/component-handler/init-functional-dialog.js b/packages/press-ui/src/packages/common/component-handler/init-functional-dialog.js index 8091a296..472f8286 100644 --- a/packages/press-ui/src/packages/common/component-handler/init-functional-dialog.js +++ b/packages/press-ui/src/packages/common/component-handler/init-functional-dialog.js @@ -44,5 +44,5 @@ export function initFunctionalDialog({ return promise.then(val => Promise.resolve(val)) .catch(err => Promise.reject(err)); } - console.warn('The press-dialog node is not found, please confirm whether the selector and context are correct'); + console.warn(`The ${options.selector} node is not found, please confirm whether the selector and context are correct`); } diff --git a/packages/press-ui/src/packages/common/component-handler/set-data.d.ts b/packages/press-ui/src/packages/common/component-handler/set-data.d.ts index 59b65c46..f3606892 100644 --- a/packages/press-ui/src/packages/common/component-handler/set-data.d.ts +++ b/packages/press-ui/src/packages/common/component-handler/set-data.d.ts @@ -1,2 +1,3 @@ export declare function setData(dialog: any, data: any, func?: string): any; export declare function vmSet(dialog: any, ...args: Array): void; +export declare function getVMInVue3(context: any): any; diff --git a/packages/press-ui/src/packages/common/component-handler/set-data.js b/packages/press-ui/src/packages/common/component-handler/set-data.js index d334a5d5..9554435e 100644 --- a/packages/press-ui/src/packages/common/component-handler/set-data.js +++ b/packages/press-ui/src/packages/common/component-handler/set-data.js @@ -15,3 +15,17 @@ export function vmSet(dialog, ...args) { vm[args[0]] = args[1]; } } + + +export function getVMInVue3(context) { + if (!context) return; + + let result; + // #ifdef H5 + result = context; + // #endif + // #ifndef H5 + result = context.$vm; + // #endif + return result; +} diff --git a/packages/press-ui/src/packages/common/dom/rect.js b/packages/press-ui/src/packages/common/dom/rect.js index da87ea03..da7caca0 100644 --- a/packages/press-ui/src/packages/common/dom/rect.js +++ b/packages/press-ui/src/packages/common/dom/rect.js @@ -1,6 +1,6 @@ import { getScrollSelector } from './scroll'; import { isNotInUni } from '../utils/utils'; -import { getSystemInfoSync } from '../utils/system'; +import { getWindowInfo } from '../utils/version'; // #ifdef H5 import getWindowOffset from '../utils/get-window-offset'; import { isVue3 } from '../vue3/vue'; @@ -46,7 +46,7 @@ export function getWindowWidth() { } // #endif - const { windowWidth, windowHeight, windowTop, windowBottom } = uni.getSystemInfoSync(); + const { windowWidth, windowHeight, windowTop, windowBottom } = getWindowInfo(); return { windowWidth, @@ -64,7 +64,7 @@ export function getStatusBarHeight() { } // #endif - const { statusBarHeight } = getSystemInfoSync(); + const { statusBarHeight } = getWindowInfo(); return statusBarHeight; } diff --git a/packages/press-ui/src/packages/common/functional-component/index.d.ts b/packages/press-ui/src/packages/common/functional-component/index.d.ts index 42782c05..3ce914c9 100644 --- a/packages/press-ui/src/packages/common/functional-component/index.d.ts +++ b/packages/press-ui/src/packages/common/functional-component/index.d.ts @@ -1,4 +1,4 @@ -export declare function selectComponent(context: any, selector: string): any; +export declare function selectComponent(context: any, selector: string | Function): any; export declare function showFunctionalComponent(options: { context?: any; selector: string; diff --git a/packages/press-ui/src/packages/common/functional-component/index.js b/packages/press-ui/src/packages/common/functional-component/index.js index 96e4fed0..efc46773 100644 --- a/packages/press-ui/src/packages/common/functional-component/index.js +++ b/packages/press-ui/src/packages/common/functional-component/index.js @@ -35,6 +35,10 @@ function traverseChildren(context, key, target) { export function selectComponent(context, selector) { if (!selector || !context) return; + if (typeof selector === 'function') { + return selector(context); + } + let attribute = selector; if (attribute.match(/^[^\w]/)) { attribute = attribute.slice(1); diff --git a/packages/press-ui/src/packages/common/utils/system.js b/packages/press-ui/src/packages/common/utils/system.js index 6ac69718..9b8fac22 100644 --- a/packages/press-ui/src/packages/common/utils/system.js +++ b/packages/press-ui/src/packages/common/utils/system.js @@ -1,23 +1,7 @@ import { canIUseGroupSetData } from './version'; import { isNotInUni } from './utils'; export { nextTick } from '../vue3/adapter'; - -let systemInfo = {}; - -export function getSystemInfoSync() { - try { - if (!Object.keys(systemInfo).length - && typeof uni !== 'undefined' - && typeof uni?.getSystemInfoSync === 'function' - ) { - systemInfo = uni.getSystemInfoSync(); - } - } catch (err) { - console.log('[getSystemInfoSync] err', err); - } - - return systemInfo; -} +export { getSystemInfoSync } from './version'; export function requestAnimationFrame(cb) { diff --git a/packages/press-ui/src/packages/common/utils/version.d.ts b/packages/press-ui/src/packages/common/utils/version.d.ts index d4a93c9d..b1b9fb73 100644 --- a/packages/press-ui/src/packages/common/utils/version.d.ts +++ b/packages/press-ui/src/packages/common/utils/version.d.ts @@ -1,6 +1,12 @@ export declare function canIUseModel(): boolean; export declare function canIUseFormFieldButton(): boolean; export declare function canIUseAnimate(): boolean; + export declare function canIUseGroupSetData(): boolean; export declare function canIUseCanvas2d(): boolean; + export declare function canIUseGetUserProfile(): boolean; + +export declare function getSystemInfoSync(): Record; +export declare function getAppBaseInfo(): Record; +export declare function getWindowInfo(): Record; diff --git a/packages/press-ui/src/packages/common/utils/version.js b/packages/press-ui/src/packages/common/utils/version.js index a15da943..56680df4 100644 --- a/packages/press-ui/src/packages/common/utils/version.js +++ b/packages/press-ui/src/packages/common/utils/version.js @@ -1,49 +1,120 @@ -import { getSystemInfoSync } from './system'; +let systemInfo = {}; +let appBaseInfo = {}; +let windowInfo = {}; + +export function getSystemInfoSync() { + try { + if (!Object.keys(systemInfo).length + && typeof uni !== 'undefined' + && typeof uni?.getSystemInfoSync === 'function' + ) { + systemInfo = uni.getSystemInfoSync(); + } + } catch (err) { + console.log('[getSystemInfoSync] err', err); + } + + return systemInfo; +} + + +export function getAppBaseInfo() { + try { + if (!Object.keys(appBaseInfo).length + && typeof uni !== 'undefined' + ) { + if (typeof uni.getAppBaseInfo === 'function') { + appBaseInfo = uni.getAppBaseInfo(); + } else if (typeof uni.getSystemInfoSync === 'function') { + appBaseInfo = uni.getSystemInfoSync(); + } + } + } catch (err) { + console.log('[getAppBaseInfo] err', err); + } + + return appBaseInfo; +} + + +export function getWindowInfo() { + try { + if (!Object.keys(windowInfo).length + && typeof uni !== 'undefined' + ) { + if (typeof uni.getWindowInfo === 'function') { + windowInfo = uni.getWindowInfo(); + } else if (typeof uni.getSystemInfoSync === 'function') { + windowInfo = uni.getSystemInfoSync(); + } + } + } catch (err) { + console.log('[getAppBaseInfo] err', err); + } + + return windowInfo; +} + function compareVersion(v1 = '', v2 = '') { const v1List = v1.split('.'); const v2List = v2.split('.'); const len = Math.max(v1List.length, v2List.length); + while (v1List.length < len) { v1List.push('0'); } + while (v2List.length < len) { v2List.push('0'); } + for (let i = 0; i < len; i++) { const num1 = parseInt(v1List[i], 10); const num2 = parseInt(v2List[i], 10); if (num1 > num2) { return 1; } + if (num1 < num2) { return -1; } } return 0; } + + function gte(version) { - const system = getSystemInfoSync(); + const system = getAppBaseInfo(); return compareVersion(system.SDKVersion, version) >= 0; } + + export function canIUseModel() { return gte('2.9.3'); } + + export function canIUseFormFieldButton() { return gte('2.10.3'); } + + export function canIUseAnimate() { return gte('2.9.0'); } + + export function canIUseGroupSetData() { return gte('2.4.0'); } -// export function canIUseNextTick() { -// return wx.canIUse('nextTick'); -// } + + export function canIUseCanvas2d() { return gte('2.9.0'); } + + export function canIUseGetUserProfile() { let result = false; diff --git a/packages/press-ui/src/packages/package.json b/packages/press-ui/src/packages/package.json index 2aa6cb08..4e56a6c6 100644 --- a/packages/press-ui/src/packages/package.json +++ b/packages/press-ui/src/packages/package.json @@ -1,6 +1,6 @@ { "name": "press-ui", - "version": "2.2.7", + "version": "2.2.11", "description": "简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目", "main": "index.js", "repository": { diff --git a/packages/press-ui/src/packages/press-area/press-area.vue b/packages/press-ui/src/packages/press-area/press-area.vue index 4a9fa1aa..331f63e0 100644 --- a/packages/press-ui/src/packages/press-area/press-area.vue +++ b/packages/press-ui/src/packages/press-area/press-area.vue @@ -131,7 +131,6 @@ export default { getPicker() { if (this.picker == null) { this.picker = this.$refs.pressPicker; - // this.picker = this.selectComponent('.press-area__picker'); } return this.picker; }, diff --git a/packages/press-ui/src/packages/press-circle/press-circle.vue b/packages/press-ui/src/packages/press-circle/press-circle.vue index 230ace1b..cfecdf79 100644 --- a/packages/press-ui/src/packages/press-circle/press-circle.vue +++ b/packages/press-ui/src/packages/press-circle/press-circle.vue @@ -48,9 +48,8 @@