diff --git a/src/assets/style/main.css b/src/assets/style/main.css index e0d90e4..f06012e 100644 --- a/src/assets/style/main.css +++ b/src/assets/style/main.css @@ -85,6 +85,22 @@ textarea { box-shadow: 0 16px 34px rgba(114, 143, 150, 0.26); } +.fcb-interactive-row { + position: relative; + z-index: 0; + transition: + background-color 180ms ease, + border-color 180ms ease, + box-shadow 180ms ease, + transform 180ms ease; +} + +.fcb-interactive-row:hover { + z-index: 1; + box-shadow: inset 3px 0 0 rgba(95, 135, 150, 0.7), 0 10px 22px rgba(86, 118, 126, 0.16); + transform: translateY(-1px); +} + .dark .theme-2026-card { border-color: rgba(68, 86, 94, 0.82); background: diff --git a/src/composables/index.ts b/src/composables/index.ts index d9eddae..bdc9912 100644 --- a/src/composables/index.ts +++ b/src/composables/index.ts @@ -1,3 +1,5 @@ +export { useAdminActivities } from './useAdminActivities' +export { useAdminTrash } from './useAdminTrash' export { useAdminFiles } from './useAdminFiles' export { useAdminLogin } from './useAdminLogin' export { useAdminSession } from './useAdminSession' diff --git a/src/composables/useAdminActivities.ts b/src/composables/useAdminActivities.ts new file mode 100644 index 0000000..3405e8a --- /dev/null +++ b/src/composables/useAdminActivities.ts @@ -0,0 +1,13 @@ +import { ActivityService } from '@/services' +import type { AdminActivityListParams, AdminActivityListResponse } from '@/types' + +export function useAdminActivities() { + const fetchAdminActivities = async ( + params: AdminActivityListParams + ): Promise => { + const response = await ActivityService.getAdminActivities(params) + return response.detail || null + } + + return { fetchAdminActivities } +} diff --git a/src/composables/useAdminSession.ts b/src/composables/useAdminSession.ts index 9333146..f120f4d 100644 --- a/src/composables/useAdminSession.ts +++ b/src/composables/useAdminSession.ts @@ -9,8 +9,13 @@ export function useAdminSession() { try { const response = await AuthService.verifyToken() - if (response.code === 200 && response.detail?.token) { - adminStore.login(response.detail) + // The current stored bearer token is what was just verified by the server. + // Do not redirect a valid session merely because an adapter omits a token + // field in the verification payload; only replace it when one is supplied. + if (response.code === 200) { + if (response.detail?.token) { + adminStore.login(response.detail) + } return true } } catch { diff --git a/src/composables/useAdminTrash.ts b/src/composables/useAdminTrash.ts new file mode 100644 index 0000000..b4bd797 --- /dev/null +++ b/src/composables/useAdminTrash.ts @@ -0,0 +1,16 @@ +import { TrashService } from '@/services' +import type { TrashListParams, TrashListResponse } from '@/types' + +export function useAdminTrash() { + const fetchTrash = async (params: TrashListParams): Promise => { + const response = await TrashService.list(params) + return response.detail || null + } + + const restoreTrashItem = async (id: number) => TrashService.restore(id) + const purgeTrashItem = async (id: number) => TrashService.purge(id) + const updateTrashRetention = async (id: number, retentionDays: number) => + TrashService.updateRetention(id, retentionDays) + + return { fetchTrash, restoreTrashItem, purgeTrashItem, updateTrashRetention } +} diff --git a/src/constants/index.ts b/src/constants/index.ts index 498481f..959df51 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -68,6 +68,8 @@ export const ROUTES = { LOGIN: '/login', DASHBOARD: '/admin/dashboard', FILE_MANAGE: '/admin/files', + TRASH: '/admin/trash', + ACTIVITY_LOG: '/admin/activities', SETTINGS: '/admin/settings' } as const @@ -78,6 +80,8 @@ export const ROUTE_NAMES = { LOGIN: 'Login', DASHBOARD: 'Dashboard', FILE_MANAGE: 'FileManage', + TRASH: 'Trash', + ACTIVITY_LOG: 'ActivityLog', SETTINGS: 'Settings' } as const @@ -85,7 +89,7 @@ export const ROUTE_NAMES = { export const REGEX_PATTERNS = { EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, PHONE: /^1[3-9]\d{9}$/, - CODE: /^[A-Za-z0-9]{4,8}$/ // 取件码格式 + CODE: /^[A-Za-z0-9]{4,16}$/ // 兼容旧码并支持当前 8 位及未来扩容 } as const // 默认配置 diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 38cca97..429bf29 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -210,6 +210,8 @@ export default { count: 'Download Count' }, maxSaveTime: 'Max Retention Period', + trashRetentionDays: 'Recycle Bin Default Retention', + trashRetentionDaysNote: 'Changing this recalculates cleanup time for dated items currently in the recycle bin. Permanent and already purged items are not affected.', timeUnits: { second: 'sec', minute: 'min', @@ -757,6 +759,8 @@ export default { count: 'Download Count' }, maxSaveTime: 'Max Retention Period', + trashRetentionDays: 'Recycle Bin Default Retention', + trashRetentionDaysNote: 'Changing this recalculates cleanup time for dated items currently in the recycle bin. Permanent and already purged items are not affected.', timeUnits: { second: 'sec', minute: 'min', @@ -839,6 +843,8 @@ export default { count: 'Download Count' }, maxSaveTime: 'Max Retention Period', + trashRetentionDays: 'Recycle Bin Default Retention', + trashRetentionDaysNote: 'Changing this recalculates cleanup time for dated items currently in the recycle bin. Permanent and already purged items are not affected.', timeUnits: { second: 'sec', minute: 'min', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index a2b135b..a17a048 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -210,6 +210,8 @@ export default { count: '按下载次数' }, maxSaveTime: '文件最长保存时间', + trashRetentionDays: '回收站默认保留期', + trashRetentionDaysNote: '修改后会重新计算当前回收站中有期限文件的清理时间;已设为永久或已清理的文件不受影响。', timeUnits: { second: '秒', minute: '分钟', @@ -778,6 +780,8 @@ export default { count: '按下载次数' }, maxSaveTime: '文件最长保存时间', + trashRetentionDays: '回收站默认保留期', + trashRetentionDaysNote: '修改后会重新计算当前回收站中有期限文件的清理时间;已设为永久或已清理的文件不受影响。', s3AccessKeyId: 'Access Key ID', s3SecretAccessKey: 'Secret Access Key', s3BucketName: '存储桶名称', @@ -926,6 +930,8 @@ export default { count: '按下载次数' }, maxSaveTime: '文件最长保存时间', + trashRetentionDays: '回收站默认保留期', + trashRetentionDaysNote: '修改后会重新计算当前回收站中有期限文件的清理时间;已设为永久或已清理的文件不受影响。', timeUnits: { second: '秒', minute: '分钟', diff --git a/src/layout/AdminLayout/AdminLayout.vue b/src/layout/AdminLayout/AdminLayout.vue index 3ce54c3..fbef430 100644 --- a/src/layout/AdminLayout/AdminLayout.vue +++ b/src/layout/AdminLayout/AdminLayout.vue @@ -126,8 +126,10 @@ import { MenuIcon, XIcon, FolderIcon, + Trash2Icon, CogIcon, LayoutDashboardIcon, + ClipboardListIcon, LogOutIcon } from 'lucide-vue-next' import { RouterLink, useRoute, useRouter } from 'vue-router' @@ -146,7 +148,7 @@ const router = useRouter() const route = useRoute() const { t } = useI18n() const isDarkMode = inject('isDarkMode') -const { verifySession, logout } = useAdminSession() +const { logout } = useAdminSession() const menuItems: MenuItem[] = [ { id: ROUTE_NAMES.DASHBOARD, @@ -160,6 +162,18 @@ const menuItems: MenuItem[] = [ icon: FolderIcon, redirect: ROUTES.FILE_MANAGE }, + { + id: ROUTE_NAMES.TRASH, + name: '回收站', + icon: Trash2Icon, + redirect: ROUTES.TRASH + }, + { + id: ROUTE_NAMES.ACTIVITY_LOG, + name: '操作记录', + icon: ClipboardListIcon, + redirect: ROUTES.ACTIVITY_LOG + }, { id: ROUTE_NAMES.SETTINGS, name: t('admin.settings.title'), @@ -212,11 +226,6 @@ onMounted(() => { handleResize() window.addEventListener('resize', handleResize) window.addEventListener('keydown', handleEscape) - void verifySession().then((isValid) => { - if (!isValid) { - void router.push(ROUTES.LOGIN) - } - }) }) onUnmounted(() => { diff --git a/src/router/index.ts b/src/router/index.ts index 294931b..d40215a 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -59,6 +59,24 @@ const routes: RouteRecordRaw[] = [ title: 'files' } }, + { + path: 'trash', + name: ROUTE_NAMES.TRASH, + component: () => import('@/views/manage/TrashView.vue'), + meta: { + ...adminPageMeta, + title: 'trash' + } + }, + { + path: 'activities', + name: ROUTE_NAMES.ACTIVITY_LOG, + component: () => import('@/views/manage/ActivityLogView.vue'), + meta: { + ...adminPageMeta, + title: 'activities' + } + }, { path: 'settings', name: ROUTE_NAMES.SETTINGS, diff --git a/src/services/activity.ts b/src/services/activity.ts new file mode 100644 index 0000000..652e251 --- /dev/null +++ b/src/services/activity.ts @@ -0,0 +1,10 @@ +import api from './client' +import type { AdminActivityListParams, AdminActivityListResponse, ApiResponse } from '@/types' + +export class ActivityService { + static async getAdminActivities( + params: AdminActivityListParams + ): Promise> { + return api.get('/admin/activities', { params }) + } +} diff --git a/src/services/index.ts b/src/services/index.ts index 38e6d24..2d2dbdc 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,7 +1,9 @@ export { AUTH_EVENTS } from './client' +export { ActivityService } from './activity' export { AuthService } from './auth' export { ConfigService } from './config' export { FileService } from './file' export { PresignUploadService } from './presign-upload' export { StatsService } from './stats' +export { TrashService } from './trash' export { uploadChunkedFile } from './upload-strategy' diff --git a/src/services/trash.ts b/src/services/trash.ts new file mode 100644 index 0000000..61ad133 --- /dev/null +++ b/src/services/trash.ts @@ -0,0 +1,20 @@ +import api from './client' +import type { ApiResponse, TrashListParams, TrashListResponse } from '@/types' + +export class TrashService { + static async list(params: TrashListParams): Promise> { + return api.get('/admin/trash/list', { params }) + } + + static async restore(id: number): Promise { + return api.post('/admin/trash/restore', { id }) + } + + static async purge(id: number): Promise { + return api.delete('/admin/trash/purge', { data: { id } }) + } + + static async updateRetention(id: number, retentionDays: number): Promise { + return api.post('/admin/trash/retention', { id, retentionDays }) + } +} diff --git a/src/types/activity.ts b/src/types/activity.ts new file mode 100644 index 0000000..ef0ca6a --- /dev/null +++ b/src/types/activity.ts @@ -0,0 +1,48 @@ +export interface AdminActivityEvent { + id: string + action: string + targetType: string + target_type?: string + targetId?: string | number | null + target_id?: string | number | null + targetName: string + target_name?: string + count: number + meta: Record + createdAt: string + created_at?: string +} + +export interface AdminActivityOption { + value: string + label: string + count: number +} + +export interface AdminActivityListResponse { + activities?: AdminActivityEvent[] + items?: AdminActivityEvent[] + page: number + size: number + total: number + storedTotal?: number + stored_total?: number + filters?: { + action?: string + targetType?: string + target_type?: string + keyword?: string + } + actionOptions?: AdminActivityOption[] + action_options?: AdminActivityOption[] + targetTypeOptions?: AdminActivityOption[] + target_type_options?: AdminActivityOption[] +} + +export interface AdminActivityListParams { + page: number + size: number + action?: string + targetType?: string + keyword?: string +} diff --git a/src/types/config.ts b/src/types/config.ts index cedc534..755edac 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -43,6 +43,7 @@ export interface ConfigState { storage_path: string uploadMinute: number max_save_seconds: number + trashRetentionDays: number opacity: number enableChunk: number s3_access_key_id: string diff --git a/src/types/index.ts b/src/types/index.ts index 9553f6d..3dad71f 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,7 +1,9 @@ +export * from './activity' export * from './api' export * from './auth' export * from './config' export * from './dashboard' export * from './file' export * from './presign-upload' +export * from './trash' export * from './ui' diff --git a/src/types/trash.ts b/src/types/trash.ts new file mode 100644 index 0000000..2cd385d --- /dev/null +++ b/src/types/trash.ts @@ -0,0 +1,27 @@ +export interface TrashFileItem { + id: number + code: string + name?: string + prefix?: string + suffix?: string + size: number + text?: string | null + trashedAt?: string | null + trashExpiresAt?: string | null + trashReason?: string | null + trashPurgedAt?: string | null + isTrashPermanent?: boolean + isTrashPurged?: boolean +} + +export interface TrashListResponse { + page: number + size: number + total: number + data: TrashFileItem[] +} + +export interface TrashListParams { + page: number + size: number +} diff --git a/src/utils/config-storage.ts b/src/utils/config-storage.ts index 2c03801..3bcc512 100644 --- a/src/utils/config-storage.ts +++ b/src/utils/config-storage.ts @@ -41,6 +41,7 @@ export const DEFAULT_CONFIG_STATE: ConfigState = { storage_path: '', uploadMinute: 1, max_save_seconds: DEFAULT_PUBLIC_CONFIG.max_save_seconds, + trashRetentionDays: 30, opacity: 0.9, enableChunk: DEFAULT_PUBLIC_CONFIG.enableChunk, s3_access_key_id: '', diff --git a/src/views/manage/ActivityLogView.vue b/src/views/manage/ActivityLogView.vue new file mode 100644 index 0000000..c7ff7a8 --- /dev/null +++ b/src/views/manage/ActivityLogView.vue @@ -0,0 +1,150 @@ + + + diff --git a/src/views/manage/FileManageView.vue b/src/views/manage/FileManageView.vue index 4afe1c7..f1d1c89 100644 --- a/src/views/manage/FileManageView.vue +++ b/src/views/manage/FileManageView.vue @@ -385,14 +385,13 @@ - -