@@ -3,21 +3,22 @@ import fs from 'node:fs';
3
3
import Table from 'tty-table' ;
4
4
5
5
import { post , get , doDelete } from './api' ;
6
+ import type { Platform } from './types' ;
6
7
7
8
const validPlatforms = {
8
9
ios : 1 ,
9
10
android : 1 ,
10
11
harmony : 1 ,
11
12
} ;
12
13
13
- export function checkPlatform ( platform ) {
14
+ export function checkPlatform ( platform : Platform ) {
14
15
if ( ! validPlatforms [ platform ] ) {
15
16
throw new Error ( `无法识别的平台 '${ platform } '` ) ;
16
17
}
17
18
return platform ;
18
19
}
19
20
20
- export function getSelectedApp ( platform ) {
21
+ export function getSelectedApp ( platform : Platform ) {
21
22
checkPlatform ( platform ) ;
22
23
23
24
if ( ! fs . existsSync ( 'update.json' ) ) {
@@ -34,7 +35,7 @@ export function getSelectedApp(platform) {
34
35
return updateInfo [ platform ] ;
35
36
}
36
37
37
- export async function listApp ( platform ) {
38
+ export async function listApp ( platform : Platform ) {
38
39
const { data } = await get ( '/app/list' ) ;
39
40
const list = platform ? data . filter ( ( v ) => v . platform === platform ) : data ;
40
41
@@ -58,12 +59,12 @@ export async function listApp(platform) {
58
59
return list ;
59
60
}
60
61
61
- export async function chooseApp ( platform ) {
62
+ export async function chooseApp ( platform : Platform ) {
62
63
const list = await listApp ( platform ) ;
63
64
64
65
while ( true ) {
65
66
const id = await question ( '输入应用 id:' ) ;
66
- const app = list . find ( ( v ) => v . id === ( id | 0 ) ) ;
67
+ const app = list . find ( ( v ) => v . id === Number ( id ) ) ;
67
68
if ( app ) {
68
69
return app ;
69
70
}
0 commit comments