From b7cf769cb24dd02a7e2191cb171bc7732ab585e2 Mon Sep 17 00:00:00 2001 From: luckfox-eng29 Date: Wed, 29 Apr 2026 17:41:56 +0800 Subject: [PATCH] feat(sd): add filesystem type selection for SD card format (exFAT/FAT32) Signed-off-by: luckfox-eng29 --- .../SharedFolders/FileManager.tsx | 82 +++++++++++++------ .../SharedFolders/SDFilePage.tsx | 33 ++++---- .../VirtualMediaSource/ImageManager.tsx | 63 ++++++++++---- usb_mass_storage.go | 14 +++- 4 files changed, 135 insertions(+), 57 deletions(-) diff --git a/ui/src/layout/components_side/SharedFolders/FileManager.tsx b/ui/src/layout/components_side/SharedFolders/FileManager.tsx index 3a7f522..febf3b0 100644 --- a/ui/src/layout/components_side/SharedFolders/FileManager.tsx +++ b/ui/src/layout/components_side/SharedFolders/FileManager.tsx @@ -67,6 +67,8 @@ interface StorageFilePageProps { onUnmountSDStorage?: () => void; onFormatSDStorage?: () => void; onMountSDStorage?: () => void; + fsType?: 'exfat' | 'fat32'; + onFsTypeChange?: (value: 'exfat' | 'fat32') => void; } export const FileManager: React.FC = ({ @@ -79,6 +81,8 @@ export const FileManager: React.FC = ({ onResetSDStorage, onUnmountSDStorage, onFormatSDStorage, + fsType, + onFsTypeChange, }) => { const { $at } = useReactAt(); @@ -251,15 +255,28 @@ export const FileManager: React.FC = ({

{sdMountStatus !== "none" && (
- - {$at("Format MicroSD Card")} - +
+

+ {$at("Choose the file system for MicroSD formatting")} +

+ + + {$at("Format MicroSD Card")} ({(fsType || "fat32")}) + +
)} @@ -318,6 +335,8 @@ export const FileManager: React.FC = ({ onUnmountSDStorage={handleUnmountWrapper} onFormatSDStorage={handleFormatWrapper} syncStorage={syncStorage} + fsType={fsType} + onFsTypeChange={onFsTypeChange} /> {uploadFile ? ( @@ -504,29 +523,46 @@ interface ActionButtonsSectionProps { onUnmountSDStorage?: () => void; onFormatSDStorage?: () => void; syncStorage: () => void; + fsType?: 'exfat' | 'fat32'; + onFsTypeChange?: (value: 'exfat' | 'fat32') => void; } const ActionButtonsSection: React.FC = ({ - mediaType, - loading, - showSDManagement, - onUnmountSDStorage, - onFormatSDStorage, - }) => { + mediaType, + loading, + showSDManagement, + onUnmountSDStorage, + onFormatSDStorage, + fsType, + onFsTypeChange, + }) => { const { $at } = useReactAt(); if (mediaType === "sd" && showSDManagement) { return ( -
- {$at("Format MicroSD Card")} +
+

+ {$at("Choose the file system for MicroSD formatting")} +

+ + {$at("Format MicroSD Card")} ({(fsType || "fat32")}) +
('fat32'); const handleResetSDStorage = async () => { setLoading(true); @@ -37,11 +38,11 @@ export default function SDFilePage() { }; const handleFormatSDStorage = async () => { - if (!window.confirm($at("Formatting the SD card will erase all data. Continue?"))) { + if (!window.confirm($at(`Formatting the SD card as ${fsType.toUpperCase()} will erase all data. Continue?`))) { return; } setLoading(true); - send("formatSDStorage", { confirm: true }, res => { + send("formatSDStorage", { confirm: true, fsType }, res => { if ("error" in res) { notifications.error(res.error.data || res.error.message); setLoading(false); @@ -54,17 +55,21 @@ export default function SDFilePage() { }; return ( - + <> + + ); } diff --git a/ui/src/layout/components_side/VirtualMediaSource/ImageManager.tsx b/ui/src/layout/components_side/VirtualMediaSource/ImageManager.tsx index eacdf29..544e5cb 100644 --- a/ui/src/layout/components_side/VirtualMediaSource/ImageManager.tsx +++ b/ui/src/layout/components_side/VirtualMediaSource/ImageManager.tsx @@ -105,6 +105,7 @@ export default function ImageManager({ const [sdMountStatus, setSDMountStatus] = useState<"ok" | "none" | "fail" | null>(storageType === 'sd' ? null : 'ok'); const [loading, setLoading] = useState(false); const [uploadFile, setUploadFile] = useState(null); + const [fsType, setFsType] = useState<'exfat' | 'fat32'>('fat32'); const filesPerPage = 5; const percentageUsed = useMemo(() => { @@ -170,7 +171,7 @@ export default function ImageManager({ return; } setLoading(true); - send("formatSDStorage", { confirm: true }, res => { + send("formatSDStorage", { confirm: true, fsType }, res => { if ("error" in res) { notifications.error(res.error.data || res.error.message); setLoading(false); @@ -347,15 +348,28 @@ export default function ImageManager({

{sdMountStatus !== "none" && (
- - {$at("Format MicroSD Card")} - +
+

+ {$at("Choose the file system for MicroSD formatting")} +

+ + + {$at("Format MicroSD Card")} ({fsType}) + +
)}
@@ -493,16 +507,29 @@ export default function ImageManager({ {unmountApi && storageType === 'sd' && ( -
- {$at("Format MicroSD Card")} +
+

+ {$at("Choose the file system for MicroSD formatting")} +

+ + {$at("Format MicroSD Card")} ({fsType}) +