Commit 7f719899 authored by Maofei94's avatar Maofei94

perf: 图片组件修改

parent 92d9caf4
Pipeline #23215 passed with stages
in 19 minutes 47 seconds
......@@ -19,6 +19,14 @@ const PictureWallProvider = props => {
if (res.code === 0) {
const { data } = res;
let arr = data.filter(item => item.moduleName !== 'menu') || [];
data.forEach(item => {
if (item.baseUrl && item.moduleName !== 'CityTemp') {
if (!localStorage.getItem('pd2-baseUrl')) {
localStorage.setItem('pd2-baseUrl', item.baseUrl);
console.log(1, item.moduleName);
}
}
});
setImgBed(arr);
}
})
......
......@@ -61,6 +61,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
previewTitle: '',
imgBed: this.props.uploadContext?.imgBed || [],
curSelectedImg: '',
baseUrl:'',
prevProps:{},
search: '',
actives: {},
......@@ -158,9 +159,10 @@ class PicturesWall extends React.Component<PicturesWallType> {
});
};
handleImgSelected = (url: string) => {
handleImgSelected = (url: string,baseUrl:any) => {
this.setState({
curSelectedImg: url,
baseUrl:baseUrl
});
};
......@@ -172,14 +174,28 @@ class PicturesWall extends React.Component<PicturesWallType> {
handleModalOk = () => {
const { maxLen = 1 } = this.props;
const { baseUrl,curSelectedImg} = this.state
const fileList = [
{
uid: uuid(8, 16),
name: '熊猫运维中台系统',
status: 'done',
url: this.state.curSelectedImg,
url: curSelectedImg,
},
];
if(!curSelectedImg){
message.warn({
duration:2,
content:'请先选择图片'
})
return
}
if(curSelectedImg.includes('CityTemp')){
localStorage.setItem('pd-baseUrl',baseUrl)
}else{
localStorage.setItem('pd2-baseUrl',baseUrl)
}
console.log(fileList[0].url)
this.props.onChange && this.props.onChange( maxLen === 1 ? fileList[0].url.replace('Web4\\', '') : fileList.map(f => f.url.replace('Web4\\', '')));
this.setState({ fileList, wallModalVisible: false });
};
......@@ -242,7 +258,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
return match&&match[1]||''
}
renderImgItem(url){
renderImgItem(url,baseUrl){
const fileName = this.getFileName(url)
const {curSelectedImg, search} = this.state;
return (
......@@ -252,7 +268,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
[styles.hide]: !fileName.includes(search)
})}
key={url}
onClick={() => this.handleImgSelected(url)}>
onClick={() => this.handleImgSelected(url,baseUrl)}>
<div
className={classnames(
curSelectedImg === url ? styles.seleted : '',
......@@ -276,7 +292,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
renderCollapse(module){
const { Panel } = Collapse;
const items = module.fileUrls.map(url =>this.renderImgItem(url))
const items = module.fileUrls.map(url =>this.renderImgItem(url,module.baseUrl))
return items.length>0&&<Panel
forceRender
header={module.moduleName}
......@@ -397,12 +413,12 @@ class PicturesWall extends React.Component<PicturesWallType> {
const child = [...item.child] || [];
console.log(picType)
if(item.fileUrls.length > 0){
child.push({
moduleName: item.moduleName,
fileUrls: item.fileUrls,
child: [],
baseUrl:item.baseUrl
})
}
return (
......
......@@ -191,13 +191,42 @@ const WebConfigPage = props => {
const handleTabChange = v => {
setCurWeb(webs.find(w => w.id === v));
};
const handleSubmit = values => {
const handleGeturl = val => {
let url;
const isSite = val.includes('CityTemp');
if (isSite) {
url = val;
} else {
url = localStorage.getItem('pd2-baseUrl')
? localStorage.getItem('pd2-baseUrl') + val
: val;
}
return url;
};
const handleSubmit = val => {
let {
bannerLogo,
logo,
shortcutIcon,
baseBannerUrl,
baseIconUrl,
baseLogoUrl,
} = val;
baseBannerUrl = handleGeturl(bannerLogo);
baseIconUrl = handleGeturl(shortcutIcon);
baseLogoUrl = handleGeturl(logo);
let values = {
...val,
baseBannerUrl,
baseIconUrl,
baseLogoUrl,
};
setSubmitting(true);
const requestMap = {
postEditWebConfig,
postAddWebSite,
};
const successMsg = isEdit ? '保存成功!' : '新增网站成功!';
const failMsg = isEdit ? '编辑失败!' : '新增网站失败!';
requestMap[isEdit ? 'postEditWebConfig' : 'postAddWebSite'](values)
......
......@@ -248,10 +248,23 @@ const MiniMenu = props => {
setAddType(1);
setAddTwoVisible(true);
};
const handleGeturl = val => {
let url;
const isSite = val.includes('CityTemp');
if (isSite) {
url = val;
} else {
url = localStorage.getItem('pd2-baseUrl')
? localStorage.getItem('pd2-baseUrl') + val
: val;
}
return url;
};
// 新增提交的回调
const submitCallback = (prop, item) => {
setSubmitLoading(true);
let obj = { ...prop };
let baseUrl = handleGeturl(prop.imageUrl);
let obj = { ...prop, baseUrl };
const parentID = item.menuID ? item.menuID : -1;
addWebMenu({
_dc: Date.now(),
......@@ -287,7 +300,8 @@ const MiniMenu = props => {
// 编辑的回调
const editSubmitCallback = prop => {
setLoading(true);
let obj = { ...prop };
let baseUrl = handleGeturl(prop.imageUrl);
let obj = { ...prop, baseUrl };
if (nodeType === 1) {
obj.relatedRoleList = String(roleList) || '';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment