feat: implement useAppControl composable for app hiding functionality and refactor index.vue to utilize it

This commit is contained in:
pandadev 2025-03-16 21:32:44 +01:00
parent 409e10a8fd
commit b828daff08
No known key found for this signature in database
GPG key ID: C39629DACB8E762F
2 changed files with 17 additions and 8 deletions

View file

@ -0,0 +1,12 @@
import { app, window } from "@tauri-apps/api";
export function useAppControl() {
const hideApp = async (): Promise<void> => {
await app.hide();
await window.getCurrentWindow().hide();
};
return {
hideApp
};
}

View file

@ -10,7 +10,7 @@
<Result v-for="(item, index) in group.items" :key="item.id" :item="item"
:selected="isSelected(groupIndex, index)" :image-url="imageUrls[item.id]"
:dimensions="imageDimensions[item.id]" @select="selectItem(groupIndex, index)" @image-error="onImageError"
@setRef="(el) => (selectedElement = el)" />
@setRef="(el: HTMLElement | null) => (selectedElement = el)" />
</div>
</div>
</OverlayScrollbarsComponent>
@ -62,7 +62,6 @@
import { ref, computed, onMounted, watch, nextTick, shallowRef } from "vue";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import "overlayscrollbars/overlayscrollbars.css";
import { app, window } from "@tauri-apps/api";
import { platform } from "@tauri-apps/plugin-os";
import { listen } from "@tauri-apps/api/event";
import { useNuxtApp } from "#app";
@ -76,9 +75,10 @@ import type {
InfoColor,
InfoCode,
} from "~/types/types";
import IconsEnter from "~/components/Icons/Enter.vue";
import IconsKey from "~/components/Icons/Key.vue";
import IconsEnter from "~/components/Keys/Enter.vue";
import IconsKey from "~/components/Keys/Key.vue";
import ActionsMenu from "~/components/ActionsMenu.vue";
import { useAppControl } from "~/composables/useAppControl";
interface GroupedHistory {
label: string;
@ -583,10 +583,7 @@ const setupEventListeners = async (): Promise<void> => {
$keyboard.enableContext('main');
};
const hideApp = async (): Promise<void> => {
await app.hide();
await window.getCurrentWindow().hide();
};
const { hideApp } = useAppControl();
const focusSearchInput = (): void => {
nextTick(() => {