fix: fixed crash on app start when there is no main window but a reader window running, closes #3897 (#3902)

This commit is contained in:
Huang Xin 2026-04-20 22:05:01 +08:00 committed by GitHub
parent 293cc545db
commit ff94dc76c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View file

@ -197,10 +197,9 @@ pub fn run() {
let builder = builder.plugin(
tauri_plugin_single_instance::Builder::new()
.callback(move |app, argv, cwd| {
let _ = app
.get_webview_window("main")
.expect("no main window")
.set_focus();
if let Some(window) = app.get_webview_window("main") {
let _ = window.set_focus();
}
let files = get_files_from_argv(argv.clone());
if !files.is_empty() {
allow_file_in_scopes(app, files.clone());
@ -377,7 +376,9 @@ pub fn run() {
true
});
#[cfg(desktop)]
#[cfg(target_os = "macos")]
let win_builder = win_builder.inner_size(1280.0, 800.0).resizable(true);
#[cfg(all(not(target_os = "macos"), desktop))]
let win_builder = win_builder.inner_size(800.0, 600.0).resizable(true);
#[cfg(target_os = "macos")]

View file

@ -263,6 +263,11 @@ const SettingsMenu: React.FC<SettingsMenuProps> = ({ onPullLibrary, setIsDropdow
setAlwaysInForeground(requestAlwaysInForeground);
};
const handleSyncLibrary = () => {
onPullLibrary(true, true);
setIsDropdownOpen?.(false);
};
const avatarUrl = user?.user_metadata?.['picture'] || user?.user_metadata?.['avatar_url'];
const userFullName = user?.user_metadata?.['full_name'];
const userDisplayName = userFullName ? userFullName.split(' ')[0] : null;
@ -329,7 +334,7 @@ const SettingsMenu: React.FC<SettingsMenuProps> = ({ onPullLibrary, setIsDropdow
Icon={user ? MdSync : MdSyncProblem}
labelClass='ps-2 pe-1 !mx-0'
iconClassName={user && isSyncing ? 'animate-reverse-spin' : ''}
onClick={onPullLibrary.bind(null, true, true)}
onClick={handleSyncLibrary}
/>
<button
onClick={handleUserProfile}