Skip to content

Commit 820d722

Browse files
committed
Refactor README files and enhance cursor_win_id_modifier.ps1 script
- Removed outdated installation instructions for overseas users in both English and Chinese README files. - Updated installation commands for macOS and Linux to point to the correct scripts. - Added a success image display in the installation sections for better user feedback. - Improved error handling and configuration writing in the cursor_win_id_modifier.ps1 script, ensuring directory existence and setting file permissions more robustly. - Included a prompt for users to restart Cursor to apply new configurations and added a message to follow the official WeChat account for further engagement.
1 parent b2f07c2 commit 820d722

File tree

4 files changed

+120
-43
lines changed

4 files changed

+120
-43
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,28 @@ If the above solutions don't work, try:
120120
<details open>
121121
<summary><b>Global Users</b></summary>
122122

123-
**Linux/macOS**
123+
**macOS**
124124

125125
```bash
126-
curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/install.sh | sudo bash
126+
curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_mac_id_modifier.sh | sudo bash
127+
```
128+
129+
**Linux**
130+
131+
```bash
132+
curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_linux_id_modifier.sh | sudo bash
127133
```
128134

129135
**Windows**
130136

131137
```powershell
132-
irm https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/install.ps1 | iex
138+
irm https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
133139
```
134140

141+
<div align="center">
142+
<img src="img/run_success.png" alt="Run Success" width="600"/>
143+
</div>
144+
135145
</details>
136146

137147
<details open>
@@ -140,7 +150,7 @@ irm https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/ins
140150
**macOS**
141151

142152
```bash
143-
curl -fsSL https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_mac_id_modifier.sh | sudo bash
153+
curl -fsSL https://aizaozao.com/accelerate.php/c | sudo bash
144154
```
145155

146156
**Linux**

README_CN.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,6 @@ You've reached your trial request limit.
113113

114114
### 🚀 一键解决方案
115115

116-
<details open>
117-
<summary><b>海外用户</b></summary>
118-
119-
**Linux/macOS**
120-
121-
```bash
122-
curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/install.sh | sudo bash
123-
```
124-
125-
**Windows**
126-
127-
```powershell
128-
irm https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/install.ps1 | iex
129-
```
130-
131-
</details>
132-
133116
<details open>
134117
<summary><b>国内用户(推荐)</b></summary>
135118

@@ -150,6 +133,9 @@ curl -fsSL https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com
150133
```powershell
151134
irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
152135
```
136+
<div align="center">
137+
<img src="img/run_success.png" alt="运行成功" width="600"/>
138+
</div>
153139

154140
</details>
155141

img/run_success.png

1.01 MB
Loading

scripts/run/cursor_win_id_modifier.ps1

Lines changed: 103 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,101 @@ $SQM_ID = "{$([System.Guid]::NewGuid().ToString().ToUpper())}"
135135
# 创建或更新配置文件
136136
Write-Host "$GREEN[信息]$NC 正在更新配置..."
137137

