From 1d20f8e5fbe408f761cb712700500107b1eeb7ad Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 30 Aug 2023 09:13:05 +0800 Subject: [PATCH] =?UTF-8?q?404=E7=8A=B6=E6=80=81=E7=A0=81=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/main_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index afe767897..a90e56bfc 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -8,6 +8,17 @@ class MainController < ApplicationController render :json => { status: 0, message: Time.now.to_i } end + def test_404 + status_code = 404 + status = status_code.to_s + fname = %w[404 403 422 500].include?(status) ? status : "unknown" + + respond_to do |format| + format.html { render template: "/shared/#{fname}", handler: [:erb], status: status } + format.all { render body: nil, status: status } + end + end + def index domain_session = params[:_educoder_session] if domain_session @@ -24,6 +35,8 @@ class MainController < ApplicationController # TODO: 这块之后需要整合,者架构重新变化,统一跳转到index后再路由分发 if params[:path] && params[:path]&.include?("h5educoderbuild") && params[:path].split("/").first == "h5educoderbuild" render file: 'public/h5educoderbuild/index.html', :layout => false, :content_type=> 'text/html' + elsif params[:path].to_s.include?("test_404") + test_404 else render file: 'public/react/build/index.html', :layout => false, :content_type=> 'text/html' end