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: 'Control Panel',
    //   path: '/panel',
    //   meta: {
    //     label: ['控制面板'],
    //     link: 'Panel.vue',
    //     icon: ['fas', 'columns']
    //   },
    //   components: lazyLoader('Panel')
    // },
    // {
    //   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
}

@@ -505,36 +505,30 @@
 )%0A    %7D,%0A   
- //
  %7B%0A   
- //
    name: 'Co
@@ -529,41 +529,30 @@
 e: '
-Control Panel
+Files
 ',%0A    
-//
   
- 
 path: '/
 pane
@@ -551,25 +551,22 @@
 : '/
-panel
+files
 ',%0A    
-//
   
- 
 meta
@@ -565,39 +565,36 @@
     meta: %7B%0A    
-//
     
- 
 label: %5B'%E6%8E%A7%E5%88%B6%E9%9D%A2%E6%9D%BF'%5D,
@@ -590,22 +590,18 @@
 : %5B'
-%E6%8E%A7%E5%88%B6%E9%9D%A2%E6%9D%BF
+%E6%AA%94%E6%A1%88%E5%BA%AB
 '%5D,%0A   
- //
     
@@ -608,21 +608,20 @@
  link: '
-Panel
+File
 .vue',%0A 
@@ -614,35 +614,32 @@
  'File.vue',%0A   
- //
      icon: %5B'fas
@@ -646,24 +646,22 @@
 ', '
-columns
+database
 '%5D%0A   
- //
    %7D
@@ -657,35 +657,32 @@
 e'%5D%0A      %7D,%0A   
- //
    components: l
@@ -696,22 +696,18 @@
 er('
-Panel
+File
 ')%0A   
- //
  %7D,%0A

Add file service.