import { NTabPane, NTabs } from 'naive-ui'
import { defineComponent, h, reactive, resolveDynamicComponent } from 'vue'
import { useRoute } from 'vue-router'
import HelpCenter from './component/help-center'
import HelpCenterCategory from './component/help-center-category'
import { getTabsCache, setTabsCaches } from '@/hooks/use-async'
export default defineComponent({
  name: 'city-manage',
  setup() {
    const state = reactive({
      tabName: 'HelpCenter' as 'HelpCenter' | 'HelpCenterCategory'
    })
    const route = useRoute()
    getTabsCache((val: any) => {
      if (val.form.tabName) {
        state.tabName = val.form.tabName
      }
    })
    const setTabs = (val: any) => {
      setTabsCaches(val, 'tabName', route)
    }
    return () => {
      // const Component = resolveDynamicComponent(state.componentName)
      return (
        <div class="system-menu-container">
          <h2>帮助中心</h2>

          <div class={['section-container']} style="padding-top: 0">
            <NTabs
              type="line"
              size="large"
              v-model:value={state.tabName}
              onUpdate:value={(val: any) => setTabs(val)}
            >
              <NTabPane
                name="HelpCenter"
                tab="帮助列表"
                //v-auth="helpCenterContent/page1599594492578836481"
              >
                <HelpCenter />
              </NTabPane>
              <NTabPane
                name="HelpCenterCategory"
                tab="帮助分类"
                //v-auth="helpCenterCatalog/page1599594656550957058"
              >
                <HelpCenterCategory />
              </NTabPane>
            </NTabs>
          </div>
        </div>
      )
    }
  }
})
