Browse Source

第二窗口相关优化

loki.wu 2 years ago
parent
commit
fe45004a25

+ 4 - 4
fis/App.axaml.cs

@@ -1,6 +1,7 @@
 using Avalonia;
 using Avalonia.Controls.ApplicationLifetimes;
 using Avalonia.Markup.Xaml;
+using fis.Log;
 using fis.Managers;
 using fis.Managers.Interfaces;
 using fis.Utilities;
@@ -22,6 +23,7 @@ namespace fis
             if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
             {
                 desktop.MainWindow = mainWindow;
+                ShellConfig.Instance.windowsNum = mainWindow.Screens.ScreenCount;
             }
 
             base.OnFrameworkInitializationCompleted();
@@ -35,12 +37,10 @@ namespace fis
             try
             {
                 var manager = AppManager.Get<ISecondaryScreenManager>();
-                await manager.ShowWindowByTypeAsync(WindowType.Measure, "http://" + ShellConfig.Instance.AppHost+ "/index.html?page=measure&platformHost="+ ShellConfig.Instance.MeasureApiHost, new System.Collections.Generic.Dictionary<string, string>(),false);
-   
-                await manager.ShowWindowByTypeAsync(WindowType.ReportEdit, "http://" + ShellConfig.Instance.AppHost+ "/index.html?page=report&platformHost=" + ShellConfig.Instance.ReportApiHost, new System.Collections.Generic.Dictionary<string, string>(),false);
+                await manager.ShowWindowByTypeAsync(WindowType.Measure, "http://" + ShellConfig.Instance.AppHost+ "/index.html?page=measure&platformHost="+ ShellConfig.Instance.LocalApiHost, new System.Collections.Generic.Dictionary<string, string>(),false);
             }
             catch (Exception ex) {
-                
+                Logger.WriteShellLog("App initSlaveWindowsAsync ex :" + ex.ToString());
             }
         }
     }

+ 31 - 19
fis/IPlatformService.cs

@@ -1,4 +1,5 @@
 using fis.Models.Vid;
+using System.Threading.Tasks;
 
 namespace fis
 {
@@ -23,27 +24,14 @@ namespace fis
 
         #endregion
 
-        #region System Configuration
-
-        /// <summary>
-        /// 加载主题
-        /// </summary>
-        /// <param name="name"></param>
-        /// <returns></returns>
-        bool LoadTheme(string name);
-
-        /// 保存配置
-        bool SaveConfig(string text);
-
-        /// 获取配置
-        string? GetConfig();
+        #region Business Interactions
 
         /// <summary>
-        /// 打开报告模板设计器
+        /// 打开图像测量
         /// </summary>
         /// <param name="name"></param>
         /// <returns></returns>
-        bool OpenImageMeasure(string token, string patientCode, string remedicalCode, string recordCode);
+        Task<bool> OpenImageMeasure(string token, string patientCode, string remedicalCode, string recordCode);
 
         /// <summary>
         /// 打开报告编辑页面
@@ -53,7 +41,7 @@ namespace fis
         /// <param name="reportCode"></param>
         /// <param name="recordCode"></param>
         /// <returns></returns>
-        bool OpenReportEdit(string token, string patientCode, string reportCode, string recordCode,string referralRecordCode);
+        bool OpenReportEdit(string token, string patientCode, string reportCode, string recordCode, string referralRecordCode);
 
         /// <summary>
         /// 打开报告预览
@@ -63,7 +51,7 @@ namespace fis
         /// <param name="reportCode"></param>
         /// <param name="recordCode"></param>
         /// <returns></returns>
-        bool OpenReportPreview(string token,  string reportCode, string recordCode);
+        bool OpenReportPreview(string token, string reportCode, string recordCode);
 
         /// <summary>
         /// 打开报告模板设计器
@@ -78,8 +66,32 @@ namespace fis
         /// <param name="name"></param>
         /// <param name="useObject"></param>
         /// <param name="templateJson"></param>
-        void SaveReportTemplate(string templateId,string name,string useObject,string templateJson);
+        void SaveReportTemplate(string templateId, string name, string useObject, string templateJson);
+
+        void CloseSlaveWindow();
+
+        #endregion
 
+        #region System Configuration
+
+        /// <summary>
+        /// 加载主题
+        /// </summary>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        bool LoadTheme(string name);
+
+        /// 保存配置
+        bool SaveConfig(string text);
+
+        /// 获取配置
+        string? GetConfig();
+
+        /// <summary>
+        /// 获取屏幕个数
+        /// </summary>
+        /// <returns></returns>
+        int GetWindowsNum();
         #endregion
 
         #region File Storage

+ 48 - 2
fis/Managers/BrowserManager.cs

@@ -1,6 +1,8 @@
 using fis.Mac;
+using fis.Utilities;
 using fis.Win;
 using System;
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using Xilium.CefGlue;
 using Xilium.CefGlue.Avalonia;
@@ -63,6 +65,12 @@ namespace fis.Managers
 
         private static FisBrowser? _slaveBrowser;
 
+        public const string NotificationName = "externalNotification";
+
+        public static AvaloniaCefBrowser? MeasureWindowBrowser { get; set; }
+
+        public static AvaloniaCefBrowser? ReportWindowBrowser { get; set; }
+
         /// <summary>
         /// 获取rpc通信的Service
         /// </summary>
@@ -152,8 +160,46 @@ namespace fis.Managers
             }
         }
 
