-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
281 lines (256 loc) · 8.46 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const path = require("path");
const vscode = require("vscode");
const { AngcyoViewsProvider } = require("./src/angcyoViewsProvider");
const { MemoWebviewPanel } = require("./src/memoWebviewPanel");
const { LpbinWebviewPanel } = require("./src/lpbinWebviewPanel");
const { HttpServerWebviewPanel } = require("./src/httpServerWebviewPanel");
const { TreeDataProvider } = require("./src/treeDataProvider");
const { WebviewPanel } = require("./src/webviewPannel");
const {
laserPeckerAddQuotationMark,
} = require("./src/addQuotationMarkLaserPecker.js");
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log("插件激活..." + context.extensionUri); //file:///e%3A/VSCodeProjects/angcyoJs
//console.log("插件激活..." + context.extensionPath); //e:\VSCodeProjects\angcyoJs
console.log(context);
//__filename
console.log(__filename); //e:\VSCodeProjects\angcyoJs\extension.js
//显示欢迎页
vscode.commands.executeCommand("setContext", "angcyo.showWelcome", true);
//读取本地配置
const config = vscode.workspace.getConfiguration("angcyo-config");
console.log("配置↓");
console.log(config);
//const defHost = "https://gitcode.net/angcyo/json/-/raw/master";
const defHost = "https://gitlab.com/angcyo/json/-/raw/master";
let host = config.get("host", defHost);
//如果host为空或空字符串, 则使用默认值
if (!host || host.length === 0) {
host = defHost;
}
console.log("host->" + host);
//
const welcomeViewsProvider = new TreeDataProvider();
vscode.window.registerTreeDataProvider("welcomeViews", welcomeViewsProvider);
//
const angcyoViewsProvider = new AngcyoViewsProvider(`${host}/angcyoUrl.json`);
vscode.window.registerTreeDataProvider("angcyoViews", angcyoViewsProvider);
//
const httpViewsProvider = new TreeDataProvider(`${host}/recommendUrl.json`);
vscode.window.registerTreeDataProvider("httpViews", httpViewsProvider);
//
const parseSvgIconPath = path.join(__filename, "..", "res", "parse.svg");
const laserPeckerViewsProvider = new TreeDataProvider(
`${host}/laserPeckerUrl.json`,
[
{
label: "lp工程文件数据解析",
iconPath: parseSvgIconPath,
command: {
command: "angcyo.laserPeckerParse",
},
tooltip: "LaserPecker工程文件数据解析",
//description: item.url,
},
{
label: "lp蓝牙指令数据解析",
iconPath: parseSvgIconPath,
command: {
command: "angcyo.laserPeckerBleParse",
},
tooltip: "LaserPecker蓝牙指令数据解析",
//description: item.url,
},
{
label: "Svg解析",
iconPath: parseSvgIconPath,
command: {
command: "angcyo.svgParse",
},
tooltip: "Svg数据解析",
//description: item.url,
},
{
label: "lpbin文件创建及解析",
iconPath: parseSvgIconPath,
command: {
command: "angcyo.binParse",
},
tooltip: "lpbin文件创建及解析",
//description: item.url,
},
{
label: "lp自动雕刻",
iconPath: parseSvgIconPath,
command: {
command: "angcyo.autoEngrave",
},
tooltip: "LaserPecker自动雕刻",
//description: item.url,
},
]
);
//console.log(parseSvgIconPath);//e:\VSCodeProjects\angcyoJs\res\parse.svg
vscode.window.registerTreeDataProvider(
"laserPeckerViews",
laserPeckerViewsProvider
);
//注册一个刷新数据的指令
vscode.commands.registerCommand("angcyo.refresh", () => {
welcomeViewsProvider.refresh();
angcyoViewsProvider.refresh();
httpViewsProvider.refresh();
laserPeckerViewsProvider.refresh();
});
//单独刷新angcyo
vscode.commands.registerCommand("angcyo.refresh.angcyo", () => {
angcyoViewsProvider.refresh();
});
//打开网页
vscode.commands.registerCommand("angcyo.openUrl", async (url) => {
console.log(`命令打开url:${url}`);
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(`${url}`));
});
//设备直连
const deviceConnectPanel = new WebviewPanel(
"angcyo.deviceConnect",
"设备直连",
"res/js/deviceConnect.js",
"res/html/deviceConnect.html"
);
vscode.commands.registerCommand("angcyo.deviceConnect", () => {
console.log(`设备直连`);
deviceConnectPanel.createOrShow(context);
});
//日志分析
const logParsePanel = new WebviewPanel(
"angcyo.logParse",
"日志分析",
"res/js/logParse.js",
"res/html/logParse.html"
);
vscode.commands.registerCommand("angcyo.logParse", () => {
console.log(`日志分析`);
logParsePanel.createOrShow(context);
});
//js工具
const jsToolsPanel = new WebviewPanel(
"angcyo.jsTools",
"JS工具",
"res/js/jsTools.js",
"res/html/jsTools.html"
);
vscode.commands.registerCommand("angcyo.jsTools", () => {
console.log(`JS工具`);
jsToolsPanel.createOrShow(context);
});
//爬虫工具
const crawlerToolsPanel = new WebviewPanel(
"angcyo.crawlerTools",
"爬虫工具",
"res/js/crawlerTools.js",
"res/html/crawlerTools.html"
);
vscode.commands.registerCommand("angcyo.crawlerTools", () => {
console.log(`爬虫工具`);
crawlerToolsPanel.createOrShow(context);
});
//httpServer
const httpServerWebviewPanel = new HttpServerWebviewPanel();
vscode.commands.registerCommand("angcyo.httpServer", () => {
console.log(`httpServer`);
httpServerWebviewPanel.createOrShow(context);
});
//bedLink
const bedLinkPanel = new WebviewPanel(
"angcyo.bedLink",
"图床链接",
"res/js/bedLink.js",
"res/html/bedLink.html"
);
vscode.commands.registerCommand("angcyo.bedLink", () => {
console.log(`bedLink`);
bedLinkPanel.createOrShow(context);
});
//LaserPecker数据解析
const laserPeckerPanel = new WebviewPanel(
"angcyo.laserPeckerParse",
"LaserPecker工程文件数据解析",
"res/js/lpProject.js",
"res/html/lpProject.html"
);
vscode.commands.registerCommand("angcyo.laserPeckerParse", () => {
console.log(`LaserPecker工程文件数据解析`);
laserPeckerPanel.createOrShow(context);
});
//LaserPecker蓝牙指令解析
const laserPeckerBlePanel = new WebviewPanel(
"angcyo.laserPeckerBleParse",
"LaserPecker蓝牙指令解析",
"res/js/lpBle.js",
"res/html/lpBle.html"
);
vscode.commands.registerCommand("angcyo.laserPeckerBleParse", () => {
console.log(`LaserPecker蓝牙指令解析`);
laserPeckerBlePanel.createOrShow(context);
});
//Svg解析
const svgParsePanel = new WebviewPanel(
"angcyo.svgParse",
"Svg解析",
"res/js/svgParse.js",
"res/html/svgParse.html"
);
vscode.commands.registerCommand("angcyo.svgParse", () => {
console.log(`Svg解析`);
svgParsePanel.createOrShow(context);
});
//lpbin解析
const lpBinPanel = new LpbinWebviewPanel();
vscode.commands.registerCommand("angcyo.binParse", () => {
console.log(`lpbin文件创建及解析`);
lpBinPanel.createOrShow(context);
});
//lp自动雕刻
const autoEngravePanel = new WebviewPanel(
"angcyo.autoEngrave",
"lp自动雕刻",
"res/js/autoEngrave.js",
"res/html/autoEngrave.html"
);
vscode.commands.registerCommand("angcyo.autoEngrave", () => {
console.log(`lp自动雕刻`);
autoEngravePanel.createOrShow(context);
});
//angcyo.memo 备忘录
const memoPanel = new MemoWebviewPanel();
vscode.commands.registerCommand("angcyo.memo", () => {
console.log(`备忘录`);
memoPanel.createOrShow(context);
});
//Api.readFile(context, "res", "main.css");
//注册一个指令, 用来给选中的文本添加引号, LaserPecker
vscode.commands.registerCommand(
"angcyo.command.addQuotationMarkLaserPecker",
() => {
laserPeckerAddQuotationMark.addQuotationMark();
}
);
}
// this method is called when your extension is deactivated
function deactivate() {
vscode.window.showInformationMessage(`angcyo is deactivate~`);
}
module.exports = {
activate,
deactivate,
};