From cf1fb97f4dacfab52899aa6827a3e2f2011fe6d4 Mon Sep 17 00:00:00 2001 From: hongyang03 Date: Wed, 16 Mar 2022 19:55:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20page=E4=B8=8B=E6=8B=89=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh-CN/components/page.md | 10 +++++++++- src/renderers/Page.tsx | 13 +++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/zh-CN/components/page.md b/docs/zh-CN/components/page.md index b5c992270..5de67a4ab 100755 --- a/docs/zh-CN/components/page.md +++ b/docs/zh-CN/components/page.md @@ -273,4 +273,12 @@ Page 默认将页面分为几个区域,分别是**内容区(`body`)**、** | interval | `number` | `3000` | 刷新时间(最小 1000) | | silentPolling | `boolean` | `false` | 配置刷新时是否显示加载动画 | | stopAutoRefreshWhen | [表达式](../../docs/concepts/expression) | `""` | 通过表达式来配置停止刷新的条件 | -| pullRefresh | `object` | `{disabled: true}` | 下拉刷新配置 | +| pullRefresh | `object` | `{disabled: true}` | 下拉刷新配置(仅用于移动端) | + +## 事件表 +| 事件名称 | 事件参数 | 说明 | +| ----------- | ------ | ------------------------------------- | +| pullRefresh | | 配置下拉刷新后下拉释放后触发(仅用于移动端) | + +## 动作表 +无 \ No newline at end of file diff --git a/src/renderers/Page.tsx b/src/renderers/Page.tsx index cde230413..e76b7d099 100644 --- a/src/renderers/Page.tsx +++ b/src/renderers/Page.tsx @@ -12,7 +12,7 @@ import { FunctionPropertyNames } from '../types'; import {filter, evalExpression} from '../utils/tpl'; -import {isVisible, autobind, bulkBindFunctions} from '../utils/helper'; +import {isVisible, autobind, bulkBindFunctions, createObject} from '../utils/helper'; import {ScopedContext, IScopedContext} from '../Scoped'; import Alert from '../components/Alert2'; import {isApiOutdated, isEffectiveApi} from '../utils/api'; @@ -617,10 +617,19 @@ export default class Page extends React.Component { } @autobind - handleRefresh() { + async handleRefresh() { + const {dispatchEvent, data} = this.props; + const rendererEvent = await dispatchEvent('pullRefresh', createObject(data)); + if (rendererEvent?.prevented) { + return; + } this.reload(); } + doAction(action: Action, data: object, throwErrors: boolean = false) { + return this.handleAction(undefined, action, data); + } + handleChange( value: any, name: string,