From 85056d3df582971f5136343e1b6b9a7bbcc0d670 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Mon, 30 Dec 2019 23:45:18 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E6=95=B4md=E5=8A=A0=E5=AF=86?=
=?UTF-8?q?=E5=BD=B1=E5=93=8D=E6=8E=A5=E5=8F=A3+=E5=B0=81=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/common/UrlTool.js | 45 ++++++-
public/react/src/common/educoder.js | 2 +-
.../modules/comment/CommentItemMDEditor.js | 4 +-
.../CompetitionContentsMd.js | 4 +-
.../CompetitionContentspdfdownload.js | 6 +-
.../modules/courses/busyWork/NewWorkForm.js | 6 +-
.../busyWork/common/TabRightComponents.js | 4 +-
.../CompetitionContentsMd.js | 4 +-
.../CompetitionContentspdfdownload.js | 6 +-
.../courses/coursesPublic/CoursesMarkdown.js | 4 +-
.../courses/coursesPublic/SelectSetting.js | 4 +-
.../courses/coursesPublic/sendResource.js | 4 +-
.../exercise/Testpapersettinghomepage.js | 4 +-
.../tasks/GraduationTasksSubmitedit.js | 4 +-
.../tasks/GraduationTasksSubmitnew.js | 4 +-
.../graduation/tasks/GraduationTasksedit.js | 4 +-
.../topics/GraduateTopicPostWorksNew.js | 4 +-
.../modules/courses/statistics/Statistics.js | 4 +-
.../src/modules/forums/MemoDetailMDEditor.js | 4 +-
.../modules/forums/MemoDetailMDEditortwo.js | 4 +-
public/react/src/modules/forums/MemoNew.js | 2 +-
public/react/src/modules/paths/PathNew.js | 110 ++++--------------
.../src/modules/projectPackages/MDEditors.js | 4 +-
.../modules/tpm/TPMsettings/oldTPMsettings.js | 6 +-
.../modules/tpm/challengesnew/TPMMDEditor.js | 4 +-
.../src/modules/tpm/challengesnew/editorMD.js | 4 +-
.../tpm/challengesnew/old/TPManswer.js | 4 +-
.../modules/tpm/newshixuns/oldNewshixuns.js | 2 +-
.../user/usersInfo/banks/NewGtaskForm.js | 4 +-
29 files changed, 118 insertions(+), 147 deletions(-)
diff --git a/public/react/src/common/UrlTool.js b/public/react/src/common/UrlTool.js
index d7a49ea63..e190bdd98 100644
--- a/public/react/src/common/UrlTool.js
+++ b/public/react/src/common/UrlTool.js
@@ -1,3 +1,4 @@
+import md5 from 'md5';
const isDev = window.location.port == 3007;
export const TEST_HOST = "https://test-newweb.educoder.net"
export function getImageUrl(path) {
@@ -68,19 +69,46 @@ export function getUrl2(path, goTest) {
}
return `${path ? path: ''}`;
}
+const newopens ="79e33abd4b6588941ab7622aed1e67e8";
+let newtimestamp;
+let checkSubmitFlgs = false;
+function railsgettimess(proxy) {
+ if(checkSubmitFlgs===false){
+ $.ajax({url:proxy,async:false,success:function(data){
+ if(data.status===0){
+ newtimestamp=data.message;
+ }
+ }})
+ checkSubmitFlgs=true
+ window.setTimeout(function () {
+ checkSubmitFlgs=false;
+ }, 3500);
+ }
+}
+
+export function Railsgettimes() {
+ railsgettimess(`${getUrl()}/api/main/first_stamp.json`);
+}
+
export function getUploadActionUrl(path, goTest) {
- return `${getUrl()}/api/attachments.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}`
+ Railsgettimes()
+ let anewopens=md5(newopens+newtimestamp);
+ return `${getUrl()}/api/attachments.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}`;
}
export function getUploadActionUrltwo(id) {
-
- return `${getUrlmys()}/api/shixuns/${id}/upload_data_sets.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}`
+ Railsgettimes()
+ let anewopens=md5(newopens+newtimestamp);
+ return `${getUrlmys()}/api/shixuns/${id}/upload_data_sets.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}`
}
export function getUploadActionUrlthree() {
-
- return `${getUrlmys()}/api/jupyters/import_with_tpm.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}`
+ Railsgettimes()
+ let anewopens=md5(newopens+newtimestamp);
+ return `${getUrlmys()}/api/jupyters/import_with_tpm.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}`
}
export function getUploadActionUrlOfAuth(id) {
- return `${getUrl()}/api/users/accounts/${id}/auth_attachment.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}`
+ Railsgettimes()
+ let anewopens=md5(newopens+newtimestamp);
+ return `${getUrl()}/api/users/accounts/${id}/auth_attachment.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}`
}
export function test(path) {
@@ -96,6 +124,11 @@ export function getTaskUrlById(id) {
return `/tasks/${id}`
}
+export function getRandomcode(url) {
+ Railsgettimes()
+ let anewopens=md5(newopens+newtimestamp);
+ return `${url}?&randomcode=${newtimestamp}&client_key=${anewopens}`
+}
export function htmlEncode(str) {
var s = "";
diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js
index 3d11ee3cb..126a42e87 100644
--- a/public/react/src/common/educoder.js
+++ b/public/react/src/common/educoder.js
@@ -2,7 +2,7 @@
// export { default as OrderStateUtil } from '../routes/Order/components/OrderStateUtil';
-export { getImageUrl as getImageUrl, getUrl as getUrl, getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl
+export { getImageUrl as getImageUrl, getUrl as getUrl, getRandomcode as getRandomcode,getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl
, getUploadActionUrl as getUploadActionUrl,getUploadActionUrltwo as getUploadActionUrltwo ,getUploadActionUrlthree as getUploadActionUrlthree, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth
, getTaskUrlById as getTaskUrlById, TEST_HOST ,htmlEncode as htmlEncode } from './UrlTool';
export { default as queryString } from './UrlTool2';
diff --git a/public/react/src/modules/comment/CommentItemMDEditor.js b/public/react/src/modules/comment/CommentItemMDEditor.js
index 8c49d356f..0bde1c6a7 100644
--- a/public/react/src/modules/comment/CommentItemMDEditor.js
+++ b/public/react/src/modules/comment/CommentItemMDEditor.js
@@ -6,7 +6,7 @@ import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom";
import PropTypes from 'prop-types';
import classNames from 'classnames'
-
+import { getImageUrl, toPath, getUrl,getUploadActionUrl } from 'educoder';
import './CommentItemMDEditor.css'
const $ = window.$;
@@ -36,7 +36,7 @@ class CommentItemMDEditor extends Component {
if( $(`#${initMD_ID} textarea`).length === 1 ) { // 没有初始化
const placeholder = '我要回复...'
// const imageUrl = `/upload_with_markdown?container_id=${commentId}&container_type=Memo`;
- const imageUrl = `/api/attachments.json`;
+ const imageUrl = `${getUploadActionUrl()}`;
const otherOptions = {
watch: false,
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js
index 049f2bab1..9ea972177 100644
--- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js
+++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import {Button, Card, Row, Col ,Upload,Icon,message,Tabs} from 'antd';
import axios from 'axios';
-import {getImageUrl,getUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder';
+import {getUploadActionUrl,getUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
const { TabPane } = Tabs;
class CompetitionContentsMd extends Component{
@@ -184,7 +184,7 @@ class CompetitionContentsMd 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) => {
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js
index eb304e007..360d65937 100644
--- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js
+++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import {Button,Layout,Row, Col,Divider,Table} from 'antd';
import axios from 'axios';
-import {getImageUrl} from 'educoder';
+import {getImageUrl,getRandomcode} from 'educoder';
import './CompetitionContentspdfdownload.css';
// import NoneData from "../../../courses/shixunHomework/shixunHomework";
@@ -158,7 +158,7 @@ class CompetitionContentspdfdownload extends Component{
return(
- 立即下载
)
@@ -172,7 +172,7 @@ class CompetitionContentspdfdownload extends Component{
return(
- 立即下载
)
diff --git a/public/react/src/modules/courses/busyWork/NewWorkForm.js b/public/react/src/modules/courses/busyWork/NewWorkForm.js
index 81851d2f2..6740f7579 100644
--- a/public/react/src/modules/courses/busyWork/NewWorkForm.js
+++ b/public/react/src/modules/courses/busyWork/NewWorkForm.js
@@ -3,7 +3,7 @@ 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 {getUploadActionUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder'
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import CBreadcrumb from '../common/CBreadcrumb'
@@ -333,7 +333,7 @@ class NewWorkForm 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) => {
@@ -352,7 +352,7 @@ class NewWorkForm 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.handleAnswerUploadChange,
onRemove: (file) => this.onAttachmentRemove(file, 'answerFileList'),
beforeUpload: (file) => {
diff --git a/public/react/src/modules/courses/busyWork/common/TabRightComponents.js b/public/react/src/modules/courses/busyWork/common/TabRightComponents.js
index 9c8f96cc2..41e03d176 100644
--- a/public/react/src/modules/courses/busyWork/common/TabRightComponents.js
+++ b/public/react/src/modules/courses/busyWork/common/TabRightComponents.js
@@ -150,8 +150,8 @@ class TabRightComponents extends Component{
{this.props.isAdmin()?