diff --git a/.vscode/launch.json b/.vscode/launch.json index 0f3cf01..c42edc0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,8 +10,7 @@ "type": "extensionHost", "request": "launch", "args": [ - "--extensionDevelopmentPath=${workspaceFolder}", - "--disable-extensions" + "--extensionDevelopmentPath=${workspaceFolder}" ], "outFiles": [ "${workspaceFolder}/dist/**/*.js" diff --git a/README.md b/README.md index 3733d18..149f192 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,10 @@ # gitcommitfilter README -This is the README for your extension "gitcommitfilter". After writing up a brief description, we recommend including the following sections. +git仓库提交历史过滤查询 ## Features -Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. - -For example if there is an image subfolder under your extension project workspace: - -\!\[feature X\]\(images/feature-x.png\) - -> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. +git仓库提交历史过滤查询 ## Requirements @@ -18,54 +12,10 @@ If you have any requirements or dependencies, add a section describing those and ## Extension Settings -Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. -For example: - -This extension contributes the following settings: - -* `myExtension.enable`: Enable/disable this extension. -* `myExtension.thing`: Set to `blah` to do something. ## Known Issues -Calling out known issues can help limit users opening duplicate issues against your extension. ## Release Notes -Users appreciate release notes as you update your extension. - -### 1.0.0 - -Initial release of ... - -### 1.0.1 - -Fixed issue #. - -### 1.1.0 - -Added features X, Y, and Z. - ---- - -## Following extension guidelines - -Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension. - -* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines) - -## Working with Markdown - -You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: - -* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux). -* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux). -* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets. - -## For more information - -* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) -* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) - -**Enjoy!** diff --git a/package.json b/package.json index 773e9f3..a706261 100644 --- a/package.json +++ b/package.json @@ -9,19 +9,13 @@ "categories": [ "Other" ], + "extensionKind": [ + "ui", + "workspace" + ], "activationEvents": [], "main": "./dist/extension.js", "contributes": { - "commands": [ - { - "command": "gitcommitfilter.helloWorld", - "title": "Hello World" - }, - { - "command": "gitcommitfilter.showCommitPanel", - "title": "Show Git Commits" - } - ], "viewsContainers": { "activitybar": [ { @@ -34,8 +28,9 @@ "views": { "gitCommitFilterView": [ { - "id": "gitCommitFilter", - "name": "Git Commits", + "type": "webview", + "id": "gitcommitfilter.view", + "name": "MyCustomView", "when": "true" } ] diff --git a/src/CommitPanel.ts b/src/CommitPanel.ts deleted file mode 100644 index 75b0669..0000000 --- a/src/CommitPanel.ts +++ /dev/null @@ -1,129 +0,0 @@ -import * as vscode from 'vscode'; -import { GitService } from './GitService'; - -export class CommitPanel { - public static currentPanel: CommitPanel | undefined; - private readonly _panel: vscode.WebviewPanel; - private readonly _extensionPath: string; - private readonly _gitService: GitService; - private _disposables: vscode.Disposable[] = []; - - public static show(extensionContext: vscode.ExtensionContext, gitService: GitService) { - const column = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.viewColumn : undefined; - - if (CommitPanel.currentPanel) { - CommitPanel.currentPanel._panel.reveal(column); - return; - } - - const panel = vscode.window.createWebviewPanel( - 'commitPanel', - 'Git Commits', - column || vscode.ViewColumn.One, - { - enableScripts: true - } - ); - - // 修正:传递正确的参数 - CommitPanel.currentPanel = new CommitPanel(panel, extensionContext, gitService); - } - - constructor(panel: vscode.WebviewPanel, extensionContext: vscode.ExtensionContext, gitService: GitService) { - this._panel = panel; - this._extensionPath = extensionContext.extensionPath; - this._gitService = gitService; - - this._panel.onDidDispose(() => this.dispose(), null, this._disposables); - this._panel.onDidChangeViewState(e => { - if (this._panel.visible) { - this._update(); - } - }, null, this._disposables); - - this._panel.webview.onDidReceiveMessage(message => { - switch (message.command) { - case 'filterCommits': - this._filterCommits(message.filter); - return; - case 'showCommitFiles': - this._showCommitFiles(message.commit); - return; - } - }, null, this._disposables); - - this._update(); - } - - public dispose() { - CommitPanel.currentPanel = undefined; - - this._panel.dispose(); - - while (this._disposables.length) { - const x = this._disposables.pop(); - if (x) { - x.dispose(); - } - } - } - - private async _update() { - const commits = await this._gitService.getCommits(); - this._panel.webview.html = this._getHtmlForWebview(commits); - } - - private async _filterCommits(filter: string) { - const commits = await this._gitService.getCommits(filter); - this._panel.webview.postMessage({ command: 'updateCommits', commits }); - } - - private async _showCommitFiles(commit: string) { - const files = await this._gitService.getCommitFiles(commit); - this._panel.webview.postMessage({ command: 'showCommitFiles', files }); - } - - private _getHtmlForWebview(commits: any[]) { - const commitListHtml = commits.map(commit => `