app.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. use think\facade\Route;
  12. use app\common\model\Category;
  13. use think\facade\Template;
  14. Route::pattern([
  15. 'name' => '\w+',
  16. 'id' => '\d+',
  17. 'cid' => '\d+',
  18. 'page' => '\d+',
  19. 'year' => '\d+',
  20. 'month' => '\d+',
  21. 'day' => '\d+',
  22. ]);
  23. Route::get('think', function () {
  24. return 'hello,ThinkPHP6!';
  25. });
  26. Route::view('/404', '404');
  27. Route::get('/all', 'index/article/index');
  28. Route::get('/:year/:month/:day/:id', 'index/article/read');
  29. Route::get('/:year/:month', 'index/article/archive');
  30. Route::post('/dolike', 'index/article/dolike');
  31. Route::get('/tags/:name', 'index/article/tags');
  32. Route::get('/time', 'index/article/time')->append(['_aside' => true]);
  33. Route::get('/about', 'index/index/about')->append(['_aside' => true]);
  34. $list = Category::getList();
  35. foreach ($list as $key => $value) {
  36. if ($value->template == 'article') {
  37. Route::get('/'.$value->url, 'index/article/index')->append(['cid' => $value->id]);
  38. }
  39. }