Skip to content

Commit 82d1aed

Browse files
author
ranpeng
committed
chore: android instance demo / types
1 parent 4c5aba4 commit 82d1aed

File tree

6 files changed

+400
-90
lines changed

6 files changed

+400
-90
lines changed

dist/tcg-sdk/androidInstance.d.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ export type BatchTaskResponse = {
88
*
99
* Code 为 0 表示成功,其他值表示失败
1010
*
11-
* Code: 10001, Message: "invalid param"
12-
* Code: 10002, Message: "invalid token"
13-
* Code: 10003, Message: "invalid operate"
11+
* Code: 10001, Msg: "invalid param"
12+
* Code: 10002, Msg: "invalid token"
13+
* Code: 10003, Msg: "invalid operate"
1414
*
1515
*/
1616
[InstanceId: string]: {
1717
Code: number;
18-
Message: string;
18+
Msg: string;
1919
};
2020
};
2121

@@ -35,7 +35,7 @@ interface DescribeInstancePropertiesResponse extends BatchTaskResponse {
3535
* Code 为 0 表示成功
3636
*/
3737
Code: number;
38-
Message: string;
38+
Msg: string;
3939
RequestId: string;
4040
DeviceInfo: InstanceProperties['DeviceInfo'];
4141
GPSInfo: InstanceProperties['GPSInfo'];
@@ -60,7 +60,7 @@ interface ListUserAppsResponse extends BatchTaskResponse {
6060
* Code 为 0 表示成功
6161
*/
6262
Code: number;
63-
Message: string;
63+
Msg: string;
6464
RequestId: string;
6565
AppList: App[];
6666
};
@@ -69,7 +69,7 @@ interface ListUserAppsResponse extends BatchTaskResponse {
6969
interface DescribeCameraMediaPlayStatusResponse extends BatchTaskResponse {
7070
[InstanceId: string]: {
7171
Code: number;
72-
Message: string;
72+
Msg: string;
7373
FilePath: string;
7474
/**
7575
* 循环次数,负数表示无限循环
@@ -81,15 +81,15 @@ interface DescribeCameraMediaPlayStatusResponse extends BatchTaskResponse {
8181
interface DescribeKeepAliveListResponse extends BatchTaskResponse {
8282
[InstanceId: string]: {
8383
Code: number;
84-
Message: string;
84+
Msg: string;
8585
AppList: string[];
8686
};
8787
}
8888

8989
interface MediaSearchResponse extends BatchTaskResponse {
9090
[InstanceId: string]: {
9191
Code: number;
92-
Message: string;
92+
Msg: string;
9393
MediaList: {
9494
FileName: string; // 'abc123.mp4';
9595
FilePath: string; // '/sdcard/xxxx';
@@ -105,7 +105,7 @@ interface ListAllAppsResponse extends BatchTaskResponse {
105105
* Code 为 0 表示成功
106106
*/
107107
Code: number;
108-
Message: string;
108+
Msg: string;
109109
RequestId: string;
110110
AppList: App[];
111111
};
@@ -114,7 +114,7 @@ interface ListAllAppsResponse extends BatchTaskResponse {
114114
interface DescribeAppInstallBlackListResponse extends BatchTaskResponse {
115115
[InstanceId: string]: {
116116
Code: number;
117-
Message: string;
117+
Msg: string;
118118
AppList: string[];
119119
};
120120
}
@@ -255,7 +255,6 @@ export interface AndroidInstance {
255255
* @example
256256
* const {url} = AndroidInstance.getInstanceImage({instanceId: 'cai-xxx1'});
257257
*
258-
* @returns {{url: string}} response url - 截图地址
259258
*/
260259
getInstanceImage({
261260
instanceId,
@@ -281,7 +280,6 @@ export interface AndroidInstance {
281280
* @example
282281
* AndroidInstance.upload({instanceId: 'cai-xxx1', files: [{file: file1, path: '/sdcard/xxx/'}, {file: file2, path: '/sdcard/xxx/']});
283282
*
284-
* @returns {{Code: number; Message: string; FileStatus: { CloudPath: string; FileName: string }[] | null}} response
285283
*/
286284
upload({ instanceId, files }: { instanceId: string; files: { file: File; path?: string }[] }): Promise<{
287285
Code: number;
@@ -299,7 +297,6 @@ export interface AndroidInstance {
299297
* @example
300298
* const {address} = AndroidInstance.getInstanceDownloadAddress({instanceId: 'cai-xxx1', path: '/sdcard/xxx/'});
301299
*
302-
* @returns {{address: string}} response address - 下载地址
303300
*/
304301
getInstanceDownloadAddress({ instanceId, path }: { instanceId: string; path: string }): { address: string };
305302
/**

samples/android_instance/src/android_instance/AndroidInstance.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ChevronDownIcon,
1111
StarIcon,
1212
EllipsisIcon,
13+
TextboxIcon,
1314
} from 'tdesign-icons-react';
1415
import { CloudGamingWebSDK } from '../sdk/tcg-sdk/index';
1516
import { CreateAndroidInstancesAccessToken } from './network';
@@ -28,7 +29,6 @@ const TCGSDK = new CloudGamingWebSDK();
2829

2930
// AndroidInstance interface
3031
// https://ex-cloud-gaming.crtrcloud.com/cloud_gaming_web/docs/AndroidInstance.html
31-
3232
const AndroidInstance = TCGSDK.getAndroidInstance();
3333

3434
let slice_point = 3;
@@ -287,6 +287,28 @@ export function AndroidInstancePage() {
287287
<VideoLibraryIcon size={20} />
288288
</div>
289289
</Dropdown>
290+
<Dropdown
291+
options={[
292+
{
293+
content: '云端输入法',
294+
value: 'cloud',
295+
},
296+
{
297+
content: '本地输入法',
298+
value: 'local',
299+
},
300+
]}
301+
onClick={(data) => {
302+
console.log(data.value);
303+
const ime = data.value as 'cloud' | 'local';
304+
305+
AndroidInstance.switchIME({ ime });
306+
}}
307+
>
308+
<div className="mt-[20px]">
309+
<TextboxIcon size={20} />
310+
</div>
311+
</Dropdown>
290312
</div>
291313
</div>
292314
</div>

samples/android_instance/src/android_instance/network.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const CreateAndroidInstancesAccessToken = async ({
88
AndroidInstanceIds = [],
99
ExpirationDuration = '12h',
1010
}: CreateAndroidInstancesAccessTokenRequest) => {
11+
// Gets more information from Tencent cloud API
12+
// https://cloud.tencent.com/document/api/1162/119708
1113
const url = `${serverEnv}/CreateAndroidInstancesAccessToken`;
1214

1315
try {

0 commit comments

Comments
 (0)