cloudreve / frontend

Cloudreve V3 的前端
248 stars 228 forks source link

境内使用Cloudflare CDN加载pdf.worker.js速度很慢 #156

Open arkylin opened 1 year ago

arkylin commented 1 year ago

使用Cloudflare CDN加载pdf.worker.js速度很慢,导致加载pdf很慢,建议更换其他在国内外加载速度都很快的CDN或者文件本地化

pdfjs.GlobalWorkerOptions.workerSrc = //cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js;

hessonsu commented 1 year ago

哦了?yarn start 要等二十多分钟才能启动起来。是因为这个吧?有无更换的步骤介绍下。后端初涉前端开发。

arkylin commented 1 year ago

不清楚,我是在访问页面-打开PDF文件的时候发现打开很慢,然后一查发现是cloudflare的cdn加载的文件速度很慢

YUDONGLING commented 12 months ago

For users in mainland, you can easily change this setting without self-build the frontend:

  1. use ./cloudreve -eject to extract the built-in static resources into statics directory;
  2. in file ./statics/static/js/pdf.________.chunk.js, replace i.pdfjs.GlobalWorkerOptions.workerSrc="//cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(i.pdfjs.version,"/pdf.worker.js"); to i.pdfjs.GlobalWorkerOptions.workerSrc="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/pdf.js/".concat(i.pdfjs.version,"/pdf.worker.js");;
  3. clear cache.

Hint: Here use the pdf.worker.js provided by ByteDance Public CDN, from cdn.bytedance.com, use other source is also okay.