Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_tpm_ui
daiao 5 years ago
commit 5a37b47dcc

@ -25,12 +25,10 @@ class ApplicationController < ActionController::Base
def check_sign
Rails.logger.info("66666 #{params}")
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)
timestamp = params[:timestamp]
sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}")
randomcode = params[:randomcode]
tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}")
Rails.logger.info("2222 #{sign}")
tip_exception(501, "请求不合理") if sign != params[:client_key]
else

@ -1,6 +1,10 @@
class MainController < ApplicationController
skip_before_action :check_sign
def first_stamp
render :json => { status: 0, message: Time.now.to_i }
end
def index
render file: 'public/react/build/index.html', :layout => false
end

@ -15,6 +15,7 @@ Rails.application.routes.draw do
scope '/api' do
get 'home/index'
get 'home/search'
get 'main/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

@ -6,9 +6,8 @@ import { requestProxy } from "./indexEduplus2RequestProxy";
import { broadcastChannelOnmessage ,SetAppModel, isDev, queryString } from 'educoder';
import { notification } from 'antd';
import './index.css';
const $ = window.$;
const opens ="79e33abd4b6588941ab7622aed1e67e8";
let timestamp = Date.parse(new Date());
const newopens=md5(opens+timestamp)
broadcastChannelOnmessage('refreshPage', () => {
window.location.reload()
})
@ -63,6 +62,14 @@ export function initAxiosInterceptors(props) {
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制
const requestMap = {};
window.railsgettimes = function(proxy) {
$.ajax({url:`${proxy}/api/main/first_stamp.json`,async:false,success:function(data,status){
if(data.status===0){
return data.message;
}
}});
}
window.setfalseInRequestMap = function(keyName) {
requestMap[keyName] = false;
}
@ -95,19 +102,22 @@ export function initAxiosInterceptors(props) {
}
if(`${config[0]}`!=`true`){
if (window.location.port === "3007") {
let timestamp=railsgettimes(proxy);
console.log(timestamp)
let newopens=md5(opens+timestamp)
config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?debug=${debugType}&timestamp=${timestamp}&client_key=${newopens}`;
config.url = `${config.url}?debug=${debugType}&randomcode=${timestamp}&client_key=${newopens}`;
} else {
config.url = `${config.url}&debug=${debugType}&timestamp=${timestamp}&client_key=${newopens}`;
config.url = `${config.url}&debug=${debugType}&randomcode=${timestamp}&client_key=${newopens}`;
}
} else {
// 加api前缀
config.url = url;
if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?&timestamp=${timestamp}&client_key=${newopens}`;
config.url = `${config.url}?&randomcode=${timestamp}&client_key=${newopens}`;
} else {
config.url = `${config.url}&timestamp=${timestamp}&client_key=${newopens}`;
config.url = `${config.url}&randomcode=${timestamp}&client_key=${newopens}`;
}
}
}

Loading…
Cancel
Save