[更新]修改路由加载

This commit is contained in:
Anyon 2018-05-05 16:23:44 +08:00
parent a34cf9ed43
commit 9e58620a2e
7 changed files with 108 additions and 63 deletions

View File

@ -0,0 +1,24 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
use think\facade\App;
use think\facade\Route;
use think\Request;
/* 注册微信端路由支持 */
Route::rule('wx-<controller>-<action>', function (Request $request, $controller, $action) {
$params = explode('-', $request->pathinfo());
[array_shift($params), array_shift($params), array_shift($params)];
return App::action("store/wechat.{$controller}/{$action}", $params);
});

59
route/demo.php Normal file
View File

@ -0,0 +1,59 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
use think\facade\Route;
// 不执行下面的路由
return [];
/* 测试环境禁止操作路由绑定 */
Route::post('admin/user/pass', function () {
return json(['code' => 0, 'msg' => '测试环境禁修改用户密码!']);
});
Route::post('admin/index/pass', function () {
return json(['code' => 0, 'msg' => '测试环境禁修改用户密码!']);
});
Route::post('admin/config/index', function () {
return json(['code' => 0, 'msg' => '测试环境禁修改系统配置操作!']);
});
Route::post('admin/config/file', function () {
return json(['code' => 0, 'msg' => '测试环境禁修改文件配置操作!']);
});
Route::post('admin/menu/index', function () {
return json(['code' => 0, 'msg' => '测试环境禁排序菜单操作!']);
});
Route::post('admin/menu/add', function () {
return json(['code' => 0, 'msg' => '测试环境禁添加菜单操作!']);
});
Route::post('admin/menu/edit', function () {
return json(['code' => 0, 'msg' => '测试环境禁编辑菜单操作!']);
});
Route::post('admin/menu/forbid', function () {
return json(['code' => 0, 'msg' => '测试环境禁止禁用菜单操作!']);
});
Route::post('admin/menu/del', function () {
return json(['code' => 0, 'msg' => '测试环境禁止删除菜单操作!']);
});
Route::post('wechat/config/index', function () {
return json(['code' => 0, 'msg' => '测试环境禁止修改微信配置操作!']);
});
Route::post('admin/node/save', function () {
return json(['code' => 0, 'msg' => '测试环境禁止修改节点数据操作!']);
});
Route::post('wechat/menu/edit', function () {
return json(['code' => 0, 'msg' => '测试环境禁止修改微信菜单操作!']);
});
Route::get('wechat/menu/cancel', function () {
return json(['code' => 0, 'msg' => '测试环境禁止删除微信菜单操作!']);
});

View File

@ -12,56 +12,16 @@
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
use think\facade\App;
use think\facade\Route;
use think\Request;
/* 注册微信端路由支持 */
Route::rule('wx-<controller>-<action>', function (Request $request, $controller, $action) {
$params = explode('-', $request->pathinfo());
[array_shift($params), array_shift($params), array_shift($params)];
return App::action("store/wechat.{$controller}/{$action}", $params);
});
/**
* 模块路由及配置检测并加载
* @include module/init.php
* @author Anyon<zoujingli@qq.com>
*/
foreach (scandir(env('app_path')) as $dir) {
if ($dir[0] !== '.') {
$filename = realpath(env('app_path') . "{$dir}/init.php");
$filename && file_exists($filename) && include($filename);
}
}
return [];
/* 测试环境禁止操作路由绑定 */
Route::post('admin/user/pass', function () {
return json(['code' => 0, 'msg' => '测试环境禁修改用户密码!']);
});
Route::post('admin/index/pass', function () {
return json(['code' => 0, 'msg' => '测试环境禁修改用户密码!']);
});
Route::post('admin/config/index', function () {
return json(['code' => 0, 'msg' => '测试环境禁修改系统配置操作!']);
});
Route::post('admin/config/file', function () {
return json(['code' => 0, 'msg' => '测试环境禁修改文件配置操作!']);
});
Route::post('admin/menu/index', function () {
return json(['code' => 0, 'msg' => '测试环境禁排序菜单操作!']);
});
Route::post('admin/menu/add', function () {
return json(['code' => 0, 'msg' => '测试环境禁添加菜单操作!']);
});
Route::post('admin/menu/edit', function () {
return json(['code' => 0, 'msg' => '测试环境禁编辑菜单操作!']);
});
Route::post('admin/menu/forbid', function () {
return json(['code' => 0, 'msg' => '测试环境禁止禁用菜单操作!']);
});
Route::post('admin/menu/del', function () {
return json(['code' => 0, 'msg' => '测试环境禁止删除菜单操作!']);
});
Route::post('wechat/config/index', function () {
return json(['code' => 0, 'msg' => '测试环境禁止修改微信配置操作!']);
});
Route::post('admin/node/save', function () {
return json(['code' => 0, 'msg' => '测试环境禁止修改节点数据操作!']);
});
Route::post('wechat/menu/edit', function () {
return json(['code' => 0, 'msg' => '测试环境禁止修改微信菜单操作!']);
});
Route::get('wechat/menu/cancel', function () {
return json(['code' => 0, 'msg' => '测试环境禁止删除微信菜单操作!']);
});

