Skip to content

Commit

Permalink
修复未安装webview2后不提示的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYFDroid committed Apr 12, 2022
1 parent b1ece1c commit 9b583cb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 44 deletions.
49 changes: 19 additions & 30 deletions EPUBium Desktop/EPUBium Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
Expand Down Expand Up @@ -161,36 +180,6 @@
<None Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="htdocs\common\img\bg_drawer_head.png" />
<Content Include="htdocs\common\img\bm_bg.png" />
<Content Include="htdocs\common\img\ic_launcher_round.png" />
<Content Include="htdocs\common\img\ic_list_go.png" />
<Content Include="htdocs\common\img\ic_menu_about.png" />
<Content Include="htdocs\common\img\ic_menu_bookmark.png" />
<Content Include="htdocs\common\img\ic_menu_bookmark_lock.png" />
<Content Include="htdocs\common\img\ic_menu_bookmark_unlock.png" />
<Content Include="htdocs\common\img\ic_menu_chapters.png" />
<Content Include="htdocs\common\img\ic_menu_daylight.png" />
<Content Include="htdocs\common\img\ic_menu_folder.png" />
<Content Include="htdocs\common\img\ic_menu_load.png" />
<Content Include="htdocs\common\img\ic_menu_reload.png" />
<Content Include="htdocs\common\img\ic_menu_rescan.png" />
<Content Include="htdocs\common\img\ic_menu_save.png" />
<Content Include="htdocs\common\img\ic_menu_searchinlibrary.png" />
<Content Include="htdocs\common\img\ic_menu_setting.png" />
<Content Include="htdocs\common\img\ic_menu_textsize.png" />
<Content Include="htdocs\common\img\menu.png" />
<Content Include="htdocs\common\img\slider_handle.png" />
<Content Include="htdocs\common\lib\jquery-3.6.0.js" />
<Content Include="htdocs\common\lib\sweetalert.min.js" />
<Content Include="htdocs\common\lib\vue-lazyload.js" />
<Content Include="htdocs\common\lib\vue.js" />
<Content Include="htdocs\common\style.css" />
<Content Include="htdocs\epubjs\read.html" />
<Content Include="htdocs\epubjs\static\epub.js" />
<Content Include="htdocs\epubjs\static\index.html" />
<Content Include="htdocs\favicon.ico" />
<Content Include="htdocs\index.html" />
<None Include="Resources\default.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
30 changes: 20 additions & 10 deletions EPUBium Desktop/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,26 @@ public Form1()
InitializeComponent();
this.BackColor = Color.White;
this.Icon = Properties.Resources.icon;

webViewControl = new WebView2();
Task<CoreWebView2Environment> createEnvTask = CoreWebView2Environment.CreateAsync(userDataFolder: Path.GetFullPath("app\\data\\cefdata"));
createEnvTask.Wait();
CoreWebView2Environment env = createEnvTask.Result;
Controls.Add(webViewControl);
webViewControl.Dock = DockStyle.Fill;
webViewControl.EnsureCoreWebView2Async(env);
webViewControl.CoreWebView2InitializationCompleted += WebView2_CoreWebView2InitializationCompleted;

try
{
webViewControl = new WebView2();
Task<CoreWebView2Environment> createEnvTask = CoreWebView2Environment.CreateAsync(userDataFolder: Path.GetFullPath("app\\data\\cefdata"));
createEnvTask.Wait();
CoreWebView2Environment env = createEnvTask.Result;
Controls.Add(webViewControl);
webViewControl.Dock = DockStyle.Fill;
webViewControl.EnsureCoreWebView2Async(env);
webViewControl.CoreWebView2InitializationCompleted += WebView2_CoreWebView2InitializationCompleted;
}catch (Exception ex)
{
if(ex.InnerException is WebView2RuntimeNotFoundException)
{
MessageBox.Show("此计算机上没有安装WebView2运行时。\r\n访问:https://developer.microsoft.com/zh-cn/microsoft-edge/webview2/consumer/ 获取运行时", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
string runtimeDownloadUrl = "https://developer.microsoft.com/zh-cn/microsoft-edge/webview2/consumer/";
Process.Start(runtimeDownloadUrl);
Application.Exit();
}
}
Disposed += Form1_Disposed;

}
Expand Down
2 changes: 2 additions & 0 deletions EPUBium Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ static int Main(string[] args)
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());

}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(),"出现错误");
File.WriteAllText("" + DateTime.Now.Ticks + ".log", String.Join(" ", args) + Environment.NewLine + ex.ToString());
return 127;
}
Expand Down
4 changes: 2 additions & 2 deletions EPUBium Desktop/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.1.0")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyVersion("3.0.1.1")]
[assembly: AssemblyFileVersion("3.0.1.1")]
Binary file modified EPUBium Desktop/htdocs.pak
Binary file not shown.
10 changes: 8 additions & 2 deletions EPUBiumDesktop.sln
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31313.79
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EPUBium Desktop", "EPUBium Desktop\EPUBium Desktop.csproj", "{9822C1C8-9B97-40E9-A904-9C31F80FA753}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Debug|x64.ActiveCfg = Debug|x64
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Debug|x64.Build.0 = Debug|x64
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Debug|x86.ActiveCfg = Debug|x86
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Debug|x86.Build.0 = Debug|x86
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Release|Any CPU.Build.0 = Release|Any CPU
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Release|x64.ActiveCfg = Release|x64
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Release|x64.Build.0 = Release|x64
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Release|x86.ActiveCfg = Release|x86
{9822C1C8-9B97-40E9-A904-9C31F80FA753}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 9b583cb

Please sign in to comment.