修改图片工具函数

This commit is contained in:
何童崇 2022-08-08 16:52:40 +08:00
parent 1e3552bd0c
commit 0374ad3769
3 changed files with 19 additions and 5 deletions

View File

@ -19,6 +19,20 @@ export function getImageUrl(path) {
return `${path}`;
}
export function getImageUrlAbsolute(path) {
// https://www.educoder.net
// https://testbdweb.trustie.net
// const local = 'http://localhost:3000'
path && !path.startsWith('/') && !path.startsWith('http') && (path = '/'.concat(path));
const local = 'https://testforgeplus.trustie.net';
const prod = window.location.origin;
if (isDev) {
return `${local}${path}`
}else{
return `${prod}${path}`;
}
}
export function numFormat(num, digits){
let d = digits || 1;
var si = [

View File

@ -4,7 +4,7 @@
export {
getUploadLogoActionUrl as getUploadLogoActionUrl,numFormat as numFormat,
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
getImageUrl as getImageUrl,getImageUrlAbsolute as getImageUrlAbsolute,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,
turnbar,returnbar

View File

@ -1,6 +1,6 @@
import { apiService } from './api.service';
import { message } from 'antd';
import { getImageUrl } from "educoder";
import { getImageUrlAbsolute } from "educoder";
import { calcChangeLineNum } from './utils/calc-change-line-num';
import { underscoreToCamelcase } from './utils/camelcase-convert';
import axios from 'axios';
@ -92,7 +92,7 @@ export const prService = {
let journals=underscoreToCamelcase(res.data.journals);
for(const item of journals){
item.author=item.user;
item.author.avatarUrl=item.user.imageUrl?getImageUrl(item.user.imageUrl):'';
item.author.avatarUrl=item.user.imageUrl?getImageUrlAbsolute(item.user.imageUrl):'';
item.author.username=item.user.name;
item.type='Common';
item.stDiff=item.diff;
@ -165,7 +165,7 @@ export const prService = {
console.log('addComment===');
let commentData=underscoreToCamelcase(res.data);
commentData.author=commentData.user;
commentData.author.avatarUrl=commentData.user.imageUrl?getImageUrl(commentData.user.imageUrl):'';
commentData.author.avatarUrl=commentData.user.imageUrl?getImageUrlAbsolute(commentData.user.imageUrl):'';
commentData.author.username=commentData.user.name;
commentData.type='Common';
commentData.stDiff=commentData.diff;
@ -189,7 +189,7 @@ export const prService = {
let reviews=underscoreToCamelcase(res.data.reviews);
for(const item of reviews){
item.author=item.reviewer;
item.author.avatarUrl=getImageUrl(item.reviewer.imageUrl);
item.author.avatarUrl=getImageUrlAbsolute(item.reviewer.imageUrl);
item.author.username=item.reviewer.name;
item.author.webUrl='';
item.body=item.content;