John há 7 meses atrás
pai
commit
11918f0fd4

+ 3 - 6
epub_node/Dockerfile

@@ -1,8 +1,5 @@
-FROM node:18.20.4
+FROM node:22.12.0
 WORKDIR /app
-COPY package*.json ./
-RUN npm install
-COPY . .
 EXPOSE 3000
-VOLUME /app/base_files
-CMD ["node", "app.js"]
+VOLUME /app
+CMD ["npm", "run", "serve"]

+ 21 - 0
epub_node/README.md

@@ -0,0 +1,21 @@
+# DB
+地址: localhost:3306
+账号密码:root:12345678
+
+# dockerfile
+
+创建镜像
+```
+docker build -t hht/epub2:v1 .
+```
+
+打包
+```bash
+docker save -o ./epub.tar hht/epub2:v1
+```
+
+启动
+```bash
+docker run -p 3000:3000 -v /f/code/newCashBook/epub_node:/app hht/epub2:v1
+```
+

+ 7 - 7
epub_node/environment/index.js

@@ -1,12 +1,12 @@
 function dbInfo() {
   // 根据需要更新db的数据配置
-  return {
-    host: "localhost",
-    port: 3306,
-    user: "root",
-    password: "12345678",
-    database: "epub_manage",
-  };
+  // return {
+  //   host: "localhost",
+  //   port: 3306,
+  //   user: "root",
+  //   password: "12345678",
+  //   database: "epub_manage",
+  // };
   return {
     host: "192.168.2.101",
     port: 6806,

+ 1 - 0
epub_node/package.json

@@ -24,6 +24,7 @@
   },
   "homepage": "https://github.com/Johnhong9527/newCashBook#readme",
   "dependencies": {
+    "adm-zip": "^0.5.16",
     "body-parser": "^1.20.3",
     "cheerio": "^1.0.0",
     "cors": "^2.8.5",

+ 1 - 1
epub_node/router/epub/index.js

@@ -82,7 +82,7 @@ router.put("/", async function (req, res) {
 
   const file_md5 = sampleFile.md5;
   uploadPath = `./base_files/${file_md5}/`;
-  epubFilePath = uploadPath + sampleFile.name;
+  epubFilePath = uploadPath + sampleFile.md5 + '.epub';
   zipEpubExtract = uploadPath + "epub-extract/";
 
   dirExists(uploadPath);

+ 7 - 0
epub_node/router/epub/style.js

@@ -12,6 +12,13 @@ export async function saveAllCSS(epub, uploadPath) {
     (elm) => elm.indexOf("css") > -1
   );
   console.log(14, getAllCss);
+/*    if (getAllCss.length) {
+      const imgRes = await Promise.allSettled(
+        getAllCss.map((img) => {
+          return fs.readFileSync()
+        })
+      );*/
+  //     // 过滤数据
   //   let imgs = epub.listImage();
   //   if (imgs.length) {
   //     const imgRes = await Promise.allSettled(

+ 1 - 1
epub_node/yarn.lock

@@ -137,7 +137,7 @@ accepts@~1.3.8:
     mime-types "~2.1.34"
     negotiator "0.6.3"
 
-adm-zip@^0.5.10:
+adm-zip@^0.5.10, adm-zip@^0.5.16:
   version "0.5.16"
   resolved "https://registry.npmmirror.com/adm-zip/-/adm-zip-0.5.16.tgz#0b5e4c779f07dedea5805cdccb1147071d94a909"
   integrity sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==