style: remove useless code.

pull/3445/head
ruibaby 2019-11-22 21:44:39 +08:00
parent 9dc87f218a
commit 1682a42ba4
3 changed files with 2 additions and 298 deletions

View File

@ -1,138 +0,0 @@
<template>
<div class="clearfix">
<a-upload
:name="name"
:customRequest="handleUpload"
listType="picture-card"
:fileList="fileList"
@preview="handlePreview"
@change="handleChange"
>
<div v-if="fileList.length < 9 && plusPhotoVisible" id="plus-photo-uploadbox">
<a-icon type="plus"/>
<div class="ant-upload-text">Upload</div>
</div>
</a-upload>
<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
<img alt="example" style="width: 100%" :src="previewImage">
</a-modal>
</div>
</template>
<script>
import axios from 'axios'
import attachmentApi from '@/api/attachment'
export default {
props: {
photoList: {
type: Array,
required: false,
default: function() {
return []
}
},
plusPhotoVisible: {
type: Boolean,
required: false,
default: true
}
},
data() {
return {
name: 'file',
previewVisible: false,
previewImage: '',
fileList: [],
uploadHandler: attachmentApi.upload
}
},
created() {
// watch
this.handlerEditPreviewPhoto(this.photoList)
},
watch: {
photoList(newValue, oldValue) {
this.handlerEditPreviewPhoto(newValue)
}
},
methods: {
handlerEditPreviewPhoto(data) {
//
this.fileList = []
//
if (data !== null && data !== undefined) {
for (var i = 0; i < data.length; i++) {
//
this.fileList.push({
uid: data[i].id,
name: data[i].name,
status: 'done',
url: data[i].thumbnail
})
}
}
},
handleCancel() {
this.previewVisible = false
},
handlePreview(file) {
this.previewImage = file.url || file.thumbUrl
this.previewVisible = true
},
handleChange({ fileList }) {
this.fileList = fileList
},
handleUpload(option) {
this.$log.debug('Uploading option', option)
const CancelToken = axios.CancelToken
const source = CancelToken.source()
const data = new FormData()
data.append(this.name, option.file)
this.uploadHandler(
data,
progressEvent => {
if (progressEvent.total > 0) {
progressEvent.percent = (progressEvent.loaded / progressEvent.total) * 100
}
this.$log.debug('Uploading percent: ', progressEvent.percent)
option.onProgress(progressEvent)
},
source.token,
option.file
)
.then(response => {
this.$log.debug('Uploaded successfully', response)
option.onSuccess(response, option.file)
this.$emit('success', response, option.file)
})
.catch(error => {
this.$log.debug('Failed to upload file', error)
option.onError(error, error.response)
this.$emit('failure', error, option.file)
})
return {
abort: () => {
this.$log.debug('Upload operation aborted by the user')
source.cancel('Upload operation canceled by the user.')
}
}
}
}
}
</script>
<style>
.ant-upload-select-picture-card i {
font-size: 32px;
color: #999;
}
.ant-upload-select-picture-card .ant-upload-text {
margin-top: 8px;
color: #666;
}
.ant-upload-list-picture-card {
/* 将浮动恢复为默认值,避免出现纵向换行情况 */
float: initial;
}
</style>

View File

