<?php
namespace app\system\route;


use app\system\middleware\AllowOriginMiddleware;
use think\facade\Config;
use think\facade\Route;
use think\Response;

/**
 * 无需授权的接口
 */
Route::group(function () {
    //后台管理员登录
    Route::rule('login/login', 'Login/index');

    Route::rule('login/logut', 'Login/logut');
    //验证码
    Route::get('login/captcha', 'Login/captcha');
    //
    Route::rule('index', 'Index/index');
    //绑定登录
    Route::rule('login/system_bind','Login/system_bind');
    //绑定登录数据
    Route::rule('login/system_bind_data','Login/system_bind_data');
    //绑定成功
    Route::rule('login/bindsuccess','Login/bindsuccess');

})->middleware(AllowOriginMiddleware::class);

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