This commit is contained in:
parent
34a487b2d0
commit
872180279b
3 changed files with 18 additions and 9 deletions
|
@ -288,14 +288,17 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%pa
|
|||
pdfOptions: ipcData.pdfOptions,
|
||||
webContentsId: ipcData.webContentsId
|
||||
});
|
||||
const savePath = ipcData.filePaths[0];
|
||||
let pdfFilePath = path.join(savePath, replaceLocalPath(ipcData.rootTitle) + ".pdf");
|
||||
const responseUnique = await fetchSyncPost("/api/file/getUniqueFilename", {path: pdfFilePath});
|
||||
pdfFilePath = responseUnique.data.path;
|
||||
fetchPost("/api/export/exportHTML", {
|
||||
id: ipcData.rootId,
|
||||
pdf: true,
|
||||
removeAssets: ipcData.removeAssets,
|
||||
merge: ipcData.mergeSubdocs,
|
||||
savePath: ipcData.filePaths[0]
|
||||
savePath,
|
||||
}, () => {
|
||||
const pdfFilePath = path.join(ipcData.filePaths[0], replaceLocalPath(ipcData.rootTitle) + ".pdf");
|
||||
fs.writeFileSync(pdfFilePath, pdfData);
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, {cmd: "destroy", webContentsId: ipcData.webContentsId});
|
||||
fetchPost("/api/export/processPDF", {
|
||||
|
@ -326,7 +329,7 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%pa
|
|||
});
|
||||
});
|
||||
};
|
||||
removePromise(path.join(ipcData.filePaths[0], "assets"));
|
||||
removePromise(path.join(savePath, "assets"));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,6 +13,7 @@ import {bindRollupData, getRollupHTML} from "./rollup";
|
|||
import {Constants} from "../../../constants";
|
||||
import * as dayjs from "dayjs";
|
||||
import {setPosition} from "../../../util/setPosition";
|
||||
import {duplicateNameAddOne} from "../../../util/functions";
|
||||
|
||||
export const duplicateCol = (options: {
|
||||
protyle: IProtyle,
|
||||
|
@ -29,12 +30,7 @@ export const duplicateCol = (options: {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
const nameMatch = newColData.name.match(/^(.*) \((\d+)\)$/);
|
||||
if (nameMatch) {
|
||||
newColData.name = `${nameMatch[1]} (${parseInt(nameMatch[2]) + 1})`;
|
||||
} else {
|
||||
newColData.name = `${newColData.name} (1)`;
|
||||
}
|
||||
newColData.name = duplicateNameAddOne(newColData.name);
|
||||
newColData.id = Lute.NewNodeID();
|
||||
const newUpdated = dayjs().format("YYYYMMDDHHmmss");
|
||||
const blockId = options.blockElement.getAttribute("data-node-id");
|
||||
|
|
|
@ -90,3 +90,13 @@ export const objEquals = (a: any, b: any): boolean => {
|
|||
if (keys.length !== Object.keys(b).length) return false;
|
||||
return keys.every(k => objEquals(a[k], b[k]));
|
||||
};
|
||||
|
||||
export const duplicateNameAddOne = (name:string) => {
|
||||
const nameMatch = name.match(/^(.*) \((\d+)\)$/);
|
||||
if (nameMatch) {
|
||||
name = `${nameMatch[1]} (${parseInt(nameMatch[2]) + 1})`;
|
||||
} else {
|
||||
name = `${name} (1)`;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue