feat: 添加最近路径管理功能,包括删除路径的API和前端交互

This commit is contained in:
catlog22
2025-12-07 17:35:10 +08:00
parent 0a96ee16a8
commit 26a325efff
7 changed files with 560 additions and 49 deletions

View File

@@ -252,3 +252,28 @@ export function clearRecentPaths() {
// Ignore errors
}
}
/**
* Remove a specific path from recent paths
* @param {string} pathToRemove - Path to remove
* @returns {boolean} - True if removed, false if not found
*/
export function removeRecentPath(pathToRemove) {
try {
const normalized = normalizePathForDisplay(resolvePath(pathToRemove));
let paths = getRecentPaths();
const originalLength = paths.length;
// Filter out the path to remove
paths = paths.filter(p => normalizePathForDisplay(p) !== normalized);
if (paths.length < originalLength) {
// Save updated list
writeFileSync(RECENT_PATHS_FILE, JSON.stringify({ paths }, null, 2), 'utf8');
return true;
}
return false;
} catch {
return false;
}
}