feat:限制模块名称规则

This commit is contained in:
JaguarJack 2023-06-07 09:28:30 +08:00
parent 66f19d8ef1
commit a36fa86d8d
3 changed files with 11 additions and 20 deletions

View File

@ -8,7 +8,6 @@ use Exception;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Modules\Develop\Support\Generate\Create\Schema;
use Illuminate\Support\Facades\Schema as SchemaFacade;
class Schemas extends CatchModel
{
@ -108,22 +107,4 @@ class Schemas extends CatchModel
return $schema;
}
/**
* delete
*
* @param $id
* @param bool $force
* @return bool|null
*/
public function deleteBy($id, bool $force = false): ?bool
{
$schema = parent::firstBy($id);
if ($schema->delete()) {
SchemaFacade::dropIfExists($schema->name);
}
return true;
}
}

View File

@ -22,6 +22,16 @@
required: true,
message: '模块名称必须填写',
},
{
validator: (rule: any, value: any, callback: any) => {
if (! /^[A-Za-z]+$/.test(value)) {
callback('模块名称只允许大小字母组合')
} else {
callback()
}
},
trigger: 'blur',
},
]"
>
<el-input v-model="formData.title" />

View File

@ -64,7 +64,7 @@ const schemaVisible = ref<boolean>(false)
const api = 'schema'
const { data, query, search, reset, loading } = useGetList(api)
const { destroy, deleted } = useDestroy('确认删除吗? 将会删除数据库的 Schema请提前做好备份一旦删除将无法恢复!')
const { destroy, deleted } = useDestroy('确认删除吗? 删除后数据表将会保留,如需删除相关表,请手动进行删除!')
const { open, close, title, visible, id } = useOpen()
const tableData = computed(() => data.value?.data)