Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzj-java
uni-app
提交
6b462945
U
uni-app
项目概览
wzj-java
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b462945
编写于
9月 14, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(h5): add effectScope
上级
7eafee5c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
47 deletion
+44
-47
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+23
-23
packages/uni-h5/src/service/api/ui/popup/showToast.ts
packages/uni-h5/src/service/api/ui/popup/showToast.ts
+21
-24
未找到文件。
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
6b462945
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, createBlock, renderList, onDeactivated, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, createBlock, renderList, onDeactivated, createApp, Transition,
effectScope,
withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { isString, extend, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize, isArray, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { I18N_JSON_DELIMITERS, once, passive, initCustomDataset, invokeArrayFns, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, ON_ERROR, callOptions, ON_LAUNCH, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, UniLifecycleHooks, NAVBAR_HEIGHT, parseQuery, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { initVueI18n, isI18nStr, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
...
...
@@ -7219,9 +7219,9 @@ function text(Quill) {
}
];
const result = {};
text2.forEach(({ name, scope }) => {
text2.forEach(({ name, scope
: scope2
}) => {
result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), {
scope
scope
: scope2
});
});
return result;
...
...
@@ -17706,7 +17706,7 @@ var modal = /* @__PURE__ */ defineComponent({
}
});
let showModalState;
const onHidePopupOnce$
2
= /* @__PURE__ */ once(() => {
const onHidePopupOnce$
1
= /* @__PURE__ */ once(() => {
UniServiceJSBridge.on("onHidePopup", () => showModalState.visible = false);
});
let currentShowModalResolve;
...
...
@@ -17717,7 +17717,7 @@ function onModalClose(type) {
});
}
const showModal = /* @__PURE__ */ defineAsyncApi(API_SHOW_MODAL, (args, { resolve }) => {
onHidePopupOnce$
2
();
onHidePopupOnce$
1
();
currentShowModalResolve = resolve;
if (!showModalState) {
showModalState = reactive(args);
...
...
@@ -17823,27 +17823,29 @@ function useToastIcon(props2) {
let showToastState;
let showType = "";
let timeoutId;
const
onHidePopupOnce$1 = /* @__PURE__ */ once(() => {
UniServiceJSBridge.on("onHidePopup", () => hidePopup("onHidePopup"));
});
const watchVisibleOnce = /* @__PURE__ */ once((
) => {
watch([() => showToastState.visible, () => showToastState.duration], ([visible, duration]) =>
{
if (visible) {
timeoutId && clearTimeout(timeoutId);
if (showType === "onShowLoading")
return;
timeoutId = setTimeout(() => {
hidePopup("onHideToast"
);
}
, duration);
} else {
timeoutId && clearTimeout(timeoutId);
}
const
scope = effectScope();
function watchVisible() {
scope.run(() => {
watch([() => showToastState.visible, () => showToastState.duration], ([visible, duration]
) => {
if (visible)
{
timeoutId && clearTimeout(timeoutId);
if (showType === "onShowLoading")
return;
timeoutId = setTimeout(() => {
hidePopup("onHideToast");
}, duration
);
}
else {
timeoutId && clearTimeout(timeoutId);
}
}
);
});
}
);
}
function createToast(args) {
if (!showToastState) {
showToastState = reactive(extend(args, { visible: false }));
nextTick(() => {
watchVisible();
UniServiceJSBridge.on("onHidePopup", () => hidePopup("onHidePopup"));
createRootApp(Toast, showToastState, () => {
}).mount(ensureRoot("u-a-t"));
});
...
...
@@ -17853,8 +17855,6 @@ function createToast(args) {
setTimeout(() => {
showToastState.visible = true;
}, 10);
watchVisibleOnce();
onHidePopupOnce$1();
}
const showToast = /* @__PURE__ */ defineAsyncApi(API_SHOW_TOAST, (args, { resolve, reject }) => {
createToast(args);
...
...
packages/uni-h5/src/service/api/ui/popup/showToast.ts
浏览文件 @
6b462945
//#region Functions
import
{
reactive
,
nextTick
,
watch
}
from
'
vue
'
import
{
reactive
,
nextTick
,
watch
,
effectScope
}
from
'
vue
'
import
{
extend
}
from
'
@vue/shared
'
import
{
defineAsyncApi
,
...
...
@@ -24,38 +24,39 @@ import type {
API_TYPE_HIDE_LOADING
,
API_TYPE_SHOW_TOAST
,
}
from
'
@dcloudio/uni-api
'
import
{
once
}
from
'
@dcloudio/uni-shared
'
//#endregion
let
showToastState
:
ToastProps
let
showType
:
'
onShowToast
'
|
'
onShowLoading
'
|
''
=
''
let
timeoutId
:
number
const
onHidePopupOnce
=
/*#__PURE__*/
once
(()
=>
{
UniServiceJSBridge
.
on
(
'
onHidePopup
'
,
()
=>
hidePopup
(
'
onHidePopup
'
))
})
const
watchVisibleOnce
=
/*#__PURE__*/
once
(()
=>
{
watch
(
[()
=>
showToastState
.
visible
,
()
=>
showToastState
.
duration
],
([
visible
,
duration
])
=>
{
if
(
visible
)
{
timeoutId
&&
clearTimeout
(
timeoutId
)
if
(
showType
===
'
onShowLoading
'
)
return
timeoutId
=
setTimeout
(()
=>
{
hidePopup
(
'
onHideToast
'
)
},
duration
)
}
else
{
timeoutId
&&
clearTimeout
(
timeoutId
)
const
scope
=
effectScope
()
function
watchVisible
()
{
scope
.
run
(()
=>
{
watch
(
[()
=>
showToastState
.
visible
,
()
=>
showToastState
.
duration
],
([
visible
,
duration
])
=>
{
if
(
visible
)
{
timeoutId
&&
clearTimeout
(
timeoutId
)
if
(
showType
===
'
onShowLoading
'
)
return
timeoutId
=
setTimeout
(()
=>
{
hidePopup
(
'
onHideToast
'
)
},
duration
)
}
else
{
timeoutId
&&
clearTimeout
(
timeoutId
)
}
}
}
)
}
)
)
}
)
}
function
createToast
(
args
:
ToastProps
)
{
if
(
!
showToastState
)
{
showToastState
=
reactive
(
extend
(
args
,
{
visible
:
false
}))
// 异步执行,避免干扰 getCurrentInstance
nextTick
(()
=>
{
watchVisible
()
UniServiceJSBridge
.
on
(
'
onHidePopup
'
,
()
=>
hidePopup
(
'
onHidePopup
'
))
createRootApp
(
Toast
,
showToastState
,
()
=>
{}).
mount
(
ensureRoot
(
'
u-a-t
'
))
})
}
else
{
...
...
@@ -66,10 +67,6 @@ function createToast(args: ToastProps) {
// 延迟一下 show 可解决窗口打开前调用 showToast 在 onHidePopup 之后触发
showToastState
.
visible
=
true
},
10
)
watchVisibleOnce
()
onHidePopupOnce
()
}
export
const
showToast
=
defineAsyncApi
<
API_TYPE_SHOW_TOAST
>
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录