refactor(admin): remove download config settings page and chain
- Drop the download config menu entry, route and schema from the settings SPA - Remove the PHP schema section, the server-side alias validation and the reserved-alias list that only served that section - Unregister aksrt_download_config from standalone import/export keys - Drop the contract tests that locked the removed page; the Download.php runtime contracts stay untouched
This commit is contained in:
@@ -140,22 +140,6 @@ class SchemaPermissions {
|
||||
]],
|
||||
],
|
||||
],
|
||||
'download' => [
|
||||
'key' => 'download',
|
||||
'title' => '下载配置',
|
||||
'version' => '1.1.0',
|
||||
'option_key' => 'aksrt_download_config',
|
||||
'groups' => [
|
||||
['key' => 'basic', 'title' => '下载总开关', 'fields' => [
|
||||
['key' => 'enabled', 'label' => '启用本站下载链接', 'type' => 'switch', 'default' => true, 'help' => '总开关:开启后下载通过本站中转链接(别名、次数、有效期生效);关闭后下载按钮直接使用原始下载地址(直连),下方链接规则全部不生效,旧的中转链接同步失效。'],
|
||||
]],
|
||||
['key' => 'rules', 'title' => '链接规则', 'fields' => [
|
||||
['key' => 'url_alias', 'label' => '下载链接 URL 别名', 'type' => 'input', 'default' => 'download', 'required' => true, 'dependsOn' => ['key' => 'enabled', 'value' => true], 'help' => '仅允许英文字母、数字、连字符和下划线;禁止中文、空格和 / \\ ? # & 等特殊符号。修改后旧别名路由立即失效,需重新获取下载地址。'],
|
||||
['key' => 'default_max_uses', 'label' => '下载链接默认使用次数', 'type' => 'number', 'default' => 1, 'min' => 1, 'max' => 100, 'dependsOn' => ['key' => 'enabled', 'value' => true], 'help' => '单个链接可完成下载的次数;文件完整送达后才计次(HEAD 探测、传输中断不计次)。耗尽后链接返回 410,需重新获取。'],
|
||||
['key' => 'ttl_minutes', 'label' => '下载链接默认有效期限(分钟)', 'type' => 'number', 'default' => 10, 'min' => 1, 'max' => 1440, 'dependsOn' => ['key' => 'enabled', 'value' => true], 'help' => '链接签发后超过该时长即失效并返回 410,不自动续期,需重新获取。'],
|
||||
]],
|
||||
],
|
||||
],
|
||||
'moderation' => [
|
||||
'key' => 'moderation',
|
||||
'title' => '评论审核',
|
||||
|
||||
@@ -301,19 +301,6 @@ class SchemaProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if ($domain === 'permissions' && $section === 'download') {
|
||||
$alias = trim((string) ($data['url_alias'] ?? ''));
|
||||
if ($alias === '') {
|
||||
$errors[] = __('下载链接 URL 别名不能为空', 'aksrt');
|
||||
} elseif (strlen($alias) > 48) {
|
||||
$errors[] = __('下载链接 URL 别名长度不能超过 48 个字符', 'aksrt');
|
||||
} elseif (!preg_match('/^[A-Za-z0-9_-]+$/', $alias)) {
|
||||
$errors[] = __('下载链接 URL 别名只能包含英文字母、数字、连字符和下划线,禁止中文、空格和 / \\ ? # & 等特殊符号', 'aksrt');
|
||||
} elseif (in_array(strtolower($alias), $this->reserved_download_aliases(), true)) {
|
||||
$errors[] = __('该别名与系统保留路径冲突,请更换其他别名以避免路由 404', 'aksrt');
|
||||
}
|
||||
}
|
||||
|
||||
return ['valid' => empty($errors), 'errors' => $errors];
|
||||
}
|
||||
|
||||
@@ -443,18 +430,6 @@ class SchemaProvider {
|
||||
&& empty($parts['fragment']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top-level slugs that must never be shadowed by the download route.
|
||||
*/
|
||||
private function reserved_download_aliases(): array {
|
||||
return [
|
||||
'wp-json', 'wp-admin', 'wp-content', 'wp-includes',
|
||||
'admin', 'login', 'logout', 'register', 'lostpassword',
|
||||
'feed', 'search', 'author', 'page', 'comments',
|
||||
'sitemap', 'sign', 'cgi-bin',
|
||||
];
|
||||
}
|
||||
|
||||
public function read_settings(string $domain, string $section = ''): array {
|
||||
if ($section !== '') {
|
||||
$schema = $this->get_section_schema($domain, $section);
|
||||
|
||||
@@ -36,7 +36,6 @@ class Settings {
|
||||
public const STANDALONE_OPTION_KEYS = [
|
||||
'aksrt_captcha_config',
|
||||
'aksrt_moderation_config',
|
||||
'aksrt_download_config',
|
||||
'aksrt_footer_tabbar',
|
||||
'aksrt_floating_buttons',
|
||||
'aksrt_credit_settings',
|
||||
|
||||
Reference in New Issue
Block a user