Skip to content

fix: complete the locale file #752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions client/packages/lowcoder/src/i18n/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ prop: {
expand: "展开",
columns: "列",
rowSelection: "行选择",
toolbar: "工具栏",
toolbar: "工具栏",
pagination: "分页",
logo: "标志",
style: "样式",
Expand Down Expand Up @@ -358,6 +358,7 @@ style: {
textSize: "字体大小",
textWeight: "字体粗细",
"fontFamily": "字体",
"fontStyle": "字体风格",
"backgroundImage": "背景图片",
"backgroundImageRepeat" : "背景图片重复",
"backgroundImageSize" : "背景图片大小",
Expand Down Expand Up @@ -1086,7 +1087,7 @@ selectInput: {
valueDesc: "当前选择的值",
selectedIndexDesc: "当前选择的值的索引,如果未选择任何值则为-1",
selectedLabelDesc: "当前选择的值的标签",
},
},
file: {
typeErrorMsg: "必须是一个带有有效文件大小单位的数字,或者是一个无单位的字节数.",
fileEmptyErrorMsg: "上传失败.文件大小为空.",
Expand Down Expand Up @@ -2327,7 +2328,7 @@ componentDoc: {
event: "事件",
eventName: "事件名称",
eventDesc: "描述",
mehtod: "方法",
mehtod: "方法",
methodUsage: "您可以通过方法与组件进行交互,并且可以在任何可以编写 JavaScript 的地方通过它们的名称调用它们.或者您可以通过事件的“控制组件”操作来调用它们.",
methodName: "方法名称",
methodDesc: "描述",
Expand Down Expand Up @@ -2561,7 +2562,7 @@ componentDocExtra: {
table: table,
},
idSource: {
title: "用户认证提供商",
title: "用户认证提供商",
form: "电子邮件",
pay: "高级",
enable: "启用",
Expand Down Expand Up @@ -2723,4 +2724,4 @@ timeLine: {
navStyle: "菜单风格",
navItemStyle: "菜单项样式",
}
};
};
6 changes: 4 additions & 2 deletions server/node-service/src/plugins/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { OpenAPIV3, OpenAPI } from "openapi-types";
import { ConfigToType, DataSourcePlugin } from "lowcoder-sdk/dataSource";
import { runOpenApi } from "../openApi";
import { parseOpenApi, ParseOpenApiOptions } from "../openApi/parse";
import SwaggerParser from "@apidevtools/swagger-parser";

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

Expand Down Expand Up @@ -34,6 +35,7 @@ const parseOptions: ParseOpenApiOptions = {
return _.upperFirst(operation.operationId || "");
},
};
const deRefedSpec = SwaggerParser.dereference(spec);

type DataSourceConfigType = ConfigToType<typeof dataSourceConfig>;

Expand All @@ -55,13 +57,13 @@ const gitHubPlugin: DataSourcePlugin<any, DataSourceConfigType> = {
actions,
};
},
run: function (actionData, dataSourceConfig): Promise<any> {
run: async function (actionData, dataSourceConfig, ctx): Promise<any> {
const runApiDsConfig = {
url: "",
serverURL: "https://api.github.com",
dynamicParamsConfig: dataSourceConfig,
};
return runOpenApi(actionData, runApiDsConfig, spec as OpenAPIV3.Document);
return runOpenApi(actionData, runApiDsConfig, spec as OpenAPIV3.Document, undefined, await deRefedSpec);
},
};

Expand Down
45 changes: 28 additions & 17 deletions server/node-service/src/plugins/openApi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import {
isFile,
} from "./util";
import { badRequest } from "../../common/error";
import { safeJsonParse } from "../../common/util";
import { OpenAPI, OpenAPIV2, OpenAPIV3 } from "openapi-types";
import _ from "lodash";
import { fetch } from "../../common/fetch";
import { RequestInit, Response } from "node-fetch";
import { RequestInit } from "node-fetch";

const dataSourceConfig = {
type: "dataSource",
Expand Down Expand Up @@ -50,30 +49,42 @@ interface ActionDataType {
[key: string]: any;
}

async function getDefinitions(
spec: OpenAPI.Document | MultiOpenApiSpecItem[],
openApiSpecDereferenced?: OpenAPI.Document,
): Promise<{ def: OpenAPI.Document; id: string }[]> {
if (openApiSpecDereferenced) {
return [{
def: openApiSpecDereferenced,
id: "",
}]
} else {
const specList = Array.isArray(spec) ? spec : [{ spec, id: "" }];
return await Promise.all(
specList.map(async ({id, spec}) => {
const deRefedSpec = await SwaggerParser.dereference(spec);
return {
def: deRefedSpec,
id,
};
})
);
}
}

export async function runOpenApi(
actionData: ActionDataType,
dataSourceConfig: DataSourceDataType,
spec: OpenAPI.Document | MultiOpenApiSpecItem[],
defaultHeaders?: Record<string, string>
defaultHeaders?: Record<string, string>,
openApiSpecDereferenced?: OpenAPI.Document,
) {
const specList = Array.isArray(spec) ? spec : [{ spec, id: "" }];
const definitions = await Promise.all(
specList.map(async ({ id, spec }) => {
const deRefedSpec = await SwaggerParser.dereference(spec);
return {
def: deRefedSpec,
id,
};
})
);
const { actionName, ...otherActionData } = actionData;
const { serverURL } = dataSourceConfig;

let definition: OpenAPI.Document | undefined;
let operation;
let realOperationId;
let operation, realOperationId, definition: OpenAPI.Document | undefined;

for (const { id, def } of definitions) {
for (const {id, def} of await getDefinitions(spec, openApiSpecDereferenced)) {
const ret = findOperation(actionName, def, id);
if (ret) {
definition = def;
Expand Down