🎨新增网盘logo上传
This commit is contained in:
parent
5ec008a338
commit
b85098506f
@ -1,8 +1,11 @@
|
|||||||
import fileApi from '@/api/file-api'
|
import fileApi from '@/api/file-api'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
baseUrl: '/api',
|
baseUrl: '/api',
|
||||||
|
// 网盘logo
|
||||||
|
logoUrl: function(filename) {
|
||||||
|
return window.location.origin + `${this.baseUrl}/file/${filename}`
|
||||||
|
},
|
||||||
// webDAV的url
|
// webDAV的url
|
||||||
webDAVUrl: function(username) {
|
webDAVUrl: function(username) {
|
||||||
return window.location.origin + `${this.baseUrl}/webDAV/${username}`
|
return window.location.origin + `${this.baseUrl}/webDAV/${username}`
|
||||||
|
|||||||
@ -9,6 +9,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
<div>
|
||||||
|
<el-upload
|
||||||
|
class="avatar-uploader"
|
||||||
|
:action="uploadUrl"
|
||||||
|
:show-file-list="false"
|
||||||
|
:on-success="handleAvatarSuccess"
|
||||||
|
:before-upload="beforeAvatarUpload">
|
||||||
|
<img v-if="logoUrl" :src="logoUrl" class="avatar">
|
||||||
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
||||||
|
</el-upload>
|
||||||
|
</div>
|
||||||
<div class="config-itme-label">启用webp:
|
<div class="config-itme-label">启用webp:
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="webpEnabled"
|
v-model="webpEnabled"
|
||||||
@ -38,18 +49,23 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
import settingApi from "@/api/setting-api";
|
import settingApi from "@/api/setting-api";
|
||||||
|
import {getSetting} from '@/api/setting-api'
|
||||||
import Bus from "@/assets/js/bus";
|
import Bus from "@/assets/js/bus";
|
||||||
|
import fileConfig from "@/utils/file-config";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
uploadUrl: process.env.VUE_APP_BASE_API + '/user/setting/upload_logo?jmal-token=' + this.$store.state.user.token,
|
||||||
title: '网盘管理',
|
title: '网盘管理',
|
||||||
syncLoading: false,
|
syncLoading: false,
|
||||||
resetLoading: false,
|
resetLoading: false,
|
||||||
webpEnabled: false
|
webpEnabled: false,
|
||||||
|
logoUrl: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.getWebsiteSetting()
|
||||||
this.getInfo()
|
this.getInfo()
|
||||||
this.getIsSync()
|
this.getIsSync()
|
||||||
Bus.$on('msg/synced', () => {
|
Bus.$on('msg/synced', () => {
|
||||||
@ -60,6 +76,29 @@ export default {
|
|||||||
Bus.$off()
|
Bus.$off()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleAvatarSuccess(res, file) {
|
||||||
|
if (res.code === 0) {
|
||||||
|
this.logoUrl = fileConfig.logoUrl(res.data)
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.message)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeAvatarUpload(file) {
|
||||||
|
const isLtOneM = file.size / 1024 / 1024 < 1;
|
||||||
|
if (!isLtOneM) {
|
||||||
|
this.$message.error('上传头像图片大小不能超过 1MB!');
|
||||||
|
}
|
||||||
|
return isLtOneM;
|
||||||
|
},
|
||||||
|
// 获取网站设置
|
||||||
|
getWebsiteSetting() {
|
||||||
|
getSetting({userId: this.$store.state.user.userId}).then((res) => {
|
||||||
|
if(res.data) {
|
||||||
|
this.logoUrl = fileConfig.logoUrl(res.data.netdiskLogo)
|
||||||
|
// this.logoUrl = '../../icons/svg/jmal-cloud.svg'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
getInfo(){
|
getInfo(){
|
||||||
settingApi.getWebp({userId: this.$store.state.user.userId}).then((res) => {
|
settingApi.getWebp({userId: this.$store.state.user.userId}).then((res) => {
|
||||||
this.webpEnabled = !res.data
|
this.webpEnabled = !res.data
|
||||||
@ -117,4 +156,29 @@ export default {
|
|||||||
>>> .el-textarea {
|
>>> .el-textarea {
|
||||||
max-width: 1080px;
|
max-width: 1080px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.avatar-uploader .el-upload {
|
||||||
|
border: 1px dashed #d9d9d9;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.avatar-uploader .el-upload:hover {
|
||||||
|
border-color: #409EFF;
|
||||||
|
}
|
||||||
|
.avatar-uploader-icon {
|
||||||
|
font-size: 28px;
|
||||||
|
color: #8c939d;
|
||||||
|
width: 150px;
|
||||||
|
height: 150px;
|
||||||
|
line-height: 150px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.avatar {
|
||||||
|
width: 150px;
|
||||||
|
height: 150px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -36,6 +36,7 @@ module.exports = {
|
|||||||
productionSourceMap: false,
|
productionSourceMap: false,
|
||||||
devServer: {
|
devServer: {
|
||||||
port: port,
|
port: port,
|
||||||
|
disableHostCheck: true,
|
||||||
open: false,
|
open: false,
|
||||||
overlay: {
|
overlay: {
|
||||||
warnings: false,
|
warnings: false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user