From a07dcdda5f35e222ba03ae678034514a1ed172af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Tue, 15 Oct 2024 17:37:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=9B=E4=B8=80=E6=AD=A5=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E5=88=9D=E5=A7=8B=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 22 +++++++++++ app/index/controller/Index.php | 6 ++- config/cache.php | 14 +++++-- config/database.php | 23 +++++------ plugin/think-plugs-static/stc/.env.example | 39 ++++++++++--------- .../think-plugs-static/stc/config/cache.php | 10 ++--- .../stc/config/database.php | 18 ++++----- .../think-plugs-static/stc/config/session.php | 10 ++--- 8 files changed, 88 insertions(+), 54 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..f61bb0377 --- /dev/null +++ b/.env.example @@ -0,0 +1,22 @@ +# 数据配置 +DB_TYPE=mysql +DB_MYSQL_HOST=thinkadmin.top +DB_MYSQL_PORT=3306 +DB_MYSQL_PREFIX= +DB_MYSQL_DATABASE=admin_v6 +DB_MYSQL_USERNAME=root +DB_MYSQL_PASSWORD= + +# 缓存配置 +CACHE_TYPE=file +CACHE_REDIS_HOST=127.0.0.1 +CACHE_REDIS_PORT=6379 +CACHE_REDIS_SELECT= +CACHE_REDIS_PASSWORD= + +# 会话配置 +SESSION_NAME=ssid +SESSION_TYPE=file +SESSION_STORE= +SESSION_EXPIRE=7200 +SESSION_PREFIX= \ No newline at end of file diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 616a90660..7e7d1fe9c 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -17,11 +17,13 @@ namespace app\index\controller; use think\admin\Controller; +use think\admin\extend\ToolsExtend; class Index extends Controller { public function index() - { - $this->redirect(sysuri('admin/login/index')); + { + // $this->redirect(sysuri('admin/login/index')); + dump(ToolsExtend::findFilesArray('app', null, null, false, 3)); } } diff --git a/config/cache.php b/config/cache.php index 25d927aa0..dc78ad360 100644 --- a/config/cache.php +++ b/config/cache.php @@ -16,10 +16,10 @@ return [ // 默认缓存驱动 - 'default' => 'file', + 'default' => env('CACHE_TYPE', 'file'), // 缓存连接配置 'stores' => [ - 'file' => [ + 'file' => [ // 驱动方式 'type' => 'File', // 缓存保存目录 @@ -33,7 +33,7 @@ return [ // 序列化机制 'serialize' => [], ], - 'safe' => [ + 'safe' => [ // 驱动方式 'type' => 'File', // 缓存保存目录 @@ -47,5 +47,13 @@ return [ // 序列化机制 'serialize' => [], ], + 'redis' => [ + // 驱动方式 + 'type' => 'redis', + 'host' => env('CACHE_REDIS_HOST', '127.0.0.1'), + 'port' => env('CACHE_REDIS_PORT', 6379), + 'select' => env('CACHE_REDIS_SELECT', 0), + 'password' => env('CACHE_REDIS_PASSWORD', ''), + ] ], ]; \ No newline at end of file diff --git a/config/database.php b/config/database.php index 039e83da9..ea58c067d 100644 --- a/config/database.php +++ b/config/database.php @@ -16,7 +16,7 @@ return [ // 默认使用的数据库连接配置 - 'default' => env('db.type', 'sqlite'), + 'default' => env('DB_TYPE', 'sqlite'), // 自定义时间查询规则 'time_query_rule' => [], // 自动写入时间戳字段 @@ -29,21 +29,21 @@ return [ // 数据库类型 'type' => 'mysql', // 服务器地址 - 'hostname' => env('db.mysql_hostname', '127.0.0.1'), + 'hostname' => env('DB_MYSQL_HOST', '127.0.0.1'), + // 服务器端口 + 'hostport' => env('DB_MYSQL_PORT', '3306'), // 数据库名 - 'database' => env('db.mysql_database', 'thinkadmin'), + 'database' => env('DB_MYSQL_DATABASE', 'thinkadmin'), // 用户名 - 'username' => env('db.mysql_username', 'root'), + 'username' => env('DB_MYSQL_USERNAME', 'root'), // 密码 - 'password' => env('db.mysql_password', ''), - // 端口 - 'hostport' => env('db.mysql_hostport', '3306'), + 'password' => env('DB_MYSQL_PASSWORD', ''), // 数据库连接参数 'params' => [], - // 数据库编码默认采用 utf8 - 'charset' => env('mysql.charset', 'utf8mb4'), // 数据库表前缀 - 'prefix' => env('mysql.prefix', ''), + 'prefix' => env('DB_MYSQL_PREFIX', ''), + // 数据库编码默认采用 utf8mb4 + 'charset' => env('DB_MYSQL_CHARSET', 'utf8mb4'), // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 'deploy' => 0, // 数据库读写是否分离 主从式有效 @@ -62,11 +62,12 @@ return [ 'fields_cache' => isOnline(), ], 'sqlite' => [ - 'charset' => 'utf8', // 数据库类型 'type' => 'sqlite', // 数据库文件 'database' => syspath('database/sqlite.db'), + // 数据库编码默认采用 utf8 + 'charset' => 'utf8', // 监听执行日志 'trigger_sql' => true, // 其他参数字段 diff --git a/plugin/think-plugs-static/stc/.env.example b/plugin/think-plugs-static/stc/.env.example index 7fe25d054..f61bb0377 100644 --- a/plugin/think-plugs-static/stc/.env.example +++ b/plugin/think-plugs-static/stc/.env.example @@ -1,21 +1,22 @@ -[db] -# 数据库类型 -type=sqlite +# 数据配置 +DB_TYPE=mysql +DB_MYSQL_HOST=thinkadmin.top +DB_MYSQL_PORT=3306 +DB_MYSQL_PREFIX= +DB_MYSQL_DATABASE=admin_v6 +DB_MYSQL_USERNAME=root +DB_MYSQL_PASSWORD= -# MySQL 数据库配置 -mysql_hostname=127.0.0.1 -mysql_hostport=3306 -mysql_database=thinkadmin -mysql_username=root -mysql_password= -mysql_prefix= +# 缓存配置 +CACHE_TYPE=file +CACHE_REDIS_HOST=127.0.0.1 +CACHE_REDIS_PORT=6379 +CACHE_REDIS_SELECT= +CACHE_REDIS_PASSWORD= -[cache] -# 缓存类型 -type=file - -# Redis 缓存服务配置 -redis_hostname=127.0.0.1 -redis_hostport=6379 -redis_password= -redis_select=0 \ No newline at end of file +# 会话配置 +SESSION_NAME=ssid +SESSION_TYPE=file +SESSION_STORE= +SESSION_EXPIRE=7200 +SESSION_PREFIX= \ No newline at end of file diff --git a/plugin/think-plugs-static/stc/config/cache.php b/plugin/think-plugs-static/stc/config/cache.php index 6fe9560ad..dc78ad360 100644 --- a/plugin/think-plugs-static/stc/config/cache.php +++ b/plugin/think-plugs-static/stc/config/cache.php @@ -16,7 +16,7 @@ return [ // 默认缓存驱动 - 'default' => env('cache.type', 'file'), + 'default' => env('CACHE_TYPE', 'file'), // 缓存连接配置 'stores' => [ 'file' => [ @@ -50,10 +50,10 @@ return [ 'redis' => [ // 驱动方式 'type' => 'redis', - 'host' => env('cache.redis_hostname', '127.0.0.1'), - 'port' => env('cache.redis_hostport', 6379), - 'password' => env('cache.redis_password', ''), - 'select' => env('cache.redis_select', 0), + 'host' => env('CACHE_REDIS_HOST', '127.0.0.1'), + 'port' => env('CACHE_REDIS_PORT', 6379), + 'select' => env('CACHE_REDIS_SELECT', 0), + 'password' => env('CACHE_REDIS_PASSWORD', ''), ] ], ]; \ No newline at end of file diff --git a/plugin/think-plugs-static/stc/config/database.php b/plugin/think-plugs-static/stc/config/database.php index 58311dd87..ea58c067d 100644 --- a/plugin/think-plugs-static/stc/config/database.php +++ b/plugin/think-plugs-static/stc/config/database.php @@ -16,7 +16,7 @@ return [ // 默认使用的数据库连接配置 - 'default' => env('db.type', 'sqlite'), + 'default' => env('DB_TYPE', 'sqlite'), // 自定义时间查询规则 'time_query_rule' => [], // 自动写入时间戳字段 @@ -29,21 +29,21 @@ return [ // 数据库类型 'type' => 'mysql', // 服务器地址 - 'hostname' => env('db.mysql_hostname', '127.0.0.1'), + 'hostname' => env('DB_MYSQL_HOST', '127.0.0.1'), + // 服务器端口 + 'hostport' => env('DB_MYSQL_PORT', '3306'), // 数据库名 - 'database' => env('db.mysql_database', 'thinkadmin'), + 'database' => env('DB_MYSQL_DATABASE', 'thinkadmin'), // 用户名 - 'username' => env('db.mysql_username', 'root'), + 'username' => env('DB_MYSQL_USERNAME', 'root'), // 密码 - 'password' => env('db.mysql_password', ''), - // 端口 - 'hostport' => env('db.mysql_hostport', '3306'), + 'password' => env('DB_MYSQL_PASSWORD', ''), // 数据库连接参数 'params' => [], // 数据库表前缀 - 'prefix' => env('db.mysql_prefix', ''), + 'prefix' => env('DB_MYSQL_PREFIX', ''), // 数据库编码默认采用 utf8mb4 - 'charset' => env('db.mysql_charset', 'utf8mb4'), + 'charset' => env('DB_MYSQL_CHARSET', 'utf8mb4'), // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 'deploy' => 0, // 数据库读写是否分离 主从式有效 diff --git a/plugin/think-plugs-static/stc/config/session.php b/plugin/think-plugs-static/stc/config/session.php index 1dd6c59b9..5025ac6b7 100644 --- a/plugin/think-plugs-static/stc/config/session.php +++ b/plugin/think-plugs-static/stc/config/session.php @@ -16,13 +16,13 @@ return [ // 字段名称 - 'name' => 'ssid', + 'name' => env('SESSION_NAME', 'ssid'), // 驱动方式 - 'type' => 'file', + 'type' => env('SESSION_TYPE', 'file'), // 存储连接 - 'store' => null, + 'store' => env('SESSION_STORE', ''), // 过期时间 - 'expire' => 7200, + 'expire' => env('SESSION_EXPIRE', 7200), // 文件前缀 - 'prefix' => '', + 'prefix' => env('SESSION_PREFIX', ''), ]; \ No newline at end of file