<template>
  <div>
    <h-space direction="vertical">
      <div>我是测试页</div>
      <h-button type="primary" @click="onClick">点我</h-button>
      <h-button type="primary" @click="onClick2">跳转</h-button>

      <div>我是一个按钮组</div>
      <h-b-button-group v-bind="propsNormal" ref="buttonGroupRef" :check-permission="false" />
      <div>pageId:{{ pageId }}</div>
    </h-space>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted } from 'vue';
import { HModal } from '@crami/ui';
import { useButtonGroup } from '@crami/bui-platform';
import { useRoute, useRouter } from 'vue-router';
import { commonApi } from '@/api/commonApi/index';
import { useHttp } from '@crami/http';

export default defineComponent({
  name: 'Home',
  // components: { HButton: Button, HBButtonGroup: BButtonGroup, HSpace: Space },
  setup() {
    const router = useRouter();
    const route = useRoute();
    const pageId = route.meta.pageId || '';
    console.log(pageId);
    console.log('--------------------params', route.params);

    const [buttonGroupRef, propsNormal] = useButtonGroup({
      menuName: 'aaa',
      direction: 'horizontal', // 间距方向
      pageName: 'Home',
      sortRule: 'unfold',
      dataSourceApi: {
        // url: 'http://10.0.59.229:7300/mock/622ff143ec91f63c580c0560/demo/menu-data',
        url: commonApi().studioCache.getMetaInfo.url,
        params: {
          ...commonApi().studioCache.getMetaInfo.params,
          type: 'menuv2',
          name: 'P_MSG_MYSENTMenu',
        },
        method: commonApi().studioCache.getMetaInfo.method,
      },
      moreItem: {
        trigger: ['click'],
      },
    });

    const onClick = () => {
      HModal.confirm({ title: '提示', content: '点击按钮啦' });
    };

    const onClick2 = () => {
      router.push({ path: '/', query: { checkCode: 'xxxxx' } });
    };

    onMounted(() => {
      // getData();
    });
    return { router, route, buttonGroupRef, propsNormal, onClick, onClick2, pageId };
  },
});
</script>
