diff --git a/.editorconfig b/.editorconfig index 1671c9b..64b6e07 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,7 @@ charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space -indent_size = 4 +indent_size = 2 trim_trailing_whitespace = true [*.md] diff --git a/app/Http/Controllers/AdminAccountController.php b/app/Http/Controllers/AdminAccountController.php deleted file mode 100644 index 8d6ce52..0000000 --- a/app/Http/Controllers/AdminAccountController.php +++ /dev/null @@ -1,10 +0,0 @@ -post('id'); - Login::admin($id); - return Yo::echo(); - } - - public function menu() - { - Login::admin(3); - $menu_group = Auth::select('id', 'name', 'title', 'icon', 'status') - ->where('type', 1)->where('show', 1)->where('del', 2) - ->orderBy('order', 'desc')->get(); - $list = []; - foreach ($menu_group as $item) { - switch (Login::$info->admin_auth_id) { - case -1: - $auth_list = Auth::select('id', 'name', 'title', 'icon', 'status')->where('pid', $item->id) - ->where('type', 2)->where('show', 1)->where('del', 2) - ->orderBy('order', 'desc')->get(); - break; - case 0: - $auth_list = Auth::select('id', 'name', 'title', 'icon', 'status')->where('pid', $item->id) - ->where('type', 2)->where('check_type', 1)->where('show', 1)->where('del', 2) - ->orderBy('order', 'desc')->get(); - break; - default: - $admin_auth = AdminAuth::find(Login::$info->admin_auth_id); - $auth_ids = json_decode($admin_auth->auth_ids, true); - $auth_list = Auth::select('id', 'name', 'title', 'icon', 'status') - ->where(function ($query) use ($auth_ids, $item) { - $query->whereIn('id', $auth_ids)->where('pid', $item->id)->where('type', 2)->where('check_type', 2)->where('show', 1)->where('del', 2); - }) - ->orWhere(function ($query) use ($auth_ids, $item) { - $query->where('type', 2)->where('pid', $item->id)->where('check_type', 1)->where('show', 1)->where('del', 2); - }) - ->orderBy('order', 'desc')->get(); - } - if (count($auth_list) !== 0) $list[] = [ - "id" => $item->id, - "name" => $item->name, - "title" => $item->title, - "icon" => $item->icon, - "status" => $item->status, - "children" => $auth_list - ]; - } - return Yo::echo([ - 'list' => $list - ]); - } - - public function all() - { - Login::admin(6); - $admin_auth_list = AdminAuth::select('id', 'name', 'del')->orderBy('updated_at', 'desc')->get(); - return Yo::echo([ - 'list' => $admin_auth_list - ]); - } - - public function list() - { - Login::admin(5); - $admin_auth_list = AdminAuth::select('id', 'name', 'auth_ids', 'remark')->where('del', 2)->orderBy('updated_at', 'desc')->get(); - $list = []; - foreach ($admin_auth_list as $item) { - $auth_ids_turn = []; - foreach (json_decode($item->auth_ids, true) as $i) { - $auth_ids_turn[] = intval($i); - } - $list[] = [ - 'id' => $item->id, - 'name' => $item->name, - 'auth_ids' => $item->auth_ids, - 'auth_ids_turn' => $auth_ids_turn, - 'remark' => $item->remark, - ]; - } - return Yo::echo([ - 'list' => $list - ]); - } - - public function delete() - { - Login::admin(5); - $ids = request()->post('ids'); - AdminAuth::whereIn('id', $ids)->update([ - 'del' => 1 - ]); - return Yo::delete_echo($ids); - } - - public function update(EditAdminAuthInput $request) - { - Login::admin(5); - $id = request()->post('id'); - $name = $request->post('name'); - $auth_ids = $request->post('auth_ids'); - $remark = $request->post('remark'); - $auth_ids_arr = []; - foreach ($auth_ids as $auth_id) $auth_ids_arr[] = (string)$auth_id; - $auth_ids_str = json_encode($auth_ids_arr, JSON_UNESCAPED_UNICODE); - if (mb_strlen($auth_ids_str) > 1000) Yo::error_echo(100007); - $admin_auth = AdminAuth::find($id); - if (!$admin_auth) Yo::error_echo(100008); - if ($admin_auth->del !== 2) Yo::error_echo(100008); - $admin_auth->name = $name; - $admin_auth->auth_ids = $auth_ids_str; - $admin_auth->remark = $remark ?? ''; - $admin_auth->save(); - return Yo::update_echo($admin_auth->id); - } - - public function create(EditAdminAuthInput $request) - { - Login::admin(5); - $name = $request->post('name'); - $auth_ids = $request->post('auth_ids'); - $remark = $request->post('remark'); - $auth_ids_arr = []; - foreach ($auth_ids as $auth_id) $auth_ids_arr[] = (string)$auth_id; - $auth_ids_str = json_encode($auth_ids_arr, JSON_UNESCAPED_UNICODE); - if (mb_strlen($auth_ids_str) > 1000) Yo::error_echo(100007); - $admin_auth = AdminAuth::create([ - 'name' => $name, - 'auth_ids' => $auth_ids_str ?? '[]', - 'remark' => $remark ?? '', - ]); - return Yo::create_echo($admin_auth->id); - } -} diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 0e240c0..417df12 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -2,219 +2,148 @@ namespace App\Http\Controllers; -use App\Http\Requests\CreateAdminInput; use App\Http\Requests\UpdateAdminNickname; use App\Http\Requests\UpdateAdminPassword; use App\Models\Admin; use App\Models\AdminAccount; +use App\Models\AdminAuth; use App\Models\AdminToken; +use App\Models\Auth; use Illuminate\Support\Str; use Yo; use Login; class AdminController extends Controller { - public function change_nickname(UpdateAdminNickname $request) - { - Login::admin(7); - $nickname = $request->post('nickname'); - Admin::where('id', Login::$info->id)->update([ - 'nickname' => $nickname - ]); - return Yo::update_echo(Login::$info->id); - } - - public function change_password(UpdateAdminPassword $request) - { - Login::admin(7); - $id = request()->post('id'); - $password = $request->post('password'); - $old_password = request()->post('old_password'); - $admin_account = AdminAccount::where('id', $id)->where('admin_id', Login::$info->id)->first(); - if (!$admin_account) Yo::error_echo(100008); - if (!password_verify($old_password, $admin_account->secret)) Yo::error_echo(100017); - if ($old_password === $password) Yo::error_echo(100018); - $admin_account->secret = bcrypt($password); - $admin_account->save(); - return Yo::update_echo(Login::$info->id); - } - - public function admin_info() - { - Login::admin(6); - $id = request()->post('id'); - $admin = Admin::select('id', 'nickname', 'admin_auth_id', 'status')->find($id); - $admin_account = AdminAccount::select('id', 'account')->where('admin_id', $admin->id)->where('type', 1)->first(); - return Yo::echo([ - 'info' => $admin, - 'account' => $admin_account, - ]); - } - - public function list() - { - Login::admin(6); - $status = request()->post('status'); - $search = request()->post('search'); - $admin_list = Admin::select('id', 'nickname', 'status') - ->selectRaw("IFNULL((select account from admin_accounts where admins.id = admin_accounts.admin_id and del = 2),'') as account") - ->where(function ($query) use ($status) { - if ($status != 0) $query->where('status', $status); + public function change_password(UpdateAdminPassword $request) + { + Login::admin(); + $account_id = request()->post('account_id'); + $password = $request->post('password'); + $old_password = request()->post('old_password'); + $admin_account = AdminAccount::where('id', $account_id)->where('admin_id', Login::$info->id)->first(); + if (!$admin_account) Yo::error_echo(100002); + if (!password_verify($old_password, $admin_account->secret)) Yo::error_echo(100010); + if ($old_password === $password) Yo::error_echo(100009); + $admin_account->secret = bcrypt($password); + $admin_account->save(); + return Yo::update_echo(Login::$info->id); + } + + public function change_nickname(UpdateAdminNickname $request) + { + Login::admin(); + $nickname = $request->post('nickname'); + Admin::where('id', Login::$info->id)->update([ + 'nickname' => $nickname + ]); + return Yo::update_echo(Login::$info->id); + } + + public function menu() + { + Login::admin(); + $menu_group = Auth::select('id', 'name', 'title', 'icon', 'status') + ->where('type', 1)->where('show', 1)->where('del', 2) + ->orderBy('order', 'desc')->get(); + $list = []; + foreach ($menu_group as $item) { + switch (Login::$info->admin_auth_id) { + case -1: + $auth_list = Auth::select('id', 'name', 'title', 'icon', 'status')->where('pid', $item->id) + ->where('type', 2)->where('show', 1)->where('del', 2) + ->orderBy('order', 'desc')->get(); + break; + case 0: + $auth_list = Auth::select('id', 'name', 'title', 'icon', 'status')->where('pid', $item->id) + ->where('type', 2)->where('check_type', 1)->where('show', 1)->where('del', 2) + ->orderBy('order', 'desc')->get(); + break; + default: + $admin_auth = AdminAuth::find(Login::$info->admin_auth_id); + $auth_ids = json_decode($admin_auth->auth_ids, true); + $auth_list = Auth::select('id', 'name', 'title', 'icon', 'status') + ->where(function ($query) use ($auth_ids, $item) { + $query->whereIn('id', $auth_ids)->where('pid', $item->id)->where('type', 2)->where('check_type', 2)->where('show', 1)->where('del', 2); }) - ->where('del', 2) - ->where(function ($query) use ($search) { - if ($search != '') $query->where('nickname', 'like', "%$search%"); - })->paginate(15); - return Yo::echo($admin_list); - } - - public function delete() - { - Login::admin(6); - $ids = request()->post('ids'); - Admin::whereIn('id', $ids)->update([ - 'del' => 1 - ]); - AdminAccount::whereIn('admin_id', $ids)->where('del', 2)->update([ - 'del' => 1 - ]); - return Yo::delete_echo($ids); - } - - public function update_status() - { - Login::admin(6); - $id = request()->post('id'); - if ($id == 1) Yo::error_echo(100016); - $status = request()->post('status'); - if ($status !== 2) $status = 1; - Admin::where('id', $id)->update([ - 'status' => $status - ]); - return Yo::update_echo($id); - } - - public function update_auth() - { - Login::admin(6); - $id = request()->post('id'); - if ($id == 1) Yo::error_echo(100016); - $admin_auth_id = request()->post('admin_auth_id'); - Admin::where('id', $id)->update([ - 'admin_auth_id' => $admin_auth_id - ]); - return Yo::update_echo($id); - } - - public function update_nickname(UpdateAdminNickname $request) - { - Login::admin(6); - $id = request()->post('id'); - $nickname = $request->post('nickname'); - Admin::where('id', $id)->update([ - 'nickname' => $nickname - ]); - return Yo::update_echo($id); - } - - public function update_password(UpdateAdminPassword $request) - { - Login::admin(6); - $id = request()->post('id'); - $password = $request->post('password'); - AdminAccount::where('id', $id)->update([ - 'secret' => bcrypt($password) - ]); - return Yo::update_echo($id); - } - - public function create(CreateAdminInput $request) - { - Login::admin(6); - $nickname = $request->post('nickname'); - $account = $request->post('account'); - $password = $request->post('password'); - $admin_auth_id = request()->post('admin_auth_id'); - if ($admin_auth_id == -1) Yo::error_echo(100016); - $admin_account_check = AdminAccount::select('id') - ->where('account', $account) - ->where('type', 1) - ->where('del', 2) - ->first(); - if ($admin_account_check) Yo::error_echo(100015); - $admin = new Admin(); - $admin->nickname = $nickname; - $admin->admin_auth_id = $admin_auth_id; - $admin->save(); - $admin_account = new AdminAccount(); - $admin_account->admin_id = $admin->id; - $admin_account->account = $account; - $admin_account->secret = bcrypt($password); - $admin_account->type = 1; - $admin_account->save(); - return Yo::create_echo($admin->id); - } - - public function info() - { - Login::admin(3); - $admin_account = AdminAccount::where('admin_id', Login::$info->id) - ->where('type', 1) - ->where('del', 2) - ->first(); - return Yo::echo([ - 'info' => [ - 'id' => Login::$info->id, - 'account' => $admin_account ? $admin_account->account : '', - 'account_id' => $admin_account ? $admin_account->id : 0, - 'nickname' => Login::$info->nickname, - ] - ]); - } - - public function status() - { - Login::admin(3); - return Yo::echo(); - } - - public function create_token($admin, $type) - { - if ($admin->status != 1) Yo::error_echo(100002); - if ($admin->del != 2) Yo::error_echo(100002); - $token = Str::orderedUuid(); - AdminToken::create([ - 'admin_id' => $admin->id, - 'token' => $token, - 'type' => $type, - 'del' => 2 - ]); - return $token; - } - - public function admin_login() - { - $account = request()->post('account'); - $password = request()->post('password'); - $type = 1; - $admin_account = AdminAccount::where('account', $account) - ->where('type', 1) - ->where('del', 2) - ->first(); - if (!$admin_account) Yo::error_echo(100001); - if (!password_verify($password, $admin_account->secret)) Yo::error_echo(100002); - $admin = Admin::where('id', $admin_account->admin_id) - ->where('status', 1) - ->where('del', 2) - ->first(); - if (!$admin) Yo::error_echo(100001); - Login::$info = $admin; - Login::$login_type = $type; - $auth_check_res = Login::check_admin_auth(2); - if ($auth_check_res !== 0) Yo::error_echo($auth_check_res); - $token = $this->create_token($admin, $type); - return Yo::echo([ - 'token' => $token - ]); + ->orWhere(function ($query) use ($auth_ids, $item) { + $query->where('type', 2)->where('pid', $item->id)->where('check_type', 1)->where('show', 1)->where('del', 2); + }) + ->orderBy('order', 'desc')->get(); + } + if (count($auth_list) !== 0) $list[] = [ + "id" => $item->id, + "name" => $item->name, + "title" => $item->title, + "icon" => $item->icon, + "status" => $item->status, + "children" => $auth_list + ]; } + return Yo::echo([ + 'list' => $list + ]); + } + + public function info() + { + Login::admin(); + $admin_account = AdminAccount::where('admin_id', Login::$info->id) + ->where('type', 1) + ->where('del', 2) + ->first(); + return Yo::echo([ + 'info' => [ + 'id' => Login::$info->id, + 'account' => $admin_account ? $admin_account->account : '', + 'account_id' => $admin_account ? $admin_account->id : 0, + 'nickname' => Login::$info->nickname, + ] + ]); + } + + public function status() + { + Login::admin(); + return Yo::echo(); + } + + public function create_token($admin, $type): string + { + if ($admin->status != 1 || $admin->del != 2) Yo::error_echo(100002); + $token = Str::orderedUuid(); + $admin_token = new AdminToken(); + $admin_token->admin_id = $admin->id; + $admin_token->token = $token; + $admin_token->type = $type; + $admin_token->del = 2; + $admin_token->save(); + return $token; + } + + public function login() + { + $account = request()->post('account'); + $password = request()->post('password'); + $type = 1; + $admin_account = AdminAccount::where('account', $account) + ->where('type', 1) + ->where('del', 2) + ->first(); + if (!$admin_account) Yo::error_echo(100004); + if (!password_verify($password, $admin_account->secret)) Yo::error_echo(100004); + $admin = Admin::where('id', $admin_account->admin_id) + ->where('status', 1) + ->where('del', 2) + ->first(); + if (!$admin) Yo::error_echo(100002); + Login::$info = $admin; + Login::$login_type = $type; + $auth_check_res = Login::check_admin_auth([2]); + if ($auth_check_res !== 0) Yo::error_echo($auth_check_res); + $token = $this->create_token($admin, $type); + return Yo::echo([ + 'token' => $token + ]); + } } diff --git a/app/Http/Controllers/AdminTokenController.php b/app/Http/Controllers/AdminTokenController.php deleted file mode 100644 index efb8382..0000000 --- a/app/Http/Controllers/AdminTokenController.php +++ /dev/null @@ -1,10 +0,0 @@ -where('type', 1)->where('del', 2) - ->orderBy('order', 'desc')->get(); - $page_list = []; - foreach ($page_group as $item) { - $page_auth_list = Auth::select('id', 'title')->where('pid', $item->id) - ->where('type', 2)->where('check_type', 2)->where('del', 2) - ->orderBy('order', 'desc')->get(); - if (count($page_auth_list) !== 0) $page_list[] = [ - "id" => $item->id, - "title" => $item->title, - "children" => $page_auth_list - ]; - } - $api_group = Auth::select('id', 'title') - ->where('type', 3)->where('del', 2) - ->orderBy('order', 'desc')->get(); - $api_list = []; - foreach ($api_group as $item) { - $api_auth_list = Auth::select('id', 'title')->where('pid', $item->id) - ->where('type', 4)->where('check_type', 2)->where('del', 2) - ->orderBy('order', 'desc')->get(); - if (count($api_auth_list) !== 0) $api_list[] = [ - "id" => $item->id, - "title" => $item->title, - "children" => $api_auth_list - ]; - } - return Yo::echo([ - 'page' => $page_list, - 'api' => $api_list, - ]); - } -} diff --git a/app/Http/Controllers/ConfigController.php b/app/Http/Controllers/ConfigController.php index 6afe2fa..6827ba2 100644 --- a/app/Http/Controllers/ConfigController.php +++ b/app/Http/Controllers/ConfigController.php @@ -9,61 +9,28 @@ use Login; class ConfigController extends Controller { - public function config() - { - $configs = $this->get_config_list([1, 2, 3, 4]); - $list = []; - foreach ($configs as $config) { - $list[$config['mark']] = $config['value']; - } - return Yo::echo($list); + public function get() + { + $label_arr = request()->post('label_arr'); + $configs = $this->get_config_list($label_arr); + $list = []; + foreach ($configs as $config) { + $value = $config->value; + if (in_array($config->type, [3, 4, 5, 6])) { + $value = json_decode($value, true); + } + $list[$config->label] = $value; } + return Yo::echo($list); + } - public function update() - { - Login::admin(9); - $mark = request()->get('mark'); - $value = request()->get('value'); - $config = Config::where('mark', $mark)->first(); - if (!$config) Yo::error_echo(100008); - switch ($mark) { - case 'logo': - case 'favicon': - case 'login_image': - $base64 = $value; - if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64, $result)) { - $type = ['png', 'jpeg', 'jpg', 'gif']; - if (!in_array($result[2], $type)) Yo::error_echo(100019); - $disk = Storage::disk('public'); - $path = "/assets/$mark.$result[2]"; - $put = $disk->put($path, base64_decode(str_replace($result[1], '', $base64))); - if (!$put) Yo::error_echo(100020); - $save = "/storage/assets/$mark.$result[2]?t=" . time(); - } else { - Yo::error_echo(100020); - } - break; - default: - $save = $value; - } - $config->value = $save; - $config->save(); - return Yo::update_echo($config->id); - } - - public function assets_list() - { - Login::admin(9); - $configs = $this->get_config_list([1, 2, 3, 4]); - $list = []; - foreach ($configs as $config) { - $list[$config['mark']] = $config['value']; - } - return Yo::echo($list); - } - - public function get_config_list($arr) - { - return Config::whereIn('id', $arr)->get(); + public function get_config_list($arr): array + { + $config_arr = []; + foreach ($arr as $item) { + $config = Config::where('label', $item)->first(); + if ($config) $config_arr[] = $config; } + return $config_arr; + } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 8bf1cff..0cb3805 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -10,9 +10,10 @@ use Lu; class Controller extends BaseController { - use AuthorizesRequests, DispatchesJobs, ValidatesRequests; + use AuthorizesRequests, DispatchesJobs, ValidatesRequests; - public function __construct(){ - Lu::RequestLog(); - } + public function __construct() + { + Lu::RequestLog(); + } } diff --git a/app/Http/Controllers/YoController.php b/app/Http/Controllers/YoController.php index 9b733ac..823088c 100644 --- a/app/Http/Controllers/YoController.php +++ b/app/Http/Controllers/YoController.php @@ -6,11 +6,11 @@ use Yo as Yoo; class YoController extends Controller { - public function __invoke() - { - return Yoo::echo([ - 'app_name' => env('APP_NAME'), - 'data' => request()->all() - ]); - } + public function __invoke() + { + return Yoo::echo([ + 'app_name' => env('APP_NAME'), + 'data' => request()->all() + ]); + } } diff --git a/app/Http/Requests/CreateAdminInput.php b/app/Http/Requests/CreateAdminInput.php deleted file mode 100644 index b0e745d..0000000 --- a/app/Http/Requests/CreateAdminInput.php +++ /dev/null @@ -1,51 +0,0 @@ - ['required', 'between:1,30'], - 'account' => ['required', 'between:1,50'], - 'password' => ['required', 'between:6,20'], - ]; - } - - public function messages() - { - return [ - 'nickname.required' => 100009, - 'nickname.between' => 100010, - 'account.required' => 100011, - 'account.between' => 100012, - 'password.required' => 100013, - 'password.between' => 100014, - ]; - } - - public function failedValidation(Validator $validator) - { - Yo::error_echo($validator->errors()->first()); - } -} diff --git a/app/Http/Requests/EditAdminAuthInput.php b/app/Http/Requests/EditAdminAuthInput.php deleted file mode 100644 index 8543a14..0000000 --- a/app/Http/Requests/EditAdminAuthInput.php +++ /dev/null @@ -1,47 +0,0 @@ - ['required', 'between:1,20'], - 'remark' => ['between:0,100'], - ]; - } - - public function messages() - { - return [ - 'name.required' => 100004, - 'name.between' => 100005, - 'remark.between' => 100006, - ]; - } - - public function failedValidation(Validator $validator) - { - Yo::error_echo($validator->errors()->first()); - } -} diff --git a/app/Http/Requests/UpdateAdminNickname.php b/app/Http/Requests/UpdateAdminNickname.php index b6dd07e..db95530 100644 --- a/app/Http/Requests/UpdateAdminNickname.php +++ b/app/Http/Requests/UpdateAdminNickname.php @@ -8,38 +8,38 @@ use Yo; class UpdateAdminNickname extends FormRequest { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ - public function authorize() - { - return true; - } + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return true; + } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - 'nickname' => ['required', 'between:1,30'], - ]; - } + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'nickname' => ['required', 'between:1,30'], + ]; + } - public function messages() - { - return [ - 'nickname.required' => 100009, - 'nickname.between' => 100010, - ]; - } + public function messages() + { + return [ + 'nickname.required' => 100005, + 'nickname.between' => 100006, + ]; + } - public function failedValidation(Validator $validator) - { - Yo::error_echo($validator->errors()->first()); - } + public function failedValidation(Validator $validator) + { + Yo::error_echo($validator->errors()->first()); + } } diff --git a/app/Http/Requests/UpdateAdminPassword.php b/app/Http/Requests/UpdateAdminPassword.php index e63d997..9173583 100644 --- a/app/Http/Requests/UpdateAdminPassword.php +++ b/app/Http/Requests/UpdateAdminPassword.php @@ -8,38 +8,38 @@ use Yo; class UpdateAdminPassword extends FormRequest { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ - public function authorize() - { - return true; - } + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return true; + } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - 'password' => ['required', 'between:6,20'], - ]; - } + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'password' => ['required', 'between:6,20'], + ]; + } - public function messages() - { - return [ - 'password.required' => 100013, - 'password.between' => 100014, - ]; - } + public function messages() + { + return [ + 'password.required' => 100007, + 'password.between' => 100008, + ]; + } - public function failedValidation(Validator $validator) - { - Yo::error_echo($validator->errors()->first()); - } + public function failedValidation(Validator $validator) + { + Yo::error_echo($validator->errors()->first()); + } } diff --git a/app/Libraries/Login.php b/app/Libraries/Login.php index 0d7103b..eb18a09 100755 --- a/app/Libraries/Login.php +++ b/app/Libraries/Login.php @@ -11,13 +11,13 @@ class Login public static $login_type; public static $token_info; - public static function check_admin_auth($auth_id = 0) + public static function check_admin_auth($auth_id = 0): int { if (self::$info->admin_auth_id === -1) return 0; $auth = Auth::where('id', $auth_id)->where('status', 1)->where('del', 2)->first(); - if (!$auth) return 100016; + if (!$auth) return 100003; if (self::$info->admin_auth_id === 0) { - if ($auth->check_type !== 1) return 100016; + if ($auth->check_type !== 1) return 100003; } else { if ($auth->check_type === 1) return 0; $admin_auth = AdminAuth::select('id') @@ -25,35 +25,45 @@ class Login ->where('auth_ids', 'like', "%\"$auth_id\"%") ->where('del', 2) ->first(); - if (!$admin_auth) return 100016; + if (!$admin_auth) return 100003; } return 0; } - public static function admin_check($auth_id = 0) + public static function admin_check($auth_ids = [], $or_ids = []): int { - if (!request()->header('Authorization')) return 100003; + if (!request()->header('Authorization')) return 100001; $header_token_arr = explode('Bearer ', request()->header('Authorization')); - if (!isset($header_token_arr[1])) return 100003; + if (!isset($header_token_arr[1])) return 100001; $header_token = $header_token_arr[1]; - if (!$header_token) return 100003; + if (!$header_token) return 100001; $admin_token_info = AdminToken::where('token', $header_token)->where('del', 2)->where('updated_at', '>', Lu::date(time() - (60 * 60 * 24 * 3)))->first(); - if (!$admin_token_info) return 100003; + if (!$admin_token_info) return 100001; $admin_info = Admin::where('id', $admin_token_info->admin_id)->where('del', 2)->where('status', 1)->first(); - if (!$admin_info) return 100003; + if (!$admin_info) return 100002; self::$info = $admin_info; self::$login_type = $admin_token_info->type; self::$token_info = $admin_token_info; - $auth_check_res = self::check_admin_auth($auth_id); - if ($auth_check_res !== 0) return $auth_check_res; + foreach ($auth_ids as $item) { + $auth_check_res = self::check_admin_auth($item); + if ($auth_check_res != 0) return $auth_check_res; + } + $ret = 0; + $ret_code = 0; + foreach ($or_ids as $item) { + $auth_check_res = self::check_admin_auth($item); + if ($auth_check_res == 0) $ret++; + if ($auth_check_res != 0) $ret_code = $auth_check_res; + } + if ($ret == 0 && $ret_code != 0) return $ret_code; $admin_token_info->updated_at = Lu::date(); $admin_token_info->save(); return 0; } - public static function admin($auth_id = 0) + public static function admin($auth_ids = [], $or_ids = []) { - $check_res = self::admin_check($auth_id); - if ($check_res !== 0) Yo::error_echo($check_res); + $check_res = self::admin_check($auth_ids, $or_ids); + if ($check_res != 0) Yo::error_echo($check_res); } } diff --git a/app/Models/AdminAuth.php b/app/Models/AdminAuth.php index 9d2225a..9b362b0 100644 --- a/app/Models/AdminAuth.php +++ b/app/Models/AdminAuth.php @@ -8,6 +8,4 @@ use Illuminate\Database\Eloquent\Model; class AdminAuth extends Model { use HasFactory; - - public $fillable = ['name', 'auth_ids', 'remark']; } diff --git a/app/Models/AdminToken.php b/app/Models/AdminToken.php index 090310b..f8951e4 100644 --- a/app/Models/AdminToken.php +++ b/app/Models/AdminToken.php @@ -8,6 +8,4 @@ use Illuminate\Database\Eloquent\Model; class AdminToken extends Model { use HasFactory; - - public $fillable = ['admin_id', 'token', 'type', 'del']; } diff --git a/config/code.php b/config/code.php index 2c223ee..3bcbb08 100644 --- a/config/code.php +++ b/config/code.php @@ -1,30 +1,21 @@ [ - 'c' => '增加成功', - 'd' => '删除成功', - 'u' => '修改成功', - 'r' => '获取成功', - ], - 100001 => '账号不可用', - 100002 => '账号或密码错误', - 100003 => '请登录', - 100004 => '请输入名称', - 100005 => '名称是一个1-20位的字符串', - 100006 => '备注是一个100位以内的字符串', - 100007 => '权限是一个2-1000位的字符串', - 100008 => '内容不存在', - 100009 => '请输入昵称', - 100010 => '昵称是一个1-30位的字符串', - 100011 => '请输入账号', - 100012 => '账号是一个1-50位的字符串', - 100013 => '请输入密码', - 100014 => '密码是一个6-20位的字符串', - 100015 => '账号已存在', - 100016 => '权限不足', - 100017 => '旧密码输入错误', - 100018 => '新旧密码相同', - 100019 => '请上传图片', - 100020 => '上传失败', - 100021 => '?不存在', + 200 => [ + 'c' => '增加成功', + 'd' => '删除成功', + 'u' => '修改成功', + 'r' => '获取成功', + ], + 100000 => '?不存在或不可用', + 100001 => '请登录', + 100002 => '账号不可用或不存在', + 100003 => '权限不足', + 100004 => '账号不存在或密码错误', + 100005 => '请输入昵称', + 100006 => '昵称长度在1-30位字符之间', + 100007 => '请输入密码', + 100008 => '密码长度在6-20位字符之间', + 100009 => '新旧密码相同', + 100010 => '旧密码输入错误', + ]; diff --git a/database/migrations/2022_07_11_104036_create_admins_table.php b/database/migrations/2022_07_11_104036_create_admins_table.php index 8056fd6..4d6a011 100644 --- a/database/migrations/2022_07_11_104036_create_admins_table.php +++ b/database/migrations/2022_07_11_104036_create_admins_table.php @@ -6,30 +6,30 @@ use Illuminate\Support\Facades\Schema; class CreateAdminsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('admins', function (Blueprint $table) { - $table->id(); - $table->string('nickname', 30)->comment('名称'); - $table->integer('admin_auth_id')->comment('权限ID'); - $table->tinyInteger('status')->default(1)->comment('1-正常 2-禁用'); - $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('admins', function (Blueprint $table) { + $table->id(); + $table->string('nickname', 30)->comment('名称'); + $table->integer('admin_auth_id')->comment('权限ID'); + $table->tinyInteger('status')->default(1)->comment('1-正常 2-禁用'); + $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('admins'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('admins'); + } } diff --git a/database/migrations/2022_07_11_104729_create_admin_accounts_table.php b/database/migrations/2022_07_11_104729_create_admin_accounts_table.php index 1e1575a..6112638 100644 --- a/database/migrations/2022_07_11_104729_create_admin_accounts_table.php +++ b/database/migrations/2022_07_11_104729_create_admin_accounts_table.php @@ -6,31 +6,31 @@ use Illuminate\Support\Facades\Schema; class CreateAdminAccountsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('admin_accounts', function (Blueprint $table) { - $table->id(); - $table->bigInteger('admin_id')->index(); - $table->string('account', 50)->index(); - $table->string('secret', 80); - $table->tinyInteger('type')->comment('1-账号密码'); - $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('admin_accounts', function (Blueprint $table) { + $table->id(); + $table->bigInteger('admin_id')->index(); + $table->string('account', 50)->index(); + $table->string('secret', 80); + $table->tinyInteger('type')->comment('1-账号密码'); + $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('admin_accounts'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('admin_accounts'); + } } diff --git a/database/migrations/2022_07_11_104741_create_admin_auths_table.php b/database/migrations/2022_07_11_104741_create_admin_auths_table.php index 8d4d9b0..d1d277f 100644 --- a/database/migrations/2022_07_11_104741_create_admin_auths_table.php +++ b/database/migrations/2022_07_11_104741_create_admin_auths_table.php @@ -6,30 +6,30 @@ use Illuminate\Support\Facades\Schema; class CreateAdminAuthsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('admin_auths', function (Blueprint $table) { - $table->id(); - $table->string('name', 20)->comment('名称'); - $table->string('auth_ids', 1000)->comment('权限IDS JSON'); - $table->string('remark', 100)->comment('备注'); - $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('admin_auths', function (Blueprint $table) { + $table->id(); + $table->string('name', 20)->comment('名称'); + $table->string('auth_ids', 1000)->comment('权限IDS JSON'); + $table->string('remark', 100)->comment('备注'); + $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('admin_auths'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('admin_auths'); + } } diff --git a/database/migrations/2022_07_11_104747_create_auths_table.php b/database/migrations/2022_07_11_104747_create_auths_table.php index 82925e0..388018c 100644 --- a/database/migrations/2022_07_11_104747_create_auths_table.php +++ b/database/migrations/2022_07_11_104747_create_auths_table.php @@ -6,36 +6,36 @@ use Illuminate\Support\Facades\Schema; class CreateAuthsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('auths', function (Blueprint $table) { - $table->id(); - $table->string('name', 20)->comment('项目名称'); - $table->string('title', 20)->comment('显示标题'); - $table->string('icon', 50)->default('')->comment('显示图标'); - $table->integer('pid')->comment('上级ID'); - $table->tinyInteger('type')->comment('1-页面分组 2-页面 3-接口分组 4-接口'); - $table->tinyInteger('check_type')->comment('1-不需要验证 2-需要验证 3-特殊验证规则'); - $table->tinyInteger('show')->default(1)->comment('1-显示 2-不显示'); - $table->tinyInteger('status')->default(1)->comment('1-正常 2-禁用'); - $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); - $table->integer('order')->default(0)->comment('排序'); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('auths', function (Blueprint $table) { + $table->id(); + $table->string('name', 20)->comment('项目名称'); + $table->string('title', 20)->comment('显示标题'); + $table->string('icon', 100)->default('')->comment('显示图标'); + $table->integer('pid')->comment('上级ID'); + $table->tinyInteger('type')->comment('1-分组 2-页面/接口'); + $table->tinyInteger('check_type')->comment('1-不需要验证 2-需要验证 3-特殊验证规则'); + $table->tinyInteger('show')->default(1)->comment('1-显示 2-不显示'); + $table->tinyInteger('status')->default(1)->comment('1-正常 2-禁用'); + $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); + $table->integer('order')->default(0)->comment('排序'); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('auths'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('auths'); + } } diff --git a/database/migrations/2022_07_11_104758_create_admin_tokens_table.php b/database/migrations/2022_07_11_104758_create_admin_tokens_table.php index bda8f77..9efc703 100644 --- a/database/migrations/2022_07_11_104758_create_admin_tokens_table.php +++ b/database/migrations/2022_07_11_104758_create_admin_tokens_table.php @@ -6,30 +6,30 @@ use Illuminate\Support\Facades\Schema; class CreateAdminTokensTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('admin_tokens', function (Blueprint $table) { - $table->id(); - $table->bigInteger('admin_id')->index()->comment('账号ID'); - $table->string('token', 50)->comment('TOKEN')->index(); - $table->tinyInteger('type')->comment('1-后台'); - $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('admin_tokens', function (Blueprint $table) { + $table->id(); + $table->bigInteger('admin_id')->index()->comment('账号ID'); + $table->string('token', 50)->comment('TOKEN')->index(); + $table->tinyInteger('type')->comment('1-后台'); + $table->tinyInteger('del')->default(2)->comment('1-删除 2-正常'); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('admin_tokens'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('admin_tokens'); + } } diff --git a/database/migrations/2022_07_11_105144_push_admin_data.php b/database/migrations/2022_07_11_105144_push_admin_data.php index 30b7c6f..41d3a1e 100644 --- a/database/migrations/2022_07_11_105144_push_admin_data.php +++ b/database/migrations/2022_07_11_105144_push_admin_data.php @@ -6,43 +6,42 @@ use Illuminate\Support\Facades\Schema; class PushAdminData extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - $data = [ - [ - 'account' => 'admin', - 'nickname' => '超级管理员', - 'password' => bcrypt('123465a'), - 'admin_auth_id' => -1, - ], - ]; - foreach ($data as $datum) { - $admin = new App\Models\Admin(); - $admin->nickname = $datum['nickname']; - $admin->admin_auth_id = $datum['admin_auth_id']; - $admin->save(); - - $admin_account = new App\Models\AdminAccount(); - $admin_account->admin_id = $admin->id; - $admin_account->account = $datum['account']; - $admin_account->secret = $datum['password']; - $admin_account->type = 1; - $admin_account->save(); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + $data = [ + [ + 'account' => 'admin', + 'nickname' => '超级管理员', + 'password' => bcrypt('123465a'), + 'admin_auth_id' => -1, + ], + ]; + foreach ($data as $datum) { + $admin = new App\Models\Admin(); + $admin->nickname = $datum['nickname']; + $admin->admin_auth_id = $datum['admin_auth_id']; + $admin->save(); + $admin_account = new App\Models\AdminAccount(); + $admin_account->admin_id = $admin->id; + $admin_account->account = $datum['account']; + $admin_account->secret = $datum['password']; + $admin_account->type = 1; + $admin_account->save(); } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } } diff --git a/database/migrations/2022_07_11_105144_push_auth_data.php b/database/migrations/2022_07_11_105144_push_auth_data.php index 20b4f08..78b3683 100644 --- a/database/migrations/2022_07_11_105144_push_auth_data.php +++ b/database/migrations/2022_07_11_105144_push_auth_data.php @@ -6,100 +6,61 @@ use Illuminate\Support\Facades\Schema; class PushAuthData extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - $data = [[ - 'name' => 'AdminApi', - 'title' => '后台接口', - 'icon' => '', - 'pid' => '0', - 'type' => '3', - 'check_type' => '1', - ], [ - 'name' => 'AdminApiLogin', - 'title' => '后台登录接口', - 'icon' => '', - 'pid' => '1', - 'type' => '4', - 'check_type' => '2', - ], [ - 'name' => 'AdminApiStatus', - 'title' => '后台登录状态', - 'icon' => '', - 'pid' => '1', - 'type' => '4', - 'check_type' => '1', - ], [ - 'name' => 'admin', - 'title' => '人员管理', - 'icon' => 'i-ic-baseline-account-box', - 'pid' => '0', - 'type' => '1', - 'check_type' => '1', - ], [ - 'name' => 'admin-auth', - 'title' => '权限管理', - 'icon' => 'i-ic-baseline-admin-panel-settings', - 'pid' => '4', - 'type' => '2', - 'check_type' => '2', - ], [ - 'name' => 'admin-list', - 'title' => '人员管理', - 'icon' => 'i-ic-baseline-account-box', - 'pid' => '4', - 'type' => '2', - 'check_type' => '2', - ], [ - 'name' => 'admin-info', - 'title' => '个人信息', - 'icon' => 'i-ic-baseline-account-box', - 'pid' => '4', - 'type' => '2', - 'check_type' => '1', - ], [ - 'name' => 'system', - 'title' => '系统设置', - 'icon' => 'i-ic-baseline-settings-applications', - 'pid' => '0', - 'type' => '1', - 'check_type' => '1', - ], [ - 'name' => 'system-assets', - 'title' => '资源设置', - 'icon' => 'i-ic-baseline-color-lens', - 'pid' => '8', - 'type' => '2', - 'check_type' => '2', - ],]; - foreach ($data as $datum) { - $auth = new App\Models\Auth(); - $auth->name = $datum['name']; - $auth->title = $datum['title']; - $auth->icon = $datum['icon']; - $auth->pid = $datum['pid']; - $auth->type = $datum['type']; - $auth->check_type = $datum['check_type']; - $auth->show = 1; - $auth->status = 1; - $auth->del = 2; - $auth->order = 0; - $auth->save(); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + $data = [[ + 'name' => 'admin_basics', + 'title' => '后台基础接口', + 'icon' => '', + 'pid' => '0', + 'type' => '1', + 'check_type' => '1', + 'show' => '2', + ], [ + 'name' => 'admin_basics_login', + 'title' => '后台登录', + 'icon' => '', + 'pid' => '1', + 'type' => '2', + 'check_type' => '1', + 'show' => '2', + ], [ + 'name' => 'admin_basics_status', + 'title' => '后台登录状态', + 'icon' => '', + 'pid' => '1', + 'type' => '2', + 'check_type' => '1', + 'show' => '2', + ]]; + foreach ($data as $datum) { + $auth = new App\Models\Auth(); + $auth->name = $datum['name']; + $auth->title = $datum['title']; + $auth->icon = $datum['icon']; + $auth->pid = $datum['pid']; + $auth->type = $datum['type']; + $auth->check_type = $datum['check_type']; + $auth->show = $datum['show']; + $auth->status = 1; + $auth->del = 2; + $auth->order = 0; + $auth->save(); } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } } diff --git a/database/migrations/2022_07_15_143135_create_configs_table.php b/database/migrations/2022_07_15_143135_create_configs_table.php index 99d1245..2081632 100644 --- a/database/migrations/2022_07_15_143135_create_configs_table.php +++ b/database/migrations/2022_07_15_143135_create_configs_table.php @@ -6,29 +6,31 @@ use Illuminate\Support\Facades\Schema; class CreateConfigsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('configs', function (Blueprint $table) { - $table->id(); - $table->string('name', 20); - $table->string('mark', 40); - $table->string('value', 300); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('configs', function (Blueprint $table) { + $table->id(); + $table->string('label', 50); + $table->string('group', 50); + $table->string('value', 1000); + $table->tinyInteger('type')->comment('1-文字 2-图片 3-文字数组 4-图片数组 5-Key_Value 6-JSON')->index(); + $table->string('remark', 100); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('configs'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('configs'); + } } diff --git a/database/migrations/2022_07_15_143353_push_config_data.php b/database/migrations/2022_07_15_143353_push_config_data.php index 7ef3209..74ebcf3 100644 --- a/database/migrations/2022_07_15_143353_push_config_data.php +++ b/database/migrations/2022_07_15_143353_push_config_data.php @@ -6,46 +6,52 @@ use Illuminate\Support\Facades\Schema; class PushConfigData extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - $data = [[ - 'name' => 'Logo', - 'mark' => 'logo', - 'value' => '/storage/assets/logo.png', - ], [ - 'name' => 'Favicon', - 'mark' => 'favicon', - 'value' => '/storage/assets/favicon.png', - ], [ - 'name' => 'Login欢迎图片', - 'mark' => 'login_image', - 'value' => '/storage/assets/login_image.jpeg', - ],[ - 'name' => '网站标题', - 'mark' => 'title', - 'value' => '鹿和后台', - ]]; - foreach ($data as $datum) { - $config = new App\Models\Config(); - $config->name = $datum['name']; - $config->mark = $datum['mark']; - $config->value = $datum['value']; - $config->save(); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + $data = [[ + 'label' => 'Logo', + 'group' => '基础设置', + 'value' => '/storage/assets/logo.png', + 'type' => '2', + ], [ + 'label' => 'Favicon', + 'group' => '基础设置', + 'value' => '/storage/assets/favicon.png', + 'type' => '2', + ], [ + 'label' => 'Login欢迎图片', + 'group' => '基础设置', + 'value' => '/storage/assets/login_image.jpeg', + 'type' => '2', + ], [ + 'label' => '网站名称', + 'group' => '基础设置', + 'value' => env('APP_NAME'), + 'type' => '1', + ]]; + foreach ($data as $datum) { + $config = new App\Models\Config(); + $config->label = $datum['label']; + $config->group = $datum['group']; + $config->value = $datum['value']; + $config->type = $datum['type']; + $config->remark = ''; + $config->save(); } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } } diff --git a/public/index.php b/public/index.php index 1d69f3a..0562bd9 100644 --- a/public/index.php +++ b/public/index.php @@ -16,8 +16,8 @@ define('LARAVEL_START', microtime(true)); | */ -if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) { - require $maintenance; +if (file_exists($maintenance = __DIR__ . '/../storage/framework/maintenance.php')) { + require $maintenance; } /* @@ -31,7 +31,7 @@ if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) | */ -require __DIR__.'/../vendor/autoload.php'; +require __DIR__ . '/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- @@ -44,12 +44,12 @@ require __DIR__.'/../vendor/autoload.php'; | */ -$app = require_once __DIR__.'/../bootstrap/app.php'; +$app = require_once __DIR__ . '/../bootstrap/app.php'; $kernel = $app->make(Kernel::class); $response = $kernel->handle( - $request = Request::capture() + $request = Request::capture() )->send(); $kernel->terminate($request, $response); diff --git a/routes/web.php b/routes/web.php index e899f67..698aaa6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -14,37 +14,14 @@ use Illuminate\Support\Facades\Route; */ $admin_api = 'Admin'; -Route::post("api/$admin_api/system/config", [\App\Http\Controllers\ConfigController::class, 'config']); -Route::post("api/$admin_api/system/update", [\App\Http\Controllers\ConfigController::class, 'update']); -Route::post("api/$admin_api/system/assets/list", [\App\Http\Controllers\ConfigController::class, 'assets_list']); - -Route::post("api/$admin_api/auth/select", [\App\Http\Controllers\AdminAuthController::class, 'all']); -Route::post("api/$admin_api/auth/all", [\App\Http\Controllers\AuthController::class, 'list']); -Route::post("api/$admin_api/change/nickname", [\App\Http\Controllers\AdminController::class, 'change_nickname']); -Route::post("api/$admin_api/change/password", [\App\Http\Controllers\AdminController::class, 'change_password']); -Route::post("api/$admin_api/auth/check", [\App\Http\Controllers\AdminAuthController::class, 'check']); - -Route::post("api/$admin_api/menu", [\App\Http\Controllers\AdminAuthController::class, 'menu']); -Route::post("api/$admin_api/get/info", [\App\Http\Controllers\AdminController::class, 'admin_info']); -Route::post("api/$admin_api/list", [\App\Http\Controllers\AdminController::class, 'list']); -Route::post("api/$admin_api/delete", [\App\Http\Controllers\AdminController::class, 'delete']); -Route::post("api/$admin_api/update/password", [\App\Http\Controllers\AdminController::class, 'update_password']); -Route::post("api/$admin_api/update/status", [\App\Http\Controllers\AdminController::class, 'update_status']); -Route::post("api/$admin_api/update/auth", [\App\Http\Controllers\AdminController::class, 'update_auth']); -Route::post("api/$admin_api/update/nickname", [\App\Http\Controllers\AdminController::class, 'update_nickname']); -Route::post("api/$admin_api/create", [\App\Http\Controllers\AdminController::class, 'create']); - -Route::post("api/$admin_api/auth/list", [\App\Http\Controllers\AdminAuthController::class, 'list']); -Route::post("api/$admin_api/auth/delete", [\App\Http\Controllers\AdminAuthController::class, 'delete']); -Route::post("api/$admin_api/auth/update", [\App\Http\Controllers\AdminAuthController::class, 'update']); -Route::post("api/$admin_api/auth/create", [\App\Http\Controllers\AdminAuthController::class, 'create']); - -Route::post("api/$admin_api/info", [\App\Http\Controllers\AdminController::class, 'info']); -Route::post("api/$admin_api/status", [\App\Http\Controllers\AdminController::class, 'status']); -Route::post("api/$admin_api/login", [\App\Http\Controllers\AdminController::class, 'admin_login']); - Route::get('/', function () { - return view('welcome'); + return view('welcome'); }); - -Route::post('api/yo', \App\Http\Controllers\YoController::class); +Route::any('api/yo', \App\Http\Controllers\YoController::class); +Route::post("api/$admin_api/Admin/Change/password", [\App\Http\Controllers\AdminController::class, 'change_password']); +Route::post("api/$admin_api/Admin/Change/nickname", [\App\Http\Controllers\AdminController::class, 'change_nickname']); +Route::post("api/$admin_api/Admin/login", [\App\Http\Controllers\AdminController::class, 'login']); +Route::post("api/$admin_api/Admin/status", [\App\Http\Controllers\AdminController::class, 'status']); +Route::post("api/$admin_api/Admin/info", [\App\Http\Controllers\AdminController::class, 'info']); +Route::post("api/$admin_api/Admin/menu", [\App\Http\Controllers\AdminController::class, 'menu']); +Route::post("api/$admin_api/Config/get", [\App\Http\Controllers\ConfigController::class, 'get']); diff --git a/storage/app/public/assets/login_image.jpeg b/storage/app/public/assets/login_image.jpeg deleted file mode 100644 index 876b2b6..0000000 Binary files a/storage/app/public/assets/login_image.jpeg and /dev/null differ diff --git a/storage/app/public/assets/login_image.jpg b/storage/app/public/assets/login_image.jpg new file mode 100644 index 0000000..e227ef5 Binary files /dev/null and b/storage/app/public/assets/login_image.jpg differ diff --git a/vite/.gitignore b/vite/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/vite/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/vite/README.md b/vite/README.md new file mode 100644 index 0000000..05ad1aa --- /dev/null +++ b/vite/README.md @@ -0,0 +1,14 @@ +# Vue 3 + Vite + +```bash +pnpm i +# If you don't have pnpm installed, run: npm install -g pnpm +pnpm dev +pnpm build +``` + +This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` + +
+ + + + +