<?php

use think\facade\Route;
use think\facade\Config;
use think\Response;

Route::group(function () {
    Route::get('index', 'PublicController/index')->name('index');//首页
    Route::get('page/:unique', 'PublicController/page')->name('pageDetail');//单页详情

    //机构
    Route::get('organ/list', 'auti.CourseController/organList')->name('organList');//机构列表
    Route::get('organ/detail/:id', 'auti.CourseController/organ')->name('organDetail');//机构详情
    //课程
    Route::get('course/list', 'auti.CourseController/list')->name('courseList');//课程列表
    Route::get('course/detail/:id', 'auti.CourseController/detail')->name('courseDetail');//课程详情
    //相关知识
    Route::get('article/list', 'auti.ArticleController/list')->name('articleList');//文章列表
    Route::get('article/detail/:id', 'auti.ArticleController/detail')->name('articleDetail');//文章详情
})->middleware(\app\http\middleware\AllowOriginMiddleware::class);

Route::miss(function () {
    if (app()->request->isOptions()) {
        $header = Config::get('cookie.header');
        unset($header['Access-Control-Allow-Credentials']);
        return Response::create('ok')->code(200)->header($header);
    } else
        return Response::create()->code(404);
});