mirror of
https://github.com/kuaifan/dootask.git
synced 2026-07-21 21:48:00 +00:00
feat(file): 我的文件纳入已共享文件,修复板块切换缓存丢失
- 「我的文件」改为展示我拥有的全部(含已共享出去的),与「共享文件」在“我共享的”上刻意重叠 - 缓存改为 stale-while-revalidate:按板块懒加载,切回该板块/目录先读缓存再拉接口静态刷新 - getFiles 清理过期行按 scope 限定范围,避免刷新一个板块误删另一板块(同为 pid=0)的缓存 - 微调 file-tabs 来源筛选字号与面包屑上边距 - 同步 ai-kb 文件入口说明(last_verified v1.8.69)
This commit is contained in:
parent
f1ea0ed3dc
commit
13ba1d3bd7
@ -230,13 +230,10 @@ class File extends AbstractModel
|
||||
} else {
|
||||
// 根目录:按板块拆分
|
||||
$array = [];
|
||||
// 我的文件(mine 仅私有 share=0;all 含全部我的)
|
||||
// 我的文件:我拥有的全部(含已共享出去的),mine 与 all 一致
|
||||
if ($scope === 'mine' || $scope === 'all') {
|
||||
$mine = File::wherePid(0)
|
||||
->whereUserid($user->userid)
|
||||
->when($scope === 'mine', function ($q) {
|
||||
$q->where('share', 0);
|
||||
})
|
||||
->when($type == 'dir', function ($q) {
|
||||
$q->whereType('folder');
|
||||
})
|
||||
|
||||
@ -17,7 +17,7 @@ prerequisites: []
|
||||
negative:
|
||||
- 文件入口不在「应用」二级页面,是左侧栏一级菜单
|
||||
- 移动端目前没有专门的「文件」Tabbar,需要从「更多」进
|
||||
last_verified: v1.8.64
|
||||
last_verified: v1.8.69
|
||||
---
|
||||
|
||||
# 文件入口在哪
|
||||
@ -31,8 +31,9 @@ DooTask 的「文件」是一级导航,相当于个人网盘 + 团队共享盘
|
||||
|
||||
## 默认视图
|
||||
- 顶部一行是板块 Tab:「我的文件」/「共享文件」,同一行最右是视图切换(宫格 / 列表),窄屏自动换行
|
||||
- 「我的文件」:自己创建的私有文件(未共享)
|
||||
- 「我的文件」:我拥有的全部文件(含已共享出去的,共享不会让它从这里消失)
|
||||
- 「共享文件」:双向共享——包含「我共享出去的」和「别人共享给我的」,可用「全部 / 我共享的 / 共享给我的」二次筛选
|
||||
- 我共享出去的文件会同时出现在「我的文件」和「共享文件」两个板块
|
||||
- 进入子文件夹后,Tab 下方出现面包屑路径(以板块名为起点,可点击回到板块根目录);根目录不显示重复标题
|
||||
- 主区域列出当前文件夹下的文件与文件夹(最多 500 条,超出滚动加载)
|
||||
- 板块选择会记住上次停留的 Tab
|
||||
|
||||
@ -41,12 +41,12 @@
|
||||
<div :class="['file-tab', {active: board === 'mine'}]" @click="switchBoard('mine')">{{$L('我的文件')}}</div>
|
||||
<div :class="['file-tab', {active: board === 'shared'}]" @click="switchBoard('shared')">{{$L('共享文件')}}</div>
|
||||
</div>
|
||||
<div class="file-tabs-full"></div>
|
||||
<div v-if="board === 'shared' && pid == 0 && !searchKey" class="file-shared-src">
|
||||
<span :class="{on: sharedSrc === 'all'}" @click="sharedSrc = 'all'">{{$L('全部')}}</span>
|
||||
<span :class="{on: sharedSrc === 'byme'}" @click="sharedSrc = 'byme'">{{$L('我共享的')}}</span>
|
||||
<span :class="{on: sharedSrc === 'tome'}" @click="sharedSrc = 'tome'">{{$L('共享给我的')}}</span>
|
||||
</div>
|
||||
<div class="file-tabs-full"></div>
|
||||
<div :class="['switch-button', tableMode]">
|
||||
<div @click="tableMode='block'"><i class="taskfont"></i></div>
|
||||
<div @click="tableMode='table'"><i class="taskfont"></i></div>
|
||||
@ -896,13 +896,13 @@ export default {
|
||||
if (file.pid != pid) {
|
||||
return false;
|
||||
}
|
||||
// 根目录按板块区分:我的=我的私有文件(share=0),共享=其余(双向共享)
|
||||
// 根目录按板块区分:我的=我拥有的全部(含已共享),共享=其余(双向共享)
|
||||
if (pid == 0) {
|
||||
const isMinePrivate = file.userid == userId && !file.share;
|
||||
if (board === 'mine') {
|
||||
return isMinePrivate;
|
||||
return file.userid == userId;
|
||||
}
|
||||
if (isMinePrivate) {
|
||||
// 共享板块:排除“我的私有”,即他人共享给我的 + 我共享出去的
|
||||
if (file.userid == userId && !file.share) {
|
||||
return false;
|
||||
}
|
||||
// 共享板块二次筛选:我共享的(我拥有) / 共享给我的(他人拥有)
|
||||
@ -1173,6 +1173,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
this.loadIng++;
|
||||
// 按当前板块拉取(拉多少缓存多少);已有缓存时 fileList 会先渲染缓存,接口回来再静态刷新
|
||||
this.$store.dispatch("getFiles", {pid: this.pid, scope: this.board}).then(async () => {
|
||||
this.loadIng--;
|
||||
this.openFileJudge()
|
||||
@ -1513,9 +1514,10 @@ export default {
|
||||
this.selectedItems = [];
|
||||
this.clearShear();
|
||||
if (this.pid > 0) {
|
||||
// 退回板块根目录,由 pid 变化触发重载
|
||||
// 从子目录切板块时退回根目录(pid 变化触发加载)
|
||||
this.browseFolder(0);
|
||||
} else {
|
||||
// 已在根目录:先由 fileList 渲染本板块缓存,再拉接口静态刷新
|
||||
this.getFileList();
|
||||
}
|
||||
},
|
||||
|
||||
23
resources/assets/js/store/actions.js
vendored
23
resources/assets/js/store/actions.js
vendored
@ -1500,7 +1500,28 @@ export default {
|
||||
data: scope ? {pid, scope} : {pid},
|
||||
}).then((result) => {
|
||||
const ids = result.data.map(({id}) => id)
|
||||
commit("file/save", state.fileLists.filter((item) => item.pid != pid || ids.includes(item.id)));
|
||||
const myId = state.userId
|
||||
// 静态刷新:仅清理"本次拉取该管、但结果里已没有"的过期行,按 scope 限定清理范围,
|
||||
// 避免刷新一个板块把另一个板块(同为 pid=0 根目录)的缓存误删
|
||||
commit("file/save", state.fileLists.filter((item) => {
|
||||
if (item.pid != pid) {
|
||||
return true // 其他目录:保留缓存
|
||||
}
|
||||
if (ids.includes(item.id)) {
|
||||
return true // 本次结果内:保留(随后 saveFile 覆盖更新)
|
||||
}
|
||||
if (pid > 0) {
|
||||
return false // 子目录内容归本次拉取管:清理过期
|
||||
}
|
||||
// 根目录:仅清理本板块 scope 归属的过期行
|
||||
if (scope === 'mine') {
|
||||
return item.userid != myId // 保留"别人共享给我的"
|
||||
}
|
||||
if (scope === 'shared') {
|
||||
return !(item.userid != myId || item.share) // 保留"我的私有"
|
||||
}
|
||||
return false // scope=all 或未指定:清理全部过期(原行为)
|
||||
}));
|
||||
//
|
||||
dispatch("saveFile", result.data);
|
||||
resolve(result)
|
||||
|
||||
6
resources/assets/sass/pages/page-file.scss
vendored
6
resources/assets/sass/pages/page-file.scss
vendored
@ -123,7 +123,7 @@
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
> span {
|
||||
font-size: 12.5px;
|
||||
font-size: 12px;
|
||||
color: $primary-text-color;
|
||||
padding: 3px 12px;
|
||||
border-radius: 14px;
|
||||
@ -202,7 +202,7 @@
|
||||
align-items: center;
|
||||
height: 24px;
|
||||
line-height: 24px;
|
||||
margin: 0 32px 0;
|
||||
margin: 8px 32px 0;
|
||||
> ul {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -811,7 +811,7 @@ body.window-portrait {
|
||||
}
|
||||
}
|
||||
.file-navigator {
|
||||
margin: 0 16px 0;
|
||||
margin: 4px 16px 0;
|
||||
.flex-full {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user