-
Notifications
You must be signed in to change notification settings - Fork 4
/
package.json
195 lines (195 loc) · 11.8 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
{
"name": "roothub",
"displayName": "RootHub",
"description": "RootHub 前端研发平台",
"version": "1.3.4",
"author": "giscafer <[email protected]>",
"repository": {
"type": "git",
"url": "https://github.com/RootLinkFE/vscode-roothub.git"
},
"license": "MIT",
"keywords": [
"roothub",
"codegen",
"vscode",
"frontend",
"openApi"
],
"publisher": "giscafer",
"icon": "resources/logo.png",
"engines": {
"vscode": "^1.65.0"
},
"categories": [
"Other"
],
"activationEvents": [
"*"
],
"main": "./dist/extension.js",
"contributes": {
"viewsContainers": {
"activitybar": [
{
"id": "roothub",
"title": "RootHub 前端研发平台",
"icon": "resources/logo.svg"
}
]
},
"views": {
"roothub": [
{
"id": "views.welcome",
"name": "Welcome"
},
{
"id": "views.tools",
"name": "Tools"
}
]
},
"viewsWelcome": [
{
"view": "views.welcome",
"contents": "欢迎使用 RootHub。\n[打开RootHub](http://roothub.leekhub.com/)\n查看[文档](https://marketplace.visualstudio.com/items?itemName=giscafer.roothub)以学习如何在 VS Code 中如何使用 RootHub App。"
},
{
"view": "view.tools",
"contents": "出错了!!欢迎提Issues >> [Github](https://github.com/RootLinkFE/vscode-roothub)"
}
],
"menus": {
"editor/context": [
{
"command": "roothub.codegen.AutoMatchActiveText",
"group": "navigation",
"when": "editorTextFocus"
},
{
"command": "roothub.codegen.SearchFixedText",
"group": "navigation",
"when": "editorTextFocus"
}
]
},
"commands": [
{
"command": "roothub.codegen.AutoMatchActiveText",
"title": "OpenApi-CodeGen匹配代码"
},
{
"command": "roothub.codegen.SearchFixedText",
"title": "OpenApi-CodeGen即时搜索"
}
],
"configuration": {
"properties": {
"codegen.custom-method": {
"type": "array",
"default": [
{
"key": "avueTable",
"label": "avueTable",
"type": "response",
"source": "custom",
"language": "vue",
"description": "avue-table组件自定义方法",
"status": 1,
"sort": 99,
"function": "/**\n * @description: generateAvueTablePageCode\n * selectedData\n * selectedData.requestSelectedData 请求参数-勾选\n * selectedData.responseSelectedData 响应参数-勾选\n * selectedData.modelData 模型参数-勾选\n * selectedData.resourceDetail 当前api菜单完整数据\n * window.utilsFn: {\n getApiNameAsPageName: any;\n prettyCode: any;\n generateTableColumnsProps: any;\n cleanParameterDescription: any;\n filterTransformArrayByRows: any;\n },\n * @return {string}\n */\n\nfunction generateAvueTablePageCode(selectedData, api) {\n const utilsFn = window.utilsFn ?? {};\n let { responseSelectedData: body, transformTextArray } = selectedData;\n if (transformTextArray) {\n body = utilsFn.filterTransformArrayByRows(body, transformTextArray);\n }\n const parametersSet = new Set();\n (api?.parameters ?? []).forEach((param) => {\n parametersSet.add(param.name);\n });\n const columnCode = utilsFn.generateTableColumnsProps(body, true, (row, index) => {\n let result = {\n prop: row.name,\n label: utilsFn.cleanParameterDescription(row.description),\n minWidth: 150,\n overHidden: true,\n };\n const item = parametersSet.has(row.name);\n if (item) {\n result.search = true;\n\n if (\n row.name.indexOf('状态') !== -1 ||\n (row.description && row.description.indexOf('ENUM#') !== -1) ||\n (row.enum && row.enum.length > 0)\n ) {\n result.searchType = 'select';\n }\n if (['date', 'time'].includes(row.name)) {\n result.searchType = 'datetime';\n result.format = 'YYYY-MM-DD HH:mm:ss';\n result.valueFormat = 'YYYY-MM-DD HH:mm:ss';\n }\n }\n return result;\n });\n\n const componentName = utilsFn.getApiNameAsPageName(api.api);\n const matchApiName = api?.api.match(/^\\/api\\/[a-zA-Z]+/);\n const apiName = matchApiName && matchApiName?.length > 0 ? matchApiName[0].replace('/api/', '') : '';\n\n return `<!-- ${api.description ?? api.summary} -->\n<template>\n <avue-crud\n :data=\"records\"\n v-model:page=\"pagination\"\n :table-loading=\"loading\"\n v-model:search=\"searchParams\"\n :option=\"option\"\n v-enter=\"handleSearch\"\n @on-load=\"handleSearch\"\n @search-reset=\"handleSearch\"\n @refresh-change=\"handleSearch\"\n @search-change=\"handleSearch\"\n @size-change=\"handleSearch\"\n @current-change=\"handleSearch\"\n >\n </avue-crud>\n</template>\n\n<script setup>\nimport { ref, computed } from 'vue';\nimport { crudOptions } from '@/core/crud';\nimport { packTableQueryParams, usePageRequest} from '@/util/businessUtil';\nimport { fetch${componentName}List } from '@/api/${apiName}';\n\nconst searchParams = ref({});\n\nconst option = computed(() => ({\n ...crudOptions(),\n addBtn: false,\n editBtn: false,\n delBtn: false,\n searchMenuSpan: 24,\n searchLabelWidth: 120,\n minWidth: 150,\n header: true,\n menu: false,\n column: ${columnCode},\n}));\n\nconst {\n records,\n pagination,\n loading,\n run: fetchTableData,\n} = usePageRequest(fetch${componentName}List, {\n manual: true,\n});\n\nconst handleSearch = (params, done) => {\n const tmp = packTableQueryParams(...searchParams.value, pagination);\n fetchTableData(tmp)\n .then((res) => {\n return res;\n })\n .finally(done);\n};\n</script>\n<style></style>\n\n`;\n}\n"
},
{
"key": "avueApiRequest",
"label": "avueApiRequest",
"type": "api",
"source": "custom",
"language": "javascript",
"description": "avue-api-request",
"status": 1,
"sort": 98,
"function": "/**\n * avue-api-request\n */\nfunction generateApiDefineition(apiData, prefix) {\n const { api, method, parameters, summary } = apiData;\n const utilsFn = window.utilsFn ?? {};\n // window.lodash\n const name = utilsFn.generateApiConstName(apiData) ?? method;\n let apiParams = 'params';\n let apiPath = prefix + api;\n const apiStrReg = /\\{([\\d\\D]*)\\}/g;\n let responseType = '';\n let argumentsData = ['params'];\n let inBody = false;\n let inQuery = false;\n (parameters || []).forEach((v) => {\n if (v.in === 'body') {\n inBody = true;\n } else if (v.in === 'query') {\n inQuery = true;\n }\n });\n // 处理接口传参格式\n if (inBody && inQuery) {\n argumentsData.push('data');\n apiParams = `params,\n data: data`;\n } else if (inQuery) {\n apiParams = 'params';\n } else if (inBody || method === 'post') {\n apiParams = 'data: params';\n }\n\n let packTableData = '';\n if (/(page|list)$/.test(api) || /列表|分页/.test(summary)) {\n packTableData = '.then(packTableData)';\n } else if (/导出/.test(summary)) {\n responseType = 'responseType: blob,';\n packTableData = '';\n }\n\n const matchPathId = apiStrReg.exec(api);\n if (matchPathId) {\n argumentsData.unshift(matchPathId[1]);\n apiPath = apiPath.replace(apiStrReg, function (str) {\n return `$${str}`;\n });\n }\n const notes = utilsFn.generateApiNotes(apiData);\n\n return `${notes}\n export const ${name || 'fetch'} = (${argumentsData.join(', ')}) => {\n return request(\n {\n url: ${'`'}${apiPath}${'`'},\n method: '${method}',\n ${apiParams},\n ${responseType}\n }\n ).then(responseHandle)${packTableData};\n };\n `;\n}\n"
},
{
"key": "baidu-general_basic",
"label": "自定义百度高精度OCR",
"type": "extract",
"source": "custom",
"language": "javascript",
"description": "百度-通用文字识别(高精度)",
"status": 1,
"sort": 97,
"function": "function generateExtractBaiduOcrapi(file, base64Image) {\n async function generateExtract(file, base64Image) {\n const utilsFn = window.utilsFn ?? {};\n const getFiletoBase64 = (f) => {\n return utilsFn.filetoBase64(f).then((imageBase64) => {\n return imageBase64;\n });\n };\n const imageBase64 = base64Image || await getFiletoBase64(file);\n const formData = new FormData();\n formData.append('image', imageBase64);\n formData.append('language_type', 'CHN_ENG');\n formData.append('detect_language', 'false'); // 是否检测语言\n formData.append('paragraph', 'false'); // 是否输出段落信息\n formData.append('probability', 'false'); // 是否返回识别结果中每一行的置信度\n formData.append('detect_direction', 'false'); // 是否检测图像朝向\n\n const res = await utilsFn.axios({\n method: 'POST',\n url: 'https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic',\n // 通用文字识别(高精度版) - https://ai.baidu.com/ai-doc/OCR/1k3h7y3db\n headers: { 'content-type': 'application/x-www-form-urlencoded' },\n params: {\n access_token: '24.38fa33748c5dd7740905f992d8c8541e.2592000.1682945835.282335-31896638',\n },\n data: formData,\n });\n const { data } = res;\n if (res.status === 200 && data.words_result?.length > 0) {\n return data;\n } else {\n return res;\n }\n }\n return generateExtract(file, base64Image);\n}"
}
],
"description": "自定义代码生成方法"
},
"codegen.setting": {
"type": "object",
"default": {
"language": "zh-CN",
"theme": "default",
"apiurlPrefixList": [],
"baiduTransAppid": "",
"baiduTransSecret": "",
"baiduApiToken": "24.ba24da4592cdd39ac59057f1dc836656.2592000.1687513296.282335-31896638",
"baiduApiTokenExpires": "1684924027509",
"baiduOCRAppid": "",
"baiduOCRSecret": "",
"matchCodeStatus": true,
"matchCodeFnKey": ""
},
"description": "codegen基础设置"
}
}
}
},
"scripts": {
"vscode:prepublish": "yarn run package",
"compile": "webpack",
"watch": "webpack --watch",
"prepackage": "bash ./scripts/build-codegen.sh",
"package": "webpack --mode production --devtool hidden-source-map",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "yarn run compile-tests && yarn run compile && yarn run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js",
"deploy": "vsce publish --yarn"
},
"devDependencies": {
"@types/glob": "^7.2.0",
"@types/mocha": "^9.1.0",
"@types/node": "14.x",
"@types/vscode": "^1.65.0",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"@vscode/test-electron": "^2.1.2",
"copy-webpack-plugin": "^10.2.4",
"eslint": "^8.9.0",
"glob": "^7.2.0",
"mocha": "^9.2.1",
"ts-loader": "^9.2.6",
"typescript": "^4.5.5",
"vsce": "^2.6.7",
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2"
},
"dependencies": {
"axios": "^0.26.0",
"bufferutil": "^4.0.6",
"event-emitter-enhancer": "^2.0.0",
"eventemitter2": "^6.4.5",
"events": "^3.3.0",
"fs-extra": "^10.0.1",
"get-port": "5.1.1",
"karma-chrome-launcher": "^3.1.0",
"os-name": "^5.0.1",
"public-ip": "^5.0.0",
"puppeteer-core": "^13.4.1",
"utf-8-validate": "^5.0.8",
"uuid": "^8.3.2",
"which-chrome": "^0.1.1"
}
}