Skip to content

Commit

Permalink
feat: add getVMInVue3
Browse files Browse the repository at this point in the history
  • Loading branch information
novlan1 committed Dec 11, 2024
1 parent 0436963 commit 5ac9f20
Show file tree
Hide file tree
Showing 35 changed files with 292 additions and 68 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

<!-- 复制到 docs 下的时候,去掉“查看文档”和“查看示例” -->
<div align="center">
<a href="https://github.com/novlan1/press-ui">
<img width="150" src="https://mike-1255355338.cos.ap-guangzhou.myqcloud.com/press%2Fimg%2Fpress-ui-avatar-transparent.png" style="margin-bottom: -25px;">
Expand All @@ -19,7 +20,7 @@
</p>
</div>

[查看文档](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. 介绍

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "press-ui",
"version": "2.2.7",
"version": "2.2.11",
"description": "简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目",
"private": true,
"repository": {
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/press-ui-vue3-pure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 介绍

Expand Down
49 changes: 49 additions & 0 deletions packages/press-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion packages/press-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
4 changes: 2 additions & 2 deletions packages/press-ui/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

<!-- 复制到 docs 下的时候,去掉“查看文档”和“查看示例” -->
<div align="center">
<a href="https://github.com/novlan1/press-ui">
<img width="150" src="https://mike-1255355338.cos.ap-guangzhou.myqcloud.com/press%2Fimg%2Fpress-ui-avatar-transparent.png" style="margin-bottom: -25px;">
Expand All @@ -19,7 +20,6 @@
</p>
</div>


### 1. 介绍

`Press UI`是一套易用、灵活,基于`uni-app`的跨端组件库。
Expand Down Expand Up @@ -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小程序、支付宝小程序、安卓项目。
Expand Down
49 changes: 49 additions & 0 deletions packages/press-ui/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
8 changes: 8 additions & 0 deletions packages/press-ui/docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ export default {
</press-popup>
```

另外,对于以下组件,在 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 项目
Expand Down
2 changes: 1 addition & 1 deletion packages/press-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "press-ui",
"version": "2.2.7",
"version": "2.2.11",
"description": "简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目",
"private": true,
"repository": {
Expand Down
1 change: 1 addition & 0 deletions packages/press-ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="google" content="notranslate" />
<meta name="description" content="易用、灵活、基于 uni-app 的跨端组件库">
<link rel="icon"
href="https://mike-1255355338.cos.ap-guangzhou.myqcloud.com/article/2023/8/own_mike_0d0107312bfd164de4.ico">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export declare function setData(dialog: any, data: any, func?: string): any;
export declare function vmSet(dialog: any, ...args: Array<any>): void;
export declare function getVMInVue3(context: any): any;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
6 changes: 3 additions & 3 deletions packages/press-ui/src/packages/common/dom/rect.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -46,7 +46,7 @@ export function getWindowWidth() {
}
// #endif

const { windowWidth, windowHeight, windowTop, windowBottom } = uni.getSystemInfoSync();
const { windowWidth, windowHeight, windowTop, windowBottom } = getWindowInfo();

return {
windowWidth,
Expand All @@ -64,7 +64,7 @@ export function getStatusBarHeight() {
}
// #endif

const { statusBarHeight } = getSystemInfoSync();
const { statusBarHeight } = getWindowInfo();
return statusBarHeight;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 1 addition & 17 deletions packages/press-ui/src/packages/common/utils/system.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions packages/press-ui/src/packages/common/utils/version.d.ts
Original file line number Diff line number Diff line change
@@ -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<string, any>;
export declare function getAppBaseInfo(): Record<string, any>;
export declare function getWindowInfo(): Record<string, any>;
Loading

0 comments on commit 5ac9f20

Please sign in to comment.