Delete useless code line.

pull/3445/head
ruibaby 2019-04-20 00:26:01 +08:00
parent 0f06588987
commit 828c8ad624
4 changed files with 24 additions and 119 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<a-drawer <a-drawer
title="附件详情" title="附件详情"
:width="isMobile()?'100%':'560'" :width="isMobile()?'100%':'460'"
closable closable
:visible="visiable" :visible="visiable"
destroyOnClose destroyOnClose
@ -86,7 +86,8 @@
</a-list-item-meta> </a-list-item-meta>
</a-list-item> </a-list-item>
<a-list-item> <a-list-item>
<a-list-item-meta :description="'!['+attachment.name+']('+attachment.path+')'"> <a-list-item-meta>
<span slot="description">![{{ attachment.name }}]({{ attachment.path }})</span>
<span slot="title"> <span slot="title">
Markdown 格式 Markdown 格式
<a-icon <a-icon
@ -196,4 +197,15 @@ export default {
.attach-detail-img img { .attach-detail-img img {
width: 100%; width: 100%;
} }
.attachment-control {
position: absolute;
bottom: 0px;
width: 100%;
border-top: 1px solid rgb(232, 232, 232);
padding: 10px 16px;
text-align: right;
left: 0px;
background: rgb(255, 255, 255);
border-radius: 0px 0px 4px 4px;
}
</style> </style>

View File

@ -158,7 +158,6 @@ export default {
</script> </script>
<style> <style>
.post-control,
.attachment-control { .attachment-control {
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;

View File

@ -70,18 +70,19 @@
</a-drawer> </a-drawer>
</a-col> </a-col>
</a-row> </a-row>
<AttachmentDrawer v-model="attachmentDrawerVisible"/>
<footer-tool-bar <footer-tool-bar
:style="{ width: isSideMenu() && isDesktop() ? `calc(100% - ${sidebarOpened ? 256 : 80}px)` : '100%'}" :style="{ width: isSideMenu() && isDesktop() ? `calc(100% - ${sidebarOpened ? 256 : 80}px)` : '100%'}"
> >
<a-button type="primary" @click="showDrawer"></a-button> <a-button type="primary" @click="showDrawer"></a-button>
<a-button type="dashed" style="margin-left: 8px;">附件库</a-button> <a-button type="dashed" style="margin-left: 8px;" @click="showAttachDrawer"></a-button>
</footer-tool-bar> </footer-tool-bar>
</div> </div>
</template> </template>
<script> <script>
import { mavonEditor } from 'mavon-editor' import { mavonEditor } from 'mavon-editor'
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
import FooterToolBar from '@/components/FooterToolbar' import FooterToolBar from '@/components/FooterToolbar'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import 'mavon-editor/dist/css/index.css' import 'mavon-editor/dist/css/index.css'
@ -92,7 +93,8 @@ export default {
name: 'Editor', name: 'Editor',
components: { components: {
mavonEditor, mavonEditor,
FooterToolBar FooterToolBar,
AttachmentDrawer
}, },
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
data() { data() {
@ -102,6 +104,7 @@ export default {
sm: { span: 24 }, sm: { span: 24 },
xs: { span: 24 } xs: { span: 24 }
}, },
attachmentDrawerVisible: false,
visible: false, visible: false,
postUrl: 'hello-world', postUrl: 'hello-world',
customTpls: [], customTpls: [],
@ -140,6 +143,9 @@ export default {
this.customTpls = response.data.data this.customTpls = response.data.data
}) })
}, },
showAttachDrawer() {
this.attachmentDrawerVisible = true
},
showDrawer() { showDrawer() {
this.visible = true this.visible = true
}, },

View File

@ -166,7 +166,6 @@ import 'mavon-editor/dist/css/index.css'
import tagApi from '@/api/tag' import tagApi from '@/api/tag'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import postApi from '@/api/post' import postApi from '@/api/post'
import attachmentApi from '@/api/attachment'
import AttachmentDrawer from '../attachment/components/AttachmentDrawer' import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
const toolbars = { const toolbars = {
@ -206,8 +205,6 @@ export default {
xs: { span: 24 } xs: { span: 24 }
}, },
attachmentDrawerVisible: false, attachmentDrawerVisible: false,
selectAttachmentDrawerVisible: false,
uploadVisible: false,
visible: false, visible: false,
childDrawerVisible: false, childDrawerVisible: false,
tags: [], tags: [],
@ -215,16 +212,7 @@ export default {
selectedCategoryIds: [], selectedCategoryIds: [],
selectedTagIds: [], selectedTagIds: [],
markdownOption: toolbars, markdownOption: toolbars,
postToStage: {}, postToStage: {}
attachments: [],
selectAttachment: {},
detailLoading: false,
pagination: {
page: 1,
size: 8,
sort: ''
},
attachmentUploadHandler: attachmentApi.upload
} }
}, },
computed: { computed: {
@ -265,14 +253,6 @@ export default {
this.categories = response.data.data this.categories = response.data.data
}) })
}, },
loadAttachments() {
const pagination = Object.assign({}, this.pagination)
pagination.page--
attachmentApi.query(pagination).then(response => {
this.attachments = response.data.data.content
this.pagination.total = response.data.data.total
})
},
createOrUpdatePost() { createOrUpdatePost() {
// Set category ids // Set category ids
this.postToStage.categoryIds = this.selectedCategoryIds this.postToStage.categoryIds = this.selectedCategoryIds
@ -299,15 +279,6 @@ export default {
}, },
showAttachDrawer() { showAttachDrawer() {
this.attachmentDrawerVisible = true this.attachmentDrawerVisible = true
this.loadAttachments()
},
showDetailDrawer(attachment) {
this.selectAttachmentDrawerVisible = true
this.detailLoading = true
this.selectAttachment = attachment
setTimeout(() => {
this.detailLoading = false
}, 500)
}, },
showThumbDrawer() { showThumbDrawer() {
this.childDrawerVisible = true this.childDrawerVisible = true
@ -325,55 +296,6 @@ export default {
}, },
onChildClose() { onChildClose() {
this.childDrawerVisible = false this.childDrawerVisible = false
},
onAttachmentClose() {
this.attachmentDrawerVisible = false
},
onSelectAttachmentClose() {
this.selectAttachmentDrawerVisible = false
},
doCopyNormalLink() {
const text = `${this.selectAttachment.path}`
this.$copyText(text)
.then(message => {
console.log('copy', message)
this.$message.success('复制成功')
})
.catch(err => {
console.log('copy.err', err)
this.$message.error('复制失败')
})
},
doCopyMarkdownLink() {
const text = `![${this.selectAttachment.name}](${this.selectAttachment.path})`
this.$copyText(text)
.then(message => {
console.log('copy', message)
this.$message.success('复制成功')
})
.catch(err => {
console.log('copy.err', err)
this.$message.error('复制失败')
})
},
handlePaginationChange(page, pageSize) {
this.pagination.page = page
this.pagination.size = pageSize
this.loadAttachments()
},
handleChange(info) {
const status = info.file.status
if (status === 'done') {
this.$message.success(`${info.file.name} 文件上传成功`)
} else if (status === 'error') {
this.$message.error(`${info.file.name} 文件上传失败`)
}
},
handleAttachmentUploadSuccess() {
this.$message.success('上传成功')
},
showUploadModal() {
this.uploadVisible = true
} }
} }
} }
@ -389,19 +311,6 @@ export default {
padding-bottom: 0; padding-bottom: 0;
} }
.post-control,
.attachment-control {
position: absolute;
bottom: 0px;
width: 100%;
border-top: 1px solid rgb(232, 232, 232);
padding: 10px 16px;
text-align: right;
left: 0px;
background: rgb(255, 255, 255);
border-radius: 0px 0px 4px 4px;
}
.ant-form-vertical .ant-form-item { .ant-form-vertical .ant-form-item {
padding-bottom: 0; padding-bottom: 0;
} }
@ -410,25 +319,4 @@ export default {
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;
} }
.attach-item {
width: 50%;
margin: 0 auto;
position: relative;
padding-bottom: 28%;
overflow: hidden;
float: left;
}
.attach-item > img {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.attach-detail-img img {
width: 100%;
}
</style> </style>