初始化

This commit is contained in:
2026-03-09 17:35:53 +08:00
commit 74f322b7c2
577 changed files with 57404 additions and 0 deletions

32
config/app.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | 应用设置
// +----------------------------------------------------------------------
return [
// 应用地址
'app_host' => env('app.host', ''),
// 应用的命名空间
'app_namespace' => '',
// 是否启用路由
'with_route' => true,
// 默认应用
'default_app' => 'api',
// 默认时区
'default_timezone' => 'Asia/Shanghai',
// 应用映射(自动多应用模式有效)
'app_map' => [],
// 域名绑定(自动多应用模式有效)
'domain_bind' => [],
// 禁止URL访问的应用列表自动多应用模式有效
'deny_app_list' => ['common'],
// 异常页面的模板文件
'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',
// 显示错误信息
'show_error_msg' => false,
];

86
config/buildadmin.php Normal file
View File

@@ -0,0 +1,86 @@
<?php
// +----------------------------------------------------------------------
// | BuildAdmin设置
// +----------------------------------------------------------------------
return [
// 允许跨域访问的域名
'cors_request_domain' => 'localhost,127.0.0.1',
// 是否开启会员登录验证码
'user_login_captcha' => true,
// 是否开启管理员登录验证码
'admin_login_captcha' => true,
// 会员登录失败可重试次数,false则无限
'user_login_retry' => 10,
// 管理员登录失败可重试次数,false则无限
'admin_login_retry' => 10,
// 开启管理员单处登录它处失效
'admin_sso' => false,
// 开启会员单处登录它处失效
'user_sso' => false,
// 会员登录态保持时间非刷新token3天
'user_token_keep_time' => 60 * 60 * 24 * 3,
// 管理员登录态保持时间非刷新token3天
'admin_token_keep_time' => 60 * 60 * 24 * 3,
// 开启前台会员中心
'open_member_center' => true,
// 模块纯净安装(安装时移动模块文件而不是复制)
'module_pure_install' => true,
// 点选验证码配置
'click_captcha' => [
// 模式:text=文字,icon=图标(若只有icon则适用于国际化站点)
'mode' => ['text', 'icon'],
// 长度
'length' => 2,
// 混淆点长度
'confuse_length' => 2,
],
// 代理服务器IP\think\Request 类将尝试获取这些代理服务器发送过来的真实IP
'proxy_server_ip' => [],
// Token 配置
'token' => [
// 默认驱动方式
'default' => 'mysql',
// 加密key
'key' => 'tcbDgmqLVzuAdNH39o0QnhOisvSCFZ7I',
// 加密方式
'algo' => 'ripemd160',
// 驱动
'stores' => [
'mysql' => [
'type' => 'Mysql',
// 留空表示使用默认的 Mysql 数据库,也可以填写其他数据库连接配置的`name`
'name' => '',
// 存储token的表名
'table' => 'token',
// 默认 token 有效时间
'expire' => 2592000,
],
'redis' => [
'type' => 'Redis',
'host' => '127.0.0.1',
'port' => 6379,
'password' => '',
// Db索引非 0 以避免数据被意外清理
'select' => 1,
'timeout' => 0,
// 默认 token 有效时间
'expire' => 2592000,
'persistent' => false,
'prefix' => 'tk:',
],
]
],
// 自动写入管理员操作日志
'auto_write_admin_log' => true,
// 缺省头像图片路径
'default_avatar' => '/static/images/avatar.png',
// 内容分发网络URL末尾不带`/`
'cdn_url' => '',
// 内容分发网络URL参数将自动添加 `?`,之后拼接到 cdn_url 的结尾(例如 `imageMogr2/format/heif`
'cdn_url_params' => '',
// 版本号
'version' => 'v2.3.6',
// 中心接口地址(用于请求模块市场的数据等用途)
'api_url' => 'https://api.buildadmin.com',
];

