Jelajahi Sumber

feat: 调试准备

zhangjie 1 tahun lalu
induk
melakukan
f3cc84e96e

+ 1 - 1
electron/db/modelApi/trackTask.ts

@@ -14,7 +14,7 @@ import {
 
 export async function getUnfinishTrackTask(schoolId: string) {
   const task = await TrackTask.findOne({
-    where: { status: { [Op.ne]: TRACK_TASK_STATUS.FINISH }, schoolId },
+    where: { status: TRACK_TASK_STATUS.READY, schoolId },
   }).catch((err) => {
     console.dir(err);
   });

+ 4 - 4
electron/main/logger.ts

@@ -1,9 +1,9 @@
-import logger from 'electron-log/main';
+import log from 'electron-log/main';
 import path from 'node:path';
 import { getRootDir } from '../preload/utils';
 
-logger.transports.console.level = false;
-logger.transports.file.resolvePathFn = () =>
+log.transports.console.level = false;
+log.transports.file.resolvePathFn = () =>
   path.join(getRootDir(), 'logs/main.log');
 
-export default logger;
+export default log;

+ 9 - 1
electron/preload/api.ts

@@ -4,7 +4,7 @@ import sizeOf from 'image-size';
 import path from 'node:path';
 import fs from 'node:fs';
 import PDFDocument from 'pdfkit';
-import logger from 'electron-log/renderer';
+import log from 'electron-log/renderer';
 
 import { getImagicPath, getTempPath } from './utils';
 
@@ -147,6 +147,14 @@ async function imagesToPdf(
   });
 }
 
+function logger(content: string, type?: 'info' | 'error') {
+  if (type === 'error') {
+    log.error(content);
+  } else {
+    log.info(content);
+  }
+}
+
 const commonApi = {
   cropImage,
   drawTrack,

+ 3 - 2
package.json

@@ -53,11 +53,12 @@
     "mitt": "^3.0.0",
     "nprogress": "^0.2.0",
     "pdfkit": "^0.15.0",
+    "pg-hstore": "^2.3.4",
     "pinia": "^2.0.23",
     "pinia-plugin-persistedstate": "^3.2.1",
     "query-string": "^8.0.3",
     "sequelize": "^6.37.3",
-    "sqlite3": "^5.1.6",
+    "sqlite3": "5.1.6",
     "vue": "^3.2.40",
     "vue-ls": "^4.2.0",
     "vue-router": "^4.0.14"
@@ -106,7 +107,7 @@
     "rollup-plugin-visualizer": "^5.8.2",
     "typescript": "^4.9.5",
     "unplugin-vue-components": "^0.24.1",
-    "vite": "^4.3.9",
+    "vite": "~4.3.9",
     "vite-plugin-compression": "^0.5.1",
     "vite-plugin-eslint": "^1.8.1",
     "vite-plugin-imagemin": "^0.6.1",

File diff ditekan karena terlalu besar
+ 230 - 237
pnpm-lock.yaml


+ 0 - 1
src/components/select-course/index.vue

@@ -51,7 +51,6 @@
       return { ...item, value: item.id, label: `${item.name}(${item.code})` };
     });
   };
-  search();
 
   const onChange = () => {
     const selectedData = props.multiple

+ 10 - 1
src/components/select-exam/index.vue

@@ -47,7 +47,6 @@
     });
     if (props.selectDefault) emitDefaultOption();
   };
-  search();
 
   function emitDefaultOption() {
     const defaultData = optionList.value[0];
@@ -76,4 +75,14 @@
       immediate: true,
     }
   );
+
+  watch(
+    () => props.semesterId,
+    (val, oldval) => {
+      if (val !== oldval) search();
+    },
+    {
+      immediate: true,
+    }
+  );
 </script>

+ 10 - 10
src/views/base/track-export/index.vue

@@ -6,6 +6,7 @@
         :clearable="false"
         select-default
         placeholder="请选择"
+        prefix
         @change="semesterChange"
       />
       <SelectExam
@@ -14,6 +15,7 @@
         :clearable="false"
         select-default
         placeholder="请选择"
+        prefix
         @default-selected="toPage(1)"
         @change="examChange"
       />
@@ -22,6 +24,7 @@
         :semester-id="searchModel.semesterId"
         :exam-id="searchModel.examId"
         placeholder="请选择"
+        prefix
         @change="courseChange"
       />
       <a-button type="primary" @click="toPage(1)">查询</a-button>
@@ -47,18 +50,14 @@
       :columns="columns"
       :data="dataList"
       :pagination="pagination"
