Skip to content

Commit cc496b7

Browse files
committed
补充了组件JsonTextField 和 PasswordInputField 的使用说明文档。
1 parent ce318c9 commit cc496b7

File tree

5 files changed

+111
-20
lines changed

5 files changed

+111
-20
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ pip install /path/to/your_project/dist/DjangoAsyncAdmin-6.5.4.tar.gz
7777
<td>版本</td><td colspan="2">说明</td>
7878
</tr>
7979

80+
<tr>
81+
<td rowspan="2">6.7.2</td>
82+
<td colspan="2">实现了Json编辑器(JsonTextField)和密码生成Input(PasswordInputField)等组件,并且同时初步调整了组件目录结构,提高了代码的可读性.</td>
83+
</tr>
84+
<tr>
85+
<td colspan="2"><img src="https://haoke98.github.io/DjangoAsyncAdmin/static/json_text_field.png"/></td>
86+
</tr>
87+
88+
89+
8090
<tr>
8191
<td rowspan="2">6.7.1</td>
8292
<td colspan="2">增加了拥有复制和自动生成密码的表单字段 PasswordFormField.</td>

docs/components.md

Lines changed: 101 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
## 基础组件
66

7-
## 表单组件
7+
## 基础组件
88

99
### 密码组件
1010

11-
继承自`froms.CharField`表单字段
11+
继承自`models.CharField`表单字段
1212

1313
#### 效果
1414

@@ -17,36 +17,117 @@
1717
#### 如何引入
1818

1919
```python
20-
from simplepro.components.forms import PasswordFormField
20+
from simplepro.components.fields import PasswordInputField
2121
```
2222

2323
#### 参数
2424

25-
| 参数名 | 类型 | 必须 | 默认值 | 说明 |
26-
|--------------|-----|-----|--------------------------------------------------------------------------|------------|
27-
| label | 字符串 | ☑️ | | 表单中的字段展示名称 |
28-
| required | 布尔值 | ☑️ | False | 是否必填 |
29-
| encryptByMd5 | 布尔值 | ☑️ | True | 是否要MD5加密 |
30-
| lenMin | 数字 | ☑️ | 6 | 最小长度 |
31-
| lenMax | 数字 | ☑️ | 48 | 最大长度 |
32-
| pattern | 字符串 | ☑️ | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-$%&@+!" | 随机生成的可选字符集 |
25+
| 参数名 | 类型 | 必须 | 说明 | 默认值 |
26+
|-----------------|-------|-----|---------------|--------------------------------------------------------------------------|
27+
| min_length | `数字` | ☑️ | 最小长度 | 6 | |
28+
| placeholder | `字符串` | ☑️ | 占位内容 | |
29+
| clearable | `布尔值` | ☑️ | 是否显示一键晴空按钮 | `True` |
30+
| show_password | `布尔值` | ☑️ | 是否显示明文现实密码的按钮 | `False` |
31+
| show_word_limit | `布尔值` | ☑️ | 是否显示字符限制 | `False` |
32+
| disabled | `布尔值` | ☑️ | 禁用 | `False` |
33+
| readonly | `布尔值` | ☑️ | 只读 | `False` |
34+
| encrypt | `字符串` | ☑️ | 加密算法 | |
35+
| pattern | `字符串` | ☑️ | 随机生成的可选字符集 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-$%&@+!" |
3336

3437
其他参数都继承`forms.CharField`.
3538

3639
#### 示例
3740

3841
```python
39-
from django.forms import ModelForm
40-
from simplepro.components.forms import PasswordFormField
42+
import datetime
43+
from django.db import models
44+
45+
from simplepro.components import fields
46+
from simplepro.components.fields import PasswordInputField
47+
from simplepro.models import BaseModel
48+
49+
50+
class AppleId(BaseModel):
51+
email = fields.CharField(verbose_name="绑定的邮箱", max_length=30, placeholder="请输入电子邮箱", null=True, unique=True,
52+
blank=True)
53+
tel = fields.CharField(verbose_name="绑定的手机号", max_length=11, placeholder="请输入绑定的手机号", null=True, unique=True,
54+
blank=True, show_word_limit=True)
55+
passwd = PasswordInputField(verbose_name='密码', max_length=12, placeholder='请输入密码', null=True, blank=True,
56+
show_password=True, show_word_limit=True, pattern="0123456789", encrypt="md5")
57+
last2FactorAuthenticateAt = models.DateTimeField(verbose_name="上次两步验证时间", null=True, blank=True, editable=False)
58+
lastConfirmedSessionValidityAt = models.DateTimeField(verbose_name="上次确认会话有效性时间", null=True, blank=True,
59+
editable=False)
60+
maxSessionAge = models.DurationField(verbose_name="最长会话有效期", blank=True, editable=False,
61+
default=datetime.timedelta(seconds=0))
62+
```
4163

