Skip to content
This repository was archived by the owner on Jan 3, 2026. It is now read-only.

Commit f6d87b9

Browse files
authored
Merge pull request #17 from CKylinMC:dev
chore: bump to 1.1.1
2 parents 2475f37 + 279c001 commit f6d87b9

File tree

10 files changed

+106
-11
lines changed

10 files changed

+106
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "pasteme",
33
"private": true,
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pasteme"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
description = "A simple clipboard manager"
55
authors = ["CKylinMC"]
66
edition = "2021"

src-tauri/src/lib.rs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
mod tray;
22

33
use enigo::{Direction, Enigo, Key, Keyboard, Settings};
4-
use tauri::{AppHandle, Manager};
4+
use tauri::{AppHandle, Manager, Runtime};
55
use tauri_plugin_autostart::MacosLauncher;
6+
use tauri_plugin_store::StoreExt;
67
use window_vibrancy::{apply_acrylic, apply_mica};
78

9+
use serde_json::json;
10+
811
#[tauri::command]
912
async fn input_text(text: &str) -> Result<(), String> {
1013
let mut enigo = Enigo::new(&Settings::default()).unwrap();
@@ -21,6 +24,45 @@ async fn simulate_paste() -> Result<(), String> {
2124
Ok(())
2225
}
2326

27+
#[tauri::command]
28+
async fn get_key_from_store<R: Runtime>(
29+
app: tauri::AppHandle<R>,
30+
_window: tauri::Window<R>,
31+
key: String,
32+
fallback: serde_json::Value,
33+
) -> Result<serde_json::Value, String> {
34+
let stores = app.store("store.bin");
35+
let store = match stores {
36+
Ok(store) => store,
37+
Err(_) => return Ok(fallback),
38+
};
39+
if store.has(key.clone()) {
40+
let value = store
41+
.get(key.clone())
42+
.expect("Failed to get value from store");
43+
Ok(value)
44+
} else {
45+
Ok(fallback)
46+
}
47+
}
48+
49+
#[tauri::command]
50+
async fn set_key_to_store<R: Runtime>(
51+
app: tauri::AppHandle<R>,
52+
_window: tauri::Window<R>,
53+
key: String,
54+
value: serde_json::Value,
55+
) -> Result<(), String> {
56+
let stores = app.store("store.bin");
57+
let store = match stores {
58+
Ok(store) => store,
59+
Err(_) => return Err("Failed to get store".to_string()),
60+
};
61+
store.set(key.clone(), json!(value));
62+
store.save().expect("Failed to save store");
63+
Ok(())
64+
}
65+
2466
fn show_window(app: &AppHandle) {
2567
let windows = app.webview_windows();
2668

@@ -65,7 +107,9 @@ pub fn run() {
65107
.plugin(tauri_plugin_opener::init())
66108
.invoke_handler(tauri::generate_handler![
67109
input_text,
68-
simulate_paste
110+
simulate_paste,
111+
get_key_from_store,
112+
set_key_to_store
69113
])
70114
.run(tauri::generate_context!())
71115
.expect("error while running tauri application");

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "PasteMe",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"identifier": "in.ckyl.pasteme",
66
"build": {
77
"beforeDevCommand": "yarn dev",

src/AppInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const AppInfo = {
2-
version: "1.1.0",
2+
version: "1.1.1",
33
};

src/composables/useConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { ref } from 'vue';
2-
import { Store } from '@tauri-apps/plugin-store';
2+
import { Store } from '@/libs/store';
33
import { tryParse } from '@/libs/utils';
44
import type { CoreMessage } from 'ai';
55

6+
67
export interface AIConfig {
78
enabled: boolean;
89
apiKey: string;

src/composables/useUpdater.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref } from 'vue';
1+
import { ref, toRaw, unref } from 'vue';
22
import { check, type Update, type DownloadEvent } from '@tauri-apps/plugin-updater';
33
import { bytesToSize } from '@/libs/utils';
44

@@ -102,13 +102,15 @@ export function useUpdater() {
102102
}
103103
case UpdateStage.DOWNLOAD: {
104104
state.value.btn = '正在下载更新';
105-
await state.value.event?.download(handleDownloadProgress);
105+
const _state = toRaw(unref(state));
106+
await _state?.event?.download(handleDownloadProgress);
106107
break;
107108
}
108109
case UpdateStage.INSTALL: {
109110
state.value.btn = '正在安装更新';
110111
state.value.type = UpdateType.INFO;
111-
await state.value.event?.install();
112+
const _state = toRaw(unref(state));
113+
await _state?.event?.install();
112114
break;
113115
}
114116
}

src/libs/bridges.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,15 @@ export async function inputText(text: string) {
77
export async function simulatePaste(){
88
return await invoke("simulate_paste");
99
}
10+
11+
export type JsonObject = { [key: string]: JsonValue };
12+
export type JsonArray = JsonValue[];
13+
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
14+
15+
export function getStoreKey(key: string, fallback: JsonValue): Promise<JsonValue> {
16+
return invoke("get_key_from_store", { key, fallback });
17+
}
18+
19+
export function setStoreKey(key: string, value: JsonValue): Promise<void> {
20+
return invoke("set_key_in_store", { key, value });
21+
}

src/libs/store.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { getStoreKey, JsonValue, setStoreKey } from "./bridges";
2+
3+
/**
4+
* StoreBackend used to move the store impl to different backend without changing usages
5+
*/
6+
export class Store {
7+
static async load(_ignored: string): Promise<Store> {
8+
return new Store();
9+
}
10+
11+
close() { }
12+
13+
save() { }
14+
15+
getRaw(key:string, fallback: JsonValue = null): Promise<JsonValue> {
16+
return getStoreKey(key, fallback);
17+
}
18+
19+
get<T>(key: string, fallback: JsonValue = null): Promise<T> {
20+
return this.getRaw(key, fallback) as Promise<T>;
21+
}
22+
23+
set(key: string, value: JsonValue = null): Promise<void> {
24+
return setStoreKey(key, value);
25+
}
26+
27+
has(key: string):Promise<boolean> {
28+
return getStoreKey(key, null).then(v => v !== null);
29+
}
30+
31+
async delete(key: string): Promise<void> {
32+
if(await this.has(key)) {
33+
return setStoreKey(key, null);
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)