-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
G
committed
Dec 12, 2023
1 parent
a2dd393
commit fe73f60
Showing
4 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
group: 全局配置 | ||
--- | ||
|
||
# 国际化 - 多语言 | ||
|
||
gbeata 默认是中文,如果需要使用其它语言,请参考下面。 | ||
|
||
设置 gbeata 语言时,会在 `localStorage` 存储 `MULTIWAY_LOCALE`,存储的是语言名。 | ||
|
||
## 方法一、通过 setLanguage 更改语言 | ||
|
||
```tsx | ||
import React, { useState } from 'react'; | ||
import { GCardGroup, setLanguage } from 'gbeata'; | ||
import { Modal } from 'antd'; | ||
|
||
export default function Demo() { | ||
const [locale, setLocale] = useState( | ||
localStorage.getItem('MULTIWAY_LOCALE') || 'zh_CN', | ||
); | ||
|
||
const handleChange = (value: string) => { | ||
setLocale(value); | ||
setLanguage(value); | ||
Modal.confirm({ | ||
title: '语言更换提示', | ||
content: | ||
'切换语言后,只会对 Multiway 组件产生影响,可观察其它页面的变化。', | ||
onOk: () => { | ||
window.location.reload(); | ||
}, | ||
}); | ||
}; | ||
return ( | ||
<GCardGroup | ||
bordered={false} | ||
onChange={handleChange} | ||
value={locale} | ||
options={[ | ||
{ label: '中文', value: 'zh_CN' }, | ||
{ label: '英文', value: 'en_US' }, | ||
{ label: '日文', value: 'ja_JP' }, | ||
]} | ||
/> | ||
); | ||
} | ||
``` | ||
|
||
```js | ||
import { setLanguage } from 'gbeata'; | ||
setLanguage('zh_CN'); | ||
``` | ||
|
||
## 方法二、通过 localStorage 更改语言 | ||
|
||
```tsx | ||
import React, { useState } from 'react'; | ||
import { GCardGroup } from 'gbeata'; | ||
import { Modal } from 'antd'; | ||
|
||
export default function Demo() { | ||
const [locale, setLocale] = useState( | ||
localStorage.getItem('MULTIWAY_LOCALE') || 'zh_CN', | ||
); | ||
|
||
const handleChange = (value: string) => { | ||
setLocale(value); | ||
localStorage.setItem('MULTIWAY_LOCALE', value); | ||
Modal.confirm({ | ||
title: '语言更换提示', | ||
content: | ||
'切换语言后,只会对 Multiway 组件产生影响,可观察其它页面的变化。', | ||
onOk: () => { | ||
window.location.reload(); | ||
}, | ||
}); | ||
}; | ||
return ( | ||
<GCardGroup | ||
bordered={false} | ||
onChange={handleChange} | ||
value={locale} | ||
options={[ | ||
{ label: '中文', value: 'zh_CN' }, | ||
{ label: '英文', value: 'en_US' }, | ||
{ label: '日文', value: 'ja_JP' }, | ||
]} | ||
/> | ||
); | ||
} | ||
``` | ||
|
||
```js | ||
localStorage.setItem('MULTIWAY_LOCALE', 'zh_CN'); | ||
``` | ||
|
||
| 语言 | 语言名 | | ||
| ---- | ------ | | ||
| 中文 | zh_CN | | ||
| 英文 | en_US | | ||
| 日文 | ja_JP | |
14 changes: 14 additions & 0 deletions
14
packages/gbeata/docs/components/setSearchDefaultVisibleRow.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
group: 全局配置 | ||
--- | ||
|
||
# 表格折叠行数设置 | ||
|
||
```js | ||
import { setSearchDefaultVisibleRow } from 'gbeata'; | ||
|
||
// 默认是 2,可以设置成 1 | ||
setSearchDefaultVisibleRow(1); | ||
``` | ||
|
||
<embed src="./index.md"></embed> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
group: 全局配置 | ||
--- | ||
|
||
# 设置表格默认属性 | ||
|
||
可以通过 `setTableDefaultProps` 设置一些表格的默认属性,现在你可以跑到其它表格页面,会发现已经没有了边框。 | ||
|
||
```tsx | ||
import React from 'react'; | ||
import { GSearchTable, GSearchTableField, setTableDefaultProps } from 'gbeata'; | ||
import { listApi } from '../api'; | ||
|
||
setTableDefaultProps({ | ||
bordered: false, | ||
}); | ||
|
||
const fields: Array<GSearchTableField> = [ | ||
{ | ||
title: '姓名', | ||
key: 'cn', | ||
search: true, | ||
}, | ||
{ | ||
title: '英文名', | ||
key: 'en', | ||
search: true, | ||
}, | ||
]; | ||
|
||
export default function Demo() { | ||
return ( | ||
<GSearchTable | ||
title="取消全局表格的边框" | ||
rowKey="sort_id" | ||
api={listApi} | ||
fields={fields} | ||
/> | ||
); | ||
} | ||
``` | ||
|
||
<embed src="./index.md"></embed> |