app.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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('/index', 'index/index/index');
  24. Route::get('/', 'index/index/index');
  25. Route::view('/404', '404');
  26. Route::get('/about', 'index/index/about')->append(['_aside' => true]);
  27. Route::get('/guest_book', 'index/index/guestBook');
  28. Route::post('/save_guest_book', 'index/index/saveGuestBook');
  29. Route::get('/tags/:name', 'index/article/tags');
  30. Route::get('/all-<page?>', 'index/article/index')->append(['cid' => 0]);
  31. Route::post('/dolike', 'index/article/dolike');
  32. Route::get('/:year/<month>-<day>/:id', 'index/article/read');
  33. Route::get('/:year/<month>-<page?>', 'index/article/archive');
  34. $list = Category::getList();
  35. foreach ($list as $key => $value) {
  36. Route::get($value->url . '-<page?>', $value->route)->append(['cid' => $value->id]);
  37. }