-        public static AvaloniaCefBrowser? MeasureWindowBrowser { get; set; }
+        /// <summary>
+        /// 执行Js方法
+        /// </summary>
+        /// <param name="methodName"></param>
+        /// <param name="targetMethodName"></param>
+        /// <param name="arguments"></param>
+        public static void ExecuteJS(string methodName, TargetMethodName targetMethodName, List<string> arguments, bool isMainBrowser = true)
+        {
+            string callString = methodName + "(";
+            if (arguments != null)
+            {
+                string comma = ", ";
+                var argumentsStr = "";
+                int index = 0;
+                foreach (var e in arguments)
+                {
+                    if (index == arguments.Count - 1)
+                    {
+                        argumentsStr += e;
+                    }
+                    else
+                    {
+                        argumentsStr += e + "&";
+                    }
+                    index++;
+                }
+                var escaped = System.Web.HttpUtility.JavaScriptStringEncode(argumentsStr, true);
+                callString += (int)targetMethodName + comma + escaped + comma + "";
+            }
+            callString += ");";
+            if (isMainBrowser)
+            {
+                MainBrowser?.ExecuteJavaScript(callString, null, 0);
+            }
+            else 
+            {
+                SlaveBrowser?.ExecuteJavaScript(callString, null, 0);
+            }
+        }
+
 
-        public static AvaloniaCefBrowser? ReportWindowBrowser { get; set; }
     }
 }

+ 1 - 1
fis/Managers/FileExporterManager.cs

