Skip to content

Commit 5c135b4

Browse files
committed
优化了密码组件使其能够支持自定义style,自定义大小,开启或关闭自动获取焦点和大小可以自由拖动调整等属性。
Signed-off-by: Sadam·Sadik <1903249375@qq.com>
1 parent 0fb7226 commit 5c135b4

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/simplePlus.egg-info/
66
/build/
77
/DjangoAsyncAdmin.egg-info/
8+
.DS_Store

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "DjangoAsyncAdmin"
3-
version = "6.7.3"
3+
version = "6.8.0"
44
authors = [
55
{ name = "Sadam·Sadik", email = "1903249375@qq.com" },
66
]

simplepro/components/fields/input_password_field.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ def __init__(self,
3434

3535
class PasswordInputField(models.CharField):
3636
""" custom model field """
37-
max_length = None
38-
min_length = None
3937

4038
def __init__(self,
4139
min_length=6,
42-
placeholder=None, clearable=True, show_password=False,
40+
placeholder=None, clearable=True, show_password=True,
4341
show_word_limit=False, disabled=False, readonly=False,
42+
size=None,
43+
resize=None,
44+
autofocus=False,
45+
style=None,
4446
encrypt: str = None,
4547
pattern: str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-$%&@+!",
4648
*args, **kwargs):
49+
4750
self.items = {
4851
'max_length': kwargs.get('max_length'),
4952
'min_length': min_length,
@@ -53,8 +56,12 @@ def __init__(self,
5356
'disabled': disabled,
5457
'readonly': readonly,
5558
'show_word_limit': show_word_limit,
59+
'size': size,
60+
'resize': resize,
61+
'autofocus': autofocus,
5662
'encrypt': encrypt,
57-
'pattern': pattern
63+
'pattern': pattern,
64+
'style': style
5865
}
5966
super(PasswordInputField, self).__init__(*args, **kwargs)
6067

simplepro/components/widgets/input_password.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ def __init__(self,
2727
show_password=False,
2828
show_word_limit=False,
2929
disabled=False, readonly=False,
30-
size=None, prefix_icon=None, suffix_icon=None, rows=None, autocomplete=None,
30+
size=None,
31+
prefix_icon=None, suffix_icon=None, rows=None, autocomplete=None, # 这几个参数是几乎没有用到,也用不到
3132
resize=None, autofocus=False,
3233
encrypt: str = "",
3334
pattern: str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-$%&@+!",
35+
style=None,
3436
*args, **kwargs):
3537
super(PasswordInputWidget, self).__init__(*args)
3638
self.items = {
@@ -53,6 +55,7 @@ def __init__(self,
5355
self.min_length = min_length
5456
self.pattern = pattern
5557
self.encrypt = encrypt
58+
self.style = style
5659

5760
def build_attrs(self):
5861
attrs = ""
@@ -86,6 +89,7 @@ def render(self, name, value, attrs=None, renderer=None):
8689
'pwdPattern': self.pattern,
8790
'encrypt': force_text(self.encrypt)
8891
},
92+
'style': self.style
8993
}
9094
_str = render_to_string(self.template_name, ctx)
9195
return mark_safe(_str)

simplepro/templates/admin/components/input_password.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{# <el-button type="info" size="small" @click="copy">复制</el-button>#}
77
{# <el-button type="primary" size="small" @click="reset">手动修改</el-button>#}
88
<input type="hidden" name="{{ raw_name }}" v-model="value">
9-
<el-input v-model="value" {{ attrs|safe }} :maxlength="lenMax" :minlength="lenMin">
9+
<el-input v-model="value" {{ attrs|safe }} {% if style %} style="{{ style|safe }}"{% endif %} :maxlength="lenMax" :minlength="lenMin">
1010
<el-button slot="prepend" @click="generate" type="success">随机生成</el-button>
1111
{# <el-button slot="append" @click="reset" type="primary" icon="el-icon-edit">手动修改</el-button>#}
1212
<el-button slot="append" @click="copy" type="info" icon="el-icon-document-copy">复制</el-button>

0 commit comments

Comments
 (0)