guoziyun 1 anno fa
parent
commit
9ebb5e8d36
2 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 5 2
      routes/res/download.js
  2. 1 1
      views/detail.ejs

+ 5 - 2
routes/res/download.js

@@ -5,14 +5,17 @@ const config = require('../../config/app');
 const { PDFDocument, rgb, StandardFonts } = require('pdf-lib');
 
 
-router.get('/pdf/:id', function (req, res, next) {
+router.get('/pdf/:type/:id', function (req, res, next) {
   (async function () {
+    let type = req.params.type;
+    if (type != 'page' || type != 'work') throw new Error(`Not Support URL`);
+
     let id = req.params.id;
     utils.validators.validateId(id);
 
     let host = config.cdnHost ?? config.resHost;
 
-    let url = `${host}/thumbs/coloring-page/page/1200/${id}.jpeg`;
+    let url = `${host}/thumbs/coloring-page/${type}/1200/${id}.jpeg`;
 
     try {
       const response = await fetch(url);

+ 1 - 1
views/detail.ejs

@@ -104,7 +104,7 @@
                             <a id="appBtn" class="play-button" style="background-color: darkolivegreen;">
                                 <%= translate.playOnApp[lang] %>
                             </a>
-                            <a href="/download/pdf/<%= detail._id %>" class="play-button"
+                            <a href="/download/pdf/page/<%= detail._id %>" class="play-button"
                                 style="background-color: lightseagreen;">
                                 <%= translate.download[lang] %>
                             </a>