@@ -56,7 +56,7 @@ namespace fis.Managers
 
         private void NotifyTheProgress(double progress, ExportStatus exportStatus)
         {
-            var callString = PlatFormHelper.GetMethodStr("externalNotification", TargetMethodName.UpdateExportProgess, new List<string>() { 
+            var callString = PlatFormHelper.GetMethodStr(BrowserManager.NotificationName, TargetMethodName.UpdateExportProgess, new List<string>() { 
             progress.ToString(),
             ((int)exportStatus).ToString()
             });

+ 1 - 3
fis/Managers/Interfaces/ISecondaryScreenManager.cs

@@ -20,8 +20,6 @@ namespace fis.Managers.Interfaces
         /// </summary>
         /// <param name="windowType"></param>
         /// <returns></returns>
-        SlaveWindow? GetWindowByType(WindowType windowType);
-
-
+        SlaveWindow? GetSlaveWindow();
     }
 }

+ 21 - 33
fis/Managers/SecondaryScreenManager.cs

@@ -12,72 +12,60 @@ namespace fis.Managers
 {
     internal class SecondaryScreenManager: ISecondaryScreenManager
     {
-        Dictionary<WindowType, SlaveWindow> windows = new Dictionary<WindowType, SlaveWindow>();
+        private SlaveWindow? _window;
 
         public async Task ShowWindowByTypeAsync(WindowType windowType, string host, Dictionary<string, string> keyValuePairs,bool isShowWindow = true) 
         {
-            SlaveWindow window;
-            if (windows.Keys.Contains(windowType))
+            if (_window != null)
             {
-                window = windows[windowType];
-                await window.ChangeContentViewAsync(host, keyValuePairs, windowType);
+                await _window.ChangeContentViewAsync(host, keyValuePairs, windowType);
             }
             else 
             {
                 await Dispatcher.UIThread.InvokeAsync(() =>
                 {
-                    window = new SlaveWindow();
-                    window.init(host, keyValuePairs, windowType);
-                    if (window.Screens.ScreenCount > 1)
+                    _window = new SlaveWindow();
+                    _window.init(host, keyValuePairs, windowType);
+                    if (_window.Screens.ScreenCount > 1)
                     {
-                        var screen = window.Screens.All.FirstOrDefault(x => x.Primary == false);
+                        var screen = _window.Screens.All.FirstOrDefault(x => x.Primary == false);
                         if (screen != null)
                         {
-                            window.Position = new PixelPoint(screen.Bounds.X, screen.Bounds.Y);
+                            _window.Position = new PixelPoint(screen.Bounds.X, screen.Bounds.Y);
                         }
                     }
-                    window.Closed += Window_Closed;
-                    windows.Add(windowType, window);
+                    _window.Closed += Window_Closed;
                     if (!isShowWindow)
                     {
-                        window.WindowState = WindowState.Minimized;
-                        window.ShowInTaskbar = false;
-                        window.Show();
-                        window.Hide();
+                        _window.WindowState = WindowState.Minimized;
+                        _window.ShowInTaskbar = false;
+                        _window.Show();
+                        _window.Hide();
                     }
                     else
                     {
-                        window.Show();
+                        _window.Show();
                     }
                 });
             }
         }
 
-        public SlaveWindow? GetWindowByType(WindowType windowType) {
-            if (windows.ContainsKey(windowType))
-            {
-                return windows[windowType];
-            }
-            else {
-                return null;
-            }
+        public SlaveWindow? GetSlaveWindow() {
+            return _window;
         }
 
         private void Window_Closed(object? sender, EventArgs e)
         {
-            if (windows.Any(w => w.Value == sender)) {
-                var window = windows.FirstOrDefault(x=>x.Value == sender);
-                windows.Remove(window.Key);
-            }
+            
         }
 
         public void Dispose()
         {
-            foreach (var w in windows.Keys) {
-                windows[w].ForceClose = true;
-                windows[w].Close();
+            if (_window != null)
+            {
+                _window.ForceClose = true;
+                _window.Close();
             }
-            windows.Clear();
         }
     }
 }

+ 3 - 3
fis/Managers/Ultra3DManager.cs

@@ -97,7 +97,7 @@ namespace fis.Managers
                     height,
                     surfaceFiles
                 };
-                var callString = PlatFormHelper.GetMethodStr("externalNotification", TargetMethodName.SetSurface, args);               
+                var callString = PlatFormHelper.GetMethodStr(BrowserManager.NotificationName, TargetMethodName.SetSurface, args);               
                 BrowserManager.MeasureWindowBrowser?.ExecuteJavaScript(callString, null, 0);                
             }
             catch (Exception exception)
@@ -108,7 +108,7 @@ namespace fis.Managers
 
         private void MDFileReady(string key)
         {
-            var callString = PlatFormHelper.GetMethodStr("externalNotification", TargetMethodName.MdlFileLoaded, new List<string>() { key});
+            var callString = PlatFormHelper.GetMethodStr(BrowserManager.NotificationName, TargetMethodName.MdlFileLoaded, new List<string>() { key});
             BrowserManager.MeasureWindowBrowser?.ExecuteJavaScript(callString, null, 0);
         }
 
@@ -120,7 +120,7 @@ namespace fis.Managers
                 var args = new List<string>{
                     base64
                 };
-                var callString = PlatFormHelper.GetMethodStr("externalNotification", TargetMethodName.AdjustPlaneImage, args);
+                var callString = PlatFormHelper.GetMethodStr(BrowserManager.NotificationName, TargetMethodName.AdjustPlaneImage, args);
                 BrowserManager.MeasureWindowBrowser?.ExecuteJavaScript(callString, null, 0);
             }
             catch (Exception exception)

