添加本地服务端口配置项,允许用户自定义发送JSON数据的端口号
- 在localClient.ts中实现从配置读取端口号,默认值为26000 - 在package.json中添加squirrel.localServicePort配置项 - 用户现在可以通过VS Code设置自定义本地C++服务端口 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
6
dist/localClient.js
vendored
6
dist/localClient.js
vendored
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sendFileToCppService = sendFileToCppService;
|
||||
const http = __importStar(require("http"));
|
||||
const vscode = __importStar(require("vscode"));
|
||||
/**
|
||||
* 构建JSON数据
|
||||
* @param filePath 文件路径
|
||||
@@ -53,12 +54,15 @@ function buildJsonData(filePath, content) {
|
||||
* @returns Promise<boolean> 是否发送成功
|
||||
*/
|
||||
async function sendFileToCppService(filePath, content) {
|
||||
// 从配置中获取端口号,默认为26000
|
||||
const config = vscode.workspace.getConfiguration('squirrel');
|
||||
const localServicePort = config.get('localServicePort', 26000);
|
||||
return new Promise((resolve) => {
|
||||
const jsonData = buildJsonData(filePath, content);
|
||||
const postData = jsonData;
|
||||
const options = {
|
||||
hostname: '127.0.0.1',
|
||||
port: 26000,
|
||||
port: localServicePort,
|
||||
path: '/send_data',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user