@@ -21,6 +21,15 @@ import { initCurrentProject } from './project/cmd';
2121
2222let _context : vscode . ExtensionContext ;
2323
24+ export function postMessageExtensionData ( context : vscode . ExtensionContext , panel : vscode . WebviewPanel ) {
25+ // 获取插件版本号(从 package.json 中读取)
26+ const extensionVersion = context . extension . packageJSON . version ;
27+ const extensionNaeme = context . extension . packageJSON . name ;
28+ // 例如:version 为 "1.0.0"
29+ console . log ( '插件版本号:' , extensionVersion ) ;
30+ panel . webview . postMessage ( { version : extensionVersion , name : extensionNaeme } ) ;
31+ }
32+
2433// 有两种模式
2534// isRTThreadWorksapce - workspace模式,会定位.vscode/workspace.json文件是否存在,是否启用
2635// isRTThread - 项目模式,rtconfig.h文件是否存在
@@ -31,6 +40,11 @@ export async function activate(context: vscode.ExtensionContext) {
3140
3241 _context = context ;
3342
43+ // 获取插件版本号(从 package.json 中读取)
44+ const extensionVersion = context . extension . packageJSON . version ;
45+ // 例如:version 为 "1.0.0"
46+ console . log ( '插件版本号:' , extensionVersion ) ;
47+
3448 // init context for isRTThread, isRTThreadWorksapce
3549 vscode . commands . executeCommand ( 'setContext' , 'isRTThread' , isRTThread ) ;
3650 context . workspaceState . update ( 'isRTThread' , isRTThread ) ;
@@ -86,12 +100,10 @@ export async function activate(context: vscode.ExtensionContext) {
86100
87101 // register commands
88102 vscode . commands . registerCommand ( 'extension.executeCommand' , ( arg1 , arg2 ) => {
89- if ( arg1 )
90- {
103+ if ( arg1 ) {
91104 executeCommand ( arg1 ) ;
92105 }
93- if ( arg2 )
94- {
106+ if ( arg2 ) {
95107 executeCommand ( arg2 ) ;
96108 }
97109 } ) ;
@@ -100,7 +112,7 @@ export async function activate(context: vscode.ExtensionContext) {
100112 // open file
101113 vscode . commands . executeCommand ( 'vscode.open' , vscode . Uri . file ( arg . fn ) ) ;
102114 }
103- } )
115+ } ) ;
104116 }
105117 }
106118
@@ -123,11 +135,11 @@ export async function activate(context: vscode.ExtensionContext) {
123135
124136 /* initialize dock view always */
125137 initDockView ( context ) ;
126- initExperimentStatusBarItem ( context )
138+ initExperimentStatusBarItem ( context ) ;
127139}
128140
129141function initExperimentStatusBarItem ( context : vscode . ExtensionContext ) {
130- if ( false ) {
142+ if ( false ) {
131143 const statusItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left , 5 ) ;
132144 statusItem . text = '$(beaker) 实验性功能' ;
133145 statusItem . tooltip = 'Experimental features' ;
0 commit comments