29
config/cache.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
// +----------------------------------------------------------------------
// | 缓存设置
// +----------------------------------------------------------------------
return [
// 默认缓存驱动
'default' => env('cache.driver', 'file'),
// 缓存连接方式配置
'stores' => [
'file' => [
// 驱动方式
'type' => 'File',
// 缓存保存目录
'path' => '',
// 缓存前缀
'prefix' => '',
// 缓存有效期 0表示永久缓存
'expire' => 0,
// 缓存标签前缀
'tag_prefix' => 'tag:',
// 序列化机制 例如 ['serialize', 'unserialize']
'serialize' => [],
],
// 更多的缓存连接
],
];

8
config/console.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
// +----------------------------------------------------------------------
// | 控制台配置
// +----------------------------------------------------------------------
return [
// 指令定义
'commands' => [],
];

20
config/cookie.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
// +----------------------------------------------------------------------
// | Cookie设置
// +----------------------------------------------------------------------
return [
// cookie 保存时间
'expire' => 0,
// cookie 保存路径
'path' => '/',
// cookie 有效域名
'domain' => '',
// cookie 启用安全传输
'secure' => false,
// httponly设置
'httponly' => false,
// 是否使用 setcookie
'setcookie' => true,
// samesite 设置,支持 'strict' 'lax'
'samesite' => '',
];

63
config/database.php Normal file
View File

@@ -0,0 +1,63 @@
<?php
return [
// 默认使用的数据库连接配置
'default' => env('database.driver', 'mysql'),
// 自定义时间查询规则
'time_query_rule' => [],
// 自动写入时间戳字段
// true为自动识别类型 false关闭
// 字符串则明确指定时间字段类型 支持 int timestamp datetime date
'auto_timestamp' => true,
// 时间字段取出后的默认时间格式
'datetime_format' => false,
// 时间字段配置 配置格式create_time,update_time
'datetime_field' => '',
// 数据库连接配置信息
'connections' => [
'mysql' => [
// 数据库类型
'type' => env('database.type', 'mysql'),
// 服务器地址
'hostname' => env('database.hostname', '127.0.0.1'),
// 数据库名
'database' => env('database.database', 'buildadmin_com'),
// 用户名
'username' => env('database.username', 'root'),
// 密码
'password' => env('database.password', 'admin888'),
// 端口
'hostport' => env('database.hostport', '3306'),
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8mb4
'charset' => env('database.charset', 'utf8mb4'),
// 数据库表前缀
'prefix' => env('database.prefix', 'ba_'),
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'deploy' => 0,
// 数据库读写是否分离 主从式有效
'rw_separate' => false,
// 读写分离后 主服务器数量
'master_num' => 1,
// 指定从服务器序号
'slave_no' => '',
// 是否严格检查字段是否存在
'fields_strict' => true,
// 是否需要断线重连
'break_reconnect' => true,
// 监听SQL
'trigger_sql' => env('app_debug', false),
// 开启字段缓存
'fields_cache' => false,
],
// 更多的数据库配置信息
],
];

24
config/filesystem.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
return [
// 默认磁盘
'default' => env('filesystem.driver', 'local'),
// 磁盘列表
'disks' => [
'local' => [
'type' => 'local',
'root' => app()->getRuntimePath() . 'storage',
],
'public' => [
// 磁盘类型
'type' => 'local',
// 磁盘路径
'root' => app()->getRootPath() . 'public/storage',
// 磁盘路径对应的外部URL路径
'url' => '/storage',
// 可见性
'visibility' => 'public',
],
// 更多的磁盘配置信息
],
];

27
config/lang.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
// +----------------------------------------------------------------------
// | 多语言设置
// +----------------------------------------------------------------------
return [
// 默认语言
'default_lang' => env('lang.default_lang', 'zh-cn'),
// 允许的语言列表
'allow_lang_list' => ['zh-cn', 'en'],
// 多语言自动侦测变量名
'detect_var' => 'lang',
// 是否使用Cookie记录-开启后 ob_flush() 等操作会报错
'use_cookie' => false,
// 多语言cookie变量
'cookie_var' => 'think_lang',
// 多语言header变量
'header_var' => 'think-lang',
// 扩展语言包
'extend_list' => [],
// Accept-Language转义为对应语言包名称
'accept_language' => [
'zh-hans-cn' => 'zh-cn',
],
// 是否支持语言分组
'allow_group' => false,
];

