<template>
  <van-config-provider :theme="theme">
    <div class="mobile-home">
      <router-view/>

      <van-tabbar route v-model="active">
        <van-tabbar-item to="/mobile/index" name="home" icon="home-o">首页</van-tabbar-item>
        <van-tabbar-item to="/mobile/chat" name="chat" icon="chat-o">对话</van-tabbar-item>
        <van-tabbar-item to="/mobile/image" name="image" icon="photo-o">绘图</van-tabbar-item>
        <van-tabbar-item to="/mobile/profile" name="profile" icon="user-o">我的
        </van-tabbar-item>
      </van-tabbar>

    </div>
  </van-config-provider>

</template>

<script setup>
import {ref} from "vue";
import {getMobileTheme, setMobileTheme} from "@/store/system";
import {useRouter} from "vue-router";
import {isMobile} from "@/utils/libs";
import bus from '@/store/eventbus'

const router = useRouter()
if (!isMobile()) {
  router.replace('/')
}

const active = ref('home')
const theme = ref(getMobileTheme())

bus.on('changeTheme', (value) => {
  theme.value = value
  setMobileTheme(theme.value)
})

</script>

<style lang="stylus">
@import '@/assets/iconfont/iconfont.css';
.mobile-home {
  .container {
    .van-nav-bar {
      position fixed
      width 100%
    }

    padding 0 10px
  }

}

// 黑色主题
.van-theme-dark body {
  background #1c1c1e
}

.van-toast--fail {
  background #fef0f0
  color #f56c6c
}

.van-toast--success {
  background #D6FBCC
  color #07C160
}

.van-nav-bar {
  position fixed
  width 100%
}
</style>