Loading... # 前言 本文转自[萌鼠大佬](https://www.moerats.com/archives/1016/) `OneList`主要的特色就是解决了因`OneDrive API`抽风导致的很多问题,稳定性和访问速度都是不错的。不过由于使用`Python`写的,而Py单线程容易阻塞,响应不够迅速,刷新缓存时,Web端请求基本不可用,所以在整体性能上有点瑕疵。基于`Golang`的性能更好,效率更高,多盘并发缓存等众多好处,于是萌咖大佬就弃用`Python`版本,使用`Golang`重写了`OneList`,同时支持国际版、个人免费版(家庭版)、中国版(世纪互联)及多网盘绑定。 # 安装 Github地址:https://github.com/MoeClub/OneList/tree/master/Rewrite 1、授权认证 点击右侧URL登录并授权,授权[国际版、个人版(家庭版)](https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=78d4dc35-7e46-42c6-9023-2d39314433a5&response_type=code&redirect_uri=http://localhost/onedrive-login&response_mode=query&scope=offline_access%20User.Read%20Files.ReadWrite.All)、[中国版(世纪互联)](https://login.chinacloudapi.cn/common/oauth2/v2.0/authorize?client_id=dfe36e60-6133-48cf-869f-4d15b8354769&response_type=code&redirect_uri=http://localhost/onedrive-login&response_mode=query&scope=offline_access%20User.Read%20Files.ReadWrite.All)。 授权后会获取一个`localhost`开头打不开的链接,这里复制好整个链接地址,包括`localhost`。 2、安装OneList ``` #新建并进入OneList目录 mkdir /opt/OneList && cd $_ #64位系统下载 wget https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/amd64/linux/OneList #32位系统下载 wget https://raw.githubusercontent.com/MoeClub/OneList//master/Rewrite/i386/linux/OneList #arm架构下载 wget https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/arm/linux/OneList #给予权限 chmod +x OneList ``` 3、使用命令 ``` Usage of OneList: -a string // 初始化配置文件,添加新配置 Setup and Init auth.json. -bind string // 绑定IP地址(公网: 0.0.0.0) Bind Address (default "127.0.0.1") -port string // 绑定端口(HTTP:80) Port (default "5288") -s string // 设置 SubPath 项, 需要与 -a 一起使用. Set SubPath. [unique per account] (default "/") -c string // 配置文件 Config file. (default "config.json") -t string // Index.html 目录样式文件 Index file. (default "index.html") -cn // 开关 // 授权中国版(世纪互联), 需要此参数. OneDrive by 21Vianet. -ms // 开关 // 授权个人版(家庭版), 需要此参数. OneDrive by Microsoft. ``` 4、生成配置文件 ``` #国际版,将url换成你上面复制的授权地址,包括http://loaclhost。 ./OneList -a "url" -s "/onedrive01" #个人版(家庭版),将url换成你上面复制的授权地址,包括http://loaclhost。 ./OneList -ms -a "url" -s "/onedrive02" #中国版(世纪互联),将url换成你上面复制的授权地址,包括http://loaclhost。 ./OneList -cn -a "url" -s "/onedrive03" ``` 提示`Success! Add config. '/path/to/config.json'`信息,则添加成功。 这里要注意的是: > 1、授权url地址只能用一次,超过需要重新授权。 > 2、命令中的/onedrive01参数为指定网盘地址后缀,比如`http://domain.com/onedrive01`。 > 3、授权多个网盘的话,重复授权多次即可,参数均会添加到一个配置文件,且后缀不能重复。 > 4、地址后缀填错了的,可以稍后在配置文件中修改。 本文默认的配置文件路径`/opt/OneList/config.json`,参数详解,可自行修改: ``` [ { // 如果是家庭版或者个人免费版, 此项应为 true. "MSAccount": false, // 如果是中国版(世纪互联), 此项应为 true. "MainLand": false, // 授权令牌 "RefreshToken": "1234564567890ABCDEF", // 单配置文件中,此项要唯一.将此OneDrive中设置为`RootPath`目录映射在`http://127.0.0.1:5288/onedrive` 下. // (只推荐一个盘位的时候使用根目录"/".) "SubPath": "/onedrive", // 读取OneDrive的某个目录作为根目录. (支持根目录"/") "RootPath": "/Test", // 隐藏OneDrive目录中的文件夹和文件, 条目间使用 "|" 分割. (跳过缓存设置的条目.) "HidePath": "/Test/Obj01|/Test/Obj02", // 使用用户名和密码加密OneDrive目录. 目录和用户名密码间使用 "?" 分割, 用户名密码使用 ":" 分割, 条目间使用 "|" 分割. 无效条目将跳过. "AuthPath": "/Test/Auth01?user01:pwd01|/Test/Auth02?user02:pwd02", // 缓存刷新间隔.(所有项目中的刷新时间取最小值为有效刷新间隔) "RefreshInterval": 900 } ] ``` 这里注意,挂载多个盘符的时候,`SubPath`参数请不要为`/`,单个网盘建议为`/`。 5、运行OneList ``` #下载默认的index.html主题,与config.json同目录,即本文默认的/opt/OneList wget https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/index.html -P /opt/OneList #监听8000地址,自行修改 /opt/OneList/OneList -bind 0.0.0.0 -port 8000 ``` 最后打开`ip:端口`访问即可,如果你挂载网盘的时候`SubPath`为`/`,那么直接通过根目录查看,如果为`/onedrive1`,那么通过`ip:端口/onedrive1`查看,如果该路径不存在,则会提示`No Found.`。 且首次运行会异步缓存,也就是至少有一个盘缓存成功了,才会显示。 6、开机自启 这里新建一个简单的systemd配置文件,适用`CentOS 7`、`Debian 8+`、`Ubuntu 16+`。 使用命令: ``` #注意修改你的运行监听端口,即你可以通过ip:端口访问程序,这里默认8000。 #将以下代码一起复制到SSH运行 cat > /etc/systemd/system/onelist.service <<EOF [Unit] Description=onelist After=network.target [Service] Type=simple ExecStart=/opt/OneList/OneList -bind 0.0.0.0 -port 8000 Restart=on-failure [Install] WantedBy=multi-user.target EOF ``` ``` #启动并设置开机自启 systemctl start onelist systemctl enable onelist ``` # 反向代理 宝塔安装Nginx,建立站点,设置反代,应为前面是绑定公网ip`/opt/OneList/OneList -bind 0.0.0.0 -port 8000`这样运行的,所以反代的时候要使用公网ip或者解析好的域名来进行设置,如图  # 更换主题 > 提示:下载主题的index.html文件,覆盖默认index.html文件,本文默认存放/opt/OneList,然后重启程序即可 主题地址:https://github.com/MoeClub/OneList/tree/master/Rewrite/@Theme 1、HaorWu ``` #作者 https://github.com/HaorWu #特点 支持移动端自适应 支持当页搜索 支持按文件名, 日期, 大小排序 支持主动查看图片 支持在线播放视频 #下载地址 https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/%40Theme/HaorWu/index.html ``` 2、jackjieYYY ``` #作者 https://github.com/jackjieYYY https://www.hostloc.com/space-uid-38920.html #特点 支持移动端自适应 支持当页搜索 支持按文件名, 日期, 大小排序 支持在线播放视频 #下载地址 https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/%40Theme/jackjieYYY/index.html ``` 3、NomadJohn 论坛大佬写的,觉得还不错,支持在线浏览图片,视频,搜索文件,以及音乐播放功能 建立新的`index.html`将下面代码复制进去,注意和`config.json`在同一目录下 https://raw.githubusercontent.com/NomadJohn/issue-blog/master/index.html # 相关命令 ``` 启动:systemctl start onelist 停止:systemctl stop onelist 重启:systemctl restart onelist 查看状态:systemctl status onelist ``` # 卸载 ``` #未设置开机自启 rm -rf /opt/OneList #设置过开机自启 systemctl stop onelist systemctl disable onelist rm -rf /opt/OneList /etc/systemd/system/onelist.service ``` 最后修改:2022 年 12 月 20 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 0 如果觉得我的文章对你有用,请随意赞赏