Skip to content

Commit

Permalink
chore: add minapp-vscode init check (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
iChenLei authored Nov 16, 2021
1 parent aee5de9 commit 9b653b1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.4.3 / 2021-11-16
==================

* 增加`minapp-vscode:init`context标志位,非小程序项目不展示`New Miniprogram Component`功能

2.4.2 / 2021-11-16
==================

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "minapp-vscode",
"displayName": "WXML - Language Service",
"description": "wechat miniprogram .wxml file syntax highlight,code autocomplete(support native miniprogram、mpvue and wepy framework,provide code snippets)",
"version": "2.4.2",
"version": "2.4.3",
"publisher": "qiu8310",
"extensionKind": [
"workspace"
Expand Down Expand Up @@ -296,7 +296,7 @@
{
"command": "minapp-vscode.createMiniprogramComponent",
"group": "navigation@10",
"when": "resourceExtname == '' && activeViewlet == 'workbench.view.explorer'"
"when": "minapp-vscode:init && resourceExtname == '' && activeViewlet == 'workbench.view.explorer'"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions src/commands/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const COMMANDS = {
createComponent: 'minapp-vscode.createMiniprogramComponent'
}

export const CONTEXT_KEYS = {
init: "minapp-vscode:init"
}
5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import VueAutoCompletion from './plugin/VueAutoCompletion'
import ActiveTextEditorListener from './plugin/ActiveTextEditorListener'
import { config, configActivate, configDeactivate } from './plugin/lib/config'
import { createMiniprogramComponent } from './commands/createMiniprogramComponent'
import { COMMANDS } from './commands/constants'
import { COMMANDS, CONTEXT_KEYS } from './commands/constants'

export function activate(context: ExtensionContext): void {
configActivate()
Expand Down Expand Up @@ -76,6 +76,9 @@ export function activate(context: ExtensionContext): void {
// trigger 需要是上两者的和
languages.registerCompletionItemProvider(vue, autoCompletionVue, '<', ' ', ':', '@', '.', '-', '(', '"', "'")
)

// 标记插件激活状态
commands.executeCommand('setContext', CONTEXT_KEYS.init, true);
}

export function deactivate(): void {
Expand Down

0 comments on commit 9b653b1

Please sign in to comment.