Explorar o código

pda-client 基础功能完成

lizw %!s(int64=3) %!d(string=hai) anos
pai
achega
a1e14571c9
Modificáronse 3 ficheiros con 110 adicións e 90 borrados
  1. 108 76
      src/Scope.ts
  2. 2 0
      src/message.ts
  3. 0 14
      src/wotu-ui.css

+ 108 - 76
src/Scope.ts

@@ -84,6 +84,15 @@ export class Scope {
         this.onLoad()
     }
 
+    showMainWindow() {
+        const handle = (window as any).mainWindow?._handle
+        if (handle) {
+            handle.setStyle({'z-index': 1})
+            Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
+            Ext.Viewport.setActiveItem(handle)
+        }
+    }
+
     /**
      * 渲染模块到全屏
      * allowBack 是否允许后退(退出)
@@ -95,85 +104,108 @@ export class Scope {
         vjsonOption: {},
         dataOption: {}
     }) {
-        _.defaults(option, {
-            allowBack: true,
-            vjsonOption: {},
-            dataOption: {}
-        })
-        const {
-            allowBack,
-            vjsonOption,
-            dataOption
-        } = option
-
         const that = this
-        this._vjsonOption = vjsonOption;
-        this._dataOption = dataOption;
-        const vmodel = _.defaultsDeep({
-            data: {}
-        }, that.model, dataOption)
-
-        //this.viewModel = new Ext.app.ViewModel(vmodel);
-        //this.viewModel.yvanScope = this
-
-        let config = _.defaultsDeep({
-                // viewModel: this.viewModel,
-                viewModel: vmodel,
-                yvanScope: this,
-                referenceHolder: true,
-            },
-            vjsonOption,
-            that.vjson,
-            {
-                xtype: 'panel',
-                // showAnimation: 'slide',
-                // hideAnimation: 'slideOut',
+        let has = false;
+        (Ext.Viewport.getItems().items as []).forEach((item, idx) => {
+            if (!has && item === that._handle) {
+                has = true
             }
-        )
-
-        if (allowBack) {
-            config = _.defaultsDeep({
-                iconCls: 'x-fa fa-angle-left',
-                cls: 'navbar',
-                tools: [
-                    {iconCls: 'x-fa fa-home'},
-                ],
-            }, config)
-        }
-        that._handle = Ext.create(config)
-
-        this.viewModel = that._handle.getViewModel()
-        this.viewModel.yvanScope = this
-        that._handle.on({
-            renderedchange(sender, item, rendered, opts) {
-                // 记录句柄
-                if (rendered) {
-                    that._handle = this
-                    window['cp'] = that
-
-                    // 调用onLoad回调
-                    try {
-                        that._onLoad()
-                    } catch (e) {
-                        console.error('errorAt onLoad', e)
-                    }
-
-                    const $back = $(sender.el.dom)
-                        .find('.navbar>.x-panelheader')
-                        .find('.x-body-el>.fa-angle-left')
-                    $back.on('click', () => {
-                        Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
-                        that._handle.close()
-                    })
-                }
-            },
-            destroy() {
-                // 卸载
-                window['cp'] = Ext.Viewport.items.getAt(Ext.Viewport.items.items.length - 2).getViewModel().yvanScope
-                that._onDestroy()
-            },
         })
-        Ext.Viewport.add(that._handle)
+        if(!has) {
+            _.defaults(option, {
+                allowBack: true,
+                vjsonOption: {},
+                dataOption: {}
+            })
+            const {
+                allowBack,
+                vjsonOption,
+                dataOption
+            } = option
+
+
+            this._vjsonOption = vjsonOption;
+            this._dataOption = dataOption;
+            const vmodel = _.defaultsDeep({
+                data: {}
+            }, that.model, dataOption)
+
+            //this.viewModel = new Ext.app.ViewModel(vmodel);
+            //this.viewModel.yvanScope = this
+
+            let config = _.defaultsDeep({
+                    // viewModel: this.viewModel,
+                    viewModel: vmodel,
+                    yvanScope: this,
+                    referenceHolder: true,
+                },
+                vjsonOption,
+                that.vjson,
+                {
+                    xtype: 'panel',
+                    // showAnimation: 'slide',
+                    // hideAnimation: 'slideOut',
+                }
+            )
+
+            if (allowBack) {
+                config = _.defaultsDeep({
+                    iconCls: 'x-fa fa-angle-left',
+                    cls: 'navbar',
+                    tools: [
+                        {
+                            iconCls: 'x-fa fa-home',
+                            handler: function () {
+                                that.showMainWindow()
+                            },
+                        },
+                    ],
+                }, config)
+            }
+            that._handle = Ext.create(config)
+
+            this.viewModel = that._handle.getViewModel()
+            this.viewModel.yvanScope = this
+            that._handle.on({
+                renderedchange(sender, item, rendered, opts) {
+                    // 记录句柄
+                    if (rendered) {
+                        that._handle = this
+                        window['cp'] = that
+
+                        // 调用onLoad回调
+                        try {
+                            that._onLoad()
+                        } catch (e) {
+                            console.error('errorAt onLoad', e)
+                        }
+                        const $back = $(sender.el.dom)
+                            .find('.navbar>.x-panelheader')
+                            .find('.x-body-el>.fa-angle-left')
+                        $back.on('click', () => {
+                            that._handle.setStyle({'z-index': 0})
+                            Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
+                            Ext.Viewport.remove(that._handle)
+                            that._handle.close()
+                        })
+                    }
+                },
+                destroy() {
+                    // 卸载
+                    window['cp'] = Ext.Viewport.items?.getAt(Ext.Viewport.items.items.length - 2)?.getViewModel()?.yvanScope
+                    that._onDestroy()
+                },
+            })
+            Ext.Viewport.add(that._handle)
+        } else {
+            window['cp'] = that
+            // 调用onLoad回调
+            try {
+                that._onLoad()
+            } catch (e) {
+                console.error('errorAt onLoad', e)
+            }
+        }
         that._handle.setStyle({'z-index': 1})
         let actived = false;
         (Ext.Viewport.getItems().items as []).forEach((item, idx) => {

+ 2 - 0
src/message.ts

@@ -16,6 +16,8 @@ export function prompt(message, multiLine = false, value = '') {
             fn(okcancel, value) {
                 if (okcancel === 'ok') {
                     resolve(value)
+                } else {
+                    reject()
                 }
             }
         });

+ 0 - 14
src/wotu-ui.css

@@ -1,17 +1,3 @@
-.menus-item {
-    width: calc(25% - 8px);
-    margin: 4px;
-    padding: 8px 0;
-}
-
-.menus-item:hover {
-    background-color: rgb(238, 238, 238);
-}
-
-.menus-item.x-selected {
-    background-color: #d1d1d1;
-}
-
 /*== layer提示框==*/
 .yvan-msg {
     min-width: 100px;