panhui 6 年之前
父節點
當前提交
353e95e951
共有 6 個文件被更改,包括 65 次插入30 次删除
  1. 10 1
      npm-shrinkwrap.json
  2. 1 1
      package.json
  3. 1 4
      src/main.js
  4. 0 1
      src/pages/Booking/OrderBookingStep2.vue
  5. 52 11
      src/service/FileUploadDownloadService.js
  6. 1 12
      vue.config.js

+ 10 - 1
npm-shrinkwrap.json

@@ -3696,7 +3696,16 @@
       "integrity": "sha1-Ecz23uxXZqw3l0TZAcEsuklRS+Y=",
       "dependencies": {
         "utility": {
-          "version": "1.16.1"
+          "version": "1.16.1",
+          "resolved": "https://registry.npm.taobao.org/utility/download/utility-1.16.1.tgz",
+          "integrity": "sha1-OD9ctjAEQUdnNxtJweSMoBniaw8=",
+          "requires": {
+            "copy-to": "^2.0.1",
+            "escape-html": "^1.0.3",
+            "mkdirp": "^0.5.1",
+            "mz": "^2.7.0",
+            "unescape": "^1.0.1"
+          }
         }
       }
     },

+ 1 - 1
package.json

@@ -57,4 +57,4 @@
         "vue-cli-plugin-electron-builder": "^1.3.5",
         "vue-template-compiler": "^2.6.10"
     }
-}
+}

+ 1 - 4
src/main.js

@@ -33,7 +33,7 @@ Vue.mixin(main);
 
 Vue.prototype.$ImgType = [''];
 
-// const baseUrl = `http://49.4.67.181:8206`;
+const baseUrl = `https://www.tutuxiang.com`;
 // const baseUrl = `http://localhost:8080`;
 const baseUrl = 'https://www.tutuxiang.com';
 Vue.prototype.$baseUrl = baseUrl;
@@ -351,9 +351,6 @@ setInterval(() => {
     }
 }, 500);
 
