(host: string)
| 203 | if (!this.db) { |
| 204 | console.error("[zpr] 数据库未初始化"); |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | // 防止并发写入 |
| 209 | if (this.isWriting) { |
| 210 | console.log("[zpr] 配置正在写入中,请稍后"); |
| 211 | return false; |
| 212 | } |
| 213 | |
| 214 | this.isWriting = true; |
| 215 | try { |
| 216 | // 验证输入参数 |
| 217 | if (!host || typeof host !== 'string') { |
| 218 | console.error("[zpr] 无效的代理地址"); |
| 219 | return false; |
| 220 | } |
| 221 | |
| 222 | // 创建备份 |
| 223 | await this.createBackup(); |
| 224 | |
| 225 | // 更新配置数据 |
| 226 | this.db.data[CONFIG_KEYS.PROXY_HOST] = host; |
| 227 | |
| 228 | // 写入配置,增强重试机制 |
| 229 | return await this.writeConfigWithRetry(); |
| 230 | } catch (error) { |
| 231 | console.error("[zpr] 设置代理失败:", error); |
| 232 | return false; |
| 233 | } finally { |
| 234 | this.isWriting = false; |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | // 帮助文本定义 |
| 240 | const help_text = `🎨 <b>随机纸片人插件</b> |
| 241 | |
| 242 | <b>命令格式:</b> |
| 243 | <code>${mainPrefix}zpr [参数]</code> |
no test coverage detected