improve:启动速度
This commit is contained in:
+8
-23
@@ -775,10 +775,9 @@ namespace Ink_Canvas
|
|||||||
// 根据设置决定是否显示启动画面
|
// 根据设置决定是否显示启动画面
|
||||||
if (ShouldShowSplashScreen() && !IsLaunchByFileOrUri(e.Args))
|
if (ShouldShowSplashScreen() && !IsLaunchByFileOrUri(e.Args))
|
||||||
{
|
{
|
||||||
await Task.Delay(100);
|
|
||||||
ShowSplashScreen();
|
ShowSplashScreen();
|
||||||
SetSplashMessage(Strings.GetString("Splash_Starting"));
|
SetSplashMessage(Strings.GetString("Splash_Starting"));
|
||||||
SetSplashProgress(20);
|
SetSplashProgress(25);
|
||||||
|
|
||||||
// 强制刷新UI,确保启动画面显示
|
// 强制刷新UI,确保启动画面显示
|
||||||
Application.Current.Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
|
Application.Current.Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
|
||||||
@@ -815,24 +814,12 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile("App | 检测到最终应用启动(更新后的应用)");
|
LogHelper.WriteLogToFile("App | 检测到最终应用启动(更新后的应用)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 释放IACore相关DLL
|
|
||||||
if (_isSplashScreenShown)
|
|
||||||
{
|
|
||||||
SetSplashMessage("正在初始化组件...");
|
|
||||||
SetSplashProgress(40);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 释放UIAccess DLL
|
|
||||||
if (_isSplashScreenShown)
|
|
||||||
{
|
|
||||||
SetSplashMessage("正在初始化组件...");
|
|
||||||
SetSplashProgress(50);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isSplashScreenShown)
|
if (_isSplashScreenShown)
|
||||||
{
|
{
|
||||||
SetSplashMessage("正在加载配置...");
|
SetSplashMessage("正在加载配置...");
|
||||||
SetSplashProgress(60);
|
SetSplashProgress(50);
|
||||||
|
await Task.Delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理更新模式启动
|
// 处理更新模式启动
|
||||||
@@ -1105,7 +1092,7 @@ namespace Ink_Canvas
|
|||||||
if (_isSplashScreenShown)
|
if (_isSplashScreenShown)
|
||||||
{
|
{
|
||||||
SetSplashMessage("正在初始化主界面...");
|
SetSplashMessage("正在初始化主界面...");
|
||||||
SetSplashProgress(80);
|
SetSplashProgress(75);
|
||||||
}
|
}
|
||||||
var mainWindow = new MainWindow();
|
var mainWindow = new MainWindow();
|
||||||
MainWindow = mainWindow;
|
MainWindow = mainWindow;
|
||||||
@@ -1150,16 +1137,14 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
if (_isSplashScreenShown)
|
if (_isSplashScreenShown)
|
||||||
{
|
{
|
||||||
SetSplashMessage("完成初始化...");
|
SetSplashMessage("启动完成!");
|
||||||
SetSplashProgress(80);
|
SetSplashProgress(100);
|
||||||
Task.Delay(300).ContinueWith(_ =>
|
Task.Delay(100).ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
SetSplashMessage("启动完成!");
|
|
||||||
SetSplashProgress(100);
|
|
||||||
// 延迟关闭启动画面,让用户看到完成消息
|
// 延迟关闭启动画面,让用户看到完成消息
|
||||||
Task.Delay(500).ContinueWith(__ =>
|
Task.Delay(100).ContinueWith(__ =>
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(() => CloseSplashScreen());
|
Dispatcher.Invoke(() => CloseSplashScreen());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using System.Windows;
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using System.Windows.Threading;
|
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows
|
namespace Ink_Canvas.Windows
|
||||||
{
|
{
|
||||||
@@ -15,16 +14,7 @@ namespace Ink_Canvas.Windows
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SplashScreen : Window
|
public partial class SplashScreen : Window
|
||||||
{
|
{
|
||||||
private DispatcherTimer _timer;
|
|
||||||
private int _loadingStep = 0;
|
|
||||||
private int _actualSplashStyle = 1;
|
private int _actualSplashStyle = 1;
|
||||||
private readonly string[] _loadingMessages = {
|
|
||||||
"正在启动 Ink Canvas...",
|
|
||||||
"正在初始化组件...",
|
|
||||||
"正在加载配置...",
|
|
||||||
"正在准备界面...",
|
|
||||||
"启动完成!"
|
|
||||||
};
|
|
||||||
|
|
||||||
public SplashScreen()
|
public SplashScreen()
|
||||||
{
|
{
|
||||||
@@ -42,33 +32,6 @@ namespace Ink_Canvas.Windows
|
|||||||
|
|
||||||
// 加载启动图片并获取实际样式
|
// 加载启动图片并获取实际样式
|
||||||
_actualSplashStyle = LoadSplashImageWithStyle();
|
_actualSplashStyle = LoadSplashImageWithStyle();
|
||||||
|
|
||||||
// 启动加载动画
|
|
||||||
StartLoadingAnimation();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StartLoadingAnimation()
|
|
||||||
{
|
|
||||||
_timer = new DispatcherTimer
|
|
||||||
{
|
|
||||||
Interval = TimeSpan.FromMilliseconds(1200)
|
|
||||||
};
|
|
||||||
_timer.Tick += Timer_Tick;
|
|
||||||
_timer.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Timer_Tick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_loadingStep < _loadingMessages.Length)
|
|
||||||
{
|
|
||||||
LoadingText.Text = _loadingMessages[_loadingStep];
|
|
||||||
_loadingStep++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_timer.Stop();
|
|
||||||
// 不要自动关闭启动画面,等待外部调用CloseSplashScreen
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloseSplashScreen()
|
public void CloseSplashScreen()
|
||||||
|
|||||||
Reference in New Issue
Block a user