Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一些缺失部分的补充 #161

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion zh-CN/api/message/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,49 @@ You have <plural count={count}>

## 扩展组件

### 网页渲染 (html)
### 网页渲染 (html) <badge>需要 Puppeteer</badge>

- **style:** HTML 中 `body` 标签的 `style` 属性

调用 Puppeteer 渲染给定 HTML。

JSX 中的 `html` 将被转化为为 HTML 中的 `body` 标签。

```html
<html style={"color: purple;"}>
<h1>This is a header</h1>
<p>Hello Puppeteer!</p>
</html>
```

你也可以为 `style` 属性指定一个对象:

```html
<html style={{
color: "purple",
}}>
<h1>This is a header</h1>
<p>Hello Puppeteer!</p>
</html>
```

如果你需要向 HTML 的 `head` 标签中添加 CSS 等页面属性,可以将它们包裹在 `head` 中。下面是一个例子:

```html
<html>
<head>
<style>
{`
body {
color: "purple"
}
`}
</style>
</head>

<h1>This is a header</h1>
<p>Hello Puppeteer!</p>
</html>
```

### 内容审查 (censor)
21 changes: 20 additions & 1 deletion zh-CN/guide/database/selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ ctx.database
```ts
// 返回的数据包含 foo, bar 两个属性
ctx.database
.join(['foo', 'bar'], (foo, bar) => $.eq(foo.id, bar.id))
.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.id))
.execute()
```

普通的 `.orderBy()` 和 `.where()` 方法不支持字段中带有 `.` 符号。因此在使用连接查询时,你需要使用[求值表达式](#求值表达式):

```ts
ctx.database
.join(['foo', 'bar'] as const, (foo, bar) => $.eq(foo.id, bar.id))
.orderBy(row => row.foo.id)
.execute()
```

如果你的表名比较复杂,你也可以为参与连接的各个表指定别名。将用于指定表名的数组改为传入一个对象,并修改传入函数的参数即可。下面是一个例子:

```ts
// 返回的数据包含 t1, t2 两个属性
ctx.database
.join({ t1: 'foo', t2: 'bar', }, row => $.eq(row.t1.id, row.t2.id))
.orderBy(row => row.t1.id)
.execute();
```
Loading