Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 9d1d686

Browse files
committed
增加启动界面,修复一些 BUG
1 parent 6c97699 commit 9d1d686

11 files changed

Lines changed: 320 additions & 31 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,5 @@ __pycache__/
296296

297297
# my rules
298298
local
299+
300+
Nacollector/GlobalConstant.cs

Nacollector/Browser/Handler/MenuHandler.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public MenuHandler(bool showReload = false)
2424
private const int SaveLink = 26504;
2525
private const int CopyLink = 26505;
2626
private const int LinkOpenDefaultBrowser = 26506;
27+
private const int LinkToZneiatProject = 26507;
28+
private const int FeedbackProject = 26508;
2729

2830
void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
2931
{
@@ -77,7 +79,9 @@ void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowse
7779
{
7880
if (_showReload)
7981
model.AddItem(CefMenuCommand.ReloadNoCache, "刷新 (ReloadNoCache)");
80-
model.AddItem((CefMenuCommand)ShowDevTools, "检查 (ShowDevTools)");
82+
model.AddItem((CefMenuCommand)FeedbackProject, "反馈问题");
83+
model.AddItem((CefMenuCommand)LinkToZneiatProject, "开源项目");
84+
// model.AddItem((CefMenuCommand)ShowDevTools, "检查 (ShowDevTools)");
8185
}
8286
}
8387

@@ -108,6 +112,12 @@ bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser browserControl, IBrows
108112
case LinkOpenDefaultBrowser:
109113
System.Diagnostics.Process.Start("explorer.exe", parameters.UnfilteredLinkUrl);
110114
break;
115+
case LinkToZneiatProject:
116+
System.Diagnostics.Process.Start("https://github.com/Zneiat/Nacollector");
117+
break;
118+
case FeedbackProject:
119+
System.Diagnostics.Process.Start("https://github.com/Zneiat/Nacollector/issues");
120+
break;
111121
}
112122

113123
return false;

Nacollector/GlobalConstant.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

Nacollector/MainForm.cs

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ private void InitSkin()
4848

4949
private void MainForm_Load(object sender, EventArgs e)
5050
{
51-
// 设置窗体透明
52-
SetOpacity(0);
51+
// 程序启动画面
52+
SetIsStarting(true);
5353
}
5454

5555
private void InitBrowser()
@@ -67,14 +67,14 @@ private void InitBrowser()
6767
crBrowser.GetBrowser().FrameLoadEnd += new EventHandler<FrameLoadEndEventArgs>(Browser_FrameLoadEnd); // 浏览器初始化完毕时执行
6868

6969
crDownloads = new CrDownloads(crBrowser);
70-
70+
7171
ContentPanel.Controls.Add(crBrowser.GetBrowser());
7272
}
73-
73+
7474
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
7575
{
76-
// 取消设置窗体透明
77-
SetOpacity(1);
76+
// 关闭程序启动画面
77+
SetIsStarting(false);
7878
}
7979

8080
/// <summary>
@@ -85,9 +85,15 @@ public class AppActionForJs
8585
// 获取程序版本
8686
public string getVersion()
8787
{
88+
crBrowser.RunJS($"AppConfig.updateCheckUrl=\"{GlobalConstant.UpdateCheckUrl}\";AppConfig.updateCheckToken=\"{GlobalConstant.UpdateCheckToken}\"");
8889
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
8990
}
9091

92+
public void showDevTools()
93+
{
94+
crBrowser.GetBrowser().ShowDevTools();
95+
}
96+
9197
// 采集是否使用IE代理请求
9298
public void _utilsReqIeProxy(bool isEnable)
9399
{
@@ -210,16 +216,40 @@ public void StartTask(object obj)
210216
Utils.ReleaseMemory(true);
211217
}
212218

219+
220+
private Form startingForm;
221+
213222
/// <summary>
214-
/// 设置窗体透明度
223+
/// 设置程序启动画面
215224
/// </summary>
216-
public void SetOpacity(int value)
225+
public void SetIsStarting(bool isStarting)
217226
{
218-
if (this.InvokeRequired) { this.Invoke(new SetOpacityDelegate(SetOpacity), new object[] { value }); return; }
227+
if (this.InvokeRequired) { this.Invoke(new SetIsStartingDelegate(SetIsStarting), new object[] { isStarting }); return; }
219228

220-
this.Opacity = value;
229+
if (isStarting)
230+
{
231+
startingForm = new Form
232+
{
233+
Size = new Size(640, 400),
234+
TopMost = true,
235+
ControlBox = false,
236+
ShowInTaskbar = false,
237+
AutoSizeMode = AutoSizeMode.GrowAndShrink,
238+
FormBorderStyle = FormBorderStyle.None,
239+
StartPosition = FormStartPosition.CenterScreen,
240+
BackgroundImageLayout = ImageLayout.Zoom,
241+
BackgroundImage = Properties.Resources.StartingImg
242+
};
243+
startingForm.Show();
244+
this.Opacity = 0;
245+
} else
246+
{
247+
startingForm.Hide();
248+
this.Opacity = 1;
249+
}
250+
221251
}
222-
public delegate void SetOpacityDelegate(int value);
252+
public delegate void SetIsStartingDelegate(bool isStarting);
223253

224254
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
225255
{

Nacollector/Nacollector.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
<Content Include="Resources\html_res\assets\material-design-iconic-font.min.css">
248248
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
249249
</Content>
250+
<None Include="Resources\StartingImg.png" />
250251
<EmbeddedResource Include="MainForm.resx">
251252
<DependentUpon>MainForm.cs</DependentUpon>
252253
</EmbeddedResource>

Nacollector/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
3434
// 方法是按如下所示使用“*”: :
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("1.1.0.0")]
37-
[assembly: AssemblyFileVersion("1.1.0.0")]
36+
[assembly: AssemblyVersion("1.2.0.0")]
37+
[assembly: AssemblyFileVersion("1.2.0.0")]
3838
[assembly: NeutralResourcesLanguage("zh-Hans")]
3939

Nacollector/Properties/Resources.Designer.cs

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)