Skip to content

Commit 1602b6a

Browse files
committed
✨ feat: generateCodeV2
1 parent caa6cdf commit 1602b6a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/commands/generateCodeV2.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as vscode from 'vscode';
2+
import { getSnippets } from '../utils/materials';
3+
4+
const { window } = vscode;
5+
6+
export const registerGenerateCodeV2 = (context: vscode.ExtensionContext) => {
7+
context.subscriptions.push(
8+
vscode.commands.registerTextEditorCommand(
9+
'lowcode.generateCodeV2',
10+
async () => {
11+
const templateList = getSnippets().filter(
12+
(s) => !s.preview.notShowInCommand,
13+
);
14+
if (templateList.length === 0) {
15+
window.showErrorMessage('请配置模板(代码片段)');
16+
}
17+
const templateResult = await window.showQuickPick(
18+
templateList.map((s) => s.name),
19+
{ placeHolder: '请选择模板' },
20+
);
21+
if (!templateResult) {
22+
return;
23+
}
24+
const template = templateList.find((s) => s.name === templateResult);
25+
if (template?.privateMaterials) {
26+
}
27+
},
28+
),
29+
);
30+
};

src/utils/materials.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export function getSnippets() {
193193
commandPrompt?: string; // 优先级比 preview.chatGPT 高
194194
viewPrompt?: string; // 优先级比 preview.chatGPT 高
195195
template: string;
196+
privateMaterials?: boolean;
196197
}[] = getCodeTemplateListFromFiles().map((s) => ({
197198
path: s.name,
198199
name: s.name,
@@ -203,6 +204,7 @@ export function getSnippets() {
203204
category: [],
204205
},
205206
template: s.template,
207+
privateMaterials: false,
206208
}));
207209
let snippetsMaterials = getLocalMaterials('snippets', snippetMaterialsPath);
208210
if (getPrivateSnippetMaterialsPath()) {

0 commit comments

Comments
 (0)