Merge pull request 'app-main增加移动端适配padding' (#2) from soul2/views into develop

Reviewed-on: soul2-demo-module/cn-soul2-web#2
develop
soul2 3 years ago
commit f000c09256
  1. 17
      src/layout/components/navbar/index.vue
  2. 15
      src/store/getters.js
  3. 6
      src/store/index.js
  4. 19
      src/store/modules/screen.js
  5. 24
      src/views/home/index.vue
  6. 26
      src/views/sodemo/index.vue
  7. 16
      src/views/soui/index.vue

@ -9,7 +9,7 @@
:collapse-transition="false" :collapse-transition="false"
mode="horizontal" mode="horizontal"
:router="true" :router="true"
:style="menuStyle" :style="screenPadding"
> >
<el-col :xs="menuItemSize.xs" :sm="menuItemSize.sm" :md="menuItemSize.md" :lg="menuItemSize.lg" <el-col :xs="menuItemSize.xs" :sm="menuItemSize.sm" :md="menuItemSize.md" :lg="menuItemSize.lg"
:xl="menuItemSize.xl" :xl="menuItemSize.xl"
@ -42,7 +42,7 @@ export default {
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
'routes' 'routes',
]), ]),
menuItemSize() { menuItemSize() {
return { return {
@ -53,12 +53,19 @@ export default {
xl: 2 xl: 2
} }
}, },
menuStyle() { screenPadding() {
if (this.screenWidth >= 600) { if (this.screenWidth >= 600) {
if (this.screenWidth >= 1000) {
return { return {
paddingLeft: '15%', paddingLeft: '15%',
paddingRight: '15%' paddingRight: '15%'
} }
} else {
return {
paddingLeft: '5%',
paddingRight: '5%'
}
}
} else { } else {
return {} return {}
} }
@ -79,6 +86,7 @@ export default {
mounted() { mounted() {
window.onresize = () => { window.onresize = () => {
this.screenWidth = document.body.clientWidth this.screenWidth = document.body.clientWidth
this.$store.commit('screen/UPDATE_SCREEN_WIDTH', document.body.clientWidth)
} }
// console.log('routes -> ', this.routes) // console.log('routes -> ', this.routes)
}, },
@ -88,11 +96,12 @@ export default {
if (!this.timer) { if (!this.timer) {
// screenWidthdatascreenWidth // screenWidthdatascreenWidth
this.screenWidth = newValue; this.screenWidth = newValue;
this.$store.commit('screen/UPDATE_SCREEN_WIDTH', newValue)
this.timer = true; this.timer = true;
setTimeout(() => { setTimeout(() => {
//console.log(this.screenWidth); //console.log(this.screenWidth);
this.timer = false; this.timer = false;
}, 400); }, 1250);
} }
} }
}, },

@ -1,5 +1,18 @@
const getters = { const getters = {
routes: state => state.menu.routes routes: state => state.menu.routes,
screenWidth: state => state.screen.screenWidth,
screenPadding: state => {
let width = state.screen.screenWidth
if (width >= 600) {
if (width >= 1000) {
return {paddingLeft: '15%', paddingRight: '15%'}
} else {
return {paddingLeft: '5%', paddingRight: '5%'}
}
} else {
return {}
}
}
} }
export default getters export default getters

@ -1,13 +1,15 @@
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import getters from "@/store/getters"; import getters from "@/store/getters";
import menu from "@/store/modules/menu" import menu from "@/store/modules/menu";
import screen from "@/store/modules/screen";
Vue.use(Vuex) Vue.use(Vuex)
const store = new Vuex.Store({ const store = new Vuex.Store({
modules: { modules: {
menu menu,
screen
}, },
getters getters
}) })

@ -0,0 +1,19 @@
const state = {
screenWidth: document.body.clientWidth
}
const mutations = {
UPDATE_SCREEN_WIDTH(state, value) {
state.screenWidth = value
console.log('run update screen width')
}
}
const actions = {}
export default {
namespaced: true,
state,
mutations,
actions
}

@ -1,10 +1,10 @@
<template> <template>
<div id="home"> <div id="home" :style="screenPadding">
<!-- 这是一个首页 <br>--> <!-- 这是一个首页 <br>-->
<!-- 如你所见它现在还什么都没有但马上就会有了 <br>--> <!-- 如你所见它现在还什么都没有但马上就会有了 <br>-->
<!-- By Soul2--> <!-- By Soul2-->
<el-card shadow="always"> <el-card shadow="always">
<el-collapse :accordion="accordion" v-model="expand" style="text-align: left"> <el-collapse :accordion="false" v-model="expand" style="text-align: left">
<el-collapse-item name="openShow"> <el-collapse-item name="openShow">
<template slot="title"> <template slot="title">
关于灵魂演示 关于灵魂演示
@ -59,7 +59,7 @@
</el-link> </el-link>
一次性下载所有演示地图也可以通过点击下方各个按钮以你希望的方式下载你所需要的特定演示地图 一次性下载所有演示地图也可以通过点击下方各个按钮以你希望的方式下载你所需要的特定演示地图
</p> </p>
<div style="margin-top: 7px;"> <div id="dl-btn">
<el-button size="mini" class="el-icon-position" <el-button size="mini" class="el-icon-position"
@click="goto('https://wow8.org/soul-demo/')" @click="goto('https://wow8.org/soul-demo/')"
> >
@ -104,13 +104,18 @@
<script> <script>
import {mapGetters} from "vuex";
export default { export default {
name: "Home", name: "Home",
components: {}, components: {},
computed: { computed: {
...mapGetters([
"screenPadding"
]),
expand() { expand() {
return ['openShow', 'soui'] return ['openShow', 'soui']
} },
}, },
methods: { methods: {
goto(where) { goto(where) {
@ -121,14 +126,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
@import "~@/style/layout/index.scss"; #dl-btn .el-button {
margin-top: 7px;
#home {
padding-left: 15%;
padding-right: 15%;
}
a {
} }
</style> </style>

@ -1,5 +1,5 @@
<template> <template>
<div id="so-demo" style="padding: 0 15%;"> <div id="so-demo" :style="screenPadding">
<el-card shadow="always"> <el-card shadow="always">
<div slot="header"> <div slot="header">
关于灵魂演示 关于灵魂演示
@ -50,7 +50,7 @@
</el-link> </el-link>
一次性下载所有演示地图也可以通过点击下方各个按钮以你希望的方式下载你所需要的特定演示地图 一次性下载所有演示地图也可以通过点击下方各个按钮以你希望的方式下载你所需要的特定演示地图
</p> </p>
<div style="margin-top: 7px;"> <div id="goto-btn">
<el-button size="mini" class="el-icon-position" <el-button size="mini" class="el-icon-position"
@click="goto('https://wow8.org/soul-demo/')" @click="goto('https://wow8.org/soul-demo/')"
> >
@ -92,11 +92,29 @@
</template> </template>
<script> <script>
import {mapGetters} from "vuex";
export default { export default {
name: "SoDemo" name: "SoDemo",
computed: {
...mapGetters([
"screenPadding"
]),
},
methods: {
goto(where) {
location.href = where
}
}
} }
</script> </script>
<style scoped> <style scoped lang="scss">
#goto-btn {
text-align: left;
}
#goto-btn .el-button {
margin-top: 7px;
}
</style> </style>

@ -1,5 +1,5 @@
<template> <template>
<div id="soui" style="text-align: left;padding: 0 15%;"> <div id="soui" style="text-align: left;" :style="screenPadding">
<el-card shadow="always"> <el-card shadow="always">
<div class="title" slot="header" style="text-align: center"> <div class="title" slot="header" style="text-align: center">
关于SoUI 关于SoUI
@ -45,8 +45,20 @@
</template> </template>
<script> <script>
import {mapGetters} from "vuex";
export default { export default {
name: "SoUi" name: "SoUi",
computed: {
...mapGetters([
"screenPadding"
]),
},
methods: {
goto(where) {
location.href = where
}
}
} }
</script> </script>

Loading…
Cancel
Save