From 462067ca96f3c6126e92016ad7405deffc752365 Mon Sep 17 00:00:00 2001 From: dev <710328466@qq.com> Date: Thu, 4 Aug 2022 15:52:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8E=A5=E5=85=A5ytt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 +++-- ytt.config.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 ytt.config.ts diff --git a/package.json b/package.json index 6879720..bfdb60f 100644 --- a/package.json +++ b/package.json @@ -39,15 +39,16 @@ }, "dependencies": { "@ant-design/icons": "^4.7.0", + "@ant-design/pro-components": "^1.1.2", "@ant-design/pro-layout": "^6.15.4", "antd": "^4.20.6", - "@ant-design/pro-components": "^1.1.2", "classnames": "^2.2.6", "dayjs": "^1.11.2", "js-cookie": "^2.2.1", "react": "^17.0.1", "react-dom": "^17.0.1", - "umi": "^3.5.15" + "umi": "^3.5.15", + "yapi-to-typescript": "^3.34.1" }, "devDependencies": { "@nicecode/commit-lint": "^0.1.2", diff --git a/ytt.config.ts b/ytt.config.ts new file mode 100644 index 0000000..aa3db05 --- /dev/null +++ b/ytt.config.ts @@ -0,0 +1,36 @@ +import { defineConfig } from 'yapi-to-typescript' + +export default defineConfig([ + { + serverUrl: 'http://yapi.jzxer.cn', + typesOnly: false, + target: 'typescript', + reactHooks: { + enabled: false, + }, + prodEnvName: 'production', + outputFilePath: 'src/api/index.ts', + requestFunctionFilePath: 'src/utils/request.ts', + dataKey: 'data', + projects: [ + { + token: '', + categories: [ + { + id: 0, + getRequestFunctionName(interfaceInfo, changeCase) { + // 以接口全路径生成请求函数名 + return changeCase.camelCase(interfaceInfo.path) + + // 若生成的请求函数名存在语法关键词报错、或想通过某个关键词触发 IDE 自动引入提示,可考虑加前缀,如: + // return changeCase.camelCase(`api_${interfaceInfo.path}`) + + // 若生成的请求函数名有重复报错,可考虑将接口请求方式纳入生成条件,如: + // return changeCase.camelCase(`${interfaceInfo.method}_${interfaceInfo.path}`) + }, + }, + ], + }, + ], + }, +]) \ No newline at end of file