update wxcode testcase

dev_tj
tangjiang 5 years ago
commit 336eaf924a

@ -1,5 +1,9 @@
class ShixunListsController < ApplicationController class ShixunListsController < ApplicationController
def index def index
# 去除开头标点符号
@reg = /^[,。?:;‘’!“”—……、]/
# 附件的替换
@atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
@results = ShixunSearchService.call(search_params, current_laboratory) @results = ShixunSearchService.call(search_params, current_laboratory)
end end

@ -4,25 +4,21 @@ json.shixun_list do
json.array! @results.with_highlights(multiple: true) do |obj, highlights| json.array! @results.with_highlights(multiple: true) do |obj, highlights|
json.merge! obj.to_searchable_json json.merge! obj.to_searchable_json
json.challenge_names obj.challenges.pluck(:subject) json.challenge_names obj.challenges.pluck(:subject)
highlights[:description]&.first&.sub!(@reg, '')
# 去除开头标点符号 highlights[:description]&.map{|des| des.gsub(@atta_reg, '')}
reg = /^[,。?:;‘’!“”—……、]/ highlights[:content]&.first&.sub!(@reg, '')
# 附件的替换 highlights[:content]&.map{|des| des.gsub(@atta_reg, '')}
atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '')
highlights[:description]&.map{|des| des.gsub(atta_reg, '')}
highlights[:content]&.first&.sub!(reg, '')
highlights[:content]&.map{|des| des.gsub(atta_reg, '')}
json.title highlights.delete(:name)&.join('...') || obj.searchable_title json.title highlights.delete(:name)&.join('...') || obj.searchable_title
json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.gsub(atta_reg, '') json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.gsub(@atta_reg, '')
json.pic url_to_avatar(obj) json.pic url_to_avatar(obj)
json.content highlights json.content highlights
json.level level_to_s(obj.trainee) json.level level_to_s(obj.trainee)
json.subjects obj.subjects.visible.unhidden.uniq do |subject| #if params[:sort] != "wechat_myshixuns_count"
json.(subject, :id, :name) json.subjects obj.subjects.select{ |s| s.status == 2 && s.hidden == 0} do |subject|
end json.(subject, :id, :name)
end
#end
end end
end end

