|
@@ -40,7 +40,7 @@ const params = reactive({
|
|
file: null,
|
|
file: null,
|
|
paperCount: void 0,
|
|
paperCount: void 0,
|
|
singlePage: false,
|
|
singlePage: false,
|
|
- // dpi: 150,
|
|
|
|
|
|
+ dpi: 150,
|
|
});
|
|
});
|
|
const cardJson = ref(null);
|
|
const cardJson = ref(null);
|
|
const fields = computed(() => {
|
|
const fields = computed(() => {
|
|
@@ -80,27 +80,27 @@ const fields = computed(() => {
|
|
],
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- // params.file && isJson.value && cardJson.value && !cardJson.value.dpi
|
|
|
|
- // ? {
|
|
|
|
- // prop: "dpi",
|
|
|
|
- // type: "radio",
|
|
|
|
- // label: "DPI",
|
|
|
|
- // colSpan: 24,
|
|
|
|
- // attrs: {
|
|
|
|
- // options: [
|
|
|
|
- // { value: 150, label: "150" },
|
|
|
|
- // { value: 200, label: "200" },
|
|
|
|
- // ],
|
|
|
|
- // disabled: cardJson.value?.dpi,
|
|
|
|
- // },
|
|
|
|
- // }
|
|
|
|
- // : null,
|
|
|
|
|
|
+ params.file && isJson.value && cardJson.value && !cardJson.value.dpi
|
|
|
|
+ ? {
|
|
|
|
+ prop: "dpi",
|
|
|
|
+ type: "radio",
|
|
|
|
+ label: "DPI",
|
|
|
|
+ colSpan: 24,
|
|
|
|
+ attrs: {
|
|
|
|
+ options: [
|
|
|
|
+ { value: 150, label: "150" },
|
|
|
|
+ { value: 200, label: "200" },
|
|
|
|
+ ],
|
|
|
|
+ disabled: cardJson.value?.dpi,
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ : null,
|
|
];
|
|
];
|
|
});
|
|
});
|
|
const isJson = ref(true);
|
|
const isJson = ref(true);
|
|
const cardSizePass = ref(true);
|
|
const cardSizePass = ref(true);
|
|
|
|
|
|
-const isJsonString = (str) => {
|
|
|
|
|
|
+const isJsonString = (str: string) => {
|
|
try {
|
|
try {
|
|
const toObj = JSON.parse(str);
|
|
const toObj = JSON.parse(str);
|
|
if (toObj && typeof toObj === "object") {
|
|
if (toObj && typeof toObj === "object") {
|
|
@@ -148,18 +148,29 @@ const rules = {
|
|
},
|
|
},
|
|
],
|
|
],
|
|
};
|
|
};
|
|
|
|
+let pageSizeStr = "";
|
|
const compareSize = (content: any, img: any) => {
|
|
const compareSize = (content: any, img: any) => {
|
|
|
|
+ let target = content[pageSizeStr];
|
|
console.log(content, img.width, img.height);
|
|
console.log(content, img.width, img.height);
|
|
|
|
+ let w = img.width / params.dpi / 0.0394;
|
|
|
|
+ let h = img.height / params.dpi / 0.0394;
|
|
|
|
+ if (Math.abs(w - target.width) > 10 || Math.abs(h - target.height) > 10) {
|
|
|
|
+ cardSizePass.value = false;
|
|
|
|
+ } else {
|
|
|
|
+ cardSizePass.value = true;
|
|
|
|
+ }
|
|
};
|
|
};
|
|
-const validateCardSize = async (json) => {
|
|
|
|
|
|
+const validateCardSize = async (json: any) => {
|
|
if (!json.pages.length) {
|
|
if (!json.pages.length) {
|
|
cardSizePass.value = false;
|
|
cardSizePass.value = false;
|
|
|
|
+ window.$message.error("卡格式文件里的pages为空");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
window.electronApi?.getPageSizeIni((content: any) => {
|
|
window.electronApi?.getPageSizeIni((content: any) => {
|
|
console.log(content);
|
|
console.log(content);
|
|
const img = new Image();
|
|
const img = new Image();
|
|
img.onload = () => {
|
|
img.onload = () => {
|
|
|
|
+ pageSizeStr = json.pages[0].exchange["page_size"];
|
|
compareSize(content, img);
|
|
compareSize(content, img);
|
|
};
|
|
};
|
|
img.onerror = function () {
|
|
img.onerror = function () {
|