* 扫描单个目录下的所有 .desktop 文件
(dirPath: string)
| 234 | * 扫描单个目录下的所有 .desktop 文件 |
| 235 | */ |
| 236 | async function scanDesktopDir(dirPath: string): Promise<string[]> { |
| 237 | try { |
| 238 | const entries = await fs.readdir(dirPath, { withFileTypes: true }) |
| 239 | return entries |
| 240 | .filter((e) => e.isFile() && e.name.endsWith('.desktop')) |
| 241 | .map((e) => path.join(dirPath, e.name)) |
| 242 | } catch { |
| 243 | return [] |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * 将单个 .desktop 文件转换为 Command 对象 |