+ 33 - 41
fis/PlatformService.cs

@@ -4,6 +4,7 @@ using fis.Models.Vid;
 using fis.Utilities;
 using System;
 using System.Collections.Generic;
+using System.Threading.Tasks;
 
 namespace fis
 {
@@ -21,6 +22,8 @@ namespace fis
 
         public string? GetConfig() => AppManager.Get<IConfigManager>().GetConfigAsync().Result;
 
+        public int GetWindowsNum() => ShellConfig.Instance.windowsNum;
+
         public bool SaveText(string name, string text) => AppManager.Get<ITextFileManager>().SaveTextAsync(name, text).Result;
 
         public string? GetText(string name) => AppManager.Get<ITextFileManager>().GetTextAsync(name).Result;
@@ -31,6 +34,19 @@ namespace fis
 
         public bool AbortExportOperation() => AppManager.Get<IFileExporterManager>().AbortExportOperation();
 
+        /// <summary>
+        /// 关闭第二窗口
+        /// </summary>
+        public void CloseSlaveWindow() {
+            var manager = AppManager.Get<ISecondaryScreenManager>();
+            var window = manager.GetSlaveWindow();
+            if (window != null)
+            {
+                window.Close();
+                BrowserManager.ExecuteJS(BrowserManager.NotificationName, TargetMethodName.Logout,new List<string>());
+            }
+        }
+
         /// <summary>
         /// 打开测量
         /// </summary>
@@ -39,14 +55,15 @@ namespace fis
         /// <param name="index"></param>
         /// <param name="imageIndex"></param>
         /// <returns></returns>
-        public bool OpenImageMeasure(string token,string patientCode,string remedicalCode, string recordCode) {
+        public async Task<bool> OpenImageMeasure(string token, string patientCode, string remedicalCode, string recordCode)
+        {
             var dictionary = new Dictionary<string, string>();
             dictionary.Add("token", token);
             dictionary.Add("patientCode", patientCode);
             dictionary.Add("remedicalCode", remedicalCode);
             dictionary.Add("recordCode", recordCode);
             var manager = AppManager.Get<ISecondaryScreenManager>();
-            manager.ShowWindowByTypeAsync(WindowType.Measure,"http://" + ShellConfig.Instance.AppHost + "/#/measure/measure_home", dictionary).GetAwaiter().GetResult();
+            await manager.ShowWindowByTypeAsync(WindowType.Measure,"http://" + ShellConfig.Instance.AppHost + "/#/measure/measure_home", dictionary);
             return true;
         }
 
@@ -70,6 +87,13 @@ namespace fis
             return true;
         }
 
+        /// <summary>
+        /// 打开报告预览
+        /// </summary>
+        /// <param name="token"></param>
+        /// <param name="reportCode"></param>
+        /// <param name="recordCode"></param>
+        /// <returns></returns>
         public bool OpenReportPreview(string token, string reportCode, string recordCode)
         {
             var dictionary = new Dictionary<string, string>();
@@ -89,8 +113,11 @@ namespace fis
         {
             var manager = AppManager.Get<ISecondaryScreenManager>();
             var dictionary = new Dictionary<string, string>();
-            var parameterStr = "?id="+ templateId +"&name=" +name+"&type="+type+ "&category=0";
-            manager.ShowWindowByTypeAsync(WindowType.TemplateDesigner,"http://" + ShellConfig.Instance.DistHost + parameterStr, dictionary);
+            dictionary.Add("templateId", templateId);
+            dictionary.Add("templateName", name);
+            dictionary.Add("templateType", type);
+            dictionary.Add("token", token);
+            manager.ShowWindowByTypeAsync(WindowType.TemplateDesigner,"", dictionary);
             return true;
         }
 
@@ -104,7 +131,7 @@ namespace fis
         public void SaveReportTemplate(string templateId, string name, string useObject, string templateJson) 
         {
             var manager = AppManager.Get<ISecondaryScreenManager>();
-            var window =  manager.GetWindowByType(WindowType.Measure);
+            var window =  manager.GetSlaveWindow();
             List<String> args = new List<string>();
             args.Add(templateId);
             args.Add(name);
@@ -112,45 +139,10 @@ namespace fis
             args.Add(templateJson);
             if (window != null) 
             {
-                ExecuteJS("externalNotification", TargetMethodName.SaveReportTemplate, args);
-            }
-        }
-
-        /// <summary>
-        /// 执行Js方法
-        /// </summary>
-        /// <param name="methodName"></param>
-        /// <param name="targetMethodName"></param>
-        /// <param name="arguments"></param>
-        public void ExecuteJS(string methodName, TargetMethodName targetMethodName, List<string> arguments)
-        {
-            string callString = methodName + "(";
-            if (arguments != null)
-            {
-                string comma = ", ";
-                var argumentsStr = "";
-                int index = 0;
-                foreach (var e in arguments)
-                {
-                    if (index == arguments.Count - 1)
-                    {
-                        argumentsStr += e;
-                    }
-                    else
-                    {
-                        argumentsStr += e + "$";
-                    }
-                    index++;
-                }
-                var escaped = System.Web.HttpUtility.JavaScriptStringEncode(argumentsStr, true);
-                callString += (int)targetMethodName + comma + escaped + comma + "";
+                BrowserManager.ExecuteJS(BrowserManager.NotificationName, TargetMethodName.SaveReportTemplate, args);
             }
-            callString += ");";
-
-            BrowserManager.MainBrowser?.ExecuteJavaScript(callString, null, 0);
         }
 
-
         public LoadVidResult LoadVid(string url)
         {
             var result = new LoadVidResult();

+ 7 - 12
fis/ShellConfig.cs

@@ -8,33 +8,28 @@ namespace fis
     {
         public readonly static ShellConfig Instance = Load();
 
+        /// <summary>
+        /// 窗口数量
+        /// </summary>
+        public int windowsNum = 0;
+
         //Gets or sets the app host which is the web App's access url
         public string AppHost { get; set; } = "app.fis.plus";
 
         /// <summary>
-        /// ����ģ�������
+        /// 模板设计器
         /// </summary>
         public string DistHost { get; set; } = "2.flyinsono.com/report/#/reportTemplateDesigner";
         
         //Gets or sets the App resource path, which stores the web content and its resources.
         public string AppResourcePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App", "flyinsono");
 
-        //����ģ���������ַ
+        //模板设计器文件地址
         public string DistResourcePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App", "dist");
 
         //Gets or sets the api host for local call, usually provider platform apis.
         public string LocalApiHost { get; set; } = "platform.fis.plus";
 
-        /// <summary>
-        ///  Gets or sets the api host for local call, usually provider platform apis.
-        /// </summary>
-        public string MeasureApiHost { get; set; } = "platform2.fis.plus";
-
-        /// <summary>
-        /// Gets or sets the api host for local call, usually provider platform apis.
-        /// </summary>
-        public string ReportApiHost { get; set; } = "platform3.fis.plus";
-
         //Gets or sets the resource host for local application resources, eg. icons, images, audios and videos.
         public string LocalResourceHost { get; set; } = "resource.fis.plus";
 

+ 24 - 149
fis/SlaveWindow.axaml.cs

@@ -1,21 +1,20 @@
-using System;
-using System.IO;
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Markup.Xaml;
+using Avalonia.Threading;
 using fis.Mac;
+using fis.Managers;
+using fis.Utilities;
 using fis.Win;
-using Xilium.CefGlue.Avalonia;
+using System;
+using System.Collections.Generic;
 using System.Globalization;
+using System.IO;
 using System.Reflection;
-using System.Threading;
 using System.Runtime.InteropServices;
-using System.Collections.Generic;
-using Xilium.CefGlue.Common.Handlers;
-using fis.Utilities;
+using System.Threading;
 using System.Threading.Tasks;
-using Avalonia.Threading;
-using fis.Managers;
+using Xilium.CefGlue.Avalonia;
 
 namespace fis
 {
@@ -23,7 +22,7 @@ namespace fis
     {
         public static SynchronizationContext? MainThreadSyncContext;
         private TextBlock? _title;
-        private AvaloniaCefBrowser? _browser;
+        private AvaloniaCefBrowser _browser;
         private string _host;
         private WindowType _windowType;
 
@@ -37,8 +36,9 @@ namespace fis
             ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
             ExtendClientAreaTitleBarHeightHint = -1;
             MainThreadSyncContext = SynchronizationContext.Current;
+            _browser = BrowserManager.SlaveBrowser;
 #if DEBUG
-           this.AttachDevTools();
+            this.AttachDevTools();
 #endif
             Closing += SlaveWindow_Closing;
         }
@@ -63,9 +63,10 @@ namespace fis
         /// <param name="keyValuePairs"></param>
         internal async Task ChangeContentViewAsync(string host, Dictionary<string, string> keyValuePairs, WindowType windowType)
         {
+            TargetMethodName targetMethodName;
             if (windowType == WindowType.TemplateDesigner) {
-                _browser.Address = host;
-                return;
+                //_browser.Address = host;
+                //return;
             }
             _host = host;
             _parameters = keyValuePairs;
@@ -88,9 +89,10 @@ namespace fis
                 Show();
             });
             Thread.Sleep(600);
-     
-            TargetMethodName targetMethodName;
-            if (windowType == WindowType.Measure)
+            if (windowType == WindowType.TemplateDesigner) {
+                targetMethodName = TargetMethodName.OpenReportDesignerPage;
+            }
+            else if (windowType == WindowType.Measure)
             {
                 targetMethodName = TargetMethodName.OpenMeasurePage;
             }
@@ -103,55 +105,19 @@ namespace fis
                     targetMethodName = TargetMethodName.OpenReportEditPage;
                 }
             }
-            ExecuteJS("externalNotification", targetMethodName, arguments);
-          
+            BrowserManager.ExecuteJS(BrowserManager.NotificationName, targetMethodName, arguments, false);
         }
 
-        /// <summary>
-        /// 执行Js方法
-        /// </summary>
-        /// <param name="methodName"></param>
-        /// <param name="targetMethodName"></param>
-        /// <param name="arguments"></param>
-        /// ?page=measure&token=F680C7A0ADEF45D28D291DFD290000AC&patientCode=PatientInfoDO_20220725094305QTFMzU&index=0&imageIndex=0
-        private void ExecuteJS(string methodName, TargetMethodName targetMethodName, List<string> arguments)
-        {
-            string callString = methodName + "(";
-            if (arguments != null)
-            {
-                string comma = ", ";
-                var argumentsStr = "";
-                int index = 0;
-                foreach (var e in arguments)
-                {
-                    if (index == arguments.Count - 1)
-                    {
-                        argumentsStr += e;
-                    }
-                    else
-                    {
-                        argumentsStr += e + "&";
-                    }
-                    index++;
-                }
-                var escaped = System.Web.HttpUtility.JavaScriptStringEncode(argumentsStr, true);
-                callString += (int)targetMethodName + comma + escaped;
-            }
-            callString += ");";
-            _browser?.ExecuteJavaScript(callString, null, 0);
-        }
-
-
-
         private void SlaveWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
         {
             if (!ForceClose)
             {
                 e.Cancel = true;
-                WindowState = WindowState.Minimized;
-                //ShowInTaskbar = false;
-                ShowActivated = false;
-                Hide();
+                Dispatcher.UIThread.InvokeAsync(() =>
+                {
+                   ShowActivated = false;
+                   Hide();
+                });
                 GC.Collect();
             }
         }
@@ -160,7 +126,6 @@ namespace fis
         {
             AvaloniaXamlLoader.Load(this);
             var browserContainer = this.FindControl<Border>("BrowserBorder");
-
             IPlatformService platformService;
             if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
             {
@@ -179,47 +144,6 @@ namespace fis
             {
                 throw new NotSupportedException($"Platform {Environment.OSVersion.Platform} is not suppoorted.");
             }
-            if (_host.Contains(ShellConfig.Instance.DistHost))
-            {
-                var appHandler = new FileSystemHostHandler(ShellConfig.Instance.DistHost, ShellConfig.Instance.DistResourcePath);
-
-                var handler = new HostRequestHandler();
-                handler.RegisterHostHandler(appHandler);
-
-                _browser = new AvaloniaCefBrowser
-                {
-                    RequestHandler = handler
-                };
-            }
-            else
-            {
-                var appHandler = new FileSystemHostHandler(ShellConfig.Instance.AppHost, ShellConfig.Instance.AppResourcePath);
-                var localHost = "";
-                
-              
-                var resourceHandler = new FileSystemHostHandler(localHost, ShellConfig.Instance.LocalResourcePath);
-                var handler = new HostRequestHandler();
-                handler.RegisterHostHandler(resourceHandler);
-                if (_windowType == WindowType.Measure)
-                {
-                    localHost = ShellConfig.Instance.MeasureApiHost;
-                    var platformHandler = new JsonRpcHandler<IMeasureService>(localHost, new MeasureService());
-                    handler.RegisterHostHandler(platformHandler);
-                }
-                else
-                {
-                    localHost = ShellConfig.Instance.ReportApiHost;
-                    var platformHandler = new JsonRpcHandler<IReportService>(localHost, new ReportService());
-                    handler.RegisterHostHandler(platformHandler);
-                }
-             
-                handler.RegisterHostHandler(appHandler);
-                _browser = new AvaloniaCefBrowser
-                {
-                    RequestHandler = handler
-                };
-            }
-
             var parameter = "";
             var index = 0;
             foreach (var p in _parameters)
@@ -257,14 +181,6 @@ namespace fis
                 {
                     _title.Text = "FLYINSONO";
                 }
-            }
-            if (_title != null && _host.Contains(ShellConfig.Instance.DistHost))
-            {
-                var scriptObj = new FisBrowserScriptObject(_title, platformService);
-                _browser.RegisterJavascriptObject(scriptObj, "FisShellApi");
-            }
-            else if(_title != null)
-            {
                 var scriptObj = new FisBrowserScriptObject(_title, platformService);
                 _browser.RegisterJavascriptObject(scriptObj, "FisShellApi");
             }
@@ -274,7 +190,6 @@ namespace fis
             WindowState = WindowState.Maximized;
             MinWidth = 1366;
             MinHeight = 768;
-
             var assembly = Assembly.GetExecutingAssembly();
             Stream? resourceStream = null;
             if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -289,7 +204,6 @@ namespace fis
             {
                 Icon = new WindowIcon(resourceStream);
             }
-
             if (_windowType == WindowType.Measure)
             {
                 BrowserManager.MeasureWindowBrowser = _browser;
@@ -301,43 +215,4 @@ namespace fis
 
         }
     }
-    interface IMeasureService 
-    {
-    
-    }
-
-    interface IReportService
-    {
-
-    }
-
-    public class MeasureService: PlatformService, IPlatformService, IMeasureService
-    {
-        public override string GetPlatformName() => "Win-X86";
-
-        public override Microphone[] GetMicrophones()
-        {
-            return new Microphone[] { };
-        }
-
-        public override Speaker[] GetSpeakers()
-        {
-            return new Speaker[] { };
-        }
-    }
-
-    public class ReportService: PlatformService, IPlatformService, IReportService
-    {
-        public override string GetPlatformName() => "Win-X86";
-
-        public override Microphone[] GetMicrophones()
-        {
-            return new Microphone[] { };
-        }
-
-        public override Speaker[] GetSpeakers()
-        {
-            return new Speaker[] { };
-        }
-    }
 }

