From d1e7d2e935e76a12ab8eb6b87312e3032e780373 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 22 Oct 2020 18:20:42 +0800 Subject: [PATCH] image url --- src/common/UrlTool.js | 27 +++++++++++++++++++++++---- src/common/educoder.js | 2 +- src/forge/Main/IndexItem.js | 4 ++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/common/UrlTool.js b/src/common/UrlTool.js index 0516da60a..7980ed0ce 100644 --- a/src/common/UrlTool.js +++ b/src/common/UrlTool.js @@ -11,11 +11,30 @@ export function getImageUrl(path) { // https://www.educoder.net // https://testbdweb.trustie.net // const local = 'http://localhost:3000' - const local = 'https://testforgeplus.trustie.net/' - if (isDev) { - return `${local}/${path}` + const local = 'https://testforgeplus.trustie.net/'; + if(path.indexOf("http://")===-1){ + if (isDev) { + return `${local}/${path}` + } + return `/${path}`; + }else{ + return path; + } +} + +export function getImage(path) { + // https://www.educoder.net + // https://testbdweb.trustie.net + // const local = 'http://localhost:3000' + const local = 'https://testforgeplus.trustie.net/'; + if(path.indexOf("http://")===-1){ + if (isDev) { + return `${local}/images/${path}` + } + return `/${path}`; + }else{ + return path; } - return `/${path}`; } export function getcdnImageUrl(path) { diff --git a/src/common/educoder.js b/src/common/educoder.js index 83d2a40c8..83cb8bf8c 100644 --- a/src/common/educoder.js +++ b/src/common/educoder.js @@ -4,7 +4,7 @@ export { getUploadLogoActionUrl as getUploadLogoActionUrl, - getImageUrl as getImageUrl, getmyUrl as getmyUrl, getRandomNumber as getRandomNumber, getUrl as getUrl, publicSearchs as publicSearchs, getRandomcode as getRandomcode, getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl + getImageUrl as getImageUrl,getImage as getImage, getmyUrl as getmyUrl, getRandomNumber as getRandomNumber, getUrl as getUrl, publicSearchs as publicSearchs, 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, getupload_git_file as getupload_git_file, getcdnImageUrl as getcdnImageUrl } from './UrlTool'; diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js index 1195ebbb5..7950d6e1c 100644 --- a/src/forge/Main/IndexItem.js +++ b/src/forge/Main/IndexItem.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { Tooltip } from 'antd'; -import { getImageUrl } from 'educoder'; +import { getImageUrl , getImage } from 'educoder'; import { Link } from 'react-router-dom'; import '../css/index.scss'; import Nodata from '../Nodata'; @@ -21,7 +21,7 @@ class IndexItem extends Component { return (
- +