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

dev_aliyun_beta
hjm 5 years ago
commit b69a9427a4

@ -83,4 +83,4 @@ $(document).on("turbolinks:before-cache", function () {
// });
$(function () {
});
});

@ -0,0 +1,8 @@
class Wechats::JsSdkSignaturesController < ApplicationController
def create
signature = Util::Wechat.js_sdk_signature(params[:url], params[:noncestr], params[:timestamp])
render_ok(signature: signature)
rescue Util::Wechat::Error => ex
render_error(ex.message)
end
end

@ -0,0 +1,74 @@
module Util::Wechat
BASE_SITE = 'https://api.weixin.qq.com'.freeze
Error = Class.new(StandardError)
class << self
attr_accessor :appid, :secret
def js_sdk_signature(url, noncestr, timestamp)
str = { jsapi_ticket: jsapi_ticket, noncestr: noncestr, timestamp: timestamp, url: url }.to_query
Digest::SHA1.hexdigest(str)
end
def access_token
# 7200s 有效时间
Rails.cache.fetch(access_token_cache_key, expires_in: 100.minutes) do
result = request(:get, '/cgi-bin/token', appid: appid, secret: secret, grant_type: 'client_credential')
result['access_token']
end
end
def refresh_access_token
Rails.cache.delete(access_token_cache_key)
access_token
end
def jsapi_ticket
# 7200s 有效时间
Rails.cache.fetch(jsapi_ticket_cache_key, expires_in: 100.minutes) do
result = request(:get, '/cgi-bin/ticket/getticket', access_token: access_token, type: 'jsapi')
result['ticket']
end
end
def refresh_jsapi_ticket
Rails.cache.delete(jsapi_ticket_cache_key)
jsapi_ticket
end
def access_token_cache_key
"#{base_cache_key}/access_token"
end
def jsapi_ticket_cache_key
"#{base_cache_key}/jsapi_ticket"
end
def base_cache_key
"wechat/#{appid}"
end
private
def request(method, url, **params)
Rails.logger.error("[wechat] request: #{method} #{url} #{params.inspect}")
client = Faraday.new(url: BASE_SITE)
response = client.public_send(method, url, params)
result = JSON.parse(response.body)
Rails.logger.error("[wechat] response:#{response.status} #{result.inspect}")
if response.status != 200
raise Error, result.inspect
end
if result['errcode'].present? && result['errcode'].to_i.nonzero?
raise Error, result.inspect
end
result
end
end
end

@ -6,6 +6,9 @@ defaults: &defaults
cate_id: '-1'
callback_url: 'http://47.96.87.25:48080/api/callbacks/aliyun_vod.json'
signature_key: 'test12345678'
wechat:
appid: 'test'
secret: 'test'
development:
<<: *defaults

@ -4,7 +4,7 @@ aliyun_vod_config = {}
begin
config = Rails.application.config_for(:configuration)
aliyun_vod_config = config['aliyun_vod']
raise 'oauth wechat config missing' if aliyun_vod_config.blank?
raise 'aliyun vod config missing' if aliyun_vod_config.blank?
rescue => ex
raise ex if Rails.env.production?

@ -0,0 +1,16 @@
wechat_config = {}
begin
config = Rails.application.config_for(:configuration)
wechat_config = config['wechat']
raise 'wechat config missing' if wechat_config.blank?
rescue => ex
raise ex if Rails.env.production?
puts %Q{\033[33m [warning] wechat config or configuration.yml missing,
please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m}
wechat_config = {}
end
Util::Wechat.appid = wechat_config['appid']
Util::Wechat.secret = wechat_config['secret']

@ -880,6 +880,10 @@ Rails.application.routes.draw do
end
end
namespace :wechats do
resource :js_sdk_signature, only: [:create]
end
#git 认证回调
match 'gitauth/*url', to: 'gits#auth', via: :all

@ -186,7 +186,7 @@ class BoardsNew extends Component{
});
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
// title: '确定要删除这个附件吗?',
title: '是否确认删除?',

@ -218,7 +218,8 @@ class CommonWorkAppraise extends Component{
</a>
<span className="color656565 mt2 color-grey-6 font-12 mr8">{item.filesize}</span>
{/*{item.delete===true?<i className="font-14 iconfont icon-guanbi " id={item.id} aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.id)}></i>:""}*/}
{item.delete===true?<i className="font-14 iconfont icon-guanbi " style={{display: 'none'}} id={item.id} aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.id)}></i>:""}
{item.delete===true?<i className="font-14 iconfont icon-guanbi " id={item.id} aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.id)}></i>:""}
{/* style={{display: 'none'}} */}
</div>
)
})}

