diff --git a/EPUBium Desktop/EPUBium Desktop.csproj b/EPUBium Desktop/EPUBium Desktop.csproj
index d5d049b..795af38 100644
--- a/EPUBium Desktop/EPUBium Desktop.csproj
+++ b/EPUBium Desktop/EPUBium Desktop.csproj
@@ -87,11 +87,14 @@
..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll
-
- ..\packages\Microsoft.Web.WebView2.1.0.1108.44\lib\net45\Microsoft.Web.WebView2.Core.dll
+
+ ..\packages\Microsoft.Web.WebView2.1.0.1264.42\lib\net45\Microsoft.Web.WebView2.Core.dll
-
- ..\packages\Microsoft.Web.WebView2.1.0.1108.44\lib\net45\Microsoft.Web.WebView2.WinForms.dll
+
+ ..\packages\Microsoft.Web.WebView2.1.0.1264.42\lib\net45\Microsoft.Web.WebView2.WinForms.dll
+
+
+ ..\packages\Microsoft.Web.WebView2.1.0.1264.42\lib\net45\Microsoft.Web.WebView2.Wpf.dll
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll
@@ -188,12 +191,12 @@
这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
-
+
cd "$(ProjectDir)htdocs"
"$(ProjectDir)zip.exe" -r -0 ..\htdocs.pak .
-
+
\ No newline at end of file
diff --git a/EPUBium Desktop/Form1.cs b/EPUBium Desktop/Form1.cs
index b8ad3e0..3084e71 100644
--- a/EPUBium Desktop/Form1.cs
+++ b/EPUBium Desktop/Form1.cs
@@ -51,13 +51,20 @@ public Form1()
}
+ private string startUrl = null;
+
+ public Form1(string startUrl) : this()
+ {
+ this.startUrl = startUrl;
+ }
+
private void WebView2_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
{
if (e.IsSuccess)
{
webView = webViewControl.CoreWebView2;
initWebView2();
- webViewControl.Source = new Uri("http://epub.zyf-internal.com");
+ webViewControl.Source = new Uri(startUrl ?? "http://epub.zyf-internal.com");
webViewControl.NavigationCompleted += WebViewControl_NavigationCompleted;
}
else
@@ -137,6 +144,29 @@ void initWebView2()
resourceHandler = new ResourceHandler(webView.Environment);
webView.WebResourceRequested += WebView_WebResourceRequested;
webView.FrameNavigationStarting += WebView_FrameNavigationStarting;
+ webView.ContextMenuRequested += WebView_ContextMenuRequested;
+ webView.NewWindowRequested += WebView_NewWindowRequested;
+ }
+
+ private void WebView_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e)
+ {
+ if (e.Uri.StartsWith(urlbase))
+ {
+ e.Handled = true;
+ new Form1(e.Uri).Show();
+ }
+ }
+
+ private void WebView_ContextMenuRequested(object sender, CoreWebView2ContextMenuRequestedEventArgs e)
+ {
+ CoreWebView2ContextMenuItem changeSkin = webView.Environment.CreateContextMenuItem("更换主题包", null, CoreWebView2ContextMenuItemKind.Command);
+ changeSkin.CustomItemSelected += onChangeSkinClicked;
+ e.MenuItems.Add(changeSkin);
+ }
+
+ private void onChangeSkinClicked(object sender, object e)
+ {
+ new FrmChangeResource().ShowDialog(this);
}
private void WebView_FrameNavigationStarting(object sender, CoreWebView2NavigationStartingEventArgs e)
diff --git a/EPUBium Desktop/Program.cs b/EPUBium Desktop/Program.cs
index 837cd9f..f389f62 100644
--- a/EPUBium Desktop/Program.cs
+++ b/EPUBium Desktop/Program.cs
@@ -32,6 +32,28 @@ static int Main(string[] args)
try
{
+ string bookToOpen = null;
+ if(args.Length != 0)
+ {
+ try
+ {
+ bookToOpen = Path.GetFullPath(args[0]);
+ }catch(Exception ex) { }
+ }
+ Environment.CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath);
+ if(bookToOpen != null)
+ {
+ if (File.Exists(bookToOpen))
+ {
+
+ }
+ else
+ {
+ MessageBox.Show("系统找不到指定的文件:"+bookToOpen,Application.ProductName);
+ return 114;
+ }
+ }
+
ensureDirectoryExists(
"app",
"app\\data",
@@ -44,9 +66,19 @@ static int Main(string[] args)
loadResPack();
DBUtils = new DBUtils();
ApiModel = new ApiModel();
+ ApiModel.OpenFromFilePath = bookToOpen;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
+ if(bookToOpen != null)
+ {
+
+ Application.Run(new Form1("http://epub.zyf-internal.com/read/SHELL/read.html"));
+ }
+ else
+ {
+
+ Application.Run(new Form1());
+ }
}
catch (Exception ex)
@@ -206,6 +238,9 @@ public class ApiModel
{
private MyPakFile openingBook = null;
+ public string OpenFromFilePath = null;
+
+
public ApiResponse callApi(string pathWithUrl)
{
int ptr = pathWithUrl.IndexOf("?");
@@ -418,19 +453,34 @@ public ApiResponse handlePathReadRequest(string bookuuid,string apipath, Diction
return new ApiResponse(ApiResponseType.ErrorNotFound, "404 Not Found");
}
Context appContext = null;
+
+ const string OpenFromFileUUID = "shell";
+
private ApiResponse handlePathReadApiRequest(string bookuuid, string api, Dictionary param)
{
if (api.StartsWith("bmload/"))
{
+ if(bookuuid.ToLower() == OpenFromFileUUID)
+ {
+ return newFixedLengthResponse(JsonConvert.SerializeObject(new BookMark(-1, bookuuid, 0, "", "无存档", -1)));
+ }
int requestId = int.Parse(api.Replace("bmload/",""));
return newFixedLengthResponse(JsonConvert.SerializeObject(Program.DBUtils.queryBookmarks(appContext, bookuuid)[requestId]));
}
if (api==("bmloadall"))
{
+ if (bookuuid.ToLower() == OpenFromFileUUID)
+ {
+ return newFixedLengthResponse("[]");
+ }
return newFixedLengthResponse(JsonConvert.SerializeObject(Program.DBUtils.queryBookmarks(appContext, bookuuid)));
}
if (api.StartsWith("bmsave/"))
{
+ if (bookuuid.ToLower() == OpenFromFileUUID)
+ {
+ return newFixedLengthResponse("OK");
+ }
int requestId = int.Parse(api.Replace("bmsave/", ""));
String name = param["name"];
@@ -440,6 +490,10 @@ private ApiResponse handlePathReadApiRequest(string bookuuid, string api, Dictio
}
if (api==("bookname"))
{
+ if (bookuuid.ToLower() == OpenFromFileUUID)
+ {
+ return newFixedLengthResponse((OpenFromFilePath)) ;
+ }
return newFixedLengthResponse(Program.DBUtils.queryBooks("uuid = ?", bookuuid).First().getDisplayName());
}
if (api == ("close"))
@@ -463,11 +517,21 @@ private ApiResponse handlePathReadBookRequest(string bookuuid, string api, Dicti
}
if (openingBook == null)
{
- string path = Program.DBUtils.queryBooks("uuid = ?", bookuuid).First().getPath();
- openingBook = new MyPakFile(path)
+ if (bookuuid.ToLower() == OpenFromFileUUID)
{
- Tag = bookuuid
- };
+ openingBook = new MyPakFile(OpenFromFilePath)
+ {
+ Tag = bookuuid
+ };
+ }
+ else
+ {
+ string path = Program.DBUtils.queryBooks("uuid = ?", bookuuid).First().getPath();
+ openingBook = new MyPakFile(path)
+ {
+ Tag = bookuuid
+ };
+ }
}
api = HttpUtility.UrlDecode(api);
Stream stream = openingBook.OpenRead(api);
diff --git a/EPUBium Desktop/Properties/AssemblyInfo.cs b/EPUBium Desktop/Properties/AssemblyInfo.cs
index 5dfb860..78bd0d7 100644
--- a/EPUBium Desktop/Properties/AssemblyInfo.cs
+++ b/EPUBium Desktop/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.0.1.1")]
-[assembly: AssemblyFileVersion("3.0.1.1")]
+[assembly: AssemblyVersion("3.0.2.0")]
+[assembly: AssemblyFileVersion("3.0.2.0")]
diff --git a/EPUBium Desktop/htdocs.pak b/EPUBium Desktop/htdocs.pak
index 8ecc619..8caf912 100644
Binary files a/EPUBium Desktop/htdocs.pak and b/EPUBium Desktop/htdocs.pak differ
diff --git a/EPUBium Desktop/packages.config b/EPUBium Desktop/packages.config
index 834862f..7287a3c 100644
--- a/EPUBium Desktop/packages.config
+++ b/EPUBium Desktop/packages.config
@@ -1,6 +1,6 @@
-
+