import type { RouteRecordRaw } from 'vue-router';

import WujieVueRendererAdapter from '@sy/wujie-vue3-renderer-adapter';

import { LOW_CODE_PROJECT_ID, VITE_RENDERER_URL } from '#/constants';
import { router } from '#/router';

// 微前端路由
const moduleName = 'project';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/project',
    name: moduleName,
    meta: {
      title: '项目管理',
      icon: 'ant-design:appstore-outlined',
    },
    children: [
      {
        path: 'list',
        name: 'ProjectList',
        meta: {
          title: '项目列表',
          icon: 'ant-design:list',
          hideInMenu: true,
        },
        component: WujieVueRendererAdapter,
        props: (route) => {
          return {
            url: `${VITE_RENDERER_URL}`,
            accessToken: localStorage.getItem('y-code-access-token'),
            fileId: '4g4mz6qi8u',
            projectId: LOW_CODE_PROJECT_ID,
            router,
            route,
          };
        },
      },
      {
        path: 'DSLFileList',
        name: 'DSLFileList',
        meta: {
          hideInMenu: true,
          title: 'dsl 文件列表',
          icon: 'ant-design:file',
        },
        component: WujieVueRendererAdapter,
        props: (route) => {
          return {
            url: `${VITE_RENDERER_URL}`,
            accessToken: localStorage.getItem('y-code-access-token'),
            fileId: '45ucatjys',
            projectId: LOW_CODE_PROJECT_ID,
            getRouter: () => router,
            route,
          };
        },
      },
    ],
  },
];

export default routes;
