Skip to content

Commit 8096a16

Browse files
committed
feat: 使用新的配置方式,将配置内容保存在 .lowcoderc 文件中
1 parent 2023fec commit 8096a16

File tree

13 files changed

+235
-342
lines changed

13 files changed

+235
-342
lines changed

package.json

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,11 @@
111111
"submenus": [
112112
{
113113
"id": "lowcode/editor/context",
114-
"label": "$(octoface) Low Code",
115-
"icon": "$(octoface)"
114+
"label": "Low Code"
116115
},
117116
{
118117
"id": "lowcode/explorer/context",
119-
"label": "$(octoface) Low Code",
120-
"icon": "$(octoface)"
118+
"label": "Low Code"
121119
}
122120
],
123121
"viewsContainers": {
@@ -142,53 +140,7 @@
142140
"view": "lowcode.welcome",
143141
"contents": "[打开文件夹](command:lowcode.openFolderForceNewWindow)\n[创建应用](command:lowcode.openScaffold)\n[设置](command:lowcode.openConfig)\n查看[文档](https://lowcoding.gitee.io)以学习如何在 VS Code 中如何使用 lowcode。"
144142
}
145-
],
146-
"configuration": {
147-
"type": "object",
148-
"title": "yapi-code 配置项",
149-
"properties": {
150-
"yapi-code.domain": {
151-
"type": "string",
152-
"default": "",
153-
"description": "域名"
154-
},
155-
"yapi-code.project": {
156-
"type": "array",
157-
"default": [],
158-
"description": "项目列表。eg.[{\"name\": \"项目\",\"token\": \"token\"}]"
159-
},
160-
"yapi-code.templatePath": {
161-
"type": "string",
162-
"default": "codeTemplate/",
163-
"description": "模板存放路径"
164-
},
165-
"yapi-code.mockNumber": {
166-
"type": "string",
167-
"default": "Random.natural(1000,1000)",
168-
"description": "模拟number数据"
169-
},
170-
"yapi-code.mockBoolean": {
171-
"type": "string",
172-
"default": "false",
173-
"description": "模拟boolean数据"
174-
},
175-
"yapi-code.mockString": {
176-
"type": "string",
177-
"default": "Random.cword(5, 7)",
178-
"description": "模拟string数据"
179-
},
180-
"yapi-code.mockKeyWordEqual": {
181-
"type": "object",
182-
"default": {},
183-
"description": "模拟关键词-全等匹配"
184-
},
185-
"yapi-code.mockKeyWordLike": {
186-
"type": "object",
187-
"default": {},
188-
"description": "模拟关键词-相似匹配"
189-
}
190-
}
191-
}
143+
]
192144
},
193145
"devDependencies": {
194146
"@types/copy-paste": "^1.1.30",
@@ -234,4 +186,4 @@
234186
"tar": "^6.0.5",
235187
"typescript-json-schema": "^0.50.1"
236188
}
237-
}
189+
}

src/commands/quickGenerateBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { commands, ExtensionContext, window } from 'vscode';
2-
import { getCommonlyUsedBlock } from '../config';
2+
import { getConfig } from '../utils/config';
33
import { genCodeByBlockWithDefaultModel } from '../utils/generate';
44
import { formatPath } from '../utils/platform';
55

66
export const registerQuickGenerateBlock = (context: ExtensionContext) => {
77
context.subscriptions.push(
88
commands.registerCommand('lowcode.quickGenerateBlock', async (args) => {
99
const path = formatPath(args.path);
10-
const blocks = getCommonlyUsedBlock();
10+
const blocks = getConfig().commonlyUsedBlock || [];
1111
if (blocks.length < 1) {
1212
window.showWarningMessage('未配置常用区块', {
1313
modal: true,

src/config.ts

Lines changed: 0 additions & 186 deletions
This file was deleted.

src/genCode/genCodeByYapi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { window } from 'vscode';
22
import { compile } from 'json-schema-to-typescript';
3-
import { getDomain, getProjectList } from '../config';
43
import { compile as compileEjs, Model } from '../utils/ejs';
54
import { getSnippets } from '../utils/materials';
65
import { fetchApiDetailInfo } from '../utils/request';
76
import { getFuncNameAndTypeName, pasteToEditor } from '../utils/editor';
87
import { mockFromSchema } from '../utils/json';
8+
import { getConfig } from '../utils/config';
99

1010
const strip = require('strip-comments');
1111
const stripJsonComments = require('strip-json-comments');
@@ -15,12 +15,12 @@ export const genCodeByYapi = async (
1515
yapiId: string,
1616
rawClipboardText: string,
1717
) => {
18-
const domain = getDomain();
18+
const domain = getConfig().yapi?.domain || '';
1919
if (!domain.trim()) {
2020
window.showErrorMessage('请配置yapi域名');
2121
return;
2222
}
23-
const projectList = getProjectList();
23+
const projectList = getConfig().yapi?.projects || [];
2424
if (projectList.length === 0) {
2525
window.showErrorMessage('请配置项目');
2626
return;

0 commit comments

Comments
 (0)