Skip to content

Commit

Permalink
Merge pull request #2 from imxcstar/main
Browse files Browse the repository at this point in the history
修改macos上的样式和路径问题
  • Loading branch information
239573049 authored Dec 31, 2024
2 parents 109af46 + a84bb23 commit cefb125
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 185 deletions.
9 changes: 4 additions & 5 deletions src/ChatBox.Desktop.Macos/ChatBox.Desktop.Macos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ChatBox\ChatBox.csproj"/>
<ProjectReference Include="..\ChatBox\ChatBox.csproj">
<Properties>IsMac=true;MACOutputPath=$(ProjectDir)/$(OutputPath);MACAPPName=ChatBox.Desktop.Macos.app</Properties>
</ProjectReference>
</ItemGroup>



<ItemGroup>
<TrimmerRootDescriptor Include="Roots.xml" />
<Content Include="logo.ico" />
</ItemGroup>


<ItemGroup>
<None Remove="favicon.ico" />
<BundleResource Include="models.json" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/ChatBox.Desktop.Macos/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static void Main(string[] args)
try
{
AppDomain.CurrentDomain.UnhandledException += UnhandledException;
HostApplication.Builder();
NSApplication.Init();
NSApplication.SharedApplication.Delegate = new AppDelegate();
NSApplication.Main(args);
Expand Down
136 changes: 0 additions & 136 deletions src/ChatBox.Desktop.Macos/models.json

This file was deleted.

3 changes: 0 additions & 3 deletions src/ChatBox.Desktop/ChatBox.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,5 @@

<ItemGroup>
<None Remove="favicon.ico" />
<None Update="models.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions src/ChatBox/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.Styling;
using Avalonia.Platform;
using ChatBox.Views;

Expand All @@ -18,6 +19,14 @@ public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
if (OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst())
{
this.Styles.Add(new StyleInclude(new Uri("resm:Styles?assembly=ChatBox"))
{
Source = new Uri("avares://ChatBox/Styling/MacOSStyles.axaml")
});
}

BindingPlugins.DataValidators.RemoveAt(0);
desktop.MainWindow = HostApplication.Services.GetRequiredService<MainWindow>();

Expand Down
91 changes: 54 additions & 37 deletions src/ChatBox/ChatBox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,37 @@
</PropertyGroup>

<ItemGroup>
<AvaloniaResource Include="Assets\**" />
<AvaloniaResource Include="Assets\**"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="AIDotNet.AutoGpt" Version="1.0.10" />
<PackageReference Include="Avalonia" Version="11.2.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
<PackageReference Include="AIDotNet.AutoGpt" Version="1.0.10"/>
<PackageReference Include="Avalonia" Version="11.2.3"/>
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Dapper.AOT" Version="1.0.31" />
<PackageReference Include="FluentAvaloniaUI" Version="2.2.0" />
<PackageReference Include="MarkdownAIRender" Version="0.1.13" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.32.0" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.32.0" />
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.32.0" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Core" Version="1.32.0-alpha" />
<PackageReference Include="SharpToken" Version="2.0.3" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3"/>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/>
<PackageReference Include="Dapper" Version="2.1.35"/>
<PackageReference Include="Dapper.AOT" Version="1.0.31"/>
<PackageReference Include="FluentAvaloniaUI" Version="2.2.0"/>
<PackageReference Include="MarkdownAIRender" Version="0.1.13"/>
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.0"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0"/>
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.32.0"/>
<PackageReference Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.32.0"/>
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.32.0"/>
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Core" Version="1.32.0-alpha"/>
<PackageReference Include="SharpToken" Version="2.0.3"/>
</ItemGroup>

<ItemGroup>
<None Update="i18n\ChatBoxMarkdown.zh-Hant.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="models.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
Expand All @@ -37,37 +46,45 @@
<AutoGen>True</AutoGen>
<DependentUpon>Language.tt</DependentUpon>
</None>
</ItemGroup>

<ItemGroup>
<None Update="system.md">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<None Update="i18n\Language.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Language.cs</LastGenOutput>
</None>
<None Update="i18n\ChatBoxMarkdown.zh-Hant.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<BundleResource Include="i18n\ChatBoxMarkdown.zh-Hant.xml"/>
<BundleResource Include="models.json"/>
</ItemGroup>

<Target Name="CopyToMonoBundle" AfterTargets="Build" Condition="'$(IsMac)' == 'true'">
<Message Text="发布到macOS平台,执行资源拷贝。" Importance="high"/>
<Message Text="$(MACOutputPath)" Importance="high"/>
<Copy
SourceFiles="@(BundleResource)"
DestinationFolder="$(MACOutputPath)/$(MACAPPName)/Contents/MonoBundle"/>
</Target>

<Target Name="CopyToMonoBundleAfterPublish" AfterTargets="Publish" Condition="'$(IsMac)' == 'true'">
<Message Text="发布到macOS平台,执行资源拷贝。" Importance="high"/>
<Message Text="$(PublishDir)" Importance="high"/>
<Copy
SourceFiles="@(BundleResource)"
DestinationFolder="$(PublishDir)/$(MACAPPName)/Contents/MonoBundle"/>
</Target>

<ItemGroup>
<Compile Update="Controls\ActionBar\ActionBar.axaml.cs">
<DependentUpon>ActionBar.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Controls\ActionBar\ActionBar.axaml.cs">
<DependentUpon>ActionBar.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
<UpToDateCheckInput Remove="Controls\RenderMarkdown\RenderMarkdown.axaml" />
<UpToDateCheckInput Remove="Controls\RenderMarkdown\RenderMarkdown.axaml"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Markdown.AIRender\src\MarkdownAIRender\MarkdownAIRender.csproj" />
<ProjectReference Include="..\ChatBox.Logger\ChatBox.Logger.csproj" />
<ProjectReference Include="..\ChatBox.Logger\ChatBox.Logger.csproj"/>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/ChatBox/MenuKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public class MenuKeys

public const string MenuKeyTool = "Tool";

public const string MenuKeySetting = "Setting";
public const string MenuKeySetting = "Settings";
}
2 changes: 1 addition & 1 deletion src/ChatBox/Service/TokenService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public List<ModelDto> LoadModels()
{
FileInfo path;
if (OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst())
path = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "Contents", "Resources", "models.json"));
path = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "Contents", "MonoBundle", "models.json"));
else
path = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "models.json"));
if (!File.Exists(path.FullName))
Expand Down
6 changes: 6 additions & 0 deletions src/ChatBox/Styling/MacOSStyles.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="Window">
<Setter Property="Padding" Value="0 25 0 0"/>
</Style>
</Styles>
4 changes: 2 additions & 2 deletions src/ChatBox/i18n/Language.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
Expand All @@ -17,4 +17,4 @@ public static class MainWindow
public static readonly string ApplicationLanguageLabel = "Localization.MainWindow.ApplicationLanguageLabel";
public static readonly string ApplicationLanguageSelectPlaceholder = "Localization.MainWindow.ApplicationLanguageSelectPlaceholder";
}
}
}
File renamed without changes.

0 comments on commit cefb125

Please sign in to comment.