chore: system

This commit is contained in:
0PandaDEV 2025-06-08 20:22:50 +02:00
parent aa928f7094
commit 97c023df91
No known key found for this signature in database
GPG key ID: 85A398412EEB8FC9
78 changed files with 15225 additions and 15225 deletions

View file

@ -1,61 +1,61 @@
import { invoke } from "@tauri-apps/api/core";
import type { HistoryItem } from "~/types/types";
export default defineNuxtPlugin(() => {
return {
provide: {
history: {
async getHistory(): Promise<HistoryItem[]> {
return await invoke<HistoryItem[]>("get_history");
},
async addHistoryItem(item: HistoryItem): Promise<void> {
await invoke<void>("add_history_item", { item });
},
async searchHistory(query: string): Promise<HistoryItem[]> {
try {
return await invoke<HistoryItem[]>("search_history", { query });
} catch (error) {
console.error("Error searching history:", error);
return [];
}
},
async loadHistoryChunk(
offset: number,
limit: number
): Promise<HistoryItem[]> {
try {
return await invoke<HistoryItem[]>("load_history_chunk", {
offset,
limit,
});
} catch (error) {
console.error("Error loading history chunk:", error);
return [];
}
},
async deleteHistoryItem(id: string): Promise<void> {
await invoke<void>("delete_history_item", { id });
},
async clearHistory(): Promise<void> {
await invoke<void>("clear_history");
},
async writeAndPaste(data: {
content: string;
contentType: string;
}): Promise<void> {
await invoke<void>("write_and_paste", data);
},
async readImage(data: { filename: string }): Promise<string> {
return await invoke<string>("read_image", data);
},
},
},
};
});
import { invoke } from "@tauri-apps/api/core";
import type { HistoryItem } from "~/types/types";
export default defineNuxtPlugin(() => {
return {
provide: {
history: {
async getHistory(): Promise<HistoryItem[]> {
return await invoke<HistoryItem[]>("get_history");
},
async addHistoryItem(item: HistoryItem): Promise<void> {
await invoke<void>("add_history_item", { item });
},
async searchHistory(query: string): Promise<HistoryItem[]> {
try {
return await invoke<HistoryItem[]>("search_history", { query });
} catch (error) {
console.error("Error searching history:", error);
return [];
}
},
async loadHistoryChunk(
offset: number,
limit: number
): Promise<HistoryItem[]> {
try {
return await invoke<HistoryItem[]>("load_history_chunk", {
offset,
limit,
});
} catch (error) {
console.error("Error loading history chunk:", error);
return [];
}
},
async deleteHistoryItem(id: string): Promise<void> {
await invoke<void>("delete_history_item", { id });
},
async clearHistory(): Promise<void> {
await invoke<void>("clear_history");
},
async writeAndPaste(data: {
content: string;
contentType: string;
}): Promise<void> {
await invoke<void>("write_and_paste", data);
},
async readImage(data: { filename: string }): Promise<string> {
return await invoke<string>("read_image", data);
},
},
},
};
});

View file

@ -1,27 +1,27 @@
import { platform } from "@tauri-apps/plugin-os";
import { useKeyboard, Key } from "@waradu/keyboard";
export default defineNuxtPlugin(async (nuxtApp) => {
const keyboardInstance = useKeyboard();
let currentOS = "windows";
try {
const osName = await Promise.resolve(platform());
currentOS = osName.toLowerCase().includes("mac") ? "macos" : "windows";
} catch (error) {
console.error("Error detecting platform:", error);
}
// Defer initialization until the app is mounted
nuxtApp.hook('app:mounted', () => {
keyboardInstance.init();
});
nuxtApp.provide('keyboard', {
listen: keyboardInstance.listen.bind(keyboardInstance),
init: keyboardInstance.init.bind(keyboardInstance),
Key,
currentOS,
// Provide a clear method if users need to manually clear all listeners from the instance
clearAll: keyboardInstance.clear ? keyboardInstance.clear.bind(keyboardInstance) : () => { console.warn('@waradu/keyboard instance does not have a clear method'); }
});
});
import { platform } from "@tauri-apps/plugin-os";
import { useKeyboard, Key } from "@waradu/keyboard";
export default defineNuxtPlugin(async (nuxtApp) => {
const keyboardInstance = useKeyboard();
let currentOS = "windows";
try {
const osName = await Promise.resolve(platform());
currentOS = osName.toLowerCase().includes("mac") ? "macos" : "windows";
} catch (error) {
console.error("Error detecting platform:", error);
}
// Defer initialization until the app is mounted
nuxtApp.hook('app:mounted', () => {
keyboardInstance.init();
});
nuxtApp.provide('keyboard', {
listen: keyboardInstance.listen.bind(keyboardInstance),
init: keyboardInstance.init.bind(keyboardInstance),
Key,
currentOS,
// Provide a clear method if users need to manually clear all listeners from the instance
clearAll: keyboardInstance.clear ? keyboardInstance.clear.bind(keyboardInstance) : () => { console.warn('@waradu/keyboard instance does not have a clear method'); }
});
});

