[更新]ComposerUpdate及框架配置

This commit is contained in:
Anyon 2018-06-07 14:47:14 +08:00
parent c4606f5037
commit f8f8af1f53
17 changed files with 202 additions and 73 deletions

View File

@ -12,29 +12,60 @@
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace think;
namespace app\admin\middleware;
use service\NodeService;
use think\exception\HttpResponseException;
use think\Db;
use think\Request;
return [
// 控制器开始前,进行权限检查
'action_begin' => function () {
$request = app('request');
/**
* 系统权限访问管理
* Class Auth
* @package app\admin\middleware
*/
class Auth
{
/**
* @param Request $request
* @param \Closure $next
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function handle($request, \Closure $next)
{
list($module, $controller, $action) = [$request->module(), $request->controller(), $request->action()];
$node = NodeService::parseNodeStr("{$module}/{$controller}/{$action}");
$info = Db::name('SystemNode')->cache(true, 30)->where(['node' => $node])->find();
$access = ['is_menu' => intval(!empty($info['is_menu'])), 'is_auth' => intval(!empty($info['is_auth'])), 'is_login' => empty($info['is_auth']) ? intval(!empty($info['is_login'])) : 1];
$access = $this->buildAuth($node = NodeService::parseNodeStr("{$module}/{$controller}/{$action}"));
// 登录状态检查
if (!empty($access['is_login']) && !session('user')) {
$msg = ['code' => 0, 'msg' => '抱歉,您还没有登录获取访问权限!', 'url' => url('@admin/login')];
throw new HttpResponseException($request->isAjax() ? json($msg) : redirect($msg['url']));
return $request->isAjax() ? json($msg) : redirect($msg['url']);
}
// 访问权限检查
if (!empty($access['is_auth']) && !auth($node)) {
throw new HttpResponseException(json(['code' => 0, 'msg' => '抱歉,您没有访问该模块的权限!']));
return json(['code' => 0, 'msg' => '抱歉,您没有访问该模块的权限!']);
}
// 模板常量声明
app('view')->init(config('template.'))->assign(['classuri' => NodeService::parseNodeStr("{$module}/{$controller}")]);
},
];
return $next($request);
}
/**
* 根据节点获取对应权限配置
* @param string $node 权限节点
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function buildAuth($node)
{
$info = Db::name('SystemNode')->cache(true, 30)->where(['node' => $node])->find();
return [
'is_menu' => intval(!empty($info['is_menu'])),
'is_auth' => intval(!empty($info['is_auth'])),
'is_login' => empty($info['is_auth']) ? intval(!empty($info['is_login'])) : 1,
];
}
}

View File

@ -0,0 +1,18 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
return [
// 系统权限访问管理
\app\admin\middleware\Auth::class,
];

View File

@ -91,6 +91,7 @@ class Demo
*/
public function scanQrc()
{
$wechat = new Pay(config('wechat.'));
$options = [
'body' => '测试商品',

View File

@ -12,13 +12,17 @@
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
use think\facade\Env;
return [
// 应用名称
'app_name' => '',
// 应用地址
'app_host' => '',
// 应用调试模式
'app_debug' => true,
// 应用Trace
'app_trace' => false,
// 应用模式状态
'app_status' => '',
// 是否支持多模块
'app_multi_module' => true,
// 入口自动绑定模块
@ -34,17 +38,22 @@ return [
// 默认JSONP处理方法
'var_jsonp_handler' => 'callback',
// 默认时区
'default_timezone' => 'PRC',
'default_timezone' => 'Asia/Shanghai',
// 是否开启多语言
'lang_switch_on' => false,
// 默认全局过滤方法 用逗号分隔多个
'default_filter' => 'trim',
'default_filter' => '',
// 默认语言
'default_lang' => 'zh-cn',
// 应用类库后缀
'class_suffix' => false,
// 控制器类后缀
'controller_suffix' => false,
// +----------------------------------------------------------------------
// | 模块设置
// +----------------------------------------------------------------------
// 默认模块名
'default_module' => 'index',
// 禁止访问模块
@ -55,32 +64,47 @@ return [
'default_action' => 'index',
// 默认验证器
'default_validate' => '',
// 默认的空模块名
'empty_module' => '',
// 默认的空控制器名
'empty_controller' => 'Error',
// 操作方法前缀
'use_action_prefix' => false,
// 操作方法后缀
'action_suffix' => '',
// 自动搜索控制器
'controller_auto_search' => false,
// +----------------------------------------------------------------------
// | URL设置
// +----------------------------------------------------------------------
// PATHINFO变量名 用于兼容模式
'var_pathinfo' => 's',
// 兼容PATH_INFO获取
'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
// pathinfo分隔符
'pathinfo_depr' => '/',
// HTTPS代理标识
'https_agent_name' => '',
// IP代理获取标识
'http_agent_ip' => 'X-REAL-IP',
// URL伪静态后缀
'url_html_suffix' => 'html',
// URL普通方式参数 用于自动生成
'url_common_param' => false,
// URL参数方式 0 按名称成对解析 1 按顺序解析
'url_param_type' => 1,
// 路由使用完整匹配
'route_complete_match' => false,
// 是否开启路由延迟解析
'url_lazy_route' => false,
// 是否强制使用路由
'url_route_must' => false,
// 合并路由规则
'route_rule_merge' => false,
// 路由是否完全匹配
'route_complete_match' => false,
// 使用注解路由
'route_annotation' => false,
// 域名部署
'url_domain_deploy' => false,
// 域名根如thinkphp.cn
'url_domain_root' => '',
// 是否自动转换URL中的控制器和操作名
@ -97,11 +121,22 @@ return [
'request_cache' => false,
// 请求缓存有效期
'request_cache_expire' => null,
// 全局请求缓存排除规则
'request_cache_except' => [],
// 是否开启路由缓存
'route_check_cache' => false,
// 路由缓存的Key自定义设置闭包默认为当前URL和请求类型的md5
'route_check_cache_key' => '',
// 路由缓存类型及参数
'route_cache_option' => '',
// 默认跳转页面对应的模板文件
'dispatch_success_tmpl' => env('think_path') . 'tpl/dispatch_jump.tpl',
'dispatch_error_tmpl' => env('think_path') . 'tpl/dispatch_jump.tpl',
'dispatch_success_tmpl' => Env::get('think_path') . 'tpl/dispatch_jump.tpl',
'dispatch_error_tmpl' => Env::get('think_path') . 'tpl/dispatch_jump.tpl',
// 异常页面的模板文件
'exception_tmpl' => env('think_path') . 'tpl/think_exception.tpl',
'exception_tmpl' => Env::get('think_path') . 'tpl/think_exception.tpl',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',
// 显示错误信息

View File

@ -1,20 +1,25 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// | 缓存设置
// +----------------------------------------------------------------------
return [
'expire' => 0,
'prefix' => '',
'path' => '',
// 驱动方式
'type' => 'File',
// 缓存保存目录
'path' => '',
// 缓存前缀
'prefix' => '',
// 缓存有效期 0表示永久缓存
'expire' => 0,
];

19
config/console.php Normal file
View File

@ -0,0 +1,19 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
return [
'name' => 'Think Console',
'version' => '0.1',
'user' => null,
];

View File

@ -21,9 +21,9 @@ return [
'path' => '/',
// cookie 有效域名
'domain' => '',
// cookie 启用安全传输
// cookie 启用安全传输
'secure' => false,
// httponly 设置
// httponly设置
'httponly' => '',
// 是否使用 setcookie
'setcookie' => true,

View File

@ -13,6 +13,7 @@
// +----------------------------------------------------------------------
return [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
@ -42,6 +43,8 @@ return [
'master_num' => 1,
// 指定从服务器序号
'slave_no' => '',
// 自动读取主库数据
'read_master' => false,
// 是否严格检查字段是否存在
'fields_strict' => true,
// 数据集返回类型
@ -52,6 +55,12 @@ return [
'datetime_format' => 'Y-m-d H:i:s',
// 是否需要进行SQL性能分析
'sql_explain' => false,
// Builder类
'builder' => '',
// Query类
'query' => '\\think\\db\\Query',
// 是否需要断线重连
'break_reconnect' => false,
// 断线标识字符串
'break_match_str' => [],
];

View File

@ -13,8 +13,18 @@
// +----------------------------------------------------------------------
return [
'path' => '',
// 日志记录方式,内置 file socket 支持扩展
'type' => 'File',
'file_size' => 1024 * 1024 * 10,
// 日志保存目录
'path' => '',
// 日志记录级别
'level' => [],
// 单文件日志写入
'single' => false,
// 独立日志级别
'apart_level' => ['emergency', 'alert', 'critical', 'error', 'sql'],
];
// 最大日志文件数量
'max_files' => 0,
// 是否关闭日志写入
'close' => false,
];

View File

@ -18,26 +18,21 @@ $uriRoot = rtrim(preg_match('/\.php$/', $appRoot) ? dirname($appRoot) : $appRoot
return [
// 模板引擎类型 支持 php think 支持扩展
'type' => 'Think',
'type' => 'Think',
// 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
'auto_rule' => 1,
// 模板路径
'view_path' => '',
'view_path' => '',
// 模板后缀
'view_suffix' => 'html',
'view_suffix' => 'html',
// 模板文件名分隔符
'view_depr' => DIRECTORY_SEPARATOR,
'view_depr' => DIRECTORY_SEPARATOR,
// 模板引擎普通标签开始标记
'tpl_begin' => '{',
'tpl_begin' => '{',
// 模板引擎普通标签结束标记
'tpl_end' => '}',
'tpl_end' => '}',
// 标签库标签开始标记
'taglib_begin' => '{',
'taglib_begin' => '{',
// 标签库标签结束标记
'taglib_end' => '}',
// 定义模板替换字符串
'tpl_replace_string' => [
'__APP__' => $appRoot,
'__ROOT__' => $uriRoot,
'__STATIC__' => $uriRoot . "/static",
],
'taglib_end' => '}',
];

View File

@ -13,5 +13,6 @@
// +----------------------------------------------------------------------
return [
// 内置Html Console 支持扩展
'type' => 'Html',
];

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::getLoader();
return ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527::getLoader();

View File

@ -175,6 +175,7 @@ return array(
'app\\admin\\controller\\Node' => $baseDir . '/application/admin/controller/Node.php',
'app\\admin\\controller\\Plugs' => $baseDir . '/application/admin/controller/Plugs.php',
'app\\admin\\controller\\User' => $baseDir . '/application/admin/controller/User.php',
'app\\admin\\middleware\\Auth' => $baseDir . '/application/admin/middleware/Auth.php',
'app\\index\\controller\\Index' => $baseDir . '/application/index/controller/Index.php',
'app\\store\\controller\\Express' => $baseDir . '/application/store/controller/Express.php',
'app\\store\\controller\\Goods' => $baseDir . '/application/store/controller/Goods.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f
class ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit6a1d9670263853112be0eb50705ac527', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit6a1d9670263853112be0eb50705ac527::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInit3b653bd8f42dcddd1a5ffaa4b92dcf0f
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit6a1d9670263853112be0eb50705ac527::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire3b653bd8f42dcddd1a5ffaa4b92dcf0f($fileIdentifier, $file);
composerRequire6a1d9670263853112be0eb50705ac527($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire3b653bd8f42dcddd1a5ffaa4b92dcf0f($fileIdentifier, $file)
function composerRequire6a1d9670263853112be0eb50705ac527($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f
class ComposerStaticInit6a1d9670263853112be0eb50705ac527
{
public static $files = array (
'1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php',
@ -265,6 +265,7 @@ class ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f
'app\\admin\\controller\\Node' => __DIR__ . '/../..' . '/application/admin/controller/Node.php',
'app\\admin\\controller\\Plugs' => __DIR__ . '/../..' . '/application/admin/controller/Plugs.php',
'app\\admin\\controller\\User' => __DIR__ . '/../..' . '/application/admin/controller/User.php',
'app\\admin\\middleware\\Auth' => __DIR__ . '/../..' . '/application/admin/middleware/Auth.php',
'app\\index\\controller\\Index' => __DIR__ . '/../..' . '/application/index/controller/Index.php',
'app\\store\\controller\\Express' => __DIR__ . '/../..' . '/application/store/controller/Express.php',
'app\\store\\controller\\Goods' => __DIR__ . '/../..' . '/application/store/controller/Goods.php',
@ -302,9 +303,9 @@ class ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3b653bd8f42dcddd1a5ffaa4b92dcf0f::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit6a1d9670263853112be0eb50705ac527::$classMap;
}, null, ClassLoader::class);
}

View File

@ -146,12 +146,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/WeOpenDeveloper.git",
"reference": "d5fb9d2b307251c7faedcb61758119bcb5b836d0"
"reference": "f0b34848d75147b16632bdec1583172936c2fff4"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/zoujingli/WeOpenDeveloper/d5fb9d2b307251c7faedcb61758119bcb5b836d0.zip",
"reference": "d5fb9d2b307251c7faedcb61758119bcb5b836d0",
"url": "https://files.phpcomposer.com/files/zoujingli/WeOpenDeveloper/f0b34848d75147b16632bdec1583172936c2fff4.zip",
"reference": "f0b34848d75147b16632bdec1583172936c2fff4",
"shasum": ""
},
"require": {
@ -160,7 +160,7 @@
"php": ">=5.4",
"zoujingli/wechat-developer": "^1.0"
},
"time": "2018-05-23T07:29:30+00:00",
"time": "2018-06-04T09:19:16+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {

View File

@ -1,4 +1,7 @@
[![Latest Stable Version](https://poser.pugx.org/zoujingli/weopen-developer/v/stable)](https://packagist.org/packages/weopen-developer) [![Latest Unstable Version](https://poser.pugx.org/zoujingli/weopen-developer/v/unstable)](https://packagist.org/packages/zoujingli/weopen-developer) [![Total Downloads](https://poser.pugx.org/zoujingli/weopen-developer/downloads)](https://packagist.org/packages/weopen-developer) [![License](https://poser.pugx.org/zoujingli/weopen-developer/license)](https://packagist.org/packages/weopen-developer)
[![Latest Stable Version](https://poser.pugx.org/zoujingli/weopen-developer/v/stable)](https://packagist.org/packages/zoujingli/weopen-developer)
[![Latest Unstable Version](https://poser.pugx.org/zoujingli/weopen-developer/v/unstable)](https://packagist.org/packages/zoujingli/weopen-developer)
[![Total Downloads](https://poser.pugx.org/zoujingli/weopen-developer/downloads)](https://packagist.org/packages/zoujingli/weopen-developer)
[![License](https://poser.pugx.org/zoujingli/weopen-developer/license)](https://packagist.org/packages/zoujingli/weopen-developer)
# WeOpenDeveloper
WeOpenDeveloper 为微信开放平台服务开发工具,基于 WeChatDeveloper 可对公众号进行管理。