mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-12 21:52:48 +00:00
1
This commit is contained in:
parent
3f90cac389
commit
a89ef3f0ef
25
packages/vite-plugin/dist/index.js
vendored
25
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,13 +730,15 @@
|
||||
let res = "";
|
||||
// 实体名
|
||||
const en = item.name || "any";
|
||||
if (config.type == "uniapp-x") {
|
||||
res = "any";
|
||||
}
|
||||
else {
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `PageResponse<${en}>`;
|
||||
res = `${name}PageResponse`;
|
||||
pageResponse += `
|
||||
interface ${name}PageResponse {
|
||||
pagination: PagePagination;
|
||||
list: ${en}[];
|
||||
}
|
||||
`;
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en} []`;
|
||||
@ -747,7 +750,6 @@
|
||||
res = "any";
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 方法描述
|
||||
t += `
|
||||
/**
|
||||
@ -809,6 +811,8 @@
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
${pageResponse}
|
||||
|
||||
${controller}
|
||||
|
||||
${noUniappX(`interface RequestOptions {
|
||||
@ -995,7 +999,8 @@
|
||||
const en = item.name || "any";
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `PageResponse<${en}>`;
|
||||
res = `${name}PageResponse`;
|
||||
types.push(res);
|
||||
break;
|
||||
case "/list":
|
||||
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,12 +347,17 @@ 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}>`;
|
||||
res = `${name}PageResponse`;
|
||||
|
||||
pageResponse += `
|
||||
interface ${name}PageResponse {
|
||||
pagination: PagePagination;
|
||||
list: ${en}[];
|
||||
}
|
||||
`;
|
||||
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en} []`;
|
||||
@ -363,7 +369,6 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
|
||||
res = "any";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 方法描述
|
||||
t += `
|
||||
@ -433,6 +438,8 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
${pageResponse}
|
||||
|
||||
${controller}
|
||||
|
||||
${noUniappX(`interface RequestOptions {
|
||||
@ -651,7 +658,8 @@ 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}[]`;
|
||||
@ -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