forked from Gitlink/forgeplus-react
Merge pull request '工具函数兼容报错' (#323) from tongChong/forgeplus-react:feature_jk_homepage into pre_dev_military
This commit is contained in:
commit
af490fbc0c
|
@ -1,11 +1,11 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import md5 from 'md5';
|
import md5 from 'md5';
|
||||||
import {Input} from "antd";
|
import { Input } from "antd";
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
|
|
||||||
const $ = window.$;
|
const $ = window.$;
|
||||||
const isDev = window.location.port == 3007;
|
const isDev = window.location.port == 3007;
|
||||||
const isdev2= window.location.hostname ==='www.educoder.net'
|
const isdev2 = window.location.hostname === 'www.educoder.net'
|
||||||
export const TEST_HOST = "http://39.105.176.215:49999"
|
export const TEST_HOST = "http://39.105.176.215:49999"
|
||||||
export function getImageUrl(path) {
|
export function getImageUrl(path) {
|
||||||
// https://www.educoder.net
|
// https://www.educoder.net
|
||||||
|
@ -24,12 +24,12 @@ export function getImage(path) {
|
||||||
// https://testbdweb.trustie.net
|
// https://testbdweb.trustie.net
|
||||||
// const local = 'http://localhost:3000'
|
// const local = 'http://localhost:3000'
|
||||||
const local = 'http://39.105.176.215:49999';
|
const local = 'http://39.105.176.215:49999';
|
||||||
if(path.indexOf("http://")===-1){
|
if (path&&path.indexOf("http://") === -1) {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return `${local}/images/${path}`
|
return `${local}/images/${path}`
|
||||||
}
|
}
|
||||||
return `/${path}`;
|
return `/${path}`;
|
||||||
}else{
|
} else {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ export function getTestImage(path) {
|
||||||
// https://testbdweb.trustie.net
|
// https://testbdweb.trustie.net
|
||||||
// const local = 'http://localhost:3000'
|
// const local = 'http://localhost:3000'
|
||||||
const local = 'http://117.50.100.12:49999';
|
const local = 'http://117.50.100.12:49999';
|
||||||
if(path.indexOf("http://")===-1){
|
if (path && path.indexOf("http://") === -1) {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return `${local}${path}`
|
return `${local}${path}`
|
||||||
}
|
}
|
||||||
return `${path}`;
|
return `${path}`;
|
||||||
}else{
|
} else {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,31 +63,31 @@ export function getcdnImageUrl(path) {
|
||||||
// https://testbdweb.trustie.net
|
// https://testbdweb.trustie.net
|
||||||
// const local = 'http://localhost:3000'
|
// const local = 'http://localhost:3000'
|
||||||
const testlocal = 'https://testali-cdn.educoder.net'
|
const testlocal = 'https://testali-cdn.educoder.net'
|
||||||
const local='https://ali-cdn.educoder.net'
|
const local = 'https://ali-cdn.educoder.net'
|
||||||
let firstStr=path.substr(0,1);
|
let firstStr = path.substr(0, 1);
|
||||||
if (isdev2) {
|
if (isdev2) {
|
||||||
return `${local}/${path}`;
|
return `${local}/${path}`;
|
||||||
}else{
|
} else {
|
||||||
if(firstStr=="/"){
|
if (firstStr == "/") {
|
||||||
return `${path}`
|
return `${path}`
|
||||||
}else{
|
} else {
|
||||||
return `/${path}`
|
return `/${path}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return `${local}/${path}`;
|
// return `${local}/${path}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setcndImagesUrl(path){
|
export function setcndImagesUrl(path) {
|
||||||
const testlocal = 'https://testali-cdn.educoder.net'
|
const testlocal = 'https://testali-cdn.educoder.net'
|
||||||
const local='https://ali-cdn.educoder.net'
|
const local = 'https://ali-cdn.educoder.net'
|
||||||
let firstStr=path.substr(0,1);
|
let firstStr = path.substr(0, 1);
|
||||||
if(firstStr=="/"){
|
if (firstStr == "/") {
|
||||||
if (!isdev2) {
|
if (!isdev2) {
|
||||||
return `${path}`
|
return `${path}`
|
||||||
}
|
}
|
||||||
return `${local}${path}`;
|
return `${local}${path}`;
|
||||||
//return isDev?`${testlocal}${path}`:`${local}${path}`;
|
//return isDev?`${testlocal}${path}`:`${local}${path}`;
|
||||||
}else{
|
} else {
|
||||||
if (!isdev2) {
|
if (!isdev2) {
|
||||||
return `/${path}`
|
return `/${path}`
|
||||||
}
|
}
|
||||||
|
@ -98,17 +98,17 @@ export function setcndImagesUrl(path){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function setImagesUrl(path){
|
export function setImagesUrl(path) {
|
||||||
const testlocal = 'https://testali-cdn.educoder.net'
|
const testlocal = 'https://testali-cdn.educoder.net'
|
||||||
const local='https://ali-cdn.educoder.net'
|
const local = 'https://ali-cdn.educoder.net'
|
||||||
let firstStr=path.substr(0,1);
|
let firstStr = path.substr(0, 1);
|
||||||
if(firstStr=="/"){
|
if (firstStr == "/") {
|
||||||
if (!isdev2) {
|
if (!isdev2) {
|
||||||
return `${path}`
|
return `${path}`
|
||||||
}
|
}
|
||||||
return `${local}${path}`;
|
return `${local}${path}`;
|
||||||
// return isDev?`${testlocal}${path}`:`${path}`;
|
// return isDev?`${testlocal}${path}`:`${path}`;
|
||||||
}else{
|
} else {
|
||||||
if (!isdev2) {
|
if (!isdev2) {
|
||||||
return `/${path}`
|
return `/${path}`
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,9 @@ export function setImagesUrl(path){
|
||||||
export function getUrl(path, goTest) {
|
export function getUrl(path, goTest) {
|
||||||
const local = 'http://39.105.176.215:49999'
|
const local = 'http://39.105.176.215:49999'
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return `${local}${path?path:''}`
|
return `${local}${path ? path : ''}`
|
||||||
}
|
}
|
||||||
return `${path ? path: ''}`;
|
return `${path ? path : ''}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUrlmys(path, goTest) {
|
export function getUrlmys(path, goTest) {
|
||||||
|
@ -136,9 +136,9 @@ export function getUrlmys(path, goTest) {
|
||||||
// const local = 'https://testeduplus2.educoder.net'
|
// const local = 'https://testeduplus2.educoder.net'
|
||||||
const local = 'https://test-jupyterweb.educoder.net'
|
const local = 'https://test-jupyterweb.educoder.net'
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return `${local}${path?path:''}`
|
return `${local}${path ? path : ''}`
|
||||||
}
|
}
|
||||||
return `${path ? path: ''}`;
|
return `${path ? path : ''}`;
|
||||||
}
|
}
|
||||||
export function getStaticUrl() {
|
export function getStaticUrl() {
|
||||||
const local = TEST_HOST;
|
const local = TEST_HOST;
|
||||||
|
@ -151,25 +151,27 @@ export function getStaticUrl() {
|
||||||
export function getUrl2(path, goTest) {
|
export function getUrl2(path, goTest) {
|
||||||
const local = 'http://localhost:3000'
|
const local = 'http://localhost:3000'
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return `${local}${path?path:''}`
|
return `${local}${path ? path : ''}`
|
||||||
}
|
}
|
||||||
return `${path ? path: ''}`;
|
return `${path ? path : ''}`;
|
||||||
}
|
}
|
||||||
const newopens ="79e33abd4b6588941ab7622aed1e67e8";
|
const newopens = "79e33abd4b6588941ab7622aed1e67e8";
|
||||||
let newtimestamp;
|
let newtimestamp;
|
||||||
let checkSubmitFlgs = false;
|
let checkSubmitFlgs = false;
|
||||||
function railsgettimess(proxy) {
|
function railsgettimess(proxy) {
|
||||||
if(checkSubmitFlgs===false){
|
if (checkSubmitFlgs === false) {
|
||||||
$.ajax({url:proxy,
|
$.ajax({
|
||||||
async:false,success:function(data){
|
url: proxy,
|
||||||
if(data.status===0){
|
async: false, success: function (data) {
|
||||||
newtimestamp=data.message;
|
if (data.status === 0) {
|
||||||
|
newtimestamp = data.message;
|
||||||
checkSubmitFlgs = true;
|
checkSubmitFlgs = true;
|
||||||
}
|
}
|
||||||
}})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
checkSubmitFlgs=false;
|
checkSubmitFlgs = false;
|
||||||
}, 2500);
|
}, 2500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,8 +214,8 @@ export function getUploadActionUrlOfAuth(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRandomNumber(type) {
|
export function getRandomNumber(type) {
|
||||||
let anewopens=md5(newopens+newtimestamp);
|
let anewopens = md5(newopens + newtimestamp);
|
||||||
return type===true?`randomcode=${newtimestamp}&client_key=${anewopens}`:`?randomcode=${newtimestamp}&client_key=${anewopens}`
|
return type === true ? `randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test(path) {
|
export function test(path) {
|
||||||
|
@ -247,20 +249,20 @@ export function htmlEncode(str) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function publicSearchs(Placeholder,onSearch,onInputs,onChanges,loadings) {
|
export function publicSearchs(Placeholder, onSearch, onInputs, onChanges, loadings) {
|
||||||
return(<Search
|
return (<Search
|
||||||
placeholder= { Placeholder || "请输入内容进行搜索" }
|
placeholder={Placeholder || "请输入内容进行搜索"}
|
||||||
onSearch={onSearch}
|
onSearch={onSearch}
|
||||||
// value={searchValue}
|
// value={searchValue}
|
||||||
onInput={onInputs}
|
onInput={onInputs}
|
||||||
onChange={onChanges}
|
onChange={onChanges}
|
||||||
loading={loadings||false}
|
loading={loadings || false}
|
||||||
allowClear={true}
|
allowClear={true}
|
||||||
></Search>)
|
></Search>)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUrlToken(name, str) {
|
export function getUrlToken(name, str) {
|
||||||
const reg = new RegExp(`(^|&)${ name}=([^&]*)(&|$)`);
|
const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`);
|
||||||
const r = str.substr(1).match(reg);
|
const r = str.substr(1).match(reg);
|
||||||
if (r != null) return decodeURIComponent(r[2]); return null;
|
if (r != null) return decodeURIComponent(r[2]); return null;
|
||||||
}
|
}
|
Loading…
Reference in New Issue