diff --git a/src/ColorMC.Core/CoreMain.cs b/src/ColorMC.Core/CoreMain.cs index 5a36e5893..558c5c269 100644 --- a/src/ColorMC.Core/CoreMain.cs +++ b/src/ColorMC.Core/CoreMain.cs @@ -13,7 +13,7 @@ namespace ColorMC.Core; public static class ColorMCCore { public const string TopVersion = "A24"; - public const string DateVersion = "20240219"; + public const string DateVersion = "20240220"; public const string Version = $"{TopVersion}.{DateVersion}"; diff --git a/src/ColorMC.Core/Net/BaseClient.cs b/src/ColorMC.Core/Net/BaseClient.cs index d9d5e4a1a..a34fcf27e 100644 --- a/src/ColorMC.Core/Net/BaseClient.cs +++ b/src/ColorMC.Core/Net/BaseClient.cs @@ -3,6 +3,7 @@ using ColorMC.Core.Objs; using ColorMC.Core.Utils; using System.Net; +using System.Net.Http.Headers; namespace ColorMC.Core.Net; @@ -47,7 +48,7 @@ public static void Init() { DownloadClient = new(new HttpClientHandler() { - Proxy = new WebProxy(ConfigUtils.Config.Http.ProxyIP, ConfigUtils.Config.Http.ProxyPort) + Proxy = new WebProxy(ConfigUtils.Config.Http.ProxyIP, ConfigUtils.Config.Http.ProxyPort), }); } else @@ -55,6 +56,10 @@ public static void Init() DownloadClient = new(); } + DownloadClient.DefaultRequestHeaders.UserAgent.Clear(); + DownloadClient.DefaultRequestHeaders.UserAgent + .Add(new ProductInfoHeaderValue("ColorMC", ColorMCCore.Version)); + if (ConfigUtils.Config.Http.LoginProxy && !string.IsNullOrWhiteSpace(ConfigUtils.Config.Http.ProxyIP)) { @@ -68,6 +73,10 @@ public static void Init() LoginClient = new(); } + LoginClient.DefaultRequestHeaders.UserAgent.Clear(); + LoginClient.DefaultRequestHeaders.UserAgent + .Add(new ProductInfoHeaderValue("ColorMC", ColorMCCore.Version)); + LoginClient.Timeout = TimeSpan.FromSeconds(10); DownloadClient.Timeout = TimeSpan.FromSeconds(10); } diff --git a/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json b/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json index b008363e6..5a97a6022 100644 --- a/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json +++ b/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json @@ -760,7 +760,7 @@ "ServerPackWindow.Tabs.Text4": "配置文件选择", "ServerPackWindow.Tab1.Text1": "服务器包会复制游戏实例的所有设置,包括JVM参数,运行前启动等数据", "ServerPackWindow.Tab1.Text6": "更新说明", - "ServerPackWindow.Tab1.Text10": "生成服务器实例", + "ServerPackWindow.Tab1.Text10": "开始生成", "ServerPackWindow.Tab1.Text11": "转到下一个设置", "ServerPackWindow.Tab1.Error3": "生成失败,请查看日志获取详细信息", "ServerPackWindow.Tab1.Info1": "正在生成服务器实例", diff --git a/src/ColorMC.Gui/UI/Controls/Main/MainEmptyControl.axaml b/src/ColorMC.Gui/UI/Controls/Main/MainEmptyControl.axaml index f1894dedb..7461f9815 100644 --- a/src/ColorMC.Gui/UI/Controls/Main/MainEmptyControl.axaml +++ b/src/ColorMC.Gui/UI/Controls/Main/MainEmptyControl.axaml @@ -11,7 +11,7 @@ d:DesignWidth="800" x:DataType="model:MainEmptyModel" mc:Ignorable="d"> - <Panel> + <Panel Background="Transparent"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top" diff --git a/src/ColorMC.Gui/UI/Controls/ServerPack/ServerPackControl.axaml.cs b/src/ColorMC.Gui/UI/Controls/ServerPack/ServerPackControl.axaml.cs index 365c7f476..160fa0b9e 100644 --- a/src/ColorMC.Gui/UI/Controls/ServerPack/ServerPackControl.axaml.cs +++ b/src/ColorMC.Gui/UI/Controls/ServerPack/ServerPackControl.axaml.cs @@ -87,6 +87,7 @@ protected override Control ViewChange(bool iswhell, int old, int index) { case 1: case 2: + case 4: model.RemoveChoise(); break; } @@ -105,6 +106,7 @@ protected override Control ViewChange(bool iswhell, int old, int index) return _tab3 ??= new(); case 3: model.LoadFile(); + model.SetTab4Click(); return _tab4 ??= new(); default: throw new InvalidEnumArgumentException(); diff --git a/src/ColorMC.Gui/UI/Controls/ServerPack/Tab1Control.axaml b/src/ColorMC.Gui/UI/Controls/ServerPack/Tab1Control.axaml index aae9c630d..321664a8f 100644 --- a/src/ColorMC.Gui/UI/Controls/ServerPack/Tab1Control.axaml +++ b/src/ColorMC.Gui/UI/Controls/ServerPack/Tab1Control.axaml @@ -22,21 +22,12 @@ <Button Width="160" Height="30" - Margin="-2,-2,3,-2" + Margin="-2" Classes="top" Command="{Binding GoToNext}" Content="{setting:Localize ServerPackWindow.Tab1.Text11}" ToolTip.Tip="{setting:Localize ToolTip.Text47}" ToolTip.VerticalOffset="-30" /> - <Button - Width="160" - Height="30" - Margin="-2,-2,0,-2" - Classes="top" - Command="{Binding Gen}" - Content="{setting:Localize ServerPackWindow.Tab1.Text10}" - ToolTip.Tip="{setting:Localize ToolTip.Text47}" - ToolTip.VerticalOffset="-30" /> </StackPanel> <TextBlock Margin="0,0,0,5" diff --git a/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackModel.cs b/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackModel.cs index f002b2e64..32f8eb743 100644 --- a/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackModel.cs +++ b/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackModel.cs @@ -33,8 +33,7 @@ public ServerPackModel(BaseModel model, ServerPackObj obj) : base(model) Obj = obj; } - [RelayCommand] - public async Task Gen() + public async void Gen() { var local = await PathBinding.SelectPath(FileType.ServerPack); if (local == null) diff --git a/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackTab1Model.cs b/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackTab1Model.cs index acdd80493..e87713781 100644 --- a/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackTab1Model.cs +++ b/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackTab1Model.cs @@ -22,6 +22,8 @@ public void GoToNext() NowView++; } + + public void LoadConfig() { _loadConfig = true; diff --git a/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackTab4Model.cs b/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackTab4Model.cs index 343d11f92..cc15b1bf6 100644 --- a/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackTab4Model.cs +++ b/src/ColorMC.Gui/UI/Model/ServerPack/ServerPackTab4Model.cs @@ -73,6 +73,12 @@ public void AddFile() LoadFile(); } + public void SetTab4Click() + { + Model.SetChoiseCall(_name, Gen); + Model.SetChoiseContent(_name, App.Lang("ServerPackWindow.Tab1.Text10")); + } + public void LoadFile() { FileList.Clear(); diff --git a/src/ColorMC.Gui/UIBinding/BaseBinding.cs b/src/ColorMC.Gui/UIBinding/BaseBinding.cs index 742a52f7e..3745ad410 100644 --- a/src/ColorMC.Gui/UIBinding/BaseBinding.cs +++ b/src/ColorMC.Gui/UIBinding/BaseBinding.cs @@ -510,6 +510,10 @@ await Launch(obj, (a) => list.Add(temp); } + if (list.Count == 0) + { + return; + } Thread.Sleep(1000);