From 84e3484e58d5af53b1b060e4bd0d5dfe3b420d77 Mon Sep 17 00:00:00 2001 From: wjkang Date: Tue, 4 Jun 2024 00:16:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20resetMaterialName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/utils/generate.ts | 5 +++-- src/utils/name.ts | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 src/utils/name.ts diff --git a/package.json b/package.json index a9539ed..e904132 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "lowcode", "description": "lowcode tool, support ChatGPT and other LLM", "author": "wjkang ", - "version": "1.8.1", + "version": "1.8.2", "icon": "asset/icon.png", "publisher": "wjkang", "repository": "https://github.com/lowcoding/lowcode-vscode", diff --git a/src/utils/generate.ts b/src/utils/generate.ts index 22aaa2a..4d637d4 100644 --- a/src/utils/generate.ts +++ b/src/utils/generate.ts @@ -19,6 +19,7 @@ import { getOutputChannel } from './outputChannel'; import { getLastActiveTextEditor } from '../context'; import { getSyncFolder } from './config'; import { createChatCompletionForScript } from './llm'; +import { resetMaterialName } from './name'; export const genCodeByBlock = async (data: { material: string; @@ -36,7 +37,7 @@ export const genCodeByBlock = async (data: { data.privateMaterials ? getPrivateBlockMaterialsPath() : blockMaterialsPath, - data.material, + resetMaterialName(data.material), ); const schemaFile = path.join(block, 'config/schema.json'); const schama = fs.readJSONSync(schemaFile); @@ -161,7 +162,7 @@ export const genCodeBySnippet = async (data: { data.privateMaterials ? getPrivateSnippetMaterialsPath() : snippetMaterialsPath, - data.name, + resetMaterialName(data.name), ); const scriptFile = path.join(snippetPath, 'script/index.js'); const hook = { diff --git a/src/utils/name.ts b/src/utils/name.ts new file mode 100644 index 0000000..dea3b4f --- /dev/null +++ b/src/utils/name.ts @@ -0,0 +1,4 @@ +export const resetMaterialName = (name: string) => { + const arrayStr = name.split('] '); + return arrayStr[1] || name; +};