diff --git a/src/Admin/ThingsGateway.Photino.Blazor/Photino/PhotinoBlazorAppBuilder.cs b/src/Admin/ThingsGateway.Photino.Blazor/Photino/PhotinoBlazorAppBuilder.cs index f12228531..e930bd0ce 100644 --- a/src/Admin/ThingsGateway.Photino.Blazor/Photino/PhotinoBlazorAppBuilder.cs +++ b/src/Admin/ThingsGateway.Photino.Blazor/Photino/PhotinoBlazorAppBuilder.cs @@ -51,7 +51,7 @@ namespace Photino.Blazor app.Initialize(sp, RootComponents); return app; } - public PhotinoBlazorApp Build(IServiceProvider serviceProvider = null) + public PhotinoBlazorApp Build(IServiceProvider serviceProvider) { // register root components with DI container // Services.AddSingleton(RootComponents); diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a4723e82c..730d7610d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,9 +1,9 @@ - 10.9.40 - 10.9.40 - 10.9.40 + 10.9.41 + 10.9.41 + 10.9.41 2.9.18 10.9.18 8.0.18 diff --git a/src/Plugin/ThingsGateway.Debug.Photino/Program.cs b/src/Plugin/ThingsGateway.Debug.Photino/Program.cs index 68b88052f..a563478be 100644 --- a/src/Plugin/ThingsGateway.Debug.Photino/Program.cs +++ b/src/Plugin/ThingsGateway.Debug.Photino/Program.cs @@ -77,7 +77,7 @@ internal sealed class Program hybridApp.MainWindow.SetUseOsDefaultLocation(false); hybridApp.MainWindow.SetUseOsDefaultSize(false); hybridApp.MainWindow.SetSize(new System.Drawing.Size(1920, 1080)); - hybridApp.MainWindow.SetTitle("ThingsGateway.Hybrid"); + hybridApp.MainWindow.SetTitle("ThingsGateway.Debug.Photino"); hybridApp.MainWindow.SetIconFile("favicon.ico"); diff --git a/src/Plugin/ThingsGateway.Foundation.Test/ThingsGateway.Foundation.Test.csproj b/src/Plugin/ThingsGateway.Foundation.Test/ThingsGateway.Foundation.Test.csproj index 891be50fb..85d3a3f9f 100644 --- a/src/Plugin/ThingsGateway.Foundation.Test/ThingsGateway.Foundation.Test.csproj +++ b/src/Plugin/ThingsGateway.Foundation.Test/ThingsGateway.Foundation.Test.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/ThingsGateway.Photino/Program.cs b/src/ThingsGateway.Photino/Program.cs index 3451d1308..5f1b7b571 100644 --- a/src/ThingsGateway.Photino/Program.cs +++ b/src/ThingsGateway.Photino/Program.cs @@ -103,12 +103,12 @@ internal sealed class Program var hybridApp = builder.Build(app.Services); hybridApp.MainWindow.ContextMenuEnabled = false; - hybridApp.MainWindow.DevToolsEnabled = true; + hybridApp.MainWindow.DevToolsEnabled = false; hybridApp.MainWindow.GrantBrowserPermissions = true; hybridApp.MainWindow.SetUseOsDefaultLocation(false); hybridApp.MainWindow.SetUseOsDefaultSize(false); hybridApp.MainWindow.SetSize(new System.Drawing.Size(1920, 1080)); - hybridApp.MainWindow.SetTitle("ThingsGateway.Hybrid"); + hybridApp.MainWindow.SetTitle("ThingsGateway.Photino"); hybridApp.MainWindow.SetIconFile("favicon.ico"); AppDomain.CurrentDomain.UnhandledException += (sender, error) => diff --git a/src/ThingsGateway.Photino/wwwroot/index.html b/src/ThingsGateway.Photino/wwwroot/index.html index 97cd54728..e3fcb24fd 100644 --- a/src/ThingsGateway.Photino/wwwroot/index.html +++ b/src/ThingsGateway.Photino/wwwroot/index.html @@ -4,7 +4,7 @@ - ThingsGateway.Hybrid + ThingsGateway.Photino diff --git a/src/ThingsGateway.RemoteWebApp/Program.cs b/src/ThingsGateway.RemoteWebApp/Program.cs new file mode 100644 index 000000000..aa2eccba8 --- /dev/null +++ b/src/ThingsGateway.RemoteWebApp/Program.cs @@ -0,0 +1,61 @@ +//------------------------------------------------------------------------------ +// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充 +// 此代码版权(除特别声明外的代码)归作者本人Diego所有 +// 源代码使用协议遵循本仓库的开源协议及附加协议 +// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway +// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway +// 使用文档:https://thingsgateway.cn/ +// QQ群:605534569 +//------------------------------------------------------------------------------ + +using Photino.NET; + +using System.Text; +using System.Xml; + +namespace ThingsGateway.Server; + +internal sealed class Program +{ + [STAThread] + private static void Main(string[] args) + { + //当前工作目录设为程序集的基目录 + System.IO.Directory.SetCurrentDirectory(AppContext.BaseDirectory); + // 增加中文编码支持 + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + + var doc = new XmlDocument(); + doc.Load("appsettings.xml"); + + string? url = doc.SelectSingleNode("/settings/urls")?.InnerText; + string? title = doc.SelectSingleNode("/settings/windowTitle")?.InnerText; + + var window = new PhotinoWindow(); + + window.Load(url); // 👈 直接加载远程地址 + + window.ContextMenuEnabled = false; + window.DevToolsEnabled = false; + window.GrantBrowserPermissions = true; + window.SetUseOsDefaultLocation(false); + window.SetUseOsDefaultSize(false); + window.SetSize(new System.Drawing.Size(1920, 1080)); + window.SetTitle(title); + window.SetIconFile("favicon.ico"); + + AppDomain.CurrentDomain.UnhandledException += (sender, error) => + { + }; + + window.WindowClosing += (sender, e) => + { + + return false; + }; + window.WaitForClose(); + Thread.Sleep(2000); + } + + +} diff --git a/src/ThingsGateway.RemoteWebApp/ThingsGateway.RemoteWebApp.csproj b/src/ThingsGateway.RemoteWebApp/ThingsGateway.RemoteWebApp.csproj new file mode 100644 index 000000000..2c23ccf34 --- /dev/null +++ b/src/ThingsGateway.RemoteWebApp/ThingsGateway.RemoteWebApp.csproj @@ -0,0 +1,57 @@ + + + + + + + + + + + + Always + + + + + + Always + + + + + + + + net8.0;net9.0; + $(TargetFramework) + WinExe + false + zh-Hans;en-US + true + favicon.ico + + false + + true + none + false + false + + + 1 + + + + + + + + + + diff --git a/src/ThingsGateway.RemoteWebApp/appsettings.xml b/src/ThingsGateway.RemoteWebApp/appsettings.xml new file mode 100644 index 000000000..cfc9cc402 --- /dev/null +++ b/src/ThingsGateway.RemoteWebApp/appsettings.xml @@ -0,0 +1,5 @@ + + + http://localhost:5000 + ThingsGateway.RemoteWebApp + diff --git a/src/ThingsGateway.RemoteWebApp/favicon.ico b/src/ThingsGateway.RemoteWebApp/favicon.ico new file mode 100644 index 000000000..d5a4939b2 Binary files /dev/null and b/src/ThingsGateway.RemoteWebApp/favicon.ico differ diff --git a/src/ThingsGateway.Server/Layout/BlazorApp.razor b/src/ThingsGateway.Server/Layout/BlazorApp.razor index 562ca75ac..7ae86c33c 100644 --- a/src/ThingsGateway.Server/Layout/BlazorApp.razor +++ b/src/ThingsGateway.Server/Layout/BlazorApp.razor @@ -21,14 +21,36 @@ ThingsGateway - + + @{ + #if !NET8_0 + } + + + + + + + + + + @{ + #else + } + + + + @{ + #endif + } + @* *@ - + @@ -40,47 +62,13 @@ - - + + - + diff --git a/src/ThingsGateway.Server/Layout/_Imports.razor b/src/ThingsGateway.Server/Layout/_Imports.razor new file mode 100644 index 000000000..ebdeac9f9 --- /dev/null +++ b/src/ThingsGateway.Server/Layout/_Imports.razor @@ -0,0 +1,10 @@ + +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop + +@using System.Net.Http +@using System.Net.Http.Json diff --git a/src/ThingsGateway.Server/wwwroot/pwa-install.js b/src/ThingsGateway.Server/wwwroot/pwa-install.js new file mode 100644 index 000000000..787ee3383 --- /dev/null +++ b/src/ThingsGateway.Server/wwwroot/pwa-install.js @@ -0,0 +1,34 @@ +let installPromptTriggered = false; + +function getCookie(name) { + const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); + return match ? match[2] : null; +} + +function hasShownInstallPrompt() { + return getCookie("tgPWAInstallPromptShown") === "true"; +} + +function markInstallPromptShown() { + document.cookie = "tgPWAInstallPromptShown=true; max-age=31536000; path=/"; +} + +window.addEventListener('beforeinstallprompt', (e) => { + e.preventDefault(); + + if (!hasShownInstallPrompt() && !installPromptTriggered) { + installPromptTriggered = true; + setTimeout(() => { + e.prompt() + .then(() => e.userChoice) + .then(choiceResult => { + markInstallPromptShown(); + }) + .catch(err => { + // 可选错误处理 + }); + }, 2000); // 延迟 2 秒提示 + } else { + // console.log("已提示过安装,不再弹出"); + } +});