+ 6 - 43
fis/Utilities/FisBrowserScriptObject.cs

@@ -63,7 +63,7 @@ namespace fis.Utilities
             args.Add(name);
             args.Add(useObject);
             args.Add(templateJson);
-            ExecuteJS("externalNotification", TargetMethodName.SaveReportTemplate, args);
+            BrowserManager.ExecuteJS(BrowserManager.NotificationName, TargetMethodName.SaveReportTemplate, args);
         }
 
         /// <summary>
@@ -271,8 +271,7 @@ namespace fis.Utilities
             }
             else
             {
-                return JsonConvert.SerializeObject(new ClipPlaneData(null,
-        null, string.Empty, 0));
+                return JsonConvert.SerializeObject(new ClipPlaneData(null, null, string.Empty, 0));
             }
         }
 
@@ -318,43 +317,7 @@ namespace fis.Utilities
                 {
                     File.Delete(file.FullName);
                 }
-
-            }
-        }
-
-
-        /// <summary>
-        /// 执行Js方法
-        /// </summary>
-        /// <param name="methodName"></param>
-        /// <param name="targetMethodName"></param>
-        /// <param name="arguments"></param>
-        private void ExecuteJS(string methodName, TargetMethodName targetMethodName, List<string> arguments)
-        {
-            string callString = methodName + "(";
-            if (arguments != null)
-            {
-                string comma = ", ";
-                var argumentsStr = "";
-                int index = 0;
-                foreach (var e in arguments)
-                {
-                    if (index == arguments.Count - 1)
-                    {
-                        argumentsStr += e;
-                    }
-                    else
-                    {
-                        argumentsStr += e + "&";
-                    }
-                    index++;
-                }
-                var escaped = System.Web.HttpUtility.JavaScriptStringEncode(argumentsStr, true);
-                callString += (int)targetMethodName + comma + escaped;
             }
-            callString += ");";
-
-            BrowserManager.MainBrowser?.ExecuteJavaScript(callString, null, 0);
         }
 
         /// <summary>
@@ -372,12 +335,12 @@ namespace fis.Utilities
             }), this);
         }
 
-        public void CloseWindow(WindowType windowType)
+        public void CloseWindow()
         {
             var manager = AppManager.Get<ISecondaryScreenManager>();
              Dispatcher.UIThread.InvokeAsync(() =>
              {
-                 var slaveWindow = manager.GetWindowByType(windowType);
+                 var slaveWindow = manager.GetSlaveWindow();
                  slaveWindow?.Close();
 
              });
@@ -385,8 +348,8 @@ namespace fis.Utilities
 
         public void RefershReports() 
         {
-            CloseWindow(WindowType.ReportEdit);
-            ExecuteJS("externalNotification",TargetMethodName.RefershReports, new List<string>());
+            CloseWindow();
+            BrowserManager.ExecuteJS(BrowserManager.NotificationName, TargetMethodName.RefershReports, new List<string>());
         }
 
         public int Age { get; set; }

+ 3 - 0
fis/Utilities/TargetMethodName.cs

@@ -27,5 +27,8 @@
         #region
         UpdateExportProgess,
         #endregion
+
+        OpenReportDesignerPage,
+        Logout,
     }
 }