Skip to content

Commit

Permalink
fix: 进一步完善初始化配置
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Oct 15, 2024
1 parent 08c4bd7 commit a07dcdd
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 54 deletions.
22 changes: 22 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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=
6 changes: 4 additions & 2 deletions app/index/controller/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
14 changes: 11 additions & 3 deletions config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

return [
// 默认缓存驱动
'default' => 'file',
'default' => env('CACHE_TYPE', 'file'),
// 缓存连接配置
'stores' => [
'file' => [
'file' => [
// 驱动方式
'type' => 'File',
// 缓存保存目录
Expand All @@ -33,7 +33,7 @@
// 序列化机制
'serialize' => [],
],
'safe' => [
'safe' => [
// 驱动方式
'type' => 'File',
// 缓存保存目录
Expand All @@ -47,5 +47,13 @@
// 序列化机制
'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', ''),
]
],
];
23 changes: 12 additions & 11 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

return [
// 默认使用的数据库连接配置
'default' => env('db.type', 'sqlite'),
'default' => env('DB_TYPE', 'sqlite'),
// 自定义时间查询规则
'time_query_rule' => [],
// 自动写入时间戳字段
Expand All @@ -29,21 +29,21 @@
// 数据库类型
'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,
// 数据库读写是否分离 主从式有效
Expand All @@ -62,11 +62,12 @@
'fields_cache' => isOnline(),
],
'sqlite' => [
'charset' => 'utf8',
// 数据库类型
'type' => 'sqlite',
// 数据库文件
'database' => syspath('database/sqlite.db'),
// 数据库编码默认采用 utf8
'charset' => 'utf8',
// 监听执行日志
'trigger_sql' => true,
// 其他参数字段
Expand Down
39 changes: 20 additions & 19 deletions plugin/think-plugs-static/stc/.env.example
Original file line number Diff line number Diff line change
@@ -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
# 会话配置
SESSION_NAME=ssid
SESSION_TYPE=file
SESSION_STORE=
SESSION_EXPIRE=7200
SESSION_PREFIX=
10 changes: 5 additions & 5 deletions plugin/think-plugs-static/stc/config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

return [
// 默认缓存驱动
'default' => env('cache.type', 'file'),
'default' => env('CACHE_TYPE', 'file'),
// 缓存连接配置
'stores' => [
'file' => [
Expand Down Expand Up @@ -50,10 +50,10 @@
'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', ''),
]
],
];
18 changes: 9 additions & 9 deletions plugin/think-plugs-static/stc/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

return [
// 默认使用的数据库连接配置
'default' => env('db.type', 'sqlite'),
'default' => env('DB_TYPE', 'sqlite'),
// 自定义时间查询规则
'time_query_rule' => [],
// 自动写入时间戳字段
Expand All @@ -29,21 +29,21 @@
// 数据库类型
'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,
// 数据库读写是否分离 主从式有效
Expand Down
10 changes: 5 additions & 5 deletions plugin/think-plugs-static/stc/config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''),
];

0 comments on commit a07dcdd

Please sign in to comment.