* 在终端中打开指定路径 * @param path 要打开的路径 * @returns 是否成功打开
(path: string)
| 182 | * @returns 是否成功打开 |
| 183 | */ |
| 184 | async openInTerminal(path: string): Promise<boolean> { |
| 185 | try { |
| 186 | // 转义路径中的单引号 |
| 187 | const escapedPath = path.replace(/'/g, "'\\''") |
| 188 | const script = ` |
| 189 | tell application "Terminal" |
| 190 | activate |
| 191 | do script "cd '${escapedPath}'" |
| 192 | end tell |
| 193 | ` |
| 194 | await this.execute(script) |
| 195 | return true |
| 196 | } catch (error) { |
| 197 | console.error('[AppleScript] 在终端打开路径失败:', error) |
| 198 | return false |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * 显示系统通知 |