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

dev_tj
cxt 5 years ago
commit f09f487359

@ -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-17 11:48:21 * @LastEditTime : 2020-01-17 15:34:40
*/ */
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) => {
@ -39,25 +39,35 @@ const App = (props) => {
const {identifier} = props.match.params; const {identifier} = props.match.params;
// 获取路径参数 // 获取路径参数
const setCookier = () => {
const _params = window.location.search; const _params = window.location.search;
if (_params) { if (_params) {
let _search = _params.split('?')[1]; let _search = _params.split('?')[1];
_search.split('&').forEach(item => { _search.split('&').forEach(item => {
console.log(item); // console.log(item);
const _arr = item.split('='); const _arr = item.split('=');
cookie.remove(_arr[0], {
path: '/',
domain: '.educoder.net'
});
cookie.save(_arr[0], _arr[1], { cookie.save(_arr[0], _arr[1], {
path: '/', path: '/',
domain: '.educoder.net' domain: '.educoder.net'
}); });
}); });
} }
}
setCookier();
const [isActive, setIsActive] = useState(-1); const [isActive, setIsActive] = useState(-1);
// const [isVisible, setIsVisible] = useState(false); // const [isVisible, setIsVisible] = useState(false);
const editorRef = useRef(null); const editorRef = useRef(null);
let timer = null; let timer = null;
useEffect(() => { useEffect(() => {
setTimeout(() => {
setCookier();
// 加载代码块内容 // 加载代码块内容
getWXCode(identifier); getWXCode(identifier, );
// 加载测试集 // 加载测试集
const params = { const params = {
path, path,
@ -65,6 +75,7 @@ const App = (props) => {
retry: 1 retry: 1
}; };
getWXCodeTestCase(identifier, params); getWXCodeTestCase(identifier, params);
}, 0);
}, []); }, []);
// 关闭 // 关闭
const handleCloseTestCase = () => { const handleCloseTestCase = () => {

@ -4,12 +4,34 @@
* @Github: * @Github:
* @Date: 2020-01-15 15:44:36 * @Date: 2020-01-15 15:44:36
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-17 10:06:45 * @LastEditTime : 2020-01-17 16:40:03
*/ */
import axios from 'axios'; import axios from 'axios';
import cookie from 'react-cookies'
// axios.defaults.withCredentials = true;
const setCookier = () => {
const _params = window.location.search;
if (_params) {
let _search = _params.split('?')[1];
_search.split('&').forEach(item => {
// console.log(item);
const _arr = item.split('=');
cookie.remove(_arr[0], {
path: '/',
domain: '.educoder.net'
});
cookie.save(_arr[0], _arr[1], {
path: '/',
domain: '.educoder.net'
});
});
}
}
// 获取代码块 // 获取代码块
export async function fetchWxCode (identifier, params) { export async function fetchWxCode (identifier, params) {
setCookier();
const url = `/tasks/${identifier}/rep_content.json`; const url = `/tasks/${identifier}/rep_content.json`;
params = Object.assign({}, params, {withCredentials: true}); params = Object.assign({}, params, {withCredentials: true});
return axios.get(url, {params}); return axios.get(url, {params});
@ -17,6 +39,7 @@ export async function fetchWxCode (identifier, params) {
// 获取测试值 // 获取测试值
export async function fetchWxCodeTextCase (identifier) { export async function fetchWxCodeTextCase (identifier) {
setCookier();
const url = `/tasks/${identifier}.json`; const url = `/tasks/${identifier}.json`;
const params = Object.assign({}, {withCredentials: true}); const params = Object.assign({}, {withCredentials: true});
return axios.get(url, {params}); return axios.get(url, {params});
@ -24,6 +47,7 @@ export async function fetchWxCodeTextCase (identifier) {
// 更新代码块内容 // 更新代码块内容
export async function fetchUpdateWxCode (identifier, params) { export async function fetchUpdateWxCode (identifier, params) {
setCookier();
// /myshixuns/8etu3pilsa/update_file.json // /myshixuns/8etu3pilsa/update_file.json
const url = `/myshixuns/${identifier}/update_file.json`; const url = `/myshixuns/${identifier}/update_file.json`;
params = Object.assign({}, params, {withCredentials: true}); params = Object.assign({}, params, {withCredentials: true});
@ -32,18 +56,21 @@ export async function fetchUpdateWxCode (identifier, params) {
// 恢复初始化 // 恢复初始化
export async function fetchRestoreWxCode (identifier, params) { export async function fetchRestoreWxCode (identifier, params) {
setCookier();
const url = `/tasks/${identifier}/reset_original_code.json`; const url = `/tasks/${identifier}/reset_original_code.json`;
params = Object.assign({}, params, {withCredentials: true}); params = Object.assign({}, params, {withCredentials: true});
return axios.get(url, {params}); return axios.get(url, {params});
} }
// 评测 // 评测
export async function fetchWxCodeGameBuild (identifier, params) { export async function fetchWxCodeGameBuild (identifier, params) {
setCookier();
const url = `/tasks/${identifier}/game_build.json`; const url = `/tasks/${identifier}/game_build.json`;
params = Object.assign({}, params, {withCredentials: true}); params = Object.assign({}, params, {withCredentials: true});
return axios.get(url, {params}); return axios.get(url, {params});
} }
export async function fetchWxCodeGameStatus (identifier) { export async function fetchWxCodeGameStatus (identifier) {
setCookier();
const url = `/tasks/${identifier}/game_status.json`; const url = `/tasks/${identifier}/game_status.json`;
const params = Object.assign({}, {withCredentials: true}); const params = Object.assign({}, {withCredentials: true});
return axios.get(url, {params}); return axios.get(url, {params});

Loading…
Cancel
Save