Skip to content

Commit 94f7db9

Browse files
committed
Merge branch 'sunxianfu' into 'dev'
Sunxianfu See merge request cooperation/vscode-rt-smart!2
2 parents 6233c38 + 7d30e93 commit 94f7db9

File tree

12 files changed

+73
-19
lines changed

12 files changed

+73
-19
lines changed

.gitlab-ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
image: node:22
2+
stages:
3+
- deploy
4+
5+
deploy-job: # This job runs in the deploy stage.
6+
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
7+
script:
8+
- npm config set registry https://registry.npmmirror.com
9+
- npm install -g @vscode/vsce
10+
- npm install
11+
- npm run compile
12+
- npm run package:vs
13+
- ls ./
14+
artifacts:
15+
paths:
16+
- "*.vsix" # 所有 .vsix 文件(如 dist/extension.vsix)
17+
expire_in: 1 week # 产物保留 1 周(可选,默认 30 天)
18+
environment: production
19+
when: manual # 标记为手动作业

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
]
177177
},
178178
"scripts": {
179+
"package:vs": "vsce package --no-dependencies",
179180
"vscode:prepublish": "npm run compile",
180181
"build:vue": "npm run build --workspace=smart-vue",
181182
"compile": "npm run build:vue && tsc -p ./",

src/extension.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ import { initCurrentProject } from './project/cmd';
2121

2222
let _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

129141
function 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';

src/vue/about/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="container">
3-
<Banner />
3+
<Banner sub-title="关于" />
44

55
<div class="content_area">
66
<div v-html="readmeMarkdown"></div>

src/vue/components/Banner.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,33 @@
22
<div class="banner">
33
<img src="https://oss-club.rt-thread.org/uploads/20250820/d1558ec1b465f2a3c44646550211a6d5.png" class="logo" />
44
<div class="info">
5-
<h1>{{ title }}</h1>
6-
<p>{{ version }}</p>
5+
<h1>{{ extentionName }}</h1>
6+
<p>{{ extentionVersion }}</p>
77
<div class="bar"></div>
88
</div>
99
</div>
1010
</template>
1111

1212
<script setup lang="ts">
13+
import { ref } from 'vue';
14+
1315
export interface BannerProps {
14-
title?: string
16+
subTitle?: string
1517
version?: string
1618
}
1719
18-
withDefaults(defineProps<BannerProps>(), {
19-
title: '扩展工具 - 关于',
20+
const extentionName = ref('')
21+
const extentionVersion = ref('')
22+
23+
const props = withDefaults(defineProps<BannerProps>(), {
24+
subTitle: '扩展工具 - 关于',
2025
version: '版本 v1.0.1'
2126
})
27+
28+
window.addEventListener('message', (e) => {
29+
e.data.name && (extentionName.value = `${e.data.name} - ${props.subTitle}`)
30+
e.data.version && (extentionVersion.value = e.data.version)
31+
})
2232
</script>
2333

2434
<style scoped>

src/vue/create-project/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="container">
3-
<Banner />
3+
<Banner sub-title="创建项目" />
44

55
<div class="content_area">
66
<div class="body-box">

src/vue/projects/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="container">
3-
<Banner />
3+
<Banner sub-title="项目" />
44

55
<div class="content_area">
66
<br>

src/vue/setting/view/layout/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="common-layout">
3-
<Banner />
3+
<Banner sub-title="设置" />
44

55
<el-aside>
66
<el-menu

src/webviews/about.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as os from 'os';
33
import * as fs from 'fs';
44
import * as marked from 'marked';
55
import * as path from 'path';
6+
import { postMessageExtensionData } from '../extension';
67

78
let aboutViewPanel: vscode.WebviewPanel | null = null;
89
const name = "about";
@@ -83,5 +84,7 @@ export function openAboutWebview(context: vscode.ExtensionContext) {
8384
aboutViewPanel = panel;
8485
}
8586

87+
postMessageExtensionData(context, aboutViewPanel);
88+
8689
return aboutViewPanel;
8790
}

src/webviews/create-project.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from 'path';
33
import * as fs from 'fs';
44
import * as os from 'os';
55
import { getEnvROOT, getExtensionVersion, createProject, readJsonObject, getBoardInfo } from '../api';
6+
import { postMessageExtensionData } from '../extension';
67

78
let createProjectViewPanel: vscode.WebviewPanel | null = null;
89
const name = "create-project";
@@ -34,8 +35,8 @@ let extensionInfo = {
3435
]
3536
}
3637
],
37-
SDKConfig : {},
38-
configInfo : [{name: "RT-Thread", path: "d:/workspace/rt-thread", description: "RT-Thread主干路径"}]
38+
SDKConfig: {},
39+
configInfo: [{ name: "RT-Thread", path: "d:/workspace/rt-thread", description: "RT-Thread主干路径" }]
3940
};
4041

4142
function readReadmeFile(fn: string): string {
@@ -146,7 +147,7 @@ export function openCreateProjectWebview(context: vscode.ExtensionContext) {
146147
case 'createProject':
147148
if (message.args && message.args.length > 0) {
148149
const project = message.args[0];
149-
150+
150151
// 调用创建工程的API - 参数顺序: folder, projectInfo
151152
createProject(project.folder, project);
152153
}
@@ -178,6 +179,8 @@ export function openCreateProjectWebview(context: vscode.ExtensionContext) {
178179
createProjectViewPanel = null;
179180
}, null, context.subscriptions);
180181
}
182+
183+
postMessageExtensionData(context, createProjectViewPanel);
181184
}
182185

183186
export function isCreateProjectWebviewActive(): boolean {

0 commit comments

Comments
 (0)