写点什么

多存储文件列表神器 Alist:轻松管理你的云端资源

作者:qife122
  • 2025-11-05
    福建
  • 本文字数:2378 字

    阅读完需:约 8 分钟

Alist - 多存储文件列表程序

<div align="center"><a href="https://alistgo.com"><img width="100px" alt="logo" src="https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg"/></a><p><em>🗂️一个支持多存储的文件列表程序,使用 Gin 和 Solidjs。</em></p><div><a href="https://goreportcard.com/report/github.com/alist-org/alist/v3"><img src="https://goreportcard.com/badge/github.com/alist-org/alist/v3" alt="latest version" /></a><a href="https://github.com/alist-org/alist/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Xhofe/alist" alt="License" /></a><a href="https://github.com/alist-org/alist/actions?query=workflow%3ABuild"><img src="https://img.shields.io/github/actions/workflow/status/Xhofe/alist/build.yml?branch=main" alt="Build status" /></a><a href="https://github.com/alist-org/alist/releases"><img src="https://img.shields.io/github/release/Xhofe/alist" alt="latest version" /></a></div></div>

功能特性

  • 多存储支持:集成了超过 70 种存储服务,包括阿里云盘、115 网盘、百度网盘、腾讯云、Google Drive、OneDrive 等

  • 统一管理:将多个存储服务聚合在单一界面中,实现统一文件管理

  • WebDAV 支持:提供 WebDAV 协议支持,兼容各种客户端

  • 快速部署:支持 Docker 快速部署,提供多种安装方式

  • 开源免费:基于 MIT 协议开源,完全免费使用

  • 跨平台:支持 Windows、Linux、macOS 等多个平台

  • 现代化界面:基于 Solidjs 构建的现代化用户界面

安装指南

环境要求

  • Go 1.20+

  • Node.js

  • GCC

  • Git

从源码安装

  1. 克隆项目代码:


git clone https://github.com/alist-org/alist.gitgit clone --recurse-submodules https://github.com/alist-org/alist-web.git
复制代码


  1. 切换到主分支:


git checkout main
复制代码


  1. 启动后端服务:


go run main.go
复制代码


  1. 启动前端服务:


pnpm dev
复制代码

使用 Docker 安装

docker pull xhofe/alistdocker run -d --restart=always -v /etc/alist:/opt/alist/data -p 5244:5244 -e PUID=0 -e PGID=0 -e UMASK=022 --name="alist" xhofe/alist:latest
复制代码

二进制文件安装

从 GitHub Releases 页面下载对应平台的二进制文件,解压后直接运行。

使用说明

基本命令

启动服务器:


./alist server
复制代码


查看版本信息:


./alist version
复制代码


管理管理员账户:


# 显示管理员信息./alist admin
# 重置管理员密码为随机字符串./alist admin random
# 设置管理员密码./alist admin set NEW_PASSWORD
# 显示管理员token./alist admin token
复制代码

服务管理

后台启动服务:


./alist start
复制代码


停止服务:


./alist stop
复制代码


重启服务:


./alist restart
复制代码


强制停止服务:


./alist kill
复制代码

存储管理

列出所有存储:


./alist storage list
复制代码


禁用存储:


./alist storage disable <挂载路径>
复制代码

核心代码

主程序入口

package main
import "github.com/alist-org/alist/v3/cmd"
func main() { cmd.Execute()}
复制代码

服务器启动核心代码

// ServerCmd represents the server commandvar ServerCmd = &cobra.Command{    Use:   "server",    Short: "Start the server at the specified address",    Long: `Start the server at the specified addressthe address is defined in config file`,    Run: func(cmd *cobra.Command, args []string) {        Init()        if conf.Conf.DelayedStart != 0 {            utils.Log.Infof("delayed start for %d seconds", conf.Conf.DelayedStart)            time.Sleep(time.Duration(conf.Conf.DelayedStart) * time.Second)        }        bootstrap.InitOfflineDownloadTools()        bootstrap.LoadStorages()        bootstrap.InitTaskManager()        if !flags.Debug && !flags.Dev {            gin.SetMode(gin.ReleaseMode)        }        r := gin.New()        r.Use(gin.LoggerWithWriter(log.StandardLogger().Out), gin.RecoveryWithWriter(log.StandardLogger().Out))        server.Init(r)        // ... 服务器初始化代码    },}
复制代码

存储驱动接口

type Driver interface {    Config() Config    GetAddition() Additional    Init(ctx context.Context) error    Drop(ctx context.Context) error    List(ctx context.Context, dir Obj, args ListArgs) ([]Obj, error)    Link(ctx context.Context, file Obj, args LinkArgs) (*Link, error)    // ... 其他接口方法}
复制代码

阿里云盘驱动示例

type AliDrive struct {    model.Storage    Addition    AccessToken string    cron        *cron.Cron    DriveId     string    UserID      string}
func (d *AliDrive) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) { files, err := d.getFiles(dir.GetID()) if err != nil { return nil, err } return utils.SliceConvert(files, func(src File) (model.Obj, error) { return &model.ObjThumb{ Object: model.Object{ ID: src.FileId, Name: src.Name, Size: src.Size, Modified: src.UpdatedAt, IsFolder: src.Type == "folder", }, Thumbnail: model.Thumbnail{Thumbnail: src.Thumbnail}, }, nil })}
复制代码


Alist 通过模块化的驱动设计,使得添加新的存储服务变得简单高效。每个存储驱动都实现了统一的接口,保证了系统的一致性和可扩展性。更多精彩内容 请关注我的个人公众号 公众号(办公 AI 智能小助手)对网络安全、黑客技术感兴趣的朋友可以关注我的安全公众号(网络安全技术点滴分享)


公众号二维码


办公AI智能小助手


公众号二维码


网络安全技术点滴分享


用户头像

qife122

关注

还未添加个人签名 2021-05-19 加入

还未添加个人简介

评论

发布
暂无评论
多存储文件列表神器Alist:轻松管理你的云端资源_开源_qife122_InfoQ写作社区