编译修改Alist绕过Replit检测防止被封

直接使用GitHub Codespaces编译,登录并创建空白模板 https://github.com/codespaces/templates

右击Codespaces空白处,在集成终端中打开,克隆项目

git clone --recurse-submodules https://github.com/alist-org/alist-web.git
#克隆前端代码

git clone https://github.com/alist-org/alist.git yema
#克隆后端代码

编译前端

npm install -g pnpm
#安装pnpm

cd alist-web 
wget https://crowdin.com/backend/download/project/alist/zh-CN.zip 
unzip zh-CN.zip 
node ./scripts/i18n.mjs
rm zh-CN.zip
#进入前端目录,下载使用中文语言包

pnpm install
#安装依赖
pnpm run build
#编译前端

cp -r /workspaces/codespaces-blank/alist-web/dist /workspaces/codespaces-blank/yema/public/
#将编译好的前端dist目录,移动到后端public目录

修改并编译后端,需要等待几分钟

cd ../yema
#执行以下命令编译服务端

appName="yema"
builtAt="$(date +'%F %T %z')"
goVersion=$(go version | sed 's/go version //')
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
gitCommit=$(git log --pretty=format:"%h" -1)
version=$(git describe --long --tags --dirty --always)
webVersion=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
ldflags="\
-w -s \
-X 'github.com/alist-org/alist/v3/internal/conf.BuiltAt=$builtAt' \
-X 'github.com/alist-org/alist/v3/internal/conf.GoVersion=$goVersion' \
-X 'github.com/alist-org/alist/v3/internal/conf.GitAuthor=$gitAuthor' \
-X 'github.com/alist-org/alist/v3/internal/conf.GitCommit=$gitCommit' \
-X 'github.com/alist-org/alist/v3/internal/conf.Version=$version' \
-X 'github.com/alist-org/alist/v3/internal/conf.WebVersion=$webVersion' \
-o $appName \
"
go build -ldflags="$ldflags" .

#编译后会生成yema

上传编译后的文件, 返回replit创建bash repl,将文件上传到repl,并将main.sh替换为以下代码

echo Hello World
URL=${REPL_SLUG}.${REPL_OWNER}.repl.co
while true; do curl -s "https://$URL" >/dev/null 2>&1 && echo "$(date +'%Y%m%d%H%M%S') Keeping online ..." && sleep 300; done &
chmod +x ./yema
nohup ./yema server

点击绿色按钮 run 即可
第一次运行会生成配置文件,默认数据库为本地,打开nohup.out在第5行获取账号密码