import type { AppRouteRecord } from '@/types/router'

/**
 * 公告管理路由模块
 *
 * 覆盖平台、租户、应用端和草稿中心的公告管理路由
 */
const announcementRoutes: AppRouteRecord[] = [
  /**
   * 平台公告管理
   * - 列表 /platform/announcements
   * - 创建 /platform/announcements/create
   * - 编辑 /platform/announcements/:announcementId/edit
   * - 详情 /platform/announcements/:announcementId
   */
  {
    path: '/platform/announcements',
    name: 'PlatformAnnouncementRoot',
    component: '/index/index',
    meta: {
      title: 'menus.announcement.platform.title',
      icon: 'ri:megaphone-line',
      permission: ['platform-announcement:read', 'platform-announcement:create']
    },
    children: [
      {
        path: '',
        name: 'PlatformAnnouncementList',
        component: () => import('@views/platform/announcements/index.vue'),
        meta: {
          title: 'menus.announcement.platform.list',
          icon: 'ri:list-check-2',
          permission: ['platform-announcement:read', 'platform-announcement:create'],
          authList: [
            { title: '创建平台公告', authMark: 'platform-announcement:create' },
            { title: '查看平台公告', authMark: 'platform-announcement:read' },
            { title: '编辑平台公告', authMark: 'platform-announcement:update' },
            { title: '删除平台公告', authMark: 'platform-announcement:delete' },
            { title: '发布平台公告', authMark: 'platform-announcement:publish' },
            { title: '撤销平台公告', authMark: 'platform-announcement:revoke' }
          ]
        }
      },
      {
        path: 'create',
        name: 'PlatformAnnouncementCreate',
        component: () => import('@views/platform/announcements/create.vue'),
        meta: {
          title: 'menus.announcement.platform.create',
          icon: 'ri:add-circle-line',
          permission: ['platform-announcement:create']
        }
      },
      {
        path: ':announcementId/edit',
        name: 'PlatformAnnouncementEdit',
        component: () => import('@views/platform/announcements/edit.vue'),
        meta: {
          title: 'menus.announcement.platform.edit',
          icon: 'ri:edit-line',
          permission: ['platform-announcement:update']
        }
      },
      {
        path: ':announcementId',
        name: 'PlatformAnnouncementDetail',
        component: () => import('@views/platform/announcements/detail.vue'),
        meta: {
          title: 'menus.announcement.platform.detail',
          icon: 'ri:file-text-line',
          permission: ['platform-announcement:read', 'platform-announcement:create']
        }
      }
    ]
  },

  /**
   * 应用端公告（仅读）
   * - 列表 /app/announcements
   * - 详情 /app/announcements/:announcementId
   */
  {
    path: '/app/announcements',
    name: 'AppAnnouncementRoot',
    component: '/index/index',
    meta: {
      title: 'menus.announcement.app.title',
      icon: 'ri:notification-badge-line',
      permission: ['app-announcement:read']
    },
    children: [
      {
        path: '',
        name: 'AppAnnouncementList',
        component: () => import('@views/app/announcements/index.vue'),
        meta: {
          title: 'menus.announcement.app.list',
          icon: 'ri:list-check-2',
          permission: ['app-announcement:read'],
          authList: [{ title: '查看应用端公告', authMark: 'app-announcement:read' }]
        }
      },
      {
        path: ':announcementId',
        name: 'AppAnnouncementDetail',
        component: () => import('@views/app/announcements/detail.vue'),
        meta: {
          title: 'menus.announcement.app.detail',
          icon: 'ri:file-text-line',
          permission: ['app-announcement:read']
        }
      }
    ]
  },

  /**
   * 草稿中心
   * - 列表 /announcement-drafts
   */
  {
    path: '/announcement-drafts',
    name: 'AnnouncementDraftRoot',
    component: '/index/index',
    meta: {
      title: 'menus.announcement.drafts.title',
      icon: 'ri:draft-line',
      permission: ['platform-announcement:create', 'tenant-announcement:create']
    },
    children: [
      {
        path: '',
        name: 'AnnouncementDraftList',
        component: () => import('@views/announcement-drafts/index.vue'),
        meta: {
          title: 'menus.announcement.drafts.list',
          icon: 'ri:draft-line',
          permission: ['platform-announcement:create', 'tenant-announcement:create']
        }
      }
    ]
  }
]

export default announcementRoutes
