Files
nanxiisletAdmin/src/mock/projects.ts
2026-01-06 16:12:34 +08:00

249 lines
6.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 项目管理 Mock 数据
*
* 用于模拟平台管理中的项目和菜单配置
*/
// 菜单项类型
export interface ProjectMenuItem {
key: string
label: string
icon?: string // 图标名称
path?: string
children?: ProjectMenuItem[]
}
// 项目版本类型
export interface ProjectVersion {
id: string
version: string // 版本号,如 1.0.0
description: string // 版本描述
createdAt: string // 创建时间
createdBy: string // 创建人
isCurrent?: boolean // 是否是当前运行版本
// 版本关联的文件列表
files?: { name: string; size: number; path?: string }[]
// 版本快照数据
snapshot: {
name: string
shortName: string
logo: string
color?: string
description?: string
baseUrl?: string
menus: ProjectMenuItem[]
}
}
// 平台项目类型
export interface PlatformProject {
id: string
name: string
shortName: string
logo: string
color?: string
description?: string
enabled: boolean
menuCount: number
createdAt: string
// 项目的访问地址用于iframe嵌套
baseUrl?: string
// 项目的菜单配置
menus: ProjectMenuItem[]
// 当前版本号
currentVersion?: string
// 版本历史
versions?: ProjectVersion[]
// 新增字段
group?: string // 分组
domain?: string // 域名
port?: number // 端口
alias?: string // 代号
enableHttps?: boolean // 启用HTTPS
acmeAccount?: string // Acme账户
certificate?: string // 证书
serverAddress?: string // 服务器地址
remark?: string // 备注
}
// CodePort 的菜单配置
const codePortMenus: ProjectMenuItem[] = [
{
key: 'codePort-dashboard',
label: '控制台',
icon: 'DashboardOutlined',
path: '/dashboard'
},
{
key: 'codePort-community',
label: '社区管理',
icon: 'TeamOutlined',
children: [
{ key: 'codePort-posts', label: '帖子管理', path: '/community/posts' },
{ key: 'codePort-comments', label: '评论管理', path: '/community/comments' },
{ key: 'codePort-tags', label: '标签管理', path: '/community/tags' },
{ key: 'codePort-circles', label: '城市圈子', path: '/community/circles' }
]
},
{
key: 'codePort-content',
label: '内容管理',
icon: 'ReadOutlined',
children: [
{ key: 'codePort-articles', label: '文章管理', path: '/content/articles' }
]
},
{
key: 'codePort-support',
label: '客服管理',
icon: 'CustomerServiceOutlined',
children: [
{ key: 'codePort-support-console', label: '接入会话', path: '/support/console' },
{ key: 'codePort-support-conversations', label: '会话列表', path: '/support/conversations' }
]
},
{
key: 'codePort-project',
label: '项目管理',
icon: 'ProjectOutlined',
children: [
{ key: 'codePort-projects', label: '项目列表', path: '/project/list' },
{ key: 'codePort-recruitment', label: '招募管理', path: '/project/recruitment' },
{ key: 'codePort-signed-projects', label: '已成交项目', path: '/project/signed' },
{ key: 'codePort-contracts', label: '合同管理', path: '/project/contract' },
{ key: 'codePort-sessions', label: '会话管理', path: '/project/sessions' }
]
},
{
key: 'codePort-talent',
label: '人才管理',
icon: 'IdcardOutlined',
children: [
{ key: 'codePort-talent-list', label: '人才列表', path: '/talent' },
{ key: 'codePort-resume-templates', label: '简历模板', path: '/talent/resume-templates' }
]
},
{
key: 'codePort-user',
label: '用户管理',
icon: 'UserOutlined',
children: [
{ key: 'codePort-users', label: '用户列表', path: '/user/list' },
{ key: 'codePort-certification', label: '认证管理', path: '/user/certification' },
{ key: 'codePort-roles', label: '角色管理', path: '/user/roles' },
{ key: 'codePort-positions', label: '岗位管理', path: '/user/positions' },
{ key: 'codePort-levels', label: '等级配置', path: '/user/levels' }
]
}
]
// Mock 项目数据 - 包含 codePort 项目
export const mockProjects: PlatformProject[] = [
{
id: 'codePort',
name: 'CodePort 码头',
shortName: 'CodePort',
logo: '码',
color: '#1890ff',
description: '人才外包平台管理后台',
enabled: true,
menuCount: 25,
createdAt: '2024-01-01T00:00:00Z',
baseUrl: 'http://localhost:5174',
menus: codePortMenus,
currentVersion: '1.0.0',
versions: [
{
id: 'v1.2.0',
version: '1.2.0',
description: '新增了客服系统和会话管理模块',
createdAt: '2024-03-15T10:00:00Z',
createdBy: '管理员',
isCurrent: true,
files: [
{ name: 'dist.zip', size: 5242880, path: '/opt/1panel/www/sites/codeport/index' }
],
snapshot: {
name: 'CodePort 码头',
shortName: 'CodePort',
logo: '码',
color: '#1890ff',
description: '人才外包平台管理后台',
baseUrl: 'http://localhost:5174',
menus: codePortMenus
}
},
{
id: 'v1.1.0',
version: '1.1.0',
description: '优化了用户管理和项目列表',
createdAt: '2024-02-01T10:00:00Z',
createdBy: '管理员',
isCurrent: false,
files: [
{ name: 'dist.zip', size: 4718592, path: '/opt/1panel/www/sites/codeport/index' }
],
snapshot: {
name: 'CodePort 码头',
shortName: 'CodePort',
logo: '码',
color: '#1890ff',
description: '人才外包平台管理后台',
baseUrl: 'http://localhost:5174',
menus: codePortMenus
}
},
{
id: 'v1.0.0',
version: '1.0.0',
description: '初始版本',
createdAt: '2024-01-01T00:00:00Z',
createdBy: '管理员',
isCurrent: false,
snapshot: {
name: 'CodePort 码头',
shortName: 'CodePort',
logo: '码',
color: '#1890ff',
description: '人才外包平台管理后台',
baseUrl: 'http://localhost:5174',
menus: codePortMenus
}
}
]
}
]
/**
* 获取所有启用的项目
*/
export function getEnabledProjects(): PlatformProject[] {
return mockProjects.filter(p => p.enabled)
}
/**
* 根据ID获取项目
*/
export function getProjectById(id: string): PlatformProject | undefined {
return mockProjects.find(p => p.id === id)
}
/**
* 获取项目的菜单配置
*/
export function getProjectMenus(projectId: string): ProjectMenuItem[] {
const project = getProjectById(projectId)
return project?.menus || []
}
/**
* 生成新版本号
*/
export function generateNextVersion(currentVersion?: string): string {
if (!currentVersion) return '1.0.0'
const parts = currentVersion.split('.').map(Number)
parts[2] = (parts[2] || 0) + 1
return parts.join('.')
}