|
1 | | -import type { SidebarConfig, VipPackageJSON, VipProject } from '@142vip/vitepress' |
2 | | -import { defineVipSidebarConfig } from '@142vip/vitepress' |
| 1 | +import { defineVipSidebarConfig, SidebarConfig } from '@142vip/vitepress' |
3 | 2 |
|
4 | | -enum ProjectId { |
| 3 | +export enum ProjectId { |
5 | 4 | BUSINESS = '商业模块', |
6 | 5 | TOOLS = '通用工具', |
7 | 6 | EGG = 'Egg.js框架', |
@@ -86,73 +85,6 @@ export const sidebarConfig = defineVipSidebarConfig([ |
86 | 85 | }, |
87 | 86 | ]) |
88 | 87 |
|
89 | | -/** |
90 | | - * 获取基本包信息 |
91 | | - * - 注意目录格式,例如:@packages/utils |
92 | | - * @vite-ignore |
93 | | - */ |
94 | | -async function getBasePkgJSON(pkgDirName: string): Promise<VipPackageJSON> { |
95 | | - // 参考格式:@packages/xxx @apps/xxx |
96 | | - return await import(`@packages/${pkgDirName}/package.json`) |
97 | | -} |
98 | | - |
99 | | -/** |
100 | | - * 获取apps目录下的模块 |
101 | | - * - @apps/vitepress-demo |
102 | | - */ |
103 | | -async function getAppsPkgJSON(pkgDirName: string): Promise<VipPackageJSON> { |
104 | | - // 参考格式:@packages/xxx @apps/xxx |
105 | | - return await import(`@apps/${pkgDirName}/package.json`) |
106 | | -} |
107 | | - |
108 | | -/** |
109 | | - * 动态获取模块信息 |
110 | | - * - 注意:遍历侧边栏 |
111 | | - */ |
112 | | -export async function getCoreProjectData(): Promise<VipProject[]> { |
113 | | - const coreProjects: VipProject[] = [] |
114 | | - for (const { items = [], text = '' } of sidebarConfig) { |
115 | | - // 过滤掉apps下的模块 |
116 | | - if (text?.includes(ProjectId.DEMO)) { |
117 | | - continue |
118 | | - } |
119 | | - for (const { text: pkgName = '' } of items) { |
120 | | - const pkgDirName = pkgName.split('@142vip/')[1] |
121 | | - const basePkg = await getBasePkgJSON(`${pkgDirName}`) |
122 | | - coreProjects.push({ |
123 | | - ...basePkg, |
124 | | - // 约定:图标+文字 |
125 | | - id: text.split(' ')[0], |
126 | | - changelog: `../changelogs/${pkgDirName}/changelog.html`, |
127 | | - readme: `../packages/${pkgDirName}/index.html`, |
128 | | - sourceCode: `https://github.com/142vip/core-x/tree/main/packages/${pkgDirName}/`, |
129 | | - }) |
130 | | - } |
131 | | - } |
132 | | - return coreProjects |
133 | | -} |
134 | | - |
135 | | -/** |
136 | | - * demo项目,用于项目展示 |
137 | | - */ |
138 | | -export async function getExampleDemoTableData(): Promise<VipProject[]> { |
139 | | - const pkgNames = ['egg-demo', 'nest-demo', 'vuepress-demo', 'vitepress-demo'] |
140 | | - |
141 | | - const exampleDemos: VipProject[] = [] |
142 | | - for (const pkgDirName of pkgNames) { |
143 | | - const pkg = await getAppsPkgJSON(`${pkgDirName}`) |
144 | | - exampleDemos.push({ |
145 | | - ...pkg, |
146 | | - private: true, |
147 | | - id: '🤡', |
148 | | - changelog: `../changelogs/${pkgDirName}/changelog.html`, |
149 | | - readme: `../apps/${pkgDirName}/index.html`, |
150 | | - sourceCode: `https://github.com/142vip/core-x/tree/main/apps/${pkgDirName}/`, |
151 | | - }) |
152 | | - } |
153 | | - return exampleDemos |
154 | | -} |
155 | | - |
156 | 88 | /** |
157 | 89 | * 根据侧边栏获取变更日志侧边栏 |
158 | 90 | */ |
|
0 commit comments