Skip to content

Commit

Permalink
增加埋点UA
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jul 6, 2024
1 parent d62cc24 commit 38325b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
20 changes: 11 additions & 9 deletions Core/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Init
public static string CompiledVersion = "CompilationTime";
public static Mode Mode = Mode.Core;
private static Timer Update_Timer;

private static Stopwatch stopwatch = new Stopwatch();

public static void Start(string[] args)
Expand Down Expand Up @@ -65,15 +65,15 @@ public static void Start(string[] args)
Config.WriteConfiguration();
var _ = Core.RuntimeObject.Account.AccountInformation;
Core.RuntimeObject.Account.CheckLoginStatus();
Log.Info(nameof(Init), $"Core初始化完成");
Log.Info(nameof(Init), $"Core初始化完成");
Log.Info(nameof(Init), $"启动耗时{stopwatch.ElapsedMilliseconds}毫秒");
Task.Run(() => CoreStartCompletEvent?.Invoke(null, new EventArgs()));

Update_Timer = new Timer(Core.Tools.ProgramUpdates.RegularInspection, null, 1, 1000 * 60 * 30);
Core.Tools.ProgramUpdates.NewVersionAvailableEvent += ProgramUpdates_NewVersionAvailableEvent;
StartStatistics();
Timer_Heartbeat = new Timer(HeartbeatStatistics, null, 1, 1000 * 3600);


}

Expand All @@ -83,7 +83,7 @@ public static void Start(string[] args)
/// 启动参数初始化
/// </summary>
private static void StartParameterInitialization(string[] args)
{
{
foreach (var arg in args)
{
if (arg.StartsWith("--"))
Expand Down Expand Up @@ -113,7 +113,7 @@ private static void StartParameterInitialization(string[] args)
string? DockerEnvironment = Environment.GetEnvironmentVariable("DDTV_Docker_Project");
if (!string.IsNullOrEmpty(DockerEnvironment))
{
if (DockerEnvironment =="DDTV_Server")
if (DockerEnvironment == "DDTV_Server")
{
Init.Mode = Mode.Docker;
}
Expand All @@ -138,7 +138,7 @@ public static double GetRunTime()
}
}



/// <summary>
/// 初始化文件和目录
Expand Down Expand Up @@ -200,8 +200,9 @@ private static void StartStatistics()
{
using (HttpClient _httpClient = new HttpClient())
{
_httpClient.Timeout = new TimeSpan(0,0,8);
_httpClient.Timeout = new TimeSpan(0, 0, 8);
_httpClient.DefaultRequestHeaders.Referrer = new Uri("https://update5.ddtv.pro");
_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd($"System/{System.Runtime.InteropServices.RuntimeInformation.OSDescription} DDTV/{Ver} Bili/{RuntimeObject.Account.AccountInformation.Uid}");
string A = _httpClient.GetStringAsync("https://update5.ddtv.pro/Start.txt").Result;
if (A == "1" || A == "1\r\n")
{
Expand All @@ -222,8 +223,9 @@ public static void HeartbeatStatistics(object state)
{
using (HttpClient _httpClient = new HttpClient())
{
_httpClient.Timeout = new TimeSpan(0,0,8);
_httpClient.Timeout = new TimeSpan(0, 0, 8);
_httpClient.DefaultRequestHeaders.Referrer = new Uri("https://update5.ddtv.pro");
_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd($"System/{System.Runtime.InteropServices.RuntimeInformation.OSDescription} DDTV/{Ver} Bili/{RuntimeObject.Account.AccountInformation.Uid}");
string A = _httpClient.GetStringAsync("https://update5.ddtv.pro/Heartbeat.txt").Result;
if (A == "1" || A == "1\r\n")
{
Expand Down
7 changes: 3 additions & 4 deletions Desktop/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public partial class MainWindow : FluentWindow

public MainWindow()
{
if(Application_Startup())
if (Application_Startup())
{
Environment.Exit(-114514);
return;
Expand Down Expand Up @@ -113,7 +113,6 @@ public void Init()
Detect.detectRoom.LiveStart += DetectRoom_LiveStart;
//初始化VLC播放器组件
LibVLCSharp.Shared.Core.Initialize("./plugins/vlc");

}

private void InitializeTitleMode()
Expand Down Expand Up @@ -186,7 +185,7 @@ public bool Application_Startup()
this.WindowState = WindowState.Normal; // 设置窗口状态为正常
System.Threading.Thread.Sleep(500);
return true;

}
}
return false;
Expand Down Expand Up @@ -233,7 +232,7 @@ private void notify()
/// <exception cref="NotImplementedException"></exception>
private void MainWindow_StateChanged(object? sender, EventArgs e)
{
if (Config.Core_RunConfig._ZoomOutMode!=0 && this.WindowState == WindowState.Minimized)
if (Config.Core_RunConfig._ZoomOutMode != 0 && this.WindowState == WindowState.Minimized)
{
this.Hide();
}
Expand Down

0 comments on commit 38325b3

Please sign in to comment.