1
1
import select from '@inquirer/select'
2
2
import input from '@inquirer/input'
3
3
4
- import {
5
- getHot100QuestionListCode ,
6
- getTitleSlugList
7
- } from '#common/utils/question-handler/getHot100QuestionListCode.js'
4
+ // import { getHot100QuestionListCode } from '#common/utils/question-handler/getHot100QuestionListCode.js'
8
5
import {
9
6
createQuestionById ,
10
7
createQuestionByTitleSlug
11
8
} from '#common/utils/create-check/createUtil.js'
12
9
import { getQuestionByKeyword } from '#common/utils/question-getter/getQuestionByKeyword.js'
10
+ import { getStudyPlanList } from '#common/utils/question-getter/getStudyPlanList.js'
11
+ import { getPlanQuestionList } from '#common/utils/question-getter/getPlanQuestionList.js'
13
12
14
- async function hotMode ( baseDir = process . cwd ( ) ) {
13
+ async function studyMode ( baseDir = process . cwd ( ) ) {
14
+ const questionList = await getStudyPlanList ( )
15
+ const planListMode = {
16
+ message : '请选择学习计划' ,
17
+ choices : questionList . map ( ( item ) => ( {
18
+ name : `${ item . name } ${ item . premiumOnly ? '(VIP)' : '' } ` ,
19
+ value : item . slug
20
+ } ) )
21
+ }
22
+ const planSlug = await select ( planListMode )
15
23
const createMode = await select ( {
16
24
message : '拉题模式' ,
17
25
choices : [
@@ -20,10 +28,14 @@ async function hotMode(baseDir = process.cwd()) {
20
28
]
21
29
} )
22
30
if ( createMode === 'single' ) {
23
- const titleSlugList = await getTitleSlugList ( )
31
+ const { planSubGroups } = await getPlanQuestionList ( planSlug )
32
+ const planList = planSubGroups . reduce ( ( acc , cur ) => {
33
+ acc . push ( ...cur . questions . map ( ( res ) => res . titleSlug ) )
34
+ return acc
35
+ } , [ ] )
24
36
const singleMode = {
25
37
message : '请选择题目?' ,
26
- choices : titleSlugList . map ( ( res ) => ( {
38
+ choices : planList . map ( ( res ) => ( {
27
39
name : res ,
28
40
value : res
29
41
} ) )
@@ -32,7 +44,7 @@ async function hotMode(baseDir = process.cwd()) {
32
44
33
45
await createQuestionByTitleSlug ( singleChoice , baseDir )
34
46
}
35
- if ( createMode === 'all' ) await getHot100QuestionListCode ( )
47
+ // if (createMode === 'all') await getHot100QuestionListCode()
36
48
}
37
49
38
50
async function keywordMode ( baseDir = process . cwd ( ) ) {
@@ -54,18 +66,16 @@ async function keywordMode(baseDir = process.cwd()) {
54
66
console . log ( chooseQuestion )
55
67
await createQuestionById ( chooseQuestion , baseDir )
56
68
}
69
+
57
70
async function selectMode ( baseDir ) {
71
+
58
72
console . log ( baseDir )
59
73
}
60
74
61
75
export async function easyFinderView ( baseDir = process . cwd ( ) ) {
62
76
const choices = [
63
77
{ name : '关键词搜索' , value : 'keyword' , description : '关键词描述' } ,
64
- {
65
- name : 'hot 100列表查询' ,
66
- value : 'hot' ,
67
- description : '最受欢迎的100道题目'
68
- } ,
78
+ { name : '学习计划' , value : 'study' , description : '企业和经典面试题目列表' } ,
69
79
{ name : '筛选模式' , value : 'select' , description : '筛选题目' }
70
80
]
71
81
@@ -76,7 +86,7 @@ export async function easyFinderView(baseDir = process.cwd()) {
76
86
const mode = await select ( modeQuestion )
77
87
78
88
const modeMap = {
79
- hot : hotMode ,
89
+ study : studyMode ,
80
90
keyword : keywordMode ,
81
91
select : selectMode
82
92
}
0 commit comments