mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-11 04:22:54 +00:00
1
This commit is contained in:
parent
3f90cac389
commit
a89ef3f0ef
51
packages/vite-plugin/dist/index.js
vendored
51
packages/vite-plugin/dist/index.js
vendored
@ -509,9 +509,9 @@
|
||||
/**
|
||||
* 不支持 uniapp-x 平台显示
|
||||
*/
|
||||
function noUniappX(text) {
|
||||
function noUniappX(text, defaultText = "") {
|
||||
if (config.type == "uniapp-x") {
|
||||
return "";
|
||||
return defaultText;
|
||||
}
|
||||
else {
|
||||
return text;
|
||||
@ -672,6 +672,7 @@
|
||||
async function createController() {
|
||||
let controller = "";
|
||||
let chain = "";
|
||||
let pageResponse = "";
|
||||
/**
|
||||
* 递归处理 service 树,生成接口定义
|
||||
* @param d 当前节点
|
||||
@ -729,24 +730,25 @@
|
||||
let res = "";
|
||||
// 实体名
|
||||
const en = item.name || "any";
|
||||
if (config.type == "uniapp-x") {
|
||||
res = "any";
|
||||
}
|
||||
else {
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `PageResponse<${en}>`;
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en} []`;
|
||||
break;
|
||||
case "/info":
|
||||
res = en;
|
||||
break;
|
||||
default:
|
||||
res = "any";
|
||||
break;
|
||||
}
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `${name}PageResponse`;
|
||||
pageResponse += `
|
||||
interface ${name}PageResponse {
|
||||
pagination: PagePagination;
|
||||
list: ${en}[];
|
||||
}
|
||||
`;
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en} []`;
|
||||
break;
|
||||
case "/info":
|
||||
res = en;
|
||||
break;
|
||||
default:
|
||||
res = "any";
|
||||
break;
|
||||
}
|
||||
// 方法描述
|
||||
t += `
|
||||
@ -809,6 +811,8 @@
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
${pageResponse}
|
||||
|
||||
${controller}
|
||||
|
||||
${noUniappX(`interface RequestOptions {
|
||||
@ -995,10 +999,11 @@
|
||||
const en = item.name || "any";
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `PageResponse<${en}>`;
|
||||
res = `${name}PageResponse`;
|
||||
types.push(res);
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en} []`;
|
||||
res = `${en}[]`;
|
||||
break;
|
||||
case "/info":
|
||||
res = en;
|
||||
@ -1013,7 +1018,7 @@
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")})${noUniappX(`: Promise<${res}>`)} {
|
||||
return request({
|
||||
return request<${res}>({
|
||||
url: "/${d[i].namespace}${a.path}",
|
||||
method: "${(a.method || "get").toLocaleUpperCase()}",
|
||||
data,
|
||||
|
||||
@ -92,9 +92,9 @@ function checkName(name: string) {
|
||||
/**
|
||||
* 不支持 uniapp-x 平台显示
|
||||
*/
|
||||
function noUniappX(text: string) {
|
||||
function noUniappX(text: string, defaultText: string = "") {
|
||||
if (config.type == "uniapp-x") {
|
||||
return "";
|
||||
return defaultText;
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
@ -275,6 +275,7 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
|
||||
async function createController() {
|
||||
let controller = "";
|
||||
let chain = "";
|
||||
let pageResponse = "";
|
||||
|
||||
/**
|
||||
* 递归处理 service 树,生成接口定义
|
||||
@ -346,23 +347,27 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
|
||||
// 实体名
|
||||
const en = item.name || "any";
|
||||
|
||||
if (config.type == "uniapp-x") {
|
||||
res = "any";
|
||||
} else {
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `PageResponse<${en}>`;
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en} []`;
|
||||
break;
|
||||
case "/info":
|
||||
res = en;
|
||||
break;
|
||||
default:
|
||||
res = "any";
|
||||
break;
|
||||
}
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `${name}PageResponse`;
|
||||
|
||||
pageResponse += `
|
||||
interface ${name}PageResponse {
|
||||
pagination: PagePagination;
|
||||
list: ${en}[];
|
||||
}
|
||||
`;
|
||||
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en} []`;
|
||||
break;
|
||||
case "/info":
|
||||
res = en;
|
||||
break;
|
||||
default:
|
||||
res = "any";
|
||||
break;
|
||||
}
|
||||
|
||||
// 方法描述
|
||||
@ -433,6 +438,8 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
${pageResponse}
|
||||
|
||||
${controller}
|
||||
|
||||
${noUniappX(`interface RequestOptions {
|
||||
@ -651,10 +658,11 @@ function createServiceCode(): { content: string; types: string[] } {
|
||||
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `PageResponse<${en}>`;
|
||||
res = `${name}PageResponse`;
|
||||
types.push(res);
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en} []`;
|
||||
res = `${en}[]`;
|
||||
break;
|
||||
case "/info":
|
||||
res = en;
|
||||
@ -670,7 +678,7 @@ function createServiceCode(): { content: string; types: string[] } {
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")})${noUniappX(`: Promise<${res}>`)} {
|
||||
return request({
|
||||
return request<${res}>({
|
||||
url: "/${d[i].namespace}${a.path}",
|
||||
method: "${(a.method || "get").toLocaleUpperCase()}",
|
||||
data,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user