From 413567d909c4da3f302b446821b7135fcc5e38c2 Mon Sep 17 00:00:00 2001 From: awa Liny <163953777+awaLiny2333@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:56:29 +0800 Subject: [PATCH] improve: System back now closes tabs if cannot go any further back. This requires optimization when in Paralleow mode to fit general using habits! --- home/src/main/ets/blocks/meowTabs.ets | 2 ++ home/src/main/ets/pages/Index.ets | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/home/src/main/ets/blocks/meowTabs.ets b/home/src/main/ets/blocks/meowTabs.ets index 83f0e34..3c1e583 100644 --- a/home/src/main/ets/blocks/meowTabs.ets +++ b/home/src/main/ets/blocks/meowTabs.ets @@ -366,6 +366,7 @@ struct meowTabs { // Switch this.current_main_tab_index = this.bunch_of_tabs.switchToTab(target); + console.log('[Meow][meowTabs] Switch to tab ' + this.current_main_tab_index.toString()) if (this.recover_tabs_finished) { // Update history this.update_backward_forward_access() @@ -582,6 +583,7 @@ struct meowTabs { } on_targeted_close_tab() { + console.log('close' + this.close_tab_gateway.toString()) if (this.close_tab_gateway >= 0) { this.close_tab(this.close_tab_gateway); this.close_tab_gateway = -1; diff --git a/home/src/main/ets/pages/Index.ets b/home/src/main/ets/pages/Index.ets index 067dcb5..db6ce35 100644 --- a/home/src/main/ets/pages/Index.ets +++ b/home/src/main/ets/pages/Index.ets @@ -51,11 +51,12 @@ struct Index { @StorageLink('current_loading_progress') current_loading_progress: number = 0 @StorageLink('tab_is_loading') tab_is_loading: boolean[] = [true] @StorageLink('current_is_loading') current_is_loading: boolean = true - // Web control statuses + // Web control @StorageLink('current_main_tab_index') current_main_tab_index: number = 0; @StorageLink('current_sub_tab_index') current_sub_tab_index: number = -1; @StorageLink('current_accessForward') current_accessForward: boolean = false; @StorageLink('current_accessBackward') current_accessBackward: boolean = false; + @StorageLink('universal_close_tab_gateway') uni_close_tab_gateway: number = -1; // Settings @State @Watch('on_title_bar_position_change') settings_title_bar_position: string = ""; @State sys_back_to_access_backward: boolean = false; @@ -141,6 +142,12 @@ struct Index { if (this.sys_back_to_access_backward) { if (this.go_back_if_possible()) { stop_system_back = true; + } else { + if (this.bunch_of_tabs.Tabs.length > 1) { + // Can close something + this.uni_close_tab_gateway = this.current_main_tab_index; + stop_system_back = true; + } } }