1
0
mirror of https://github.com/Tim-Paik/neutauri.git synced 2024-10-12 23:29:41 +00:00
This commit is contained in:
2023-03-24 21:40:29 +08:00
parent 1bebb857ee
commit 167bee14e7
10 changed files with 483 additions and 469 deletions

View File

@ -1,7 +1,7 @@
#![windows_subsystem = "windows"]
use neutauri_data as data;
use std::path::PathBuf;
use std::{borrow::Cow, path::PathBuf};
use wry::{
application::{
dpi::{PhysicalSize, Size},
@ -141,7 +141,10 @@ fn main() -> wry::Result<()> {
let mut file = match res.open(path) {
Ok(file) => file,
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound && res.webview_attr.spa {
if e.kind() == std::io::ErrorKind::NotFound
&& res.webview_attr.spa
&& path != "/index.html"
{
res.open("index.html")?
} else {
return Err(wry::Error::Io(e));
@ -150,7 +153,7 @@ fn main() -> wry::Result<()> {
};
wry::http::Response::builder()
.header("Content-Type", file.mimetype())
.body(file.decompressed_data()?)
.body(Cow::Owned(file.decompressed_data()?))
.map_err(|e| e.into())
})
.with_ipc_handler(|window: &Window, req: String| {