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