|
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\Route;
use app\admin\model\Category as CategoryModel;
use app\admin\model\SysMenu as SysMenuModel;
Route::pattern([
'name' => '\w+',
'id' => '\d+',
'cid' => '\d+',
'page' => '\d+',
]);
// 首页
Route::get('/','index');
Route::get('index','index/index/index');
// 登录
Route::get('admin/login','admin/login/index');
Route::post('admin/login/login','admin/login/dologin');
Route::get('admin/login/logout','admin/login/logout');
// 后台首页
Route::get('admin/index/index','admin/index/index');
Route::get('admin/index','admin/index/index');
Route::get('admin','admin/index/index');
// index 模块路由
$categoryModel = new CategoryModel();
$categoryList = $categoryModel->field('id,pid,name,tablename,url,type')->where('is_del', 0)->select();
foreach ($categoryList as $key => $value) {
// var_dump($value->toArray());
if ($value->type==2) {
Route::get($value->url,'index/'.$value->url.'/index');
} elseif($value->type==1) {
Route::get($value->url,'index/'.$value->tablename.'/index?cid='.$value->id);
} else {
Route::get($value->url.'/:id','index/'.$value->tablename.'/detail?cid='.$value->id);
Route::get($value->url,'index/'.$value->tablename.'/index?cid='.$value->id);
}
}
// exit;
// admin 模块路由
$sysMenuModel = new SysMenuModel();
$sysMenuList = $sysMenuModel->field('id, pid, name, url, type, icon')->select();
foreach ($sysMenuList as $key => $value) {
// var_dump($value->toArray());
if ($value->type==1) {
Route::get($value->url,$value->url);
} elseif($value->type==2) {
Route::rule($value->url,$value->url);
}
}
// exit;
// Route::get('contactus','index/base/contactus');
// Route::get('news/:id','index/article/detail?cid=3');
// Route::get('news','index/article/index?cid=3');
// Route::get('case/:id','index/article/detail?cid=4');
// Route::get('case','index/article/index?cid=4');
// Route::get('honour/:id','index/article/detail?cid=5');
// Route::get('honour','index/article/index?cid=5');
// Route::get('product/:id','index/article/detail?cid=2');
// Route::get('product','index/article/index?cid=2');
|