added ESlint 语法检测

This commit is contained in:
何秀钢
2021-06-02 14:11:45 +08:00
parent 3932a8fbf3
commit 2f0465a1a1
94 changed files with 5031 additions and 4790 deletions
+23 -17
View File
@@ -2,14 +2,14 @@
<el-drawer title="媒体库" :visible.sync="drawer">
<div class="media">
<el-image
class="header-img-box-list"
:src="(item.url && item.url.slice(0, 4) !== 'http')?path+item.url:item.url"
v-for="(item,key) in picList"
:key="key"
class="header-img-box-list"
:src="(item.url && item.url.slice(0, 4) !== 'http')?path+item.url:item.url"
@click.native="chooseImg(item.url,target,targetKey)"
>
<div slot="error" class="header-img-box-list">
<i class="el-icon-picture-outline"></i>
<i class="el-icon-picture-outline" />
</div>
</el-image>
</div>
@@ -18,34 +18,40 @@
<script>
const path = process.env.VUE_APP_BASE_API
import { getFileList } from "@/api/fileUploadAndDownload";
import { getFileList } from '@/api/fileUploadAndDownload'
export default {
props: {
target: [Object],
targetKey: [String]
target: {
type: Object,
default: null
},
targetKey: {
type: String,
default: ''
}
},
data() {
return {
drawer: false,
picList: [],
path:path
};
path: path
}
},
methods: {
chooseImg(url, target, targetKey) {
if(target&&targetKey){
target[targetKey] = url;
if (target && targetKey) {
target[targetKey] = url
}
this.$emit("enter-img", url);
this.drawer = false;
this.$emit('enter-img', url)
this.drawer = false
},
async open() {
const res = await getFileList({ page: 1, pageSize: 9999 });
this.picList = res.data.list;
this.drawer = true;
const res = await getFileList({ page: 1, pageSize: 9999 })
this.picList = res.data.list
this.drawer = true
}
}
};
}
</script>
<style lang="scss">
@@ -65,4 +71,4 @@ export default {
}
}
</style>
</style>
+51 -51
View File
@@ -1,63 +1,63 @@
<template>
<span class="headerAvatar">
<template v-if="picType === 'avatar'">
<el-avatar :size="30" :src="avatar" v-if="userInfo.headerImg"></el-avatar>
<el-avatar :size="30" :src="require('@/assets/noBody.png')" v-else></el-avatar>
</template>
<template v-if="picType === 'img'">
<img :src="avatar" class="avatar" v-if="userInfo.headerImg" />
<img :src="require('@/assets/noBody.png')" class="avatar" v-else/>
</template>
<template v-if="picType === 'file'">
<img :src="file" class="file"/>
</template>
</span>
<span class="headerAvatar">
<template v-if="picType === 'avatar'">
<el-avatar v-if="userInfo.headerImg" :size="30" :src="avatar" />
<el-avatar v-else :size="30" :src="require('@/assets/noBody.png')" />
</template>
<template v-if="picType === 'img'">
<img v-if="userInfo.headerImg" :src="avatar" class="avatar">
<img v-else :src="require('@/assets/noBody.png')" class="avatar">
</template>
<template v-if="picType === 'file'">
<img :src="file" class="file">
</template>
</span>
</template>
<script>
import { mapGetters } from 'vuex'
const path = process.env.VUE_APP_BASE_API
export default {
name: "customPic",
props: {
picType: {
type: String,
required: false,
default: "avatar"
},
picSrc: {
type: String,
required: false,
default: ""
}
name: 'CustomPic',
props: {
picType: {
type: String,
required: false,
default: 'avatar'
},
data(){
return{
path: path + '/',
}
},
computed:{
...mapGetters('user', ['userInfo']),
avatar(){
if(this.picSrc === ''){
if(this.userInfo.headerImg !== '' && this.userInfo.headerImg.slice(0, 4) === "http"){
return this.userInfo.headerImg
}
return this.path + this.userInfo.headerImg
}else{
if(this.picSrc !== '' && this.picSrc.slice(0, 4) === "http"){
return this.picSrc
}
return this.path + this.picSrc
}
},
file(){
if(this.picSrc && this.picSrc.slice(0, 4) !== "http"){
return this.path + this.picSrc
}
return this.picSrc
}
picSrc: {
type: String,
required: false,
default: ''
}
},
data() {
return {
path: path + '/'
}
},
computed: {
...mapGetters('user', ['userInfo']),
avatar() {
if (this.picSrc === '') {
if (this.userInfo.headerImg !== '' && this.userInfo.headerImg.slice(0, 4) === 'http') {
return this.userInfo.headerImg
}
return this.path + this.userInfo.headerImg
} else {
if (this.picSrc !== '' && this.picSrc.slice(0, 4) === 'http') {
return this.picSrc
}
return this.path + this.picSrc
}
},
file() {
if (this.picSrc && this.picSrc.slice(0, 4) !== 'http') {
return this.path + this.picSrc
}
return this.picSrc
}
}
}
</script>
+25 -26
View File
@@ -4,8 +4,6 @@
<upload-image v-model="imageUrl" :fileSize="512" />
已上传文件 {{ imageUrl }}
</div>
-->
<template>
@@ -19,62 +17,63 @@
:before-upload="beforeImageUpload"
:multiple="false"
>
<img v-if="imageUrl" :src="path + imageUrl" class="image" />
<i v-else class="el-icon-plus image-uploader-icon"></i>
<img v-if="imageUrl" :src="path + imageUrl" class="image">
<i v-else class="el-icon-plus image-uploader-icon" />
</el-upload>
</div>
</template>
<script>
const path = process.env.VUE_APP_BASE_API;
import { mapGetters } from "vuex";
import ImageCompress from "@/utils/image.js";
const path = process.env.VUE_APP_BASE_API
import { mapGetters } from 'vuex'
import ImageCompress from '@/utils/image'
export default {
name: "upload-image",
name: 'UploadImage',
model: {
prop: "imageUrl",
event: "change",
prop: 'imageUrl',
event: 'change'
},
props: {
imageUrl: {
type: String,
default: "",
default: ''
},
fileSize: {
type: Number,
default: 2048, // 2M 超出后执行压缩
default: 2048 // 2M 超出后执行压缩
},
maxWH: {
type: Number,
default: 1920, // 图片长宽上限
},
default: 1920 // 图片长宽上限
}
},
data() {
return {
path: path,
};
path: path
}
},
computed: {
...mapGetters("user", ["userInfo", "token"]),
...mapGetters('user', ['userInfo', 'token'])
},
methods: {
beforeImageUpload(file) {
let isRightSize = file.size / 1024 < this.fileSize;
const isRightSize = file.size / 1024 < this.fileSize
if (!isRightSize) {
// 压缩
let compress = new ImageCompress(file, this.fileSize, this.maxWH);
return compress.compress();
const compress = new ImageCompress(file, this.fileSize, this.maxWH)
return compress.compress()
}
return isRightSize;
return isRightSize
},
handleImageSuccess(res) {
// this.imageUrl = URL.createObjectURL(file.raw);
const { data } = res;
const { data } = res
if (data.file) {
this.$emit("change", data.file.url);
this.$emit('change', data.file.url)
}
},
},
};
}
}
}
</script>
<style lang="scss" scoped>