Skip to content

Commit 2e148e8

Browse files
committed
🔖 v2.0.1
✨ 打开启动器时检查更新 ✨ 加载、存储窗口大小 ✨ 更新完后提示更新日志 🐛 关于界面在亮色主题下无法正常显示 🚚 重命名 @IloveEi 写的的部分命名 :lipstick: 作者信息
1 parent d61d2fc commit 2e148e8

12 files changed

Lines changed: 363 additions & 259 deletions

App.xaml.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@ public partial class App : Application
1515
{
1616
private LineFileParser _lineFileParser = new LineFileParser();
1717

18-
public static string LauncherVersion = "2.0.0";
18+
public static string LauncherVersion = "2.0.1";
1919
public static string LauncherVersionType = "alpha";
20-
public static string LauncherBuildVersion = "0004";
20+
public static string LauncherBuildVersion = "0005";
21+
public static string LauncherUpdateLog =
22+
@" 新功能:
23+
✨ 存储并在启动时加载窗口大小
24+
✨ 打开启动器时检查更新
25+
✨ 更新完成后提示更新日志 (就是这个)
26+
修复BUG:
27+
🐛 关于界面在亮色主题下无法正常显示
28+
其他:
29+
💄 作者信息
30+
";
2131

2232
protected override void OnStartup(StartupEventArgs e)
2333
{

Basic/UpdateChecker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static async Task Update(LMCVersion version, bool useGit = false)
5858
await downloader.DownloadFileAsync();
5959
string fullPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
6060
string fileName = Path.GetFileName(fullPath);
61-
File.WriteAllText("./LMC/update.bat", $"@echo off\necho 正在更新...\ntitle 更新中\nTASKKILL /F /IM \"{fileName}\" /T\ntimeout /t 2 /nobreak\ndel \"{fullPath}\"\ncopy \"{Path.GetFullPath("./LMC/" + version.Version + ".exe")}\" \"{fullPath}\"\ndel \"{Path.GetFullPath("./LMC/" + version.Version + ".exe")}\"\nstart {fullPath}", new UTF8Encoding(false));
61+
File.WriteAllText("./LMC/update.bat", $"@echo off\necho Updating...\ntitle Updating\nTASKKILL /F /IM \"{fileName}\" /T\ntimeout /t 2 /nobreak\ndel \"{fullPath}\"\ncopy \"{Path.GetFullPath("./LMC/" + version.Version + ".exe")}\" \"{fullPath}\"\ndel \"{Path.GetFullPath("./LMC/" + version.Version + ".exe")}\"\nstart {fullPath}", new UTF8Encoding(false));
6262
ProcessStartInfo psi = new ProcessStartInfo();
6363
psi.CreateNoWindow = true;
6464
psi.FileName = "cmd.exe";

FodyWeavers.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2-
<Costura />
3-
</Weavers>
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd" />

LMC.csproj

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="packages\Costura.Fody.6.0.0-beta0000\build\Costura.Fody.props" Condition="Exists('packages\Costura.Fody.6.0.0-beta0000\build\Costura.Fody.props')" />
43
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
54
<PropertyGroup>
65
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -83,9 +82,6 @@
8382
<Reference Include="Common, Version=1.1.109.0, Culture=neutral, processorArchitecture=MSIL">
8483
<HintPath>packages\Shared.Common.1.2.0\lib\net472\Common.dll</HintPath>
8584
</Reference>
86-
<Reference Include="Costura, Version=6.0.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
87-
<HintPath>packages\Costura.Fody.6.0.0-beta0000\lib\netstandard2.0\Costura.dll</HintPath>
88-
</Reference>
8985
<Reference Include="iNKORE.UI.WPF, Version=1.2.8.0, Culture=neutral, PublicKeyToken=cd19e634b9706635, processorArchitecture=MSIL">
9086
<HintPath>packages\iNKORE.UI.WPF.Modern.0.9.30\lib\net452\iNKORE.UI.WPF.dll</HintPath>
9187
</Reference>
@@ -290,7 +286,7 @@
290286
</ApplicationDefinition>
291287
<Compile Include="Basic\Config.cs" />
292288
<Compile Include="Basic\UpdateChecker.cs" />
293-
<Compile Include="Minecraft\GameInstanceLauncher.cs" />
289+
<Compile Include="Minecraft\GameLauncher.cs" />
294290
<Compile Include="Pages\AccountTypes\MicrosoftLoginPage.xaml.cs">
295291
<DependentUpon>MicrosoftLoginPage.xaml</DependentUpon>
296292
</Compile>
@@ -447,15 +443,8 @@
447443
<ItemGroup>
448444
<Resource Include="steve.png" />
449445
</ItemGroup>
446+
<ItemGroup>
447+
<Resource Include="junse.jpg" />
448+
</ItemGroup>
450449
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
451-
<Import Project="packages\Fody.6.8.2\build\Fody.targets" Condition="Exists('packages\Fody.6.8.2\build\Fody.targets')" />
452-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
453-
<PropertyGroup>
454-
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
455-
</PropertyGroup>
456-
<Error Condition="!Exists('packages\Fody.6.8.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Fody.6.8.2\build\Fody.targets'))" />
457-
<Error Condition="!Exists('packages\Costura.Fody.6.0.0-beta0000\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.6.0.0-beta0000\build\Costura.Fody.props'))" />
458-
<Error Condition="!Exists('packages\Costura.Fody.6.0.0-beta0000\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.6.0.0-beta0000\build\Costura.Fody.targets'))" />
459-
</Target>
460-
<Import Project="packages\Costura.Fody.6.0.0-beta0000\build\Costura.Fody.targets" Condition="Exists('packages\Costura.Fody.6.0.0-beta0000\build\Costura.Fody.targets')" />
461450
</Project>

MainWindow.xaml.cs

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using LMC.Account;
1515
using LMC.Pages;
1616
using LMC.Utils;
17+
using System.Reflection.Emit;
1718

1819
namespace LMC
1920
{
@@ -46,26 +47,107 @@ public MainWindow()
4647
InitializeComponent();
4748
s_background = BackGround;
4849
MainFrame = MainFrm;
50+
double width;
51+
if(double.TryParse(Config.ReadGlobal("window", "width"), out width))
52+
{
53+
this.Width = width;
54+
}
55+
double height;
56+
if (double.TryParse(Config.ReadGlobal("window", "height"), out height))
57+
{
58+
this.Height = height;
59+
}
4960
if (File.Exists($"./LMC/update.bat"))
5061
{
5162
File.Delete($"./LMC/update.bat");
52-
ShowDialog("确认", $"更新成功,可以关闭CMD命令行窗口,LMC已更新至{App.LauncherVersion}-{App.LauncherVersionType},构建号{App.LauncherBuildVersion}", "提示");
63+
ShowDialog("确认", $"更新成功,可以关闭CMD命令行窗口,LMC已更新至{App.LauncherVersion}-{App.LauncherVersionType},构建号{App.LauncherBuildVersion},更新内容:\n{App.LauncherUpdateLog}", "提示");
5364
}
5465
Secrets.GetDeviceCode();
5566
var accounts = AccountManager.GetAccounts(false).Result;
56-
foreach ( var account in accounts)
67+
foreach (var account in accounts)
5768
{
58-
if(account.Type == AccountType.MSA)
69+
if (account.Type == AccountType.MSA)
5970
{
60-
AccountManager.GetAvatarAsync(account,64);
71+
AccountManager.GetAvatarAsync(account, 64);
6172
}
6273
}
74+
this.Loaded += MainWindow_Loaded;
75+
this.SizeChanged += MainWindow_SizeChanged;
6376
}
6477
catch {
6578
Environment.Exit(1);
6679
}
6780
}
6881

82+
private void MainWindow_SizeChanged(object sender, SizeChangedEventArgs e)
83+
{
84+
double width = this.ActualWidth;
85+
double height = this.ActualHeight;
86+
Config.WriteGlobal("window", "width", width.ToString());
87+
Config.WriteGlobal("window", "height", height.ToString());
88+
}
89+
90+
private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
91+
{
92+
s_logger.Info("正在检查更新");
93+
try
94+
{
95+
var ver = await UpdateChecker.Check();
96+
97+
if (ver == null)
98+
{
99+
throw new Exception("检查更新失败,版本为空");
100+
}
101+
if (ver.Type == App.LauncherVersionType && ver.Version == App.LauncherVersion && ver.Build == App.LauncherBuildVersion) {
102+
s_logger.Info("当前是最新版");
103+
return;
104+
}
105+
if (!ver.SecurityOrEmergency)
106+
{
107+
var res = await ShowDialog("取消", $"发现新的非紧急更新版!\n版本号:{ver.Version}\n类型:{ver.Type}\n构建号:{ver.Build}", "更新", ContentDialogButton.Primary, "更新");
108+
if (res == ContentDialogResult.Primary)
109+
{
110+
try
111+
{
112+
await UpdateChecker.Update(ver);
113+
}
114+
catch (Exception ex)
115+
{
116+
new Logger("MW-UPD").Error($"更新失败:{ex.Message}\n{ex.StackTrace}");
117+
}
118+
}
119+
}
120+
else
121+
{
122+
ContentDialog dialog = new ContentDialog();
123+
dialog.Title = "更新";
124+
dialog.Content = $"发现新的紧急更新版!\n版本号:{ver.Version}\n类型:{ver.Type}\n构建号:{ver.Build}";
125+
dialog.PrimaryButtonText = "更新";
126+
dialog.DefaultButton = ContentDialogButton.Primary;
127+
dialog.PrimaryButtonClick += async (s, e) =>
128+
{
129+
try
130+
{
131+
await UpdateChecker.Update(ver);
132+
}
133+
catch (Exception ex)
134+
{
135+
new Logger("AP-UPD").Error($"更新失败:{ex.Message}\n{ex.StackTrace}");
136+
}
137+
};
138+
dialog.ShowAsync();
139+
140+
}
141+
}
142+
catch (Exception ex)
143+
{
144+
s_logger.Error("更新检查失败:" + ex.Message + "\n" + ex.StackTrace);
145+
ShowDialog("确认", $"更新检查失败:{ex.Message}\n{ex.StackTrace}", "错误");
146+
}
147+
148+
}
149+
150+
69151
public static void AddAccPage()
70152
{
71153
MainFrame.Navigate(AddAccountPage);

0 commit comments

Comments
 (0)