refactor: react router (#5073)

* refactor: react router

* chore: update

* fix: router

* refactor: generate router children by navItems

* chore: set start page when create window

* docs: update UPDATELOG.md
This commit is contained in:
oomeow
2025-10-18 20:25:31 +08:00
committed by GitHub
parent 8e20b1b0a0
commit 96ce529b16
16 changed files with 74 additions and 115 deletions

View File

@@ -338,7 +338,15 @@ impl IVerge {
pub async fn new() -> Self {
match dirs::verge_path() {
Ok(path) => match help::read_yaml::<IVerge>(&path).await {
Ok(config) => config,
Ok(mut config) => {
// compatibility
if let Some(start_page) = config.start_page.clone()
&& start_page == "/home"
{
config.start_page = Some(String::from("/"));
}
config
}
Err(err) => {
log::error!(target: "app", "{err}");
Self::template()
@@ -362,7 +370,7 @@ impl IVerge {
env_type: Some("bash".into()),
#[cfg(target_os = "windows")]
env_type: Some("powershell".into()),
start_page: Some("/home".into()),
start_page: Some("/".into()),
traffic_graph: Some(true),
enable_memory_usage: Some(true),
enable_group_icon: Some(true),

View File

@@ -1,6 +1,7 @@
use tauri::WebviewWindow;
use crate::{
config::Config,
core::handle,
logging_error,
utils::{
@@ -17,13 +18,19 @@ const MINIMAL_WIDTH: f64 = 520.0;
const MINIMAL_HEIGHT: f64 = 520.0;
/// 构建新的 WebView 窗口
pub fn build_new_window() -> Result<WebviewWindow, String> {
pub async fn build_new_window() -> Result<WebviewWindow, String> {
let app_handle = handle::Handle::app_handle();
let start_page = Config::verge()
.await
.latest_ref()
.start_page
.clone()
.unwrap_or("/".to_string());
match tauri::WebviewWindowBuilder::new(
app_handle,
"main", /* the unique window label */
tauri::WebviewUrl::App("index.html".into()),
tauri::WebviewUrl::App(start_page.into()),
)
.title("Clash Verge")
.center()

View File

@@ -328,7 +328,7 @@ impl WindowManager {
return false;
}
match build_new_window() {
match build_new_window().await {
Ok(_) => {
logging!(info, Type::Window, "新窗口创建成功");
}