45
config/log.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
// +----------------------------------------------------------------------
// | 日志设置
// +----------------------------------------------------------------------
return [
// 默认日志记录通道
'default' => env('log.channel', 'file'),
// 日志记录级别
'level' => [],
// 日志类型记录的通道 ['error'=>'email',...]
'type_channel' => [],
// 关闭全局日志写入
'close' => false,
// 全局日志处理 支持闭包
'processor' => null,
// 日志通道列表
'channels' => [
'file' => [
// 日志记录方式
'type' => 'File',
// 日志保存目录
'path' => '',
// 单文件日志写入
'single' => false,
// 独立日志级别
'apart_level' => [],
// 最大日志文件数量
'max_files' => 0,
// 使用JSON格式记录
'json' => false,
// 日志处理
'processor' => null,
// 关闭通道日志写入
'close' => false,
// 日志输出格式化
'format' => '[%s][%s] %s',
// 是否实时写入
'realtime_write' => false,
],
// 其它日志通道配置
],
];

8
config/middleware.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
// 中间件配置
return [
// 别名或分组
'alias' => [],
// 优先级设置,此数组中的中间件会按照数组中的顺序优先执行
'priority' => [],
];

45
config/route.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
// +----------------------------------------------------------------------
// | 路由设置
// +----------------------------------------------------------------------
return [
// pathinfo分隔符
'pathinfo_depr' => '/',
// URL伪静态后缀
'url_html_suffix' => 'html',
// URL普通方式参数 用于自动生成
'url_common_param' => true,
// 是否开启路由延迟解析
'url_lazy_route' => false,
// 是否强制使用路由
'url_route_must' => false,
// 合并路由规则
'route_rule_merge' => false,
// 路由是否完全匹配
'route_complete_match' => false,
// 访问控制器层名称
'controller_layer' => 'controller',
// 空控制器名
'empty_controller' => 'Error',
// 是否使用控制器后缀
'controller_suffix' => false,
// 默认的路由变量规则
'default_route_pattern' => '[\w\.]+',
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
'request_cache_key' => false,
// 请求缓存有效期
'request_cache_expire' => null,
// 全局请求缓存排除规则
'request_cache_except' => [],
// 默认控制器名
'default_controller' => 'Index',
// 默认操作名
'default_action' => 'index',
// 操作方法后缀
'action_suffix' => '',
// 默认JSONP格式返回的处理方法
'default_jsonp_handler' => 'jsonpReturn',
// 默认JSONP处理方法
'var_jsonp_handler' => 'callback',
];

19
config/session.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
// +----------------------------------------------------------------------
// | 会话设置
// +----------------------------------------------------------------------
return [
// session name
'name' => 'PHPSESSID',
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id' => '',
// 驱动方式 支持file cache
'type' => 'file',
// 存储连接标识 当type使用cache的时候有效
'store' => null,
// 过期时间
'expire' => 1440,
// 前缀
'prefix' => '',
];

169
config/terminal.php Normal file
View File

