Commit 2705cb1f authored by 段廷瑞's avatar 段廷瑞

pref: 自动打包工具优化;WebKit重置尺寸强制刷新

parent e07d796b
...@@ -61,3 +61,4 @@ bin ...@@ -61,3 +61,4 @@ bin
/Tools/.claude/settings.local.json /Tools/.claude/settings.local.json
/.claude/settings.local.json /.claude/settings.local.json
/AppHome/ClaudeChat /AppHome/ClaudeChat
/CLAUDE.md
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
...@@ -38,7 +39,21 @@ namespace Ftt.PatchPack ...@@ -38,7 +39,21 @@ namespace Ftt.PatchPack
{ {
projects = ProjectHelp.Read(); projects = ProjectHelp.Read();
if (projects == null) projects = new Dictionary<string, Project>(); if (projects == null) projects = new Dictionary<string, Project>();
foreach (var cli in projects)
// 自愈:清理因重命名 Bug 产生的幽灵条目(Key 与 Project.Name 不一致的残留 Key)
var orphanKeys = new List<string>();
foreach (var kv in projects)
{
if (kv.Key != kv.Value.Name && projects.ContainsKey(kv.Value.Name))
orphanKeys.Add(kv.Key);
}
foreach (var key in orphanKeys)
projects.Remove(key);
if (orphanKeys.Count > 0)
ProjectHelp.Save(projects);
// 按名称字典序排序
foreach (var cli in projects.OrderBy(p => p.Key))
{ {
lstProject.Items.Add(cli.Key); lstProject.Items.Add(cli.Key);
} }
...@@ -114,16 +129,21 @@ namespace Ftt.PatchPack ...@@ -114,16 +129,21 @@ namespace Ftt.PatchPack
private void btnEdit_Click(object sender, EventArgs e) private void btnEdit_Click(object sender, EventArgs e)
{ {
var item = lstProject.SelectedItems; var items = lstProject.CheckedItems;
if (item.Count == 0) return; if (items.Count == 0)
{
MessageBox.Show("请勾选需要修改的项目!");
return;
}
if (projects.TryGetValue(item[0].Text, out Project project) && project != null) var item = items[0];
if (projects.TryGetValue(item.Text, out Project project) && project != null)
{ {
using (FrmProject frmProject = new FrmProject(projects, ref project)) using (FrmProject frmProject = new FrmProject(projects, ref project))
{ {
if (frmProject.ShowDialog() == DialogResult.Yes) if (frmProject.ShowDialog() == DialogResult.Yes)
{ {
item[0].Text = project.Name; item.Text = project.Name;
} }
} }
} }
...@@ -134,7 +154,7 @@ namespace Ftt.PatchPack ...@@ -134,7 +154,7 @@ namespace Ftt.PatchPack
var items = lstProject.CheckedItems; var items = lstProject.CheckedItems;
if (items.Count == 0) if (items.Count == 0)
{ {
MessageBox.Show("请选择需要删除的项目!"); MessageBox.Show("请勾选需要删除的项目!");
return; return;
} }
if (MessageBox.Show($"是否确定要删除勾选的 {items.Count} 个项目?", "询问", MessageBoxButtons.YesNo) != DialogResult.Yes) return; if (MessageBox.Show($"是否确定要删除勾选的 {items.Count} 个项目?", "询问", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
...@@ -145,7 +165,13 @@ namespace Ftt.PatchPack ...@@ -145,7 +165,13 @@ namespace Ftt.PatchPack
projects.TryGetValue(item.Text, out Project project); projects.TryGetValue(item.Text, out Project project);
if (project != null && projects.ContainsKey(project.Name)) projects.Remove(project.Name); // 优先按项目对象当前名称移除;如果已存在旧 Key 残留,也一并清理
if (project != null && projects.ContainsKey(project.Name))
projects.Remove(project.Name);
// 兜底:如果字典中仍存在 item.Text 对应的键(如幽灵条目),也一并移除
if (projects.ContainsKey(item.Text))
projects.Remove(item.Text);
lstProject.Items.Remove(item); lstProject.Items.Remove(item);
} }
......
...@@ -8,6 +8,7 @@ namespace Ftt.PatchPack ...@@ -8,6 +8,7 @@ namespace Ftt.PatchPack
{ {
Project project = null; Project project = null;
Dictionary<string, Project> dictionary; Dictionary<string, Project> dictionary;
string originalName = null; // 记录编辑前的原始名称,用于重命名时清理旧 Key
private FrmProject() private FrmProject()
{ {
...@@ -24,7 +25,7 @@ namespace Ftt.PatchPack ...@@ -24,7 +25,7 @@ namespace Ftt.PatchPack
public FrmProject(Dictionary<string, Project> dictionary, ref Project project) : this() public FrmProject(Dictionary<string, Project> dictionary, ref Project project) : this()
{ {
this.project = project; this.project = project;
this.originalName = project.Name; // 记录原始名称
this.dictionary = dictionary; this.dictionary = dictionary;
} }
...@@ -122,6 +123,12 @@ namespace Ftt.PatchPack ...@@ -122,6 +123,12 @@ namespace Ftt.PatchPack
project.RelativeDbFilePath = txtRelativeDbFilePath.Text.Trim(); project.RelativeDbFilePath = txtRelativeDbFilePath.Text.Trim();
project.Name = txtProjectName.Text.Trim(); project.Name = txtProjectName.Text.Trim();
// 如果名称已变更,先移除旧 Key 防止幽灵条目
if (originalName != null && originalName != project.Name)
{
dictionary.Remove(originalName);
}
if (this.dictionary.ContainsKey(project.Name)) if (this.dictionary.ContainsKey(project.Name))
{ {
if (dictionary[project.Name] != project //如果是同一个对象,则不需要提示 if (dictionary[project.Name] != project //如果是同一个对象,则不需要提示
......
...@@ -72,6 +72,21 @@ namespace WebKit ...@@ -72,6 +72,21 @@ namespace WebKit
ShowToolBar = pnlToolBar.Visible = ToBool(ConfigurationManager.AppSettings["ShowToolBar"]); ShowToolBar = pnlToolBar.Visible = ToBool(ConfigurationManager.AppSettings["ShowToolBar"]);
InitWebKit(null); InitWebKit(null);
// 修复全屏/最大化时 CEF 渲染区域不跟随缩放的问题
this.ResizeEnd += FrmWeb_ResizeEnd;
}
}
/// <summary>
/// 窗口大小变化结束时强制刷新 CEF 内部渲染区域,
/// 解决全屏/最大化时右下角黑色区域问题。
/// </summary>
private void FrmWeb_ResizeEnd(object sender, EventArgs e)
{
if (browser != null && panel1.Controls.Contains(browser))
{
browser.Size = panel1.ClientSize;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment