mirror of
https://github.com/vastsa/FileCodeBoxFronted.git
synced 2026-11-24 21:58:01 +08:00
Merge pull request #11 from Marrrrrrrrry/main
API 字段与配置键统一 snake_case(配合后端契约变更,请与后端 PR 同窗口合入)
This commit is contained in:
25 files changed
+367
-428
No files matched your search
+1
-1
@@ -26,7 +26,7 @@ const { config } = storeToRefs(configStore)
|
||||
const adminStore = useAdminStore()
|
||||
const { t } = useI18n()
|
||||
const { verifySession } = useAdminSession()
|
||||
const showAdminAddress = computed(() => config.value.showAdminAddr === 1)
|
||||
const showAdminAddress = computed(() => config.value.show_admin_addr === 1)
|
||||
const adminEntryLabel = computed(() =>
|
||||
t(adminStore.isAuthenticated ? 'admin.session.loggedIn' : 'admin.session.loggedOut')
|
||||
)
|
||||
|
||||
+123
-127
@@ -40,22 +40,22 @@ import {
|
||||
import { buildRetrieveUrl } from '@/utils/share-url'
|
||||
|
||||
const emptySummary = (): AdminFileSummary => ({
|
||||
totalFiles: 0,
|
||||
activeCount: 0,
|
||||
expiredCount: 0,
|
||||
textCount: 0,
|
||||
fileCount: 0,
|
||||
chunkedCount: 0,
|
||||
healthAttentionCount: 0,
|
||||
healthDangerCount: 0,
|
||||
healthWarningCount: 0,
|
||||
expiringSoonCount: 0,
|
||||
storageIssueCount: 0,
|
||||
neverRetrievedCount: 0,
|
||||
healthyCount: 0,
|
||||
permanentCount: 0,
|
||||
storageUsed: 0,
|
||||
usedCount: 0
|
||||
total_files: 0,
|
||||
active_count: 0,
|
||||
expired_count: 0,
|
||||
text_count: 0,
|
||||
file_count: 0,
|
||||
chunked_count: 0,
|
||||
health_attention_count: 0,
|
||||
health_danger_count: 0,
|
||||
health_warning_count: 0,
|
||||
expiring_soon_count: 0,
|
||||
storage_issue_count: 0,
|
||||
never_retrieved_count: 0,
|
||||
healthy_count: 0,
|
||||
permanent_count: 0,
|
||||
storage_used: 0,
|
||||
used_count: 0
|
||||
})
|
||||
|
||||
const normalizeCount = (value: number | string | null | undefined) => Number(value || 0)
|
||||
@@ -172,8 +172,8 @@ const buildDefaultViewPresetParams = (): AdminFileViewPresetParams => ({
|
||||
status: 'all',
|
||||
type: 'all',
|
||||
health: 'all',
|
||||
sortBy: 'created_at',
|
||||
sortOrder: 'desc',
|
||||
sort_by: 'created_at',
|
||||
sort_order: 'desc',
|
||||
size: 10
|
||||
})
|
||||
|
||||
@@ -189,15 +189,15 @@ const normalizeViewPresetParams = (params: unknown): AdminFileViewPresetParams =
|
||||
status: normalizePresetChoice(rawParams.status, adminFileStatusFilters, defaults.status),
|
||||
type: normalizePresetChoice(rawParams.type, adminFileTypeFilters, defaults.type),
|
||||
health: normalizePresetChoice(rawParams.health, adminFileHealthFilters, defaults.health),
|
||||
sortBy: normalizePresetChoice(
|
||||
rawParams.sortBy ?? rawParams.sort_by,
|
||||
sort_by: normalizePresetChoice(
|
||||
rawParams.sort_by,
|
||||
adminFileSortFields,
|
||||
defaults.sortBy
|
||||
defaults.sort_by
|
||||
),
|
||||
sortOrder: normalizePresetChoice(
|
||||
rawParams.sortOrder ?? rawParams.sort_order,
|
||||
sort_order: normalizePresetChoice(
|
||||
rawParams.sort_order,
|
||||
adminFileSortOrders,
|
||||
defaults.sortOrder
|
||||
defaults.sort_order
|
||||
),
|
||||
size: normalizePresetSize(rawParams.size ?? defaults.size)
|
||||
}
|
||||
@@ -220,8 +220,8 @@ export function useAdminFiles() {
|
||||
status: 'all',
|
||||
type: 'all',
|
||||
health: 'all',
|
||||
sortBy: 'created_at',
|
||||
sortOrder: 'desc'
|
||||
sort_by: 'created_at',
|
||||
sort_order: 'desc'
|
||||
})
|
||||
|
||||
const showEditModal = ref(false)
|
||||
@@ -262,7 +262,7 @@ export function useAdminFiles() {
|
||||
() => isBatchDeleting.value || isBatchUpdating.value || isBatchPolicyActionRunning.value
|
||||
)
|
||||
const totalPages = computed(() => Math.max(Math.ceil(params.value.total / params.value.size), 1))
|
||||
const storageUsedText = computed(() => formatFileSize(summary.value.storageUsed))
|
||||
const storageUsedText = computed(() => formatFileSize(summary.value.storage_used))
|
||||
const currentPageSelectedCount = computed(
|
||||
() => tableData.value.filter((file) => selectedFileIds.value.has(file.id)).length
|
||||
)
|
||||
@@ -282,8 +282,8 @@ export function useAdminFiles() {
|
||||
status: params.value.status === 'all' ? undefined : params.value.status,
|
||||
type: params.value.type === 'all' ? undefined : params.value.type,
|
||||
health: params.value.health === 'all' ? undefined : params.value.health,
|
||||
sortBy: params.value.sortBy,
|
||||
sortOrder: params.value.sortOrder
|
||||
sort_by: params.value.sort_by,
|
||||
sort_order: params.value.sort_order
|
||||
}))
|
||||
|
||||
const hasActiveFilters = computed(
|
||||
@@ -299,8 +299,8 @@ export function useAdminFiles() {
|
||||
status: params.value.status || 'all',
|
||||
type: params.value.type || 'all',
|
||||
health: params.value.health || 'all',
|
||||
sortBy: params.value.sortBy || 'created_at',
|
||||
sortOrder: params.value.sortOrder || 'desc',
|
||||
sort_by: params.value.sort_by || 'created_at',
|
||||
sort_order: params.value.sort_order || 'desc',
|
||||
size: params.value.size || 10
|
||||
})
|
||||
|
||||
@@ -318,9 +318,7 @@ export function useAdminFiles() {
|
||||
id,
|
||||
name: t(nameKey),
|
||||
filters: presetFilters,
|
||||
params: presetFilters,
|
||||
isBuiltIn: true,
|
||||
isDefault: id === builtInAllViewPresetId,
|
||||
is_default: id === builtInAllViewPresetId
|
||||
}
|
||||
}
|
||||
@@ -350,46 +348,46 @@ export function useAdminFiles() {
|
||||
])
|
||||
|
||||
const healthFilterOptions = computed<HealthFilterOption[]>(() => [
|
||||
{ value: 'all', label: t('fileManage.healthFilters.all'), count: summary.value.totalFiles },
|
||||
{ value: 'all', label: t('fileManage.healthFilters.all'), count: summary.value.total_files },
|
||||
{
|
||||
value: 'attention',
|
||||
label: t('fileManage.healthFilters.attention'),
|
||||
count: summary.value.healthAttentionCount
|
||||
count: summary.value.health_attention_count
|
||||
},
|
||||
{
|
||||
value: 'danger',
|
||||
label: t('fileManage.healthFilters.danger'),
|
||||
count: summary.value.healthDangerCount
|
||||
count: summary.value.health_danger_count
|
||||
},
|
||||
{
|
||||
value: 'warning',
|
||||
label: t('fileManage.healthFilters.warning'),
|
||||
count: summary.value.healthWarningCount
|
||||
count: summary.value.health_warning_count
|
||||
},
|
||||
{
|
||||
value: 'expiring_soon',
|
||||
label: t('fileManage.healthFilters.expiringSoon'),
|
||||
count: summary.value.expiringSoonCount
|
||||
count: summary.value.expiring_soon_count
|
||||
},
|
||||
{
|
||||
value: 'storage_issue',
|
||||
label: t('fileManage.healthFilters.storageIssue'),
|
||||
count: summary.value.storageIssueCount
|
||||
count: summary.value.storage_issue_count
|
||||
},
|
||||
{
|
||||
value: 'never_retrieved',
|
||||
label: t('fileManage.healthFilters.neverRetrieved'),
|
||||
count: summary.value.neverRetrievedCount
|
||||
count: summary.value.never_retrieved_count
|
||||
},
|
||||
{
|
||||
value: 'healthy',
|
||||
label: t('fileManage.healthFilters.healthy'),
|
||||
count: summary.value.healthyCount
|
||||
count: summary.value.healthy_count
|
||||
},
|
||||
{
|
||||
value: 'permanent',
|
||||
label: t('fileManage.healthFilters.permanent'),
|
||||
count: summary.value.permanentCount
|
||||
count: summary.value.permanent_count
|
||||
}
|
||||
])
|
||||
|
||||
@@ -425,14 +423,14 @@ export function useAdminFiles() {
|
||||
)
|
||||
|
||||
const inferIsText = (file: FileListItem) => {
|
||||
if (typeof file.isText === 'boolean') return file.isText
|
||||
if (typeof file.is_text === 'boolean') return file.is_text
|
||||
if (typeof file.is_text === 'boolean') return file.is_text
|
||||
if (file.type) return file.type === 'text'
|
||||
return Boolean(file.text)
|
||||
}
|
||||
|
||||
const inferIsExpired = (file: FileListItem) => {
|
||||
if (typeof file.isExpired === 'boolean') return file.isExpired
|
||||
if (typeof file.is_expired === 'boolean') return file.is_expired
|
||||
if (typeof file.is_expired === 'boolean') return file.is_expired
|
||||
if (
|
||||
file.expired_count !== null &&
|
||||
@@ -444,10 +442,10 @@ export function useAdminFiles() {
|
||||
return isExpiredByDate(file.expired_at)
|
||||
}
|
||||
|
||||
const inferIsChunked = (file: FileListItem) => Boolean(file.isChunked ?? file.is_chunked)
|
||||
const inferIsChunked = (file: FileListItem) => Boolean(file.is_chunked)
|
||||
|
||||
const getRemainingDownloads = (file: FileListItem) => {
|
||||
if (file.remainingDownloads !== undefined) return file.remainingDownloads
|
||||
if (file.remaining_downloads !== undefined) return file.remaining_downloads
|
||||
if (file.remaining_downloads !== undefined) return file.remaining_downloads
|
||||
if (
|
||||
file.expired_count !== null &&
|
||||
@@ -460,30 +458,30 @@ export function useAdminFiles() {
|
||||
}
|
||||
|
||||
const buildFallbackSummary = (files: AdminFileViewItem[], total: number): AdminFileSummary => ({
|
||||
totalFiles: total,
|
||||
activeCount: files.filter((file) => !file.isExpiredFile).length,
|
||||
expiredCount: files.filter((file) => file.isExpiredFile).length,
|
||||
textCount: files.filter((file) => file.isTextFile).length,
|
||||
fileCount: files.filter((file) => !file.isTextFile).length,
|
||||
chunkedCount: files.filter((file) => file.isChunkedFile).length,
|
||||
healthAttentionCount: files.filter((file) =>
|
||||
total_files: total,
|
||||
active_count: files.filter((file) => !file.isExpiredFile).length,
|
||||
expired_count: files.filter((file) => file.isExpiredFile).length,
|
||||
text_count: files.filter((file) => file.isTextFile).length,
|
||||
file_count: files.filter((file) => !file.isTextFile).length,
|
||||
chunked_count: files.filter((file) => file.isChunkedFile).length,
|
||||
health_attention_count: files.filter((file) =>
|
||||
['danger', 'warning'].includes(file.statusInsightSeverity)
|
||||
).length,
|
||||
healthDangerCount: files.filter((file) => file.statusInsightSeverity === 'danger').length,
|
||||
healthWarningCount: files.filter((file) => file.statusInsightSeverity === 'warning').length,
|
||||
expiringSoonCount: files.filter((file) => file.statusInsightReasons.includes('expires_soon'))
|
||||
health_danger_count: files.filter((file) => file.statusInsightSeverity === 'danger').length,
|
||||
health_warning_count: files.filter((file) => file.statusInsightSeverity === 'warning').length,
|
||||
expiring_soon_count: files.filter((file) => file.statusInsightReasons.includes('expires_soon'))
|
||||
.length,
|
||||
storageIssueCount: files.filter((file) =>
|
||||
storage_issue_count: files.filter((file) =>
|
||||
file.statusInsightReasons.includes('storage_metadata_incomplete')
|
||||
).length,
|
||||
neverRetrievedCount: files.filter((file) =>
|
||||
never_retrieved_count: files.filter((file) =>
|
||||
file.statusInsightReasons.includes('never_retrieved')
|
||||
).length,
|
||||
healthyCount: files.filter((file) => file.statusInsightSeverity === 'success').length,
|
||||
permanentCount: files.filter((file) => file.statusInsightState === 'permanent').length,
|
||||
storageUsed: files.reduce((totalSize, file) => totalSize + normalizeCount(file.size), 0),
|
||||
usedCount: files.reduce(
|
||||
(totalUsed, file) => totalUsed + normalizeCount(file.usedCount ?? file.used_count),
|
||||
healthy_count: files.filter((file) => file.statusInsightSeverity === 'success').length,
|
||||
permanent_count: files.filter((file) => file.statusInsightState === 'permanent').length,
|
||||
storage_used: files.reduce((totalSize, file) => totalSize + normalizeCount(file.size), 0),
|
||||
used_count: files.reduce(
|
||||
(totalUsed, file) => totalUsed + normalizeCount(file.used_count),
|
||||
0
|
||||
)
|
||||
})
|
||||
@@ -497,28 +495,28 @@ export function useAdminFiles() {
|
||||
if (!rawSummary) return fallback
|
||||
|
||||
return {
|
||||
totalFiles: normalizeCount(rawSummary.totalFiles ?? fallback.totalFiles),
|
||||
activeCount: normalizeCount(rawSummary.activeCount ?? fallback.activeCount),
|
||||
expiredCount: normalizeCount(rawSummary.expiredCount ?? fallback.expiredCount),
|
||||
textCount: normalizeCount(rawSummary.textCount ?? fallback.textCount),
|
||||
fileCount: normalizeCount(rawSummary.fileCount ?? fallback.fileCount),
|
||||
chunkedCount: normalizeCount(rawSummary.chunkedCount ?? fallback.chunkedCount),
|
||||
healthAttentionCount: normalizeCount(
|
||||
rawSummary.healthAttentionCount ?? fallback.healthAttentionCount
|
||||
total_files: normalizeCount(rawSummary.total_files ?? fallback.total_files),
|
||||
active_count: normalizeCount(rawSummary.active_count ?? fallback.active_count),
|
||||
expired_count: normalizeCount(rawSummary.expired_count ?? fallback.expired_count),
|
||||
text_count: normalizeCount(rawSummary.text_count ?? fallback.text_count),
|
||||
file_count: normalizeCount(rawSummary.file_count ?? fallback.file_count),
|
||||
chunked_count: normalizeCount(rawSummary.chunked_count ?? fallback.chunked_count),
|
||||
health_attention_count: normalizeCount(
|
||||
rawSummary.health_attention_count ?? fallback.health_attention_count
|
||||
),
|
||||
healthDangerCount: normalizeCount(rawSummary.healthDangerCount ?? fallback.healthDangerCount),
|
||||
healthWarningCount: normalizeCount(
|
||||
rawSummary.healthWarningCount ?? fallback.healthWarningCount
|
||||
health_danger_count: normalizeCount(rawSummary.health_danger_count ?? fallback.health_danger_count),
|
||||
health_warning_count: normalizeCount(
|
||||
rawSummary.health_warning_count ?? fallback.health_warning_count
|
||||
),
|
||||
expiringSoonCount: normalizeCount(rawSummary.expiringSoonCount ?? fallback.expiringSoonCount),
|
||||
storageIssueCount: normalizeCount(rawSummary.storageIssueCount ?? fallback.storageIssueCount),
|
||||
neverRetrievedCount: normalizeCount(
|
||||
rawSummary.neverRetrievedCount ?? fallback.neverRetrievedCount
|
||||
expiring_soon_count: normalizeCount(rawSummary.expiring_soon_count ?? fallback.expiring_soon_count),
|
||||
storage_issue_count: normalizeCount(rawSummary.storage_issue_count ?? fallback.storage_issue_count),
|
||||
never_retrieved_count: normalizeCount(
|
||||
rawSummary.never_retrieved_count ?? fallback.never_retrieved_count
|
||||
),
|
||||
healthyCount: normalizeCount(rawSummary.healthyCount ?? fallback.healthyCount),
|
||||
permanentCount: normalizeCount(rawSummary.permanentCount ?? fallback.permanentCount),
|
||||
storageUsed: normalizeCount(rawSummary.storageUsed ?? fallback.storageUsed),
|
||||
usedCount: normalizeCount(rawSummary.usedCount ?? fallback.usedCount)
|
||||
healthy_count: normalizeCount(rawSummary.healthy_count ?? fallback.healthy_count),
|
||||
permanent_count: normalizeCount(rawSummary.permanent_count ?? fallback.permanent_count),
|
||||
storage_used: normalizeCount(rawSummary.storage_used ?? fallback.storage_used),
|
||||
used_count: normalizeCount(rawSummary.used_count ?? fallback.used_count)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,8 +537,8 @@ export function useAdminFiles() {
|
||||
const isExpiredFile = inferIsExpired(file)
|
||||
const isChunkedFile = inferIsChunked(file)
|
||||
const remainingDownloadsValue = getRemainingDownloads(file)
|
||||
const usedCount = normalizeCount(file.usedCount ?? file.used_count)
|
||||
const statusInsights = file.statusInsights ?? file.status_insights
|
||||
const usedCount = normalizeCount(file.used_count)
|
||||
const statusInsights = file.status_insights
|
||||
const isPermanentFile =
|
||||
!file.expired_at &&
|
||||
(file.expired_count === null || file.expired_count === undefined || file.expired_count < 0)
|
||||
@@ -548,7 +546,7 @@ export function useAdminFiles() {
|
||||
statusInsights?.state ??
|
||||
(isExpiredFile ? 'expired' : isPermanentFile ? 'permanent' : 'available')
|
||||
const statusInsightNextAction =
|
||||
statusInsights?.nextAction ?? statusInsights?.next_action ?? 'monitor'
|
||||
statusInsights?.next_action ?? 'monitor'
|
||||
const statusInsightSeverity = normalizeInsightSeverity(statusInsights?.severity)
|
||||
|
||||
return {
|
||||
@@ -630,11 +628,11 @@ export function useAdminFiles() {
|
||||
const detail = file as AdminFileDetailResponse
|
||||
const policy = detail.policy
|
||||
const storage = detail.storage
|
||||
const expiredAt = policy?.expiredAt ?? policy?.expired_at ?? file.expired_at ?? null
|
||||
const expiredCount = policy?.expiredCount ?? policy?.expired_count ?? file.expired_count ?? null
|
||||
const expiredAt = policy?.expired_at ?? file.expired_at ?? null
|
||||
const expiredCount = policy?.expired_count ?? file.expired_count ?? null
|
||||
const prefixedName = `${file.prefix || ''}${file.suffix || ''}`
|
||||
const displayName =
|
||||
detail.displayName ??
|
||||
detail.display_name ??
|
||||
detail.display_name ??
|
||||
detail.filename ??
|
||||
file.name ??
|
||||
@@ -647,41 +645,41 @@ export function useAdminFiles() {
|
||||
}
|
||||
const viewItem = createFileViewItem(normalizedFile)
|
||||
const remainingDownloadsValue =
|
||||
policy?.remainingDownloads ?? policy?.remaining_downloads ?? viewItem.remainingDownloadsValue
|
||||
policy?.remaining_downloads ?? viewItem.remainingDownloadsValue
|
||||
const canPreviewText =
|
||||
detail.canPreviewText ?? detail.can_preview_text ?? viewItem.canPreviewText
|
||||
const canDownloadFile = detail.canDownload ?? detail.can_download ?? !viewItem.isExpiredFile
|
||||
detail.can_preview_text ?? viewItem.canPreviewText
|
||||
const canDownloadFile = detail.can_download ?? !viewItem.isExpiredFile
|
||||
const textLengthValue = normalizeCount(
|
||||
detail.textLength ?? detail.text_length ?? detail.text?.length
|
||||
detail.text_length ?? detail.text?.length
|
||||
)
|
||||
const isPermanentFile =
|
||||
detail.isPermanent ??
|
||||
detail.is_permanent ??
|
||||
policy?.isPermanent ??
|
||||
detail.is_permanent ??
|
||||
policy?.is_permanent ??
|
||||
policy?.is_permanent ??
|
||||
(!expiredAt && (expiredCount === null || expiredCount === undefined || expiredCount < 0))
|
||||
const hasDownloadLimitFile =
|
||||
detail.hasDownloadLimit ??
|
||||
detail.has_download_limit ??
|
||||
detail.has_download_limit ??
|
||||
(expiredCount !== null && expiredCount !== undefined && expiredCount >= 0)
|
||||
const hasExpirationTimeFile =
|
||||
detail.hasExpirationTime ?? detail.has_expiration_time ?? Boolean(expiredAt)
|
||||
detail.has_expiration_time ?? Boolean(expiredAt)
|
||||
const storageBackendValue =
|
||||
storage?.backend ?? detail.storageBackend ?? detail.storage_backend ?? '-'
|
||||
const isChunkedStorage = storage?.isChunked ?? storage?.is_chunked ?? viewItem.isChunkedFile
|
||||
const statusInsights = detail.statusInsights ?? detail.status_insights
|
||||
const isChunkedStorage = storage?.is_chunked ?? viewItem.isChunkedFile
|
||||
const statusInsights = detail.status_insights
|
||||
const statusInsightState =
|
||||
statusInsights?.state ??
|
||||
(viewItem.isExpiredFile ? 'expired' : isPermanentFile ? 'permanent' : 'available')
|
||||
const statusInsightNextAction =
|
||||
statusInsights?.nextAction ?? statusInsights?.next_action ?? 'monitor'
|
||||
const metadata = detail.metadata ?? detail.meta
|
||||
statusInsights?.next_action ?? 'monitor'
|
||||
const metadata = detail.metadata
|
||||
const metadataNote = detail.note ?? metadata?.note ?? ''
|
||||
const metadataTags = normalizeMetadataTags(detail.tags ?? metadata?.tags)
|
||||
const metadataUpdatedAt =
|
||||
detail.metadataUpdatedAt ??
|
||||
detail.metadata_updated_at ??
|
||||
metadata?.updatedAt ??
|
||||
detail.metadata_updated_at ??
|
||||
metadata?.updated_at ??
|
||||
metadata?.updated_at ??
|
||||
null
|
||||
|
||||
@@ -700,14 +698,14 @@ export function useAdminFiles() {
|
||||
hasExpirationTimeFile,
|
||||
isChunkedStorage: Boolean(isChunkedStorage),
|
||||
storageBackendValue,
|
||||
fileHashValue: storage?.fileHash ?? storage?.file_hash ?? detail.fileHash ?? detail.file_hash,
|
||||
filePathValue: storage?.filePath ?? storage?.file_path ?? detail.filePath ?? detail.file_path,
|
||||
fileHashValue: storage?.file_hash ?? detail.file_hash,
|
||||
filePathValue: storage?.file_path ?? detail.file_path,
|
||||
uuidFileNameValue:
|
||||
storage?.uuidFileName ??
|
||||
storage?.uuid_file_name ??
|
||||
detail.uuidFileName ??
|
||||
storage?.uuid_file_name ??
|
||||
detail.uuid_file_name ??
|
||||
detail.uuid_file_name,
|
||||
uploadIdValue: storage?.uploadId ?? storage?.upload_id ?? detail.uploadId ?? detail.upload_id,
|
||||
uploadIdValue: storage?.upload_id ?? detail.upload_id,
|
||||
metadataNote,
|
||||
metadataTags,
|
||||
metadataUpdatedAt,
|
||||
@@ -813,7 +811,6 @@ export function useAdminFiles() {
|
||||
|
||||
return {
|
||||
ids,
|
||||
clearExpiredAt: true,
|
||||
clear_expired_at: true
|
||||
}
|
||||
}
|
||||
@@ -822,7 +819,7 @@ export function useAdminFiles() {
|
||||
id: number,
|
||||
payload: AdminBatchUpdateFilesRequest
|
||||
): AdminFilePatchPayload => {
|
||||
if (payload.clearExpiredAt || payload.clear_expired_at) {
|
||||
if (payload.clear_expired_at) {
|
||||
return {
|
||||
id,
|
||||
expired_at: legacyForeverExpiresAt,
|
||||
@@ -850,7 +847,7 @@ export function useAdminFiles() {
|
||||
}
|
||||
|
||||
if (action === 'reset_download_limit') {
|
||||
request.downloadLimit = detailPolicyDownloadLimit
|
||||
request.download_limit = detailPolicyDownloadLimit
|
||||
request.download_limit = detailPolicyDownloadLimit
|
||||
}
|
||||
|
||||
@@ -867,7 +864,7 @@ export function useAdminFiles() {
|
||||
}
|
||||
|
||||
if (action === 'reset_download_limit') {
|
||||
request.downloadLimit = detailPolicyDownloadLimit
|
||||
request.download_limit = detailPolicyDownloadLimit
|
||||
request.download_limit = detailPolicyDownloadLimit
|
||||
}
|
||||
|
||||
@@ -913,7 +910,7 @@ export function useAdminFiles() {
|
||||
}
|
||||
|
||||
const getPresetParams = (preset: AdminFileViewPreset) =>
|
||||
normalizeViewPresetParams(preset.filters ?? preset.params)
|
||||
normalizeViewPresetParams(preset.filters)
|
||||
|
||||
const normalizeSavedViewPreset = (preset: AdminFileViewPreset): AdminFileViewPreset | null => {
|
||||
const id = String(preset.id || '').trim()
|
||||
@@ -950,8 +947,7 @@ export function useAdminFiles() {
|
||||
return {
|
||||
id,
|
||||
name: normalizedName,
|
||||
filters,
|
||||
params: filters
|
||||
filters
|
||||
}
|
||||
}
|
||||
|
||||
@@ -963,7 +959,7 @@ export function useAdminFiles() {
|
||||
isViewPresetLoading.value = true
|
||||
try {
|
||||
const response = await FileService.getAdminFileViewPresets()
|
||||
const rawPresets = response.detail?.presets ?? response.detail?.items ?? []
|
||||
const rawPresets = response.detail?.presets ?? []
|
||||
savedViewPresets.value = rawPresets
|
||||
.map((preset) => normalizeSavedViewPreset(preset))
|
||||
.filter((preset): preset is AdminFileViewPreset => Boolean(preset))
|
||||
@@ -999,8 +995,8 @@ export function useAdminFiles() {
|
||||
params.value.status = presetParams.status
|
||||
params.value.type = presetParams.type
|
||||
params.value.health = presetParams.health
|
||||
params.value.sortBy = presetParams.sortBy
|
||||
params.value.sortOrder = presetParams.sortOrder
|
||||
params.value.sort_by = presetParams.sort_by
|
||||
params.value.sort_order = presetParams.sort_order
|
||||
params.value.size = presetParams.size
|
||||
params.value.page = 1
|
||||
selectedViewPresetId.value = preset.id
|
||||
@@ -1128,8 +1124,8 @@ export function useAdminFiles() {
|
||||
params.value.status = 'all'
|
||||
params.value.type = 'all'
|
||||
params.value.health = 'all'
|
||||
params.value.sortBy = 'created_at'
|
||||
params.value.sortOrder = 'desc'
|
||||
params.value.sort_by = 'created_at'
|
||||
params.value.sort_order = 'desc'
|
||||
selectedViewPresetId.value = builtInAllViewPresetId
|
||||
clearSelection()
|
||||
await loadFiles()
|
||||
@@ -1332,8 +1328,8 @@ export function useAdminFiles() {
|
||||
try {
|
||||
const response = await deleteAdminFilesWithFallback(ids)
|
||||
const detail = response.detail
|
||||
const deletedCount = detail?.deletedCount ?? detail?.deleted_count ?? ids.length
|
||||
const failedCount = detail?.failedCount ?? detail?.failed_count ?? 0
|
||||
const deletedCount = detail?.deleted_count ?? ids.length
|
||||
const failedCount = detail?.failed_count ?? 0
|
||||
|
||||
if (tableData.value.length <= deletedCount && params.value.page > 1) {
|
||||
params.value.page -= 1
|
||||
@@ -1378,8 +1374,8 @@ export function useAdminFiles() {
|
||||
try {
|
||||
const response = await updateAdminFilesWithFallback(ids, payload)
|
||||
const detail = response.detail
|
||||
const updatedCount = detail?.updatedCount ?? detail?.updated_count ?? ids.length
|
||||
const failedCount = detail?.failedCount ?? detail?.failed_count ?? 0
|
||||
const updatedCount = detail?.updated_count ?? ids.length
|
||||
const failedCount = detail?.failed_count ?? 0
|
||||
|
||||
clearSelection()
|
||||
await loadFiles()
|
||||
@@ -1424,10 +1420,10 @@ export function useAdminFiles() {
|
||||
try {
|
||||
const response = await applyAdminFilesPolicyActionWithFallback(ids, action)
|
||||
const detail = response.detail
|
||||
const updatedCount = detail?.updatedCount ?? detail?.updated_count ?? ids.length
|
||||
const updatedCount = detail?.updated_count ?? ids.length
|
||||
const failedCount =
|
||||
(detail?.failedCount ?? detail?.failed_count ?? 0) +
|
||||
(detail?.missingCount ?? detail?.missing_count ?? 0)
|
||||
(detail?.failed_count ?? 0) +
|
||||
(detail?.missing_count ?? 0)
|
||||
|
||||
clearSelection()
|
||||
await loadFiles()
|
||||
@@ -1468,7 +1464,7 @@ export function useAdminFiles() {
|
||||
previewText.value = response.detail.content
|
||||
previewMetaText.value = response.detail.truncated
|
||||
? t('fileManage.previewTruncated', {
|
||||
shown: response.detail.previewLength ?? response.detail.preview_length ?? 0,
|
||||
shown: response.detail.preview_length ?? 0,
|
||||
total: response.detail.length
|
||||
})
|
||||
: t('fileManage.previewComplete', { count: response.detail.length })
|
||||
|
||||
@@ -24,8 +24,8 @@ const emptyDashboardData = (): DashboardViewData => ({
|
||||
usedCount: 0,
|
||||
storageBackend: '-',
|
||||
uploadSizeLimit: 0,
|
||||
openUpload: 0,
|
||||
enableChunk: 0,
|
||||
open_upload: 0,
|
||||
enable_chunk: 0,
|
||||
maxSaveSeconds: 0,
|
||||
healthAttentionCount: 0,
|
||||
healthDangerCount: 0,
|
||||
@@ -75,19 +75,19 @@ const healthSummaryKeys: (keyof DashboardHealthSummary)[] = [
|
||||
|
||||
const normalizeHealthSummary = (detail: DashboardData): DashboardHealthSummary => ({
|
||||
healthAttentionCount: toNumber(
|
||||
detail.healthSummary?.healthAttentionCount ?? detail.healthAttentionCount
|
||||
detail.health_attention_count
|
||||
),
|
||||
healthDangerCount: toNumber(detail.healthSummary?.healthDangerCount ?? detail.healthDangerCount),
|
||||
healthDangerCount: toNumber(detail.health_danger_count),
|
||||
healthWarningCount: toNumber(
|
||||
detail.healthSummary?.healthWarningCount ?? detail.healthWarningCount
|
||||
detail.health_warning_count
|
||||
),
|
||||
expiringSoonCount: toNumber(detail.healthSummary?.expiringSoonCount ?? detail.expiringSoonCount),
|
||||
storageIssueCount: toNumber(detail.healthSummary?.storageIssueCount ?? detail.storageIssueCount),
|
||||
expiringSoonCount: toNumber(detail.expiring_soon_count),
|
||||
storageIssueCount: toNumber(detail.storage_issue_count),
|
||||
neverRetrievedCount: toNumber(
|
||||
detail.healthSummary?.neverRetrievedCount ?? detail.neverRetrievedCount
|
||||
detail.never_retrieved_count
|
||||
),
|
||||
healthyCount: toNumber(detail.healthSummary?.healthyCount ?? detail.healthyCount),
|
||||
permanentCount: toNumber(detail.healthSummary?.permanentCount ?? detail.permanentCount)
|
||||
healthyCount: toNumber(detail.healthy_count),
|
||||
permanentCount: toNumber(detail.permanent_count)
|
||||
})
|
||||
|
||||
export function useDashboardStats(options: UseDashboardStatsOptions = {}) {
|
||||
@@ -110,27 +110,27 @@ export function useDashboardStats(options: UseDashboardStatsOptions = {}) {
|
||||
}
|
||||
|
||||
const detail = response.detail
|
||||
dashboardData.totalFiles = toNumber(detail.totalFiles)
|
||||
dashboardData.storageUsed = toNumber(detail.storageUsed)
|
||||
dashboardData.yesterdayCount = toNumber(detail.yesterdayCount)
|
||||
dashboardData.todayCount = toNumber(detail.todayCount)
|
||||
dashboardData.yesterdaySize = toNumber(detail.yesterdaySize)
|
||||
dashboardData.todaySize = toNumber(detail.todaySize)
|
||||
dashboardData.sysUptime = detail.sysUptime
|
||||
dashboardData.hasExtendedStats = hasOwn(detail, 'activeCount')
|
||||
dashboardData.totalFiles = toNumber(detail.total_files)
|
||||
dashboardData.storageUsed = toNumber(detail.storage_used)
|
||||
dashboardData.yesterdayCount = toNumber(detail.yesterday_count)
|
||||
dashboardData.todayCount = toNumber(detail.today_count)
|
||||
dashboardData.yesterdaySize = toNumber(detail.yesterday_size)
|
||||
dashboardData.todaySize = toNumber(detail.today_size)
|
||||
dashboardData.sysUptime = detail.sys_uptime
|
||||
dashboardData.hasExtendedStats = hasOwn(detail, 'active_count')
|
||||
dashboardData.activeCount = dashboardData.hasExtendedStats
|
||||
? toNumber(detail.activeCount)
|
||||
? toNumber(detail.active_count)
|
||||
: dashboardData.totalFiles
|
||||
dashboardData.expiredCount = toNumber(detail.expiredCount)
|
||||
dashboardData.textCount = toNumber(detail.textCount)
|
||||
dashboardData.fileCount = toNumber(detail.fileCount)
|
||||
dashboardData.chunkedCount = toNumber(detail.chunkedCount)
|
||||
dashboardData.usedCount = toNumber(detail.usedCount)
|
||||
dashboardData.storageBackend = detail.storageBackend || '-'
|
||||
dashboardData.uploadSizeLimit = toNumber(detail.uploadSizeLimit)
|
||||
dashboardData.openUpload = toNumber(detail.openUpload)
|
||||
dashboardData.enableChunk = toNumber(detail.enableChunk)
|
||||
dashboardData.maxSaveSeconds = toNumber(detail.maxSaveSeconds)
|
||||
dashboardData.expiredCount = toNumber(detail.expired_count)
|
||||
dashboardData.textCount = toNumber(detail.text_count)
|
||||
dashboardData.fileCount = toNumber(detail.file_count)
|
||||
dashboardData.chunkedCount = toNumber(detail.chunked_count)
|
||||
dashboardData.usedCount = toNumber(detail.used_count)
|
||||
dashboardData.storageBackend = detail.storage_backend || '-'
|
||||
dashboardData.uploadSizeLimit = toNumber(detail.upload_size_limit)
|
||||
dashboardData.open_upload = toNumber(detail.open_upload)
|
||||
dashboardData.enable_chunk = toNumber(detail.enable_chunk)
|
||||
dashboardData.maxSaveSeconds = toNumber(detail.max_save_seconds)
|
||||
const healthSummary = normalizeHealthSummary(detail)
|
||||
healthSummaryKeys.forEach((key) => {
|
||||
dashboardData[key] = healthSummary[key]
|
||||
|
||||
@@ -136,7 +136,7 @@ export function usePresignedUpload(options: UsePresignedUploadOptions = {}) {
|
||||
file_name: file.name,
|
||||
file_size: file.size,
|
||||
expire_value: options?.expireValue ?? DEFAULT_EXPIRE_VALUE,
|
||||
expire_style: options?.expireStyle ?? DEFAULT_EXPIRE_STYLE
|
||||
expire_style: options?.expire_style ?? DEFAULT_EXPIRE_STYLE
|
||||
})
|
||||
|
||||
if (response.code === 200 && response.detail) {
|
||||
@@ -178,7 +178,7 @@ export function usePresignedUpload(options: UsePresignedUploadOptions = {}) {
|
||||
presignStatus.value = PRESIGN_UPLOAD_STATUS.CONFIRMING
|
||||
const confirmResponse = await PresignUploadService.confirmUpload(session.upload_id, {
|
||||
expire_value: options?.expireValue ?? DEFAULT_EXPIRE_VALUE,
|
||||
expire_style: options?.expireStyle ?? DEFAULT_EXPIRE_STYLE
|
||||
expire_style: options?.expire_style ?? DEFAULT_EXPIRE_STYLE
|
||||
})
|
||||
|
||||
if (confirmResponse.code === 200 && confirmResponse.detail?.code) {
|
||||
|
||||
@@ -72,8 +72,7 @@ export function useRetrieveFlow() {
|
||||
downloadUrl,
|
||||
content,
|
||||
date: new Date().toLocaleString(),
|
||||
type: isText ? 'text' : 'file',
|
||||
remainingDownloads: detail.remaining_downloads
|
||||
type: isText ? 'text' : 'file'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export function useSendFlow() {
|
||||
const selectedFile = ref<File | null>(null)
|
||||
const selectedFiles = ref<File[]>([])
|
||||
const textContent = ref('')
|
||||
const expirationMethod = ref(config.value.expireStyle[0] || 'day')
|
||||
const expirationMethod = ref(config.value.expire_style[0] || 'day')
|
||||
const expirationValue = ref('1')
|
||||
const uploadProgress = ref(0)
|
||||
const uploadedBytes = ref(0)
|
||||
@@ -38,11 +38,11 @@ export function useSendFlow() {
|
||||
const sendRecords = computed(() => fileDataStore.shareData)
|
||||
const uploadDescription = computed(() =>
|
||||
t('send.uploadArea.descriptionWithLimit', {
|
||||
size: getStorageUnit(config.value.uploadSize)
|
||||
size: getStorageUnit(config.value.upload_size)
|
||||
})
|
||||
)
|
||||
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 : ['*']
|
||||
})
|
||||
@@ -58,16 +58,16 @@ export function useSendFlow() {
|
||||
.join(',')
|
||||
})
|
||||
const expirationOptions = computed(() =>
|
||||
config.value.expireStyle.map((value) => ({
|
||||
config.value.expire_style.map((value) => ({
|
||||
value,
|
||||
label: getUnit(value)
|
||||
}))
|
||||
)
|
||||
watch(
|
||||
() => config.value.expireStyle,
|
||||
(expireStyle) => {
|
||||
if (expireStyle.length > 0 && !expireStyle.includes(expirationMethod.value)) {
|
||||
expirationMethod.value = expireStyle[0]
|
||||
() => config.value.expire_style,
|
||||
(expire_style) => {
|
||||
if (expire_style.length > 0 && !expire_style.includes(expirationMethod.value)) {
|
||||
expirationMethod.value = expire_style[0]
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
@@ -102,7 +102,7 @@ export function useSendFlow() {
|
||||
})
|
||||
|
||||
const checkOpenUpload = () => {
|
||||
if (config.value.openUpload === 0 && !adminStore.hasToken) {
|
||||
if (config.value.open_upload === 0 && !adminStore.hasToken) {
|
||||
alertStore.showAlert(t('send.messages.guestUploadDisabled'), 'error')
|
||||
return false
|
||||
}
|
||||
@@ -118,9 +118,9 @@ export function useSendFlow() {
|
||||
}
|
||||
|
||||
const checkFileSize = (file: File) => {
|
||||
if (file.size > config.value.uploadSize) {
|
||||
if (file.size > config.value.upload_size) {
|
||||
alertStore.showAlert(
|
||||
t('send.messages.fileSizeExceeded', { size: getStorageUnit(config.value.uploadSize) }),
|
||||
t('send.messages.fileSizeExceeded', { size: getStorageUnit(config.value.upload_size) }),
|
||||
'error'
|
||||
)
|
||||
selectedFile.value = null
|
||||
@@ -315,15 +315,15 @@ export function useSendFlow() {
|
||||
selectedFile: selectedFile.value,
|
||||
selectedFiles: selectedFiles.value,
|
||||
expireValue,
|
||||
expireStyle: expirationMethod.value,
|
||||
enableChunk: Boolean(config.value.enableChunk),
|
||||
expire_style: expirationMethod.value,
|
||||
enable_chunk: Boolean(config.value.enable_chunk),
|
||||
validateFileSize: checkFileSize
|
||||
})
|
||||
} else {
|
||||
response = await submitText({
|
||||
text: textContent.value,
|
||||
expireValue,
|
||||
expireStyle: expirationMethod.value
|
||||
expire_style: expirationMethod.value
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -20,15 +20,15 @@ type SubmitFileOptions = {
|
||||
selectedFile: File | null
|
||||
selectedFiles: File[]
|
||||
expireValue: number
|
||||
expireStyle: string
|
||||
enableChunk: boolean
|
||||
expire_style: string
|
||||
enable_chunk: boolean
|
||||
validateFileSize: (file: File) => boolean
|
||||
}
|
||||
|
||||
type SubmitTextOptions = {
|
||||
text: string
|
||||
expireValue: number
|
||||
expireStyle: string
|
||||
expire_style: string
|
||||
}
|
||||
|
||||
export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
@@ -40,11 +40,11 @@ export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
const handleChunkUpload = async (
|
||||
file: File,
|
||||
expireValue: number,
|
||||
expireStyle: string
|
||||
expire_style: string
|
||||
): Promise<ApiResponse> => {
|
||||
return uploadChunkedFile(file, {
|
||||
expireValue,
|
||||
expireStyle,
|
||||
expire_style,
|
||||
onHashCalculated: options.onHashCalculated,
|
||||
onProgress: (progress: UploadProgress) => {
|
||||
options.onProgress(progress)
|
||||
@@ -60,11 +60,11 @@ export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
const handlePresignedUpload = async (
|
||||
file: File,
|
||||
expireValue: number,
|
||||
expireStyle: string
|
||||
expire_style: string
|
||||
): Promise<ApiResponse<{ code?: string; name?: string }>> => {
|
||||
const code = await presignUploadFile(file, {
|
||||
expireValue,
|
||||
expireStyle: expireStyle as ExpireStyle,
|
||||
expire_style: expire_style as ExpireStyle,
|
||||
onProgress: (progress) => {
|
||||
options.onProgress(progress)
|
||||
}
|
||||
@@ -87,8 +87,8 @@ export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
selectedFile,
|
||||
selectedFiles,
|
||||
expireValue,
|
||||
expireStyle,
|
||||
enableChunk,
|
||||
expire_style,
|
||||
enable_chunk,
|
||||
validateFileSize
|
||||
}: SubmitFileOptions): Promise<ApiResponse | null> => {
|
||||
let fileToUpload = selectedFile
|
||||
@@ -106,13 +106,13 @@ export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
throw new Error(options.translate('send.messages.selectFile'))
|
||||
}
|
||||
|
||||
return enableChunk
|
||||
? handleChunkUpload(fileToUpload, expireValue, expireStyle)
|
||||
: handlePresignedUpload(fileToUpload, expireValue, expireStyle)
|
||||
return enable_chunk
|
||||
? handleChunkUpload(fileToUpload, expireValue, expire_style)
|
||||
: handlePresignedUpload(fileToUpload, expireValue, expire_style)
|
||||
}
|
||||
|
||||
const submitText = ({ text, expireValue, expireStyle }: SubmitTextOptions) =>
|
||||
FileService.uploadText(text, expireValue, expireStyle)
|
||||
const submitText = ({ text, expireValue, expire_style }: SubmitTextOptions) =>
|
||||
FileService.uploadText(text, expireValue, expire_style)
|
||||
|
||||
return {
|
||||
resetPresignUpload,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
type SaveTimeUnit
|
||||
} from '@/utils/config-form'
|
||||
|
||||
type ConfigFlagKey = 'enableChunk' | 's3_proxy' | 'openUpload' | 'showAdminAddr'
|
||||
type ConfigFlagKey = 'enable_chunk' | 's3_proxy' | 'open_upload' | 'show_admin_addr'
|
||||
|
||||
const SECONDS_PER_DAY = 24 * 60 * 60
|
||||
|
||||
@@ -29,7 +29,7 @@ export function useSystemConfig() {
|
||||
const savedPayloadSnapshot = ref('')
|
||||
const fileSize = ref(1)
|
||||
const sizeUnit = ref<FileSizeUnit>('MB')
|
||||
const storageLimit = ref(0)
|
||||
const storage_limit = ref(0)
|
||||
const storageLimitUnit = ref<FileSizeUnit>('GB')
|
||||
const saveTime = ref(1)
|
||||
const saveTimeUnit = ref<SaveTimeUnit>('天')
|
||||
@@ -43,9 +43,9 @@ export function useSystemConfig() {
|
||||
{ value: fileSize.value, unit: sizeUnit.value },
|
||||
{ value: saveTime.value, unit: saveTimeUnit.value }
|
||||
)
|
||||
payload.adminSessionExpire = Math.round(adminSessionDays.value * SECONDS_PER_DAY)
|
||||
payload.storageLimit =
|
||||
storageLimit.value === 0 ? 0 : fileSizeFormToBytes(storageLimit.value, storageLimitUnit.value)
|
||||
payload.admin_session_expire = Math.round(adminSessionDays.value * SECONDS_PER_DAY)
|
||||
payload.storage_limit =
|
||||
storage_limit.value === 0 ? 0 : fileSizeFormToBytes(storage_limit.value, storageLimitUnit.value)
|
||||
|
||||
if (!payload.admin_token) {
|
||||
delete payload.admin_token
|
||||
@@ -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: ''
|
||||
}
|
||||
@@ -170,12 +169,12 @@ export function useSystemConfig() {
|
||||
}
|
||||
|
||||
const syncConfigForm = (nextConfig: ConfigState) => {
|
||||
const sizeForm = bytesToFileSizeForm(nextConfig.uploadSize)
|
||||
const sizeForm = bytesToFileSizeForm(nextConfig.upload_size)
|
||||
fileSize.value = sizeForm.value
|
||||
sizeUnit.value = sizeForm.unit
|
||||
|
||||
const storageLimitForm = bytesToFileSizeForm(nextConfig.storageLimit)
|
||||
storageLimit.value = storageLimitForm.value
|
||||
const storageLimitForm = bytesToFileSizeForm(nextConfig.storage_limit)
|
||||
storage_limit.value = storageLimitForm.value
|
||||
storageLimitUnit.value = storageLimitForm.unit
|
||||
|
||||
const saveTimeForm = secondsToSaveTimeForm(nextConfig.max_save_seconds)
|
||||
@@ -183,7 +182,7 @@ export function useSystemConfig() {
|
||||
saveTimeUnit.value = saveTimeForm.unit
|
||||
adminSessionDays.value = Math.max(
|
||||
1,
|
||||
Math.round(nextConfig.adminSessionExpire / SECONDS_PER_DAY)
|
||||
Math.round(nextConfig.admin_session_expire / SECONDS_PER_DAY)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -219,7 +218,7 @@ export function useSystemConfig() {
|
||||
|
||||
// 计算属性
|
||||
const maxFileSizeMB = computed(() => {
|
||||
return Math.round(config.value.uploadSize / 1024 / 1024)
|
||||
return Math.round(config.value.upload_size / 1024 / 1024)
|
||||
})
|
||||
|
||||
const isConfigLoaded = computed(() => {
|
||||
@@ -235,7 +234,7 @@ export function useSystemConfig() {
|
||||
isDirty,
|
||||
fileSize,
|
||||
sizeUnit,
|
||||
storageLimit,
|
||||
storage_limit,
|
||||
storageLimitUnit,
|
||||
saveTime,
|
||||
saveTimeUnit,
|
||||
|
||||
@@ -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[]
|
||||
}
|
||||
@@ -140,7 +140,7 @@ export default {
|
||||
notificationTitle: 'Announcement Title',
|
||||
notificationContent: 'Announcement Content',
|
||||
storageSettings: 'Storage',
|
||||
storageLimit: 'Total Storage Capacity',
|
||||
storage_limit: 'Total Storage Capacity',
|
||||
storageLimitHelp:
|
||||
'Active shares and pending uploads share this quota. Set to 0 for unlimited.',
|
||||
storagePath: 'Storage Path',
|
||||
|
||||
@@ -140,7 +140,7 @@ export default {
|
||||
notificationTitle: '公告标题',
|
||||
notificationContent: '公告内容',
|
||||
storageSettings: '存储配置',
|
||||
storageLimit: '总存储容量上限',
|
||||
storage_limit: '总存储容量上限',
|
||||
storageLimitHelp: '所有有效分享与未完成上传共同占用容量,设置为 0 表示不限制。',
|
||||
storagePath: '文件存储路径',
|
||||
storagePathPlaceholder: '使用默认路径可留空',
|
||||
|
||||
@@ -63,12 +63,12 @@ export class FileService {
|
||||
static async uploadText(
|
||||
text: string,
|
||||
expireValue = 1,
|
||||
expireStyle = 'day'
|
||||
expire_style = 'day'
|
||||
): Promise<ApiResponse<TextSendResponse>> {
|
||||
const formData = new FormData()
|
||||
formData.append('text', text)
|
||||
formData.append('expire_value', String(expireValue))
|
||||
formData.append('expire_style', expireStyle)
|
||||
formData.append('expire_style', expire_style)
|
||||
return api.post('/share/text/', formData, multipartUploadConfig())
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ export class FileService {
|
||||
return api.get('/admin/file/preview', {
|
||||
params: {
|
||||
id,
|
||||
maxChars
|
||||
max_chars: maxChars
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ const CHUNK_SIZE = 5 * 1024 * 1024
|
||||
|
||||
type ChunkedUploadOptions = {
|
||||
expireValue: number
|
||||
expireStyle: string
|
||||
expire_style: string
|
||||
onHashCalculated?: (hash: string) => void
|
||||
onProgress?: (progress: UploadProgress) => void
|
||||
messages?: {
|
||||
@@ -86,7 +86,7 @@ export const uploadChunkedFile = async (
|
||||
|
||||
const completeResponse = await FileService.completeChunkUpload(uploadId, {
|
||||
expire_value: options.expireValue,
|
||||
expire_style: options.expireStyle
|
||||
expire_style: options.expire_style
|
||||
})
|
||||
|
||||
if (completeResponse.code !== 200) {
|
||||
|
||||
@@ -18,7 +18,7 @@ export const useConfigStore = defineStore('config', () => {
|
||||
})
|
||||
const publicMeta = ref<PublicConfigMeta>({})
|
||||
|
||||
const uploadSizeLimit = computed(() => config.value.uploadSize)
|
||||
const uploadSizeLimit = computed(() => config.value.upload_size)
|
||||
const appVersion = computed(() => publicMeta.value.version || '')
|
||||
|
||||
const updateConfig = (nextConfig: Partial<ConfigState>) => {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
export interface ApiResponse<T = unknown> {
|
||||
code: number
|
||||
message?: string
|
||||
msg?: string
|
||||
detail?: T
|
||||
}
|
||||
|
||||
export interface ApiErrorPayload {
|
||||
detail?: string | { setup?: string }
|
||||
message?: string
|
||||
msg?: string
|
||||
}
|
||||
+15
-18
@@ -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
|
||||
}
|
||||
@@ -31,28 +29,27 @@ export interface ConfigState {
|
||||
name: string
|
||||
description: string
|
||||
file_storage: string
|
||||
themesChoices: ThemeChoice[]
|
||||
expireStyle: string[]
|
||||
themes_choices: ThemeChoice[]
|
||||
expire_style: string[]
|
||||
code_generate_type: 'number' | 'secret'
|
||||
adminSessionExpire: number
|
||||
admin_session_expire: number
|
||||
admin_token: string
|
||||
robotsText: string
|
||||
robots_text: string
|
||||
keywords: string
|
||||
notify_title: string
|
||||
notify_content: string
|
||||
openUpload: number
|
||||
uploadSize: number
|
||||
open_upload: number
|
||||
upload_size: number
|
||||
allowed_file_types: string[]
|
||||
allowedFileTypes?: string[]
|
||||
storage_path: string
|
||||
storageLimit: number
|
||||
uploadMinute: number
|
||||
storage_limit: number
|
||||
upload_minute: number
|
||||
max_save_seconds: number
|
||||
opacity: number
|
||||
enableChunk: number
|
||||
enable_chunk: number
|
||||
s3_access_key_id: string
|
||||
background: string
|
||||
showAdminAddr: number
|
||||
show_admin_addr: number
|
||||
page_explain: string
|
||||
s3_secret_access_key: string
|
||||
aws_session_token: string
|
||||
@@ -62,11 +59,11 @@ export interface ConfigState {
|
||||
s3_bucket_name: string
|
||||
s3_endpoint_url: string
|
||||
s3_hostname: string
|
||||
uploadCount: number
|
||||
errorMinute: number
|
||||
errorCount: number
|
||||
upload_count: number
|
||||
error_minute: number
|
||||
error_count: number
|
||||
s3_proxy: number
|
||||
themesSelect: string
|
||||
themes_select: string
|
||||
webdav_url: string
|
||||
webdav_username: string
|
||||
webdav_password: string
|
||||
|
||||
+60
-73
@@ -1,5 +1,6 @@
|
||||
import type { AdminFileHealthFilter } from './file'
|
||||
|
||||
/** 视图模型:dashboard 页面内部展示状态(camel 为前端自有命名)。 */
|
||||
export interface DashboardHealthSummary {
|
||||
healthAttentionCount: number
|
||||
healthDangerCount: number
|
||||
@@ -11,82 +12,68 @@ export interface DashboardHealthSummary {
|
||||
permanentCount: number
|
||||
}
|
||||
|
||||
/** API 形状:/admin/dashboard 响应(snake_case,与后端 D7 对齐)。 */
|
||||
export interface DashboardData {
|
||||
totalFiles: number
|
||||
storageUsed: number | string
|
||||
yesterdayCount: number
|
||||
todayCount: number
|
||||
yesterdaySize: number | string
|
||||
todaySize: number | string
|
||||
sysUptime: number | null
|
||||
activeCount?: number
|
||||
expiredCount?: number
|
||||
textCount?: number
|
||||
fileCount?: number
|
||||
chunkedCount?: number
|
||||
usedCount?: number
|
||||
storageBackend?: string
|
||||
uploadSizeLimit?: number
|
||||
openUpload?: number
|
||||
enableChunk?: number
|
||||
maxSaveSeconds?: number
|
||||
healthAttentionCount?: number
|
||||
healthDangerCount?: number
|
||||
healthWarningCount?: number
|
||||
expiringSoonCount?: number
|
||||
storageIssueCount?: number
|
||||
neverRetrievedCount?: number
|
||||
healthyCount?: number
|
||||
permanentCount?: number
|
||||
healthSummary?: Partial<DashboardHealthSummary>
|
||||
total_files: number
|
||||
storage_used: number | string
|
||||
yesterday_count: number
|
||||
today_count: number
|
||||
yesterday_size: number | string
|
||||
today_size: number | string
|
||||
sys_uptime: number | null
|
||||
active_count?: number
|
||||
expired_count?: number
|
||||
text_count?: number
|
||||
file_count?: number
|
||||
chunked_count?: number
|
||||
used_count?: number
|
||||
storage_backend?: string
|
||||
upload_size_limit?: number
|
||||
open_upload?: number
|
||||
enable_chunk?: number
|
||||
max_save_seconds?: number
|
||||
health_attention_count?: number
|
||||
health_danger_count?: number
|
||||
health_warning_count?: number
|
||||
expiring_soon_count?: number
|
||||
storage_issue_count?: number
|
||||
never_retrieved_count?: number
|
||||
healthy_count?: number
|
||||
permanent_count?: number
|
||||
}
|
||||
|
||||
export type DashboardViewData = Omit<
|
||||
DashboardData,
|
||||
| keyof DashboardHealthSummary
|
||||
| 'activeCount'
|
||||
| 'expiredCount'
|
||||
| 'textCount'
|
||||
| 'fileCount'
|
||||
| 'chunkedCount'
|
||||
| 'usedCount'
|
||||
| 'storageBackend'
|
||||
| 'uploadSizeLimit'
|
||||
| 'openUpload'
|
||||
| 'enableChunk'
|
||||
| 'maxSaveSeconds'
|
||||
| 'storageUsed'
|
||||
| 'yesterdaySize'
|
||||
| 'todaySize'
|
||||
> &
|
||||
DashboardHealthSummary & {
|
||||
hasExtendedStats: boolean
|
||||
activeCount: number
|
||||
expiredCount: number
|
||||
textCount: number
|
||||
fileCount: number
|
||||
chunkedCount: number
|
||||
usedCount: number
|
||||
storageBackend: string
|
||||
uploadSizeLimit: number
|
||||
openUpload: number
|
||||
enableChunk: number
|
||||
maxSaveSeconds: number
|
||||
storageUsed: number
|
||||
yesterdaySize: number
|
||||
todaySize: number
|
||||
storageUsedText: string
|
||||
yesterdaySizeText: string
|
||||
todaySizeText: string
|
||||
uploadSizeLimitText: string
|
||||
sysUptimeText: string
|
||||
activeRatio: number
|
||||
textRatio: number
|
||||
fileRatio: number
|
||||
healthyRatio: number
|
||||
healthAttentionRatio: number
|
||||
todaySizeRatio: number
|
||||
}
|
||||
export type DashboardViewData = {
|
||||
hasExtendedStats: boolean
|
||||
totalFiles: number
|
||||
storageUsed: number
|
||||
yesterdayCount: number
|
||||
todayCount: number
|
||||
yesterdaySize: number
|
||||
todaySize: number
|
||||
sysUptime: number | null
|
||||
activeCount: number
|
||||
expiredCount: number
|
||||
textCount: number
|
||||
fileCount: number
|
||||
chunkedCount: number
|
||||
usedCount: number
|
||||
storageBackend: string
|
||||
uploadSizeLimit: number
|
||||
open_upload: number
|
||||
enable_chunk: number
|
||||
maxSaveSeconds: number
|
||||
storageUsedText: string
|
||||
yesterdaySizeText: string
|
||||
todaySizeText: string
|
||||
uploadSizeLimitText: string
|
||||
sysUptimeText: string
|
||||
activeRatio: number
|
||||
textRatio: number
|
||||
fileRatio: number
|
||||
healthyRatio: number
|
||||
healthAttentionRatio: number
|
||||
todaySizeRatio: number
|
||||
} & DashboardHealthSummary
|
||||
|
||||
export interface DashboardHealthAction {
|
||||
key: string
|
||||
|
||||
+20
-50
@@ -22,19 +22,12 @@ export interface FileListItem {
|
||||
name?: string
|
||||
type?: 'text' | 'file'
|
||||
status?: 'active' | 'expired'
|
||||
isText?: boolean
|
||||
is_text?: boolean
|
||||
isExpired?: boolean
|
||||
is_expired?: boolean
|
||||
isChunked?: boolean
|
||||
is_chunked?: boolean
|
||||
statusInsights?: AdminFileDetailStatusInsights
|
||||
status_insights?: AdminFileDetailStatusInsights
|
||||
remainingDownloads?: number | null
|
||||
remaining_downloads?: number | null
|
||||
usedCount?: number
|
||||
used_count?: number
|
||||
fileHash?: string | null
|
||||
file_hash?: string | null
|
||||
}
|
||||
|
||||
@@ -57,22 +50,22 @@ export interface AdminFileViewItem extends FileListItem {
|
||||
}
|
||||
|
||||
export interface AdminFileSummary {
|
||||
totalFiles: number
|
||||
activeCount: number
|
||||
expiredCount: number
|
||||
textCount: number
|
||||
fileCount: number
|
||||
chunkedCount: number
|
||||
healthAttentionCount: number
|
||||
healthDangerCount: number
|
||||
healthWarningCount: number
|
||||
expiringSoonCount: number
|
||||
storageIssueCount: number
|
||||
neverRetrievedCount: number
|
||||
healthyCount: number
|
||||
permanentCount: number
|
||||
storageUsed: number
|
||||
usedCount: number
|
||||
total_files: number
|
||||
active_count: number
|
||||
expired_count: number
|
||||
text_count: number
|
||||
file_count: number
|
||||
chunked_count: number
|
||||
health_attention_count: number
|
||||
health_danger_count: number
|
||||
health_warning_count: number
|
||||
expiring_soon_count: number
|
||||
storage_issue_count: number
|
||||
never_retrieved_count: number
|
||||
healthy_count: number
|
||||
permanent_count: number
|
||||
storage_used: number
|
||||
used_count: number
|
||||
}
|
||||
|
||||
export type AdminFileStatusFilter = 'all' | 'active' | 'expired'
|
||||
@@ -98,8 +91,8 @@ export interface AdminFileListParams {
|
||||
status?: AdminFileStatusFilter
|
||||
type?: AdminFileTypeFilter
|
||||
health?: AdminFileHealthFilter
|
||||
sortBy?: AdminFileSortBy
|
||||
sortOrder?: AdminFileSortOrder
|
||||
sort_by?: AdminFileSortBy
|
||||
sort_order?: AdminFileSortOrder
|
||||
}
|
||||
|
||||
export interface AdminFileViewPresetParams {
|
||||
@@ -107,8 +100,8 @@ export interface AdminFileViewPresetParams {
|
||||
status: AdminFileStatusFilter
|
||||
type: AdminFileTypeFilter
|
||||
health: AdminFileHealthFilter
|
||||
sortBy: AdminFileSortBy
|
||||
sortOrder: AdminFileSortOrder
|
||||
sort_by: AdminFileSortBy
|
||||
sort_order: AdminFileSortOrder
|
||||
size: number
|
||||
}
|
||||
|
||||
@@ -118,11 +111,8 @@ export interface AdminFileViewPreset {
|
||||
filters?: AdminFileViewPresetParams
|
||||
params?: AdminFileViewPresetParams
|
||||
isBuiltIn?: boolean
|
||||
isDefault?: boolean
|
||||
is_default?: boolean
|
||||
createdAt?: string | null
|
||||
created_at?: string | null
|
||||
updatedAt?: string | null
|
||||
updated_at?: string | null
|
||||
}
|
||||
|
||||
@@ -130,12 +120,10 @@ export interface AdminFileViewPresetRequest {
|
||||
id?: string
|
||||
name: string
|
||||
filters: AdminFileViewPresetParams
|
||||
params?: AdminFileViewPresetParams
|
||||
}
|
||||
|
||||
export interface AdminFileViewPresetsResponse {
|
||||
presets?: AdminFileViewPreset[]
|
||||
items?: AdminFileViewPreset[]
|
||||
total?: number
|
||||
}
|
||||
|
||||
@@ -166,14 +154,12 @@ export type AdminFilePolicyAction =
|
||||
export interface AdminFilePolicyActionRequest {
|
||||
id: number
|
||||
action: AdminFilePolicyAction
|
||||
downloadLimit?: number
|
||||
download_limit?: number
|
||||
}
|
||||
|
||||
export interface AdminFileMetadata {
|
||||
note: string
|
||||
tags: string[]
|
||||
updatedAt?: string | null
|
||||
updated_at?: string | null
|
||||
}
|
||||
|
||||
@@ -198,14 +184,10 @@ export interface AdminFilePreviewResponse {
|
||||
type: 'text'
|
||||
content: string
|
||||
length: number
|
||||
previewLength?: number
|
||||
preview_length?: number
|
||||
truncated: boolean
|
||||
maxChars?: number
|
||||
max_chars?: number
|
||||
createdAt?: string | null
|
||||
created_at?: string | null
|
||||
expiredAt?: string | null
|
||||
expired_at?: string | null
|
||||
}
|
||||
|
||||
@@ -214,9 +196,7 @@ export interface AdminFileDetailPolicy {
|
||||
expired_at?: string | null
|
||||
expiredCount?: number | null
|
||||
expired_count?: number | null
|
||||
remainingDownloads?: number | null
|
||||
remaining_downloads?: number | null
|
||||
isExpired?: boolean
|
||||
is_expired?: boolean
|
||||
isPermanent?: boolean
|
||||
is_permanent?: boolean
|
||||
@@ -228,9 +208,7 @@ export interface AdminFileDetailStorage {
|
||||
file_path?: string | null
|
||||
uuidFileName?: string | null
|
||||
uuid_file_name?: string | null
|
||||
fileHash?: string | null
|
||||
file_hash?: string | null
|
||||
isChunked?: boolean
|
||||
is_chunked?: boolean
|
||||
uploadId?: string | null
|
||||
upload_id?: string | null
|
||||
@@ -243,16 +221,13 @@ export interface AdminFileDetailInsightMetrics {
|
||||
age_seconds?: number
|
||||
secondsUntilExpiration?: number | null
|
||||
seconds_until_expiration?: number | null
|
||||
remainingDownloads?: number | null
|
||||
remaining_downloads?: number | null
|
||||
usedCount?: number
|
||||
used_count?: number
|
||||
}
|
||||
|
||||
export interface AdminFileDetailStatusInsights {
|
||||
severity?: AdminFileInsightSeverity
|
||||
state?: string
|
||||
nextAction?: string
|
||||
next_action?: string
|
||||
reasons?: string[]
|
||||
metrics?: AdminFileDetailInsightMetrics
|
||||
@@ -306,7 +281,6 @@ export interface AdminFileDetailResponse extends FileListItem {
|
||||
tags?: string[]
|
||||
metadataUpdatedAt?: string | null
|
||||
metadata_updated_at?: string | null
|
||||
statusInsights?: AdminFileDetailStatusInsights
|
||||
status_insights?: AdminFileDetailStatusInsights
|
||||
timeline?: AdminFileDetailTimelineItem[]
|
||||
}
|
||||
@@ -385,7 +359,6 @@ export interface AdminBatchUpdateFilesResponse {
|
||||
export interface AdminBatchPolicyActionRequest {
|
||||
ids: number[]
|
||||
action: AdminFilePolicyAction
|
||||
downloadLimit?: number
|
||||
download_limit?: number
|
||||
}
|
||||
|
||||
@@ -421,7 +394,6 @@ export interface ShareSelectResponse {
|
||||
download_url?: string | null
|
||||
created_at?: string | null
|
||||
expired_at?: string | null
|
||||
expires_at?: string | null
|
||||
expired_count?: number | null
|
||||
used_count?: number
|
||||
remaining_downloads?: number | null
|
||||
@@ -435,7 +407,6 @@ export interface ShareMetadataResponse {
|
||||
is_text: boolean
|
||||
created_at?: string | null
|
||||
expired_at?: string | null
|
||||
expires_at?: string | null
|
||||
expired_count?: number | null
|
||||
used_count?: number
|
||||
remaining_downloads?: number | null
|
||||
@@ -450,7 +421,6 @@ export interface ReceivedFileRecord {
|
||||
content: string | null
|
||||
date: string
|
||||
type?: 'file' | 'text'
|
||||
remainingDownloads?: number | null
|
||||
}
|
||||
|
||||
export interface SentFileRecord {
|
||||
|
||||
@@ -50,6 +50,6 @@ export interface PresignStatusResponse {
|
||||
|
||||
export interface PresignUploadOptions {
|
||||
expireValue?: number
|
||||
expireStyle?: ExpireStyle
|
||||
expire_style?: ExpireStyle
|
||||
onProgress?: (progress: UploadProgress) => void
|
||||
}
|
||||
@@ -245,7 +245,6 @@ export function getResponseMessage(response: ApiResponse, fallback: string): str
|
||||
return (
|
||||
getReadableMessage(response.detail) ||
|
||||
getReadableMessage(response.message) ||
|
||||
getReadableMessage(response.msg) ||
|
||||
fallback
|
||||
)
|
||||
}
|
||||
@@ -260,7 +259,6 @@ export function getErrorMessage(error: unknown, fallback: string): string {
|
||||
return (
|
||||
getReadableMessage(responseData?.detail) ||
|
||||
getReadableMessage(responseData?.message) ||
|
||||
getReadableMessage(responseData?.msg) ||
|
||||
errorWithResponse.message ||
|
||||
fallback
|
||||
)
|
||||
|
||||
@@ -101,7 +101,7 @@ export function buildConfigSubmitPayload(
|
||||
): ConfigState {
|
||||
return {
|
||||
...config,
|
||||
uploadSize: fileSizeFormToBytes(fileSize.value, fileSize.unit),
|
||||
upload_size: fileSizeFormToBytes(fileSize.value, fileSize.unit),
|
||||
max_save_seconds: saveTimeFormToSeconds(saveTime.value, saveTime.unit)
|
||||
}
|
||||
}
|
||||
+37
-40
@@ -2,66 +2,64 @@ import { DEFAULT_CONFIG, FILE_SIZE_LIMITS, STORAGE_KEYS } from '@/constants'
|
||||
import type { ConfigState, SystemConfig } from '@/types'
|
||||
|
||||
export type PublicConfig = SystemConfig & {
|
||||
uploadSize: number
|
||||
upload_size: number
|
||||
allowed_file_types?: string[]
|
||||
expireStyle: string[]
|
||||
expire_style: string[]
|
||||
code_generate_type?: 'number' | 'secret'
|
||||
openUpload: number
|
||||
open_upload: number
|
||||
max_save_seconds: number
|
||||
enableChunk: number
|
||||
enable_chunk: number
|
||||
notify_title?: string
|
||||
notify_content?: string
|
||||
page_explain?: string
|
||||
showAdminAddr?: number
|
||||
themesSelect?: string
|
||||
show_admin_addr?: number
|
||||
themes_select?: string
|
||||
background?: string
|
||||
opacity?: number
|
||||
}
|
||||
|
||||
type PublicConfigInput = Omit<Partial<ConfigState>, 'showAdminAddr'> & {
|
||||
showAdminAddr?: number | string
|
||||
type PublicConfigInput = Omit<Partial<ConfigState>, 'show_admin_addr'> & {
|
||||
show_admin_addr?: number | string
|
||||
show_admin_address?: number | string
|
||||
}
|
||||
|
||||
export const DEFAULT_PUBLIC_CONFIG: PublicConfig = {
|
||||
...DEFAULT_CONFIG,
|
||||
uploadSize: FILE_SIZE_LIMITS.MAX_FILE_SIZE,
|
||||
allowedFileTypes: ['*'],
|
||||
upload_size: FILE_SIZE_LIMITS.MAX_FILE_SIZE,
|
||||
allowed_file_types: ['*'],
|
||||
expireStyle: ['day'],
|
||||
expire_style: ['day'],
|
||||
code_generate_type: 'secret',
|
||||
openUpload: 1,
|
||||
open_upload: 1,
|
||||
max_save_seconds: 0,
|
||||
enableChunk: 0,
|
||||
showAdminAddr: 0
|
||||
enable_chunk: 0,
|
||||
show_admin_addr: 0
|
||||
}
|
||||
|
||||
export const DEFAULT_CONFIG_STATE: ConfigState = {
|
||||
name: DEFAULT_PUBLIC_CONFIG.name,
|
||||
description: DEFAULT_PUBLIC_CONFIG.description || '',
|
||||
file_storage: '',
|
||||
themesChoices: [],
|
||||
expireStyle: DEFAULT_PUBLIC_CONFIG.expireStyle,
|
||||
themes_choices: [],
|
||||
expire_style: DEFAULT_PUBLIC_CONFIG.expire_style,
|
||||
code_generate_type: DEFAULT_PUBLIC_CONFIG.code_generate_type || 'secret',
|
||||
adminSessionExpire: 30 * 24 * 60 * 60,
|
||||
admin_session_expire: 30 * 24 * 60 * 60,
|
||||
admin_token: '',
|
||||
robotsText: '',
|
||||
robots_text: '',
|
||||
keywords: '',
|
||||
notify_title: '',
|
||||
notify_content: '',
|
||||
openUpload: DEFAULT_PUBLIC_CONFIG.openUpload,
|
||||
uploadSize: DEFAULT_PUBLIC_CONFIG.uploadSize,
|
||||
allowed_file_types: DEFAULT_PUBLIC_CONFIG.allowedFileTypes,
|
||||
allowedFileTypes: DEFAULT_PUBLIC_CONFIG.allowedFileTypes,
|
||||
open_upload: DEFAULT_PUBLIC_CONFIG.open_upload,
|
||||
upload_size: DEFAULT_PUBLIC_CONFIG.upload_size,
|
||||
allowed_file_types: DEFAULT_PUBLIC_CONFIG.allowed_file_types,
|
||||
storage_path: '',
|
||||
storageLimit: 0,
|
||||
uploadMinute: 1,
|
||||
storage_limit: 0,
|
||||
upload_minute: 1,
|
||||
max_save_seconds: DEFAULT_PUBLIC_CONFIG.max_save_seconds,
|
||||
opacity: 0.9,
|
||||
enableChunk: DEFAULT_PUBLIC_CONFIG.enableChunk,
|
||||
enable_chunk: DEFAULT_PUBLIC_CONFIG.enable_chunk,
|
||||
s3_access_key_id: '',
|
||||
background: '',
|
||||
showAdminAddr: 0,
|
||||
show_admin_addr: 0,
|
||||
page_explain: '',
|
||||
s3_secret_access_key: '',
|
||||
aws_session_token: '',
|
||||
@@ -71,11 +69,11 @@ export const DEFAULT_CONFIG_STATE: ConfigState = {
|
||||
s3_bucket_name: '',
|
||||
s3_endpoint_url: '',
|
||||
s3_hostname: '',
|
||||
uploadCount: 1,
|
||||
errorMinute: 1,
|
||||
errorCount: 1,
|
||||
upload_count: 1,
|
||||
error_minute: 1,
|
||||
error_count: 1,
|
||||
s3_proxy: 0,
|
||||
themesSelect: '',
|
||||
themes_select: '',
|
||||
webdav_url: '',
|
||||
webdav_username: '',
|
||||
webdav_password: ''
|
||||
@@ -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,24 +109,23 @@ 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,
|
||||
uploadSize: config.uploadSize,
|
||||
allowedFileTypes,
|
||||
allowed_file_types: allowedFileTypes,
|
||||
expireStyle: config.expireStyle,
|
||||
upload_size: config.upload_size,
|
||||
allowed_file_types,
|
||||
expire_style: config.expire_style,
|
||||
code_generate_type: config.code_generate_type,
|
||||
openUpload: config.openUpload,
|
||||
open_upload: config.open_upload,
|
||||
max_save_seconds: config.max_save_seconds,
|
||||
enableChunk: config.enableChunk,
|
||||
enable_chunk: config.enable_chunk,
|
||||
notify_title: config.notify_title,
|
||||
notify_content: config.notify_content,
|
||||
page_explain: config.page_explain,
|
||||
showAdminAddr: normalizeAdminAddress(config.showAdminAddr ?? config.show_admin_address),
|
||||
themesSelect: config.themesSelect,
|
||||
show_admin_addr: normalizeAdminAddress(config.show_admin_addr ?? config.show_admin_address),
|
||||
themes_select: config.themes_select,
|
||||
background: config.background,
|
||||
opacity: config.opacity
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
{{ dashboardData.chunkedCount }}
|
||||
</strong>
|
||||
<span class="text-sm" :class="[mutedTextClass]">
|
||||
{{ dashboardData.enableChunk ? t('common.enabled') : t('common.disabled') }}
|
||||
{{ dashboardData.enable_chunk ? t('common.enabled') : t('common.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -196,7 +196,7 @@
|
||||
/>
|
||||
<PolicyRow
|
||||
:label="t('admin.dashboard.guestUpload')"
|
||||
:value="dashboardData.openUpload ? t('common.enabled') : t('common.disabled')"
|
||||
:value="dashboardData.open_upload ? t('common.enabled') : t('common.disabled')"
|
||||
/>
|
||||
<PolicyRow :label="t('admin.dashboard.maxSaveTime')" :value="maxSaveTimeText" />
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
{{ t('fileManage.title') }}
|
||||
</h2>
|
||||
<p class="mt-1 text-sm" :class="[mutedTextClass]">
|
||||
{{ t('fileManage.subtitle', { count: summary.totalFiles }) }}
|
||||
{{ t('fileManage.subtitle', { count: summary.total_files }) }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
@@ -149,7 +149,7 @@
|
||||
{{ t('fileManage.sortBy') }}
|
||||
</span>
|
||||
<select
|
||||
v-model="params.sortBy"
|
||||
v-model="params.sort_by"
|
||||
class="w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-zinc-500"
|
||||
:class="[fieldClass]"
|
||||
@change="handleSearch"
|
||||
@@ -166,7 +166,7 @@
|
||||
{{ t('fileManage.sortOrder') }}
|
||||
</span>
|
||||
<select
|
||||
v-model="params.sortOrder"
|
||||
v-model="params.sort_order"
|
||||
class="w-full rounded-lg border px-3 py-2 text-sm focus:border-transparent focus:ring-2 focus:ring-zinc-500"
|
||||
:class="[fieldClass]"
|
||||
@change="handleSearch"
|
||||
@@ -1473,19 +1473,19 @@ const openDetailTextPreview = () => {
|
||||
const summaryCards = computed(() => [
|
||||
{
|
||||
label: t('fileManage.totalFiles'),
|
||||
value: summary.value.totalFiles,
|
||||
value: summary.value.total_files,
|
||||
icon: ArchiveIcon,
|
||||
iconClass: isDarkMode.value ? 'bg-zinc-900/30 text-zinc-300' : 'bg-zinc-50 text-zinc-600'
|
||||
},
|
||||
{
|
||||
label: t('fileManage.activeFiles'),
|
||||
value: summary.value.activeCount,
|
||||
value: summary.value.active_count,
|
||||
icon: ActivityIcon,
|
||||
iconClass: isDarkMode.value ? 'bg-zinc-700 text-zinc-200' : 'bg-slate-100 text-slate-700'
|
||||
},
|
||||
{
|
||||
label: t('fileManage.expiredFiles'),
|
||||
value: summary.value.expiredCount,
|
||||
value: summary.value.expired_count,
|
||||
icon: ClockIcon,
|
||||
iconClass: isDarkMode.value ? 'bg-red-900/30 text-red-300' : 'bg-red-50 text-red-600'
|
||||
},
|
||||
|
||||
@@ -16,7 +16,7 @@ const {
|
||||
isDirty,
|
||||
fileSize,
|
||||
sizeUnit,
|
||||
storageLimit,
|
||||
storage_limit,
|
||||
storageLimitUnit,
|
||||
saveTime,
|
||||
saveTimeUnit,
|
||||
@@ -185,10 +185,10 @@ onMounted(() => {
|
||||
|
||||
<SettingSwitch
|
||||
:label="t('admin.settings.showAdminAddress')"
|
||||
:model-value="config.showAdminAddr"
|
||||
:model-value="config.show_admin_addr"
|
||||
:enabled-text="t('common.enabled')"
|
||||
:disabled-text="t('common.disabled')"
|
||||
@toggle="toggleConfigFlag('showAdminAddr')"
|
||||
@toggle="toggleConfigFlag('show_admin_addr')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -220,7 +220,7 @@ onMounted(() => {
|
||||
{{ t('manage.settings.themeSelection') }}
|
||||
</label>
|
||||
<select
|
||||
v-model="config.themesSelect"
|
||||
v-model="config.themes_select"
|
||||
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border appearance-none bg-no-repeat bg-right focus:ring-2 focus:ring-zinc-500 focus:border-zinc-500 outline-none cursor-pointer"
|
||||
:class="[
|
||||
isDarkMode
|
||||
@@ -231,7 +231,7 @@ onMounted(() => {
|
||||
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M7%208l3%203%203-3%22%20stroke%3D%22%236B7280%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
|
||||
"
|
||||
>
|
||||
<option v-for="item in config.themesChoices" :value="item.key" :key="item.key">
|
||||
<option v-for="item in config.themes_choices" :value="item.key" :key="item.key">
|
||||
{{ item.name }} (by {{ item.author }} V{{ item.version }})
|
||||
</option>
|
||||
</select>
|
||||
@@ -244,7 +244,7 @@ onMounted(() => {
|
||||
{{ t('manage.settings.robotsFile') }}
|
||||
</label>
|
||||
<textarea
|
||||
v-model="config.robotsText"
|
||||
v-model="config.robots_text"
|
||||
rows="3"
|
||||
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border resize-none focus:ring-2 focus:ring-zinc-500 focus:border-zinc-500 outline-none"
|
||||
:class="[
|
||||
@@ -354,10 +354,10 @@ onMounted(() => {
|
||||
<SettingSwitch
|
||||
v-if="config.file_storage === 'local'"
|
||||
:label="t('manage.settings.chunkUploadNote')"
|
||||
:model-value="config.enableChunk"
|
||||
:model-value="config.enable_chunk"
|
||||
:enabled-text="t('common.enabled')"
|
||||
:disabled-text="t('common.disabled')"
|
||||
@toggle="toggleConfigFlag('enableChunk')"
|
||||
@toggle="toggleConfigFlag('enable_chunk')"
|
||||
/>
|
||||
<div v-if="config.file_storage === 'webdav'" class="space-y-4">
|
||||
<!-- 通知设置 -->
|
||||
@@ -593,10 +593,10 @@ onMounted(() => {
|
||||
|
||||
<SettingSwitch
|
||||
:label="t('manage.settings.chunkUploadNote')"
|
||||
:model-value="config.enableChunk"
|
||||
:model-value="config.enable_chunk"
|
||||
:enabled-text="t('common.enabled')"
|
||||
:disabled-text="t('common.disabled')"
|
||||
@toggle="toggleConfigFlag('enableChunk')"
|
||||
@toggle="toggleConfigFlag('enable_chunk')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -614,13 +614,13 @@ onMounted(() => {
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<SettingNumberInput
|
||||
v-model="config.uploadMinute"
|
||||
v-model="config.upload_minute"
|
||||
:label="t('manage.settings.uploadPerMinute')"
|
||||
:suffix="t('common.minute')"
|
||||
/>
|
||||
|
||||
<SettingNumberInput
|
||||
v-model="config.uploadCount"
|
||||
v-model="config.upload_count"
|
||||
:label="t('manage.settings.uploadCountLimit')"
|
||||
:suffix="t('common.files')"
|
||||
/>
|
||||
@@ -699,13 +699,13 @@ onMounted(() => {
|
||||
<input
|
||||
type="checkbox"
|
||||
:value="style"
|
||||
v-model="config.expireStyle"
|
||||
v-model="config.expire_style"
|
||||
class="peer sr-only"
|
||||
/>
|
||||
<div
|
||||
class="px-4 py-2 rounded-full border-2 transition-all duration-200 select-none"
|
||||
:class="[
|
||||
config.expireStyle.includes(style)
|
||||
config.expire_style.includes(style)
|
||||
? isDarkMode
|
||||
? 'bg-zinc-600 border-zinc-600 text-white'
|
||||
: 'bg-zinc-600 border-zinc-600 text-white'
|
||||
@@ -784,11 +784,11 @@ onMounted(() => {
|
||||
class="block text-sm font-medium"
|
||||
:class="[isDarkMode ? 'text-zinc-300' : 'text-zinc-700']"
|
||||
>
|
||||
{{ t('admin.settings.storageLimit') }}
|
||||
{{ t('admin.settings.storage_limit') }}
|
||||
</label>
|
||||
<div class="flex items-center space-x-2">
|
||||
<input
|
||||
v-model.number="storageLimit"
|
||||
v-model.number="storage_limit"
|
||||
type="number"
|
||||
min="0"
|
||||
step="1"
|
||||
@@ -820,10 +820,10 @@ onMounted(() => {
|
||||
|
||||
<SettingSwitch
|
||||
:label="t('manage.settings.guestUpload')"
|
||||
:model-value="config.openUpload"
|
||||
:model-value="config.open_upload"
|
||||
:enabled-text="t('common.enabled')"
|
||||
:disabled-text="t('common.disabled')"
|
||||
@toggle="toggleConfigFlag('openUpload')"
|
||||
@toggle="toggleConfigFlag('open_upload')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -839,13 +839,13 @@ onMounted(() => {
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<SettingNumberInput
|
||||
v-model="config.errorMinute"
|
||||
v-model="config.error_minute"
|
||||
:label="t('manage.settings.errorPerMinute')"
|
||||
:suffix="t('common.minute')"
|
||||
/>
|
||||
|
||||
<SettingNumberInput
|
||||
v-model="config.errorCount"
|
||||
v-model="config.error_count"
|
||||
:label="t('manage.settings.errorCountLimit')"
|
||||
:suffix="t('common.times')"
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user