forked from akai/readest
This commit is contained in:
@@ -138,7 +138,7 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i
|
||||
|
||||
const handleCloseBooks = throttle(async () => {
|
||||
const settings = useSettingsStore.getState().settings;
|
||||
await Promise.all(bookKeys.map((key) => saveConfigAndCloseBook(key)));
|
||||
await Promise.all(bookKeys.map(async (key) => await saveConfigAndCloseBook(key)));
|
||||
await saveSettings(envConfig, settings);
|
||||
}, 200);
|
||||
|
||||
@@ -166,6 +166,7 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i
|
||||
const openWithFiles = (await parseOpenWithFiles()) || [];
|
||||
if (appService?.hasWindow) {
|
||||
if (openWithFiles.length > 0) {
|
||||
tauriHandleOnCloseWindow(handleCloseBooks);
|
||||
return await tauriHandleClose();
|
||||
}
|
||||
const currentWindow = getCurrentWindow();
|
||||
|
||||
@@ -49,7 +49,8 @@ export const tauriHandleClose = async () => {
|
||||
|
||||
export const tauriHandleOnCloseWindow = async (callback: () => void) => {
|
||||
const currentWindow = getCurrentWindow();
|
||||
return currentWindow.listen(TauriEvent.WINDOW_CLOSE_REQUESTED, async () => {
|
||||
return await currentWindow.onCloseRequested(async (event) => {
|
||||
event.preventDefault();
|
||||
await callback();
|
||||
if (currentWindow.label.startsWith('reader')) {
|
||||
await emitTo('main', 'close-reader-window', { label: currentWindow.label });
|
||||
|
||||
Reference in New Issue
Block a user