Skip to content

Commit 2c5757a

Browse files
authored
Merge pull request #115 from YouZiXiL/main
refactor(admin): 允许字典名称包含下划线
2 parents 14563a1 + a984cce commit 2c5757a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/plugin/admin/app/controller/DictController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public function insert(Request $request): Response
6666
if (Dict::get($name)) {
6767
return $this->json(1, '字典已经存在');
6868
}
69-
if (!preg_match('/^[a-zA-Z0-9]+$/', $name)) {
70-
return $this->json(2, '字典名称只能是字母数字的组合');
69+
if (!preg_match('/^[a-zA-Z0-9_]+$/', $name)) {
70+
return $this->json(2, '字典名称只能是字母数字下划线的组合');
7171
}
7272
$values = (array)$request->post('value', []);
7373
Dict::save($name, $values);
@@ -88,8 +88,8 @@ public function update(Request $request): Response
8888
if (!Dict::get($name)) {
8989
return $this->json(1, '字典不存在');
9090
}
91-
if (!preg_match('/^[a-zA-Z0-9]+$/', $name)) {
92-
return $this->json(2, '字典名称只能是字母数字的组合');
91+
if (!preg_match('/^[a-zA-Z0-9_]+$/', $name)) {
92+
return $this->json(2, '字典名称只能是字母数字下划线的组合');
9393
}
9494
Dict::save($name, $request->post('value'));
9595
}

0 commit comments

Comments
 (0)