提交 aaecb088 编写于 作者: zhujiamin's avatar zhujiamin

update:更新模态动态引入

上级 9eca2e48
...@@ -99,20 +99,22 @@ export class AppModal { ...@@ -99,20 +99,22 @@ export class AppModal {
* @returns {Subject<any>} * @returns {Subject<any>}
* @memberof AppModal * @memberof AppModal
*/ */
private createVueExample(view: { name: string, title: string, fileDir:string, width?: number, height?: number, isfullscreen?: boolean, customClass?: string }, context: any = {}, viewparams: any = {}, navdatas: Array<any> = [], uuid: string): Subject<any> { private createVueExample(view: { name: string, title: string, fileDir:string, width?: number, height?: number, isfullscreen?: boolean, customClass?: string }, context: any = {}, viewparam: any = {}, navdatas: Array<any> = [], uuid: string): Subject<any> {
const self: any = this; const self: any = this;
if (!self.store || !self.i18n) { if (!self.store || !self.i18n) {
self.initBasicData(); self.initBasicData();
} }
try { try {
let subject: null | Subject<any> = new Subject<any>(); let subject: null | Subject<any> = new Subject<any>();
let props = { view: view, viewdata: context, viewparams: viewparams, navdatas: navdatas, uuid: uuid, subject: subject }; let props = { view: view, context: context, viewparam: viewparam, navdatas: navdatas, uuid: uuid, subject: subject };
let dir = view.fileDir.replace(/@/, '../../') let dir = view.fileDir.replace(/@page/, '');
//Vite 支持使用特殊的 import.meta.glob 函数从文件系统导入多个模块
const modules = import.meta.glob('../../page/*/*/index.ts');
const AsyncComp = defineAsyncComponent({ const AsyncComp = defineAsyncComponent({
// 工厂函数 // 工厂函数
loader: () => import(dir), loader: modules['../../page' + dir + '/index.ts'],
// 加载异步组件时要使用的组件 // 加载异步组件时要使用的组件
loadingComponent: IbizLoading, loadingComponent: IbizLoading,
// 在显示 loadingComponent 之前的延迟 | 默认值:200(单位 ms) // 在显示 loadingComponent 之前的延迟 | 默认值:200(单位 ms)
delay: 0, delay: 0,
}); });
...@@ -121,10 +123,10 @@ export class AppModal { ...@@ -121,10 +123,10 @@ export class AppModal {
const div = document.createElement('div'); const div = document.createElement('div');
document.body.appendChild(div); document.body.appendChild(div);
const app = createApp(component, const app = createApp(component,
{ {
close: () => { document.body.removeChild(div); app.unmount(); }, close: () => { document.body.removeChild(div); app.unmount(); },
...props ...props
} }
); );
app.component(view.name, AsyncComp); app.component(view.name, AsyncComp);
const vm = app.use(Antd).mount(div); const vm = app.use(Antd).mount(div);
......
...@@ -10,12 +10,12 @@ interface AppModalProps { ...@@ -10,12 +10,12 @@ interface AppModalProps {
/** /**
* @description 视图上下文参数 * @description 视图上下文参数
*/ */
viewdata?: any; context?: any;
/** /**
* @description 视图参数 * @description 视图参数
*/ */
viewparams?: any; viewparam?: any;
/** /**
* @description 导航数据 * @description 导航数据
...@@ -35,8 +35,8 @@ interface AppModalProps { ...@@ -35,8 +35,8 @@ interface AppModalProps {
const props = withDefaults(defineProps<AppModalProps>(), { const props = withDefaults(defineProps<AppModalProps>(), {
view:{}, view:{},
viewdata: {}, context: {},
viewparams: {}, viewparam: {},
navdatas: [], navdatas: [],
}); });
...@@ -222,9 +222,9 @@ const handleShowState = ($event: any) => { ...@@ -222,9 +222,9 @@ const handleShowState = ($event: any) => {
class="viewcontainer2" class="viewcontainer2"
:width="width" :width="width"
:height="height" :height="height"
:viewdata="JSON.stringify(viewdata)" :context="JSON.stringify(context)"
:viewparam="JSON.stringify(viewparams)" :viewparam="JSON.stringify(viewparam)"
:navdatas="navdatas" :navdatas="navdatas"
:viewDefaultUsage="false" :viewDefaultUsage="false"
:noViewCaption="true" :noViewCaption="true"
@viewdataschange="dataChange($event)" @viewdataschange="dataChange($event)"
...@@ -233,4 +233,4 @@ const handleShowState = ($event: any) => { ...@@ -233,4 +233,4 @@ const handleShowState = ($event: any) => {
:ref="viewname" :ref="viewname"
></component> ></component>
</a-modal> </a-modal>
</template> </template>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册