✨ 整合文件选择工具栏
This commit is contained in:
@@ -79,6 +79,7 @@ const isLegacyEndpointUnavailable = (error: unknown) => {
|
||||
|
||||
const legacyForeverExpiresAt = '2099-12-31T23:59'
|
||||
const detailPolicyDownloadLimit = 5
|
||||
const hourInMilliseconds = 60 * 60 * 1000
|
||||
const dayInMilliseconds = 24 * 60 * 60 * 1000
|
||||
|
||||
type DetailPolicyActionOption = {
|
||||
@@ -99,7 +100,9 @@ type HealthFilterOption = {
|
||||
const emptyBatchEditForm = (): AdminBatchEditForm => ({
|
||||
mode: 'expiresAt',
|
||||
expired_at: '',
|
||||
expired_count: null
|
||||
expired_count: null,
|
||||
relative_expire_value: null,
|
||||
relative_expire_unit: 'hours'
|
||||
})
|
||||
|
||||
const metadataTagSeparatorPattern = /[,,\n]+/
|
||||
@@ -269,6 +272,12 @@ export function useAdminFiles() {
|
||||
)
|
||||
const selectedCount = computed(() => selectedFileIds.value.size)
|
||||
const hasSelectedFiles = computed(() => selectedCount.value > 0)
|
||||
const selectedFilesOnCurrentPage = computed(() =>
|
||||
tableData.value.filter((file) => selectedFileIds.value.has(file.id))
|
||||
)
|
||||
const selectedHasPermanentFiles = computed(() =>
|
||||
selectedFilesOnCurrentPage.value.some((file) => file.isPermanentFile)
|
||||
)
|
||||
const isAllCurrentPageSelected = computed(
|
||||
() => tableData.value.length > 0 && currentPageSelectedCount.value === tableData.value.length
|
||||
)
|
||||
@@ -429,7 +438,7 @@ export function useAdminFiles() {
|
||||
)
|
||||
|
||||
const batchPolicyActionOptions = computed<BatchPolicyActionOption[]>(
|
||||
() => createPolicyActionOptions(false)
|
||||
() => createPolicyActionOptions(selectedHasPermanentFiles.value)
|
||||
)
|
||||
|
||||
const inferIsText = (file: FileListItem) => {
|
||||
@@ -571,6 +580,7 @@ export function useAdminFiles() {
|
||||
displayHealthAction: t(`fileManage.insightActions.${statusInsightNextAction}`),
|
||||
isTextFile,
|
||||
isExpiredFile,
|
||||
isPermanentFile,
|
||||
isChunkedFile,
|
||||
remainingDownloadsValue,
|
||||
canPreviewText: isTextFile,
|
||||
@@ -823,6 +833,23 @@ export function useAdminFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
if (form.mode === 'relativeExpire') {
|
||||
if (
|
||||
form.relative_expire_value === null ||
|
||||
!Number.isFinite(form.relative_expire_value) ||
|
||||
form.relative_expire_value <= 0
|
||||
) {
|
||||
return null
|
||||
}
|
||||
const duration =
|
||||
form.relative_expire_value *
|
||||
(form.relative_expire_unit === 'days' ? dayInMilliseconds : hourInMilliseconds)
|
||||
return {
|
||||
ids,
|
||||
expired_at: formatLocalDateTime(new Date(Date.now() + duration))
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ids,
|
||||
clearExpiredAt: true,
|
||||
@@ -1425,10 +1452,11 @@ export function useAdminFiles() {
|
||||
|
||||
const applySelectedPolicyAction = async (action: AdminFilePolicyAction) => {
|
||||
if (!hasSelectedFiles.value || isBatchActionRunning.value) return
|
||||
const selectedAction = batchPolicyActionOptions.value.find((option) => option.action === action)
|
||||
if (selectedAction?.disabled) return
|
||||
|
||||
const ids = Array.from(selectedFileIds.value)
|
||||
const actionLabel =
|
||||
batchPolicyActionOptions.value.find((option) => option.action === action)?.label || action
|
||||
const actionLabel = selectedAction?.label || action
|
||||
if (
|
||||
!window.confirm(
|
||||
t('fileManage.batchPolicyActionConfirm', {
|
||||
@@ -1690,6 +1718,7 @@ export function useAdminFiles() {
|
||||
selectedFileDetail,
|
||||
selectedCount,
|
||||
selectedFileIds,
|
||||
selectedHasPermanentFiles,
|
||||
selectedViewPresetId,
|
||||
storageUsedText,
|
||||
summary,
|
||||
|
||||
Reference in New Issue
Block a user