CrazyIter_Bin 2 năm trước cách đây
mục cha
commit
8853c2a2fe

+ 3 - 0
TEAMModelOS.FunctionV4/Program.cs

@@ -4,10 +4,13 @@ using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.DependencyInjection.Extensions;
 using Microsoft.Extensions.Hosting;
+using PuppeteerSharp;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.IO;
 using System.Linq;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
 using TEAMModelOS.Models;

+ 22 - 1
TEAMModelOS/Controllers/System/CoreController.cs

@@ -11,6 +11,7 @@ using System.IO;
 using System.Linq;
 using System.Net.Http;
 using System.Reflection;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Text.Json;
 using System.Text.RegularExpressions;
@@ -228,9 +229,22 @@ namespace TEAMModelOS.Controllers
                 IpPort = "127.0.0.1";
             }
             string ip = IpPort.Split(":")[0];
+            string os = "";
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+            {//Linux
+                os = "Linux";
+            }
+            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+            {//Windows
+                os = "Windows";
+            }
+            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+            {//OSX
+                os = "OSX";
+            } 
             string region = await _searcher.SearchIpAsync(ip);
 
-            return Ok(new { version, description, nowtime, region, ip });
+            return Ok(new { os, version, description, nowtime, region, ip });
         }
         /// <summary>
         /// 网页截图参数
@@ -258,6 +272,13 @@ namespace TEAMModelOS.Controllers
                 {
                     Directory.CreateDirectory(dir);
                 }
+                var bfOptions = new BrowserFetcherOptions();
+                if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+                {
+                    bfOptions.Path = Path.GetTempPath();
+                }
+                var bf = new BrowserFetcher(bfOptions);
+
                 await new BrowserFetcher().DownloadAsync("970485");
                 var browser = await Puppeteer.LaunchAsync(new LaunchOptions
                 {