@@ -0,0 +1,169 @@
<?php
// +----------------------------------------------------------------------
// | BuildAdmin - WEB终端配置
// | 1. 我们只推荐在本地开发环境使用WEB终端
// | 2. 命令参数中可以使用 %s %f 等占位符,系统将从 request()->param('extend') 取值,以 ~~ 分割多个参数后使用 sprintf 函数替换进完整的命令字符串
// | 3. 命令主体千万不能使用 %s %f 等占位符,参数使用占位符时,系统将自动使用 escapeshellarg 对参数值进行转义来防止命令注入攻击
// +----------------------------------------------------------------------
return [
// npm包管理器
'npm_package_manager' => 'pnpm',
// 允许执行的命令
'commands' => [
// 数据库迁移命令
'migrate' => [
'run' => [
'cwd' => '',
'command' => 'php think migrate:run',
'notes' => 'Start the database migration'
],
'rollback' => 'php think migrate:rollback',
'breakpoint' => 'php think migrate:breakpoint',
],
// 安装包管理器的命令
'install' => [
'cnpm' => 'npm install cnpm -g --registry=https://registry.npmmirror.com',
'yarn' => 'npm install -g yarn',
'pnpm' => 'npm install -g pnpm',
'ni' => 'npm install -g @antfu/ni',
],
// 查看版本的命令
'version' => [
'npm' => 'npm -v',
'cnpm' => 'cnpm -v',
'yarn' => 'yarn -v',
'pnpm' => 'pnpm -v',
'node' => 'node -v',
],
// 测试命令
'test' => [
'npm' => [
'cwd' => 'public/npm-install-test',
'command' => 'npm install',
],
'cnpm' => [
'cwd' => 'public/npm-install-test',
'command' => 'cnpm install',
],
'yarn' => [
'cwd' => 'public/npm-install-test',
'command' => 'yarn install',
],
'pnpm' => [
'cwd' => 'public/npm-install-test',
'command' => 'pnpm install',
],
'ni' => [
'cwd' => 'public/npm-install-test',
'command' => 'ni install',
],
],
// 安装 WEB 依赖包
'web-install' => [
'npm' => [
'cwd' => 'web',
'command' => 'npm install',
],
'cnpm' => [
'cwd' => 'web',
'command' => 'cnpm install',
],
'yarn' => [
'cwd' => 'web',
'command' => 'yarn install',
],
'pnpm' => [
'cwd' => 'web',
'command' => 'pnpm install',
],
'ni' => [
'cwd' => 'web',
'command' => 'ni install',
],
],
// 安装 Web-Nuxt 依赖包
'nuxt-install' => [
'npm' => [
'cwd' => 'web-nuxt',
'command' => 'npm install',
],
'cnpm' => [
'cwd' => 'web-nuxt',
'command' => 'cnpm install',
],
'yarn' => [
'cwd' => 'web-nuxt',
'command' => 'yarn install',
],
'pnpm' => [
'cwd' => 'web-nuxt',
'command' => 'pnpm install',
],
'ni' => [
'cwd' => 'web-nuxt',
'command' => 'ni install',
],
],
// 构建 WEB 端
'web-build' => [
'npm' => [
'cwd' => 'web',
'command' => 'npm run build',
'notes' => 'Start executing the build command of the web project',
],
'cnpm' => [
'cwd' => 'web',
'command' => 'cnpm run build',
'notes' => 'Start executing the build command of the web project',
],
'yarn' => [
'cwd' => 'web',
'command' => 'yarn run build',
'notes' => 'Start executing the build command of the web project',
],
'pnpm' => [
'cwd' => 'web',
'command' => 'pnpm run build',
'notes' => 'Start executing the build command of the web project',
],
'ni' => [
'cwd' => 'web',
'command' => 'nr build',
'notes' => 'Start executing the build command of the web project',
],
],
// 设置 NPM 源
'set-npm-registry' => [
'npm' => 'npm config set registry https://registry.npmjs.org/ && npm config get registry',
'taobao' => 'npm config set registry https://registry.npmmirror.com/ && npm config get registry',
'tencent' => 'npm config set registry https://mirrors.cloud.tencent.com/npm/ && npm config get registry'
],
// 设置 composer 源
'set-composer-registry' => [
'composer' => 'composer config --unset repos.packagist',
'aliyun' => 'composer config -g repos.packagist composer https://mirrors.aliyun.com/composer/',
'tencent' => 'composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/',
'huawei' => 'composer config -g repos.packagist composer https://mirrors.huaweicloud.com/repository/php/',
'kkame' => 'composer config -g repos.packagist composer https://packagist.kr',
],
'npx' => [
'prettier' => [
'cwd' => 'web',
'command' => 'npx prettier --write %s',
'notes' => 'Start formatting the web project code',
],
],
'composer' => [
'update' => [
'cwd' => '',
'command' => 'composer update --no-interaction',
'notes' => 'Start installing the composer dependencies'
]
],
'ping' => [
'baidu' => 'ping baidu.com',
'localhost' => 'ping 127.0.0.1 -n 6',
]
],
];

