Skip to content

Commit

Permalink
up 调整安装包策略
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloryr committed Aug 21, 2024
1 parent 1d85c92 commit f529f0b
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 254 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.wxs
2 changes: 1 addition & 1 deletion src/ColorMC.Core/CoreMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ColorMC.Core;
public static class ColorMCCore
{
public const string TopVersion = "A29";
public const string DateVersion = "20240820";
public const string DateVersion = "20240821";

/// <summary>
/// 版本号
Expand Down
15 changes: 12 additions & 3 deletions src/ColorMC.Core/Utils/AuthDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,24 @@ public static void Init()
Logs.Info(LanguageHelper.Get("Core.Auth.Info1"));

var path = (SystemInfo.Os == OsType.MacOS ?
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) :
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
+ "/ColorMC/";
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.ColorMC/" :
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) + "/ColorMC/";

Logs.Info(path);

Directory.CreateDirectory(path);

s_local = Path.GetFullPath(path + Name);

if (SystemInfo.Os == OsType.Windows)
{
var path1 = Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/ColorMC/" + Name);
if (File.Exists(path1))
{
File.Move(path1, s_local);
}
}

if (File.Exists(s_local))
{
Load();
Expand Down
28 changes: 1 addition & 27 deletions src/ColorMC.Gui/ColorMCGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public static class ColorMCGui

public static string RunDir { get; private set; }
public static string[] BaseSha1 { get; private set; }
public static string InputDir { get; private set; }

public static RunType RunType { get; private set; } = RunType.AppBuilder;

Expand Down Expand Up @@ -71,31 +70,6 @@ public static void Main(string[] args)

RunType = RunType.Program;

if (string.IsNullOrWhiteSpace(InputDir))
{
RunDir = SystemInfo.Os switch
{
OsType.Linux => $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/.ColorMC/",
OsType.MacOS => "/Users/shared/ColorMC/",
_ => AppContext.BaseDirectory
};


if (SystemInfo.Os == OsType.Linux)
{
string path = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/ColorMC/";
if (Directory.Exists(path))
{
Directory.Move(path, RunDir);
}
}
}
else
{
RunDir = InputDir;
}


Console.WriteLine($"RunDir: {RunDir}");

if (args.Length > 0)
Expand Down Expand Up @@ -184,7 +158,7 @@ public static void SetBaseSha1(string[] data)

public static void SetInputDir(string dir)
{
InputDir = dir;
RunDir = dir;
}

public static void SetCrash(bool crash)
Expand Down
2 changes: 1 addition & 1 deletion src/ColorMC.Gui/Manager/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static bool ShowCustom(bool test = false)
CustomWindow = dll;
}
AWindow(dll.Window, test);
var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}/ColorMC/custom";
var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/ColorMC/custom";
if (!File.Exists(path))
{
File.WriteAllText(path, "custom");
Expand Down
4 changes: 2 additions & 2 deletions src/ColorMC.Gui/UI/Model/Setting/SettingTab1Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task ChangeBackRunDir()
return;
}

var path1 = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}/ColorMC/run";
var path1 = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/ColorMC/run";
PathHelper.Delete(path1);

ColorMCGui.Reboot();
Expand All @@ -57,7 +57,7 @@ public async Task ChangeRunDir()
return;
}

var path1 = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}/ColorMC/run";
var path1 = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/ColorMC/run";
PathHelper.WriteText(path1, path);

ColorMCGui.Reboot();
Expand Down
8 changes: 0 additions & 8 deletions src/ColorMC.Launcher/App.axaml

This file was deleted.

22 changes: 0 additions & 22 deletions src/ColorMC.Launcher/App.axaml.cs

This file was deleted.

21 changes: 5 additions & 16 deletions src/ColorMC.Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static class Program
public static void Main(string[] args)
{
#if !DEBUG
var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}/ColorMC/run";
var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/ColorMC/run";
if (File.Exists(path))
{
var dir = File.ReadAllText(path);
Expand Down Expand Up @@ -135,10 +135,9 @@ public static void Main(string[] args)
}
catch
{
//有没有权限写文件
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
return;
//没有权限写文件
_inputDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}/ColorMC/";
_inputDir = Path.GetFullPath(_inputDir);
}

_loadDir = _inputDir + "dll";
Expand All @@ -148,6 +147,7 @@ public static void Main(string[] args)
try
{
#if DEBUG
Gui.ColorMCGui.SetInputDir(AppContext.BaseDirectory);
Gui.ColorMCGui.Main(args);
#else

Expand Down Expand Up @@ -186,17 +186,6 @@ public static AppBuilder BuildAvaloniaApp()
return Gui.ColorMCGui.BuildAvaloniaApp();
}
#else
public static AppBuilder BuildAvaloniaApp()
{
return AppBuilder.Configure<App>()
.With(new FontManagerOptions
{
DefaultFamilyName = Font,
})
.LogToTrace()
.UsePlatformDetect();
}

#if !AOT
private static bool NotHaveDll()
{
Expand Down
64 changes: 0 additions & 64 deletions src/ColorMC.Launcher/Window1.axaml

This file was deleted.

67 changes: 0 additions & 67 deletions src/ColorMC.Launcher/Window1.axaml.cs

This file was deleted.

25 changes: 25 additions & 0 deletions src/ColorMC.Msi.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35208.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorMC.Setup.Wix", "ColorMC.Setup.Wix\ColorMC.Setup.Wix.csproj", "{0AAF6B64-6D7F-42F5-82BD-9E172A3F7761}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0AAF6B64-6D7F-42F5-82BD-9E172A3F7761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AAF6B64-6D7F-42F5-82BD-9E172A3F7761}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0AAF6B64-6D7F-42F5-82BD-9E172A3F7761}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AAF6B64-6D7F-42F5-82BD-9E172A3F7761}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2DC32020-288B-43AD-89E4-DB9EC993C539}
EndGlobalSection
EndGlobal
8 changes: 4 additions & 4 deletions src/ColorMC.Setup.Wix/ColorMC.Setup.Wix.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<DebugType>embedded</DebugType>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<Description>WiX WPF CustomUI Application</Description>
<Description>ColorMC Application</Description>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>WixSharp</RootNamespace>
<UseWPF>true</UseWPF>
Expand All @@ -28,8 +28,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="WixSharp-wix4.WPF" Version="2.1.5" />
<PackageReference Include="WixToolset.UI.wixext" Version="5.0.0" />
<PackageReference Include="WixSharp-wix4.WPF" Version="2.3.2" />
<PackageReference Include="WixToolset.UI.wixext" Version="5.0.1" />
</ItemGroup>


Expand Down
Loading

0 comments on commit f529f0b

Please sign in to comment.