update
This commit is contained in:
parent
050d72034c
commit
c56847a2b2
1
icons/protocol.svg
Normal file
1
icons/protocol.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1742640634061" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1503" data-darkreader-inline-fill="" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M768 854.016h-170.016L768 170.016h170.016L768 854.016zM682.016 170.016H512l-170.016 684H512l170.016-684zM86.016 704q0 44 31.008 75.008t75.008 31.008 75.008-31.008T298.048 704t-31.008-75.008-75.008-31.008-75.008 31.008T86.016 704z m0-297.984q0 44 31.008 75.008t75.008 31.008 75.008-31.008 31.008-75.008-31.008-76-75.008-32-75.008 32-31.008 76z" p-id="1504"></path></svg>
|
After Width: | Height: | Size: 733 B |
103
package.json
103
package.json
@ -1,47 +1,58 @@
|
|||||||
{
|
{
|
||||||
"name": "openmcp",
|
"name": "openmcp",
|
||||||
"displayName": "openmcp",
|
"displayName": "openmcp",
|
||||||
"description": "A MCP Client for MCP/OpenMCP",
|
"description": "A MCP Client for MCP/OpenMCP",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.98.0"
|
"vscode": "^1.98.0"
|
||||||
},
|
},
|
||||||
"categories": [
|
"categories": [
|
||||||
"Other"
|
"Other"
|
||||||
],
|
],
|
||||||
"activationEvents": [],
|
"activationEvents": [
|
||||||
"main": "./dist/extension.js",
|
"*"
|
||||||
"contributes": {
|
],
|
||||||
"commands": [
|
"main": "./dist/extension.js",
|
||||||
{
|
"contributes": {
|
||||||
"command": "openmcp.helloWorld",
|
"commands": [
|
||||||
"title": "Hello World"
|
{
|
||||||
}
|
"command": "openmcp.helloWorld",
|
||||||
]
|
"title": "Hello World"
|
||||||
},
|
}
|
||||||
"scripts": {
|
],
|
||||||
"vscode:prepublish": "npm run package",
|
"views": {
|
||||||
"compile": "webpack",
|
"explorer": [
|
||||||
"watch": "webpack --watch",
|
{
|
||||||
"package": "webpack --mode production --devtool hidden-source-map",
|
"id": "webview-sidebar.view",
|
||||||
"compile-tests": "tsc -p . --outDir out",
|
"icon": "./icons/protocol.svg",
|
||||||
"watch-tests": "tsc -p . -w --outDir out",
|
"name": "WebView"
|
||||||
"pretest": "npm run compile-tests && npm run compile && npm run lint",
|
}
|
||||||
"lint": "eslint src",
|
]
|
||||||
"test": "vscode-test"
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"scripts": {
|
||||||
"@types/vscode": "^1.98.0",
|
"vscode:prepublish": "npm run package",
|
||||||
"@types/mocha": "^10.0.10",
|
"compile": "webpack",
|
||||||
"@types/node": "20.x",
|
"watch": "webpack --watch",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.25.0",
|
"package": "webpack --mode production --devtool hidden-source-map",
|
||||||
"@typescript-eslint/parser": "^8.25.0",
|
"compile-tests": "tsc -p . --outDir out",
|
||||||
"eslint": "^9.21.0",
|
"watch-tests": "tsc -p . -w --outDir out",
|
||||||
"typescript": "^5.7.3",
|
"pretest": "npm run compile-tests && npm run compile && npm run lint",
|
||||||
"ts-loader": "^9.5.2",
|
"lint": "eslint src",
|
||||||
"webpack": "^5.98.0",
|
"test": "vscode-test"
|
||||||
"webpack-cli": "^6.0.1",
|
},
|
||||||
"@vscode/test-cli": "^0.0.10",
|
"devDependencies": {
|
||||||
"@vscode/test-electron": "^2.4.1"
|
"@types/vscode": "^1.98.0",
|
||||||
}
|
"@types/mocha": "^10.0.10",
|
||||||
}
|
"@types/node": "20.x",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^8.25.0",
|
||||||
|
"@typescript-eslint/parser": "^8.25.0",
|
||||||
|
"eslint": "^9.21.0",
|
||||||
|
"typescript": "^5.7.3",
|
||||||
|
"ts-loader": "^9.5.2",
|
||||||
|
"webpack": "^5.98.0",
|
||||||
|
"webpack-cli": "^6.0.1",
|
||||||
|
"@vscode/test-cli": "^0.0.10",
|
||||||
|
"@vscode/test-electron": "^2.4.1"
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +1,50 @@
|
|||||||
// The module 'vscode' contains the VS Code extensibility API
|
|
||||||
// Import the module and reference it with the alias vscode in your code below
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
// This method is called when your extension is activated
|
|
||||||
// Your extension is activated the very first time the command is executed
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
|
// 注册 WebView 视图
|
||||||
|
console.log('activate');
|
||||||
|
|
||||||
|
const provider = new WebviewViewProvider(context.extensionUri);
|
||||||
|
|
||||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
context.subscriptions.push(
|
||||||
// This line of code will only be executed once when your extension is activated
|
vscode.commands.registerCommand('openmcp.helloWorld', () => {
|
||||||
console.log('Congratulations, your extension "openmcp" is now active!');
|
vscode.window.showInformationMessage('Hello World!');
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
// The command has been defined in the package.json file
|
context.subscriptions.push(
|
||||||
// Now provide the implementation of the command with registerCommand
|
vscode.window.registerWebviewViewProvider('webview-sidebar.view', provider)
|
||||||
// The commandId parameter must match the command field in package.json
|
);
|
||||||
const disposable = vscode.commands.registerCommand('openmcp.helloWorld', () => {
|
|
||||||
// The code you place here will be executed every time your command is executed
|
|
||||||
// Display a message box to the user
|
|
||||||
vscode.window.showInformationMessage('Hello World from openmcp!');
|
|
||||||
});
|
|
||||||
|
|
||||||
context.subscriptions.push(disposable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method is called when your extension is deactivated
|
class WebviewViewProvider implements vscode.WebviewViewProvider {
|
||||||
export function deactivate() {}
|
constructor(private readonly _extensionUri: vscode.Uri) {}
|
||||||
|
|
||||||
|
public resolveWebviewView(webviewView: vscode.WebviewView) {
|
||||||
|
webviewView.webview.options = {
|
||||||
|
enableScripts: true, // 启用 JavaScript
|
||||||
|
};
|
||||||
|
|
||||||
|
// 设置 WebView 的 HTML 内容
|
||||||
|
webviewView.webview.html = getWebviewContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWebviewContent(): string {
|
||||||
|
return `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>WebView</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello, WebView!</h1>
|
||||||
|
<p>This is a custom WebView in VS Code Sidebar.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deactivate() {}
|
Loading…
x
Reference in New Issue
Block a user