@ -320,11 +320,19 @@ class CommonWorkPost extends Component{
// ModalSave: ()=>this.deleteAttachment(file),
// ModalCancel:this.cancelAttachment
// })
if(file.response!=undefined){
this.deleteAttachment(file)
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file)
},
onCancel() {
console.log('Cancel');
},
});
return false;
}
}
cancelAttachment=()=>{

@ -3,7 +3,8 @@ import { Input, InputNumber, Form, Button, Checkbox, Upload, Icon, message, Moda
import axios from 'axios'
import '../css/busyWork.css'
import '../css/Courses.css'
import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder'
import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll
, getUploadActionUrl } from 'educoder'
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import CBreadcrumb from '../common/CBreadcrumb'
@ -243,7 +244,7 @@ class NewWork extends Component{
}
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '是否确认删除?',
@ -331,7 +332,7 @@ class NewWork extends Component{
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
action: `${getUploadActionUrl()}`,
onChange: this.handleContentUploadChange,
onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'),
beforeUpload: (file) => {

@ -73,7 +73,7 @@ class AccessoryModal extends Component{
// ModalCancel:this.cancelAttachment
// })
// return false;
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.deleteAttachment(file);
}
}

@ -64,7 +64,7 @@ class AccessoryModal2 extends Component{
// ModalCancel:this.cancelAttachment
// })
// return false;
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.deleteAttachment(file);
}

@ -296,7 +296,7 @@ class Selectsetting extends Component{
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})

@ -132,7 +132,7 @@ class Sendresource extends Component{
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})

@ -157,7 +157,7 @@ class GraduationTasksSubmitedit extends Component{
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
let {attachments,fileList}=this.state;
const url = `/attachments/${file}.json`
axios.delete(url, {

@ -146,7 +146,7 @@ class GraduationTasksSubmitnew extends Component{
// },
// });
// return false;
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.setState({
Modalstype:true,
Modalstopval:'确定要删除这个附件吗?',

@ -88,7 +88,7 @@ class GraduationTasksappraiseMainEditor extends Component{
this.setState({ fileList });
}
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '确定要删除这个附件吗?',
okText: '确定',

@ -150,7 +150,7 @@ class GraduationTasksedit extends Component{
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
// debugger
this.cancelAttachment();
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`

@ -173,7 +173,7 @@ class GraduationTasksnew extends Component {
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
// const url = `/attachments/${file}.json`
axios.delete(url, {})

@ -216,7 +216,7 @@ class GraduateTopicNew extends Component{
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',

@ -163,7 +163,7 @@ class GraduateTopicPostWorksNew extends Component{
this.setState({ fileList });
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',

@ -73,7 +73,7 @@ class CreateGroupByImportModal extends Component{
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '是否确认删除?',

@ -2499,6 +2499,8 @@ class Listofworksstudentone extends Component {
// console.log(data);
// console.log(datas);
// console.log(this.props.isAdmin());
console.log("学生老师列表");
return (
this.props.isAdmin() === true ?
(

@ -561,7 +561,7 @@ class MemoNew extends Component {
}
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
// title: '确定要删除这个附件吗?',
content: '是否确认删除?',

@ -47,7 +47,7 @@ class CaseNew extends Component{
// 上传附件-删除确认框
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '是否确认删除?',
onOk: () => {

@ -1384,7 +1384,7 @@ export default class TPMsettings extends Component {
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',

@ -772,7 +772,7 @@ class Newshixuns extends Component {
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',

@ -356,6 +356,7 @@ class InfosTopics extends Component{
margin-right: 20px;
display: block;
margin-bottom: 0px;
color: #666;
}
.mr38{
@ -385,7 +386,7 @@ class InfosTopics extends Component{
<div className="clearfix topicsbox">
{types==="publicly"?<div className={"topcschild"}>
<a className={types==="personal"?"topicstopfont fr topcsactive":"topicstopfont fr"}
href={`/users/${username}/topics/personal`}>个人题库</a>
href={`/users/${username}/topics/personal`}>我的题库</a>
<a className={types==="publicly"?"topicstopfont fl topcsactive":"topicstopfont fl"}
>公共题库</a>
</div>:<div className={"topcschild"}>
@ -408,9 +409,9 @@ class InfosTopics extends Component{
</div>
<div className={"shaiContent"}>
<div className={data===undefined?"":data.course_list===undefined||data.course_list.length===0?"shaiContent mb45":"shaiContent"}>
<li className={course_list_id===undefined?"shaiItem shixun_repertoire active fl":"shaiItem shixun_repertoire fl"} onClick={()=>this.searchCourselistid(undefined)}>全部</li>
<div className="fl pr topicsItem pagetype mb20">
<div className="fl pr topicsItem mb20">
{data===undefined?"":data.course_list===undefined||data.course_list.length===0?"":data.course_list.map((item,key)=>{
return(
<li key={key} className={course_list_id===item.id?"shaiItem shixun_repertoire active":"shaiItem shixun_repertoire"} onClick={()=>this.searchCourselistid(item.id)}>{item.name}</li>
@ -496,7 +497,7 @@ class InfosTopics extends Component{
<span className="mr50 color-grey9">{item.solve_count} 次答题</span>
<span className="mr50 color-grey9">{moment(item.updated_at).fromNow()}</span>
</span>
<span className="topicsbtn">{item.course_list_name}</span>
{item.course_list_name===null?"":<span className="topicsbtn">{item.course_list_name}</span>}
</p>
<div className="homepagePostSetting homepagePostSettingname topscisright">

@ -306,6 +306,7 @@
font-weight: 400;
cursor: pointer;
line-height: 55px;
color: #666;
}
.alltopisc{
@ -400,4 +401,8 @@
max-width: 1050px;
max-height: 115px;
overflow-y: auto;
}
.mb45{
margin-bottom: 45px!important;
}
Loading…
Cancel
Save