Skip to content

Commit a222250

Browse files
authored
Merge pull request #752 from cnelf/fix/complete-the-locale-file
fix: complete the locale file
2 parents da0c2aa + a722043 commit a222250

File tree

3 files changed

+38
-24
lines changed
  • client/packages/lowcoder/src/i18n/locales
  • server/node-service/src/plugins

3 files changed

+38
-24
lines changed

client/packages/lowcoder/src/i18n/locales/zh.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ prop: {
140140
expand: "展开",
141141
columns: "列",
142142
rowSelection: "行选择",
143-
toolbar: "工具栏",
143+
toolbar: "工具栏",
144144
pagination: "分页",
145145
logo: "标志",
146146
style: "样式",
@@ -358,6 +358,7 @@ style: {
358358
textSize: "字体大小",
359359
textWeight: "字体粗细",
360360
"fontFamily": "字体",
361+
"fontStyle": "字体风格",
361362
"backgroundImage": "背景图片",
362363
"backgroundImageRepeat" : "背景图片重复",
363364
"backgroundImageSize" : "背景图片大小",
@@ -1086,7 +1087,7 @@ selectInput: {
10861087
valueDesc: "当前选择的值",
10871088
selectedIndexDesc: "当前选择的值的索引,如果未选择任何值则为-1",
10881089
selectedLabelDesc: "当前选择的值的标签",
1089-
},
1090+
},
10901091
file: {
10911092
typeErrorMsg: "必须是一个带有有效文件大小单位的数字,或者是一个无单位的字节数.",
10921093
fileEmptyErrorMsg: "上传失败.文件大小为空.",
@@ -2327,7 +2328,7 @@ componentDoc: {
23272328
event: "事件",
23282329
eventName: "事件名称",
23292330
eventDesc: "描述",
2330-
mehtod: "方法",
2331+
mehtod: "方法",
23312332
methodUsage: "您可以通过方法与组件进行交互,并且可以在任何可以编写 JavaScript 的地方通过它们的名称调用它们.或者您可以通过事件的“控制组件”操作来调用它们.",
23322333
methodName: "方法名称",
23332334
methodDesc: "描述",
@@ -2561,7 +2562,7 @@ componentDocExtra: {
25612562
table: table,
25622563
},
25632564
idSource: {
2564-
title: "用户认证提供商",
2565+
title: "用户认证提供商",
25652566
form: "电子邮件",
25662567
pay: "高级",
25672568
enable: "启用",
@@ -2723,4 +2724,4 @@ timeLine: {
27232724
navStyle: "菜单风格",
27242725
navItemStyle: "菜单项样式",
27252726
}
2726-
};
2727+
};

server/node-service/src/plugins/github/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { OpenAPIV3, OpenAPI } from "openapi-types";
55
import { ConfigToType, DataSourcePlugin } from "lowcoder-sdk/dataSource";
66
import { runOpenApi } from "../openApi";
77
import { parseOpenApi, ParseOpenApiOptions } from "../openApi/parse";
8+
import SwaggerParser from "@apidevtools/swagger-parser";
89

910
const spec = readYaml(path.join(__dirname, "./github.spec.yaml"));
1011

@@ -34,6 +35,7 @@ const parseOptions: ParseOpenApiOptions = {
3435
return _.upperFirst(operation.operationId || "");
3536
},
3637
};
38+
const deRefedSpec = SwaggerParser.dereference(spec);
3739

3840
type DataSourceConfigType = ConfigToType<typeof dataSourceConfig>;
3941

@@ -55,13 +57,13 @@ const gitHubPlugin: DataSourcePlugin<any, DataSourceConfigType> = {
5557
actions,
5658
};
5759
},
58-
run: function (actionData, dataSourceConfig): Promise<any> {
60+
run: async function (actionData, dataSourceConfig, ctx): Promise<any> {
5961
const runApiDsConfig = {
6062
url: "",
6163
serverURL: "https://api.github.com",
6264
dynamicParamsConfig: dataSourceConfig,
6365
};
64-
return runOpenApi(actionData, runApiDsConfig, spec as OpenAPIV3.Document);
66+
return runOpenApi(actionData, runApiDsConfig, spec as OpenAPIV3.Document, undefined, await deRefedSpec);
6567
},
6668
};
6769

server/node-service/src/plugins/openApi/index.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import {
1212
isFile,
1313
} from "./util";
1414
import { badRequest } from "../../common/error";
15-
import { safeJsonParse } from "../../common/util";
1615
import { OpenAPI, OpenAPIV2, OpenAPIV3 } from "openapi-types";
1716
import _ from "lodash";
1817
import { fetch } from "../../common/fetch";
19-
import { RequestInit, Response } from "node-fetch";
18+
import { RequestInit } from "node-fetch";
2019

2120
const dataSourceConfig = {
2221
type: "dataSource",
@@ -50,30 +49,42 @@ interface ActionDataType {
5049
[key: string]: any;
5150
}
5251

52+
async function getDefinitions(
53+
spec: OpenAPI.Document | MultiOpenApiSpecItem[],
54+
openApiSpecDereferenced?: OpenAPI.Document,
55+
): Promise<{ def: OpenAPI.Document; id: string }[]> {
56+
if (openApiSpecDereferenced) {
57+
return [{
58+
def: openApiSpecDereferenced,
59+
id: "",
60+
}]
61+
} else {
62+
const specList = Array.isArray(spec) ? spec : [{ spec, id: "" }];
63+
return await Promise.all(
64+
specList.map(async ({id, spec}) => {
65+
const deRefedSpec = await SwaggerParser.dereference(spec);
66+
return {
67+
def: deRefedSpec,
68+
id,
69+
};
70+
})
71+
);
72+
}
73+
}
74+
5375
export async function runOpenApi(
5476
actionData: ActionDataType,
5577
dataSourceConfig: DataSourceDataType,
5678
spec: OpenAPI.Document | MultiOpenApiSpecItem[],
57-
defaultHeaders?: Record<string, string>
79+
defaultHeaders?: Record<string, string>,
80+
openApiSpecDereferenced?: OpenAPI.Document,
5881
) {
59-
const specList = Array.isArray(spec) ? spec : [{ spec, id: "" }];
60-
const definitions = await Promise.all(
61-
specList.map(async ({ id, spec }) => {
62-
const deRefedSpec = await SwaggerParser.dereference(spec);
63-
return {
64-
def: deRefedSpec,
65-
id,
66-
};
67-
})
68-
);
6982
const { actionName, ...otherActionData } = actionData;
7083
const { serverURL } = dataSourceConfig;
7184

72-
let definition: OpenAPI.Document | undefined;
73-
let operation;
74-
let realOperationId;
85+
let operation, realOperationId, definition: OpenAPI.Document | undefined;
7586

76-
for (const { id, def } of definitions) {
87+
for (const {id, def} of await getDefinitions(spec, openApiSpecDereferenced)) {
7788
const ret = findOperation(actionName, def, id);
7889
if (ret) {
7990
definition = def;

0 commit comments

Comments
 (0)