From 9b653b14ec233445d984e4abbf376b67c9d9e145 Mon Sep 17 00:00:00 2001 From: Lei Chen Date: Tue, 16 Nov 2021 14:36:30 +0800 Subject: [PATCH] chore: add minapp-vscode init check (#126) --- CHANGELOG.md | 5 +++++ package-lock.json | 2 +- package.json | 4 ++-- src/commands/constants.ts | 4 ++++ src/extension.ts | 5 ++++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c3053..049171b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +2.4.3 / 2021-11-16 +================== + +* 增加`minapp-vscode:init`context标志位,非小程序项目不展示`New Miniprogram Component`功能 + 2.4.2 / 2021-11-16 ================== diff --git a/package-lock.json b/package-lock.json index 4c9eba3..e79c420 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "minapp-vscode", - "version": "2.4.2", + "version": "2.4.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4f863e3..d55284a 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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'" } ] }, diff --git a/src/commands/constants.ts b/src/commands/constants.ts index 8136c96..446ca15 100644 --- a/src/commands/constants.ts +++ b/src/commands/constants.ts @@ -1,3 +1,7 @@ export const COMMANDS = { createComponent: 'minapp-vscode.createMiniprogramComponent' } + +export const CONTEXT_KEYS = { + init: "minapp-vscode:init" +} diff --git a/src/extension.ts b/src/extension.ts index acab6cc..c70840d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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() @@ -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 {