提交 54c54ee4 编写于 作者: Cano1997's avatar Cano1997

update: html视图添加loading

上级 b770bdac
......@@ -23,10 +23,16 @@ export const HtmlView = defineComponent({
const url = ref('');
const loaded = ref(false);
// initd防止重复初始化
const initd = ref(false);
// 是否初始化完成
const isComplete = ref(false);
const loading = ref(false);
const getTicket = (params: IData) => {
loaded.value = true;
loading.value = true;
ibiz.net
.post('/sygw/ticket', params)
.then(res => {
......@@ -44,15 +50,20 @@ export const HtmlView = defineComponent({
ibiz.notification.error({
title: error.message || error.response.data.resultDesc,
});
})
.finally(() => {
isComplete.value = true;
loading.value = false;
});
};
watch(
() => c,
() => {
if (!c.model || loaded.value) {
if (!c.model || initd.value) {
return;
}
initd.value = true;
if (c.model.htmlUrl) {
url.value = StringUtil.fill(c.model.htmlUrl, c.context, c.params);
}
......@@ -65,6 +76,8 @@ export const HtmlView = defineComponent({
)?.value;
if (srfenableaccess === 'true') {
getTicket({ targetclientid });
} else {
isComplete.value = true;
}
},
{
......@@ -78,9 +91,16 @@ export const HtmlView = defineComponent({
c.endViewLoading();
};
return { c, ns, url, onLoad };
return { c, ns, url, isComplete, loading, onLoad };
},
render() {
if (!this.isComplete) {
return (
<div class={[this.ns.b()]}>
{this.loading ? <i-spin size='large' fix></i-spin> : null}
</div>
);
}
if (this.url) {
return (
<view-base class={this.ns.b()} controller={this.c}>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册