From ea77c5b0e8b70a9da730b36c84a8674b954fba27 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Fri, 27 Mar 2026 15:25:55 +0800 Subject: [PATCH] =?UTF-8?q?folder=E5=A2=9E=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=99=A8=E5=85=A5=E5=8F=A3=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=AA=97=E5=8F=A3=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/commands/windows.rs | 18 +++++++++++++++++- src-tauri/src/lib.rs | 18 ++++++++++++++++++ .../layout/folder-name-dropdown.tsx | 13 ++++++++++++- src/components/layout/folder-title-bar.tsx | 4 +--- .../project-boot/project-boot-workspace.tsx | 7 +------ .../project-boot/shadcn/constants.ts | 19 +++---------------- .../shadcn/create-project-dialog.tsx | 7 +------ .../shadcn/shadcn-config-panel.tsx | 18 +++++++++++++++--- src/components/welcome/folder-actions.tsx | 2 +- src/i18n/messages/ar.json | 1 + src/i18n/messages/de.json | 1 + src/i18n/messages/en.json | 1 + src/i18n/messages/es.json | 1 + src/i18n/messages/fr.json | 1 + src/i18n/messages/ja.json | 1 + src/i18n/messages/ko.json | 1 + src/i18n/messages/pt.json | 1 + src/i18n/messages/zh-CN.json | 1 + src/i18n/messages/zh-TW.json | 1 + src/lib/api.ts | 4 ++-- 20 files changed, 81 insertions(+), 39 deletions(-) diff --git a/src-tauri/src/commands/windows.rs b/src-tauri/src/commands/windows.rs index 3c1f779..e665bc2 100644 --- a/src-tauri/src/commands/windows.rs +++ b/src-tauri/src/commands/windows.rs @@ -610,13 +610,22 @@ pub async fn open_push_window( } #[tauri::command] -pub async fn open_project_boot_window(app: AppHandle) -> Result<(), AppCommandError> { +pub async fn open_project_boot_window( + app: AppHandle, + source: Option, +) -> Result<(), AppCommandError> { if let Some(existing) = app.get_webview_window("project-boot") { ensure_windows_undecorated(&existing); let _ = existing.unminimize(); existing.set_focus().map_err(|e| { AppCommandError::window("Failed to focus project boot window", e.to_string()) })?; + // Close welcome if opened from welcome + if source.as_deref() == Some("welcome") { + if let Some(w) = app.get_webview_window("welcome") { + let _ = w.close(); + } + } return Ok(()); } @@ -633,5 +642,12 @@ pub async fn open_project_boot_window(app: AppHandle) -> Result<(), AppCommandEr })?; ensure_windows_undecorated(&window); + // Close welcome if opened from welcome + if source.as_deref() == Some("welcome") { + if let Some(w) = app.get_webview_window("welcome") { + let _ = w.close(); + } + } + Ok(()) } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 5d40719..c9071f3 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -140,6 +140,24 @@ pub fn run() { }); } + if label == "project-boot" + && matches!( + event, + tauri::WindowEvent::CloseRequested { .. } | tauri::WindowEvent::Destroyed + ) + { + let app = window.app_handle(); + if !APP_QUITTING.load(Ordering::Relaxed) { + let has_other = app + .webview_windows() + .keys() + .any(|l| *l != label && *l != "settings"); + if !has_other { + let _ = windows::open_welcome_window(app); + } + } + } + if let tauri::WindowEvent::CloseRequested { .. } = event { if label.starts_with("folder-") { let app = window.app_handle(); diff --git a/src/components/layout/folder-name-dropdown.tsx b/src/components/layout/folder-name-dropdown.tsx index 295a030..2d21e32 100644 --- a/src/components/layout/folder-name-dropdown.tsx +++ b/src/components/layout/folder-name-dropdown.tsx @@ -1,7 +1,13 @@ "use client" import { useState } from "react" -import { ChevronDown, Folder, FolderOpen, GitBranch } from "lucide-react" +import { + ChevronDown, + Folder, + FolderOpen, + GitBranch, + Rocket, +} from "lucide-react" import { useTranslations } from "next-intl" import { DropdownMenu, @@ -16,6 +22,7 @@ import { listOpenFolders, loadFolderHistory, openFolderWindow, + openProjectBootWindow, } from "@/lib/api" import { openFileDialog } from "@/lib/platform" import { useFolderContext } from "@/contexts/folder-context" @@ -87,6 +94,10 @@ export function FolderNameDropdown() { {t("cloneRepository")} + openProjectBootWindow()}> + + {t("projectBoot")} + {openFolders.length > 0 && ( <> diff --git a/src/components/layout/folder-title-bar.tsx b/src/components/layout/folder-title-bar.tsx index 1856315..aa75138 100644 --- a/src/components/layout/folder-title-bar.tsx +++ b/src/components/layout/folder-title-bar.tsx @@ -302,9 +302,7 @@ export function FolderTitleBar() { { try { - await openProjectBootWindow() + await openProjectBootWindow("welcome") } catch (err) { console.error("[FolderActions] failed to open project boot:", err) toast.error(t("toasts.openProjectBootFailed")) diff --git a/src/i18n/messages/ar.json b/src/i18n/messages/ar.json index e7d85b1..3bb8243 100644 --- a/src/i18n/messages/ar.json +++ b/src/i18n/messages/ar.json @@ -856,6 +856,7 @@ "fallbackFolderName": "مجلد", "openFolder": "فتح مجلد", "cloneRepository": "استنساخ المستودع", + "projectBoot": "مُنشئ المشروع", "opened": "مفتوح", "recentOpen": "المفتوح مؤخرًا" }, diff --git a/src/i18n/messages/de.json b/src/i18n/messages/de.json index 9e05b05..6a02ae0 100644 --- a/src/i18n/messages/de.json +++ b/src/i18n/messages/de.json @@ -856,6 +856,7 @@ "fallbackFolderName": "Ordner", "openFolder": "Ordner öffnen", "cloneRepository": "Repository klonen", + "projectBoot": "Projekt-Boot", "opened": "Geöffnet", "recentOpen": "Zuletzt geöffnet" }, diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index 4ff3127..9ee6bd4 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -856,6 +856,7 @@ "fallbackFolderName": "Folder", "openFolder": "Open Folder", "cloneRepository": "Clone Repository", + "projectBoot": "Project Boot", "opened": "Opened", "recentOpen": "Recently Opened" }, diff --git a/src/i18n/messages/es.json b/src/i18n/messages/es.json index c44cd0b..797e190 100644 --- a/src/i18n/messages/es.json +++ b/src/i18n/messages/es.json @@ -856,6 +856,7 @@ "fallbackFolderName": "Carpeta", "openFolder": "Abrir carpeta", "cloneRepository": "Clonar repositorio", + "projectBoot": "Inicializador de proyecto", "opened": "Abierto", "recentOpen": "Abiertos recientemente" }, diff --git a/src/i18n/messages/fr.json b/src/i18n/messages/fr.json index 0b3ec3e..f6e4ed6 100644 --- a/src/i18n/messages/fr.json +++ b/src/i18n/messages/fr.json @@ -856,6 +856,7 @@ "fallbackFolderName": "Dossier", "openFolder": "Ouvrir le dossier", "cloneRepository": "Cloner le dépôt", + "projectBoot": "Lanceur de projet", "opened": "Ouvert", "recentOpen": "Ouvert récemment" }, diff --git a/src/i18n/messages/ja.json b/src/i18n/messages/ja.json index 37fa269..d4329d3 100644 --- a/src/i18n/messages/ja.json +++ b/src/i18n/messages/ja.json @@ -856,6 +856,7 @@ "fallbackFolderName": "フォルダ", "openFolder": "フォルダを開く", "cloneRepository": "リポジトリをクローン", + "projectBoot": "プロジェクトブート", "opened": "開いているフォルダ", "recentOpen": "最近開いたフォルダ" }, diff --git a/src/i18n/messages/ko.json b/src/i18n/messages/ko.json index 9ee8e07..c9b00b1 100644 --- a/src/i18n/messages/ko.json +++ b/src/i18n/messages/ko.json @@ -856,6 +856,7 @@ "fallbackFolderName": "폴더", "openFolder": "폴더 열기", "cloneRepository": "리포지토리 클론", + "projectBoot": "프로젝트 부트", "opened": "열린 항목", "recentOpen": "최근 연 항목" }, diff --git a/src/i18n/messages/pt.json b/src/i18n/messages/pt.json index c0544ef..db1af80 100644 --- a/src/i18n/messages/pt.json +++ b/src/i18n/messages/pt.json @@ -856,6 +856,7 @@ "fallbackFolderName": "Pasta", "openFolder": "Abrir pasta", "cloneRepository": "Clonar repositório", + "projectBoot": "Inicializador de projeto", "opened": "Aberto", "recentOpen": "Abertos recentemente" }, diff --git a/src/i18n/messages/zh-CN.json b/src/i18n/messages/zh-CN.json index 63148e8..3b244f2 100644 --- a/src/i18n/messages/zh-CN.json +++ b/src/i18n/messages/zh-CN.json @@ -856,6 +856,7 @@ "fallbackFolderName": "文件夹", "openFolder": "打开文件夹", "cloneRepository": "克隆仓库", + "projectBoot": "项目启动器", "opened": "已打开", "recentOpen": "最近打开" }, diff --git a/src/i18n/messages/zh-TW.json b/src/i18n/messages/zh-TW.json index 9cb98b2..b266c38 100644 --- a/src/i18n/messages/zh-TW.json +++ b/src/i18n/messages/zh-TW.json @@ -856,6 +856,7 @@ "fallbackFolderName": "資料夾", "openFolder": "打開資料夾", "cloneRepository": "複製倉庫", + "projectBoot": "專案啟動器", "opened": "已打開", "recentOpen": "最近打開" }, diff --git a/src/lib/api.ts b/src/lib/api.ts index 75cd0b8..1e45abc 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -952,9 +952,9 @@ export async function openSettingsWindow( window.open(result.path, `settings-${section ?? "general"}`) } -export async function openProjectBootWindow(): Promise { +export async function openProjectBootWindow(source?: string): Promise { if (getTransport().isDesktop()) { - return getTransport().call("open_project_boot_window") + return getTransport().call("open_project_boot_window", { source }) } window.open("/project-boot", "project-boot") }