Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

pref: optimize the layout of the post editing page. #286

Merged
merged 1 commit into from
Jan 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/config/router.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const asyncRouterMap = [
{
path: '/posts',
name: 'Posts',
component: BlankLayout,
redirect: '/posts/list',
component: PageView,
meta: { title: '文章', icon: 'form' },
children: [
{
Expand All @@ -33,10 +33,17 @@ export const asyncRouterMap = [
},
{
path: '/posts/write',
name: 'PostEdit',
name: 'PostWrite',
component: () => import('@/views/post/PostEdit'),
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',
name: 'CategoryList',
Expand All @@ -56,7 +63,7 @@ export const asyncRouterMap = [
{
path: '/sheets',
name: 'Sheets',
component: PageView,
component: BlankLayout,
redirect: '/sheets/list',
meta: { title: '页面', icon: 'read' },
children: [
Expand All @@ -68,10 +75,17 @@ export const asyncRouterMap = [
},
{
path: '/sheets/write',
name: 'SheetEdit',
name: 'SheetWrite',
component: () => import('@/views/sheet/SheetEdit'),
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',
name: 'LinkList',
Expand Down
2 changes: 2 additions & 0 deletions src/core/lazy_lib/components_use.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import {
Affix,
Anchor,
AutoComplete,
Alert,
Expand Down Expand Up @@ -54,6 +55,7 @@ import {
Space
} from 'ant-design-vue'

Vue.use(Affix)
Vue.use(Anchor)
Vue.use(AutoComplete)
Vue.use(Alert)
Expand Down
31 changes: 30 additions & 1 deletion src/layouts/PageView.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
<template>
<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
class="page-header"
v-if="!$route.meta.hiddenHeaderContent"
v-if="!$route.meta.hiddenHeaderContent && !affix"
>
<div class="page-header-index-wide">
<a-page-header
Expand Down Expand Up @@ -45,6 +70,10 @@ export default {
type: String,
default: null,
},
affix: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand Down
4 changes: 4 additions & 0 deletions src/styles/global.less
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,10 @@ body {
top: 0;
}

.ant-affix {
z-index: 2000!important;
}

#nprogress {
pointer-events: none;
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:number="statisticsData.postCount"
>
<router-link
:to="{ name:'PostEdit' }"
:to="{ name:'PostWrite' }"
slot="action"
>
<a-icon
Expand Down
1 change: 1 addition & 0 deletions src/views/interface/ThemeList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<page-view
affix
:title="activatedTheme ? activatedTheme.name : '无'"
subTitle="当前启用"
>
Expand Down
7 changes: 4 additions & 3 deletions src/views/post/CategoryList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<page-view>
<a-row :gutter="12">
<a-col
:xl="10"
Expand Down Expand Up @@ -225,10 +225,11 @@
@listenToSelect="handleSelectThumbnail"
title="选择封面图"
/>
</div>
</page-view>
</template>

<script>
import { PageView } from '@/layouts'
import { mixin, mixinDevice } from '@/utils/mixin.js'
import CategorySelectTree from './components/CategorySelectTree'
import categoryApi from '@/api/category'
Expand Down Expand Up @@ -262,7 +263,7 @@ const columns = [
]

export default {
components: { CategorySelectTree },
components: { PageView, CategorySelectTree },
mixins: [mixin, mixinDevice],
data() {
return {
Expand Down
64 changes: 33 additions & 31 deletions src/views/post/PostEdit.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
<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-col :span="24">
<div class="mb-4">
Expand Down Expand Up @@ -41,34 +70,7 @@
/>

<AttachmentDrawer v-model="attachmentDrawerVisible" />

<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>
</page-view>
</template>

<script>
Expand All @@ -78,18 +80,18 @@ import { datetimeFormat } from '@/utils/datetime'

import PostSettingDrawer from './components/PostSettingDrawer'
import AttachmentDrawer from '../attachment/components/AttachmentDrawer'
import FooterToolBar from '@/components/FooterToolbar'
import MarkdownEditor from '@/components/Editor/MarkdownEditor'
import { PageView } from '@/layouts'
// import RichTextEditor from '@/components/editor/RichTextEditor'

import postApi from '@/api/post'
export default {
mixins: [mixin, mixinDevice],
components: {
PostSettingDrawer,
FooterToolBar,
AttachmentDrawer,
MarkdownEditor,
PageView,
// RichTextEditor
},
data() {
Expand Down
8 changes: 5 additions & 3 deletions src/views/post/PostList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<page-view>
<a-card
:bordered="false"
:bodyStyle="{ padding: '16px' }"
Expand Down Expand Up @@ -78,7 +78,7 @@
</div>

<div class="table-operator">
<router-link :to="{ name: 'PostEdit' }">
<router-link :to="{ name: 'PostWrite' }">
<a-button
type="primary"
icon="plus"
Expand Down Expand Up @@ -515,11 +515,12 @@
:id="selectedPost.id"
@close="onPostCommentsClose"
/>
</div>
</page-view>
</template>

<script>
import { mixin, mixinDevice } from '@/utils/mixin.js'
import { PageView } from '@/layouts'
import PostSettingDrawer from './components/PostSettingDrawer'
import TargetCommentDrawer from '../comment/components/TargetCommentDrawer'
import TagSelect from './components/TagSelect'
Expand Down Expand Up @@ -579,6 +580,7 @@ const columns = [
export default {
name: 'PostList',
components: {
PageView,
TagSelect,
CategoryTree,
PostSettingDrawer,
Expand Down
6 changes: 4 additions & 2 deletions src/views/post/TagList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<page-view>
<a-row :gutter="12">
<a-col
:xl="10"
Expand Down Expand Up @@ -131,13 +131,15 @@
@listenToSelect="handleSelectThumbnail"
title="选择封面图"
/>
</div>
</page-view>
</template>

<script>
import { PageView } from '@/layouts'
import tagApi from '@/api/tag'

export default {
components: { PageView },
data() {
return {
list: {
Expand Down
Loading