CrazyIter_Bin 4 ヶ月 前
コミット
a20331e016

+ 35 - 3
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Services/IndexService.cs

@@ -10,7 +10,8 @@ using System.Text.RegularExpressions;
 using System.Management;
 using IES.ExamServer.Models;
 using System.CodeDom.Compiler;
- 
+using System.Text;
+
 namespace IES.ExamServer.Services
 {
     public static class IndexService
@@ -290,13 +291,44 @@ namespace IES.ExamServer.Services
             //        Uri uri = new Uri(url);
             //        device.uris.Add(new UriInfo { port= uri.Port, protocol= uri.Scheme });
             //    }
-                 
+
             //}
             //else
             //{
             //    throw new Exception("未获取到端口信息!");
             //}
-            string hashData = ShaHashHelper.GetSHA1($"{device.name}-{device.remote}-{string.Join(",", device.uris.Select(x => $"{x.port}-{x.protocol}"))}-{device.os}-{string.Join(",", device.networks.Select(x => $"{x.mac}-{x.ip}"))}");
+            var networks = device.networks;
+            if (device.networks.IsNotEmpty()) 
+            {
+               var order=  device.networks.OrderByDescending(x => x.physical).ToList();
+                for (int i=0; i<order.Count();i++) 
+                {
+                    if (i==0)
+                    {
+                        order[i].domain="exam.habook.local";
+                    }
+                    else {
+                        order[i].domain=$"exam{i}.habook.local";
+                    }
+                }
+                //优先以物理网卡来生成hash,如果没有则以所有网卡生成hash
+                var physical = order.FindAll(x => x.physical==1);
+                if (physical.IsNotEmpty())
+                {
+                    networks.AddRange(physical);
+                }
+            }
+            StringBuilder sb= new StringBuilder();
+            sb.Append(device.name);//设备名称
+            sb.Append(device.os);//系统名称
+            sb.Append(device.bit);//系统位
+            sb.Append(device.arch);//指令架构
+            sb.Append(device.cpu);//cpu核心树
+            sb.Append(string.Join(",", device.cpuInfos.Select(x=>$"{x.name}{x.hz}")));//cpu名称和频率
+            sb.Append(device.ram);//内存
+            sb.Append(string.Join(",", networks.Select(x => $"{x.mac}-{x.name}")));//网卡地址和名称
+            //暂不使用远程ip和局域网内ip作为hash,可能发生变化
+            string hashData = ShaHashHelper.GetSHA256(sb.ToString());
             device.deviceId=hashData;
             device.id= hashData;
             return device;

+ 1 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamViews/vue.config.js

@@ -60,5 +60,6 @@ module.exports = defineConfig({
                 }
             }
         },
+        historyApiFallback: true,
     },
 })