138-
$config = @{
139-
'telemetry.machineId' = $MACHINE_ID
140-
'telemetry.macMachineId' = $MAC_MACHINE_ID
141-
'telemetry.devDeviceId' = $UUID
142-
'telemetry.sqmId' = $SQM_ID
143-
}
138+
try {
139+
# 确保目录存在
140+
$storageDir = Split-Path $STORAGE_FILE -Parent
141+
if (-not (Test-Path $storageDir)) {
142+
New-Item -ItemType Directory -Path $storageDir -Force | Out-Null
143+
}
144144

145-
$config | ConvertTo-Json | Set-Content $STORAGE_FILE
145+
# 写入配置
146+
$config = @{
147+
'telemetry.machineId' = $MACHINE_ID
148+
'telemetry.macMachineId' = $MAC_MACHINE_ID
149+
'telemetry.devDeviceId' = $UUID
150+
'telemetry.sqmId' = $SQM_ID
151+
}
152+
153+
# 使用 System.IO.File 方法写入文件
154+
try {
155+
$jsonContent = $config | ConvertTo-Json
156+
[System.IO.File]::WriteAllText(
157+
[System.IO.Path]::GetFullPath($STORAGE_FILE),
158+
$jsonContent,
159+
[System.Text.Encoding]::UTF8
160+
)
161+
Write-Host "$GREEN[信息]$NC 成功写入配置文件"
162+
} catch {
163+
throw "写入文件失败: $_"
164+
}
146165

147-
# 设置文件权限
148-
$acl = Get-Acl $STORAGE_FILE
149-
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule(
150-
$env:USERNAME, "FullControl", "Allow"
151-
)
152-
$acl.SetAccessRule($rule)
153-
Set-Acl $STORAGE_FILE $acl
166+
# 尝试设置文件权限
167+
try {
168+
# 使用当前用户名和域名
169+
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
170+
$userAccount = "$($env:USERDOMAIN)\$($env:USERNAME)"
171+
172+
# 创建新的访问控制列表
173+
$acl = New-Object System.Security.AccessControl.FileSecurity
174+
175+
# 添加当前用户的完全控制权限
176+
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(
177+
$userAccount, # 使用域名\用户名格式
178+
[System.Security.AccessControl.FileSystemRights]::FullControl,
179+
[System.Security.AccessControl.InheritanceFlags]::None,
180+
[System.Security.AccessControl.PropagationFlags]::None,
181+
[System.Security.AccessControl.AccessControlType]::Allow
182+
)
183+
184+
try {
185+
$acl.AddAccessRule($accessRule)
186+
Set-Acl -Path $STORAGE_FILE -AclObject $acl -ErrorAction Stop
187+
Write-Host "$GREEN[信息]$NC 成功设置文件权限"
188+
} catch {
189+
# 如果第一种方法失败,尝试使用 icacls
190+
Write-Host "$YELLOW[警告]$NC 使用备选方法设置权限..."
191+
$result = Start-Process "icacls.exe" -ArgumentList "`"$STORAGE_FILE`" /grant `"$($env:USERNAME):(F)`"" -Wait -NoNewWindow -PassThru
192+
if ($result.ExitCode -eq 0) {
193+
Write-Host "$GREEN[信息]$NC 成功使用 icacls 设置文件权限"
194+
} else {
195+
Write-Host "$YELLOW[警告]$NC 设置文件权限失败,但文件已写入成功"
196+
}
197+
}
198+
} catch {
199+
Write-Host "$YELLOW[警告]$NC 设置文件权限失败: $_"
200+
Write-Host "$YELLOW[警告]$NC 尝试使用 icacls 命令..."
201+
try {
202+
$result = Start-Process "icacls.exe" -ArgumentList "`"$STORAGE_FILE`" /grant `"$($env:USERNAME):(F)`"" -Wait -NoNewWindow -PassThru
203+
if ($result.ExitCode -eq 0) {
204+
Write-Host "$GREEN[信息]$NC 成功使用 icacls 设置文件权限"
205+
} else {
206+
Write-Host "$YELLOW[警告]$NC 所有权限设置方法都失败,但文件已写入成功"
207+
}
208+
} catch {
209+
Write-Host "$YELLOW[警告]$NC icacls 命令失败: $_"
210+
}
211+
}
212+
213+
} catch {
214+
Write-Host "$RED[错误]$NC 主要操作失败: $_"
215+
Write-Host "$YELLOW[尝试]$NC 使用备选方法..."
216+
217+
try {
218+
# 备选方法:使用 Add-Content
219+
$tempFile = [System.IO.Path]::GetTempFileName()
220+
$config | ConvertTo-Json | Set-Content -Path $tempFile -Encoding UTF8
221+
Copy-Item -Path $tempFile -Destination $STORAGE_FILE -Force
222+
Remove-Item -Path $tempFile
223+
Write-Host "$GREEN[信息]$NC 使用备选方法成功写入配置"
224+
} catch {
225+
Write-Host "$RED[错误]$NC 所有尝试都失败了"
226+
Write-Host "错误详情: $_"
227+
Write-Host "目标文件: $STORAGE_FILE"
228+
Write-Host "请确保您有足够的权限访问该文件"
229+
Read-Host "按回车键退出"
230+
exit 1
231+
}
232+
}
154233

155234
# 显示结果
156235
Write-Host ""
@@ -178,6 +257,15 @@ if ($backupFiles) {
178257
Write-Host "│ └── (空)"
179258
}
180259

260+
# 显示公众号信息
261+
Write-Host ""
262+
Write-Host "$GREEN================================$NC"
263+
Write-Host "$YELLOW 关注公众号【煎饼果子卷AI】一起交流更多Cursor技巧和AI知识 $NC"
264+
Write-Host "$GREEN================================$NC"
265+
Write-Host ""
266+
Write-Host "$GREEN[信息]$NC 请重启 Cursor 以应用新的配置"
267+
Write-Host ""
268+
181269
# 询问是否要禁用自动更新
182270
Write-Host ""
183271
Write-Host "$YELLOW[询问]$NC 是否要禁用 Cursor 自动更新功能?"
@@ -217,14 +305,7 @@ else {
217305
Write-Host "$YELLOW[信息]$NC 保持默认设置,不进行更改"
218306
}
219307

220-
# 显示公众号信息
221-
Write-Host ""
222-
Write-Host "$GREEN================================$NC"
223-
Write-Host "$YELLOW 关注公众号【煎饼果子卷AI】一起交流更多Cursor技巧和AI知识 $NC"
224-
Write-Host "$GREEN================================$NC"
225-
Write-Host ""
226-
Write-Host "$GREEN[信息]$NC 请重启 Cursor 以应用新的配置"
227-
Write-Host ""
308+
228309

229310
Read-Host "按回车键退出"
230311
exit 0

0 commit comments

Comments
 (0)