Merge branch 'dev_aliyun' into develop

dev_daiao
daiao 5 years ago
commit ea82c27c3d

@ -17,7 +17,7 @@ class Oauth::CreateOrFindQqAccountService < ApplicationService
new_user = true
# 新用户
login = User.generate_login('Q')
@user = User.new(login: login, nickname: params.dig('info', 'nickname'), type: 'User', status: User::STATUS_ACTIVE)
@user = User.new(login: login, nickname: params.dig('info', 'nickname').force_encoding('UTF-8'), type: 'User', status: User::STATUS_ACTIVE)
end
ActiveRecord::Base.transaction do

@ -24,7 +24,15 @@ class Oauth::CreateOrFindWechatAccountService < ApplicationService
new_user = true
# 新用户
login = User.generate_login('w')
@user = User.new(login: login, nickname: result['nickname'], type: 'User', status: User::STATUS_ACTIVE)
cd = CharDet.detect(result['nickname'])
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
decode_content =
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
result['nickname'].encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '})
else
result['nickname'].force_encoding('UTF-8')
end
@user = User.new(login: login, nickname: decode_content, type: 'User', status: User::STATUS_ACTIVE)
end
ActiveRecord::Base.transaction do

@ -139935,6 +139935,29 @@ $(document).on('turbolinks:load', function() {
}
})
;
$(document).on('turbolinks:load', function(){
if ($('body.admins-shixun-feedback-messages-index-page').length > 0) {
var baseOptions = {
autoclose: true,
language: 'zh-CN',
format: 'yyyy-mm-dd 00:00:00',
startDate: '2017-04-01'
}
var defineDateRangeSelect = function(element){
var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions);
$(element).datepicker(options);
$(element).find('.start-date').datepicker().on('changeDate', function(e){
$(element).find('.end-date').datepicker('setStartDate', e.date);
})
};
defineDateRangeSelect('.grow-date-input-daterange');
}
})
;
$(document).on('turbolinks:load', function() {
if ($('body.admins-shixun-settings-index-page').length > 0) {
let searchContainer = $(".shixun-settings-list-form");

@ -15,6 +15,7 @@ import actions from '../../redux/actions';
import MultipTags from './components/multiptags';
import { Link } from 'react-router-dom';
import CONST from '../../constants';
import { withRouter } from 'react-router';
const {tagBackground, diffText} = CONST;
const { Search } = Input;
@ -96,66 +97,67 @@ const testMaps = {
}
}
/**
* 表格列
*/
const options = {
title: '操作',
key: 'action',
fixed: 'right',
width: 100,
render: (text, record) => (
<span>
<Button type="primary">
<Link to={`/problems/${record.identifier}/edit`}>编辑</Link>
</Button>
</span>
),
}
const columns = [
{
title: '标题',
dataIndex: 'name',
render: (name, record) => <Link style={{ color: '#459be5' }} to={`/myproblems/${record.identifier}`}>{name}</Link>
},
{
title: '分类',
dataIndex: 'category',
width: '20%',
align: 'center',
render: (category) => <span>{category ? testMaps['category'][+category] : '-'}</span>
},
{
title: '难度',
dataIndex: 'difficult',
align: 'center',
width: '15%',
render: (difficult) => {
if (difficult) {
return <Tag color={tagBackground[+difficult]}>{diffText[+difficult]}</Tag>
} else {
return '-';
class DeveloperHome extends React.PureComponent {
/**
* 表格列
*/
options = {
title: '操作',
key: 'action',
fixed: 'right',
width: 100,
render: (text, record) => (
<span>
<Button type="primary">
<Link to={`/problems/${record.identifier}/edit`}>编辑</Link>
</Button>
</span>
),
}
columns = [
{
title: '标题',
dataIndex: 'name',
render: (name, record) => <Button type="link" onClick={() => this.handleNameClick(record)} className={'oj_item_name'}>{name}</Button>
},
{
title: '分类',
dataIndex: 'category',
width: '20%',
align: 'center',
render: (category) => <span>{category ? testMaps['category'][+category] : '-'}</span>
},
{
title: '难度',
dataIndex: 'difficult',
align: 'center',
width: '15%',
render: (difficult) => {
if (difficult) {
return <Tag color={tagBackground[+difficult]}>{diffText[+difficult]}</Tag>
} else {
return '-';
}
}
}
},
{
title: '热度',
dataIndex: 'hack_user_lastest_codes_count',
sorter: true,
align: 'center',
width: '10%'
},
{
title: '通过率',
dataIndex: 'passed_rate',
sorter: true,
align:'right',
width: '10%',
render: val => <span>{`${val}%`}</span>
},
];
},
{
title: '热度',
dataIndex: 'hack_user_lastest_codes_count',
sorter: true,
align: 'center',
width: '10%'
},
{
title: '通过率',
dataIndex: 'passed_rate',
sorter: true,
align:'right',
width: '10%',
render: val => <span>{`${val}%`}</span>
},
];
class DeveloperHome extends React.PureComponent {
state = {
data: [],
loading: false,
@ -170,7 +172,7 @@ class DeveloperHome extends React.PureComponent {
page: 1, // 当前页数
limit: 10 // 每页显示条件
},
columns: columns,
columns: this.columns,
searchInfo: []
};
@ -179,7 +181,7 @@ class DeveloperHome extends React.PureComponent {
const { isMySource } = this.props;
if (isMySource) {
this.handleFilterSearch({come_from: 'mine'});
let _columns = columns.concat([options]);
let _columns = this.columns.concat([this.options]);
this.setState({
columns: _columns
});
@ -309,13 +311,13 @@ class DeveloperHome extends React.PureComponent {
this.handleFilterSearch({come_from: item.key === 'all' ? '' : item.key});
if (item.key !== 'all') {
let _columns = columns.concat([options]);
let _columns = this.columns.concat([this.options]);
this.setState({
columns: _columns
});
} else {
this.setState({
columns: columns
columns: this.columns
})
}
}
@ -333,10 +335,19 @@ class DeveloperHome extends React.PureComponent {
});
if (info.type === 'come_from' && info.key === 'mine') {
this.setState({
columns: columns
columns: this.columns
});
}
}
// 点击name
handleNameClick = (record) => {
console.log('name has click', record);
// 先调用start接口获取返回的 identifier, 再跳转到开启编辑
this.props.startProgramQuestion(record.identifier, this.props);
}
render () {
// const { testReducer, handleClick } = this.props;
const {
@ -453,10 +464,11 @@ const mapDispatchToProps = (dispatch) => ({
handleClick: () => dispatch(actions.toggleTodo()),
fetchOJList: (params) => dispatch(actions.getOJList(params)),
changePaginationInfo: (obj) => dispatch(actions.changePaginationInfo(obj)),
startProgramQuestion: (id, props) => dispatch(actions.startProgramQuestion(id, props))
});
export default connect(
export default withRouter(connect(
mapStateToProps,
mapDispatchToProps
)(DeveloperHome);
)(DeveloperHome));
// export default DeveloperHome;

@ -72,4 +72,8 @@
color: #fff;
}
}
.oj_item_name{
color: #459be5;
cursor: pointer;
}
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-25 09:46:03
* @LastEditors: tangjiang
* @LastEditTime: 2019-11-29 14:45:27
* @LastEditTime: 2019-11-29 15:04:12
*/
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.bubble.css';

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-23 10:53:19
* @LastEditors: tangjiang
* @LastEditTime: 2019-11-29 08:56:18
* @LastEditTime: 2019-11-29 20:00:34
*/
import './index.scss';
import React, { useEffect } from 'react';
@ -20,9 +20,10 @@ import actions from '../../../redux/actions';
const StudentStudy = (props) => {
useEffect(() => {
const { match: { params }, startProgramQuestion } = props;
const { match: { params }, getUserProgramDetail } = props;
let { id } = params;
startProgramQuestion(id);
// startProgramQuestion(id);
getUserProgramDetail(id);
}, []);
return (
<div className={'student_study_warp'}>
@ -61,7 +62,9 @@ const mapStateToProps = (state) => ({});
const mapDispatchToProps = (dispatch) => ({
// 调用开启编辑
startProgramQuestion: (id) => dispatch(actions.startProgramQuestion(id))
// startProgramQuestion: (id) => dispatch(actions.startProgramQuestion(id))
// 调用编程题详情
getUserProgramDetail: (id) => dispatch(actions.getUserProgramDetail(id))
});
export default connect(

@ -36,6 +36,7 @@ import {
saveUserInputCode,
changeUserCodeTab,
submitUserCode,
getUserProgramDetail
// isUpdateCodeCtx
} from './ojForUser';
@ -79,6 +80,7 @@ export default {
changeSubmitLoadingStatus,
submitUserCode,
changePublishLoadingStatus,
isMyPublish
isMyPublish,
getUserProgramDetail
// isUpdateCodeCtx
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:42:11
* @LastEditors: tangjiang
* @LastEditTime: 2019-11-29 12:03:51
* @LastEditTime: 2019-11-29 20:07:09
*/
import types from "./actionTypes";
import { Base64 } from 'js-base64';
@ -19,7 +19,7 @@ import {
} from "../../services/ojService";
// 进入编程页面时,首先调用开启编程题接口
export const startProgramQuestion = (id) => {
export const startProgramQuestion = (id, props) => {
return (dispatch) => {
fetchStartProgram(id).then(res => {
const { status, data } = res;
@ -29,21 +29,30 @@ export const startProgramQuestion = (id) => {
type: types.SAVE_USER_PROGRAM_ID,
payload: identifier
});
// 调用用户编程详情接口
fetchUserProgramDetail(identifier).then(res => {
const { status, data = {} } = res;
if (status === 200) {
dispatch({
type: types.USER_PROGRAM_DETAIL,
payload: data
});
}
})
// 跳转至开启编程
props.history.push(`/myproblems/${identifier}`);
// Redirect.to
}
})
}
}
// 获取用户编程题详情
export const getUserProgramDetail = (identifier) => {
// 调用用户编程详情接口
return (dispatch) => {
fetchUserProgramDetail(identifier).then(res => {
const { status, data = {} } = res;
if (status === 200) {
dispatch({
type: types.USER_PROGRAM_DETAIL,
payload: data
});
}
});
}
}
/**
* @description 更新代码
* @param {*} identifier

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 16:35:46
* @LastEditors: tangjiang
* @LastEditTime: 2019-11-28 21:21:56
* @LastEditTime: 2019-11-29 18:55:43
*/
import types from './actionTypes';
import CONST from '../../constants';
@ -204,7 +204,7 @@ export const validateOjForm = (props, type) => {
payload: true
});
setTimeout(() => {
props.history.push('/developer');
props.history.push('/problems');
}, 1000);
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors: tangjiang
* @LastEditTime: 2019-11-28 17:34:13
* @LastEditTime: 2019-11-29 20:07:57
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';

Loading…
Cancel
Save