小程序初始提交

This commit is contained in:
jdc
2025-11-13 10:36:23 +08:00
parent f26b4f9a2f
commit 5db3b180eb
447 changed files with 83351 additions and 0 deletions

21
cool-unix/config/dev.ts Normal file
View File

@@ -0,0 +1,21 @@
import { get } from "@/cool";
import { proxy, value } from "./proxy";
export const dev = () => {
const host = get(proxy, `${value}.target`) as string;
let baseUrl: string;
// #ifdef H5
baseUrl = `/${value}`;
// #endif
// #ifndef H5
baseUrl = host + "";
// #endif
return {
host,
baseUrl
};
};

46
cool-unix/config/index.ts Normal file
View File

@@ -0,0 +1,46 @@
import { isMp } from "@/cool";
import { dev } from "./dev";
import { prod } from "./prod";
// 判断当前是否为开发环境
export const isDev = process.env.NODE_ENV == "development";
// 忽略 token 校验的接口路径
export const ignoreTokens: string[] = [];
// 微信配置
type WxConfig = {
debug: boolean;
};
// 配置类型定义
type Config = {
name: string; // 应用名称
version: string; // 应用版本
locale: string; // 应用语言
website: string; // 官网地址
host: string; // 主机地址
baseUrl: string; // 基础路径
showDarkButton: boolean; // 是否显示暗色模式切换按钮
isCustomTabBar: boolean; // 是否自定义 tabBar
backTop: boolean; // 是否显示回到顶部按钮
wx: WxConfig; // 微信配置
};
// 根据环境导出最终配置
export const config = {
name: "Cool Unix",
version: "1.0.0",
locale: "zh",
website: "https://cool-js.com",
showDarkButton: isMp() ? false : true,
isCustomTabBar: true,
backTop: true,
wx: {
debug: false
},
...(isDev ? dev() : prod())
} as Config;
// 导出代理相关配置
export * from "./proxy";

21
cool-unix/config/prod.ts Normal file
View File

@@ -0,0 +1,21 @@
import { get } from "@/cool";
import { proxy } from "./proxy";
export const prod = () => {
const host = get(proxy, `prod.target`) as string;
let baseUrl: string;
// #ifdef H5
baseUrl = host + "/api";
// #endif
// #ifndef H5
baseUrl = host + "/api";
// #endif
return {
host,
baseUrl
};
};

21
cool-unix/config/proxy.ts Normal file
View File

@@ -0,0 +1,21 @@
export const proxy = {
// 开发环境配置
dev: {
// 官方测试地址
// target: "https://show.cool-admin.com/api",
// 本地地址
target: "http://127.0.0.1:8001",
changeOrigin: true,
rewrite: (path: string) => path.replace("/dev", "")
},
// 生产环境配置
prod: {
// 官方测试地址
target: "https://show.cool-admin.com",
changeOrigin: true,
rewrite: (path: string) => path.replace("/prod", "/api")
}
};
export const value = "dev";