mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Merge branch 'master' of https://git.topthink.com/topteam/framework
This commit is contained in:
@@ -115,7 +115,7 @@ return [
|
|||||||
// | 模板设置
|
// | 模板设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'template' => [
|
'template' => [
|
||||||
// 模板引擎类型 支持 php think 支持扩展
|
// 模板引擎类型 支持 php think 支持扩展
|
||||||
'type' => 'Think',
|
'type' => 'Think',
|
||||||
// 视图基础目录,配置目录为所有模块的视图起始目录
|
// 视图基础目录,配置目录为所有模块的视图起始目录
|
||||||
@@ -137,32 +137,32 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
// 视图输出字符串内容替换
|
// 视图输出字符串内容替换
|
||||||
'view_replace_str' => [],
|
'view_replace_str' => [],
|
||||||
// 默认跳转页面对应的模板文件
|
// 默认跳转页面对应的模板文件
|
||||||
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||||
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 异常及错误设置
|
// | 异常及错误设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
// 异常页面的模板文件
|
// 异常页面的模板文件
|
||||||
'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
|
'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
|
||||||
|
|
||||||
// 错误显示信息,非调试模式有效
|
// 错误显示信息,非调试模式有效
|
||||||
'error_message' => '页面错误!请稍后再试~',
|
'error_message' => '页面错误!请稍后再试~',
|
||||||
// 显示错误信息
|
// 显示错误信息
|
||||||
'show_error_msg' => false,
|
'show_error_msg' => false,
|
||||||
// 异常处理handle类 留空使用 \think\exception\Handle
|
// 异常处理handle类 留空使用 \think\exception\Handle
|
||||||
'exception_handle' => '',
|
'exception_handle' => '',
|
||||||
// 是否记录trace信息到日志
|
// 是否记录trace信息到日志
|
||||||
'record_trace' => false,
|
'record_trace' => false,
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 日志设置
|
// | 日志设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'log' => [
|
'log' => [
|
||||||
// 日志记录方式,内置 file socket 支持扩展
|
// 日志记录方式,内置 file socket 支持扩展
|
||||||
'type' => 'File',
|
'type' => 'File',
|
||||||
// 日志保存目录
|
// 日志保存目录
|
||||||
@@ -174,7 +174,7 @@ return [
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | Trace设置 开启 app_trace 后 有效
|
// | Trace设置 开启 app_trace 后 有效
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
'trace' => [
|
'trace' => [
|
||||||
// 内置Html Console 支持扩展
|
// 内置Html Console 支持扩展
|
||||||
'type' => 'Html',
|
'type' => 'Html',
|
||||||
],
|
],
|
||||||
@@ -183,7 +183,7 @@ return [
|
|||||||
// | 缓存设置
|
// | 缓存设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'cache' => [
|
'cache' => [
|
||||||
// 驱动方式
|
// 驱动方式
|
||||||
'type' => 'File',
|
'type' => 'File',
|
||||||
// 缓存保存目录
|
// 缓存保存目录
|
||||||
@@ -198,7 +198,7 @@ return [
|
|||||||
// | 会话设置
|
// | 会话设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'session' => [
|
'session' => [
|
||||||
'id' => '',
|
'id' => '',
|
||||||
// SESSION_ID的提交变量,解决flash上传跨域
|
// SESSION_ID的提交变量,解决flash上传跨域
|
||||||
'var_session_id' => '',
|
'var_session_id' => '',
|
||||||
@@ -215,7 +215,7 @@ return [
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | Cookie设置
|
// | Cookie设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
'cookie' => [
|
'cookie' => [
|
||||||
// cookie 名称前缀
|
// cookie 名称前缀
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
// cookie 保存时间
|
// cookie 保存时间
|
||||||
@@ -236,7 +236,7 @@ return [
|
|||||||
// | 数据库设置
|
// | 数据库设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'database' => [
|
'database' => [
|
||||||
// 数据库类型
|
// 数据库类型
|
||||||
'type' => 'mysql',
|
'type' => 'mysql',
|
||||||
// 数据库连接DSN配置
|
// 数据库连接DSN配置
|
||||||
@@ -280,10 +280,17 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
//分页配置
|
//分页配置
|
||||||
'paginate' => [
|
'paginate' => [
|
||||||
'type' => 'bootstrap',
|
'type' => 'bootstrap',
|
||||||
'var_page' => 'page',
|
'var_page' => 'page',
|
||||||
'list_rows' => 15,
|
'list_rows' => 15,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
//控制台配置
|
||||||
|
'console' => [
|
||||||
|
'name' => 'Think Console',
|
||||||
|
'version' => '0.1',
|
||||||
|
'user' => null
|
||||||
|
]
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -79,14 +79,19 @@ class Console
|
|||||||
/**
|
/**
|
||||||
* Console constructor.
|
* Console constructor.
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $name 名称
|
* @param string $name 名称
|
||||||
* @param string $version 版本
|
* @param string $version 版本
|
||||||
|
* @param null|string $user 执行用户
|
||||||
*/
|
*/
|
||||||
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
|
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN', $user = null)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->version = $version;
|
$this->version = $version;
|
||||||
|
|
||||||
|
if ($user) {
|
||||||
|
$this->setUser($user);
|
||||||
|
}
|
||||||
|
|
||||||
$this->defaultCommand = 'list';
|
$this->defaultCommand = 'list';
|
||||||
$this->definition = $this->getDefaultInputDefinition();
|
$this->definition = $this->getDefaultInputDefinition();
|
||||||
|
|
||||||
@@ -95,6 +100,19 @@ class Console
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置执行用户
|
||||||
|
* @param $user
|
||||||
|
*/
|
||||||
|
public function setUser($user)
|
||||||
|
{
|
||||||
|
$user = posix_getpwnam($user);
|
||||||
|
if ($user) {
|
||||||
|
posix_setuid($user['uid']);
|
||||||
|
posix_setgid($user['gid']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化 Console
|
* 初始化 Console
|
||||||
* @access public
|
* @access public
|
||||||
@@ -106,8 +124,9 @@ class Console
|
|||||||
static $console;
|
static $console;
|
||||||
|
|
||||||
if (!$console) {
|
if (!$console) {
|
||||||
|
$config = Config::get('console');
|
||||||
// 实例化 console
|
// 实例化 console
|
||||||
$console = new self('Think Console', '0.1');
|
$console = new self($config['name'], $config['version'], $config['user']);
|
||||||
|
|
||||||
// 读取指令集
|
// 读取指令集
|
||||||
if (is_file(CONF_PATH . 'command' . EXT)) {
|
if (is_file(CONF_PATH . 'command' . EXT)) {
|
||||||
@@ -479,7 +498,7 @@ class Console
|
|||||||
}, $namespace);
|
}, $namespace);
|
||||||
|
|
||||||
$allNamespaces = $this->getNamespaces();
|
$allNamespaces = $this->getNamespaces();
|
||||||
$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);
|
$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);
|
||||||
|
|
||||||
if (empty($namespaces)) {
|
if (empty($namespaces)) {
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
@@ -527,7 +546,7 @@ class Console
|
|||||||
}, $name);
|
}, $name);
|
||||||
|
|
||||||
$allCommands = array_keys($this->commands);
|
$allCommands = array_keys($this->commands);
|
||||||
$commands = preg_grep('{^' . $expr . '}', $allCommands);
|
$commands = preg_grep('{^' . $expr . '}', $allCommands);
|
||||||
|
|
||||||
if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) {
|
if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) {
|
||||||
if (false !== ($pos = strrpos($name, ':'))) {
|
if (false !== ($pos = strrpos($name, ':'))) {
|
||||||
@@ -550,7 +569,7 @@ class Console
|
|||||||
|
|
||||||
if (count($commands) > 1) {
|
if (count($commands) > 1) {
|
||||||
$commandList = $this->commands;
|
$commandList = $this->commands;
|
||||||
$commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands) {
|
$commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands) {
|
||||||
$commandName = $commandList[$nameOrAlias]->getName();
|
$commandName = $commandList[$nameOrAlias]->getName();
|
||||||
|
|
||||||
return $commandName === $nameOrAlias || !in_array($commandName, $commands);
|
return $commandName === $nameOrAlias || !in_array($commandName, $commands);
|
||||||
@@ -601,7 +620,7 @@ class Console
|
|||||||
$abbrevs = [];
|
$abbrevs = [];
|
||||||
foreach ($names as $name) {
|
foreach ($names as $name) {
|
||||||
for ($len = strlen($name); $len > 0; --$len) {
|
for ($len = strlen($name); $len > 0; --$len) {
|
||||||
$abbrev = substr($name, 0, $len);
|
$abbrev = substr($name, 0, $len);
|
||||||
$abbrevs[$abbrev][] = $name;
|
$abbrevs[$abbrev][] = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -754,8 +773,8 @@ class Console
|
|||||||
*/
|
*/
|
||||||
private function findAlternatives($name, $collection)
|
private function findAlternatives($name, $collection)
|
||||||
{
|
{
|
||||||
$threshold = 1e3;
|
$threshold = 1e3;
|
||||||
$alternatives = [];
|
$alternatives = [];
|
||||||
$collectionParts = [];
|
$collectionParts = [];
|
||||||
|
|
||||||
foreach ($collection as $item) {
|
foreach ($collection as $item) {
|
||||||
|
|||||||
Reference in New Issue
Block a user