跳到主要内容

github/tai

公开

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

提交记录
新增Core/Models/Config/BehaviorModel.cs+20 −0看文件
@@ -0,0 +1,20 @@
1新增:using System;
2新增:using System.Collections.Generic;
3新增:using System.Linq;
4新增:using System.Text;
5新增:using System.Threading.Tasks;
6新增:
7新增:namespace Core.Models.Config
8新增:{
9新增: /// <summary>
10新增: /// 行为
11新增: /// </summary>
12新增: public class BehaviorModel
13新增: {
14新增: [Config(Name = "忽略进程", Description = "忽略的进程将不进行时长统计", Group = "忽略进程", Placeholder ="进程名,不需要输入.exe")]
15新增: /// <summary>
16新增: /// 忽略的进程列表
17新增: /// </summary>
18新增: public List<string> IgnoreProcessList { get; set; } = new List<string>();
19新增: }
20新增:}
修改Core/Models/Config/ConfigModel.cs+6 −0看文件
@@ -21,5 +21,11 @@ namespace Core.Models.Config
2121 /// 常规
2222 /// </summary>
2323 public GeneralModel General { get; set; }
24新增:
25新增: /// <summary>
26新增: /// 行为
27新增: /// </summary>
28新增: public BehaviorModel Behavior { get; set; }
29新增:
2430 }
2531}
修改Core/Servicers/Instances/Main.cs+3 −2看文件
@@ -138,9 +138,10 @@ namespace Core.Servicers.Instances
138138 UpdateTime();
139139 }
140140
141删除: if (!IgnoreProcess.Contains(processName)
141新增: if (!config.Behavior.IgnoreProcessList.Contains(processName)
142142 && file != string.Empty
143删除: && sleepStatus != SleepStatus.Sleep)
143新增: && sleepStatus != SleepStatus.Sleep
144新增: && !IgnoreProcess.Contains(processName))
144145 {
145146 activeProcess = processName;
146147 activeProcessDescription = description;
修改UI/Models/DetailPageModel.cs+29 −2看文件
@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
44using System.Linq;
55using System.Text;
66using System.Threading.Tasks;
7新增:using System.Windows;
78using UI.Controls.Charts.Model;
89
910namespace UI.Models
@@ -32,13 +33,39 @@ namespace UI.Models
3233 public string Ratio { get { return Ratio_; } set { Ratio_ = value; OnPropertyChanged(); } }
3334
3435 private DateTime Date_;
35删除: public DateTime Date { get { return Date_; } set { Date_ = value; OnPropertyChanged();} }
36新增: public DateTime Date { get { return Date_; } set { Date_ = value; OnPropertyChanged(); } }
3637
3738 private string LongDay_;
38删除: public string LongDay { get { return LongDay_; } set { LongDay_ = value;OnPropertyChanged();} }
39新增: public string LongDay { get { return LongDay_; } set { LongDay_ = value; OnPropertyChanged(); } }
3940
4041 private string ProcessName_;
4142 public string ProcessName { get { return ProcessName_; } set { ProcessName_ = value; OnPropertyChanged(); } }
4243
44新增: private bool IsIgnore_;
45新增: public bool IsIgnore
46新增: {
47新增: get { return IsIgnore_; }
48新增: set
49新增: {
50新增: IsIgnore_ = value;
51新增: if (IsIgnore)
52新增: {
53新增: BlockBtnVisibility = Visibility.Collapsed;
54新增: CancelBlockBtnVisibility = Visibility.Visible;
55新增: }
56新增: else
57新增: {
58新增: BlockBtnVisibility = Visibility.Visible;
59新增: CancelBlockBtnVisibility = Visibility.Collapsed;
60新增: }
61新增: OnPropertyChanged();
62新增: }
63新增: }
64新增:
65新增: private Visibility BlockBtnVisibility_ = Visibility.Collapsed;
66新增: public Visibility BlockBtnVisibility { get { return BlockBtnVisibility_; } set { BlockBtnVisibility_ = value; OnPropertyChanged(); } }
67新增:
68新增: private Visibility CancelBlockBtnVisibility_ = Visibility.Collapsed;
69新增: public Visibility CancelBlockBtnVisibility { get { return CancelBlockBtnVisibility_; } set { CancelBlockBtnVisibility_ = value; OnPropertyChanged(); } }
4370 }
4471}
修改UI/ViewModels/DetailPageVM.cs+62 −2看文件
@@ -1,10 +1,12 @@
11using Core.Librarys;
2新增:using Core.Models.Config;
23using Core.Servicers.Interfaces;
34using System;
45using System.Collections.Generic;
56using System.Linq;
67using System.Text;
78using System.Threading.Tasks;
9新增:using UI.Controls;
810using UI.Controls.Charts.Model;
911using UI.Librays;
1012using UI.Models;
@@ -15,14 +17,27 @@ namespace UI.ViewModels
1517 {
1618 private readonly IData data;
1719 private readonly MainViewModel main;
20新增: private readonly IAppConfig appConfig;
21新增:
22新增: private ConfigModel config;
23新增: public Command BlockActionCommand { get; set; }
24新增: public Command ClearSelectMonthDataCommand { get; set; }
25新增:
1826 public DetailPageVM(
19删除: IData data, MainViewModel main)
27新增: IData data, MainViewModel main, IAppConfig appConfig)
2028 {
2129 this.data = data;
2230 this.main = main;
31新增: this.appConfig = appConfig;
32新增:
33新增: BlockActionCommand = new Command(new Action<object>(OnBlockActionCommand));
34新增: ClearSelectMonthDataCommand = new Command(new Action<object>(OnClearSelectMonthDataCommand));
35新增:
2336 Init();
2437 }
2538
39新增:
40新增:
2641 private async void Init()
2742 {
2843 Process = main.Data as ChartsDataModel;
@@ -31,9 +46,35 @@ namespace UI.ViewModels
3146
3247 PropertyChanged += DetailPageVM_PropertyChanged;
3348
49新增: config = appConfig.GetConfig();
50新增:
3451 await LoadData();
3552
3653 await LoadInfo();
54新增:
55新增: }
56新增:
57新增: private async void OnClearSelectMonthDataCommand(object obj)
58新增: {
59新增: await Clear();
60新增: }
61新增:
62新增: private void OnBlockActionCommand(object obj)
63新增: {
64新增: if (obj.ToString() == "block")
65新增: {
66新增: config.Behavior.IgnoreProcessList.Add(ProcessName);
67新增: IsIgnore = true;
68新增: main.Toast("进程已忽略");
69新增: }
70新增: else
71新增: {
72新增: config.Behavior.IgnoreProcessList.Remove(ProcessName);
73新增: IsIgnore = false;
74新增: main.Toast("进程已取消忽略");
75新增: }
76新增:
77新增: appConfig.Save();
3778 }
3879
3980 private async void DetailPageVM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
@@ -54,7 +95,8 @@ namespace UI.ViewModels
5495 if (info != null)
5596 {
5697 ProcessName = info.ProcessName;
57删除:
98新增: // 判断是否是忽略的进程
99新增: IsIgnore = config.Behavior.IgnoreProcessList.Contains(ProcessName);
58100 }
59101 }
60102 }
@@ -67,6 +109,7 @@ namespace UI.ViewModels
67109 {
68110 if (Process != null)
69111 {
112新增:
70113 var monthData = data.GetProcessMonthLogList(Process.PopupText, Date);
71114 int monthTotal = monthData.Sum(m => m.Time);
72115 Total = Timer.Fromat(monthTotal);
@@ -105,6 +148,23 @@ namespace UI.ViewModels
105148 });
106149 }
107150
151新增: private async Task Clear()
152新增: {
153新增: await Task.Run(async () =>
154新增: {
155新增: if (Process != null)
156新增: {
157新增: main.Toast("正在处理");
158新增: data.Clear(ProcessName, Process.PopupText, Date);
159新增:
160新增: await LoadData();
161新增: main.Toast("已清空");
162新增: }
163新增: }
164新增: );
165新增: }
166新增:
167新增:
108168 private List<ChartsDataModel> MapToChartsData(List<Core.Models.DailyLogModel> list)
109169 {
110170 var resData = new List<ChartsDataModel>();
修改UI/ViewModels/SettingPageVM.cs+10 −1看文件
@@ -41,7 +41,7 @@ namespace UI.ViewModels
4141
4242 TabbarData = new System.Collections.ObjectModel.ObservableCollection<string>()
4343 {
44删除: "常规","关联","关于"
44新增: "常规","关联","行为","关于"
4545 };
4646
4747 PropertyChanged += SettingPageVM_PropertyChanged;
@@ -73,6 +73,10 @@ namespace UI.ViewModels
7373 }
7474
7575 }
76新增: else if (TabbarSelectedIndex == 2)
77新增: {
78新增: config.Behavior = Data as BehaviorModel;
79新增: }
7680
7781 appConfig.Save();
7882 }
@@ -89,6 +93,11 @@ namespace UI.ViewModels
8993 // 关联
9094 Data = config.Links;
9195 }
96新增: else if (TabbarSelectedIndex == 2)
97新增: {
98新增: // 行为
99新增: Data = config.Behavior;
100新增: }
92101 }
93102 }
94103 }
修改UI/Views/DetailPage.xaml+23 −4看文件
@@ -7,7 +7,9 @@
77 xmlns:DatePickerBar="clr-namespace:UI.Controls.DatePickerBar" x:Class="UI.Views.DetailPage"
88 mc:Ignorable="d"
99 d:DesignHeight="450" d:DesignWidth="800"
10删除: Title="DetailPage">
10新增: Title="DetailPage"
11新增: xmlns:btn="clr-namespace:UI.Controls.Button"
12新增: xmlns:base="clr-namespace:UI.Controls.Base">
1113
1214 <Grid>
1315 <StackPanel Margin="20">
@@ -21,19 +23,32 @@
2123 <Grid.ColumnDefinitions>
2224 <ColumnDefinition Width="100"/>
2325 <ColumnDefinition Width="9*"/>
26新增: <ColumnDefinition Width="3*"/>
2427
2528 </Grid.ColumnDefinitions>
2629 <Image Source="{Binding Process.Icon}" Width="25" HorizontalAlignment="Center" VerticalAlignment="Center"/>
2730
2831 <StackPanel Grid.Column="1" VerticalAlignment="Center">
2932 <StackPanel Orientation="Horizontal">
30删除: <TextBlock Text="{Binding Process.Name}" FontSize="18" />
31删除: <TextBlock ToolTip="进程名" Text="{Binding ProcessName}" FontSize="12" Foreground="Gray" VerticalAlignment="Center" Margin="15,0,0,0"/>
33新增: <Border Background="#f51837" Padding="10,5" CornerRadius="4" Margin="0,0,4,0" VerticalAlignment="Center" Visibility="{Binding CancelBlockBtnVisibility}" ToolTip="该进程将不再统计使用时长">
34新增: <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
35新增: <base:Icon IconType="Blocked" FontSize="12" VerticalAlignment="Center" Foreground="White"/>
36新增: <TextBlock Text="已被忽略" Foreground="White" VerticalAlignment="Center" Margin="5,0,0,0"/>
37新增: </StackPanel>
38新增: </Border>
39新增: <TextBlock Text="{Binding Process.Name}" FontSize="18" VerticalAlignment="Center"/>
40新增: <TextBlock ToolTip="进程名" Text="{Binding ProcessName}" FontSize="12" Foreground="Gray" VerticalAlignment="Center" Margin="10,0,0,0"/>
3241
3342 </StackPanel>
3443 <TextBlock ToolTip="进程文件路径" Foreground="Gray" Text="{Binding Process.PopupText}" Margin="0,5,0,0" TextWrapping="WrapWithOverflow"/>
3544
3645 </StackPanel>
46新增:
47新增: <StackPanel Grid.Column="2" HorizontalAlignment="Right" Margin="0,0,20,0">
48新增: <btn:Button Command="{Binding BlockActionCommand}" CommandParameter="block" Width="120" Visibility="{Binding BlockBtnVisibility}" Icon="Blocked">忽略此进程</btn:Button>
49新增: <btn:Button Command="{Binding BlockActionCommand}" CommandParameter="unblock" Width="120" Visibility="{Binding CancelBlockBtnVisibility}" Icon="Remove">取消忽略此进程</btn:Button>
50新增:
51新增: </StackPanel>
3752 </Grid>
3853 </Border>
3954
@@ -43,8 +58,12 @@
4358 Padding="20,20"
4459 Margin="0,20,0,0">
4560 <StackPanel>
46删除: <DatePickerBar:DatePickerBar ShowType="Month" HorizontalAlignment="Left" SelectedDate="{Binding Date,Mode=TwoWay}"/>
61新增: <Grid>
62新增: <DatePickerBar:DatePickerBar ShowType="Month" HorizontalAlignment="Left" SelectedDate="{Binding Date,Mode=TwoWay}"/>
4763
64新增: <btn:Button ToolTip="清空此进程在该月的统计数据" HorizontalAlignment="Right" VerticalAlignment="Top" Background="#f51837" Foreground="White" Width="120" Margin="0" Icon="Delete" Command="{Binding ClearSelectMonthDataCommand}">清空统计</btn:Button>
65新增:
66新增: </Grid>
4867 <Grid Margin="0,20,0,0">
4968 <Grid.ColumnDefinitions>
5069 <ColumnDefinition Width="256"/>
修改UI/Views/SettingPage.xaml+4 −0看文件
@@ -41,6 +41,9 @@
4141 <TabItem>
4242 <SettingPanel:SettingPanel Data="{Binding Data,Mode=TwoWay}" Margin="0,0,0,10"/>
4343 </TabItem>
44新增: <TabItem>
45新增: <SettingPanel:SettingPanel Data="{Binding Data,Mode=TwoWay}" Margin="0,0,0,0"/>
46新增: </TabItem>
4447 <TabItem>
4548 <!--关于-->
4649 <Border Background="White" Padding="20" CornerRadius="6">
@@ -62,6 +65,7 @@
6265 </StackPanel>
6366 </Border>
6467 </TabItem>
68新增:
6569 </TabControl>
6670 </StackPanel>
6771