From 3cf9e8bfb20fa3bb2e891d0e8bb97652356023a8 Mon Sep 17 00:00:00 2001 From: RedPig97 <1978141412@qq.com> Date: Tue, 7 May 2024 21:06:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Especial-view?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E5=A3=B3=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/index.ts | 2 + src/components/special-view/special-view.tsx | 57 ++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/components/special-view/special-view.tsx diff --git a/src/components/index.ts b/src/components/index.ts index 58caa6a..ef01f0a 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,10 +1,12 @@ import { App } from 'vue'; import { IBizViewShell } from './view-shell/view-shell'; +import { IBizSpecialView } from './special-view/special-view'; export { IBizViewShell }; export default { install(v: App): void { v.component(IBizViewShell.name, IBizViewShell); + v.component(IBizSpecialView.name, IBizSpecialView); }, }; diff --git a/src/components/special-view/special-view.tsx b/src/components/special-view/special-view.tsx new file mode 100644 index 0000000..6faec6d --- /dev/null +++ b/src/components/special-view/special-view.tsx @@ -0,0 +1,57 @@ +/* eslint-disable no-param-reassign */ +/* eslint-disable vue/no-mutating-props */ +import { IViewProvider, getViewProvider } from '@ibiz-template/runtime'; +import { defineComponent, h, PropType, ref, resolveComponent } from 'vue'; +import { IAppView } from '@ibiz/model-core'; +import { useNamespace } from '@ibiz-template/vue3-util'; + +export const IBizSpecialView = defineComponent({ + name: 'IBizSpecialView', + props: { + context: { type: Object as PropType, required: true }, + params: { type: Object as PropType }, + modelData: { type: Object as PropType }, + viewId: { type: String }, + }, + setup(props) { + const ns = useNamespace('view-shell'); + const isComplete = ref(false); + const errMsg = ref(''); + const provider = ref(); + // 初始化方法 + const init = async (): Promise => { + try { + provider.value = await getViewProvider(props.modelData!); + } catch (error) { + ibiz.log.error(error); + errMsg.value = (error as IData).message; + } finally { + isComplete.value = true; + } + }; + + init(); + + return { ns, isComplete, errMsg, provider }; + }, + render() { + if (this.isComplete && this.provider) { + return h( + resolveComponent(this.provider.component) as string, + { + context: this.$props.context, + params: this.$props.params, + modelData: this.$props.modelData, + ...this.$attrs, + provider: this.provider, + }, + this.$slots, + ); + } + return ( +
+ {this.isComplete ? this.errMsg : null} +
+ ); + }, +}); -- Gitee From 6f5d46ff8f96bddade6ffb6a080e19d66072dbdf Mon Sep 17 00:00:00 2001 From: RedPig97 <1978141412@qq.com> Date: Tue, 7 May 2024 21:07:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E8=A7=86=E5=9B=BE=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E3=80=81=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=85=A5=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E7=BB=98=E5=88=B6special-view=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E5=A3=B3=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/@macro/view/default-view.hbs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/template/@macro/view/default-view.hbs b/template/@macro/view/default-view.hbs index ca02487..568c737 100644 --- a/template/@macro/view/default-view.hbs +++ b/template/@macro/view/default-view.hbs @@ -1,10 +1,12 @@