修改: 调整布局,解决全局动画导致的界面抖动问题;

This commit is contained in:
iczer 2020-06-18 18:41:08 +08:00
parent d4d46eeaae
commit a90fa8d106
14 changed files with 122 additions and 64 deletions

View File

@ -18,5 +18,7 @@ export default {
} }
</script> </script>
<style lang="less"> <style lang="less" scoped>
#id{
}
</style> </style>

View File

@ -1,8 +1,7 @@
<template> <template>
<div class="exception"> <div class="exception-page" :style="{minHeight: layoutMinHeight - 64 + 'px'}">
<div class="img"> <div class="img">
<img :src="config[type].img" /> <img :src="config[type].img" />
<!--<div class="ele" :style="{backgroundImage: `url(${config[type].img})`}"/>-->
</div> </div>
<div class="content"> <div class="content">
<h1>{{config[type].title}}</h1> <h1>{{config[type].title}}</h1>
@ -24,17 +23,18 @@ export default {
return { return {
config: Config config: Config
} }
} },
inject: ['layoutMinHeight']
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.exception{ .exception-page{
min-height: 500px; border-radius: 4px;
height: 80%; display: flex;
justify-content: center;
align-items: center; align-items: center;
text-align: center; background-color: white;
margin-top: 150px;
.img{ .img{
display: inline-block; display: inline-block;
padding-right: 52px; padding-right: 52px;
@ -46,7 +46,6 @@ export default {
} }
.content{ .content{
display: inline-block; display: inline-block;
flex: auto;
h1{ h1{
color: #434e59; color: #434e59;
font-size: 72px; font-size: 72px;

View File

@ -7,7 +7,7 @@
</img-checkbox-group> </img-checkbox-group>
</setting-item> </setting-item>
<setting-item title="主题色"> <setting-item title="主题色">
<color-checkbox-group @change="onColorChange" :defaultValues="[0]" :multiple="false"> <color-checkbox-group @change="onColorChange" :defaultValues="[5]" :multiple="false">
<color-checkbox v-for="(color, index) in colors" :key="index" :color="color" :value="index" /> <color-checkbox v-for="(color, index) in colors" :key="index" :color="color" :value="index" />
</color-checkbox-group> </color-checkbox-group>
</setting-item> </setting-item>
@ -96,6 +96,11 @@ export default {
colors: ['#f5222d', '#fa541c', '#faad14', '#13c2c2', '#52c41a', '#1d92ff', '#2f54eb', '#722ed1'], colors: ['#f5222d', '#fa541c', '#faad14', '#13c2c2', '#52c41a', '#1d92ff', '#2f54eb', '#722ed1'],
} }
}, },
watch: {
animate(){
this.direction = 0
}
},
computed: { computed: {
animateCfg() { animateCfg() {
return this.animates[this.animate] return this.animates[this.animate]

View File

@ -51,9 +51,8 @@
direction = animate.directions[0] direction = animate.directions[0]
} else { } else {
direction = animate.directions.find(item => item == this.direction) direction = animate.directions.find(item => item == this.direction)
direction = (direction == undefined || direction === 'default') ? '' : direction
} }
window.console.log(direction) direction = (direction == undefined || direction === 'default') ? '' : direction
if (direction != '') { if (direction != '') {
direction = isLeave && this.reverse ? this.reversePosition(direction, animate.directions) : direction direction = isLeave && this.reverse ? this.reversePosition(direction, animate.directions) : direction
direction = direction[0].toUpperCase() + direction.substring(1) direction = direction[0].toUpperCase() + direction.substring(1)

View File

@ -1,5 +1,5 @@
<template> <template>
<a-layout> <a-layout class="global-layout">
<drawer v-if="isMobile" :openDrawer="collapsed" @change="onDrawerChange"> <drawer v-if="isMobile" :openDrawer="collapsed" @change="onDrawerChange">
<sider-menu :theme="theme" :menuData="menuData" :collapsed="false" :collapsible="false" @menuSelect="onMenuSelect"/> <sider-menu :theme="theme" :menuData="menuData" :collapsed="false" :collapsible="false" @menuSelect="onMenuSelect"/>
</drawer> </drawer>
@ -10,9 +10,9 @@
</div> </div>
<setting /> <setting />
</drawer> </drawer>
<a-layout> <a-layout class="global-layout-main">
<global-header :menuData="menuData" :collapsed="collapsed" @toggleCollapse="toggleCollapse"/> <global-header :menuData="menuData" :collapsed="collapsed" @toggleCollapse="toggleCollapse"/>
<a-layout-content :style="{minHeight: minHeight, padding: '24px 24px 0', position: 'relative'}"> <a-layout-content class="global-layout-content" :style="{minHeight: minHeight, padding: '24px 24px 0', position: 'relative'}">
<slot></slot> <slot></slot>
</a-layout-content> </a-layout-content>
<a-layout-footer style="padding: 0px"> <a-layout-footer style="padding: 0px">
@ -29,7 +29,7 @@ import Drawer from '../components/tool/Drawer'
import SiderMenu from '../components/menu/SiderMenu' import SiderMenu from '../components/menu/SiderMenu'
import Setting from '../components/setting/Setting' import Setting from '../components/setting/Setting'
const minHeight = window.innerHeight - 64 - 24 - 122 const minHeight = window.innerHeight - 64 - 122
let menuData = [] let menuData = []
@ -44,6 +44,11 @@ export default {
showSetting: false showSetting: false
} }
}, },
provide() {
return{
layoutMinHeight: minHeight,
}
},
computed: { computed: {
isMobile () { isMobile () {
return this.$store.state.setting.isMobile return this.$store.state.setting.isMobile
@ -82,14 +87,38 @@ export default {
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.setting{ .global-layout{
background-color: #1890ff; height: 100vh;
color: #fff; .global-layout-main{
border-radius: 5px 0 0 5px; height: 100vh;
line-height: 40px; overflow-y: scroll;
font-size: 22px; scrollbar-color: @primary-color @primary-2;
width: 40px; scrollbar-width: thin;
height: 40px; &::-webkit-scrollbar{
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15); width: 3px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 3px;
background: @primary;
}
&::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 1px rgba(0,0,0,0);
border-radius: 3px;
background: @primary-3;
}
}
.global-layout-content{
}
.setting{
background-color: #1890ff;
color: #fff;
border-radius: 5px 0 0 5px;
line-height: 40px;
font-size: 22px;
width: 40px;
height: 40px;
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
}
} }
</style> </style>

View File

@ -1,25 +1,25 @@
<template> <template>
<global-layout> <global-layout>
<contextmenu :itemList="menuItemList" :visible.sync="menuVisible" @select="onMenuSelect" /> <contextmenu :itemList="menuItemList" :visible.sync="menuVisible" @select="onMenuSelect" />
<a-tabs <a-tabs
@contextmenu.native="e => onContextmenu(e)" @contextmenu.native="e => onContextmenu(e)"
v-if="multiPage" v-if="multiPage"
:active-key="activePage" :active-key="activePage"
style="margin-top: -8px; margin-bottom: 8px" style="margin-top: -8px; margin-bottom: 8px"
:hide-add="true" :hide-add="true"
type="editable-card" type="editable-card"
@change="changePage" @change="changePage"
@edit="editPage"> @edit="editPage">
<a-tab-pane :key="page.fullPath" v-for="page in pageList"> <a-tab-pane :key="page.fullPath" v-for="page in pageList">
<span slot="tab" :pagekey="page.fullPath">{{page.name}}</span> <span slot="tab" :pagekey="page.fullPath">{{page.name}}</span>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
<page-toggle-transition :animate="animate.name" :direction="animate.direction"> <page-toggle-transition :animate="animate.name" :direction="animate.direction">
<keep-alive v-if="multiPage"> <keep-alive v-if="multiPage">
<router-view /> <router-view />
</keep-alive> </keep-alive>
<router-view v-else /> <router-view v-else />
</page-toggle-transition> </page-toggle-transition>
</global-layout> </global-layout>
</template> </template>
@ -159,6 +159,9 @@ export default {
} }
</script> </script>
<style scoped> <style scoped lang="less">
.menu-view{
.menu-view-content{
}
}
</style> </style>

View File

@ -1,5 +1,5 @@
<template> <template>
<div style="margin: -24px -24px 0px"> <div class="page-layout">
<page-header :breadcrumb="breadcrumb" :title="title" :logo="logo" :avatar="avatar"> <page-header :breadcrumb="breadcrumb" :title="title" :logo="logo" :avatar="avatar">
<slot name="action" slot="action"></slot> <slot name="action" slot="action"></slot>
<slot slot="content" name="headerContent"></slot> <slot slot="content" name="headerContent"></slot>
@ -50,6 +50,9 @@ export default {
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.page-header{
margin: -24px -24px 0;
}
.link{ .link{
margin-top: 16px; margin-top: 16px;
line-height: 24px; line-height: 24px;
@ -64,11 +67,11 @@ export default {
} }
.page-content{ .page-content{
position: relative; position: relative;
padding: 24px 24px 0;
&.side{ &.side{
padding: 24px 24px 0;
} }
&.head{ &.head{
padding: 24px 0 0; margin: 0 auto;
max-width: 1400px; max-width: 1400px;
} }
} }

View File

@ -9,6 +9,8 @@ export default {
} }
</script> </script>
<style scoped> <style scoped lang="less">
.exception-page{
margin: -24px 0 0;
}
</style> </style>

View File

@ -9,6 +9,8 @@ export default {
} }
</script> </script>
<style scoped> <style scoped lang="less">
.exception-page{
margin: -24px 0 0;
}
</style> </style>

View File

@ -1,5 +1,5 @@
<template> <template>
<exception-page type="500" /> <exception-page type="500" />
</template> </template>
<script> <script>
@ -9,6 +9,8 @@ export default {
} }
</script> </script>
<style scoped> <style scoped lang="less">
.exception-page{
margin: -24px 0 0;
}
</style> </style>

View File

@ -11,7 +11,7 @@ export default {
multiPage: true, multiPage: true,
animates: animates, animates: animates,
animate: { animate: {
name: 'back', name: 'bounce',
direction: 'left' direction: 'left'
} }
}, },

View File

@ -1,4 +1,16 @@
@import "../theme"; @import '~ant-design-vue/lib/style/color/colors.less';
@primary: #1890ff;
@primary-color: @primary; @primary-color: @primary;
@processing-color: @primary; @processing-color: @primary;
@link-color: @primary; @link-color: @primary;
@primary-1: color(~`colorPalette('@{primary}', 1) `);
@primary-2: color(~`colorPalette('@{primary}', 2) `);
@primary-3: color(~`colorPalette('@{primary}', 3) `);
@primary-4: color(~`colorPalette('@{primary}', 4) `);
@primary-5: color(~`colorPalette('@{primary}', 5) `);
@primary-6: color(~`colorPalette('@{primary}', 6) `);
@primary-7: color(~`colorPalette('@{primary}', 7) `);
@primary-8: color(~`colorPalette('@{primary}', 8) `);
@primary-9: color(~`colorPalette('@{primary}', 9) `);
@primary-10: color(~`colorPalette('@{primary}', 10) `);

View File

@ -1 +1 @@
@primary: #1890ff; @import "./default/index";

View File

@ -1,14 +1,14 @@
// let path = require('path') let path = require('path')
const ThemeColorReplacer = require('webpack-theme-color-replacer') const ThemeColorReplacer = require('webpack-theme-color-replacer')
const getThemeColors = require('./src/utils/themeUtil').getThemeColors const getThemeColors = require('./src/utils/themeUtil').getThemeColors
const themeColor = require('./src/config').themeColor const themeColor = require('./src/config').themeColor
module.exports = { module.exports = {
// transpileDependencies: ['webpack-theme-color-replacer'],
pluginOptions: { pluginOptions: {
'style-resources-loader': { 'style-resources-loader': {
preProcessor: 'less', preProcessor: 'less',
// patterns: [path.resolve(__dirname, "./src/theme/theme.less")] patterns: [path.resolve(__dirname, "./src/theme/theme.less")],
patterns: []
} }
}, },
configureWebpack: config => { configureWebpack: config => {