From d3db99e1915943412b6acd0372405325e64486a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=A0=E4=BA=86=E8=91=B1=E8=8A=B1=E7=9A=84=E8=9B=8B?= =?UTF-8?q?=E7=82=92=E9=A5=AD?= <2878709960@qq.com> Date: Mon, 3 Mar 2025 17:43:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E5=AE=9E=E4=BD=93HTML=E7=B1=BB=E5=9E=8B=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/html-view/html-view.scss | 7 ++ src/components/html-view/html-view.tsx | 86 +++++++++++++++++++++++++ src/components/index.ts | 2 + template/@macro/view/default-view.hbs | 4 ++ 4 files changed, 99 insertions(+) create mode 100644 src/components/html-view/html-view.scss create mode 100644 src/components/html-view/html-view.tsx diff --git a/src/components/html-view/html-view.scss b/src/components/html-view/html-view.scss new file mode 100644 index 0000000..3589fde --- /dev/null +++ b/src/components/html-view/html-view.scss @@ -0,0 +1,7 @@ +@include b(view-dehtmlview) { + > iframe { + width: 100%; + height: 100%; + border: 0; + } +} diff --git a/src/components/html-view/html-view.tsx b/src/components/html-view/html-view.tsx new file mode 100644 index 0000000..bfa3697 --- /dev/null +++ b/src/components/html-view/html-view.tsx @@ -0,0 +1,86 @@ +import { + getErrorViewProvider, + IModal, + ViewController, +} from '@ibiz-template/runtime'; +import { IAppPortalView } from '@ibiz/model-core'; +import { + defineComponent, + PropType, + computed, + resolveComponent, + h, + onBeforeMount, + ref, +} from 'vue'; +import { useNamespace, useViewController } from '../../use'; +import './html-view.scss'; + +export const IBizHtmlView = defineComponent({ + name: 'IBizHtmlView', + props: { + context: Object as PropType, + params: { type: Object as PropType, default: () => ({}) }, + modelData: { type: Object as PropType, required: true }, + modal: { type: Object as PropType }, + state: { type: Object as PropType }, + }, + setup() { + const ns = useNamespace('view'); + const c = useViewController((...args) => new ViewController(...args)); + // 视图部件模型在viewlayoutPanel里面。 + const controls = c.model.viewLayoutPanel?.controls || c.model.controls; + const { viewType, sysCss, codeName } = c.model; + const typeClass = viewType!.toLowerCase(); + const sysCssName = sysCss?.cssName; + const viewClassNames = [ + ns.b(), + true && ns.b(typeClass), + true && ns.m(codeName), + true && sysCssName, + ]; + const isLoading = ref(false); + + const url = computed(() => { + if (c.model) { + const { htmlUrl } = c.model as IData; + if (htmlUrl) { + return htmlUrl; + } + } + return ''; + }); + + onBeforeMount(() => { + if (url.value) { + isLoading.value = true; + } + }); + + const onLoad = () => { + isLoading.value = false; + }; + + return { c, ns, controls, viewClassNames, url, isLoading, onLoad }; + }, + render() { + if (this.url) { + return ( +
+ +
+ ); + } + + let Content = null; + const provider = getErrorViewProvider('404'); + if (provider) { + if (typeof provider.component === 'string') { + Content = h(resolveComponent(provider.component) as string); + } + Content = h(provider.component); + } + + return
{Content}
; + }, +}); diff --git a/src/components/index.ts b/src/components/index.ts index ef01f0a..a974554 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,6 +1,7 @@ import { App } from 'vue'; import { IBizViewShell } from './view-shell/view-shell'; import { IBizSpecialView } from './special-view/special-view'; +import { IBizHtmlView } from './html-view/html-view' export { IBizViewShell }; @@ -8,5 +9,6 @@ export default { install(v: App): void { v.component(IBizViewShell.name, IBizViewShell); v.component(IBizSpecialView.name, IBizSpecialView); + v.component(IBizHtmlView.name, IBizHtmlView); }, }; diff --git a/template/@macro/view/default-view.hbs b/template/@macro/view/default-view.hbs index 568c737..de88614 100644 --- a/template/@macro/view/default-view.hbs +++ b/template/@macro/view/default-view.hbs @@ -7,6 +7,8 @@ {{else if (in page.viewType "APPDATAUPLOADVIEW")}} + {{else if (in page.viewType "DEHTMLVIEW")}} + {{else }} {{/if}} @@ -23,6 +25,8 @@ {{else if (in page.viewType "APPDATAUPLOADVIEW")}} + {{else if (in page.viewType "DEHTMLVIEW")}} + {{else }} {{/if}} -- Gitee