|
@@ -44,7 +44,7 @@ import { CaretLeftOutlined, CaretRightOutlined } from "@ant-design/icons-vue";
|
|
|
import { DataCheckListFilter, DataCheckListItem } from "@/ap/types/dataCheck";
|
|
|
import { allCheckList, fetchAndParseData } from "./api";
|
|
|
import { StudentPage } from "./types";
|
|
|
-import { useDataCheckStore } from "@/store";
|
|
|
+import { useDataCheckStore, useAppStore } from "@/store";
|
|
|
|
|
|
import SimplePagination from "@/components/SimplePagination/index.vue";
|
|
|
import ScanImage from "./ScanImage/index.vue";
|
|
@@ -55,6 +55,7 @@ defineOptions({
|
|
|
});
|
|
|
|
|
|
const dataCheckStore = useDataCheckStore();
|
|
|
+const appStore = useAppStore();
|
|
|
dataCheckStore.resetInfo();
|
|
|
|
|
|
let searchModel = {} as DataCheckListFilter;
|
|
@@ -174,9 +175,38 @@ async function onNextStudent() {
|
|
|
onSelectStudent(dataCheckStore.curStudentIndex + 1);
|
|
|
}
|
|
|
|
|
|
+function getImgDpi(imgWidth: number): number {
|
|
|
+ const dpi = (25.4 * imgWidth) / 183;
|
|
|
+
|
|
|
+ if (Math.abs(dpi - 100) < 5) {
|
|
|
+ return 100;
|
|
|
+ }
|
|
|
+ if (Math.abs(dpi - 150) < 5) {
|
|
|
+ return 150;
|
|
|
+ }
|
|
|
+ return 150;
|
|
|
+}
|
|
|
+
|
|
|
+function getImgSize(url: string) {
|
|
|
+ return new Promise<{ width: number; height: number }>((resolve) => {
|
|
|
+ const img = new Image();
|
|
|
+ img.src = url;
|
|
|
+ console.log(url);
|
|
|
+
|
|
|
+ img.onload = () => {
|
|
|
+ resolve({
|
|
|
+ width: img.width,
|
|
|
+ height: img.height,
|
|
|
+ });
|
|
|
+ };
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
// page
|
|
|
async function selectPage(index: number) {
|
|
|
const recogData = await fetchAndParseData(dataList.value[index].recogUri);
|
|
|
+ const size = await getImgSize(dataList.value[index].sheetUri);
|
|
|
+ dataList.value[index].recogDpi = getImgDpi(size.width);
|
|
|
dataList.value[index].recogData = recogData;
|
|
|
dataCheckStore.setInfo({
|
|
|
curPage: dataList.value[index],
|
|
@@ -259,7 +289,13 @@ function shortcutHandle(e: KeyboardEvent) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
+onMounted(async () => {
|
|
|
+ const appConfig = await window.electronApi.getAppIni();
|
|
|
+ if (!appConfig.base.serverUrl) {
|
|
|
+ message.error("请先设置服务器地址");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ appStore.setState({ serverUrl: appConfig.base.serverUrl });
|
|
|
registShortcut();
|
|
|
onSearch();
|
|
|
});
|