样式修改

mapState简化
master
toesbieya 6 years ago
parent 12770dcaf7
commit 925036e6f8
  1. 2
      vue/src/assets/styles/index.scss
  2. 17
      vue/src/layout/components/Header.vue
  3. 17
      vue/src/layout/components/Main.vue
  4. 13
      vue/src/layout/components/Navbar/index.vue
  5. 1
      vue/src/layout/components/Navbar/style.scss
  6. 31
      vue/src/layout/components/Sidebar/components/Logo.vue
  7. 2
      vue/src/layout/components/Sidebar/components/SidebarItemContent.vue
  8. 24
      vue/src/layout/components/Sidebar/index.vue
  9. 14
      vue/src/layout/components/Sidebar/style.scss
  10. 2
      vue/src/layout/components/TagsView/index.vue
  11. 14
      vue/src/layout/index.vue
  12. 9
      vue/src/views/app/login/index.vue
  13. 8
      vue/src/views/example/developingTest/components/ApiSpeedTest.vue
  14. 6
      vue/src/views/example/developingTest/components/ImageCompressTest.vue
  15. 7
      vue/src/views/userCenter/components/UserCard.vue

@ -10,7 +10,7 @@ body {
height: 100%; height: 100%;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
} }
html { html {

@ -2,12 +2,12 @@
<header <header
:class="{'hide-header':hideHeader}" :class="{'hide-header':hideHeader}"
class="header-container" class="header-container"
@mouseenter="mouseOutside=false" @mouseenter="() => valueCtrl('mouseOutside',false)"
@mouseleave="mouseOutside=true" @mouseleave="() => valueCtrl('mouseOutside',true)"
> >
<v-navbar @menu-show="navbarMenuShow=$event"/> <v-navbar @menu-show="e => valueCtrl('navbarMenuShow',e)"/>
<tags-view v-if="useTagsView" @menu-show="tagsViewMenuShow=$event"/> <tags-view v-if="useTagsView" @menu-show="e => valueCtrl('tagsViewMenuShow',e)"/>
</header> </header>
</template> </template>
@ -31,10 +31,7 @@
}, },
computed: { computed: {
...mapState('setting', { ...mapState('setting', ['useTagsView', 'headerAutoHidden']),
useTagsView: state => state.useTagsView,
headerAutoHidden: state => state.headerAutoHidden
}),
hideHeader() { hideHeader() {
return this.mouseOutside return this.mouseOutside
@ -56,6 +53,10 @@
}, },
methods: { methods: {
valueCtrl(key, value) {
this[key] = value
},
moveEvent(e) { moveEvent(e) {
if (e.clientY <= 15) this.mouseOutside = false if (e.clientY <= 15) this.mouseOutside = false
}, },

@ -38,18 +38,11 @@
components: {KeepRouterViewAlive}, components: {KeepRouterViewAlive},
computed: { computed: {
...mapState('app', { ...mapState('app', ['scrollTop']),
scrollTop: state => state.scrollTop,
}), ...mapState('setting', ['showBackToTop']),
...mapState('setting', { ...mapState('tagsView', ['cachedViews', 'transitionName']),
showBackToTop: state => state.showBackToTop
}),
...mapState('tagsView', {
cachedViews: state => state.cachedViews,
transitionName: state => state.transitionName
}),
...mapState('iframe', { ...mapState('iframe', {
showIframe: state => state.show, showIframe: state => state.show,

@ -71,16 +71,9 @@
}, },
computed: { computed: {
...mapState('user', { ...mapState('user', ['avatar', 'name', 'prepare_logout']),
avatar: state => state.avatar,
name: state => state.name, ...mapState('setting', ['sidebarCollapse', 'showBreadcrumb']),
prepare_logout: state => state.prepare_logout
}),
...mapState('setting', {
sidebarCollapse: state => state.sidebarCollapse,
showBreadcrumb: state => state.showBreadcrumb
}),
showSystemMonitor() { showSystemMonitor() {
return auth('/system/monitor') return auth('/system/monitor')

@ -4,6 +4,7 @@
height: $nav-height; height: $nav-height;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
z-index: 9;
background: #fff; background: #fff;
box-shadow: 0 1px 4px rgba(0, 21, 41, .08); box-shadow: 0 1px 4px rgba(0, 21, 41, .08);

@ -1,25 +1,26 @@
<template> <script type="text/jsx">
<div :class="{'collapse':collapse}" class="sidebar-logo-container">
<router-link class="sidebar-logo-link" key="expand" to="/">
<img v-if="logo" :src="logo" class="sidebar-logo">
<h1 v-if="!collapse" class="sidebar-title">{{ title }}</h1>
</router-link>
</div>
</template>
<script>
import {sidebarLogoUrl, title} from '@/config' import {sidebarLogoUrl, title} from '@/config'
export default { export default {
name: 'SidebarLogo', name: 'SidebarLogo',
functional: true,
props: {collapse: Boolean}, props: {collapse: Boolean},
data() { render(h, context) {
return { const {collapse} = context.props
title,
logo: sidebarLogoUrl const logoClass = {'sidebar-logo-container': true, 'collapse': collapse}
}
return (
<div class={logoClass}>
<router-link class="sidebar-logo-link" to="/">
{sidebarLogoUrl && <img src={sidebarLogoUrl} class="sidebar-logo"/>}
{!collapse && <h1 class="sidebar-title">{title}</h1>}
</router-link>
</div>
)
} }
} }
</script> </script>

@ -17,7 +17,7 @@
if (icon) { if (icon) {
const isElIcon = icon.startsWith('el-icon-') const isElIcon = icon.startsWith('el-icon-')
iconComponent = isElIcon ? <i class={icon + ' svg-icon'}/> : <svg-icon icon={icon}/> iconComponent = isElIcon ? <i class={`svg-icon ${icon}`}/> : <svg-icon icon={icon}/>
} }
else iconComponent = <span class="svg-icon"/> else iconComponent = <span class="svg-icon"/>

@ -16,21 +16,11 @@
}, },
computed: { computed: {
...mapState('app', { ...mapState('app', ['device']),
device: state => state.device
}), ...mapState('resource', ['sidebarMenus']),
...mapState('resource', { ...mapState('setting', ['showLogo', 'sidebarCollapse', 'sidebarUniqueOpen', 'sidebarShowParent', 'sidebarAutoHidden']),
routes: state => state.sidebarMenus
}),
...mapState('setting', {
showLogo: state => state.showLogo,
sidebarCollapse: state => state.sidebarCollapse,
sidebarUniqueOpen: state => state.sidebarUniqueOpen,
sidebarShowParent: state => state.sidebarShowParent,
sidebarAutoHidden: state => state.sidebarAutoHidden
}),
activeMenu() { activeMenu() {
const route = this.$route const route = this.$route
@ -132,7 +122,7 @@
mode="vertical" mode="vertical"
on-select={this.select} on-select={this.select}
> >
{this.routes.map(route => ( {this.sidebarMenus.map(route => (
<sidebar-item <sidebar-item
key={route.path} key={route.path}
show-parent={this.sidebarShowParent} show-parent={this.sidebarShowParent}
@ -150,7 +140,7 @@
on-mouseleave={() => this.mouseOutside = true} on-mouseleave={() => this.mouseOutside = true}
> >
{this.showLogo && <logo collapse={this.collapse}/>} {this.showLogo && <logo collapse={this.collapse}/>}
{<el-scrollbar>{menu}</el-scrollbar>} {<el-scrollbar noresize native>{menu}</el-scrollbar>}
</aside> </aside>
) )
} }

@ -42,18 +42,18 @@ $iconSize: 17px;
line-height: $nav-height; line-height: $nav-height;
text-align: center; text-align: center;
& .sidebar-logo-link { .sidebar-logo-link {
height: 100%; height: 100%;
width: 100%; width: 100%;
& .sidebar-logo { .sidebar-logo {
width: 32px; width: 32px;
height: 32px; height: 32px;
vertical-align: middle; vertical-align: middle;
margin-right: 12px; margin-right: 12px;
} }
& .sidebar-title { .sidebar-title {
display: inline-block; display: inline-block;
margin: 0; margin: 0;
color: #fff; color: #fff;
@ -74,14 +74,6 @@ $iconSize: 17px;
.el-scrollbar { .el-scrollbar {
flex: 1; flex: 1;
> .el-scrollbar__wrap {
overflow-x: hidden !important;
}
> .el-scrollbar__bar.is-vertical {
right: 0;
}
} }
} }

@ -171,7 +171,7 @@
beforeDestroy() { beforeDestroy() {
//fade //fade
this.$store.commit('setting/transitionName', 'el-fade-in-linear') this.$store.commit('tagsView/transitionName', 'el-fade-in-linear')
}, },
mounted() { mounted() {

@ -30,19 +30,11 @@
components: {VMain, VSidebar, VHeader}, components: {VMain, VSidebar, VHeader},
computed: { computed: {
...mapState('app', { ...mapState('app', ['device', 'hasHeader']),
device: state => state.device,
hasHeader: state => state.hasHeader
}),
...mapState('setting', { ...mapState('setting', ['useTagsView', 'sidebarCollapse']),
useTagsView: state => state.useTagsView,
sidebarCollapse: state => state.sidebarCollapse
}),
...mapState('socket', { ...mapState('socket', ['online']),
online: state => state.online
}),
...mapState('user', { ...mapState('user', {
isLogin: state => !isEmpty(state.id) && !isEmpty(state.token) isLogin: state => !isEmpty(state.id) && !isEmpty(state.token)

@ -5,7 +5,7 @@
<div class="login-container" @click.stop> <div class="login-container" @click.stop>
<div class="title"> <div class="title">
{{title}} {{title}}
<set-animation :value="animation" custom-class="set-animation" @select="setAnimation"/> <set-animation :value="loginBackgroundAnimation" custom-class="set-animation" @select="setAnimation"/>
</div> </div>
<component :is="component"/> <component :is="component"/>
@ -34,10 +34,7 @@
}, },
computed: { computed: {
...mapState('app', { ...mapState('app', ['device', 'loginBackgroundAnimation']),
device: state => state.device,
animation: state => state.loginBackgroundAnimation
}),
component() { component() {
const formType = this.$route.path.substring(1) const formType = this.$route.path.substring(1)
@ -64,7 +61,7 @@
mounted() { mounted() {
// //
this.device !== 'mobile' && this.setAnimation(this.animation) this.device !== 'mobile' && this.setAnimation(this.loginBackgroundAnimation)
}, },
beforeDestroy() { beforeDestroy() {

@ -1,7 +1,7 @@
<template> <template>
<div class="tip-row"> <div class="tip-row">
测试接口返回速度<br> 测试接口返回速度<br>
当前响应次数{{times}}平均响应{{avg}}毫秒最长响应{{max}}毫秒 当前响应次数{{times}}响应时间{{cur}}毫秒平均响应{{avg}}毫秒最长响应{{max}}毫秒
<el-row> <el-row>
<el-button type="primary" @click="post">点我测试</el-button> <el-button type="primary" @click="post">点我测试</el-button>
<el-button plain @click="reset">重置</el-button> <el-button plain @click="reset">重置</el-button>
@ -18,6 +18,7 @@
return { return {
loading: false, loading: false,
times: 0, times: 0,
cur: 0,
avg: 0, avg: 0,
max: 0, max: 0,
total: 0 total: 0
@ -31,17 +32,20 @@
request request
.post('/test/test') .post('/test/test')
.finally(() => { .finally(() => {
const end = performance.now() - start const end = (performance.now() - start)
if (end > this.max) this.max = end if (end > this.max) this.max = end
this.cur = end.toFixed(2)
this.total += end this.total += end
this.times++ this.times++
this.avg = (this.total / this.times).toFixed(2) this.avg = (this.total / this.times).toFixed(2)
this.loading = false this.loading = false
}) })
}, },
reset() { reset() {
if (this.loading) return if (this.loading) return
this.times = 0 this.times = 0
this.cur = 0
this.avg = 0 this.avg = 0
this.max = 0 this.max = 0
this.total = 0 this.total = 0

@ -31,6 +31,7 @@
</el-row> </el-row>
</div> </div>
</div> </div>
<div class="tip-row"> <div class="tip-row">
测试纯前端png图片压缩效率 测试纯前端png图片压缩效率
<a href="https://github.com/psych0der/pngquantjs" target="_blank">使用pngquant</a> <a href="https://github.com/psych0der/pngquantjs" target="_blank">使用pngquant</a>
@ -118,6 +119,7 @@
this[type].input.size = file.size this[type].input.size = file.size
this[type].input.src = window.URL.createObjectURL(file) this[type].input.src = window.URL.createObjectURL(file)
}, },
cancel(type) { cancel(type) {
if (this[type].loading) return if (this[type].loading) return
window.URL.revokeObjectURL(this[type].input.src) window.URL.revokeObjectURL(this[type].input.src)
@ -130,6 +132,7 @@
this[type].totalCost = 0 this[type].totalCost = 0
this[type].calcCost = 0 this[type].calcCost = 0
}, },
compress(type) { compress(type) {
if (this[type].loading) return if (this[type].loading) return
if (!this[type].input.file) return elError(`请选择一张${type}图片`) if (!this[type].input.file) return elError(`请选择一张${type}图片`)
@ -143,18 +146,21 @@
} }
reader.readAsArrayBuffer(this[type].input.file) reader.readAsArrayBuffer(this[type].input.file)
}, },
compressJPG(uint8Array, start) { compressJPG(uint8Array, start) {
import('@/plugin/imageCompress/cjpeg') import('@/plugin/imageCompress/cjpeg')
.then(_ => _.default(uint8Array, this.jpg.quality)) .then(_ => _.default(uint8Array, this.jpg.quality))
.then(({data, time}) => this.compressSuccess({type: 'jpg', start, data, time})) .then(({data, time}) => this.compressSuccess({type: 'jpg', start, data, time}))
.finally(() => this.jpg.loading = false) .finally(() => this.jpg.loading = false)
}, },
compressPNG(uint8Array, start) { compressPNG(uint8Array, start) {
import('@/plugin/imageCompress/pngquant') import('@/plugin/imageCompress/pngquant')
.then(_ => _.default(uint8Array, this.png.quality, this.png.speed)) .then(_ => _.default(uint8Array, this.png.quality, this.png.speed))
.then(({data, time}) => this.compressSuccess({type: 'png', start, data, time})) .then(({data, time}) => this.compressSuccess({type: 'png', start, data, time}))
.finally(() => this.png.loading = false) .finally(() => this.png.loading = false)
}, },
compressSuccess({type, start, data, time}) { compressSuccess({type, start, data, time}) {
this[type].totalCost = (window.performance.now() - start).toFixed(2) this[type].totalCost = (window.performance.now() - start).toFixed(2)
this[type].calcCost = time.toFixed(2) this[type].calcCost = time.toFixed(2)

@ -36,12 +36,7 @@
}, },
computed: { computed: {
...mapState('user', { ...mapState('user', ['name', 'avatar', 'role_name', 'admin'])
name: state => state.name,
avatar: state => state.avatar,
role_name: state => state.role_name,
admin: state => state.admin
})
} }
} }
</script> </script>

Loading…
Cancel
Save