refactor(phone-image): 配置字段对齐,架构文档更新

- PHP getConfigFields 移除 template/font,新增 pageAlignments
- validateConfig 字段与 getConfigFields 一致
- 架构文档更新数据流、配置体系、已知问题、修复记录章节
This commit is contained in:
augushong
2026-05-11 21:24:16 +08:00
parent e9d839ae8a
commit 518085d493
2 changed files with 126 additions and 50 deletions

View File

@@ -15,11 +15,10 @@ class PhoneImage implements PostOutputManagerInterface
public function getConfigFields(): array
{
return [
'template' => ['type' => 'select', 'options' => ['minimal', 'magazine', 'mixed'], 'default' => 'minimal'],
'size' => ['type' => 'select', 'options' => ['xiaohongshu', 'douyin'], 'default' => 'xiaohongshu'],
'font' => ['type' => 'select', 'options' => ['source-han-sans', 'alibaba-puhuiti', 'lxgw-wenkai'], 'default' => 'source-han-sans'],
'fontSize' => ['type' => 'number', 'default' => 14, 'min' => 10, 'max' => 24],
'watermark' => ['type' => 'text', 'default' => ''],
'pageAlignments' => ['type' => 'json', 'default' => '{}'],
];
}
@@ -30,21 +29,17 @@ class PhoneImage implements PostOutputManagerInterface
{
$fields = $this->getConfigFields();
if (isset($config['template']) && !in_array($config['template'], $fields['template']['options'])) {
return false;
}
if (isset($config['size']) && !in_array($config['size'], $fields['size']['options'])) {
return false;
}
if (isset($config['font']) && !in_array($config['font'], $fields['font']['options'])) {
return false;
}
if (isset($config['fontSize'])) {
$size = intval($config['fontSize']);
if ($size < $fields['fontSize']['min'] || $size > $fields['fontSize']['max']) {
return false;
}
}
// watermark 是文本类型,无需特殊验证
// pageAlignments 是 JSON 类型,存储时由框架自动序列化
return true;
}