代码调整

This commit is contained in:
joylink_cuiweidong 2022-10-09 13:06:54 +08:00
parent ba3e306211
commit 25b4a4fa45
2 changed files with 100 additions and 4 deletions

View File

@ -143,3 +143,11 @@ export function checkFrontProjectExist(params) {
params
});
}
//
export function getUploadUrl(params) {
return request({
url: `/api/minio/preSignedUrl`,
method: 'get',
params
});
}

View File

@ -22,24 +22,30 @@
<el-form-item label="关于系统:" prop="aboutSystem">
<el-input v-model="formModel.aboutSystem" style="width: 400px;" size="small" />
</el-form-item>
<el-form-item label="项目Logo:" prop="loginProLogo">
<div class="eachButton uploadLogo">
<i class="el-icon-plus avatar-uploader-icon el-icon-other" />
<input id="upload_file" ref="files" type="file" class="file_box" accept="image/jpeg,image/png" @change="uploadLogo">
<img v-if="formModel.loginProLogo" :src="formModel.loginProLogo" :alt="formModel.loginProLogo">
</div>
</el-form-item>
<!-- loginProLogo:'', // logo
loginProLogoWidth:'', // logo
loginProLogoHeight:'', // logo -->
<el-form-item label="页签名称:" prop="browserTitle" class="inlineBlock">
<el-input v-model="formModel.browserTitle" style="width: 210px;" size="small" />
</el-form-item>
<el-form-item label="导航栏名称:" prop="homeTitle" class="inlineBlock" style="margin-left:10px">
<el-input v-model="formModel.homeTitle" style="width: 210px;" size="small" />
</el-form-item>
<!-- navLogoWidth //Logo -->
<!-- navLogoHeight //Logo -->
<el-form-item label="案例展示:" prop="caseShow" class="inlineBlock">
<el-switch v-model="formModel.caseShow" />
</el-form-item>
<el-form-item label="帮助展示:" prop="helpShow" class="inlineBlock">
<el-switch v-model="formModel.helpShow" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button v-loading="loading" type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
@ -48,7 +54,8 @@
</el-dialog>
</template>
<script>
import { updateFrontProjectConfig } from '@/api/projectConfig';
import { updateFrontProjectConfig, getUploadUrl } from '@/api/projectConfig';
import request from '@/utils/request';
export default {
name:'FrontProjectConfig',
data() {
@ -70,6 +77,8 @@ export default {
browserTitle:'', //
homeTitle:'', //
navLogoWidth:'', // Logo
navLogoHeight:'', // Logo
caseShow:true, //
helpShow:true //
@ -117,6 +126,8 @@ export default {
this.formModel.browserTitle = viewSetting.browserTitle || '';
this.formModel.homeTitle = viewSetting.homeTitle || '';
this.formModel.navLogoWidth = viewSetting.navLogoWidth || '';
this.formModel.navLogoHeight = viewSetting.navLogoHeight || '';
this.formModel.caseShow = viewSetting.caseShow || true;
this.formModel.helpShow = viewSetting.helpShow || true;
@ -137,6 +148,8 @@ export default {
browserTitle:'', //
homeTitle:'', //
navLogoWidth:'', // Logo
navLogoHeight:'', // Logo
caseShow:true, //
helpShow:true //
@ -162,6 +175,50 @@ export default {
});
}
});
},
uploadLogo() {
const pic = document.getElementById('upload_file');
if (!pic.files || !pic.files[0]) {
return;
}
const file = pic.files[0];
const mineType = file.type;
const fileSize = file.size;
if (mineType != 'image/png' && mineType != 'image/jpeg') {
this.$message.error('仅支持png和jpeg格式的图片');
return;
}
if (fileSize / (1024 * 1024) > 1) {
this.$message.error('图片应该小于1M');
return;
}
const fileArray = file.name.split('.');
const fileType = fileArray[fileArray.length - 1] || '';
if (!fileType) {
return;
}
const params = {
directory:'logo',
fileName:'favicon_' + this.row.markKey + '.' + fileType,
method:'PUT'
};
getUploadUrl(params).then((response) => {
const url = response.data;
if (url) {
request({
headers: { 'Content-Type': 'multipart/form-data'},
url:url,
method: 'put',
data: file
}).then((res) => {
debugger;
});
}
});
// directoryMINIO
// fileName
// method
}
}
};
@ -170,4 +227,35 @@ export default {
.inlineBlock{
display: inline-block;
}
.eachButton{
margin-left:10px;
width:100px;
height:100px;
border:1px #ccc dashed;
margin-bottom: 10px;
}
.el-icon-other{
width: 100%;
text-align: center;
height: 100%;
line-height: 72px;
font-size: 16px;
}
.uploadLogo {
position: relative;
overflow: hidden;
// float: right;
padding: 9px 15px;
margin-right: 3px;
cursor: pointer;
input {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
}
}
</style>