✨ 重新设计分享管理页面
- 添加搜索/筛选功能(关键字、类型、状态、排序) - 重新设计卡片视图,展示更多信息(状态、类型、加密、存储来源等) - 添加filteredShares计算属性实现筛选和排序 - 添加辅助方法:getShareTypeLabel、getShareStatus、getShareProtection等 - 优化分享卡片样式,支持深色/浅色主题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -89,6 +89,12 @@ createApp({
|
||||
customDays: 7
|
||||
},
|
||||
shareResult: null,
|
||||
shareFilters: {
|
||||
keyword: '',
|
||||
type: 'all', // all/file/directory/all_files
|
||||
status: 'all', // all/active/expiring/expired/protected/public
|
||||
sort: 'created_desc' // created_desc/created_asc/views_desc/downloads_desc/expire_asc
|
||||
},
|
||||
|
||||
// 文件重命名
|
||||
showRenameModal: false,
|
||||
@@ -304,6 +310,56 @@ createApp({
|
||||
// 存储类型显示文本
|
||||
storageTypeText() {
|
||||
return this.storageType === 'local' ? '本地存储' : 'SFTP存储';
|
||||
},
|
||||
|
||||
// 分享筛选+排序后的列表
|
||||
filteredShares() {
|
||||
let list = [...this.shares];
|
||||
const keyword = this.shareFilters.keyword.trim().toLowerCase();
|
||||
|
||||
if (keyword) {
|
||||
list = list.filter(s =>
|
||||
(s.share_path || '').toLowerCase().includes(keyword) ||
|
||||
(s.share_code || '').toLowerCase().includes(keyword) ||
|
||||
(s.share_url || '').toLowerCase().includes(keyword)
|
||||
);
|
||||
}
|
||||
|
||||
if (this.shareFilters.type !== 'all') {
|
||||
const targetType = this.shareFilters.type === 'all_files' ? 'all' : this.shareFilters.type;
|
||||
list = list.filter(s => (s.share_type || 'file') === targetType);
|
||||
}
|
||||
|
||||
if (this.shareFilters.status !== 'all') {
|
||||
list = list.filter(s => {
|
||||
if (this.shareFilters.status === 'expired') return this.isExpired(s.expires_at);
|
||||
if (this.shareFilters.status === 'expiring') return this.isExpiringSoon(s.expires_at) && !this.isExpired(s.expires_at);
|
||||
if (this.shareFilters.status === 'active') return !this.isExpired(s.expires_at);
|
||||
if (this.shareFilters.status === 'protected') return !!s.share_password;
|
||||
if (this.shareFilters.status === 'public') return !s.share_password;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
list.sort((a, b) => {
|
||||
const getTime = s => s.created_at ? new Date(s.created_at).getTime() : 0;
|
||||
const getExpire = s => s.expires_at ? new Date(s.expires_at).getTime() : Number.MAX_SAFE_INTEGER;
|
||||
|
||||
switch (this.shareFilters.sort) {
|
||||
case 'created_asc':
|
||||
return getTime(a) - getTime(b);
|
||||
case 'views_desc':
|
||||
return (b.view_count || 0) - (a.view_count || 0);
|
||||
case 'downloads_desc':
|
||||
return (b.download_count || 0) - (a.download_count || 0);
|
||||
case 'expire_asc':
|
||||
return getExpire(a) - getExpire(b);
|
||||
default:
|
||||
return getTime(b) - getTime(a); // created_desc
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1916,6 +1972,49 @@ handleDragLeave(e) {
|
||||
return expireDate <= now;
|
||||
},
|
||||
|
||||
// 分享类型标签
|
||||
getShareTypeLabel(type) {
|
||||
switch (type) {
|
||||
case 'directory': return '文件夹';
|
||||
case 'all': return '全部文件';
|
||||
case 'file':
|
||||
default: return '文件';
|
||||
}
|
||||
},
|
||||
|
||||
// 分享状态标签
|
||||
getShareStatus(share) {
|
||||
if (this.isExpired(share.expires_at)) {
|
||||
return { text: '已过期', class: 'danger', icon: 'fa-clock' };
|
||||
}
|
||||
if (this.isExpiringSoon(share.expires_at)) {
|
||||
return { text: '即将到期', class: 'warn', icon: 'fa-hourglass-half' };
|
||||
}
|
||||
return { text: '有效', class: 'success', icon: 'fa-check-circle' };
|
||||
},
|
||||
|
||||
// 分享保护标签
|
||||
getShareProtection(share) {
|
||||
if (share.share_password) {
|
||||
return { text: '已加密', class: 'info', icon: 'fa-lock' };
|
||||
}
|
||||
return { text: '公开', class: 'info', icon: 'fa-unlock' };
|
||||
},
|
||||
|
||||
// 存储来源
|
||||
getStorageLabel(storageType) {
|
||||
if (!storageType) return '默认';
|
||||
return storageType === 'local' ? '本地存储' : storageType.toUpperCase();
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatDateTime(value) {
|
||||
if (!value) return '--';
|
||||
const d = new Date(value);
|
||||
if (Number.isNaN(d.getTime())) return value;
|
||||
return d.toLocaleString();
|
||||
},
|
||||
|
||||
copyShareLink(url) {
|
||||
// 复制分享链接到剪贴板
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
|
||||
Reference in New Issue
Block a user