(filePath: string)
| 174 | } |
| 175 | |
| 176 | export async function parseUrlFile(filePath: string): Promise<UrlFileInfo | null> { |
| 177 | try { |
| 178 | const content = await fsPromises.readFile(filePath, 'utf-8') |
| 179 | let url = '' |
| 180 | let iconFile = '' |
| 181 | |
| 182 | for (const line of content.split('\n')) { |
| 183 | const trimmed = line.trim() |
| 184 | if (trimmed.startsWith('URL=')) { |
| 185 | url = trimmed.slice(4) |
| 186 | } else if (trimmed.startsWith('IconFile=')) { |
| 187 | iconFile = trimmed.slice(9) |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | if (!url) return null |
| 192 | |
| 193 | // 跳过普通网页链接(http/https),保留其他应用协议(如 steam://) |
| 194 | const lowerUrl = url.toLowerCase() |
| 195 | if (lowerUrl.startsWith('http://') || lowerUrl.startsWith('https://')) { |
| 196 | return null |
| 197 | } |
| 198 | |
| 199 | return { url, iconFile } |
| 200 | } catch { |
| 201 | return null |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // 递归扫描目录中的快捷方式 |
| 206 | async function scanDirectory( |
no outgoing calls
no test coverage detected