Skip to content

Commit

Permalink
fix: builed chinese bug, transfrom to utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Jun 26, 2024
1 parent 2dd09a5 commit 52efcbb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
<EmbeddedResource Include="Resources\logo.png" />
</ItemGroup>

<ItemGroup>
<None Update="zh\**\*">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MDriveSync.Client.App\MDriveSync.Client.App.csproj" />
</ItemGroup>
Expand Down
22 changes: 11 additions & 11 deletions src/MDriveSync.Client.WinFormAPI/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Web.WebView2.WinForms;
using System.Reflection;

Expand All @@ -16,15 +16,15 @@ public MainForm()
{
InitializeComponent();

// 从配置文件中读取 URL,如果没有则使用默认值
// 从配置文件中读取 URL,如果没有则使用默认值
var configuration = Program.Configuration;
apiUrl = configuration.GetValue<string>("urls")?.Replace("*", "localhost") ?? "http://localhost:8080";

// Initialize WebView2
webView = new WebView2
{
Dock = DockStyle.Fill,
Source = new Uri($"{apiUrl}") // 指向 Web API 的 URL
Source = new Uri($"{apiUrl}") // 指向 Web API 的 URL
};
this.Controls.Add(webView);

Expand All @@ -36,14 +36,14 @@ public MainForm()
Visible = true
};

// 使用资源中的 PNG 图像
// 使用资源中的 PNG 图像
this.Icon = LoadIconFromResource("MDriveSync.Client.WinFormAPI.Resources.logo.png", 64, 64);

notifyIcon.DoubleClick += NotifyIcon_DoubleClick;

// Initialize ContextMenuStrip
contextMenuStrip = new ContextMenuStrip();
exitMenuItem = new ToolStripMenuItem("退出", null, ExitMenuItem_Click);
exitMenuItem = new ToolStripMenuItem("退出", null, ExitMenuItem_Click);
contextMenuStrip.Items.Add(exitMenuItem);
notifyIcon.ContextMenuStrip = contextMenuStrip;

Expand All @@ -70,17 +70,17 @@ protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true; // 取消关闭操作
this.WindowState = FormWindowState.Minimized; // 最小化窗口
this.Hide(); // 隐藏窗口
notifyIcon.Visible = true; // 显示 NotifyIcon
e.Cancel = true; // 取消关闭操作
this.WindowState = FormWindowState.Minimized; // 最小化窗口
this.Hide(); // 隐藏窗口
notifyIcon.Visible = true; // 显示 NotifyIcon
}
}

private void ExitMenuItem_Click(object sender, EventArgs e)
{
notifyIcon.Visible = false;
notifyIcon.Dispose(); // 确保图标被释放
notifyIcon.Dispose(); // 确保图标被释放
Application.Exit();
}

Expand Down Expand Up @@ -121,4 +121,4 @@ private Icon LoadIconFromResource(string resourceName)
}
}
}
}
}
8 changes: 4 additions & 4 deletions src/MDriveSync.Client.WinFormAPI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand Down Expand Up @@ -30,11 +30,11 @@ public static IHostBuilder CreateHostBuilder() =>
{
var env = context.HostingEnvironment;
// 添加 appsettings.json 配置文件
// 添加 appsettings.json 配置文件
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
// 添加环境变量
// 添加环境变量
config.AddEnvironmentVariables();
})
.ConfigureWebHostDefaults(webBuilder =>
Expand All @@ -54,4 +54,4 @@ public static IHostBuilder CreateHostBuilder() =>
}
});
}
}
}

0 comments on commit 52efcbb

Please sign in to comment.