2
vendor/autoload.php vendored
View File

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

View File

@ -162,6 +162,7 @@ return array(
'app\\store\\controller\\GoodsCate' => $baseDir . '/application/store/controller/GoodsCate.php',
'app\\store\\controller\\GoodsSpec' => $baseDir . '/application/store/controller/GoodsSpec.php',
'app\\store\\controller\\Order' => $baseDir . '/application/store/controller/Order.php',
'app\\store\\controller\\wechat\\Demo' => $baseDir . '/application/store/controller/wechat/Demo.php',
'app\\store\\controller\\wechat\\Index' => $baseDir . '/application/store/controller/wechat/Index.php',
'app\\store\\service\\GoodsService' => $baseDir . '/application/store/service/GoodsService.php',
'app\\store\\service\\OrderService' => $baseDir . '/application/store/service/OrderService.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit38d0f6865bffe6f3ec7977ff5e7499f1
class ComposerAutoloaderInitf5974243cd36d6c47ccc2deac6411e2c
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInit38d0f6865bffe6f3ec7977ff5e7499f1
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit38d0f6865bffe6f3ec7977ff5e7499f1', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitf5974243cd36d6c47ccc2deac6411e2c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit38d0f6865bffe6f3ec7977ff5e7499f1', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitf5974243cd36d6c47ccc2deac6411e2c', '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\ComposerStaticInit38d0f6865bffe6f3ec7977ff5e7499f1::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitf5974243cd36d6c47ccc2deac6411e2c::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInit38d0f6865bffe6f3ec7977ff5e7499f1
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit38d0f6865bffe6f3ec7977ff5e7499f1::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitf5974243cd36d6c47ccc2deac6411e2c::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire38d0f6865bffe6f3ec7977ff5e7499f1($fileIdentifier, $file);
composerRequiref5974243cd36d6c47ccc2deac6411e2c($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire38d0f6865bffe6f3ec7977ff5e7499f1($fileIdentifier, $file)
function composerRequiref5974243cd36d6c47ccc2deac6411e2c($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit38d0f6865bffe6f3ec7977ff5e7499f1
class ComposerStaticInitf5974243cd36d6c47ccc2deac6411e2c
{
public static $files = array (
'1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php',
@ -245,6 +245,7 @@ class ComposerStaticInit38d0f6865bffe6f3ec7977ff5e7499f1
'app\\store\\controller\\GoodsCate' => __DIR__ . '/../..' . '/application/store/controller/GoodsCate.php',
'app\\store\\controller\\GoodsSpec' => __DIR__ . '/../..' . '/application/store/controller/GoodsSpec.php',
'app\\store\\controller\\Order' => __DIR__ . '/../..' . '/application/store/controller/Order.php',
'app\\store\\controller\\wechat\\Demo' => __DIR__ . '/../..' . '/application/store/controller/wechat/Demo.php',
'app\\store\\controller\\wechat\\Index' => __DIR__ . '/../..' . '/application/store/controller/wechat/Index.php',
'app\\store\\service\\GoodsService' => __DIR__ . '/../..' . '/application/store/service/GoodsService.php',
'app\\store\\service\\OrderService' => __DIR__ . '/../..' . '/application/store/service/OrderService.php',
@ -273,9 +274,9 @@ class ComposerStaticInit38d0f6865bffe6f3ec7977ff5e7499f1
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit38d0f6865bffe6f3ec7977ff5e7499f1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit38d0f6865bffe6f3ec7977ff5e7499f1::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit38d0f6865bffe6f3ec7977ff5e7499f1::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf5974243cd36d6c47ccc2deac6411e2c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf5974243cd36d6c47ccc2deac6411e2c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf5974243cd36d6c47ccc2deac6411e2c::$classMap;
}, null, ClassLoader::class);
}