<template>
  <!-- <nuxt-link to="/user">首页</nuxt-link> -->
  <!-- <nuxt-link to="/m_user">首页</nuxt-link> -->
  <nuxt-child />
</template>
<script>


import {postListData} from '../api/index'
export default {
  middleware({ store, route, redirect, params, query }) {
    console.log('middleware layouts inside')
    // store状态树信息
    // route 一条目标路由信息
    //redirect 路由的强制跳转
    // params query 校验参数的合理性
    // console.log('layouts守卫前置守卫')
    // redirect('/reg')
  },
  data() {
    return {

    }
  },
  beforeMount() {
    this.goto()
  },
  methods: {
    async goto() {
     let z =  postListData({
        "categoryId": 1
      }) 
      console.log('zzzzzzz',z)
      var system = {};
      system.pingtai = /(Win32|Win16|WinCE|Mac68K|MacIntel|MacIntel|MacPPC|Linux mips64)/i.test(navigator.platform);
      if (system.pingtai) {
        //电脑
        console.log('电脑')
        this.$router.push('/user')
      } else {
        //手机
        console.log('手机')
      }
    }
  }
}
</script>