Skip to content

Commit dafd4b0

Browse files
committed
add: 关于页面的功能补全
1 parent a41617e commit dafd4b0

File tree

3 files changed

+112
-8
lines changed

3 files changed

+112
-8
lines changed

llcomNext/LLCOM/Services/Utils.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
using Avalonia;
5+
using Avalonia.Controls;
6+
using Avalonia.Controls.ApplicationLifetimes;
7+
8+
namespace LLCOM.Services;
9+
10+
public class Utils
11+
{
12+
private static string? _version = null;
13+
/// <summary>
14+
/// 软件版本
15+
/// </summary>
16+
public static string Version
17+
{
18+
get
19+
{
20+
if (_version is null)
21+
{
22+
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version!;
23+
_version = $"{version.Major}.{version.Minor}.{version.Build}";
24+
}
25+
return _version;
26+
}
27+
}
28+
29+
/// <summary>
30+
/// 用户配置文件路径
31+
/// win:C:\Users\{username}\LLCOM_Next
32+
/// linux:/home/{username}/LLCOM_Next
33+
/// mac:/Users/{username}/LLCOM_Next
34+
/// </summary>
35+
public readonly static string AppPath =
36+
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "LLCOM_Next");
37+
38+
/// <summary>
39+
/// 启动软件时的初始化操作
40+
/// </summary>
41+
public static void Initial()
42+
{
43+
if (!Directory.Exists(AppPath))
44+
Directory.CreateDirectory(AppPath);
45+
//初始化语言 TODO
46+
}
47+
48+
public static async Task<bool> CopyString(string txt)
49+
{
50+
try
51+
{
52+
TopLevel top;
53+
var app = Application.Current!.ApplicationLifetime;
54+
if (app is IClassicDesktopStyleApplicationLifetime desktop)
55+
{
56+
top = desktop.MainWindow!;
57+
}
58+
else if (app is ISingleViewApplicationLifetime single)
59+
{
60+
top = TopLevel.GetTopLevel(single.MainView)!;
61+
}
62+
else
63+
return false;
64+
var clipboard = top.Clipboard;
65+
await clipboard!.SetTextAsync(txt);
66+
return true;
67+
}
68+
catch
69+
{
70+
return false;
71+
}
72+
}
73+
}

llcomNext/LLCOM/ViewModels/Pages/SettingPageViewModel.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using System;
2+
using System.Threading.Tasks;
3+
using CommunityToolkit.Mvvm.ComponentModel;
4+
using CommunityToolkit.Mvvm.Input;
25

36
namespace LLCOM.ViewModels;
47

@@ -13,4 +16,25 @@ public SettingPageViewModel(Func<Type, ViewModelBase> getService)
1316
{
1417
_getService = getService;
1518
}
19+
20+
[ObservableProperty] private string _systemInfo =
21+
$"LLCOM: {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}\n\n" +
22+
$"Operating System: {Environment.OSVersion.VersionString}\n" +
23+
$".Net CLR: {Environment.Version}\n" +
24+
#if debug
25+
$"Debug mode: true\n" +
26+
#else
27+
$"Debug mode: false\n" +
28+
#endif
29+
$"Location: {Environment.CurrentDirectory}\n" +
30+
$"AppData: TODO\n" +
31+
$"Environment: {Environment.GetEnvironmentVariable("PATH")}";
32+
33+
[RelayCommand]
34+
private async Task CopySystemInfo()
35+
{
36+
await Services.Utils.CopyString(SystemInfo);
37+
}
38+
39+
1640
}

llcomNext/LLCOM/Views/Pages/SettingPageView.axaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,27 @@
6161
<TextBlock TextWrapping="Wrap">
6262
软件支持跨平台,为各平台用户提供一致的体验。
6363
</TextBlock>
64-
<TextBlock Margin="0,5,0,0" Text="本软件为开源项目" />
65-
<HyperlinkButton
66-
Classes="WithIcon Underline"
67-
Content="LLCOM Next GitHub源码仓库"
68-
Height="20"
69-
NavigateUri="https://github.com/chenxuuu/llcom/tree/next" />
64+
<StackPanel Margin="0,5,0,0" Orientation="Horizontal">
65+
<TextBlock Text="本软件为开源项目:" />
66+
<HyperlinkButton
67+
Classes="WithIcon Underline"
68+
Content="GitHub源码仓库"
69+
Height="20"
70+
NavigateUri="https://github.com/chenxuuu/llcom/tree/next" />
71+
</StackPanel>
72+
7073

7174
<TextBox
7275
AcceptsReturn="True"
7376
FontSize="15"
7477
IsReadOnly="True"
7578
Margin="0,20,0,0"
76-
Text="LLCOM 2.0.0&#13;Window 10 21H1&#13;用来展示系统和软件版本信息&#13;xxx"
77-
TextWrapping="Wrap" />
79+
Text="{Binding SystemInfo}" />
80+
<Button
81+
Command="{Binding CopySystemInfoCommand}"
82+
Content="复制调试信息"
83+
HorizontalAlignment="Stretch"
84+
Margin="0,5,0,0" />
7885
</StackPanel>
7986
</ScrollViewer>
8087
</TabItem>

0 commit comments

Comments
 (0)