42
config/throttle.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | 节流设置
// +----------------------------------------------------------------------
use think\middleware\Throttle;
use think\middleware\throttle\CounterFixed;
use think\Request;
use think\Response;
return [
// 缓存键前缀,防止键值与其他应用冲突
'prefix' => 'throttle_',
// 缓存的键true 表示使用来源ip
'key' => true,
// 要被限制的请求类型, eg: GET POST PUT DELETE HEAD 等
'visit_method' => ['GET', 'HEAD'],
// 设置访问频率,例如 '10/m' 指的是允许每分钟请求10次;'10/60'指允许每60秒请求10次。值 null 表示不限制, eg: null 10/m 20/h 300/d 200/300
'visit_rate' => '120/m',
/*
* 设置节流算法,组件提供了四种算法:
* - CounterFixed :计数固定窗口
* - CounterSlider: 滑动窗口
* - TokenBucket : 令牌桶算法
* - LeakyBucket : 漏桶限流算法
*/
'driver_name' => CounterFixed::class,
// 响应体中设置速率限制的头部信息含义见https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
'visit_enable_show_rate_limit' => true,
// 访问受限时返回的响应
'visit_fail_response' => function (Throttle $throttle, Request $request, int $wait_seconds) {
return Response::create([
'code' => 0,
'msg' => 'Please do not request frequently. Try again in ' . $wait_seconds . ' seconds.',
], 'json')->header([
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Max-Age' => 0,
'Access-Control-Allow-Methods' => '*',
'Access-Control-Allow-Headers' => '*',
'Access-Control-Allow-Origin' => '*',
]);
},
];

10
config/trace.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
// +----------------------------------------------------------------------
// | Trace设置 开启调试模式后有效
// +----------------------------------------------------------------------
return [
// 内置Html和Console两种方式 支持扩展
'type' => 'Html',
// 读取的日志通道名
'channel' => '',
];

21
config/upload.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | BuildAdmin上传设置
// +----------------------------------------------------------------------
return [
// 最大上传
'max_size' => '10mb',
// 文件保存格式化方法:topic=存储子目录,fileName=文件名前15个字符
'save_name' => '/storage/{topic}/{year}{mon}{day}/{fileName}{fileSha1}{.suffix}',
/**
* 上传文件的后缀和 MIME类型 白名单
* 0. 永远使用最少配置
* 1. 此处不支持通配符
* 2. 千万不要允许 php,php5,.htaccess,.user.ini 等可执行或配置文件
* 3. 允许 pdf,ppt,docx 等可能含有脚本的文件时,请先从服务器配置此类文件直接下载而不是预览
*/
'allowed_suffixes' => 'jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3',
'allowed_mime_types' => [],
];

25
config/view.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
// +----------------------------------------------------------------------
// | 模板设置
// +----------------------------------------------------------------------
return [
// 模板引擎类型使用Think
'type' => 'Think',
// 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
'auto_rule' => 1,
// 模板目录名
'view_dir_name' => 'view',
// 模板后缀
'view_suffix' => 'html',
// 模板文件名分隔符
'view_depr' => DIRECTORY_SEPARATOR,
// 模板引擎普通标签开始标记
'tpl_begin' => '{',
// 模板引擎普通标签结束标记
'tpl_end' => '}',
// 标签库标签开始标记
'taglib_begin' => '{',
// 标签库标签结束标记
'taglib_end' => '}',
];