mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 21:24:05 +02:00
feat: move database access to rust
This commit is contained in:
parent
4b3b6eaf21
commit
a94496dbdb
5 changed files with 687 additions and 317 deletions
47
plugins/history.ts
Normal file
47
plugins/history.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
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[]> {
|
||||
return await invoke<HistoryItem[]>("search_history", { query });
|
||||
},
|
||||
|
||||
async loadHistoryChunk(
|
||||
offset: number,
|
||||
limit: number
|
||||
): Promise<HistoryItem[]> {
|
||||
return await invoke<HistoryItem[]>("load_history_chunk", {
|
||||
offset,
|
||||
limit,
|
||||
});
|
||||
},
|
||||
|
||||
async getImagePath(path: string): Promise<string> {
|
||||
return await invoke<string>("get_image_path", { path });
|
||||
},
|
||||
|
||||
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);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue