x-app-sdk 1.0.0 → 1.0.2
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.
- package/README.md +52 -38
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,50 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# x-app-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Giới thiệu
|
|
4
|
+
`x-app-sdk` là một thư viện hỗ trợ phát triển ứng dụng với các tính năng tương tác với `superapp` và các thành phần UI cơ bản.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## Cài đặt
|
|
7
|
+
Bạn có thể cài đặt `x-app-sdk` bằng npm:
|
|
8
|
+
```sh
|
|
9
|
+
npm install x-app-sdk
|
|
10
|
+
```
|
|
11
|
+
Hoặc sử dụng yarn:
|
|
12
|
+
```sh
|
|
13
|
+
yarn add x-app-sdk
|
|
14
|
+
```
|
|
6
15
|
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
## Các tính năng chính
|
|
17
|
+
### 1. SDK tương tác với SuperApp
|
|
18
|
+
#### `requestInfo()`
|
|
19
|
+
Lấy thông tin từ `superapp`.
|
|
20
|
+
```js
|
|
21
|
+
import { requestInfo } from 'x-app-sdk';
|
|
9
22
|
|
|
10
|
-
|
|
23
|
+
requestInfo().then(info => {
|
|
24
|
+
console.log('Thông tin ứng dụng:', info);
|
|
25
|
+
}).catch(error => {
|
|
26
|
+
console.error('Lỗi khi lấy thông tin:', error);
|
|
27
|
+
});
|
|
28
|
+
```
|
|
11
29
|
|
|
12
|
-
|
|
30
|
+
#### `openPickerImage()`
|
|
31
|
+
Mở trình chọn ảnh từ `superapp`.
|
|
32
|
+
```js
|
|
33
|
+
import { openPickerImage } from 'x-app-sdk';
|
|
13
34
|
|
|
14
|
-
|
|
35
|
+
openPickerImage().then(imageData => {
|
|
36
|
+
console.log('Dữ liệu ảnh:', imageData);
|
|
37
|
+
}).catch(error => {
|
|
38
|
+
console.error('Lỗi khi mở trình chọn ảnh:', error);
|
|
39
|
+
});
|
|
40
|
+
```
|
|
15
41
|
|
|
42
|
+
#### `closeApp()`
|
|
43
|
+
Đóng ứng dụng từ `superapp`.
|
|
16
44
|
```js
|
|
17
|
-
|
|
18
|
-
languageOptions: {
|
|
19
|
-
// other options...
|
|
20
|
-
parserOptions: {
|
|
21
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
22
|
-
tsconfigRootDir: import.meta.dirname,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
```
|
|
45
|
+
import { closeApp } from 'x-app-sdk';
|
|
27
46
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
|
|
47
|
+
closeApp();
|
|
48
|
+
```
|
|
31
49
|
|
|
50
|
+
### 2. UI Components
|
|
51
|
+
#### `Button`
|
|
52
|
+
Component nút bấm đơn giản.
|
|
32
53
|
```js
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// Add the react plugin
|
|
41
|
-
react,
|
|
42
|
-
},
|
|
43
|
-
rules: {
|
|
44
|
-
// other rules...
|
|
45
|
-
// Enable its recommended rules
|
|
46
|
-
...react.configs.recommended.rules,
|
|
47
|
-
...react.configs['jsx-runtime'].rules,
|
|
48
|
-
},
|
|
49
|
-
})
|
|
54
|
+
import { Button } from 'x-app-sdk';
|
|
55
|
+
|
|
56
|
+
const App = () => (
|
|
57
|
+
<Button onPress={() => alert('Button clicked!')}>
|
|
58
|
+
Nhấn vào đây
|
|
59
|
+
</Button>
|
|
60
|
+
);
|
|
50
61
|
```
|
|
62
|
+
|
|
63
|
+
## Kết luận
|
|
64
|
+
Thư viện `x-app-sdk` giúp bạn dễ dàng tương tác với `superapp` và cung cấp các thành phần UI cơ bản cho ứng dụng của bạn.
|