Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzj-java
uni-app
提交
b546fbc2
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,发现更多精彩内容 >>
提交
b546fbc2
编写于
9月 07, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(H5): showToast
上级
05a72fda
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
25 deletion
+38
-25
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+1
-1
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+17
-12
packages/uni-h5/src/service/api/ui/popup/showToast.ts
packages/uni-h5/src/service/api/ui/popup/showToast.ts
+20
-12
未找到文件。
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
b546fbc2
...
...
@@ -451,7 +451,7 @@ const ServiceJSBridge = /* @__PURE__ */ shared.extend(initBridge("view"), {
invokeViewMethodKeepAlive
});
function
initI18n
()
{
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
);
const
localeKeys
=
Object
.
keys
(
__uniConfig
.
locales
||
{}
);
if
(
localeKeys
.
length
)
{
const
i18n2
=
useI18n
();
localeKeys
.
forEach
((
locale
)
=>
i18n2
.
add
(
locale
,
__uniConfig
.
locales
[
locale
]));
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
b546fbc2
...
...
@@ -1288,7 +1288,7 @@ const ServiceJSBridge = /* @__PURE__ */ extend(initBridge("view"), {
invokeViewMethodKeepAlive
});
function initI18n() {
const localeKeys = Object.keys(__uniConfig.locales);
const localeKeys = Object.keys(__uniConfig.locales
|| {}
);
if (localeKeys.length) {
const i18n2 = useI18n();
localeKeys.forEach((locale) => i18n2.add(locale, __uniConfig.locales[locale]));
...
...
@@ -17883,9 +17883,23 @@ let timeoutId;
const onHidePopupOnce$1 = /* @__PURE__ */ once(() => {
UniServiceJSBridge.on("onHidePopup", () => hidePopup("onHidePopup"));
});
const watchVisibleOnce = /* @__PURE__ */ once(() => {
watch([() => showToastState.visible, () => showToastState.duration], ([visible, duration]) => {
if (showType === "onShowLoading")
return;
if (visible) {
timeoutId && clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
hidePopup("onHideToast");
}, duration);
} else {
timeoutId && clearTimeout(timeoutId);
}
});
});
function createToast(args) {
if (!showToastState) {
showToastState = reactive(
args
);
showToastState = reactive(
extend(args, { visible: false })
);
nextTick(() => {
createRootApp(Toast, showToastState, () => {
}).mount(ensureRoot("u-a-t"));
...
...
@@ -17896,16 +17910,7 @@ function createToast(args) {
setTimeout(() => {
showToastState.visible = true;
}, 10);
watchEffect(() => {
if (showToastState.visible) {
timeoutId && clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
hidePopup("onHideToast");
}, showToastState.duration);
} else {
timeoutId && clearTimeout(timeoutId);
}
});
watchVisibleOnce();
onHidePopupOnce$1();
}
const showToast = /* @__PURE__ */ defineAsyncApi(API_SHOW_TOAST, (args, { resolve, reject }) => {
...
...
packages/uni-h5/src/service/api/ui/popup/showToast.ts
浏览文件 @
b546fbc2
//#region Functions
import
{
reactive
,
nextTick
,
watch
Effect
}
from
'
vue
'
import
{
reactive
,
nextTick
,
watch
}
from
'
vue
'
import
{
extend
}
from
'
@vue/shared
'
import
{
defineAsyncApi
,
...
...
@@ -34,9 +34,26 @@ const onHidePopupOnce = /*#__PURE__*/ once(() => {
UniServiceJSBridge
.
on
(
'
onHidePopup
'
,
()
=>
hidePopup
(
'
onHidePopup
'
))
})
const
watchVisibleOnce
=
/*#__PURE__*/
once
(()
=>
{
watch
(
[()
=>
showToastState
.
visible
,
()
=>
showToastState
.
duration
],
([
visible
,
duration
])
=>
{
if
(
showType
===
'
onShowLoading
'
)
return
if
(
visible
)
{
timeoutId
&&
clearTimeout
(
timeoutId
)
timeoutId
=
setTimeout
(()
=>
{
hidePopup
(
'
onHideToast
'
)
},
duration
)
}
else
{
timeoutId
&&
clearTimeout
(
timeoutId
)
}
}
)
})
function
createToast
(
args
:
ToastProps
)
{
if
(
!
showToastState
)
{
showToastState
=
reactive
(
args
)
showToastState
=
reactive
(
extend
(
args
,
{
visible
:
false
})
)
// 异步执行,避免干扰 getCurrentInstance
nextTick
(()
=>
{
createRootApp
(
Toast
,
showToastState
,
()
=>
{}).
mount
(
ensureRoot
(
'
u-a-t
'
))
...
...
@@ -50,16 +67,7 @@ function createToast(args: ToastProps) {
showToastState
.
visible
=
true
},
10
)
watchEffect
(()
=>
{
if
(
showToastState
.
visible
)
{
timeoutId
&&
clearTimeout
(
timeoutId
)
timeoutId
=
setTimeout
(()
=>
{
hidePopup
(
'
onHideToast
'
)
},
showToastState
.
duration
)
}
else
{
timeoutId
&&
clearTimeout
(
timeoutId
)
}
})
watchVisibleOnce
()
onHidePopupOnce
()
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录