View file

@ -1,68 +1,68 @@
import { ref, computed } from 'vue';
import type { HistoryItem } from '~/types/types';
interface GroupedHistory {
label: string;
items: HistoryItem[];
}
const selectedGroupIndex = ref(0);
const selectedItemIndex = ref(0);
const selectedElement = ref<HTMLElement | null>(null);
const useSelectedResult = (groupedHistory: Ref<GroupedHistory[]>) => {
const selectedItem = computed<HistoryItem | undefined>(() => {
const group = groupedHistory.value[selectedGroupIndex.value];
return group?.items[selectedItemIndex.value] ?? undefined;
});
const isSelected = (groupIndex: number, itemIndex: number): boolean => {
return selectedGroupIndex.value === groupIndex && selectedItemIndex.value === itemIndex;
};
const selectNext = (): void => {
const currentGroup = groupedHistory.value[selectedGroupIndex.value];
if (selectedItemIndex.value < currentGroup.items.length - 1) {
selectedItemIndex.value++;
} else if (selectedGroupIndex.value < groupedHistory.value.length - 1) {
selectedGroupIndex.value++;
selectedItemIndex.value = 0;
}
};
const selectPrevious = (): void => {
if (selectedItemIndex.value > 0) {
selectedItemIndex.value--;
} else if (selectedGroupIndex.value > 0) {
selectedGroupIndex.value--;
selectedItemIndex.value = groupedHistory.value[selectedGroupIndex.value].items.length - 1;
}
};
const selectItem = (groupIndex: number, itemIndex: number): void => {
selectedGroupIndex.value = groupIndex;
selectedItemIndex.value = itemIndex;
};
return {
selectedItem,
isSelected,
selectNext,
selectPrevious,
selectItem,
selectedElement
};
};
export default defineNuxtPlugin(() => {
return {
provide: {
selectedResult: {
selectedGroupIndex,
selectedItemIndex,
selectedElement,
useSelectedResult
}
}
};
import { ref, computed } from 'vue';
import type { HistoryItem } from '~/types/types';
interface GroupedHistory {
label: string;
items: HistoryItem[];
}
const selectedGroupIndex = ref(0);
const selectedItemIndex = ref(0);
const selectedElement = ref<HTMLElement | null>(null);
const useSelectedResult = (groupedHistory: Ref<GroupedHistory[]>) => {
const selectedItem = computed<HistoryItem | undefined>(() => {
const group = groupedHistory.value[selectedGroupIndex.value];
return group?.items[selectedItemIndex.value] ?? undefined;
});
const isSelected = (groupIndex: number, itemIndex: number): boolean => {
return selectedGroupIndex.value === groupIndex && selectedItemIndex.value === itemIndex;
};
const selectNext = (): void => {
const currentGroup = groupedHistory.value[selectedGroupIndex.value];
if (selectedItemIndex.value < currentGroup.items.length - 1) {
selectedItemIndex.value++;
} else if (selectedGroupIndex.value < groupedHistory.value.length - 1) {
selectedGroupIndex.value++;
selectedItemIndex.value = 0;
}
};
const selectPrevious = (): void => {
if (selectedItemIndex.value > 0) {
selectedItemIndex.value--;
} else if (selectedGroupIndex.value > 0) {
selectedGroupIndex.value--;
selectedItemIndex.value = groupedHistory.value[selectedGroupIndex.value].items.length - 1;
}
};
const selectItem = (groupIndex: number, itemIndex: number): void => {
selectedGroupIndex.value = groupIndex;
selectedItemIndex.value = itemIndex;
};
return {
selectedItem,
isSelected,
selectNext,
selectPrevious,
selectItem,
selectedElement
};
};
export default defineNuxtPlugin(() => {
return {
provide: {
selectedResult: {
selectedGroupIndex,
selectedItemIndex,
selectedElement,
useSelectedResult
}
}
};
});

View file

@ -1,17 +1,17 @@
import { invoke } from "@tauri-apps/api/core";
export default defineNuxtPlugin(() => {
return {
provide: {
settings: {
async getSetting(key: string): Promise<string> {
return await invoke<string>("get_setting", { key });
},
async saveSetting(key: string, value: string): Promise<void> {
await invoke<void>("save_setting", { key, value });
},
},
},
};
});
import { invoke } from "@tauri-apps/api/core";
export default defineNuxtPlugin(() => {
return {
provide: {
settings: {
async getSetting(key: string): Promise<string> {
return await invoke<string>("get_setting", { key });
},
async saveSetting(key: string, value: string): Promise<void> {
await invoke<void>("save_setting", { key, value });
},
},
},
};
});