From 97dab335f3f6c83d159c434e4ae5a948de2dc483 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 16 Jan 2020 14:39:05 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E9=95=9C=E5=83=8F=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/edu_datas/game.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/edu_datas/game.json.jbuilder b/app/views/edu_datas/game.json.jbuilder index 3f4a0335e..963583d2f 100644 --- a/app/views/edu_datas/game.json.jbuilder +++ b/app/views/edu_datas/game.json.jbuilder @@ -3,4 +3,5 @@ json.game @game json.shixun @shixun json.shixun_env @env +json.shixun_image @shixun.main_mirror_name json.shixun_tags @shixun_tags \ No newline at end of file From 00a5bb8834853ad62e185f67d4c9f8a85d47aef5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 13:56:57 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/git_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/git_service.rb b/app/services/git_service.rb index 2bfc7423c..3f7a42c97 100644 --- a/app/services/git_service.rb +++ b/app/services/git_service.rb @@ -68,8 +68,8 @@ class GitService content = JSON.parse(body) if content["code"] != 0 - raise("版本库异常") logger.error("repository error: #{content['msg']}") + raise("版本库异常") end #raise content["msg"] if content["code"] != 0 From fa1affb3f71c6ac1530300f85649ee71b8a07639 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 14:17:38 +0800 Subject: [PATCH 03/15] 1 --- app/helpers/student_works_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/student_works_helper.rb b/app/helpers/student_works_helper.rb index 40759c9e0..9a91dfbf2 100644 --- a/app/helpers/student_works_helper.rb +++ b/app/helpers/student_works_helper.rb @@ -82,7 +82,7 @@ module StudentWorksHelper # 最大效率值 # max_efficiency = objects.map{|o| o[:efficiency]}.max results = - objects.each_with_index.map do |object, index| + objects.map_with_index do |object, index| y_score = (object[:evaluate_count] == 0 ? 0 : (object[:user_total_score] / object[:evaluate_count].to_f)) eff_score = format("%.2f", y_score).to_f # 效率值 From 8e85bbdc4d7744c1bb3c2f2bdb201482b3805fa4 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 14:43:59 +0800 Subject: [PATCH 04/15] 1 --- app/helpers/student_works_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/student_works_helper.rb b/app/helpers/student_works_helper.rb index 9a91dfbf2..40759c9e0 100644 --- a/app/helpers/student_works_helper.rb +++ b/app/helpers/student_works_helper.rb @@ -82,7 +82,7 @@ module StudentWorksHelper # 最大效率值 # max_efficiency = objects.map{|o| o[:efficiency]}.max results = - objects.map_with_index do |object, index| + objects.each_with_index.map do |object, index| y_score = (object[:evaluate_count] == 0 ? 0 : (object[:user_total_score] / object[:evaluate_count].to_f)) eff_score = format("%.2f", y_score).to_f # 效率值 From 8457cfc406ac2c6dbf51e5cade04c20a70524118 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 17 Jan 2020 16:58:01 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/zip_pack.rake | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/tasks/zip_pack.rake b/lib/tasks/zip_pack.rake index e3215090b..9cfb36a8e 100644 --- a/lib/tasks/zip_pack.rake +++ b/lib/tasks/zip_pack.rake @@ -38,9 +38,8 @@ namespace :zip_pack do def zip_homework_pdf homeworks, folder, parallel_size Dir.mkdir(folder) unless File.directory?(folder) - homeworks = homeworks.includes(:score_student_works) - Parallel.each(homeworks, in_processes: 2) do |homework| + homeworks.includes(:score_student_works).each do |homework| out_file_name = "#{Time.now.strftime("%Y%m%d%H%M%S").to_s}-#{homework.course_id}-#{homework.name}.zip" out_file_name.gsub!(" ", "-") out_file_name.gsub!("/", "_") @@ -51,21 +50,26 @@ namespace :zip_pack do if student_works.size > 0 pdfs = [] + file_paths = [] + student_works.find_in_batches(batch_size: 500) do |sw| + Parallel.each(sw, in_threads: parallel_size) do |student_work| + export = ExportShixunReportService.new(homework, student_work) + pdf = export.to_pdf + pdfs << pdf + file_paths << {filename: export.filename, path: pdf.path} + puts "out: #{export.filename}_#{pdf.path}" + end + end + Zip::File.open(zipfile_name, Zip::File::CREATE) do |zip| - student_works.find_in_batches(batch_size: 500) do |sw| - Parallel.each(sw, in_processes: parallel_size) do |student_work| - export = ExportShixunReportService.new(homework, student_work) - pdf = export.to_pdf - pdfs << pdf - begin - zip.add(export.filename, pdf.path) - puts "out: #{export.filename}_#{pdf.path}" - rescue => ex - Rails.logger.error(ex.message) + file_paths.each do |pdf| + begin + zip.add(pdf[:filename], pdf[:path]) + rescue => ex + Rails.logger.error(ex.message) - zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } - next - end + zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } + next end end end From b6f42ad542acc98a2c13b438dd4bb6570a4463db Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 17:31:10 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/statistic_subject_info.rake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index 259824174..aecaa1866 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -10,7 +10,7 @@ namespace :subjects do column_value = "subject_id, study_count, course_study_count, initiative_study, passed_count, course_used_count, " + "school_used_count, created_at, updated_at" subjects.find_in_batches(batch_size: 50) do |s| - Parallel.each(s, in_processes: 4) do |subject| + Parallel.each_with_index(s, in_processes: 4) do |subject, index| puts("---------------------data_statistic: #{subject.id}") Rails.logger.info("---------------------data_statistic: #{subject.id}") data = Subjects::DataStatisticService.new(subject) @@ -23,7 +23,7 @@ namespace :subjects do "#{data.passed_count}, #{data.course_used_count}, #{data.school_used_count}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 + if buffer_size == 1000 || (index +1) == data.size sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str}" puts sql ActiveRecord::Base.connection.execute sql @@ -55,14 +55,14 @@ namespace :subjects do puts("---------------------course_info_statistic: #{subject.id}") Rails.logger.info("---------------------course_info_statistic: #{subject.id}") data = Subjects::CourseUsedInfoService.call(subject) - Parallel.map(data) do |key| + Parallel.map_with_index(data) do |key, index| next if key[:school_id].nil? str += ", " unless str.empty? str += ("(#{subject.id}, #{key[:school_id]}, '#{key[:school_name]}', #{key[:course_count]}, " + "#{key[:student_count]}, #{key[:choice_shixun_num]}, #{key[:choice_shixun_frequency]}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 + if buffer_size == 1000 || (index + 1) == data.size sql = "REPLACE INTO subject_course_records(#{column_value}) VALUES #{str}" puts sql ActiveRecord::Base.connection.execute sql @@ -90,11 +90,11 @@ namespace :subjects do column_value = "subject_id, shixun_id, stage, shixun_name, challenge_count, course_count, " + "school_count, used_count, passed_count, evaluate_count, passed_ave_time, created_at, updated_at" subjects.find_in_batches(batch_size: 50) do |s| - Parallel.each(s, in_processes: 4) do |subject| + Parallel.each_with_index(s, in_processes: 4) do |subject| puts("---------------------shixun_info_statistic: #{subject.id}") Rails.logger.info("---------------------shixun_info_statistic: #{subject.id}") data = Subjects::ShixunUsedInfoService.call(subject) - data.each do |key| + data.each_with_index do |key, index| next if key[:shixun_id].nil? str += ", " unless str.empty? str += ("(#{subject.id}, #{key[:shixun_id]}, '#{key[:stage]}', '#{key[:name]}', #{key[:challenge_count]}, " + @@ -102,7 +102,7 @@ namespace :subjects do "#{key[:evaluate_count]}, #{key[:passed_ave_time]}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 + if buffer_size == 1000 || (index+1) == data.size sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str}" puts sql ActiveRecord::Base.connection.execute sql @@ -131,7 +131,7 @@ namespace :subjects do "code_line_count, evaluate_count, cost_time, created_at, updated_at" subjects.find_in_batches(batch_size: 50) do |s| - Parallel.each(s, in_processes: 4) do |subject| + Parallel.each_with_index(s, in_processes: 4) do |subject, index| puts("---------------------user_info_statistic: #{subject.id}") data = Subjects::UserUsedInfoService.call(subject) data.each do |key| @@ -141,7 +141,7 @@ namespace :subjects do "#{key[:passed_games_count]}, #{key[:code_line_count]}, #{key[:evaluate_count]}, #{key[:cost_time]}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 + if buffer_size == 1000 || (index+1 == data.size) sql = "REPLACE INTO subject_user_infos(#{column_value}) VALUES #{str}" ActiveRecord::Base.connection.execute sql str = "" From ce1ac4d8389488f33d5bee4b31e783d147cda0df Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 17:37:30 +0800 Subject: [PATCH 07/15] 1 --- lib/tasks/statistic_subject_info.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index aecaa1866..c510c60fb 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -9,8 +9,8 @@ namespace :subjects do buffer_size = 0 column_value = "subject_id, study_count, course_study_count, initiative_study, passed_count, course_used_count, " + "school_used_count, created_at, updated_at" - subjects.find_in_batches(batch_size: 50) do |s| - Parallel.each_with_index(s, in_processes: 4) do |subject, index| + subjects.find_in_batches(batch_size: 50) do |s, index| + Parallel.each_with_index(s, in_processes: 4) do |subject| puts("---------------------data_statistic: #{subject.id}") Rails.logger.info("---------------------data_statistic: #{subject.id}") data = Subjects::DataStatisticService.new(subject) @@ -23,7 +23,7 @@ namespace :subjects do "#{data.passed_count}, #{data.course_used_count}, #{data.school_used_count}, " + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") buffer_size += 1 - if buffer_size == 1000 || (index +1) == data.size + if buffer_size == 1000 || subjects.count == (index+1) sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str}" puts sql ActiveRecord::Base.connection.execute sql From 06eb69097aefd1354b0a5074a59db9e216ce26ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 17 Jan 2020 17:58:03 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 42 +++++++++++++++++++- public/react/src/modules/wxcode/index.js | 46 +++++++++++----------- public/react/src/services/wxcodeService.js | 38 +++++++++--------- 3 files changed, 83 insertions(+), 43 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index cf813573c..72053896b 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -5,6 +5,7 @@ import md5 from 'md5'; import { requestProxy } from "./indexEduplus2RequestProxy"; import { broadcastChannelOnmessage ,SetAppModel, isDev, queryString } from 'educoder'; import { notification } from 'antd'; +import cookie from 'react-cookies'; import './index.css'; const $ = window.$; const opens ="79e33abd4b6588941ab7622aed1e67e8"; @@ -24,6 +25,18 @@ function locationurl(list){ } +function 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.save('_educoder_session',_arr[0]); + cookie.save('autologin_trustie',_arr[1]); + }); + } +} // TODO 开发期多个身份切换 let debugType ="" @@ -96,7 +109,7 @@ export function initAxiosInterceptors(props) { requestMap[keyName] = false; } - + //响应前的设置 axios.interceptors.request.use( config => { // config.headers['Content-Type']= 'no-cache' @@ -111,6 +124,33 @@ export function initAxiosInterceptors(props) { // proxy = 'http://localhost:3000' // } // --------------------------------------------- + // console.log("开始请求了"); + // console.log(config.url); + // console.log(window.location.pathname); + try { + const str =window.location.pathname; + if(str.indexOf("/wxcode") !== -1){ + // console.log("开始重写cookis"); + const _params = window.location.search; + // console.log("1111"); + if (_params) { + // console.log("22222"); + let _search = _params.split('?')[1]; + _search.split('&').forEach(item => { + const _arr = item.split('='); + if(_arr[0]==='_educoder_session'){ + cookie.save('_educoder_session',_arr[1],{ path: '/' }); + }else{ + cookie.save('autologin_trustie',_arr[1],{ path: '/' }); + } + }); + } + } + }catch (e) { + + } + + // if (config.url.indexOf(proxy) != -1 || config.url.indexOf(':') != -1) { return config } diff --git a/public/react/src/modules/wxcode/index.js b/public/react/src/modules/wxcode/index.js index 2fb871288..67bea0524 100644 --- a/public/react/src/modules/wxcode/index.js +++ b/public/react/src/modules/wxcode/index.js @@ -1,7 +1,7 @@ /* * @Description: 微信端代码编辑器 * @Author: tangjiang - * @Github: + * @Github: * @Date: 2020-01-15 09:56:34 * @LastEditors : tangjiang * @LastEditTime : 2020-01-17 15:34:40 @@ -35,28 +35,28 @@ const App = (props) => { evaluateWxCode, showWXCodeTextCase, changeWXCodeEvaluateLoading - } = props; + } = props; const {identifier} = props.match.params; // 获取路径参数 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' - }); - }); - } + // 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' + // }); + // }); + // } } setCookier(); const [isActive, setIsActive] = useState(-1); @@ -111,7 +111,7 @@ const App = (props) => { updateWXCodeForInterval(identifier, path); }, 10000); } - } + } // 关闭单个测试集 const handleCloseItem = (i, flag) => { @@ -130,7 +130,7 @@ const App = (props) => { changeWXCodeEvaluateLoading(true); evaluateWxCode(identifier, path); } - + const tcclasses = isShow ? `wx-code-test-case active` : 'wx-code-test-case'; const loading = showLoading ? 'code-evaluate-loading active' : 'code-evaluate-loading'; const _val = sets_error_count === 0; @@ -200,19 +200,19 @@ const App = (props) => { { is_public - ? (result + ? (result ? : ) : ( 隐藏测试集,暂不支持解锁和查看 - {/* {result + {/* {result ? : } */} ) } - +
测试输入 {input || '-'} diff --git a/public/react/src/services/wxcodeService.js b/public/react/src/services/wxcodeService.js index 073f248fa..c03514155 100644 --- a/public/react/src/services/wxcodeService.js +++ b/public/react/src/services/wxcodeService.js @@ -1,7 +1,7 @@ /* - * @Description: + * @Description: * @Author: tangjiang - * @Github: + * @Github: * @Date: 2020-01-15 15:44:36 * @LastEditors : tangjiang * @LastEditTime : 2020-01-17 16:40:03 @@ -11,27 +11,27 @@ 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' - }); - }); - } + // 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) { - setCookier(); + setCookier(); const url = `/tasks/${identifier}/rep_content.json`; params = Object.assign({}, params, {withCredentials: true}); return axios.get(url, {params}); From 98e58ed58911103e396afde9bc49e15ba0e9cc22 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 18:09:36 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...117095750_modify_1_wechat_support_for_shixuns.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb diff --git a/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb b/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb new file mode 100644 index 000000000..3e099e9ac --- /dev/null +++ b/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb @@ -0,0 +1,13 @@ +class Modify1WechatSupportForShixuns < ActiveRecord::Migration[5.2] + def change + shixuns = Shixun.joins(:challenges).where(is_wechat_support: true) + .select("shixuns.*, challenges.path path") + shixuns.each do |shixun| + if shixun.path.split(";").count > 1 + shixun.update_attribute(:is_wechat_support, false) + end + end + Shixun.joins(:challenges).where(challenges: {st: 1}).update_all(is_wechat_support: false) + + end +end From ce9d8ee40061e1c0f91b72f71330aea163065bb8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 18:11:32 +0800 Subject: [PATCH 10/15] 1 --- .../20200117095750_modify_1_wechat_support_for_shixuns.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb b/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb index 3e099e9ac..1e973b014 100644 --- a/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb +++ b/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb @@ -1,9 +1,9 @@ class Modify1WechatSupportForShixuns < ActiveRecord::Migration[5.2] def change - shixuns = Shixun.joins(:challenges).where(is_wechat_support: true) + shixuns = Shixun.joins(:challenges).where(is_wechat_support: true, status: 2) .select("shixuns.*, challenges.path path") shixuns.each do |shixun| - if shixun.path.split(";").count > 1 + if shixun.path && shixun.path.split(";").count > 1 shixun.update_attribute(:is_wechat_support, false) end end From da995a8d9aeb46bc4a44c2b72fa92b2bb1d58809 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 17 Jan 2020 18:25:49 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E4=B8=8D=E4=BF=9D=E5=AD=98=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/code_sessions_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/weapps/code_sessions_controller.rb b/app/controllers/weapps/code_sessions_controller.rb index 350fa4978..04b35a06c 100644 --- a/app/controllers/weapps/code_sessions_controller.rb +++ b/app/controllers/weapps/code_sessions_controller.rb @@ -29,7 +29,7 @@ class Weapps::CodeSessionsController < Weapps::BaseController end set_session_unionid(user_info['unionId']) - user_info['nickname'] = user_info['nickName'] + # user_info['nickname'] = user_info['nickName'] session[:wechat_user_extra] = user_info end From 1c365c014f9f9140ed3c9f8fb30cdbdd297fc920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 17 Jan 2020 18:47:46 +0800 Subject: [PATCH 12/15] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/wxcode/index.js | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/public/react/src/modules/wxcode/index.js b/public/react/src/modules/wxcode/index.js index 67bea0524..775a1cb4e 100644 --- a/public/react/src/modules/wxcode/index.js +++ b/public/react/src/modules/wxcode/index.js @@ -41,22 +41,22 @@ const App = (props) => { // 获取路径参数 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' - // }); - // }); - // } + 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' + }); + }); + } } setCookier(); const [isActive, setIsActive] = useState(-1); From b3039a30e432ca8f6e1987cfb54db9661af75a61 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 17 Jan 2020 19:17:57 +0800 Subject: [PATCH 13/15] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=8D?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=BE=AE=E4=BF=A1=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/code_sessions_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/weapps/code_sessions_controller.rb b/app/controllers/weapps/code_sessions_controller.rb index 04b35a06c..3b8102779 100644 --- a/app/controllers/weapps/code_sessions_controller.rb +++ b/app/controllers/weapps/code_sessions_controller.rb @@ -21,6 +21,8 @@ class Weapps::CodeSessionsController < Weapps::BaseController Rails.logger.info("[Weapp] code: #{params[:code]}") user_info = Wechat::Weapp.decrypt(result['session_key'], params[:encrypted_data], params[:iv]) + user_info.delete(:nickName) + # 老用户,已绑定 open_user = OpenUsers::Wechat.find_by(uid: user_info['unionId']) if open_user.present? && open_user.user From 5c7e4f387deeca72f67c32f03aa5ffcd83d008f5 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 17 Jan 2020 19:34:19 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=8D?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=BE=AE=E4=BF=A1=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/code_sessions_controller.rb | 2 +- app/controllers/weapps/sessions_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/weapps/code_sessions_controller.rb b/app/controllers/weapps/code_sessions_controller.rb index 3b8102779..984e008a5 100644 --- a/app/controllers/weapps/code_sessions_controller.rb +++ b/app/controllers/weapps/code_sessions_controller.rb @@ -21,7 +21,7 @@ class Weapps::CodeSessionsController < Weapps::BaseController Rails.logger.info("[Weapp] code: #{params[:code]}") user_info = Wechat::Weapp.decrypt(result['session_key'], params[:encrypted_data], params[:iv]) - user_info.delete(:nickName) + # user_info.delete(:nickName) # 老用户,已绑定 open_user = OpenUsers::Wechat.find_by(uid: user_info['unionId']) diff --git a/app/controllers/weapps/sessions_controller.rb b/app/controllers/weapps/sessions_controller.rb index 8c7c57a7f..371a3f7d3 100644 --- a/app/controllers/weapps/sessions_controller.rb +++ b/app/controllers/weapps/sessions_controller.rb @@ -16,7 +16,7 @@ class Weapps::SessionsController < Weapps::BaseController end # 绑定微信号 - OpenUsers::Wechat.create!(user: user, uid: session_unionid, extra: session[:wechat_user_extra]) if user.wechat_open_user.blank? + OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank? successful_authentication(user) end From e0ff4d13c62ce7f92a49387eff940448ed2057f3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 17 Jan 2020 19:35:47 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=8D?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=BE=AE=E4=BF=A1=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/sessions_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/weapps/sessions_controller.rb b/app/controllers/weapps/sessions_controller.rb index 371a3f7d3..732d0a686 100644 --- a/app/controllers/weapps/sessions_controller.rb +++ b/app/controllers/weapps/sessions_controller.rb @@ -15,6 +15,7 @@ class Weapps::SessionsController < Weapps::BaseController return end + # session[:wechat_user_extra].delete(:nickName) # 绑定微信号 OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank?