|
@@ -32,7 +32,7 @@ async function getImageDim(
|
|
|
img.src = URL.createObjectURL(blob);
|
|
|
img.onload = () => {
|
|
|
URL.revokeObjectURL(img.src);
|
|
|
- console.log(img.width);
|
|
|
+ // console.log(img.width);
|
|
|
res([img.width, img.height]);
|
|
|
};
|
|
|
});
|
|
@@ -80,6 +80,19 @@ onMounted(async () => {
|
|
|
for (const student of students) {
|
|
|
for (const sheetUrl of student.sheetUrls) {
|
|
|
try {
|
|
|
+ const index = student.sheetUrls.indexOf(sheetUrl);
|
|
|
+ student.index = index + 1;
|
|
|
+ student.examId = store.env.examId;
|
|
|
+ const filePath = window.electron.join(
|
|
|
+ config.dir,
|
|
|
+ mustache.render(config.template, student)
|
|
|
+ );
|
|
|
+ if (window.electron.existsSync(filePath) && config.append) {
|
|
|
+ console.log(filePath + " already exists");
|
|
|
+ finishedCount.value += 1;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
const imageRes = await httpApp.get(sheetUrl, {
|
|
|
responseType: "blob",
|
|
|
});
|
|
@@ -89,16 +102,13 @@ onMounted(async () => {
|
|
|
// console.log(imageRes.data);
|
|
|
// console.log(await imageRes.data.arrayBuffer());
|
|
|
// console.log(new Uint8Array(await imageRes.data.arrayBuffer()));
|
|
|
- const index = student.sheetUrls.indexOf(sheetUrl);
|
|
|
- student.index = index + 1;
|
|
|
- student.examId = store.env.examId;
|
|
|
- // console.log(mustache.render(config.template, student));
|
|
|
+
|
|
|
await window.electron.addWatermark(
|
|
|
JSON.parse(JSON.stringify(store)),
|
|
|
await imageRes.data.arrayBuffer(),
|
|
|
width,
|
|
|
height,
|
|
|
- [config.dir, mustache.render(config.template, student)],
|
|
|
+ filePath,
|
|
|
student,
|
|
|
index + 1,
|
|
|
config.trackMode
|
|
@@ -127,21 +137,29 @@ onMounted(async () => {
|
|
|
p.examId = store.env.examId;
|
|
|
for (let i = 0; i < p.urls.length; i++) {
|
|
|
try {
|
|
|
+ const index = i + 1;
|
|
|
+ p.index = index;
|
|
|
+ const filePath = window.electron.join(
|
|
|
+ config.dir,
|
|
|
+ mustache.render(config.template, p)
|
|
|
+ );
|
|
|
+ if (window.electron.existsSync(filePath) && config.append) {
|
|
|
+ console.log(filePath + " already exists");
|
|
|
+ finishedCount.value += 1;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
const imageRes = await httpApp.get(p.urls[i], {
|
|
|
responseType: "blob",
|
|
|
});
|
|
|
|
|
|
const [width, height] = await getImageDim(imageRes.data);
|
|
|
-
|
|
|
- const index = i + 1;
|
|
|
- p.index = index;
|
|
|
- // console.log(mustache.render(config.template, student));
|
|
|
await window.electron.addWatermark(
|
|
|
JSON.parse(JSON.stringify(store)),
|
|
|
await imageRes.data.arrayBuffer(),
|
|
|
width,
|
|
|
height,
|
|
|
- [config.dir, mustache.render(config.template, p)],
|
|
|
+ filePath,
|
|
|
p,
|
|
|
index,
|
|
|
config.trackMode
|