mirror of https://github.com/Tim-Paik/neutauri.git
fix config dir
This commit is contained in:
parent
a242b1b12d
commit
f965abf581
|
@ -238,7 +238,7 @@ impl Default for Config {
|
|||
max_inner_size: None,
|
||||
resizable: true,
|
||||
fullscreen: false,
|
||||
title: "".to_string(),
|
||||
title: "".into(),
|
||||
maximized: false,
|
||||
visible: true,
|
||||
transparent: false,
|
||||
|
@ -246,9 +246,9 @@ impl Default for Config {
|
|||
always_on_top: false,
|
||||
window_icon: None,
|
||||
spa: false,
|
||||
url: Some("/index.html".to_string()),
|
||||
url: Some("/index.html".into()),
|
||||
html: None,
|
||||
initialization_script: Some("".to_string()),
|
||||
initialization_script: Some("".into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ fn options() -> fs::OpenOptions {
|
|||
fn main() -> wry::Result<()> {
|
||||
let arg = std::env::args()
|
||||
.nth(1)
|
||||
.unwrap_or_else(|| "neutauri.toml".to_string());
|
||||
.unwrap_or_else(|| "neutauri.toml".into());
|
||||
if arg == "--help" || arg == "-h" {
|
||||
println!("Usage: neutauri_bundler [neutauri.toml]");
|
||||
return Ok(());
|
||||
|
|
|
@ -206,7 +206,7 @@ impl Default for Config {
|
|||
max_inner_size: None,
|
||||
resizable: true,
|
||||
fullscreen: false,
|
||||
title: "".to_string(),
|
||||
title: "".into(),
|
||||
maximized: false,
|
||||
visible: true,
|
||||
transparent: false,
|
||||
|
@ -214,9 +214,9 @@ impl Default for Config {
|
|||
always_on_top: false,
|
||||
window_icon: None,
|
||||
spa: false,
|
||||
url: Some("/index.html".to_string()),
|
||||
url: Some("/index.html".into()),
|
||||
html: None,
|
||||
initialization_script: Some("".to_string()),
|
||||
initialization_script: Some("".into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#![windows_subsystem = "windows"]
|
||||
|
||||
use std::path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use wry::{
|
||||
application::{
|
||||
dpi::{PhysicalSize, Size},
|
||||
event::{Event, WindowEvent, StartCause},
|
||||
event::{Event, StartCause, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
window::{Fullscreen, Icon, Window, WindowBuilder},
|
||||
},
|
||||
webview::{RpcRequest, WebViewBuilder, WebContext},
|
||||
webview::{RpcRequest, WebContext, WebViewBuilder},
|
||||
};
|
||||
mod data;
|
||||
|
||||
|
@ -114,13 +114,29 @@ fn main() -> wry::Result<()> {
|
|||
};
|
||||
let path = std::env::current_exe()?;
|
||||
let path = path.file_stem().unwrap_or_else(|| "neutauri_app".as_ref());
|
||||
let mut web_context = if cfg!(windows) {
|
||||
let config_path = std::env::var("APPDATA").unwrap_or_else(|_| ".".into());
|
||||
let config_path = path::Path::new(&config_path).join(path);
|
||||
let mut web_context = if cfg!(target_os = "windows") {
|
||||
let config_path = match std::env::var("APPDATA") {
|
||||
Ok(dir) => PathBuf::from(dir),
|
||||
Err(_) => PathBuf::from("."),
|
||||
}
|
||||
.join(path);
|
||||
WebContext::new(Some(config_path))
|
||||
} else if cfg!(linux) {
|
||||
let config_path = std::env::var("HOME").unwrap_or_else(|_| ".".into());
|
||||
let config_path = path::Path::new(&config_path).join(".local/share/").join(path);
|
||||
} else if cfg!(target_os = "linux") {
|
||||
let config_path = match std::env::var("XDG_CONFIG_DIR") {
|
||||
Ok(dir) => PathBuf::from(dir),
|
||||
Err(_) => match std::env::var("HOME") {
|
||||
Ok(dir) => PathBuf::from(dir).join(".config"),
|
||||
Err(_) => PathBuf::from("."),
|
||||
},
|
||||
}
|
||||
.join(path);
|
||||
WebContext::new(Some(config_path))
|
||||
} else if cfg!(target_os = "macos") {
|
||||
let config_path = match std::env::var("HOME") {
|
||||
Ok(dir) => PathBuf::from(dir).join("Library/Application Support/"),
|
||||
Err(_) => PathBuf::from("."),
|
||||
}
|
||||
.join(path);
|
||||
WebContext::new(Some(config_path))
|
||||
} else {
|
||||
WebContext::new(None)
|
||||
|
|
Loading…
Reference in New Issue