parent
							
								
									3770b63a0a
								
							
						
					
					
						commit
						08012fb515
					
				@ -0,0 +1,275 @@
 | 
				
			||||
.wx-code-area{
 | 
				
			||||
  height: 100vh;
 | 
				
			||||
  overflow: hidden;
 | 
				
			||||
  .wx-code-flex{
 | 
				
			||||
    display: flex;
 | 
				
			||||
    position: relative;
 | 
				
			||||
    flex-direction: column;
 | 
				
			||||
    height: 100%;
 | 
				
			||||
  }
 | 
				
			||||
  .wx-code-item{
 | 
				
			||||
    flex: 1;
 | 
				
			||||
  }
 | 
				
			||||
  .wx-code-test{
 | 
				
			||||
    display: flex;
 | 
				
			||||
    justify-content: space-between;
 | 
				
			||||
    align-items: center;
 | 
				
			||||
    height: 120px;
 | 
				
			||||
    background-color: #052645;
 | 
				
			||||
    padding: 0 50px;
 | 
				
			||||
  }
 | 
				
			||||
 | 
				
			||||
  .flex-btn{
 | 
				
			||||
    display: flex;
 | 
				
			||||
    .icon-btn{
 | 
				
			||||
      display: flex;
 | 
				
			||||
      flex-direction: column;
 | 
				
			||||
      color: #2EA4FF;
 | 
				
			||||
      align-items: center;
 | 
				
			||||
      .icon{
 | 
				
			||||
        // font-size: 24px !important;
 | 
				
			||||
        transform: scale(2);
 | 
				
			||||
        line-height: 2;
 | 
				
			||||
      }
 | 
				
			||||
      .icon-reset{
 | 
				
			||||
        transform: scale(2.4);
 | 
				
			||||
      }
 | 
				
			||||
      // .icon:first-child{
 | 
				
			||||
      //   transform: scale((3));
 | 
				
			||||
      // }
 | 
				
			||||
 | 
				
			||||
      &:last-child{
 | 
				
			||||
        margin-left: 50px;
 | 
				
			||||
      }
 | 
				
			||||
      .icon-txt{
 | 
				
			||||
        font-size: 24px;
 | 
				
			||||
      }
 | 
				
			||||
    }
 | 
				
			||||
  }
 | 
				
			||||
  
 | 
				
			||||
  .wx-pt-btn{
 | 
				
			||||
    border: none;
 | 
				
			||||
    outline: none;
 | 
				
			||||
    border-radius: 9999px;
 | 
				
			||||
    padding: 0 40px;
 | 
				
			||||
    line-height: 72px;
 | 
				
			||||
    font-size: 32px;
 | 
				
			||||
    color: #fff;
 | 
				
			||||
    background:#2EA4FF;
 | 
				
			||||
  }
 | 
				
			||||
 | 
				
			||||
  .wx-code-test-case{
 | 
				
			||||
    position: fixed;
 | 
				
			||||
    bottom: 0;
 | 
				
			||||
    left: 0;
 | 
				
			||||
    right: 0;
 | 
				
			||||
    top: 0;
 | 
				
			||||
    transform: translateY(100%);
 | 
				
			||||
    transition: transform, opacity .3s;
 | 
				
			||||
    opacity: 0;
 | 
				
			||||
    // border-top-left-radius: 16px;
 | 
				
			||||
    // border-top-right-radius: 16px;
 | 
				
			||||
    
 | 
				
			||||
    &::before{
 | 
				
			||||
      position: absolute;
 | 
				
			||||
      width: 100%;
 | 
				
			||||
      height: 100%;
 | 
				
			||||
      content: '';
 | 
				
			||||
      background: rgba(0,0,0,.6);
 | 
				
			||||
    }
 | 
				
			||||
    .text-case-list{
 | 
				
			||||
      position: absolute;
 | 
				
			||||
      width: 100%;
 | 
				
			||||
      bottom: 0;
 | 
				
			||||
      top: 150px;
 | 
				
			||||
      background:rgba(1,14,31,1);
 | 
				
			||||
      border-top-left-radius: 16px;
 | 
				
			||||
      border-top-right-radius: 16px;
 | 
				
			||||
      border:2px solid rgba(33,56,87,1);
 | 
				
			||||
      color: #fff;
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
    .list-header{
 | 
				
			||||
      display: flex;
 | 
				
			||||
      justify-content: space-between;
 | 
				
			||||
      align-items: center;
 | 
				
			||||
      height: 88px;
 | 
				
			||||
      padding: 30px;
 | 
				
			||||
      box-sizing: border-box;
 | 
				
			||||
      border-bottom: 2px solid #213857;
 | 
				
			||||
      .header-title{
 | 
				
			||||
        color:#637DA6;
 | 
				
			||||
        font-size: 24px; 
 | 
				
			||||
      }
 | 
				
			||||
      .header-close{
 | 
				
			||||
        font-size: 28px;
 | 
				
			||||
        color: #2EA4FF;
 | 
				
			||||
      }
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
    .wxcode-test-result{
 | 
				
			||||
      display: flex;
 | 
				
			||||
      height: 72px;
 | 
				
			||||
      // background: gold;
 | 
				
			||||
      align-items: center;
 | 
				
			||||
      padding: 0 30px;
 | 
				
			||||
      .success{
 | 
				
			||||
        color: rgba(68,209,95,1);
 | 
				
			||||
      }
 | 
				
			||||
      .fail{
 | 
				
			||||
        color: rgba(196, 79, 78, 1);
 | 
				
			||||
      }
 | 
				
			||||
      .icon{
 | 
				
			||||
        font-size: 36px !important;
 | 
				
			||||
        position: relative;
 | 
				
			||||
        top: -8px;
 | 
				
			||||
        margin-right: 10px;
 | 
				
			||||
      }
 | 
				
			||||
      .result-txt{
 | 
				
			||||
        font-size: 34px;
 | 
				
			||||
      }
 | 
				
			||||
      .result-txt-desc{
 | 
				
			||||
        max-width: 500px;
 | 
				
			||||
        overflow: hidden;
 | 
				
			||||
        text-overflow:ellipsis;
 | 
				
			||||
        white-space: nowrap;
 | 
				
			||||
        margin: 20px;
 | 
				
			||||
      }
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
    .case-list{
 | 
				
			||||
      position: absolute;
 | 
				
			||||
      left: 0;
 | 
				
			||||
      right: 0;
 | 
				
			||||
      bottom: 0;
 | 
				
			||||
      top: 0px;
 | 
				
			||||
      overflow: auto;
 | 
				
			||||
      margin-top: 88px;
 | 
				
			||||
      padding: 0 30px 30px;
 | 
				
			||||
      // margin: 88px 30px 0;
 | 
				
			||||
      .case-item{
 | 
				
			||||
        position: relative;
 | 
				
			||||
        margin-top: 30px;
 | 
				
			||||
        border-radius: 8px;
 | 
				
			||||
        background:rgba(23,39,64,1);
 | 
				
			||||
        padding: 30px;
 | 
				
			||||
      }
 | 
				
			||||
 | 
				
			||||
      &.hasResult{
 | 
				
			||||
        margin-top: 170px;
 | 
				
			||||
 | 
				
			||||
        .case-item:first-child{
 | 
				
			||||
          margin-top: 0;
 | 
				
			||||
        }
 | 
				
			||||
      }
 | 
				
			||||
      
 | 
				
			||||
      .case-item-header{
 | 
				
			||||
        display: flex;
 | 
				
			||||
        justify-content: space-between;
 | 
				
			||||
        align-items: center;
 | 
				
			||||
        .case_item_success,
 | 
				
			||||
        .case_item_fail{
 | 
				
			||||
          font-size: 24px !important;
 | 
				
			||||
          transform: scale(2);
 | 
				
			||||
        }
 | 
				
			||||
        .case_item_success{
 | 
				
			||||
          color: rgba(68,209,95,1);
 | 
				
			||||
        }
 | 
				
			||||
        .case_item_fail{
 | 
				
			||||
          color: rgba(196, 79, 78, 1);
 | 
				
			||||
        }
 | 
				
			||||
        .case-item-tips{
 | 
				
			||||
          color: #C67676;
 | 
				
			||||
          font-size: 22px;
 | 
				
			||||
        }
 | 
				
			||||
      }
 | 
				
			||||
 | 
				
			||||
      .item-header-desc{
 | 
				
			||||
        font-size: 32px;
 | 
				
			||||
        color: #405D8C;
 | 
				
			||||
        line-height: 1.5;
 | 
				
			||||
        // background: gold;
 | 
				
			||||
        .icon{
 | 
				
			||||
          position: relative;
 | 
				
			||||
          top: -4px;
 | 
				
			||||
          font-size: 32px !important;
 | 
				
			||||
          margin-right: 10px;
 | 
				
			||||
        }
 | 
				
			||||
        &.active{
 | 
				
			||||
          color: #fff;
 | 
				
			||||
        }
 | 
				
			||||
      }
 | 
				
			||||
      
 | 
				
			||||
      .case-item-tips{
 | 
				
			||||
        font-size: 28px;
 | 
				
			||||
      }
 | 
				
			||||
      .case-item-desc{
 | 
				
			||||
        display: none;
 | 
				
			||||
        flex-direction: column;
 | 
				
			||||
        font-size: 28px;
 | 
				
			||||
        line-height: 1.5;
 | 
				
			||||
 | 
				
			||||
        &.active{
 | 
				
			||||
          display: flex;
 | 
				
			||||
        }
 | 
				
			||||
      }
 | 
				
			||||
      .desc-title{
 | 
				
			||||
        color: #637DA6;
 | 
				
			||||
        line-height: 2;
 | 
				
			||||
      }
 | 
				
			||||
      .text-area-style{
 | 
				
			||||
        background:#010E1F !important;
 | 
				
			||||
        color: #fff;
 | 
				
			||||
        font-size: 28px;
 | 
				
			||||
        line-height: 1.5;
 | 
				
			||||
        border: none;
 | 
				
			||||
      }
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
    &.active{
 | 
				
			||||
      transform: translateY(0);
 | 
				
			||||
      opacity: 1;
 | 
				
			||||
      // .item-header-desc{
 | 
				
			||||
      //   color: #fff;
 | 
				
			||||
      // }
 | 
				
			||||
    }
 | 
				
			||||
  }
 | 
				
			||||
  .code-evaluate-loading{
 | 
				
			||||
    display: none;
 | 
				
			||||
    position: fixed;
 | 
				
			||||
    left: 0;
 | 
				
			||||
    right: 0;
 | 
				
			||||
    bottom: 0;
 | 
				
			||||
    top: 0;
 | 
				
			||||
    justify-content: center;
 | 
				
			||||
    align-items: center;
 | 
				
			||||
    &::before{
 | 
				
			||||
      position: absolute;
 | 
				
			||||
      width: 100%;
 | 
				
			||||
      height: 100%;
 | 
				
			||||
      content: '';
 | 
				
			||||
      background: rgba(0,0,0,.5);
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
    .loading-flex{
 | 
				
			||||
      display: flex;
 | 
				
			||||
      position: absolute;
 | 
				
			||||
      flex-direction: column;
 | 
				
			||||
      justify-content: center;
 | 
				
			||||
      width: 100%;
 | 
				
			||||
      height: 100%;
 | 
				
			||||
      text-align: center;
 | 
				
			||||
      color: #fff;
 | 
				
			||||
      .loading-icon{
 | 
				
			||||
        font-size: 100px !important;
 | 
				
			||||
      }
 | 
				
			||||
      .loading-txt{
 | 
				
			||||
        font-size: 32px;
 | 
				
			||||
      }
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
    &.active{
 | 
				
			||||
      display: flex;
 | 
				
			||||
    }
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
@ -0,0 +1,196 @@
 | 
				
			||||
/*
 | 
				
			||||
 * @Description: 
 | 
				
			||||
 * @Author: tangjiang
 | 
				
			||||
 * @Github: 
 | 
				
			||||
 * @Date: 2020-01-15 15:41:10
 | 
				
			||||
 * @LastEditors  : tangjiang
 | 
				
			||||
 * @LastEditTime : 2020-01-16 15:25:25
 | 
				
			||||
 */
 | 
				
			||||
import types from './actionTypes.js';
 | 
				
			||||
import {
 | 
				
			||||
  fetchWxCode,
 | 
				
			||||
  fetchWxCodeTextCase,
 | 
				
			||||
  fetchRestoreWxCode,
 | 
				
			||||
  fetchUpdateWxCode,
 | 
				
			||||
  fetchWxCodeGameBuild,
 | 
				
			||||
  fetchWxCodeGameStatus
 | 
				
			||||
} from '../../services/wxcodeService.js';
 | 
				
			||||
 | 
				
			||||
// 加载代码块
 | 
				
			||||
export const getWXCode = (identifier) => {
 | 
				
			||||
  return (dispatch) => {
 | 
				
			||||
    fetchWxCode(identifier).then(res => {
 | 
				
			||||
      if (res.status === 200) {
 | 
				
			||||
        dispatch({
 | 
				
			||||
          type: types.GET_WXCODE_BY_IDENTIFIER,
 | 
				
			||||
          payload: res.data.content
 | 
				
			||||
        });
 | 
				
			||||
      }
 | 
				
			||||
    });
 | 
				
			||||
  }
 | 
				
			||||
};
 | 
				
			||||
 | 
				
			||||
// 加载测试集
 | 
				
			||||
export const getWXCodeTestCase = (identifier, params) => {
 | 
				
			||||
  return (dispatch) => {
 | 
				
			||||
    fetchWxCodeTextCase(identifier, params).then(res => {
 | 
				
			||||
      // console.log('加载测试集: ====>>>>>>', res);
 | 
				
			||||
      try{
 | 
				
			||||
        const {data = {}} = res;
 | 
				
			||||
        console.log(data.test_sets);
 | 
				
			||||
        dispatch({
 | 
				
			||||
          type: types.GET_WXCODE_TEST_CASE,
 | 
				
			||||
          payload: {
 | 
				
			||||
            test_sets: data.test_sets || [],
 | 
				
			||||
            game_id: data.game && data.game.id,
 | 
				
			||||
            myIdentifier: data.myshixun.identifier,
 | 
				
			||||
            exec_time: data.challenge.exec_time,
 | 
				
			||||
            path: data.challenge.path,
 | 
				
			||||
            last_compile_output: data.last_compile_output,
 | 
				
			||||
            test_sets_count: data.test_sets_count,
 | 
				
			||||
            sets_error_count: data.sets_error_count
 | 
				
			||||
          }
 | 
				
			||||
        });
 | 
				
			||||
      } catch(err) {
 | 
				
			||||
        console.log(err);
 | 
				
			||||
      };
 | 
				
			||||
    });
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
// 初始化
 | 
				
			||||
export const restoreWXCode = (identifier, params) => {
 | 
				
			||||
  return (dispatch) => {
 | 
				
			||||
    fetchRestoreWxCode(identifier, params).then(res => {
 | 
				
			||||
      console.log('点击了初始化代码: ', res);
 | 
				
			||||
      const {data} = res;
 | 
				
			||||
      dispatch({
 | 
				
			||||
        type: types.GET_WXCODE_BY_IDENTIFIER,
 | 
				
			||||
        payload: data.content || ''
 | 
				
			||||
      });
 | 
				
			||||
    });
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
// 更新编辑器代码
 | 
				
			||||
export const updateWXCodeForEditor = (code) => {
 | 
				
			||||
  return {
 | 
				
			||||
    type: types.UPDATE_WXCODE_FOR_EDITOR,
 | 
				
			||||
    payload: code
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
export const updateWxCode = (path, identifier, userCode, game_id, evaluate = 0,) => {
 | 
				
			||||
  return fetchUpdateWxCode(identifier, {
 | 
				
			||||
    path,
 | 
				
			||||
    evaluate,
 | 
				
			||||
    content: userCode,
 | 
				
			||||
    game_id
 | 
				
			||||
  });
 | 
				
			||||
}
 | 
				
			||||
// 定时更新代码内容
 | 
				
			||||
export const updateWXCodeForInterval = (identifier, path) => {
 | 
				
			||||
  return (dispatch, getState) => {
 | 
				
			||||
    const {wxCode, userCode, game_id, myIdentifier} = getState().wxcodeReducer;
 | 
				
			||||
    if (wxCode !== userCode) {
 | 
				
			||||
      updateWxCode(path, myIdentifier, userCode, game_id, 0);
 | 
				
			||||
    }
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
// 评测
 | 
				
			||||
export const evaluateWxCode = (identifier, path) => {
 | 
				
			||||
  return (dispatch, getState) => {
 | 
				
			||||
    const {
 | 
				
			||||
      userCode,
 | 
				
			||||
      game_id,
 | 
				
			||||
      myIdentifier,
 | 
				
			||||
      exec_time,
 | 
				
			||||
      path,
 | 
				
			||||
      last_compile_output,
 | 
				
			||||
      test_sets_count,
 | 
				
			||||
      sets_error_count
 | 
				
			||||
    } = getState().wxcodeReducer;
 | 
				
			||||
    updateWxCode(path, myIdentifier, userCode, game_id, 1).then(res => {
 | 
				
			||||
      // build 
 | 
				
			||||
      // const {} = res;
 | 
				
			||||
      console.log(res);
 | 
				
			||||
      const params = {
 | 
				
			||||
        content_modified: 1,
 | 
				
			||||
        sec_key: res.data.sec_key
 | 
				
			||||
      }
 | 
				
			||||
      console.log(params);
 | 
				
			||||
      fetchWxCodeGameBuild(identifier, params).then(res => {
 | 
				
			||||
        if (res.data.status === 1) {
 | 
				
			||||
          // 定时调用 game_status fetchWxCodeGameStatus
 | 
				
			||||
          let count = 1;
 | 
				
			||||
          const intervalTime = 500;
 | 
				
			||||
          function wxCodeGameStatus (intervalTime, finalTime, count, timer) {
 | 
				
			||||
            const excuteTime = (count++) * intervalTime; // 当前执行时间
 | 
				
			||||
            console.log(finalTime, count, excuteTime);
 | 
				
			||||
            fetchWxCodeGameStatus(identifier).then(r => {
 | 
				
			||||
              const { status, test_sets = [] } = r.data;
 | 
				
			||||
              if (+status > -1 || ((excuteTime / 1000) > (finalTime + 1))) {
 | 
				
			||||
                clearInterval(timer);
 | 
				
			||||
                timer = null;
 | 
				
			||||
                dispatch({
 | 
				
			||||
                  type: types.SHOW_WX_CODE_LOADING,
 | 
				
			||||
                  payload: false
 | 
				
			||||
                });
 | 
				
			||||
                setTimeout(() => {
 | 
				
			||||
                  // 显示测试集弹框
 | 
				
			||||
                  dispatch({
 | 
				
			||||
                    type: types.IS_SHOW_WXCODE_TEST_CASES,
 | 
				
			||||
                    payload: true
 | 
				
			||||
                  });
 | 
				
			||||
                  dispatch({
 | 
				
			||||
                    type: types.GET_WXCODE_TEST_CASE,
 | 
				
			||||
                    payload: {
 | 
				
			||||
                      test_sets,
 | 
				
			||||
                      game_id,
 | 
				
			||||
                      myIdentifier,
 | 
				
			||||
                      exec_time,
 | 
				
			||||
                      path,
 | 
				
			||||
                      last_compile_output,
 | 
				
			||||
                      test_sets_count,
 | 
				
			||||
                      sets_error_count
 | 
				
			||||
                    }
 | 
				
			||||
                  });
 | 
				
			||||
                }, 50);
 | 
				
			||||
              }
 | 
				
			||||
            }).catch(err => {
 | 
				
			||||
              dispatch({
 | 
				
			||||
                type: types.SHOW_WX_CODE_LOADING,
 | 
				
			||||
                payload: false
 | 
				
			||||
              });
 | 
				
			||||
            });
 | 
				
			||||
          }
 | 
				
			||||
          let timer = setInterval(() => {
 | 
				
			||||
            wxCodeGameStatus(intervalTime, exec_time, count++, timer);
 | 
				
			||||
          }, intervalTime);
 | 
				
			||||
        }
 | 
				
			||||
      })
 | 
				
			||||
    }).catch(err => {
 | 
				
			||||
      dispatch({
 | 
				
			||||
        type: types.SHOW_WX_CODE_LOADING,
 | 
				
			||||
        payload: false
 | 
				
			||||
      });
 | 
				
			||||
    });
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
// 显示测试集
 | 
				
			||||
export const showWXCodeTextCase = (flag) => {
 | 
				
			||||
  return {
 | 
				
			||||
    type: types.IS_SHOW_WXCODE_TEST_CASES,
 | 
				
			||||
    payload: flag
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
// 显示测评中的状态
 | 
				
			||||
export const changeWXCodeEvaluateLoading = (flag) => {
 | 
				
			||||
  return {
 | 
				
			||||
    type: types.SHOW_WX_CODE_LOADING,
 | 
				
			||||
    payload: flag
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
@ -0,0 +1,68 @@
 | 
				
			||||
/*
 | 
				
			||||
 * @Description: 
 | 
				
			||||
 * @Author: tangjiang
 | 
				
			||||
 * @Github: 
 | 
				
			||||
 * @Date: 2020-01-15 15:37:44
 | 
				
			||||
 * @LastEditors  : tangjiang
 | 
				
			||||
 * @LastEditTime : 2020-01-16 15:22:37
 | 
				
			||||
 */
 | 
				
			||||
import types from "../actions/actionTypes";
 | 
				
			||||
const initialState = {
 | 
				
			||||
  wxCode: '',
 | 
				
			||||
  userCode: '',
 | 
				
			||||
  testCase: [],
 | 
				
			||||
  game_id: '',
 | 
				
			||||
  myIdentifier: '',
 | 
				
			||||
  exec_time: 0,
 | 
				
			||||
  last_compile_output: '',
 | 
				
			||||
  test_sets_count: 0,
 | 
				
			||||
  sets_error_count: 0,
 | 
				
			||||
  path: '',
 | 
				
			||||
  isShow: false,
 | 
				
			||||
  showLoading: false
 | 
				
			||||
};
 | 
				
			||||
 | 
				
			||||
const wxcodeReducer = (state = initialState, action) => {
 | 
				
			||||
  const { payload, type } = action;
 | 
				
			||||
  switch (type) {
 | 
				
			||||
    case types.GET_WXCODE_BY_IDENTIFIER:
 | 
				
			||||
      return {
 | 
				
			||||
        ...state,
 | 
				
			||||
        wxCode: payload,
 | 
				
			||||
        userCode: payload
 | 
				
			||||
      }
 | 
				
			||||
    case types.GET_WXCODE_TEST_CASE:
 | 
				
			||||
      return {
 | 
				
			||||
        ...state,
 | 
				
			||||
        testCase: payload.test_sets,
 | 
				
			||||
        game_id: payload.game_id,
 | 
				
			||||
        myIdentifier: payload.myIdentifier,
 | 
				
			||||
        exec_time: payload.exec_time,
 | 
				
			||||
        path: payload.path,
 | 
				
			||||
        last_compile_output: payload.last_compile_output,
 | 
				
			||||
        test_sets_count: payload.test_sets_count,
 | 
				
			||||
        sets_error_count: payload.sets_error_count
 | 
				
			||||
      }
 | 
				
			||||
    case types.UPDATE_WXCODE_FOR_EDITOR:
 | 
				
			||||
      return {
 | 
				
			||||
        ...state,
 | 
				
			||||
        userCode: payload
 | 
				
			||||
      }
 | 
				
			||||
    case types.IS_SHOW_WXCODE_TEST_CASES:
 | 
				
			||||
      return {
 | 
				
			||||
        ...state,
 | 
				
			||||
        isShow: payload
 | 
				
			||||
      }
 | 
				
			||||
    case types.SHOW_WX_CODE_LOADING:
 | 
				
			||||
      return {
 | 
				
			||||
        ...state,
 | 
				
			||||
        showLoading: payload
 | 
				
			||||
      }
 | 
				
			||||
    default:
 | 
				
			||||
      return {
 | 
				
			||||
        ...state
 | 
				
			||||
      }
 | 
				
			||||
  }
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
export default wxcodeReducer;
 | 
				
			||||
@ -0,0 +1,44 @@
 | 
				
			||||
/*
 | 
				
			||||
 * @Description: 
 | 
				
			||||
 * @Author: tangjiang
 | 
				
			||||
 * @Github: 
 | 
				
			||||
 * @Date: 2020-01-15 15:44:36
 | 
				
			||||
 * @LastEditors  : tangjiang
 | 
				
			||||
 * @LastEditTime : 2020-01-16 11:20:24
 | 
				
			||||
 */
 | 
				
			||||
import axios from 'axios';
 | 
				
			||||
 | 
				
			||||
// 获取代码块
 | 
				
			||||
export async function fetchWxCode (identifier, params) {
 | 
				
			||||
  const url = `/tasks/${identifier}/rep_content.json`;
 | 
				
			||||
  return axios.get(url, {params});
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
// 获取测试值
 | 
				
			||||
export async function fetchWxCodeTextCase (identifier) {
 | 
				
			||||
  const url = `/tasks/${identifier}.json`;
 | 
				
			||||
  return axios.get(url);
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
// 更新代码块内容
 | 
				
			||||
export async function fetchUpdateWxCode (identifier, params) {
 | 
				
			||||
  // /myshixuns/8etu3pilsa/update_file.json
 | 
				
			||||
  const url = `/myshixuns/${identifier}/update_file.json`;
 | 
				
			||||
  return axios.post(url, params);
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
// 恢复初始化
 | 
				
			||||
export async function fetchRestoreWxCode (identifier, params) {
 | 
				
			||||
  const url = `/tasks/${identifier}/reset_original_code.json`;
 | 
				
			||||
  return axios.get(url, {params});
 | 
				
			||||
}
 | 
				
			||||
// 评测
 | 
				
			||||
export async function fetchWxCodeGameBuild (identifier, params) {
 | 
				
			||||
  const url = `/tasks/${identifier}/game_build.json`;
 | 
				
			||||
  return axios.get(url, {params});
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
export async function fetchWxCodeGameStatus (identifier) {
 | 
				
			||||
  const url = `/tasks/${identifier}/game_status.json`;
 | 
				
			||||
  return axios.get(url);
 | 
				
			||||
}
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue