Skip to content

Commit 9e92a76

Browse files
committed
refactor: update IPC event name for Google Picker and enhance handling of picker actions
refactor: improve success message for added books in ImportLocal component
1 parent 9cde3ec commit 9e92a76

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,13 +616,14 @@ const createMainWin = () => {
616616
googlePickerView.webContents.loadURL(config.url)
617617
}
618618
});
619-
ipcMain.on('finish-picker', (event, config) => {
619+
ipcMain.on('picker-action', (event, config) => {
620620
console.log("Picker finished with data:", config);
621621
//将数据传递给主窗口
622-
if (mainWin && !mainWin.isDestroyed()) {
622+
623+
if (mainWin && !mainWin.isDestroyed() && config.action === 'picked') {
623624
mainWin.webContents.send('picker-finished', config);
624625
}
625-
if (googlePickerView) {
626+
if (googlePickerView && (config.action === 'cancel' || config.action === 'picked')) {
626627
mainWin.contentView.removeChildView(googlePickerView);
627628
googlePickerView = null;
628629
}

src/components/dialogs/importDialog/component.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ class ImportDialog extends React.Component<
310310
// 处理Google文件导入
311311
handleImportGoogleFile = async (googleFile: any) => {
312312
try {
313-
const tokenConfig = await getCloudConfig("google");
314-
315313
// 检查文件格式
316314
const fileExtension =
317315
"." + googleFile.name.split(".").pop()?.toLowerCase();
@@ -335,10 +333,6 @@ class ImportDialog extends React.Component<
335333

336334
toast.dismiss("google-download-" + googleFile.id);
337335
await this.props.importBookFunc(file);
338-
339-
toast.success(
340-
this.props.t("Addition successful") + ": " + googleFile.name
341-
);
342336
} catch (error) {
343337
console.error("Error importing Google file:", error);
344338
toast.error(this.props.t("Failed to import") + ": " + googleFile.name);

src/components/importLocal/component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class ImportLocal extends React.Component<ImportLocalProps, ImportLocalState> {
137137
"shelfList"
138138
);
139139
}
140-
toast.success(this.props.t("Addition successful"));
140+
toast.success(this.props.t("Addition successful") + ": " + book.name);
141141
setTimeout(() => {
142142
this.state.isOpenFile && this.handleJump(book);
143143
if (

0 commit comments

Comments
 (0)