42-
from .models import DbServiceUser
64+
![](static/apple_id.png)
4365

66+
## 高级组件
4467

45-
class DbServiceUserForm(ModelForm):
46-
password = PasswordFormField(label="密码", required=False, encryptByMd5=False)
68+
### Json编辑器
4769

48-
class Meta:
49-
model = DbServiceUser
50-
fields = ['owner', 'service', 'username', 'password', 'hasRootPriority']
70+
继承自`models.TextField`表单字段
71+
72+
#### 效果图
73+
74+
![](static/json_text_field.png)
75+
76+
#### 如何引入
77+
78+
```python
79+
from simplepro.editor.fields import JsonTextField
80+
```
81+
82+
#### 参数
83+
84+
目前没有专属参数,其他参数都继承`models.TextField`.
85+
86+
#### 示例
87+
88+
```python
89+
from django.db import models
90+
from simplepro.models import BaseModel
91+
92+
from simplepro.editor.fields import JsonTextField
93+
94+
95+
class LocalMedia(BaseModel):
96+
id = models.CharField(max_length=50, primary_key=True)
97+
98+
filename = models.CharField(max_length=100, verbose_name="文件名", null=True, blank=True)
99+
ext = models.CharField(max_length=10, verbose_name="扩展名", null=True, blank=True)
100+
size = models.BigIntegerField(verbose_name="大小", null=True, blank=True)
101+
duration = models.PositiveIntegerField(null=True, verbose_name="时长", blank=True)
102+
dimensionX = models.IntegerField(verbose_name="DX", null=True, blank=True)
103+
dimensionY = models.IntegerField(verbose_name="DY", null=True, blank=True)
104+
orientation = models.IntegerField(null=True, verbose_name="方向", blank=True)
105+
adjustmentRenderType = models.IntegerField(null=True, blank=True)
106+
timeZoneOffset = models.IntegerField(null=True, blank=True)
107+
burstFlags = models.IntegerField(null=True, blank=True)
51108

52-
```
109+
masterRecordChangeTag = models.CharField(max_length=50, null=True, blank=True)
110+
assetRecordChangeTag = models.CharField(max_length=50, null=True, blank=True)
111+
112+
asset_date = models.DateTimeField(verbose_name="生成时间", null=True, blank=True)
113+
added_date = models.DateTimeField(verbose_name="加入icloud的时间", null=True, blank=True)
114+
detach_icloud_date = models.DateTimeField(verbose_name="从icloud中移除时间", null=True, blank=True)
115+
116+
locationEnc = models.TextField(null=True, verbose_name="地址信息(已加密)", blank=True)
117+
118+
thumb = models.ImageField(verbose_name="缩略图", upload_to=upload_thumb, null=True, help_text="视频和图像都会有,JPEG格式",
119+
blank=True)
120+
prv = models.FileField(verbose_name="可预览文件", null=True, upload_to=upload_prv,
121+
help_text="HICH图片和PNG图片的可预览文件为JPEG图,MOV视频的可预览文件为MP4", blank=True)
122+
origin = models.FileField(verbose_name="原始文件", null=True, upload_to=upload_origin, blank=True)
123+
124+
versions = JsonTextField(null=True, blank=True)
125+
masterRecord = JsonTextField(null=True, blank=True)
126+
assetRecord = JsonTextField(null=True, blank=True)
127+
assetRecordAfterDelete = JsonTextField(null=True, blank=True)
128+
129+
class Meta:
130+
verbose_name = "本地资源"
131+
ordering = ('-asset_date',)
132+
```
133+
![](static/json_editor_example.png)

docs/static/apple_id.png

377 KB
Loading

docs/static/json_editor_example.png

352 KB
Loading

docs/static/json_text_field.png

315 KB
Loading

0 commit comments

Comments
 (0)