Commit 2159b347 authored by 郭铭瑶's avatar 郭铭瑶 🤘

全局右侧模块切换功能

parent 3a4e25f6
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
v-for="btn in btns" v-for="btn in btns"
:key="btn.name" :key="btn.name"
:class="{ on: btn.type === curBtn }" :class="{ on: btn.type === curBtn }"
@click="curBtn = btn.type" @click="handleThemeSelect(btn.type)"
> >
{{ btn.name }} {{ btn.name }}
</div> </div>
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, onBeforeUnmount, ref } from 'vue' import { defineComponent, onBeforeUnmount, ref } from 'vue'
import { getDate, getTime } from '../util' import { getDate, getTime } from '../util'
import store from '@/store'
export default defineComponent({ export default defineComponent({
name: 'MyTitle', name: 'MyTitle',
...@@ -45,7 +46,11 @@ export default defineComponent({ ...@@ -45,7 +46,11 @@ export default defineComponent({
}, },
]) ])
const curBtn = ref('manage') const curBtn = ref('manage')
const handleThemeSelect = (type: string) => {
if (curBtn.value === type) return
curBtn.value = type
store.commit('SET_CURRENT_THEME', type)
}
timer.value = setInterval(() => { timer.value = setInterval(() => {
time.value = getTime() time.value = getTime()
}) })
...@@ -59,6 +64,7 @@ export default defineComponent({ ...@@ -59,6 +64,7 @@ export default defineComponent({
timer, timer,
btns, btns,
curBtn, curBtn,
handleThemeSelect,
} }
}, },
}) })
......
...@@ -3,8 +3,10 @@ import state from './state' ...@@ -3,8 +3,10 @@ import state from './state'
import mutations from './mutations' import mutations from './mutations'
import actions from './actions' import actions from './actions'
export type ThemeType = 'manage' | 'service' | 'safety'
export interface GlobalStateProps { export interface GlobalStateProps {
showLoading: boolean showLoading: boolean
curTheme: ThemeType
} }
export default createStore<GlobalStateProps>({ export default createStore<GlobalStateProps>({
state, state,
......
import { GlobalStateProps } from './index' import { GlobalStateProps, ThemeType } from './index'
export default { export default {
SET_LOADING(state: GlobalStateProps, val: boolean): void { SET_LOADING(state: GlobalStateProps, val: boolean): void {
state.showLoading = val state.showLoading = val
}, },
SET_CURRENT_THEME(state: GlobalStateProps, val: ThemeType): void {
state.curTheme = val
},
} }
import { GlobalStateProps } from './index'
export default { export default {
showLoading: false, showLoading: false,
} curTheme: 'manage',
} as GlobalStateProps
...@@ -10,19 +10,30 @@ ...@@ -10,19 +10,30 @@
<LeftComponent area="left" /> <LeftComponent area="left" />
</m-animate> </m-animate>
<m-animate enter="fadeInRight" leave="fadeOutRight"> <m-animate enter="fadeInRight" leave="fadeOutRight">
<RightComponent area="right" /> <PublicManage v-show="curTheme === 'manage'" area="right" />
</m-animate>
<m-animate enter="fadeInRight" leave="fadeOutRight">
<PublicService v-show="curTheme === 'service'" area="right" />
</m-animate> </m-animate>
</m-grid> </m-grid>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue' import { computed, defineComponent } from 'vue'
import LeftComponent from './left/left-component.vue' import LeftComponent from './left/left-component.vue'
import RightComponent from './right/right-component.vue' import PublicManage from './right/public-manage.vue'
import PublicService from './right/public-service.vue'
import store from '@/store'
export default defineComponent({ export default defineComponent({
name: 'Main', name: 'Main',
components: { LeftComponent, RightComponent }, components: { LeftComponent, PublicManage, PublicService },
setup() {
const curTheme = computed(() => store.state.curTheme)
return {
curTheme,
}
},
}) })
</script> </script>
......
...@@ -12,7 +12,6 @@ import { defineComponent } from 'vue' ...@@ -12,7 +12,6 @@ import { defineComponent } from 'vue'
export default defineComponent({ export default defineComponent({
name: 'BussinessEntry', name: 'BussinessEntry',
setup() {},
}) })
</script> </script>
......
<template> <template>
<div class="right-component"> <div class="public-manage">
<m-card mode="border"> <m-card mode="border">
<Complain /> <Complain />
</m-card> </m-card>
...@@ -23,7 +23,7 @@ import KeyTask from './key-task.vue' ...@@ -23,7 +23,7 @@ import KeyTask from './key-task.vue'
import BussinessEntry from './business-entry.vue' import BussinessEntry from './business-entry.vue'
export default defineComponent({ export default defineComponent({
name: 'RightComponent', name: 'PublicMange',
components: { Complain, Demand, Analysis, KeyTask, BussinessEntry }, components: { Complain, Demand, Analysis, KeyTask, BussinessEntry },
}) })
</script> </script>
...@@ -31,7 +31,7 @@ export default defineComponent({ ...@@ -31,7 +31,7 @@ export default defineComponent({
<style lang="stylus" scoped> <style lang="stylus" scoped>
@import '../../components/MyComponent/main.styl' @import '../../components/MyComponent/main.styl'
.right-component .public-manage
$full() $full()
display flex display flex
justify-content space-between justify-content space-between
......
<template>
<div class="public-service">
<m-card mode="border"> </m-card>
<m-card mode="border"> </m-card>
<m-card mode="border"> </m-card>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'PublicService',
setup() {},
})
</script>
<style lang="stylus" scoped>
@import '../../components/MyComponent/main.styl'
.public-service
$full()
display flex
justify-content space-between
>div
height 100%
width 33%
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment