diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 65c05ef2a..5abb3d69a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,8 +27,7 @@ class ApplicationController < ActionController::Base if params[:client_key].present? Rails.logger.info("111111 #{params[:client_key]}") Rails.logger.info("00000 #{params[:timestamp]}") - Rails.logger.info("Time.now - params[:timestamp].to_i: #{Time.now.to_i - params[:timestamp].to_i}") - tip_exception(501, "请求超时") unless (Time.now.to_i - params[:timestamp].to_i).between?(0,5) + tip_exception(501, "请求不合理") unless (Time.now.to_i - params[:timestamp].to_i).between?(0,5) timestamp = params[:timestamp] sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") Rails.logger.info("2222 #{sign}") diff --git a/app/controllers/ecs/homes_controller.rb b/app/controllers/ecs/homes_controller.rb index 7edbd7d78..2202f6882 100644 --- a/app/controllers/ecs/homes_controller.rb +++ b/app/controllers/ecs/homes_controller.rb @@ -3,6 +3,10 @@ class Ecs::HomesController < Ecs::BaseController @school_managers = current_school.users end + def first_stamp + render :json => { status: 0, message: Time.now.to_i } + end + private def current_school diff --git a/config/routes.rb b/config/routes.rb index f9ed12dbe..c569596cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,6 +15,7 @@ Rails.application.routes.draw do scope '/api' do get 'home/index' get 'home/search' + get 'home/first_stamp' get 'search', to: 'searchs#index' @@ -1336,6 +1337,7 @@ Rails.application.routes.draw do root 'main#index' + ## react用 get '*path', to: 'main#index', constraints: ReactConstraint.new end diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 29e7461ec..9350001e4 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -7,8 +7,6 @@ import { broadcastChannelOnmessage ,SetAppModel, isDev, queryString } from 'educ import { notification } from 'antd'; import './index.css'; const opens ="79e33abd4b6588941ab7622aed1e67e8"; -let timestamp = Date.parse(new Date()); -const newopens=md5(opens+timestamp) broadcastChannelOnmessage('refreshPage', () => { window.location.reload() }) @@ -94,6 +92,8 @@ export function initAxiosInterceptors(props) { } } if(`${config[0]}`!=`true`){ + let timestamp = Date.parse(new Date())/1000; + let newopens=md5(opens+timestamp) if (window.location.port === "3007") { config.url = `${proxy}${url}`; if (config.url.indexOf('?') == -1) {