feat: streamline mobile file workspace
This commit is contained in:
@@ -12,6 +12,19 @@ createApp({
|
||||
return (saved && ['overview', 'settings', 'monitor', 'users'].includes(saved)) ? saved : 'overview';
|
||||
})();
|
||||
|
||||
const initialFileViewMode = (() => {
|
||||
try {
|
||||
const saved = localStorage.getItem('fileViewMode');
|
||||
if (saved && ['grid', 'list'].includes(saved)) {
|
||||
return saved;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('[视图] 无法读取文件视图偏好:', error);
|
||||
}
|
||||
|
||||
return window.matchMedia('(max-width: 768px)').matches ? 'list' : 'grid';
|
||||
})();
|
||||
|
||||
return {
|
||||
// API配置
|
||||
// API配置 - 通过nginx代理访问
|
||||
@@ -29,7 +42,7 @@ createApp({
|
||||
// 视图状态
|
||||
currentView: 'files',
|
||||
isLogin: true,
|
||||
fileViewMode: 'grid', // 文件显示模式: grid 大图标, list 列表
|
||||
fileViewMode: initialFileViewMode, // 移动端默认列表视图,并记住用户选择
|
||||
shareViewMode: 'list', // 分享显示模式: grid 大图标, list 列表
|
||||
shareResourceTab: 'shares', // 分享中心资源标签: shares / directLinks
|
||||
settingsTab: 'storage', // 设置中心标签: storage / appearance / security
|
||||
@@ -349,6 +362,7 @@ createApp({
|
||||
contextMenuX: 0,
|
||||
contextMenuY: 0,
|
||||
contextMenuFile: null,
|
||||
showMobileCreateSheet: false,
|
||||
showMobileFileActionSheet: false,
|
||||
mobileActionFile: null,
|
||||
|
||||
@@ -2245,6 +2259,46 @@ handleDragLeave(e) {
|
||||
document.body.style.overflow = locked ? 'hidden' : '';
|
||||
},
|
||||
|
||||
setFileViewMode(mode) {
|
||||
if (!['grid', 'list'].includes(mode)) return;
|
||||
this.fileViewMode = mode;
|
||||
|
||||
try {
|
||||
localStorage.setItem('fileViewMode', mode);
|
||||
} catch (error) {
|
||||
console.warn('[视图] 无法保存文件视图偏好:', error);
|
||||
}
|
||||
},
|
||||
|
||||
openMobileCreateSheet(event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
this.closeMobileFileActionSheet();
|
||||
this.showMobileCreateSheet = true;
|
||||
this.setMobileSheetScrollLock(true);
|
||||
},
|
||||
|
||||
closeMobileCreateSheet() {
|
||||
this.showMobileCreateSheet = false;
|
||||
this.setMobileSheetScrollLock(false);
|
||||
},
|
||||
|
||||
mobileCreateAction(action) {
|
||||
this.closeMobileCreateSheet();
|
||||
|
||||
if (action === 'upload') {
|
||||
this.$nextTick(() => this.$refs.fileUploadInput?.click());
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === 'folder') {
|
||||
this.showCreateFolderModal = true;
|
||||
}
|
||||
},
|
||||
|
||||
openMobileFileActionSheet(file, event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
@@ -5176,11 +5230,12 @@ handleDragLeave(e) {
|
||||
this.isDragging = false;
|
||||
});
|
||||
|
||||
// 添加 ESC 键监听(按 ESC 关闭拖拽覆盖层)
|
||||
// 添加 ESC 键监听(按 ESC 关闭当前浮层)
|
||||
window.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape" && this.isDragging) {
|
||||
this.isDragging = false;
|
||||
}
|
||||
if (e.key !== "Escape") return;
|
||||
if (this.isDragging) this.isDragging = false;
|
||||
if (this.showMobileCreateSheet) this.closeMobileCreateSheet();
|
||||
if (this.showMobileFileActionSheet) this.closeMobileFileActionSheet();
|
||||
});
|
||||
|
||||
// 设置axios响应拦截器,处理401错误(token过期/失效)
|
||||
|
||||
Reference in New Issue
Block a user