跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

提交记录
修改Core/Core.csproj+2 −2看文件
@@ -171,7 +171,7 @@
171171 <Compile Include="Librarys\Logger.cs" />
172172 <Compile Include="Servicers\Instances\DateTimeObserver.cs" />
173173 <Compile Include="Servicers\Instances\Main.cs" />
174删除: <Compile Include="Servicers\Instances\Observer.cs" />
174新增: <Compile Include="Servicers\Instances\AppObserver.cs" />
175175 <Compile Include="Servicers\Instances\Sleepdiscover.cs" />
176176 <Compile Include="Servicers\Interfaces\IAppConfig.cs" />
177177 <Compile Include="Servicers\Interfaces\ICategorys.cs" />
@@ -179,7 +179,7 @@
179179 <Compile Include="Servicers\Interfaces\IData.cs" />
180180 <Compile Include="Servicers\Interfaces\IDateTimeObserver.cs" />
181181 <Compile Include="Servicers\Interfaces\IMain.cs" />
182删除: <Compile Include="Servicers\Interfaces\IObserver.cs" />
182新增: <Compile Include="Servicers\Interfaces\IAppObserver.cs" />
183183 <Compile Include="Servicers\Interfaces\ISleepdiscover.cs" />
184184 </ItemGroup>
185185 <ItemGroup>
改名Core/Servicers/Instances/Observer.cs → Core/Servicers/Instances/AppObserver.cs+3 −2看文件
@@ -13,14 +13,14 @@ using System.Threading.Tasks;
1313
1414namespace Core.Servicers.Instances
1515{
16删除: public class Observer : IObserver
16新增: public class AppObserver : IAppObserver
1717 {
1818 private IntPtr hook;
1919 Win32API.WinEventDelegate winEventDelegate;
2020
2121 public event ObserverEventHandler OnAppActive;
2222
23删除: public Observer()
23新增: public AppObserver()
2424 {
2525 winEventDelegate = new Win32API.WinEventDelegate(WinEventProc);
2626 }
@@ -40,6 +40,7 @@ namespace Core.Servicers.Instances
4040
4141 private async void Handle(IntPtr hwnd)
4242 {
43新增: Debug.WriteLine(hwnd);
4344 string processName = String.Empty, processFileName = String.Empty, processDescription = String.Empty;
4445
4546 var processResult = await Task.Run(() =>
修改Core/Servicers/Instances/Main.cs+7 −7看文件
@@ -20,7 +20,7 @@ namespace Core.Servicers.Instances
2020{
2121 public class Main : IMain
2222 {
23删除: private readonly IObserver observer;
23新增: private readonly IAppObserver appObserver;
2424 private readonly IData data;
2525 private readonly ISleepdiscover sleepdiscover;
2626 private readonly IAppConfig appConfig;
@@ -83,14 +83,14 @@ namespace Core.Servicers.Instances
8383 // 已经更新过的应用列表
8484 private List<string> updatedAppList = new List<string>();
8585 public Main(
86删除: IObserver observer,
86新增: IAppObserver appObserver,
8787 IData data,
8888 ISleepdiscover sleepdiscover,
8989 IAppConfig appConfig,
9090 IDateTimeObserver dateTimeObserver,
9191 IAppData appData, ICategorys categories)
9292 {
93删除: this.observer = observer;
93新增: this.appObserver = appObserver;
9494 this.data = data;
9595 this.sleepdiscover = sleepdiscover;
9696 this.appConfig = appConfig;
@@ -102,7 +102,7 @@ namespace Core.Servicers.Instances
102102 ConfigIgnoreProcessRegxList = new List<string>();
103103 ConfigIgnoreProcessList = new List<string>();
104104
105删除: observer.OnAppActive += Observer_OnAppActive;
105新增: appObserver.OnAppActive += Observer_OnAppActive;
106106 sleepdiscover.SleepStatusChanged += Sleepdiscover_SleepStatusChanged;
107107 appConfig.ConfigChanged += AppConfig_ConfigChanged;
108108 dateTimeObserver.OnDateTimeChanging += DateTimeObserver_OnDateTimeChanging;
@@ -175,16 +175,16 @@ namespace Core.Servicers.Instances
175175 activeProcess = null;
176176
177177 dateTimeObserver.Start();
178删除: observer.Start();
178新增: appObserver.Start();
179179 }
180180 public void Stop()
181181 {
182182 dateTimeObserver.Stop();
183删除: observer.Stop();
183新增: appObserver.Stop();
184184 }
185185 public void Exit()
186186 {
187删除: observer?.Stop();
187新增: appObserver?.Stop();
188188 }
189189
190190
改名Core/Servicers/Interfaces/IObserver.cs → Core/Servicers/Interfaces/IAppObserver.cs+1 −1看文件
@@ -10,7 +10,7 @@ namespace Core.Servicers.Interfaces
1010 /// <summary>
1111 /// 观察者,用于监听应用程序获取焦点事件
1212 /// </summary>
13删除: public interface IObserver
13新增: public interface IAppObserver
1414 {
1515 /// <summary>
1616 /// 启动观察
修改UI/App.xaml.cs+2 −2看文件
@@ -182,7 +182,7 @@ namespace UI
182182 private void ConfigureServices(IServiceCollection services)
183183 {
184184 // 核心服务
185删除: services.AddSingleton<IObserver, Observer>();
185新增: services.AddSingleton<IAppObserver, AppObserver>();
186186 services.AddSingleton<IMain, Main>();
187187 services.AddSingleton<IData, Data>();
188188 services.AddSingleton<ISleepdiscover, Sleepdiscover>();
@@ -241,7 +241,7 @@ namespace UI
241241 var main = serviceProvider.GetService<IMainServicer>();
242242 main.Start();
243243
244删除: var observer = serviceProvider.GetService<IObserver>();
244新增: var observer = serviceProvider.GetService<IAppObserver>();
245245 observer.OnAppActive += (p, d, f) =>
246246 {
247247 Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>