Skip to content

Commit

Permalink
docs: tushan i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Feb 21, 2024
1 parent 84419b5 commit bd756c2
Show file tree
Hide file tree
Showing 59 changed files with 1,928 additions and 369 deletions.
13 changes: 6 additions & 7 deletions website/docs/charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
sidebar_position: 6
---

# 图表
# Charts

图表展示是后台管理系统重要一环,`Tushan` 作为一个开箱即用的最佳实践内部自带了一个图表库 `recharts`
Chart display is an important part of backend management systems. As a ready-to-use best practice, `Tushan` comes with a charting library called `recharts` internally.

当然你可以不用自带的而使用自定义的库,打包系统会自动过滤到没有引入依赖
Of course, you can use your own custom library instead of the built-in one, and the bundling system will automatically filter out dependencies that are not imported.

你可以通过如下方式引入:
You can import it as follows:

```ts
import { LineChart } from 'tushan/chart'
```

### 示例
### Example

![](/img/docs/misc/chart.png)


更多关于 `recharts` 的介绍与示例可以访问他的官方文档: [https://recharts.org/en-US/examples](https://recharts.org/en-US/examples)
For more information and examples about `recharts`, you can visit its official documentation: [https://recharts.org/en-US/examples](https://recharts.org/en-US/examples)
19 changes: 9 additions & 10 deletions website/docs/configuration/ListTable.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
sidebar_position: 3
title: <ListTable />
---
## `<ListTable />`

`<ListTable />` 是一个预设好的列表视图。包含列表展示、侧边栏、过滤条件、导入导出
The `<ListTable />` component is a pre-configured list view that includes list display, sidebar, filter conditions, and import/export functionality.

一个常见的`<ListTable />`长成下面这个样子
A typical `<ListTable />` looks like this:

```tsx
<ListTable
Expand All @@ -24,7 +21,7 @@ title: <ListTable />
/>
```

- `filter`: 用于定义过滤条件,过滤条件用于提供给用户筛选记录的方式。一个简单的示例是这样的:
- `filter`: Defines filter conditions to allow users to filter records. A simple example is as follows:
```tsx
<ListTable
filter={[
Expand All @@ -34,11 +31,11 @@ title: <ListTable />
]}
/>
```
*一个特殊的约定是我们会定义`q`为通用的搜索条件,比如文档的标题和内容。*
*A special convention is defining `q` as a universal search condition, such as for document titles and content.*

- `fields`: 其中`fields`表示要渲染的字段,在列表中则是列表项,在侧边栏则是对应表单的表单项。通过不同的工厂函数生成的不同字段类型的`createXXXField`函数对应多个不同类型数据的渲染方式。
- `fields`: The `fields` parameter specifies the fields to be rendered in the list, with each field corresponding to a list item in the list view and a form field in the sidebar. Different types of fields are rendered using various factory functions like `createXXXField`, tailored to different data types.

- `action`: 表示需要支持的常见操作类型,常见的操作类型为`创建`, `查看详情`, `编辑`, `删除`。以及 `导出`, `刷新`, 同时还支持自定义操作。一个自定义操作的例子如下:
- `action`: Specifies the common operation types to be supported, such as `create`, `view details`, `edit`, `delete`, along with `export`, `refresh`, and also supports custom operations. An example of a custom operation is as follows:
```tsx
<ListTable
action={{
Expand All @@ -54,3 +51,5 @@ title: <ListTable />
}}
/>
```

This setup allows for a flexible and feature-rich list view that can be customized to fit various backend management needs.
25 changes: 11 additions & 14 deletions website/docs/configuration/Resource.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
sidebar_position: 2
title: <Resource />
---
## `<Resource />` Component

`<Resource />` 组件定义一个数据实体的实例,会自动产生对应的菜单、路由等常规信息。
The `<Resource />` component defines an instance of a data entity, automatically generating corresponding menus, routes, and other standard information.

```tsx
<Resource
Expand All @@ -13,11 +10,11 @@ title: <Resource />
/>
```

其中 `name` 的值会涉及到接口的自动请求与缓存定义
Here, the value of `name` is involved in the automatic request and cache definition of the interface.

`<Resource />` 的具体实现由其参数决定,如果仅有上面的属性的话是没有任何内容的,一般而言我们会为期增加list参数作为默认的页面。
The specific implementation of `<Resource />` is determined by its parameters. If it only has the above attributes, it will not contain any content. Generally, we add a `list` parameter as the default page.

比如渲染一个最简单的列表
For example, to render a simple list:

```tsx
<Resource
Expand All @@ -42,13 +39,13 @@ title: <Resource />
/>
```

我们可以使用 `tushan` 内置的 `<ListTable />` 组件来渲染一个基本列表。这个组件可以实现: 过滤、排序、增删改查等常见的列表相关操作。
We can use the built-in `<ListTable />` component in `tushan` to render a basic list. This component can perform common list-related operations like filtering, sorting, CRUD actions, etc.

对于字段的渲染,我们可以通过形如 `createTextField` 的方法告知 `<ListTable />` 组件我们要声明的字段类型。参数类型为: `createTextField(source, options?)`,其中`source`是前后端统一的字段名,而options则是该字段的一些可供自定义的配置参数。对于不同的字段类型可能会有不同的配置。
For field rendering, we can use methods like `createTextField` to inform the `<ListTable />` component of the field types we want to declare. The method signature is `createTextField(source, options?)`, where `source` is the field name unified between the frontend and backend, and `options` are customizable configuration parameters for the field. Different field types may have different configurations.

另外, `<ListTable />` 还提供了一个 `action` 参数用于自定义是否打开列表的 **创建**/**查看详情**/**编辑**/**删除** 的操作。
Additionally, `<ListTable />` provides an `action` parameter to customize whether to enable operations like **create**, **view details**, **edit**, and **delete** for the list.

对于信息的搜索与条件过滤。`<ListTable />`提供`filter`参数用于构建过滤条件字段。形如:
For search and condition filtering, `<ListTable />` offers a `filter` parameter to construct filter condition fields, like so:
```tsx
<ListTable
filter={[
Expand All @@ -60,9 +57,9 @@ title: <Resource />
/>
```

一般来说,我们为把`q`定义为通用的搜索逻辑,其他的具体的字段需要响应的后端提供相关能力。
Typically, `q` is defined as a universal search logic, while other specific fields require the corresponding backend capabilities to support them.

一个常见的列表搜索请求体大概是这样的:
A common list search request body might look like this:

```json
// GET
Expand Down
37 changes: 16 additions & 21 deletions website/docs/configuration/Tushan.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
sidebar_position: 1
title: <Tushan />
---
## `<Tushan />` Component

## `<Tushan />` 组件

`<Tushan />` 组件是后台管理中一切的入口,一个一个最简单的 `<Tushan />` 组件大概是长成下面这样的:
The `<Tushan />` component serves as the entry point for backend management. A simple `<Tushan />` component setup might look like this:

```tsx
<Tushan
Expand All @@ -16,17 +11,17 @@ title: <Tushan />
</Tushan>
```

- `basename` 定义路由的基础路径,默认是 `/`, 你也可以将其改为 `/admin` 或者其他的子路径以方便和其他的项目做集成
- `dataProvider` 定义与后端接口交互的方式,一般来说常规的json数据格式可以直接用 `tushan` 预设好的方案:
- `basename` defines the base path for routing, with the default being `/`. You can change this to `/admin` or another subpath to integrate with other projects.
- `dataProvider` specifies how to interact with backend interfaces. For standard JSON data formats, you can directly use the preset solution from `tushan`:
```tsx
import { jsonServerProvider } from 'tushan';

const dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com');
```

其中 `https://jsonplaceholder.typicode.com` 替换成自己的服务端接口地址
Replace `https://jsonplaceholder.typicode.com` with your own server's API endpoint.

当然你可以自己实现自己的`dataProvider`, 具体类型声明可以参考如下结构:
You can also implement your own `dataProvider`. The specific type declaration can refer to the following structure:

```tsx
import { DataProvider, fetchJSON, HTTPClient } from 'tushan';
Expand All @@ -39,11 +34,11 @@ title: <Tushan />
}
```

### 自定义布局
### Custom Layout

`Tushan` 中的布局是完全可以被自定义的,包括整体布局以及细节的header/footer等。
The layout in `Tushan`, including the overall structure and details like header/footer, is fully customizable.

一个修改布局的示例如下:
Here is an example of modifying the layout:

```tsx
<Tushan
Expand All @@ -54,11 +49,11 @@ title: <Tushan />
</Tushan>
```

在这个示例中自定义了标题栏与底部的footer
This example customizes the header and the footer.

关于如何定义仪表盘可以见 [自定义仪表盘](../guide/custom-dashboard.md)
For information on customizing the dashboard, see [Custom Dashboard](../guide/custom-dashboard.md).

或者你也可以整体替换掉整个布局, 如下:
Alternatively, you can replace the entire layout as follows:

```tsx
<Tushan
Expand All @@ -67,13 +62,13 @@ title: <Tushan />
</Tushan>
```

你可以在源码中查看默认布局实现用于参考:
You can refer to the default layout implementation in the source code for guidance:

[https://github.com/msgbyte/tushan/blob/master/packages/tushan/client/components/layout/index.tsx](https://github.com/msgbyte/tushan/blob/master/packages/tushan/client/components/layout/index.tsx)

### 自定义登录界面
### Custom Login Page

类似的,你可以直接在Tushan组件中进行自定义登录界面
Similarly, you can customize the login page directly within the Tushan component:

```tsx
<Tushan
Expand All @@ -82,6 +77,6 @@ title: <Tushan />
</Tushan>
```

登录界面的实现可以参考默认的登录页面实现:
The implementation of the login page can refer to the default login page:

[https://github.com/msgbyte/tushan/blob/master/packages/tushan/client/components/defaults/LoginPage.tsx](https://github.com/msgbyte/tushan/blob/master/packages/tushan/client/components/defaults/LoginPage.tsx)
4 changes: 2 additions & 2 deletions website/docs/configuration/_category_.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"label": "应用配置",
"label": "Application Configuration",
"position": 10,
"link": {
"type": "generated-index",
"description": "Tushan 应用配置"
"description": "Tushan Application Configuration"
}
}
4 changes: 2 additions & 2 deletions website/docs/fields/_category_.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"label": "字段类型",
"label": "Field Types",
"position": 20,
"link": {
"type": "generated-index",
"description": "字段类型"
"description": "Field Types"
}
}
4 changes: 2 additions & 2 deletions website/docs/guide/_category_.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"label": "功能手册",
"label": "Feature Manual",
"position": 30,
"link": {
"type": "generated-index",
"description": "功能手册"
"description": "Feature Manual"
}
}
Loading

0 comments on commit bd756c2

Please sign in to comment.