-setTimeout(() => {
-    FileUploadDownloadService.deleteUploadedFile();
-}, 0 * 1000);
 
 setInterval(() => {
     if (store.state.userInfo && store.state.userInfo.id) {

+ 0 - 1
src/pages/Booking/OrderBookingStep2.vue

@@ -377,7 +377,6 @@ export default {
             this.pathLoading = true;
             this.oneOrder = false;
             var children = this.readDir(pathInfo, true);
-
             if (!children || children.length == 0) {
                 this.pathLoading = false;
                 return;

+ 52 - 11
src/service/FileUploadDownloadService.js

@@ -69,7 +69,10 @@ let downloadQueue = queue(3, function(job, done) {
 async function checkFalse() {
     //下载,下载队列为空,把所有状态为downloading的状态改为ERROR
     let downloadList = (await db.Download.findAll({
-        where: { status: DownloadStatus.DOWNLOADING, status: DownloadStatus.WAITING },
+        where: {
+            status: DownloadStatus.DOWNLOADING,
+            status: DownloadStatus.WAITING,
+        },
     })).map(i => i.get());
     downloadList.forEach(async i => {
         await db.Download.update(
@@ -85,9 +88,9 @@ async function checkFalse() {
     });
 
     //上传
-    let fileList = (await db.File.findAll({ where: { status: UploadStatus.UPLOADING } })).map(i =>
-        i.get(),
-    );
+    let fileList = (await db.File.findAll({
+        where: { status: UploadStatus.UPLOADING },
+    })).map(i => i.get());
     fileList.forEach(async i => {
         await db.File.update(
             {
@@ -116,6 +119,10 @@ const init = async () => {
     resume();
 
     initiated = true;
+
+    setTimeout(() => {
+        deleteUploadedFile();
+    }, 0 * 1000);
 };
 
 const PromiseQueue = arr => {
@@ -412,7 +419,9 @@ const uploadOrder = async (topDir, prefixes, userId, clientOrderId) => {
         let archiveFile = await archive(topDir, outPath);
         let info = fs.statSync(archiveFile);
         await sequelize.query(`UPDATE SubOrders 
-            SET size = ( SELECT SUM( size ) FROM Files WHERE subOrderId = ${subOrder.id} ) 
+            SET size = ( SELECT SUM( size ) FROM Files WHERE subOrderId = ${
+                subOrder.id
+            } ) 
             WHERE id = ${subOrder.id}`);
         await db.File.update(
             {
@@ -449,8 +458,17 @@ const uploadOrder = async (topDir, prefixes, userId, clientOrderId) => {
                         progress: 0,
                         status: UploadStatus.PREPARING,
                     })).get();
-                    await readDir(path.resolve(topDir, child), orderId, subOrder.id, child, prefix);
-                    let archiveFile = await archive(path.resolve(topDir, child), outPath);
+                    await readDir(
+                        path.resolve(topDir, child),
+                        orderId,
+                        subOrder.id,
+                        child,
+                        prefix,
+                    );
+                    let archiveFile = await archive(
+                        path.resolve(topDir, child),
+                        outPath,
+                    );
                     let info = fs.statSync(archiveFile);
                     await db.File.update(
                         {
@@ -483,12 +501,27 @@ const uploadOrder = async (topDir, prefixes, userId, clientOrderId) => {
                     );
                 } else {
                     let filepath = path.resolve(dir, child);
-                    const buffer = readChunk.sync(filepath, 0, fileType.minimumBytes);
+                    const buffer = readChunk.sync(
+                        filepath,
+                        0,
+                        fileType.minimumBytes,
+                    );
                     let type = fileType(buffer);
                     let src = filepath;
                     let dst = currRelative;
                     if (type && type.mime.startsWith('image')) {
-                        src = await ImageUtils.makeThumbnail(filepath);
+                        if (/tif|bmp|gif/i.test(type.ext)) {
+                            let tmpFile = path.resolve(
+                                app.getPath('userData'),
+                                'tmp',
+                                uuidv1() + '.jpg',
+                            );
+                            fs.copyFileSync(filepath, tmpFile);
+                            src = tmpFile;
+                        } else {
+                            src = await ImageUtils.makeThumbnail(filepath);
+                        }
+
                         // dst = orderId + "/" + relative + '/' + transferFilename(path.basename(currRelative))
                         dst =
                             prefix +
@@ -527,7 +560,9 @@ const archive = async (dir, outPath) => {
         // 'close' event is fired only when a file descriptor is involved
         output.on('close', function() {
             console.log(archive.pointer() + ' total bytes');
-            console.log('archiver has been finalized and the output file descriptor has closed.');
+            console.log(
+                'archiver has been finalized and the output file descriptor has closed.',
+            );
             resolve(outPath);
         });
 
@@ -645,7 +680,13 @@ async function getFilePath(pathName, i) {
     return _path;
 }
 
-const downloadFile = async (objectName, orderName, userId, quantity, userOrderId) => {
+const downloadFile = async (
+    objectName,
+    orderName,
+    userId,
+    quantity,
+    userOrderId,
+) => {
     let pathName = await getFilePath(userOrderId + '_' + orderName, 0);
     let download = (await db.Download.create({
         dst: objectName,

+ 1 - 12
vue.config.js

@@ -22,20 +22,9 @@ module.exports = {
             nodeModulesPath: ['./node_modules'],
             builderOptions: {
                 productName: '图途象',
-                win: {
-                    target: [
-                        {
-                            target: 'nsis',
-                            arch: [
-                                'x64',
-                                'ia32',
-                            ],
-                        },
-                    ],
-                },
                 nsis: {
                     oneClick: false,
-                    perMachine: false,
+                    perMachine: true,
                     allowToChangeInstallationDirectory: true,
                 },
             },