From 2a41938989897889ee4efb5e8577f6c327bcd718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <1261960504@qq.com> Date: Fri, 17 Dec 2021 16:06:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=87=BD=E6=95=B0=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/UrlTool.js | 106 +++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/src/common/UrlTool.js b/src/common/UrlTool.js index 175fb56b..d9cd23f8 100644 --- a/src/common/UrlTool.js +++ b/src/common/UrlTool.js @@ -1,16 +1,16 @@ import React from "react"; import md5 from 'md5'; -import {Input} from "antd"; +import { Input } from "antd"; const { Search } = Input; const $ = window.$; 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 function getImageUrl(path) { // https://www.educoder.net // https://testbdweb.trustie.net - // const local = 'http://localhost:3000' + // const local = 'http://localhost:3000' const local = 'http://39.105.176.215:49999'; if (isDev) { @@ -22,14 +22,14 @@ export function getImageUrl(path) { export function getImage(path) { // https://www.educoder.net // https://testbdweb.trustie.net - // const local = 'http://localhost:3000' + // const local = 'http://localhost:3000' const local = 'http://39.105.176.215:49999'; - if(path.indexOf("http://")===-1){ + if (path&&path.indexOf("http://") === -1) { if (isDev) { return `${local}/images/${path}` } return `/${path}`; - }else{ + } else { return path; } } @@ -37,14 +37,14 @@ export function getImage(path) { export function getTestImage(path) { // https://www.educoder.net // https://testbdweb.trustie.net - // const local = 'http://localhost:3000' + // const local = 'http://localhost:3000' const local = 'http://117.50.100.12:49999'; - if(path.indexOf("http://")===-1){ + if (path && path.indexOf("http://") === -1) { if (isDev) { return `${local}${path}` } return `${path}`; - }else{ + } else { return path; } } @@ -61,33 +61,33 @@ export function getLogoImageUrl(path) { export function getcdnImageUrl(path) { // https://www.educoder.net // https://testbdweb.trustie.net - // const local = 'http://localhost:3000' - const testlocal = 'https://testali-cdn.educoder.net' - const local='https://ali-cdn.educoder.net' - let firstStr=path.substr(0,1); + // const local = 'http://localhost:3000' + const testlocal = 'https://testali-cdn.educoder.net' + const local = 'https://ali-cdn.educoder.net' + let firstStr = path.substr(0, 1); if (isdev2) { return `${local}/${path}`; - }else{ - if(firstStr=="/"){ + } else { + if (firstStr == "/") { return `${path}` - }else{ + } else { return `/${path}` } } // return `${local}/${path}`; } -export function setcndImagesUrl(path){ +export function setcndImagesUrl(path) { const testlocal = 'https://testali-cdn.educoder.net' - const local='https://ali-cdn.educoder.net' - let firstStr=path.substr(0,1); - if(firstStr=="/"){ + const local = 'https://ali-cdn.educoder.net' + let firstStr = path.substr(0, 1); + if (firstStr == "/") { if (!isdev2) { return `${path}` } return `${local}${path}`; - //return isDev?`${testlocal}${path}`:`${local}${path}`; - }else{ + //return isDev?`${testlocal}${path}`:`${local}${path}`; + } else { if (!isdev2) { return `/${path}` } @@ -98,31 +98,31 @@ export function setcndImagesUrl(path){ -export function setImagesUrl(path){ +export function setImagesUrl(path) { const testlocal = 'https://testali-cdn.educoder.net' - const local='https://ali-cdn.educoder.net' - let firstStr=path.substr(0,1); - if(firstStr=="/"){ + const local = 'https://ali-cdn.educoder.net' + let firstStr = path.substr(0, 1); + if (firstStr == "/") { if (!isdev2) { return `${path}` } return `${local}${path}`; // return isDev?`${testlocal}${path}`:`${path}`; - }else{ + } else { if (!isdev2) { return `/${path}` } return `${local}/${path}`; - //return isDev?`${testlocal}/${path}`:`/${path}`; + //return isDev?`${testlocal}/${path}`:`/${path}`; } } export function getUrl(path, goTest) { const local = 'http://39.105.176.215:49999' if (isDev) { - return `${local}${path?path:''}` + return `${local}${path ? path : ''}` } - return `${path ? path: ''}`; + return `${path ? path : ''}`; } export function getUrlmys(path, goTest) { @@ -136,9 +136,9 @@ export function getUrlmys(path, goTest) { // const local = 'https://testeduplus2.educoder.net' const local = 'https://test-jupyterweb.educoder.net' if (isDev) { - return `${local}${path?path:''}` + return `${local}${path ? path : ''}` } - return `${path ? path: ''}`; + return `${path ? path : ''}`; } export function getStaticUrl() { const local = TEST_HOST; @@ -149,27 +149,29 @@ export function getStaticUrl() { return '' } export function getUrl2(path, goTest) { - const local = 'http://localhost:3000' + const local = 'http://localhost:3000' 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 checkSubmitFlgs = false; function railsgettimess(proxy) { - if(checkSubmitFlgs===false){ - $.ajax({url:proxy, - async:false,success:function(data){ - if(data.status===0){ - newtimestamp=data.message; + 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; + checkSubmitFlgs = false; }, 2500); } } @@ -212,8 +214,8 @@ export function getUploadActionUrlOfAuth(id) { } export function getRandomNumber(type) { - let anewopens=md5(newopens+newtimestamp); - return type===true?`randomcode=${newtimestamp}&client_key=${anewopens}`:`?randomcode=${newtimestamp}&client_key=${anewopens}` + let anewopens = md5(newopens + newtimestamp); + return type === true ? `randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}` } export function test(path) { @@ -247,20 +249,20 @@ export function htmlEncode(str) { return s; } -export function publicSearchs(Placeholder,onSearch,onInputs,onChanges,loadings) { - return() } export function getUrlToken(name, str) { - const reg = new RegExp(`(^|&)${ name}=([^&]*)(&|$)`); - const r = str.substr(1).match(reg); - if (r != null) return decodeURIComponent(r[2]); return null; + const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`); + const r = str.substr(1).match(reg); + if (r != null) return decodeURIComponent(r[2]); return null; } \ No newline at end of file