alist icon indicating copy to clipboard operation
alist copied to clipboard

希望增加能够记住排序设定的功能

Open LAOZTK opened this issue 1 year ago • 2 comments

Please make sure of the following things

  • [X] I have read the documentation.
  • [X] I'm sure there are no duplicate issues or discussions.
  • [X] I'm sure this feature is not implemented.
  • [X] I'm sure it's a reasonable and popular requirement.

Description of the feature / 需求描述

上一级目录按了按时间排序,然后进入子目录后,返回上一级目录,还是按照时间排序 现在每次返回都是按照默认方式排序,没办法记住排序的方式

Suggested solution / 实现思路

No response

Additional context / 附件

No response

LAOZTK avatar Oct 14 '24 08:10 LAOZTK

Thanks for opening your first issue here! Be sure to follow the issue template!

welcome[bot] avatar Oct 14 '24 08:10 welcome[bot]

+1,附实现思路:

  1. 在数据库中,添加 table,table 名可以为 [prefix]_order_rule,field 包含路径 path,order_by,order_direction,add_time
  2. UI 中,点击文件列表表头,触发排序规则的更新 API(不知前端是否支持?),API 可以为 POST /api/fs/order,参数包含 path,order_by,order_direction,取值与 storage 表兼容
  3. 后端直接写入数据库,同时设置该规则的添加时间 add_time 为当前时间戳
  4. 当前端请求 /api/fs/list 返回目录列表时,同时在返回值中设置 order_by,order_direction 的值,由后端从数据库中查询,并在前端应用该排序规则;如无法查到,返回 storage 表中对应的配置作为缺省值
  5. 避免在后端进行排序,以降低服务器压力
  6. 每次查询到 order_rule 表中的排序规则时,更新 add_time 为当前时间戳
  7. alist 定期清理该表中所有超时的记录(通过预设超时时间实现)。超时代表用户长期不访问该目录,清理不会影响用户体验
  8. 建议在数据库中添加字段以记录程序上次启动和上次停止的时间戳,这样计算超时用户体验更好
  9. 也可考虑在 redis 中实现该功能,如 alist 打算引入 redis,建议将基础索引功能也迁移到 redis 中
  10. 有空提 PR,现在蹲个好心人

Rirmach avatar Oct 19 '24 19:10 Rirmach

+1

aogg avatar Dec 03 '24 03:12 aogg