Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
062fc810
U
uni-app
项目概览
Velpro187
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
062fc810
编写于
7月 28, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(App): onWindowResize, offWindowResize
上级
25cea862
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
60 addition
and
39 deletion
+60
-39
packages/uni-api/src/index.ts
packages/uni-api/src/index.ts
+1
-1
packages/uni-api/src/service/ui/window.ts
packages/uni-api/src/service/ui/window.ts
+27
-0
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+19
-0
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+2
-0
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+8
-8
packages/uni-h5/src/service/api/index.ts
packages/uni-h5/src/service/api/index.ts
+2
-0
packages/uni-h5/src/service/api/ui/window.ts
packages/uni-h5/src/service/api/ui/window.ts
+1
-30
未找到文件。
packages/uni-api/src/index.ts
浏览文件 @
062fc810
...
...
@@ -13,6 +13,7 @@ export * from './service/ui/createMediaQueryObserver'
export
*
from
'
./service/ui/createSelectorQuery
'
export
*
from
'
./service/ui/createAnimation
'
export
*
from
'
./service/ui/tabBar
'
export
*
from
'
./service/ui/window
'
export
*
from
'
./service/keyboard/getSelectedTextRange
'
...
...
@@ -84,7 +85,6 @@ export * from './protocols/ui/showToast'
export
*
from
'
./protocols/ui/startPullDownRefresh
'
export
*
from
'
./protocols/ui/stopPullDownRefresh
'
export
*
from
'
./protocols/ui/tabBar
'
export
*
from
'
./protocols/ui/window
'
export
*
from
'
./protocols/plugin/getProvider
'
export
*
from
'
./protocols/plugin/oauth
'
...
...
packages/uni-api/src/service/ui/window.ts
0 → 100644
浏览文件 @
062fc810
import
{
API_ON_WINDOW_RESIZE
,
API_TYPE_ON_WINDOW_RESIZE
,
API_OFF_WINDOW_RESIZE
,
API_TYPE_OFF_WINDOW_RESIZE
,
}
from
'
../../protocols/ui/window
'
import
{
defineOnApi
,
defineOffApi
}
from
'
../../helpers/api
'
/**
* 监听窗口大小变化
*/
export
const
onWindowResize
=
defineOnApi
<
API_TYPE_ON_WINDOW_RESIZE
>
(
API_ON_WINDOW_RESIZE
,
()
=>
{
// 生命周期包括onResize,框架直接监听resize
// window.addEventListener('resize', onResize)
}
)
/**
* 取消监听窗口大小变化
*/
export
const
offWindowResize
=
defineOffApi
<
API_TYPE_OFF_WINDOW_RESIZE
>
(
API_OFF_WINDOW_RESIZE
,
()
=>
{
// window.removeEventListener('resize', onResize)
}
)
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
062fc810
...
...
@@ -3937,6 +3937,23 @@ var serviceContext = (function (vue) {
// noop
});
const API_ON_WINDOW_RESIZE = 'onWindowResize';
const API_OFF_WINDOW_RESIZE = 'offWindowResize';
/**
* 监听窗口大小变化
*/
const onWindowResize = defineOnApi(API_ON_WINDOW_RESIZE, () => {
// 生命周期包括onResize,框架直接监听resize
// window.addEventListener('resize', onResize)
});
/**
* 取消监听窗口大小变化
*/
const offWindowResize = defineOffApi(API_OFF_WINDOW_RESIZE, () => {
// window.removeEventListener('resize', onResize)
});
const API_GET_SELECTED_TEXT_RANGE = 'getSelectedTextRange';
const getSelectedTextRange = defineAsyncApi(API_GET_SELECTED_TEXT_RANGE, (_, { resolve, reject }) => {
...
...
@@ -10715,6 +10732,8 @@ var serviceContext = (function (vue) {
createVideoContext: createVideoContext,
createMapContext: createMapContext,
createAnimation: createAnimation,
onWindowResize: onWindowResize,
offWindowResize: offWindowResize,
onTabBarMidButtonTap: onTabBarMidButtonTap,
createCanvasContext: createCanvasContext,
canvasGetImageData: canvasGetImageData,
...
...
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
062fc810
...
...
@@ -77,6 +77,8 @@ export {
createVideoContext
,
createMapContext
,
createAnimation
,
onWindowResize
,
offWindowResize
,
onTabBarMidButtonTap
,
createCanvasContext
,
canvasGetImageData
,
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
062fc810
...
...
@@ -4403,6 +4403,12 @@ const createAnimation$1 = /* @__PURE__ */ defineSyncApi(API_CREATE_ANIMATION, (o
const API_ON_TAB_BAR_MID_BUTTON_TAP = "onTabBarMidButtonTap";
const onTabBarMidButtonTap = /* @__PURE__ */ defineOnApi(API_ON_TAB_BAR_MID_BUTTON_TAP, () => {
});
const API_ON_WINDOW_RESIZE = "onWindowResize";
const API_OFF_WINDOW_RESIZE = "offWindowResize";
const onWindowResize = /* @__PURE__ */ defineOnApi(API_ON_WINDOW_RESIZE, () => {
});
const offWindowResize = /* @__PURE__ */ defineOffApi(API_OFF_WINDOW_RESIZE, () => {
});
const API_GET_SELECTED_TEXT_RANGE = "getSelectedTextRange";
const getSelectedTextRange$1 = /* @__PURE__ */ defineAsyncApi(API_GET_SELECTED_TEXT_RANGE, (_, { resolve, reject }) => {
UniServiceJSBridge.invokeViewMethod("getSelectedTextRange", {}, getCurrentPageId(), (res) => {
...
...
@@ -5263,8 +5269,6 @@ const SetTabBarBadgeOptions = {
}
}, IndexOptions.formatArgs)
};
const API_ON_WINDOW_RESIZE = "onWindowResize";
const API_OFF_WINDOW_RESIZE = "offWindowResize";
const initIntersectionObserverPolyfill = function() {
if (typeof window !== "object") {
return;
...
...
@@ -18990,10 +18994,6 @@ function createRightWindowTsx(rightWindow, layoutState, windowState) {
}, 8, ["data-show", "style"]), [[vShow, layoutState.showRightWindow || layoutState.apiShowRightWindow]]);
}
}
const onWindowResize = /* @__PURE__ */ defineOnApi(API_ON_WINDOW_RESIZE, () => {
});
const offWindowResize = /* @__PURE__ */ defineOffApi(API_OFF_WINDOW_RESIZE, () => {
});
const showTopWindow = /* @__PURE__ */ defineAsyncApi("showTopWindow", (_, { resolve, reject }) => {
const state2 = getLayoutState();
if (!state2) {
...
...
@@ -19133,6 +19133,8 @@ var api = {
createVideoContext,
createMapContext,
createAnimation: createAnimation$1,
onWindowResize,
offWindowResize,
onTabBarMidButtonTap,
createCanvasContext,
canvasGetImageData,
...
...
@@ -19225,8 +19227,6 @@ var api = {
showTabBarRedDot,
removeTabBarBadge,
setTabBarBadge,
onWindowResize,
offWindowResize,
showTopWindow,
hideTopWindow,
showLeftWindow,
...
...
packages/uni-h5/src/service/api/index.ts
浏览文件 @
062fc810
...
...
@@ -77,6 +77,8 @@ export {
createVideoContext
,
createMapContext
,
createAnimation
,
onWindowResize
,
offWindowResize
,
onTabBarMidButtonTap
,
createCanvasContext
,
canvasGetImageData
,
...
...
packages/uni-h5/src/service/api/ui/window.ts
浏览文件 @
062fc810
import
{
extend
}
from
'
@vue/shared
'
import
{
nextTick
}
from
'
vue
'
import
{
API_ON_WINDOW_RESIZE
,
API_TYPE_ON_WINDOW_RESIZE
,
API_OFF_WINDOW_RESIZE
,
API_TYPE_OFF_WINDOW_RESIZE
,
defineOnApi
,
defineOffApi
,
defineAsyncApi
,
defineSyncApi
,
}
from
'
@dcloudio/uni-api
'
import
{
defineAsyncApi
,
defineSyncApi
}
from
'
@dcloudio/uni-api
'
import
{
getLayoutState
}
from
'
../../../framework/components/layout
'
/**
* 监听窗口大小变化
*/
export
const
onWindowResize
=
defineOnApi
<
API_TYPE_ON_WINDOW_RESIZE
>
(
API_ON_WINDOW_RESIZE
,
()
=>
{
// 生命周期包括onResize,框架直接监听resize
// window.addEventListener('resize', onResize)
}
)
/**
* 取消监听窗口大小变化
*/
export
const
offWindowResize
=
defineOffApi
<
API_TYPE_OFF_WINDOW_RESIZE
>
(
API_OFF_WINDOW_RESIZE
,
()
=>
{
// window.removeEventListener('resize', onResize)
}
)
export
const
showTopWindow
=
<
typeof
uni
.
showTopWindow
>
(
defineAsyncApi
(
'
showTopWindow
'
,
(
_
,
{
resolve
,
reject
})
=>
{
const
state
=
getLayoutState
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录