开始修复的备份
This commit is contained in:
17
dist/extension.js
vendored
17
dist/extension.js
vendored
@@ -49,6 +49,7 @@ const onTypeFormattingProvider_1 = require("./providers/onTypeFormattingProvider
|
|||||||
const documentFormattingProvider_1 = require("./providers/documentFormattingProvider");
|
const documentFormattingProvider_1 = require("./providers/documentFormattingProvider");
|
||||||
const codeErrorProvider_1 = require("./providers/codeErrorProvider");
|
const codeErrorProvider_1 = require("./providers/codeErrorProvider");
|
||||||
const apiParser_1 = require("./providers/apiParser");
|
const apiParser_1 = require("./providers/apiParser");
|
||||||
|
const localClient_1 = require("./localClient");
|
||||||
function activate(context) {
|
function activate(context) {
|
||||||
console.log('Squirrel NUT Explorer 正在激活...');
|
console.log('Squirrel NUT Explorer 正在激活...');
|
||||||
// 初始化API解析器
|
// 初始化API解析器
|
||||||
@@ -132,12 +133,26 @@ function activate(context) {
|
|||||||
const saveListener = vscode.workspace.onDidSaveTextDocument(async (doc) => {
|
const saveListener = vscode.workspace.onDidSaveTextDocument(async (doc) => {
|
||||||
if (doc.uri.scheme === 'squirrel') {
|
if (doc.uri.scheme === 'squirrel') {
|
||||||
const filePath = doc.uri.path.substring(1); // 去掉开头的 '/'
|
const filePath = doc.uri.path.substring(1); // 去掉开头的 '/'
|
||||||
const success = await model.saveFileContent(filePath, doc.getText());
|
const fileContent = doc.getText();
|
||||||
|
const success = await model.saveFileContent(filePath, fileContent);
|
||||||
if (success) {
|
if (success) {
|
||||||
output.appendLine(`[Squirrel] 文件 ${filePath} 保存成功`);
|
output.appendLine(`[Squirrel] 文件 ${filePath} 保存成功`);
|
||||||
provider.refresh();
|
provider.refresh();
|
||||||
// 更新函数缓存
|
// 更新函数缓存
|
||||||
await functionExtractor.updateFileCache(model, filePath);
|
await functionExtractor.updateFileCache(model, filePath);
|
||||||
|
// 发送文件内容到本地C++服务
|
||||||
|
try {
|
||||||
|
const sendSuccess = await (0, localClient_1.sendFileToCppService)(filePath, fileContent);
|
||||||
|
if (sendSuccess) {
|
||||||
|
output.appendLine(`[Squirrel] 文件 ${filePath} 已发送到C++服务`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
output.appendLine(`[Squirrel] 文件 ${filePath} 发送到C++服务失败`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
output.appendLine(`[Squirrel] 发送文件到C++服务时发生错误: ${error}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
output.appendLine(`[Squirrel] 文件 ${filePath} 保存失败`);
|
output.appendLine(`[Squirrel] 文件 ${filePath} 保存失败`);
|
||||||
|
|||||||
2
dist/extension.js.map
vendored
2
dist/extension.js.map
vendored
File diff suppressed because one or more lines are too long
BIN
squirrel-nut-explorer-1.1.1.vsix
Normal file
BIN
squirrel-nut-explorer-1.1.1.vsix
Normal file
Binary file not shown.
41
客户端.cpp
Normal file
41
客户端.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include "httplib.h"
|
||||||
|
#include "rapidjson/document.h"
|
||||||
|
#include "rapidjson/writer.h"
|
||||||
|
#include "rapidjson/stringbuffer.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
std::string buildJsonData(const std::string& str1, const std::string& str2) {
|
||||||
|
rapidjson::StringBuffer sb;
|
||||||
|
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
|
||||||
|
|
||||||
|
writer.StartObject();
|
||||||
|
writer.Key(str1.c_str()); // 使用 str1 作为 key
|
||||||
|
writer.String(str2.c_str()); // 使用 str2 作为 value
|
||||||
|
writer.EndObject();
|
||||||
|
|
||||||
|
return sb.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
httplib::Client cli("http://127.0.0.1:26000");
|
||||||
|
|
||||||
|
// 准备数据
|
||||||
|
std::string str1 = "load.nut";
|
||||||
|
std::string str2 = "\r\nlocal job = sq_getJob();\r\nprint(job);\r\n ";
|
||||||
|
|
||||||
|
// 构建 JSON
|
||||||
|
std::string jsonStr = buildJsonData(str1, str2);
|
||||||
|
std::cout << "发送的 JSON: " << jsonStr << std::endl;
|
||||||
|
|
||||||
|
// 发送数据
|
||||||
|
auto res = cli.Post("/send_data", jsonStr, "application/json");
|
||||||
|
|
||||||
|
if (res && res->status == 200) {
|
||||||
|
std::cout << "服务端回复: " << res->body << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cerr << "发送失败,状态码: " << (res ? res->status : 0) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user