Fix relocated desktop tool paths and package release 0.2.2
This commit is contained in:
1 parent
efaf16de18
commit
e366eb5bec
14 files changed
+250
-33
No files matched your search
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><Version>0.2.1</Version><OutputType>WinExe</OutputType><TargetFramework>net8.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>
|
||||
<PropertyGroup><Version>0.2.2</Version><OutputType>WinExe</OutputType><TargetFramework>net8.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>
|
||||
<ItemGroup><PackageReference Include="Avalonia.Desktop" Version="11.3.8"/><PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.8"/><PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/></ItemGroup>
|
||||
<ItemGroup><AvaloniaResource Include="Assets/**"/></ItemGroup></Project>
|
||||
@@ -104,8 +104,10 @@ public static class DesktopPaths
|
||||
public static string ResolveTool(string value, string name)
|
||||
{
|
||||
value = Environment.ExpandEnvironmentVariables(value.Trim().Trim('"'));
|
||||
if (File.Exists(value)) return Path.GetFullPath(value);
|
||||
if (value == name || value == name + ".exe")
|
||||
var installed = value.Replace('\\', '/');
|
||||
var managed = System.Text.RegularExpressions.Regex.IsMatch(installed, @"/Programs/(TTSTD|TongTongStudio)/ADS-(Flutter|Avalonia)/", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
||||
if (File.Exists(value) && !managed) return Path.GetFullPath(value);
|
||||
if (managed || !File.Exists(value))
|
||||
{
|
||||
var found = FindTool(name);
|
||||
if (File.Exists(found)) return Path.GetFullPath(found);
|
||||
|
||||
@@ -97,6 +97,18 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
||||
preferredDevice = settings.PreferredDevice;
|
||||
}
|
||||
catch (Exception error) { Log("读取配置失败,使用默认值:" + error.Message); }
|
||||
if (File.Exists(settingsFile)) {
|
||||
var changed=false;
|
||||
string Repair(string value,string name) {
|
||||
try {
|
||||
var resolved=DesktopPaths.ResolveTool(value,name);
|
||||
if(resolved!=value){changed=true;Log($"已更新 {name} 工具位置:{resolved}");}
|
||||
return resolved;
|
||||
} catch(InvalidOperationException) { return value; }
|
||||
}
|
||||
ClientPath=Repair(ClientPath,"ads-client");AdbPath=Repair(AdbPath,"adb");ScrcpyPath=Repair(ScrcpyPath,"scrcpy");
|
||||
if(changed)PersistSelectedPaths();
|
||||
}
|
||||
var environmentToken = loadLocalCredentials ? Environment.GetEnvironmentVariable("ADS_CLIENT_TOKEN") : null;
|
||||
if (!string.IsNullOrWhiteSpace(environmentToken))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user