fix: read public config contract as snake_case (sync backend D7 follow-up)

Drop the allowedFileTypes camel twin from SystemConfig/ConfigState/
config-storage defaults and mapping; send-flow file-type validation
reads allowed_file_types only; DEFAULT_CONFIG drops dead keys.
This commit is contained in:
Marrrrrrrrry committed 2026-09-11 04:09:25 +08:00
1 parent fbd90f938e
commit f1893579cc
5 files changed
+8 -17

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ export function useSendFlow() {
})
)
const allowedFileTypes = computed(() => {
const types = config.value.allowedFileTypes || config.value.allowed_file_types || ['*']
const types = config.value.allowed_file_types || ['*']
const normalized = types.map((type) => String(type).trim()).filter(Boolean)
return normalized.length > 0 ? normalized : ['*']
})
+1 -2
View File
@@ -70,7 +70,7 @@ export function useSystemConfig() {
const normalizeEditableConfig = (nextConfig: Partial<ConfigState>): ConfigState => {
const allowedFileTypes = normalizeAllowedFileTypes(
nextConfig.allowed_file_types ?? nextConfig.allowedFileTypes
nextConfig.allowed_file_types
)
const codeGenerateType = nextConfig.code_generate_type === 'secret' ? 'secret' : 'number'
@@ -78,7 +78,6 @@ export function useSystemConfig() {
...DEFAULT_CONFIG_STATE,
...nextConfig,
allowed_file_types: allowedFileTypes,
allowedFileTypes,
code_generate_type: codeGenerateType,
admin_token: ''
}
+1 -3
View File
@@ -94,7 +94,5 @@ export const REGEX_PATTERNS = {
export const DEFAULT_CONFIG = {
name: 'FileCodeBox',
description: '文件传输工具',
maxFileSize: FILE_SIZE_LIMITS.MAX_FILE_SIZE,
allowedFileTypes: ['*'] as string[],
expireDays: 7
allowed_file_types: ['*'] as string[]
}
+1 -4
View File
@@ -1,9 +1,7 @@
export interface SystemConfig {
name: string
description?: string
maxFileSize: number
allowedFileTypes: string[]
expireDays: number
allowed_file_types: string[]
notify_title?: string
notify_content?: string
}
@@ -43,7 +41,6 @@ export interface ConfigState {
open_upload: number
upload_size: number
allowed_file_types: string[]
allowedFileTypes?: string[]
storage_path: string
storage_limit: number
upload_minute: number
+4 -7
View File
@@ -26,7 +26,6 @@ type PublicConfigInput = Omit<Partial<ConfigState>, 'show_admin_addr'> & {
export const DEFAULT_PUBLIC_CONFIG: PublicConfig = {
...DEFAULT_CONFIG,
upload_size: FILE_SIZE_LIMITS.MAX_FILE_SIZE,
allowedFileTypes: ['*'],
allowed_file_types: ['*'],
expire_style: ['day'],
code_generate_type: 'secret',
@@ -51,8 +50,7 @@ export const DEFAULT_CONFIG_STATE: ConfigState = {
notify_content: '',
open_upload: DEFAULT_PUBLIC_CONFIG.open_upload,
upload_size: DEFAULT_PUBLIC_CONFIG.upload_size,
allowed_file_types: DEFAULT_PUBLIC_CONFIG.allowedFileTypes,
allowedFileTypes: DEFAULT_PUBLIC_CONFIG.allowedFileTypes,
allowed_file_types: DEFAULT_PUBLIC_CONFIG.allowed_file_types,
storage_path: '',
storage_limit: 0,
upload_minute: 1,
@@ -87,7 +85,7 @@ function normalizeFileTypes(value: unknown): string[] {
? value.split(',')
: Array.isArray(value)
? value
: DEFAULT_PUBLIC_CONFIG.allowedFileTypes
: DEFAULT_PUBLIC_CONFIG.allowed_file_types
const normalized = rawTypes.map((item) => String(item).trim()).filter(Boolean)
return normalized.length > 0 ? normalized : ['*']
}
@@ -111,14 +109,13 @@ export function toPublicConfig(
): Partial<PublicConfig> {
if (!config) return {}
const allowedFileTypes = normalizeFileTypes(config.allowedFileTypes ?? config.allowed_file_types)
const allowed_file_types = normalizeFileTypes(config.allowed_file_types)
return {
name: config.name,
description: config.description,
upload_size: config.upload_size,
allowedFileTypes,
allowed_file_types: allowedFileTypes,
allowed_file_types,
expire_style: config.expire_style,
code_generate_type: config.code_generate_type,
open_upload: config.open_upload,