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

update: html视图添加loading

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