Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
recoluan committed Dec 7, 2024
1 parent 407d443 commit 17c2720
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
43 changes: 42 additions & 1 deletion docs/docs/api/node-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ title: Node API
export default demoKit
```

## KitOptions
### KitOptions

```ts
interface KitOptions {
Expand All @@ -48,6 +48,47 @@ interface KitOptions {
}
```

## getKitData

- Type: `<T extends object>(kitName: string) => Promise<T>`
- Description: Get current kit data.
- Example:
```typescript
import { getKitData } from '@revili/helpers/node'

const kitData = await getKitData()
```

## writeKitData

- Type: `<T extends object>(kitName: string, data: T) => Promise<void>`
- Description: Write kit data.
- Example:
```typescript
import { writeKitData } from '@revili/helpers/node'

await writeKitData({
name: 'my-kit',
version: '1.0.0',
description: 'My first kit',
author: 'reco_luan'
})
```

### updateKitData

- Type: `<T extends object>(kitName: string, partialData: Partial<T>) => Promise<void>`
- Description: Updates kit data to update only the specified fields.
- Example:
```typescript
import { updateKitData } from '@revili/helpers/node'

await updateKitData({
version: '1.0.1',
description: 'The description has been updated!'
})
```

## useServerSocket

- Type: `(server: ViteDevServer) => WebSocketServer | null`
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/guide/kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ const getCurrnetPath = () => {
</template>
```

#### Kit's data persistence

Revili provides `getKitData`, `writeKitData`, and `updateKitData` 3 APIs to achieve data persistence, refer to [Node API](/docs/api/node-api.html) for details.

### Debug

The products of the `Standard Kit` are stored under the `dist` folder, so add `--dir=./dist` parameter when you need to execute a command in the root directory of the kit.
Expand Down
43 changes: 42 additions & 1 deletion docs/zh/docs/api/node-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ title: Node API
export default demoKit
```

## KitOptions
### KitOptions

```ts
interface KitOptions {
Expand All @@ -48,6 +48,47 @@ interface KitOptions {
}
```

## getKitData

- 类型:`<T extends object>(kitName: string) => Promise<T>`
- 描述:获取当前 kit 的数据。
- 案例:
```typescript
import { getKitData } from 'revili/node'

const kitData = await getKitData()
```

## writeKitData

- 类型:`<T extends object>(kitName: string, data: T) => Promise<void>`
- 描述:写入 kit 数据。
- 案例:
```typescript
import { writeKitData } from 'revili/node'

await writeKitData({
name: 'my-kit',
version: '1.0.0',
description: '我的第一个 kit',
author: '作者名'
})
```

### updateKitData

- 类型:`<T extends object>(kitName: string, partialData: Partial<T>) => Promise<void>`
- 描述:更新 kit 数据,只更新指定的字段。
- 案例:
```typescript
import { updateKitData } from 'revili/node'

await updateKitData({
version: '1.0.1',
description: '更新后的描述'
})
```

## useServerSocket

- 类型:`(server: ViteDevServer) => WebSocketServer | null`
Expand Down
4 changes: 4 additions & 0 deletions docs/zh/docs/guide/kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ const getCurrnetPath = () => {
</template>
```

#### Kit 的数据持久化

Revili 提供了 `getKitData``writeKitData``updateKitData` 3 个 API 来实现数据的持久化,详情请参考 [Node API](/zh/docs/api/node-api.html)

### 调试

标准套件的产物存放在 `dist` 文件夹下,所以在需要在套件根目录执行命令时添加 `--dir=./dist` 参数。
Expand Down

0 comments on commit 17c2720

Please sign in to comment.