@ -51,9 +51,6 @@
:xs="12" :xs="12"
:style="{ marginBottom: '12px' }" :style="{ marginBottom: '12px' }"
> >
<!-- <analysis-card :loading="countsLoading" title="总访问" :number="countsData.visitCount">
<a-tooltip slot="action">
<template slot="title">文章总访问共 {{ countsData.visitCount }} </template>-->
<analysis-card <analysis-card
:loading="countsLoading" :loading="countsLoading"
title="总访问" title="总访问"
@ -68,10 +65,6 @@
:duration="3000" :duration="3000"
></countTo> ></countTo>
</template> </template>
<!-- <countTo :startVal="0" :endVal="countsData.visitCount" :duration="3000"></countTo> -->
<!-- <template>
<countTo :startVal="0" :endVal="countsData.visitCount" :duration="3000"></countTo>
</template>-->
<a href="javascript:void(0);"> <a href="javascript:void(0);">
<a-icon type="info-circle-o" /> <a-icon type="info-circle-o" />
</a> </a>
@ -220,26 +213,11 @@
placeholder="写点什么吧..." placeholder="写点什么吧..."
/> />
</a-form-item> </a-form-item>
<!-- 日志图片上传 -->
<!-- <a-form-item v-show="showMoreOptions">
<UploadPhoto
@success="handlerPhotoUploadSuccess"
:photoList="photoList"
></UploadPhoto>
</a-form-item> -->
<a-form-item> <a-form-item>
<a-button <a-button
type="primary" type="primary"
@click="handleCreateJournalClick" @click="handleCreateJournalClick"
>保存</a-button> >保存</a-button>
<!-- <a
href="javascript:;"
class="more-options-btn"
type="default"
@click="handleUploadPhotoWallClick"
>更多选项<a-icon type="down" /></a> -->
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-card> </a-card>
@ -354,7 +332,6 @@ import { PageView } from '@/layouts'
import AnalysisCard from './components/AnalysisCard' import AnalysisCard from './components/AnalysisCard'
import RecentCommentTab from './components/RecentCommentTab' import RecentCommentTab from './components/RecentCommentTab'
import countTo from 'vue-count-to' import countTo from 'vue-count-to'
import UploadPhoto from '../../components/Upload/UploadPhoto.vue'
import postApi from '@/api/post' import postApi from '@/api/post'
import logApi from '@/api/log' import logApi from '@/api/log'
@ -367,12 +344,10 @@ export default {
PageView, PageView,
AnalysisCard, AnalysisCard,
RecentCommentTab, RecentCommentTab,
countTo, countTo
UploadPhoto
}, },
data() { data() {
return { return {
photoList: [],
// showMoreOptions: false, // showMoreOptions: false,
startVal: 0, startVal: 0,
logType: logApi.logType, logType: logApi.logType,
@ -389,7 +364,6 @@ export default {
content: '', content: '',
photos: [] photos: []
}, },
journalPhotos: [], //
logs: [], logs: [],
logPagination: { logPagination: {
page: 1, page: 1,
@ -450,18 +424,6 @@ export default {
next() next()
}, },
methods: { methods: {
// handlerPhotoUploadSuccess(response, file) {
// var callData = response.data.data
// var photo = {
// name: callData.name,
// url: callData.path,
// thumbnail: callData.thumbPath,
// suffix: callData.suffix,
// width: callData.width,
// height: callData.height
// }
// this.journalPhotos.push(photo)
// },
listLatestPosts() { listLatestPosts() {
postApi.listLatest(5).then(response => { postApi.listLatest(5).then(response => {
this.postData = response.data.data this.postData = response.data.data
@ -485,8 +447,6 @@ export default {
this.$router.push({ name: 'PostEdit', query: { postId: post.id } }) this.$router.push({ name: 'PostEdit', query: { postId: post.id } })
}, },
handleCreateJournalClick() { handleCreateJournalClick() {
//
// this.journal.photos = this.journalPhotos
if (!this.journal.content) { if (!this.journal.content) {
this.$notification['error']({ this.$notification['error']({
message: '提示', message: '提示',
@ -497,14 +457,8 @@ export default {
journalApi.create(this.journal).then(response => { journalApi.create(this.journal).then(response => {
this.$message.success('发表成功!') this.$message.success('发表成功!')
this.journal = {} this.journal = {}
// this.photoList = []
// this.showMoreOptions = false
}) })
}, },
// handleUploadPhotoWallClick() {
// //
// this.showMoreOptions = !this.showMoreOptions
// },
handleShowLogDrawer() { handleShowLogDrawer() {
this.logDrawerVisible = true this.logDrawerVisible = true
this.loadLogs() this.loadLogs()
@ -541,13 +495,3 @@ export default {
} }
} }
</script> </script>
<style lang="less" scoped>
/* .more-options-btn {
margin-left: 15px;
text-decoration: none;
}
a {
text-decoration: none;
} */
</style>

View File

@ -75,29 +75,6 @@
slot-scope="item, index" slot-scope="item, index"
:key="index" :key="index"
> >
<!-- 日志图片集合 -->
<!-- <a-card
hoverable
v-for="(photo, photoIndex) in item.photos"
:key="photoIndex"
class="photo-card"
@click="handlerPhotoPreview(photo)"
>
<img alt="example" :src="photo.thumbnail" slot="cover">
</a-card> -->
<!-- <a-modal
:visible="previewVisible"
:footer="null"
@cancel="handleCancelPreview"
>
<img
:alt="previewPhoto.name + previewPhoto.description"
style="width: 100%"
:src="previewPhoto.url"
>
</a-modal> -->
<template slot="actions"> <template slot="actions">
<span> <span>
<a href="javascript:void(0);"> <a href="javascript:void(0);">
@ -127,9 +104,6 @@
<a-icon type="unlock" /> <a-icon type="unlock" />
</a> </a>
</span> </span>
<!-- <span>
From 微信
</span>-->
</template> </template>
<template slot="extra"> <template slot="extra">
<a <a
@ -207,24 +181,6 @@
defaultChecked defaultChecked
/> />
</a-form-item> </a-form-item>
<!-- <a-form-item v-show="showMoreOptions">
<UploadPhoto
@success="handlerPhotoUploadSuccess"
:photoList="photoList"
:plusPhotoVisible="plusPhotoVisible"
></UploadPhoto>
</a-form-item>
<a-form-item>
<a
href="javascript:;"
class="more-options-btn"
type="default"
@click="handleUploadPhotoWallClick"
>
更多选项
<a-icon type="down"/>
</a>
</a-form-item> -->
</a-form> </a-form>
</a-modal> </a-modal>
@ -298,23 +254,12 @@ import { mixin, mixinDevice } from '@/utils/mixin.js'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import journalApi from '@/api/journal' import journalApi from '@/api/journal'
import journalCommentApi from '@/api/journalComment' import journalCommentApi from '@/api/journalComment'
import UploadPhoto from '@/components/Upload/UploadPhoto.vue'
export default { export default {
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: { JournalCommentTree, UploadPhoto }, components: { JournalCommentTree },
data() { data() {
return { return {
journalType: journalApi.journalType, journalType: journalApi.journalType,
// plusPhotoVisible: true,
// photoList: [], //
// previewVisible: false,
showMoreOptions: false,
// previewPhoto: {
// //
// name: '',
// description: '',
// url: ''
// },
title: '发表', title: '发表',
listLoading: false, listLoading: false,
visible: false, visible: false,
@ -336,7 +281,6 @@ export default {
comments: [], comments: [],
journal: {}, journal: {},
isPublic: true, isPublic: true,
journalPhotos: [], //
selectComment: null, selectComment: null,
replyComment: {} replyComment: {}
} }
@ -348,30 +292,6 @@ export default {
...mapGetters(['user']) ...mapGetters(['user'])
}, },
methods: { methods: {
// handleCancelPreview() {
// this.previewVisible = false
// },
// handlerPhotoPreview(photo) {
// //
// this.previewVisible = true
// this.previewPhoto = photo
// },
// handlerPhotoUploadSuccess(response, file) {
// var callData = response.data.data
// var photo = {
// name: callData.name,
// url: callData.path,
// thumbnail: callData.thumbPath,
// suffix: callData.suffix,
// width: callData.width,
// height: callData.height
// }
// this.journalPhotos.push(photo)
// },
// handleUploadPhotoWallClick() {
// //
// this.showMoreOptions = !this.showMoreOptions
// },
loadJournals(isSearch) { loadJournals(isSearch) {
this.queryParam.page = this.pagination.page - 1 this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size this.queryParam.size = this.pagination.size
@ -390,19 +310,12 @@ export default {
this.title = '新建' this.title = '新建'
this.visible = true this.visible = true
this.journal = {} this.journal = {}
//
// this.plusPhotoVisible = true
// this.photoList = []
}, },
handleEdit(item) { handleEdit(item) {
this.title = '编辑' this.title = '编辑'
this.journal = item this.journal = item
this.isPublic = item.type !== 'INTIMATE' this.isPublic = item.type !== 'INTIMATE'
this.visible = true this.visible = true
// ,
// this.plusPhotoVisible = false
// this.photoList = item.photos
}, },
handleDelete(id) { handleDelete(id) {
journalApi.delete(id).then(response => { journalApi.delete(id).then(response => {
@ -439,8 +352,6 @@ export default {
}) })
}, },
createOrUpdateJournal() { createOrUpdateJournal() {
//
// this.journal.photos = this.journalPhotos
this.journal.type = this.isPublic ? 'PUBLIC' : 'INTIMATE' this.journal.type = this.isPublic ? 'PUBLIC' : 'INTIMATE'
if (!this.journal.content) { if (!this.journal.content) {
@ -461,7 +372,6 @@ export default {
journalApi.create(this.journal).then(response => { journalApi.create(this.journal).then(response => {
this.$message.success('发表成功!') this.$message.success('发表成功!')
this.loadJournals() this.loadJournals()
// this.photoList = []
this.isPublic = true this.isPublic = true
}) })
} }
@ -481,15 +391,3 @@ export default {
} }
} }
</script> </script>
<style scoped="scoped">
/* .more-options-btn {
margin-left: 15px;
text-decoration: none;
}
.photo-card {
width: 104px;
display: inline-block;
margin-right: 5px;
} */
</style>