import * as types from '../../mutation-types'
import lazyLoader from './lazyLoader'

const state = {
  items: [
    {
      name: 'Home',
      path: '/',
      meta: {
        label: ['主頁面'],
        link: 'Home.vue',
        icon: ['fas', 'home']
      },
      components: lazyLoader('Home')
    },
    {
      name: 'Server Status',
      path: '/status',
      meta: {
        label: ['伺服器'],
        link: 'Server.vue',
        icon: ['fas', 'server']
      },
      components: lazyLoader('Server')
    },
    {
      name: 'Files',
      path: '/files',
      meta: {
        label: ['檔案庫'],
        link: 'File.vue',
        icon: ['fas', 'database']
      },
      components: lazyLoader('File')
    },
    // {
    //   name: 'Post',
    //   path: '/post',
    //   meta: {
    //     label: ['新增文章'],
    //     link: 'Post.vue',
    //     icon: ['fas', 'file']
    //   },
    //   components: lazyLoader('Post/Add')
    // },
    // {
    //   name: 'Post List',
    //   path: '/post-list',
    //   meta: {
    //     label: ['文章列表'],
    //     link: 'Post.vue',
    //     icon: ['fas', 'list-alt']
    //   },
    //   components: lazyLoader('Post/List')
    // },
    {
      name: 'News',
      path: '/news',
      meta: {
        label: ['新增新聞'],
        link: 'News.vue',
        icon: ['fas', 'plus']
      },
      components: lazyLoader('News/Add')
    },
    {
      name: 'News List',
      path: '/news-list',
      meta: {
        label: ['新聞列表'],
        link: 'News.vue',
        icon: ['fas', 'newspaper']
      },
      components: lazyLoader('News/List')
    }
  ]
}

const mutations = {
  [types.EXPAND_MENU] (state, menuItem) {
    if (menuItem.index > -1) {
      if (state.items[menuItem.index] && state.items[menuItem.index].meta) {
        state.items[menuItem.index].meta.expanded = menuItem.expanded
      }
    } else if (menuItem.item && 'expanded' in menuItem.item.meta) {
      menuItem.item.meta.expanded = menuItem.expanded
    }
  }
}

export default {
  state,
  mutations
}

@@ -705,36 +705,30 @@
 )%0A    %7D,%0A   
- //
  %7B%0A   
- //
    name: 'Po
@@ -728,37 +728,34 @@
 me: 'Post',%0A    
-//
   
- 
 path: '/post',%0A 
@@ -748,35 +748,32 @@
 th: '/post',%0A   
- //
    meta: %7B%0A    /
@@ -762,35 +762,32 @@
      meta: %7B%0A   
- //
      label: %5B'%E6%96%B0%E5%A2%9E
@@ -791,27 +791,24 @@
 '%E6%96%B0%E5%A2%9E%E6%96%87%E7%AB%A0'%5D,%0A   
- //
      link: '
@@ -813,35 +813,32 @@
  'Post.vue',%0A   
- //
      icon: %5B'fas
@@ -848,38 +848,32 @@
 'file'%5D%0A    
-//
   
- 
 %7D,%0A   
- //
    component
@@ -905,30 +905,21 @@
 %0A   
- //
  %7D,%0A   
- //
  %7B%0A   
- //
    n
@@ -940,21 +940,18 @@
 t',%0A    
-//
   
- 
 path: '/
@@ -965,19 +965,16 @@
 st',%0A   
- //
    meta:
@@ -975,27 +975,24 @@
  meta: %7B%0A   
- //
      label: 
@@ -1000,27 +1000,24 @@
 '%E6%96%87%E7%AB%A0%E5%88%97%E8%A1%A8'%5D,%0A   
- //
      link: '
@@ -1030,19 +1030,16 @@
 ue',%0A   
- //
      ico
@@ -1069,22 +1069,16 @@
     
-//
   
- 
 %7D,%0A   
- //
    c
@@ -1119,11 +1119,8 @@
 %0A   
- //
  %7D,%0A

Add post editor to menu.