Complete post edit ui

pull/9/head
ruibaby 2019-04-16 20:59:42 +08:00
parent b90ea3d0bf
commit e0591f7749
2 changed files with 86 additions and 16 deletions

View File

@ -13,7 +13,7 @@
background: #fff; background: #fff;
border-top: 1px solid #e8e8e8; border-top: 1px solid #e8e8e8;
padding: 0 24px; padding: 0 24px;
z-index: 9; z-index: 1000;
&:after { &:after {
content: ""; content: "";

View File

@ -2,7 +2,7 @@
<div class="page-header-index-wide"> <div class="page-header-index-wide">
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24"> <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
<a-card>
<div style="margin-bottom: 16px"> <div style="margin-bottom: 16px">
<a-input <a-input
v-model="postToStage.title" v-model="postToStage.title"
@ -11,9 +11,6 @@
placeholder="请输入文章标题" placeholder="请输入文章标题"
/> />
</div> </div>
<a-button type="primary" @click="showDrawer"></a-button>
<a-button type="primary" @click="showAttachDrawer"></a-button>
</a-card>
<div id="editor"> <div id="editor">
<mavon-editor v-model="postToStage.originalContent" :boxShadow="false" :ishljs="true"/> <mavon-editor v-model="postToStage.originalContent" :boxShadow="false" :ishljs="true"/>
@ -116,7 +113,7 @@
@close="onAttachmentClose" @close="onAttachmentClose"
> >
<a-row type="flex" align="middle"> <a-row type="flex" align="middle">
<a-input-search placeholder="搜索附件" enterButton size="large"/> <a-input-search placeholder="搜索附件" enterButton/>
</a-row> </a-row>
<a-divider></a-divider> <a-divider></a-divider>
<a-row type="flex" align="middle"> <a-row type="flex" align="middle">
@ -205,13 +202,38 @@
</a-col> </a-col>
</a-row> </a-row>
</a-drawer> </a-drawer>
<div class="attachment-control">
<a-button @click="showUploadModal" type="primary">上传附件</a-button>
</div>
</a-drawer> </a-drawer>
<a-modal title="上传附件" v-model="uploadVisible" :footer="null">
<a-upload-dragger
name="file"
:multiple="true"
accept="image/*"
:customRequest="handleUpload"
@change="handleChange"
>
<p class="ant-upload-drag-icon">
<a-icon type="inbox"/>
</p>
<p class="ant-upload-text">点击选择文件或将文件拖拽到此处</p>
<p class="ant-upload-hint">支持单个或批量上传</p>
</a-upload-dragger>
</a-modal>
<footer-tool-bar :style="{ width: isSideMenu() && isDesktop() ? `calc(100% - ${sidebarOpened ? 256 : 80}px)` : '100%'}">
<a-button type="primary" @click="showDrawer"></a-button>
<a-button type="dashed" @click="showAttachDrawer" style="margin-left: 8px;">附件库</a-button>
</footer-tool-bar>
</div> </div>
</template> </template>
<script> <script>
import CategoryTree from './components/CategoryTree' import CategoryTree from './components/CategoryTree'
import { mavonEditor } from 'mavon-editor' import { mavonEditor } from 'mavon-editor'
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'
import tagApi from '@/api/tag' import tagApi from '@/api/tag'
@ -243,7 +265,8 @@ export default {
name: 'Editor', name: 'Editor',
components: { components: {
mavonEditor, mavonEditor,
CategoryTree CategoryTree,
FooterToolBar
}, },
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
data() { data() {
@ -257,6 +280,7 @@ export default {
selectAttachmentDrawerWidth: '460', selectAttachmentDrawerWidth: '460',
attachmentDrawerVisible: false, attachmentDrawerVisible: false,
selectAttachmentDrawerVisible: false, selectAttachmentDrawerVisible: false,
uploadVisible: false,
visible: false, visible: false,
childDrawerVisible: false, childDrawerVisible: false,
drawerWidth: '460', drawerWidth: '460',
@ -418,6 +442,50 @@ export default {
this.pagination.page = page this.pagination.page = page
this.pagination.size = pageSize this.pagination.size = pageSize
this.loadAttachments() 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} 文件上传失败`)
}
},
handleUpload(option) {
this.$log.debug('Uploading option', option)
const CancelToken = attachmentApi.CancelToken
const source = CancelToken.source()
const data = new FormData()
data.append('file', option.file)
attachmentApi
.upload(
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
)
.then(response => {
option.onSuccess(response, option.file)
this.loadAttachments()
})
.catch(error => {
option.onError(error, error.response)
})
return {
abort: () => {
source.cancel('Upload operation canceled by the user.')
}
}
},
showUploadModal() {
this.uploadVisible = true
} }
} }
} }
@ -426,6 +494,7 @@ export default {
<style scoped> <style scoped>
.v-note-wrapper { .v-note-wrapper {
z-index: 1000; z-index: 1000;
min-height: 540px;
} }
.ant-card { .ant-card {
@ -436,7 +505,8 @@ export default {
padding-bottom: 0; padding-bottom: 0;
} }
.post-control { .post-control,
.attachment-control {
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
width: 100%; width: 100%;