60 lines
2.8 KiB
PHP
Executable File
60 lines
2.8 KiB
PHP
Executable File
<?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>
|
|
// +----------------------------------------------------------------------
|
|
use think\facade\Route;
|
|
use app\model\Model;
|
|
|
|
$model = Model::where('status', '>', 0)->field(['id', 'name'])->select()->toArray();
|
|
|
|
foreach ($model as $value) {
|
|
Route::rule('/admin/' . $value['name'] . '/:function', 'Admin.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
|
|
Route::rule('/front/' . $value['name'] . '/:function', 'Front.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
|
|
Route::rule('/user/' . $value['name'] . '/:function', 'User.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
|
|
}
|
|
|
|
Route::rule('/', 'Front.Index/index');
|
|
Route::rule('search', 'Front.Content/search');
|
|
Route::rule('lists', 'Front.Content/lists');
|
|
Route::rule('detail-:id', 'Front.Content/detail');
|
|
Route::rule('category', 'Front.Content/category');
|
|
Route::rule('topic-:id', 'Front.Content/topic');
|
|
Route::rule('form/:id/:name', 'Front.Form/index');
|
|
Route::rule('front/:controller/:function', 'Front.:controller/:function');
|
|
|
|
Route::group('admin', function () {
|
|
Route::rule('/', 'admin.Index/index');
|
|
Route::rule('login', 'admin.Index/login');
|
|
Route::rule('logout', 'admin.Index/logout');
|
|
Route::rule('upload/:function', 'Upload/:function');
|
|
Route::rule(':controller/:function', 'admin.:controller/:function');
|
|
});
|
|
|
|
Route::group('user', function () {
|
|
Route::rule('/', 'User.Index/index');
|
|
Route::rule('login', 'User.Index/login');
|
|
Route::rule('logout', 'User.Index/logout');
|
|
Route::rule('register', 'User.Index/register');
|
|
Route::rule('upload/:function', 'Upload/:function');
|
|
Route::rule(':controller/:function', 'User.:controller/:function');
|
|
});
|
|
|
|
Route::group('api', function () {
|
|
Route::rule('/', 'api.Index/index');
|
|
Route::rule('login', 'api.Login/index');
|
|
Route::rule('register', 'api.Login/register');
|
|
Route::rule('logout', 'api.Login/logout');
|
|
Route::rule(':controller/:function', 'api.:controller/:function');
|
|
})->allowCrossDomain([
|
|
'Access-Control-Allow-Origin' => '*',
|
|
'Access-Control-Allow-Credentials' => 'true',
|
|
'Access-Control-Allow-Headers' => 'authorization, token, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With',
|
|
]);
|
|
|
|
Route::miss('front.Index/miss'); |