@ -109,30 +109,46 @@ export function initAxiosInterceptors(props) {
// proxy="https://test-jupyterweb.educoder.net" // proxy="https://test-jupyterweb.educoder.net"
//proxy="http://192.168.2.63:3001" //proxy="http://192.168.2.63:3001"
try { try {
const str =window.location.pathname; var u = navigator.userAgent;
if(str.indexOf("/wxcode") !== -1){ var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
// console.log("开始重写cookis"); if (isIOS) {
const _params = window.location.search; //苹果走
// console.log("1111"); const str =window.location.pathname;
if (_params) { if(str.indexOf("/wxcode") !== -1){
// console.log("22222"); // console.log("开始重写cookis");
let _search = _params.split('?')[1]; const _params = window.location.search;
_search.split('&').forEach(item => { // console.log("1111");
const _arr = item.split('='); if (_params) {
if(_arr[0]==='_educoder_session'){ // console.log("22222");
cookie.save('_educoder_session',_arr[1],{ path: '/' }); let _search = _params.split('?')[1];
cookie.save('_educoder_session',_arr[1], { domain: '.educoder.net', path: '/'}); _search.split('&').forEach(item => {
setCookie(_arr[1]); const _arr = item.split('=');
}else{ if(_arr[0]==='_educoder_session'){
cookie.save('autologin_trustie',_arr[1],{ path: '/' }); cookie.save('_educoder_session',_arr[1],{ path: '/' });
cookie.save('autologin_trustie',_arr[1], { domain: '.educoder.net', path: '/'}); cookie.save('_educoder_session',_arr[1], { domain: '.educoder.net', path: '/'});
} }else{
}); cookie.save('autologin_trustie',_arr[1],{ path: '/' });
cookie.save('autologin_trustie',_arr[1], { domain: '.educoder.net', path: '/'});
}
});
}
} }
}else{
// const str =window.location.pathname;
// if(str.indexOf("/wxcode") !== -1){
// const _params = window.location.search;
// if (_params) {
// let _search = _params.split('?')[1];
// _search.split('&').forEach(item => {
// const _arr = item.split('=');
// cookie.save(_arr[0], _arr[1], {
// path: '/',
// domain: '.educoder.net'
// });
// });
// }
// }
} }
}catch (e) { }catch (e) {
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2020-01-15 09:56:34 * @Date: 2020-01-15 09:56:34
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-18 11:40:26 * @LastEditTime : 2020-01-18 11:51:42
*/ */
import './index.scss'; import './index.scss';
import React, {useState, useEffect, useRef} from 'react'; import React, {useState, useEffect, useRef} from 'react';
@ -12,7 +12,7 @@ import MonacoEditor from '@monaco-editor/react';
import { Input, Icon } from 'antd'; import { Input, Icon } from 'antd';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import actions from '../../redux/actions'; import actions from '../../redux/actions';
// import cookie from 'react-cookies'; import cookie from 'react-cookies';
const { TextArea } = Input; const { TextArea } = Input;
const App = (props) => { const App = (props) => {
@ -44,25 +44,35 @@ const App = (props) => {
const {identifier} = props.match.params; const {identifier} = props.match.params;
// 获取路径参数 // 获取路径参数
const _params = window.location.search;
const setCookier = () => { const setCookier = () => {
// const _params = window.location.search; var u = navigator.userAgent;
// if (_params) { var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
// let _search = _params.split('?')[1]; if (isIOS) {
// _search.split('&').forEach(item => {
// // console.log(item); }else{
// const _arr = item.split('='); const _params = window.location.search;
// cookie.remove(_arr[0], { if (_params) {
// path: '/', let _search = _params.split('?')[1];
// domain: '.educoder.net' _search.split('&').forEach(item => {
// }); // console.log(item);
// cookie.save(_arr[0], _arr[1], { const _arr = item.split('=');
// path: '/', cookie.remove(_arr[0], {
// domain: '.educoder.net' domain: '.educoder.net',
// }); path: '/',
// });
// } });
cookie.save(_arr[0], _arr[1], {
path: '/',
domain: '.educoder.net'
});
});
}
}
} }
setCookier(); setCookier();
const [isActive, setIsActive] = useState(-1); const [isActive, setIsActive] = useState(-1);
const [tip, setTip] = useState(''); const [tip, setTip] = useState('');
@ -180,7 +190,7 @@ const App = (props) => {
const tclasses = _val ? 'result-txt success' : 'result-txt fail'; const tclasses = _val ? 'result-txt success' : 'result-txt fail';
const ulClasses = !!last_compile_output ? 'case-list hasResult' : 'case-list'; const ulClasses = !!last_compile_output ? 'case-list hasResult' : 'case-list';
const resultFlag = !!last_compile_output ? 'wxcode-test-result active' : 'wxcode-test-result'; const resultFlag = !!last_compile_output ? 'wxcode-test-result active' : 'wxcode-test-result';
console.log('==========>>>>>>>> 评测结果样式', last_compile_output, resultFlag); // console.log('==========>>>>>>>> 评测结果样式', last_compile_output, resultFlag);
return ( return (
<div className="wx-code-area"> <div className="wx-code-area">
<div className="wx-code-flex"> <div className="wx-code-flex">

@ -11,19 +11,30 @@ import cookie from 'react-cookies'
// axios.defaults.withCredentials = true; // axios.defaults.withCredentials = true;
const setCookier = () => { const setCookier = () => {
// const _params = window.location.search; var u = navigator.userAgent;
// if (_params) { var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
// let _search = _params.split('?')[1]; if (isIOS) {
// _search.split('&').forEach(item => {
// // console.log(item); }else{
// const _arr = item.split('='); const _params = window.location.search;
// cookie.remove(_arr[0], { if (_params) {
// path: '/', let _search = _params.split('?')[1];
// domain: '.educoder.net' _search.split('&').forEach(item => {
// }); // console.log(item);
// cookie.save(_arr[0], _arr[1], { domain: '.educoder.net', path: '/'}); const _arr = item.split('=');
// }); cookie.remove(_arr[0], {
// } domain: '.educoder.net',
path: '/',
});
cookie.save(_arr[0], _arr[1], {
path: '/',
domain: '.educoder.net'
});
});
}
}
} }
// 获取代码块 // 获取代码块

Loading…
Cancel
Save