tronclass-auto 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tui.js +8 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tronclass-auto",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "自動觀看 eclass/TronClass 影片、填寫表單的 CLI 工具",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/tui.js CHANGED
@@ -70,19 +70,13 @@ async function runMenu(config) {
70
70
  return;
71
71
  }
72
72
 
73
- const courseChoices = config.courses.map((url, i) => {
74
- const match = url.match(/\/course\/(\d+)\//);
75
- const id = match ? match[1] : '?';
76
- return { name: `[${id}] ${url}`, value: i, checked: true };
77
- });
78
-
79
- const { selectedCourses } = await inquirer.prompt([{
80
- type: 'checkbox',
81
- name: 'selectedCourses',
82
- message: '選擇要觀看的課程:',
83
- choices: courseChoices,
84
- validate: (ans) => ans.length > 0 ? true : '至少選一個課程'
73
+ const { confirm } = await inquirer.prompt([{
74
+ type: 'confirm',
75
+ name: 'confirm',
76
+ message: `開始觀看全部 ${config.courses.length} 個課程?`,
77
+ default: true
85
78
  }]);
79
+ if (!confirm) return;
86
80
 
87
81
  const { headless } = await inquirer.prompt([{
88
82
  type: 'confirm',
@@ -94,14 +88,14 @@ async function runMenu(config) {
94
88
  console.log('');
95
89
  box([
96
90
  chalk.green('開始自動觀看'),
97
- `課程: ${chalk.cyan(selectedCourses.length)} 個`,
91
+ `課程: ${chalk.cyan(config.courses.length)} 個`,
98
92
  `模式: ${headless ? chalk.gray('無頭') : chalk.white('有頭')}`,
99
93
  `倍速: ${chalk.yellow(config.playbackRate || 2)}x`,
100
94
  ]);
101
95
  console.log('');
102
96
 
103
97
  const { runWithSelection } = require('./index');
104
- await runWithSelection(selectedCourses.map(i => config.courses[i]), headless);
98
+ await runWithSelection(config.courses, headless);
105
99
  await pressAnyKey();
106
100
  }
107
101