-      :scroll="{ x: 1200 }"
+      :scroll="{ x: 600 }"
       :bordered="false"
     >
       <template #courseCode="{ record }">
         {{ courseNameCodeFilter(record) }}
       </template>
       <template #action="{ record }">
-        <a-button
-          type="text"
-          class="btn-primary"
-          disabled
-          @click="toDownload(record)"
+        <a-button type="text" class="btn-primary" @click="toDownload(record)"
           >下载</a-button
         >
       </template>
@@ -116,16 +115,17 @@
     },
     {
       title: '试卷编号',
-      slotName: 'paperNumber',
+      dataIndex: 'paperNumber',
     },
     {
       title: '参考人数',
-      slotName: 'studentCount',
+      dataIndex: 'studentCount',
+      width: 100,
     },
     {
       title: '操作',
       slotName: 'action',
-      width: 220,
+      width: 80,
       fixed: 'right',
       cellClass: 'action-column',
     },
@@ -254,7 +254,7 @@
 
     await updateTrackTaskReady();
     detailBuildStop.value = true;
-    taskProgressRef.value?.open();
+    // taskProgressRef.value?.open();
   }
 
   // 单个课程下载

+ 6 - 3
src/views/base/track-export/modifySet.vue

@@ -1,7 +1,7 @@
 <template>
   <a-modal
     v-model:visible="visible"
-    :width="500"
+    :width="560"
     title-align="start"
     top="10vh"
     :align-center="false"
@@ -25,16 +25,19 @@
           </a-checkbox>
         </a-checkbox-group>
       </a-form-item>
-      <a-form-item field="outputDir" label="保存目录">
+      <a-form-item field="outputDir" label="保存目录" :content-flex="false">
         <a-input-search
           v-model.trim="formData.outputDir"
-          :style="{ width: '400px' }"
+          :style="{ width: '420px' }"
           readonly
           search-button
           button-text="浏览"
           @search="toSelectDir"
         >
         </a-input-search>
+        <a-checkbox v-model="formData.outputDirIsDefault"
+          >设为默认下载路径</a-checkbox
+        >
       </a-form-item>
     </a-form>
 

+ 2 - 2
src/views/base/track-export/taskDetailBuildProgess.vue

@@ -1,7 +1,7 @@
 <template>
   <a-modal
     v-model:visible="visible"
-    :width="500"
+    :width="320"
     :mask-closable="false"
     :esc-to-close="false"
     :closable="false"
@@ -9,7 +9,7 @@
     hide-title
     @before-open="modalBeforeOpen"
   >
-    <div class="part-box">
+    <div style="text-align: center">
       <a-spin :tip="taskTips" />
     </div>
   </a-modal>

+ 10 - 1
src/views/base/track-export/taskProgress.vue

@@ -54,7 +54,7 @@
   const PROGRESS_KEY = 'progress';
 
   const taskInfo = ref<DescData[]>([]);
-  const task = ref<TrackTaskData>();
+  const task = ref<TrackTaskData>({} as TrackTaskData);
   const total = ref(0);
   const finishCount = ref(0);
   const progressNum = ref(0);
@@ -69,6 +69,15 @@
       ? 0
       : Math.floor((10000 * finishCount.value) / total.value) / 10000;
 
+    if (finishCount.value === total.value) {
+      await window.db.updateTrackTaskStatus({
+        id: task.value.id,
+        status: 'FINISH',
+      });
+      window.electron.stopWinProcess();
+      return;
+    }
+
     addSetTimeout(PROGRESS_KEY, updateProgress, 1 * 1000);
   }
 

+ 1 - 5
src/views/base/track-export/useDraw.ts

@@ -109,11 +109,7 @@ export default function useDraw(winId: number) {
   const trackConfig = ref({} as TrackConfigType);
 
   function addLog(content: string, type?: 'info' | 'error') {
-    if (type === 'error') {
-      window.api.logger.error(`win:${curWinId} ${content}`);
-    } else {
-      window.api.logger.info(`win:${curWinId} ${content}`);
-    }
+    window.api.logger(`win:${curWinId} ${content}`, type);
   }
 
   async function getTrackTask(schoolId: string) {

+ 1 - 1
src/views/base/track-export/useTask.ts

@@ -26,7 +26,7 @@ export default function useTask() {
   async function updateTrackTaskReady() {
     await window.db.updateTrackTaskStatus({
       id: trackTaskId.value,
-      status: 'FINISH',
+      status: 'READY',
     });
   }
 

+ 1 - 1
src/views/login/login/index.vue

@@ -84,7 +84,7 @@
     schoolCode: '',
     type: 'ACCOUNT',
     loginName: 'admin',
-    password: '12345678',
+    password: 'autumn123',
   });
 
   const rules: FormRules<keyof LoginData> = {

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini