pref: optimize the layout of the post editing page. (halo-dev/console#286)

pull/3445/head
Ryan Wang 2021-01-24 14:00:18 +08:00 committed by GitHub
parent de929aa990
commit da3a315f8f
15 changed files with 170 additions and 99 deletions

View File

@ -21,8 +21,8 @@ export const asyncRouterMap = [
{ {
path: '/posts', path: '/posts',
name: 'Posts', name: 'Posts',
component: BlankLayout,
redirect: '/posts/list', redirect: '/posts/list',
component: PageView,
meta: { title: '文章', icon: 'form' }, meta: { title: '文章', icon: 'form' },
children: [ children: [
{ {
@ -33,10 +33,17 @@ export const asyncRouterMap = [
}, },
{ {
path: '/posts/write', path: '/posts/write',
name: 'PostEdit', name: 'PostWrite',
component: () => import('@/views/post/PostEdit'), component: () => import('@/views/post/PostEdit'),
meta: { title: '写文章', hiddenHeaderContent: false, keepAlive: false } meta: { title: '写文章', hiddenHeaderContent: false, keepAlive: false }
}, },
{
path: '/posts/edit',
name: 'PostEdit',
hidden: true,
component: () => import('@/views/post/PostEdit'),
meta: { title: '编辑文章', hiddenHeaderContent: false, keepAlive: false }
},
{ {
path: '/categories', path: '/categories',
name: 'CategoryList', name: 'CategoryList',
@ -56,7 +63,7 @@ export const asyncRouterMap = [
{ {
path: '/sheets', path: '/sheets',
name: 'Sheets', name: 'Sheets',
component: PageView, component: BlankLayout,
redirect: '/sheets/list', redirect: '/sheets/list',
meta: { title: '页面', icon: 'read' }, meta: { title: '页面', icon: 'read' },
children: [ children: [
@ -68,10 +75,17 @@ export const asyncRouterMap = [
}, },
{ {
path: '/sheets/write', path: '/sheets/write',
name: 'SheetEdit', name: 'SheetWrite',
component: () => import('@/views/sheet/SheetEdit'), component: () => import('@/views/sheet/SheetEdit'),
meta: { title: '新建页面', hiddenHeaderContent: false, keepAlive: false } meta: { title: '新建页面', hiddenHeaderContent: false, keepAlive: false }
}, },
{
path: '/sheets/edit',
name: 'SheetEdit',
hidden: true,
component: () => import('@/views/sheet/SheetEdit'),
meta: { title: '编辑页面', hiddenHeaderContent: false, keepAlive: false }
},
{ {
path: '/sheets/links', path: '/sheets/links',
name: 'LinkList', name: 'LinkList',

View File

@ -1,5 +1,6 @@
import Vue from 'vue' import Vue from 'vue'
import { import {
Affix,
Anchor, Anchor,
AutoComplete, AutoComplete,
Alert, Alert,
@ -54,6 +55,7 @@ import {
Space Space
} from 'ant-design-vue' } from 'ant-design-vue'
Vue.use(Affix)
Vue.use(Anchor) Vue.use(Anchor)
Vue.use(AutoComplete) Vue.use(AutoComplete)
Vue.use(Alert) Vue.use(Alert)

View File

@ -1,8 +1,33 @@
<template> <template>
<div :style="!$route.meta.hiddenHeaderContent ? 'margin: -24px -24px 0px;' : null"> <div :style="!$route.meta.hiddenHeaderContent ? 'margin: -24px -24px 0px;' : null">
<a-affix v-if="affix">
<div
class="page-header"
v-if="!$route.meta.hiddenHeaderContent"
>
<div class="page-header-index-wide">
<a-page-header
:title="title"
:sub-title="subTitle"
:breadcrumb="{ props: { routes:breadList } }"
>
<slot
name="extra"
slot="extra"
>
</slot>
<slot
name="footer"
slot="footer"
>
</slot>
</a-page-header>
</div>
</div>
</a-affix>
<div <div
class="page-header" class="page-header"
v-if="!$route.meta.hiddenHeaderContent" v-if="!$route.meta.hiddenHeaderContent && !affix"
> >
<div class="page-header-index-wide"> <div class="page-header-index-wide">
<a-page-header <a-page-header
@ -45,6 +70,10 @@ export default {
type: String, type: String,
default: null, default: null,
}, },
affix: {
type: Boolean,
default: false,
},
}, },
data() { data() {
return { return {

View File

@ -858,6 +858,10 @@ body {
top: 0; top: 0;
} }
.ant-affix {
z-index: 2000!important;
}
#nprogress { #nprogress {
pointer-events: none; pointer-events: none;
} }

View File

@ -14,7 +14,7 @@
:number="statisticsData.postCount" :number="statisticsData.postCount"
> >
<router-link <router-link
:to="{ name:'PostEdit' }" :to="{ name:'PostWrite' }"
slot="action" slot="action"
> >
<a-icon <a-icon

View File

@ -1,5 +1,6 @@
<template> <template>
<page-view <page-view
affix
:title="activatedTheme ? activatedTheme.name : '无'" :title="activatedTheme ? activatedTheme.name : '无'"
subTitle="当前启用" subTitle="当前启用"
> >

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <page-view>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col <a-col
:xl="10" :xl="10"
@ -225,10 +225,11 @@
@listenToSelect="handleSelectThumbnail" @listenToSelect="handleSelectThumbnail"
title="选择封面图" title="选择封面图"
/> />
</div> </page-view>
</template> </template>
<script> <script>
import { PageView } from '@/layouts'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import CategorySelectTree from './components/CategorySelectTree' import CategorySelectTree from './components/CategorySelectTree'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
@ -262,7 +263,7 @@ const columns = [
] ]
export default { export default {
components: { CategorySelectTree }, components: { PageView, CategorySelectTree },
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
data() { data() {
return { return {

View File

@ -1,5 +1,34 @@
<template> <template>
<div> <page-view
affix
:title="postToStage.title?postToStage.title:'新文章'"
>
<template slot="extra">
<a-space>
<ReactiveButton
type="danger"
@click="handleSaveDraft(false)"
@callback="draftSavederrored = false"
:loading="draftSaving"
:errored="draftSavederrored"
text="保存草稿"
loadedText="保存成功"
erroredText="保存失败"
></ReactiveButton>
<a-button
@click="handlePreview"
:loading="previewSaving"
>预览</a-button>
<a-button
type="primary"
@click="postSettingVisible = true"
>发布</a-button>
<a-button
type="dashed"
@click="attachmentDrawerVisible = true"
>附件库</a-button>
</a-space>
</template>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<div class="mb-4"> <div class="mb-4">
@ -41,34 +70,7 @@
/> />
<AttachmentDrawer v-model="attachmentDrawerVisible" /> <AttachmentDrawer v-model="attachmentDrawerVisible" />
</page-view>
<footer-tool-bar :style="{ width: isSideMenu() && isDesktop() ? `calc(100% - ${sidebarOpened ? 256 : 80}px)` : '100%' }">
<a-space>
<ReactiveButton
type="danger"
@click="handleSaveDraft(false)"
@callback="draftSavederrored = false"
:loading="draftSaving"
:errored="draftSavederrored"
text="保存草稿"
loadedText="保存成功"
erroredText="保存失败"
></ReactiveButton>
<a-button
@click="handlePreview"
:loading="previewSaving"
>预览</a-button>
<a-button
type="primary"
@click="postSettingVisible = true"
>发布</a-button>
<a-button
type="dashed"
@click="attachmentDrawerVisible = true"
>附件库</a-button>
</a-space>
</footer-tool-bar>
</div>
</template> </template>
<script> <script>
@ -78,8 +80,8 @@ import { datetimeFormat } from '@/utils/datetime'
import PostSettingDrawer from './components/PostSettingDrawer' import PostSettingDrawer from './components/PostSettingDrawer'
import AttachmentDrawer from '../attachment/components/AttachmentDrawer' import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
import FooterToolBar from '@/components/FooterToolbar'
import MarkdownEditor from '@/components/Editor/MarkdownEditor' import MarkdownEditor from '@/components/Editor/MarkdownEditor'
import { PageView } from '@/layouts'
// import RichTextEditor from '@/components/editor/RichTextEditor' // import RichTextEditor from '@/components/editor/RichTextEditor'
import postApi from '@/api/post' import postApi from '@/api/post'
@ -87,9 +89,9 @@ export default {
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: { components: {
PostSettingDrawer, PostSettingDrawer,
FooterToolBar,
AttachmentDrawer, AttachmentDrawer,
MarkdownEditor, MarkdownEditor,
PageView,
// RichTextEditor // RichTextEditor
}, },
data() { data() {

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <page-view>
<a-card <a-card
:bordered="false" :bordered="false"
:bodyStyle="{ padding: '16px' }" :bodyStyle="{ padding: '16px' }"
@ -78,7 +78,7 @@
</div> </div>
<div class="table-operator"> <div class="table-operator">
<router-link :to="{ name: 'PostEdit' }"> <router-link :to="{ name: 'PostWrite' }">
<a-button <a-button
type="primary" type="primary"
icon="plus" icon="plus"
@ -515,11 +515,12 @@
:id="selectedPost.id" :id="selectedPost.id"
@close="onPostCommentsClose" @close="onPostCommentsClose"
/> />
</div> </page-view>
</template> </template>
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import { PageView } from '@/layouts'
import PostSettingDrawer from './components/PostSettingDrawer' import PostSettingDrawer from './components/PostSettingDrawer'
import TargetCommentDrawer from '../comment/components/TargetCommentDrawer' import TargetCommentDrawer from '../comment/components/TargetCommentDrawer'
import TagSelect from './components/TagSelect' import TagSelect from './components/TagSelect'
@ -579,6 +580,7 @@ const columns = [
export default { export default {
name: 'PostList', name: 'PostList',
components: { components: {
PageView,
TagSelect, TagSelect,
CategoryTree, CategoryTree,
PostSettingDrawer, PostSettingDrawer,

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <page-view>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col <a-col
:xl="10" :xl="10"
@ -131,13 +131,15 @@
@listenToSelect="handleSelectThumbnail" @listenToSelect="handleSelectThumbnail"
title="选择封面图" title="选择封面图"
/> />
</div> </page-view>
</template> </template>
<script> <script>
import { PageView } from '@/layouts'
import tagApi from '@/api/tag' import tagApi from '@/api/tag'
export default { export default {
components: { PageView },
data() { data() {
return { return {
list: { list: {

View File

@ -1,5 +1,34 @@
<template> <template>
<div> <page-view
affix
:title="sheetToStage.title?sheetToStage.title:'新页面'"
>
<template slot="extra">
<a-space>
<ReactiveButton
type="danger"
@click="handleSaveDraft(false)"
@callback="draftSavederrored = false"
:loading="draftSaving"
:errored="draftSavederrored"
text="保存草稿"
loadedText="保存成功"
erroredText="保存失败"
></ReactiveButton>
<a-button
@click="handlePreview"
:loading="previewSaving"
>预览</a-button>
<a-button
type="primary"
@click="sheetSettingVisible = true"
>发布</a-button>
<a-button
type="dashed"
@click="attachmentDrawerVisible = true"
>附件库</a-button>
</a-space>
</template>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<div class="mb-4"> <div class="mb-4">
@ -37,39 +66,14 @@
/> />
<AttachmentDrawer v-model="attachmentDrawerVisible" /> <AttachmentDrawer v-model="attachmentDrawerVisible" />
<footer-tool-bar :style="{ width: isSideMenu() && isDesktop() ? `calc(100% - ${sidebarOpened ? 256 : 80}px)` : '100%'}"> </page-view>
<a-space>
<ReactiveButton
type="danger"
@click="handleSaveDraft(false)"
@callback="draftSavederrored = false"
:loading="draftSaving"
:errored="draftSavederrored"
text="保存草稿"
loadedText="保存成功"
erroredText="保存失败"
></ReactiveButton>
<a-button
@click="handlePreview"
:loading="previewSaving"
>预览</a-button>
<a-button
type="primary"
@click="sheetSettingVisible = true"
>发布</a-button>
<a-button
type="dashed"
@click="attachmentDrawerVisible = true"
>附件库</a-button>
</a-space>
</footer-tool-bar>
</div>
</template> </template>
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
// import { mapGetters } from 'vuex' // import { mapGetters } from 'vuex'
import { datetimeFormat } from '@/utils/datetime' import { datetimeFormat } from '@/utils/datetime'
import { PageView } from '@/layouts'
import SheetSettingDrawer from './components/SheetSettingDrawer' import SheetSettingDrawer from './components/SheetSettingDrawer'
import AttachmentDrawer from '../attachment/components/AttachmentDrawer' import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
import FooterToolBar from '@/components/FooterToolbar' import FooterToolBar from '@/components/FooterToolbar'
@ -79,10 +83,11 @@ import MarkdownEditor from '@/components/Editor/MarkdownEditor'
import sheetApi from '@/api/sheet' import sheetApi from '@/api/sheet'
export default { export default {
components: { components: {
PageView,
FooterToolBar, FooterToolBar,
AttachmentDrawer, AttachmentDrawer,
SheetSettingDrawer, SheetSettingDrawer,
MarkdownEditor MarkdownEditor,
// RichTextEditor // RichTextEditor
}, },
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
@ -95,7 +100,7 @@ export default {
contentChanges: 0, contentChanges: 0,
draftSaving: false, draftSaving: false,
draftSavederrored: false, draftSavederrored: false,
previewSaving: false previewSaving: false,
} }
}, },
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
@ -141,7 +146,7 @@ export default {
}, },
onCancel() { onCancel() {
next(false) next(false)
} },
}) })
} }
}, },
@ -162,12 +167,12 @@ export default {
if (newValue) { if (newValue) {
this.contentChanges++ this.contentChanges++
} }
} },
}, },
computed: { computed: {
temporaryContent() { temporaryContent() {
return this.sheetToStage.originalContent return this.sheetToStage.originalContent
} },
// ...mapGetters(['options']) // ...mapGetters(['options'])
}, },
methods: { methods: {
@ -276,7 +281,7 @@ export default {
}, },
onRefreshSheetMetasFromSetting(metas) { onRefreshSheetMetasFromSetting(metas) {
this.selectedMetas = metas this.selectedMetas = metas
} },
} },
} }
</script> </script>

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <page-view>
<a-row> <a-row>
<a-col :span="24"> <a-col :span="24">
<div class="card-container"> <div class="card-container">
@ -20,28 +20,34 @@
</div> </div>
</a-col> </a-col>
</a-row> </a-row>
</div> </page-view>
</template> </template>
<script> <script>
import { PageView } from '@/layouts'
import IndependentSheetList from './components/IndependentSheetList' import IndependentSheetList from './components/IndependentSheetList'
import CustomSheetList from './components/CustomSheetList' import CustomSheetList from './components/CustomSheetList'
export default { export default {
components: {
PageView,
IndependentSheetList,
CustomSheetList,
},
data() { data() {
const panes = [ const panes = [
{ title: '独立页面', icon: 'paper-clip', component: 'IndependentSheetList', key: 'independent' }, { title: '独立页面', icon: 'paper-clip', component: 'IndependentSheetList', key: 'independent' },
{ title: '自定义页面', icon: 'fork', component: 'CustomSheetList', key: 'custom' } { title: '自定义页面', icon: 'fork', component: 'CustomSheetList', key: 'custom' },
] ]
return { return {
activeKey: panes[0].key, activeKey: panes[0].key,
panes panes,
} }
}, },
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
// Get post id from query // Get post id from query
const activeKey = to.query.activeKey const activeKey = to.query.activeKey
next(vm => { next((vm) => {
if (activeKey) { if (activeKey) {
vm.activeKey = activeKey vm.activeKey = activeKey
} }
@ -52,14 +58,10 @@ export default {
handler: function(newVal, oldVal) { handler: function(newVal, oldVal) {
if (newVal) { if (newVal) {
const path = this.$router.history.current.path const path = this.$router.history.current.path
this.$router.push({ path, query: { activeKey: newVal } }).catch(err => err) this.$router.push({ path, query: { activeKey: newVal } }).catch((err) => err)
} }
} },
} },
}, },
components: {
IndependentSheetList,
CustomSheetList
}
} }
</script> </script>

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <page-view>
<a-row> <a-row>
<a-col :span="24"> <a-col :span="24">
<a-card <a-card
@ -255,10 +255,11 @@
/> />
<AttachmentDrawer v-model="attachmentDrawer.visible" /> <AttachmentDrawer v-model="attachmentDrawer.visible" />
</div> </page-view>
</template> </template>
<script> <script>
import { PageView } from '@/layouts'
import TargetCommentDrawer from '../../comment/components/TargetCommentDrawer' import TargetCommentDrawer from '../../comment/components/TargetCommentDrawer'
import AttachmentDrawer from '../../attachment/components/AttachmentDrawer' import AttachmentDrawer from '../../attachment/components/AttachmentDrawer'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
@ -267,7 +268,7 @@ import journalApi from '@/api/journal'
import optionApi from '@/api/option' import optionApi from '@/api/option'
export default { export default {
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: { TargetCommentDrawer, AttachmentDrawer }, components: { PageView, TargetCommentDrawer, AttachmentDrawer },
data() { data() {
return { return {
list: { list: {

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <page-view>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col <a-col
:xl="10" :xl="10"
@ -260,10 +260,11 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-modal> </a-modal>
</div> </page-view>
</template> </template>
<script> <script>
import { PageView } from '@/layouts'
import { mapActions } from 'vuex' import { mapActions } from 'vuex'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import optionApi from '@/api/option' import optionApi from '@/api/option'
@ -298,6 +299,9 @@ const columns = [
] ]
export default { export default {
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: {
PageView,
},
data() { data() {
return { return {
table: { table: {

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <page-view>
<a-row <a-row
:gutter="12" :gutter="12"
type="flex" type="flex"
@ -272,10 +272,11 @@
:drawerWidth="480" :drawerWidth="480"
/> />
</a-drawer> </a-drawer>
</div> </page-view>
</template> </template>
<script> <script>
import { PageView } from '@/layouts'
import { mapActions } from 'vuex' import { mapActions } from 'vuex'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import photoApi from '@/api/photo' import photoApi from '@/api/photo'
@ -284,6 +285,7 @@ import { datetimeFormat } from '@/utils/datetime'
export default { export default {
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: { PageView },
data() { data() {
return { return {
list: { list: {