feat(file): 我的文件纳入已共享文件,修复板块切换缓存丢失

- 「我的文件」改为展示我拥有的全部(含已共享出去的),与「共享文件」在“我共享的”上刻意重叠
- 缓存改为 stale-while-revalidate:按板块懒加载,切回该板块/目录先读缓存再拉接口静态刷新
- getFiles 清理过期行按 scope 限定范围,避免刷新一个板块误删另一板块(同为 pid=0)的缓存
- 微调 file-tabs 来源筛选字号与面包屑上边距
- 同步 ai-kb 文件入口说明(last_verified v1.8.69)
This commit is contained in:
kuaifan 2026-07-14 12:16:22 +00:00
parent f1ea0ed3dc
commit 13ba1d3bd7
5 changed files with 37 additions and 16 deletions

View File

@ -230,13 +230,10 @@ class File extends AbstractModel
} else {
// 根目录:按板块拆分
$array = [];
// 我的文件mine 仅私有 share=0all 含全部我的)
// 我的文件我拥有的全部含已共享出去的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');
})

View File

@ -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

View File

@ -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">&#xe60c;</i></div>
<div @click="tableMode='table'"><i class="taskfont">&#xe66a;</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();
}
},

View File

@ -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)

View File

@ -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;
}