添加读取本地文件功能,支持以 base64 格式返回身份证照片;更新客户信息接口,支持上传婚姻状况及相关信息
This commit is contained in:
@@ -381,6 +381,26 @@ app.whenReady().then(() => {
|
||||
}
|
||||
});
|
||||
|
||||
// 读取本地文件并以 base64 返回(用于渲染进程获取 id card 照片)
|
||||
ipcMain.handle("read-local-file", async (event, filePath) => {
|
||||
try {
|
||||
if (!filePath || typeof filePath !== "string") {
|
||||
return { success: false, error: "invalid filePath" };
|
||||
}
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return { success: false, error: `file not exists: ${filePath}` };
|
||||
}
|
||||
const buffer = fs.readFileSync(filePath);
|
||||
const base64 = buffer.toString("base64");
|
||||
const mime = "image/bmp";
|
||||
|
||||
return { success: true, data: base64, mime };
|
||||
} catch (err) {
|
||||
log.error("read-local-file error:", err);
|
||||
return { success: false, error: err.message || String(err) };
|
||||
}
|
||||
});
|
||||
|
||||
app.on("activate", () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
|
||||
Reference in New Issue
Block a user