2025-08-30 14:52:23 +08:00

70 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { base } from "./base";
import { config } from "./config";
import { demo } from "./demo";
import { getProxyTarget } from "./proxy";
import type { Config } from "../types";
import { virtual } from "./virtual";
import { assign, merge } from "lodash";
import { uniappX } from "./uniapp-x";
export function cool(options: Config.Options) {
// 应用类型admin | app
config.type = options.type;
// 请求地址
config.reqUrl = getProxyTarget(options.proxy);
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;
// svg
if (options.svg) {
assign(config.svg, options.svg);
}
// Eps
if (options.eps) {
const { dist, mapping, api, enable = true } = options.eps;
// 是否开启
config.eps.enable = enable;
// 类型
if (api) {
config.eps.api = api;
}
// 输出目录
if (dist) {
config.eps.dist = dist;
}
// 匹配规则
if (mapping) {
merge(config.eps.mapping, mapping);
}
}
// 如果类型为 uniapp-x则关闭 eps
if (config.type == "uniapp-x") {
config.eps.enable = false;
}
// tailwind
if (options.tailwind) {
assign(config.tailwind, options.tailwind);
}
return [base(), virtual(), uniappX(), demo(options.demo)];
}