mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-10 20:02:54 +00:00
clean 判断错误
This commit is contained in:
parent
9330acc33c
commit
e66d64d83e
87
packages/vite-plugin/dist/index.js
vendored
87
packages/vite-plugin/dist/index.js
vendored
@ -1112,12 +1112,22 @@
|
||||
break;
|
||||
}
|
||||
// 方法描述
|
||||
t += `
|
||||
/**
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")}): Promise<${res}>;
|
||||
`;
|
||||
if (config.type == "uniapp-x") {
|
||||
t += `
|
||||
/**
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")}): Promise<any>;
|
||||
`;
|
||||
}
|
||||
else {
|
||||
t += `
|
||||
/**
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")}): Promise<${res}>;
|
||||
`;
|
||||
}
|
||||
if (!permission.includes(n)) {
|
||||
permission.push(n);
|
||||
}
|
||||
@ -1159,6 +1169,8 @@
|
||||
return `
|
||||
type json = any;
|
||||
|
||||
${await createDict()}
|
||||
|
||||
interface PagePagination {
|
||||
size: number;
|
||||
page: number;
|
||||
@ -1188,8 +1200,6 @@
|
||||
|
||||
${noUniappX("type Request = (options: RequestOptions) => Promise<any>;")}
|
||||
|
||||
${await createDict()}
|
||||
|
||||
type Service = {
|
||||
${noUniappX("request: Request;")}
|
||||
|
||||
@ -1354,32 +1364,13 @@
|
||||
if (item.name) {
|
||||
types.push(item.name);
|
||||
}
|
||||
// 返回类型
|
||||
let res = "";
|
||||
// 实体名
|
||||
const en = item.name || "any";
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `${name}PageResponse`;
|
||||
types.push(res);
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en}[]`;
|
||||
break;
|
||||
case "/info":
|
||||
res = en;
|
||||
break;
|
||||
default:
|
||||
res = "any";
|
||||
break;
|
||||
}
|
||||
// 方法描述
|
||||
t += `
|
||||
/**
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")})${noUniappX(`: Promise<${res}>`)} {
|
||||
return request<${res}>({
|
||||
${n}(data?: any): Promise<any> {
|
||||
return request({
|
||||
url: "/${d[i].namespace}${a.path}",
|
||||
method: "${(a.method || "get").toLocaleUpperCase()}",
|
||||
data,
|
||||
@ -2370,17 +2361,17 @@ if (typeof window !== 'undefined') {
|
||||
}
|
||||
code = code.replace("const ctx = {}", `const ctx = ${JSON.stringify(ctx, null, 4)}`);
|
||||
}
|
||||
if (id.includes("/cool/service/index.ts")) {
|
||||
const eps = await createEps();
|
||||
if (eps.serviceCode) {
|
||||
const { content, types } = eps.serviceCode;
|
||||
const typeCode = `import type { ${lodash.uniq(types).join(", ")} } from '../types';`;
|
||||
code =
|
||||
typeCode +
|
||||
"\n\n" +
|
||||
code.replace("const service = {}", `const service = ${content}`);
|
||||
}
|
||||
}
|
||||
// if (id.includes("/cool/service/index.ts")) {
|
||||
// const eps = await createEps();
|
||||
// if (eps.serviceCode) {
|
||||
// const { content, types } = eps.serviceCode;
|
||||
// const typeCode = `import type { ${uniq(types).join(", ")} } from '../types';`;
|
||||
// code =
|
||||
// typeCode +
|
||||
// "\n\n" +
|
||||
// code.replace("const service = {}", `const service = ${content}`);
|
||||
// }
|
||||
// }
|
||||
if (id.endsWith(".json")) {
|
||||
const d = JSON.parse(code);
|
||||
for (let i in d) {
|
||||
@ -2446,11 +2437,13 @@ if (typeof window !== 'undefined') {
|
||||
config.type = options.type;
|
||||
// 请求地址
|
||||
config.reqUrl = getProxyTarget(options.proxy);
|
||||
// 是否纯净版
|
||||
config.clean = options.clean;
|
||||
if (config.clean) {
|
||||
// 默认设置为测试地址
|
||||
config.reqUrl = "https://show.cool-admin.com/api";
|
||||
if (config.type == "uniapp-x") {
|
||||
// 是否纯净版
|
||||
config.clean = options.clean ?? true;
|
||||
if (config.clean) {
|
||||
// 默认设置为测试地址
|
||||
config.reqUrl = "https://show.cool-admin.com/api";
|
||||
}
|
||||
}
|
||||
// 是否开启名称标签
|
||||
config.nameTag = options.nameTag ?? true;
|
||||
@ -2476,6 +2469,10 @@ if (typeof window !== 'undefined') {
|
||||
lodash.merge(config.eps.mapping, mapping);
|
||||
}
|
||||
}
|
||||
// 如果类型为 uniapp-x,则关闭 eps
|
||||
if (config.type == "uniapp-x") {
|
||||
config.eps.enable = false;
|
||||
}
|
||||
// tailwind
|
||||
if (options.tailwind) {
|
||||
lodash.assign(config.tailwind, options.tailwind);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cool-vue/vite-plugin",
|
||||
"version": "8.2.8",
|
||||
"version": "8.2.10",
|
||||
"description": "cool-admin、cool-uni builder",
|
||||
"types": "./dist/index.d.ts",
|
||||
"main": "/dist/index.js",
|
||||
|
||||
@ -382,12 +382,21 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
|
||||
}
|
||||
|
||||
// 方法描述
|
||||
t += `
|
||||
/**
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")}): Promise<${res}>;
|
||||
`;
|
||||
if (config.type == "uniapp-x") {
|
||||
t += `
|
||||
/**
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")}): Promise<any>;
|
||||
`;
|
||||
} else {
|
||||
t += `
|
||||
/**
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")}): Promise<${res}>;
|
||||
`;
|
||||
}
|
||||
|
||||
if (!permission.includes(n)) {
|
||||
permission.push(n);
|
||||
@ -436,6 +445,8 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
|
||||
return `
|
||||
type json = any;
|
||||
|
||||
${await createDict()}
|
||||
|
||||
interface PagePagination {
|
||||
size: number;
|
||||
page: number;
|
||||
@ -465,8 +476,6 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
|
||||
|
||||
${noUniappX("type Request = (options: RequestOptions) => Promise<any>;")}
|
||||
|
||||
${await createDict()}
|
||||
|
||||
type Service = {
|
||||
${noUniappX("request: Request;")}
|
||||
|
||||
@ -661,35 +670,13 @@ function createServiceCode(): { content: string; types: string[] } {
|
||||
types.push(item.name);
|
||||
}
|
||||
|
||||
// 返回类型
|
||||
let res = "";
|
||||
|
||||
// 实体名
|
||||
const en = item.name || "any";
|
||||
|
||||
switch (a.path) {
|
||||
case "/page":
|
||||
res = `${name}PageResponse`;
|
||||
types.push(res);
|
||||
break;
|
||||
case "/list":
|
||||
res = `${en}[]`;
|
||||
break;
|
||||
case "/info":
|
||||
res = en;
|
||||
break;
|
||||
default:
|
||||
res = "any";
|
||||
break;
|
||||
}
|
||||
|
||||
// 方法描述
|
||||
t += `
|
||||
/**
|
||||
* ${a.summary || n}
|
||||
*/
|
||||
${n}(data${q.length == 1 ? "?" : ""}: ${q.join("")})${noUniappX(`: Promise<${res}>`)} {
|
||||
return request<${res}>({
|
||||
${n}(data?: any): Promise<any> {
|
||||
return request({
|
||||
url: "/${d[i].namespace}${a.path}",
|
||||
method: "${(a.method || "get").toLocaleUpperCase()}",
|
||||
data,
|
||||
|
||||
@ -14,12 +14,14 @@ export function cool(options: Config.Options) {
|
||||
// 请求地址
|
||||
config.reqUrl = getProxyTarget(options.proxy);
|
||||
|
||||
// 是否纯净版
|
||||
config.clean = options.clean;
|
||||
if (config.type == "uniapp-x") {
|
||||
// 是否纯净版
|
||||
config.clean = options.clean ?? true;
|
||||
|
||||
if (config.clean) {
|
||||
// 默认设置为测试地址
|
||||
config.reqUrl = "https://show.cool-admin.com/api";
|
||||
if (config.clean) {
|
||||
// 默认设置为测试地址
|
||||
config.reqUrl = "https://show.cool-admin.com/api";
|
||||
}
|
||||
}
|
||||
|
||||
// 是否开启名称标签
|
||||
@ -53,6 +55,11 @@ export function cool(options: Config.Options) {
|
||||
}
|
||||
}
|
||||
|
||||
// 如果类型为 uniapp-x,则关闭 eps
|
||||
if (config.type == "uniapp-x") {
|
||||
config.eps.enable = false;
|
||||
}
|
||||
|
||||
// tailwind
|
||||
if (options.tailwind) {
|
||||
assign(config.tailwind, options.tailwind);
|
||||
|
||||
@ -126,19 +126,19 @@ export function codePlugin(): Plugin[] {
|
||||
);
|
||||
}
|
||||
|
||||
if (id.includes("/cool/service/index.ts")) {
|
||||
const eps = await createEps();
|
||||
// if (id.includes("/cool/service/index.ts")) {
|
||||
// const eps = await createEps();
|
||||
|
||||
if (eps.serviceCode) {
|
||||
const { content, types } = eps.serviceCode;
|
||||
const typeCode = `import type { ${uniq(types).join(", ")} } from '../types';`;
|
||||
// if (eps.serviceCode) {
|
||||
// const { content, types } = eps.serviceCode;
|
||||
// const typeCode = `import type { ${uniq(types).join(", ")} } from '../types';`;
|
||||
|
||||
code =
|
||||
typeCode +
|
||||
"\n\n" +
|
||||
code.replace("const service = {}", `const service = ${content}`);
|
||||
}
|
||||
}
|
||||
// code =
|
||||
// typeCode +
|
||||
// "\n\n" +
|
||||
// code.replace("const service = {}", `const service = ${content}`);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (id.endsWith(".json")) {
|
||||
const d = JSON.parse(code);
|
||||
|
||||
2
packages/vite-plugin/types/index.d.ts
vendored
2
packages/vite-plugin/types/index.d.ts
vendored
@ -120,6 +120,6 @@ export declare namespace Config {
|
||||
darkTextClass?: string;
|
||||
};
|
||||
// 是否纯净版
|
||||
clean: boolean;
|
||||
clean?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user