Skip to content

Commit

Permalink
docs: update ui api documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Dec 26, 2023
1 parent 3698c0c commit b00a257
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/docs/develop/fe-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,23 @@ artalk.setDarkMode(true)
## 浏览量组件 `loadCountWidget`

详情见:[浏览量统计](../guide/frontend/pv.md)

## 获取配置 `getConf`

获取当前 Artalk 配置。

```js
const artalk = Artalk.init({ ... })

const conf = artalk.getConf()
```

## 获取挂载元素 `getEl`

获取当前 Artalk 挂载的 DOM 元素。

```js
const artalk = Artalk.init({ ... })

const el = artalk.getEl()
```
4 changes: 4 additions & 0 deletions ui/artalk/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ class Context implements ContextApi {
return this.conf
}

public getEl(): HTMLElement {
return this.$root
}

public getMarked() {
return marked.getInstance()
}
Expand Down
3 changes: 3 additions & 0 deletions ui/artalk/types/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export interface ContextApi extends EventManagerFuncs<EventPayloadMap> {
/** 获取配置 */
getConf(): ArtalkConfig

/** 获取挂载元素 */
getEl(): HTMLElement

/** 更新配置 */
updateConf(conf: Partial<ArtalkConfig>): void
}

0 comments on commit b00a257

Please sign in to comment.