跳到主要内容

github/tai

公开

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

提交记录
修改UI/Models/DetailPageModel.cs+12 −0看文件
@@ -67,5 +67,17 @@ namespace UI.Models
6767
6868 private Visibility CancelBlockBtnVisibility_ = Visibility.Collapsed;
6969 public Visibility CancelBlockBtnVisibility { get { return CancelBlockBtnVisibility_; } set { CancelBlockBtnVisibility_ = value; OnPropertyChanged(); } }
70新增:
71新增: private string TodayTime_;
72新增: /// <summary>
73新增: /// 今日使用时长
74新增: /// </summary>
75新增: public string TodayTime { get { return TodayTime_; } set { TodayTime_ = value; OnPropertyChanged(); } }
76新增:
77新增: private string Yesterday_;
78新增: /// <summary>
79新增: /// 相比昨日
80新增: /// </summary>
81新增: public string Yesterday { get { return Yesterday_; } set { Yesterday_ = value; OnPropertyChanged(); } }
7082 }
7183}
修改UI/ViewModels/DetailPageVM.cs+70 −2看文件
@@ -3,9 +3,11 @@ using Core.Models.Config;
33using Core.Servicers.Interfaces;
44using System;
55using System.Collections.Generic;
6新增:using System.IO;
67using System.Linq;
78using System.Text;
89using System.Threading.Tasks;
10新增:using System.Windows;
911using UI.Controls;
1012using UI.Controls.Charts.Model;
1113using UI.Librays;
@@ -22,7 +24,7 @@ namespace UI.ViewModels
2224 private ConfigModel config;
2325 public Command BlockActionCommand { get; set; }
2426 public Command ClearSelectMonthDataCommand { get; set; }
25删除:
27新增: public Command InfoMenuActionCommand { get; set; }
2628 public DetailPageVM(
2729 IData data, MainViewModel main, IAppConfig appConfig)
2830 {
@@ -32,7 +34,7 @@ namespace UI.ViewModels
3234
3335 BlockActionCommand = new Command(new Action<object>(OnBlockActionCommand));
3436 ClearSelectMonthDataCommand = new Command(new Action<object>(OnClearSelectMonthDataCommand));
35删除:
37新增: InfoMenuActionCommand = new Command(new Action<object>(OnInfoMenuActionCommand));
3638 Init();
3739 }
3840
@@ -53,6 +55,29 @@ namespace UI.ViewModels
5355 await LoadInfo();
5456
5557 }
58新增: private void OnInfoMenuActionCommand(object obj)
59新增: {
60新增: switch (obj.ToString())
61新增: {
62新增: case "copy processname":
63新增: Clipboard.SetText(ProcessName);
64新增:
65新增: break;
66新增: case "copy process file":
67新增: Clipboard.SetText(Process.PopupText);
68新增: break;
69新增: case "open dir":
70新增: if (File.Exists(Process.PopupText))
71新增: {
72新增: System.Diagnostics.Process.Start("explorer.exe", "/select, " + Process.PopupText);
73新增: }
74新增: else
75新增: {
76新增: main.Toast("进程文件似乎不存在", Controls.Base.IconTypes.Blocked);
77新增: }
78新增: break;
79新增: }
80新增: }
5681
5782 private async void OnClearSelectMonthDataCommand(object obj)
5883 {
@@ -98,6 +123,48 @@ namespace UI.ViewModels
98123 // 判断是否是忽略的进程
99124 IsIgnore = config.Behavior.IgnoreProcessList.Contains(ProcessName);
100125 }
126新增:
127新增: var today = data.GetProcess(ProcessName, DateTime.Now);
128新增: var yesterday = data.GetProcess(ProcessName, DateTime.Now.AddDays(-1));
129新增:
130新增: if (today != null)
131新增: {
132新增: TodayTime = Timer.Fromat(today.Time);
133新增: }
134新增: else
135新增: {
136新增: TodayTime = "暂无数据";
137新增: }
138新增:
139新增: if (yesterday != null)
140新增: {
141新增: int diffseconds = today != null ? today.Time - yesterday.Time : yesterday.Time;
142新增:
143新增: string diffText = string.Empty;
144新增: if (diffseconds != yesterday.Time)
145新增: {
146新增: if (diffseconds == 0)
147新增: {
148新增: // 无变化
149新增: diffText = "持平";
150新增: }
151新增: else if (diffseconds > 0)
152新增: {
153新增: // 增加
154新增: diffText = "增加了" + Timer.Fromat(diffseconds);
155新增: }
156新增: else
157新增: {
158新增: // 减少
159新增: diffText = "减少了" + Timer.Fromat(Math.Abs(diffseconds));
160新增: }
161新增: }
162新增: Yesterday = diffseconds == yesterday.Time ? "减少100%" : diffText;
163新增: }
164新增: else
165新增: {
166新增: Yesterday = "昨日未使用";
167新增: }
101168 }
102169 }
103170 );
@@ -158,6 +225,7 @@ namespace UI.ViewModels
158225 data.Clear(ProcessName, Process.PopupText, Date);
159226
160227 await LoadData();
228新增: await LoadInfo();
161229 main.Toast("已清空");
162230 }
163231 }
修改UI/Views/DetailPage.xaml+31 −1看文件
@@ -19,6 +19,13 @@
1919 Background="White"
2020 CornerRadius="12"
2121 Padding="0,20">
22新增: <Border.ContextMenu>
23新增: <ContextMenu>
24新增: <MenuItem Command="{Binding InfoMenuActionCommand}" CommandParameter="copy processname" Header="复制进程名称"/>
25新增: <MenuItem Command="{Binding InfoMenuActionCommand}" CommandParameter="copy process file" Header="复制进程路径"/>
26新增: <MenuItem Command="{Binding InfoMenuActionCommand}" CommandParameter="open dir" Header="打开进程所在目录"/>
27新增: </ContextMenu>
28新增: </Border.ContextMenu>
2229 <Grid>
2330 <Grid.ColumnDefinitions>
2431 <ColumnDefinition Width="100"/>
@@ -51,12 +58,35 @@
5158 </StackPanel>
5259 </Grid>
5360 </Border>
61新增: <TextBlock Text="今日数据" FontSize="14" Margin="0,20,0,0"/>
5462
5563 <Border
5664 Background="White"
5765 CornerRadius="12"
5866 Padding="20,20"
59删除: Margin="0,20,0,0">
67新增: Margin="0,10,0,0">
68新增: <StackPanel>
69新增: <StackPanel Orientation="Horizontal" ToolTip="今日使用总时长">
70新增: <base:Icon IconType="Timer" VerticalAlignment="Center" Foreground="Gray"/>
71新增: <TextBlock Text="{Binding TodayTime}" VerticalAlignment="Center" Margin="10,0,0,0"/>
72新增: </StackPanel>
73新增: <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
74新增: <base:Icon IconType="Chart" VerticalAlignment="Center" Foreground="Gray"/>
75新增: <TextBlock Text="相比昨日" VerticalAlignment="Center" Margin="10,0,0,0"/>
76新增: <TextBlock Text="{Binding Yesterday}" VerticalAlignment="Center" Margin="5,0,0,0"/>
77新增:
78新增: </StackPanel>
79新增:
80新增: </StackPanel>
81新增: </Border>
82新增:
83新增: <TextBlock Text="月份数据" FontSize="14" Margin="0,20,0,0"/>
84新增:
85新增: <Border
86新增: Background="White"
87新增: CornerRadius="12"
88新增: Padding="20,20"
89新增: Margin="0,10,0,0">
6090 <StackPanel>
6191 <Grid>
6292 <DatePickerBar:DatePickerBar ShowType="Month" HorizontalAlignment="Left" SelectedDate="{Binding Date,Mode=TwoWay}"/>