Browse Source
			
			
			
			
				
		- Add explicit Router type imports across views - Replace $router type casting with proper typing - Use $router.back() instead of $router.go(-1) for consistency - Add proper route and router typings to components - Clean up router navigation methods - Fix router push/back method calls This commit improves type safety and consistency in router usage across the application's view components.
				 56 changed files with 582 additions and 252 deletions
			
			
		@ -1,9 +1,59 @@ | 
				
			|||
// Import from node_modules using relative path
 | 
				
			|||
import { App as CapacitorApp } from '../../../node_modules/@capacitor/app'; | 
				
			|||
 | 
				
			|||
// Re-export the App interface with our own wrapper
 | 
				
			|||
export const App = { | 
				
			|||
  addListener: (eventName: string, listenerFunc: (data: any) => void) => { | 
				
			|||
    return CapacitorApp.addListener(eventName, listenerFunc); | 
				
			|||
  } | 
				
			|||
};  | 
				
			|||
 | 
				
			|||
import { | 
				
			|||
  App as CapacitorApp, | 
				
			|||
  AppLaunchUrl, | 
				
			|||
  BackButtonListener, | 
				
			|||
} from "@capacitor/app"; | 
				
			|||
import type { PluginListenerHandle } from "@capacitor/core"; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * Interface defining the app event listener functionality | 
				
			|||
 * Supports 'backButton' and 'appUrlOpen' events from Capacitor | 
				
			|||
 */ | 
				
			|||
interface AppInterface { | 
				
			|||
  /** | 
				
			|||
   * Add listener for back button events | 
				
			|||
   * @param eventName - Must be 'backButton' | 
				
			|||
   * @param listenerFunc - Callback function for back button events | 
				
			|||
   * @returns Promise that resolves with a removable listener handle | 
				
			|||
   */ | 
				
			|||
  addListener( | 
				
			|||
    eventName: "backButton", | 
				
			|||
    listenerFunc: BackButtonListener, | 
				
			|||
  ): Promise<PluginListenerHandle> & PluginListenerHandle; | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * Add listener for app URL open events | 
				
			|||
   * @param eventName - Must be 'appUrlOpen' | 
				
			|||
   * @param listenerFunc - Callback function for URL open events | 
				
			|||
   * @returns Promise that resolves with a removable listener handle | 
				
			|||
   */ | 
				
			|||
  addListener( | 
				
			|||
    eventName: "appUrlOpen", | 
				
			|||
    listenerFunc: (data: AppLaunchUrl) => void, | 
				
			|||
  ): Promise<PluginListenerHandle> & PluginListenerHandle; | 
				
			|||
} | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * App wrapper for Capacitor functionality | 
				
			|||
 * Provides type-safe event listeners for back button and URL open events | 
				
			|||
 */ | 
				
			|||
export const App: AppInterface = { | 
				
			|||
  addListener( | 
				
			|||
    eventName: "backButton" | "appUrlOpen", | 
				
			|||
    listenerFunc: BackButtonListener | ((data: AppLaunchUrl) => void), | 
				
			|||
  ): Promise<PluginListenerHandle> & PluginListenerHandle { | 
				
			|||
    if (eventName === "backButton") { | 
				
			|||
      return CapacitorApp.addListener( | 
				
			|||
        eventName, | 
				
			|||
        listenerFunc as BackButtonListener, | 
				
			|||
      ) as Promise<PluginListenerHandle> & PluginListenerHandle; | 
				
			|||
    } else { | 
				
			|||
      return CapacitorApp.addListener( | 
				
			|||
        eventName, | 
				
			|||
        listenerFunc as (data: AppLaunchUrl) => void, | 
				
			|||
      ) as Promise<PluginListenerHandle> & PluginListenerHandle; | 
				
			|||
    } | 
				
			|||
  }, | 
				
			|||
}; | 
				
			|||
 | 
				
			|||
					Loading…
					
					
				
		Reference in new issue