Skip to content

Commit a3c489d

Browse files
committed
update
1 parent 611c9c4 commit a3c489d

File tree

7 files changed

+62
-17
lines changed

7 files changed

+62
-17
lines changed

src-tauri/Cargo.lock

Lines changed: 16 additions & 0 deletions
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ tauri-plugin-updater = "2"
2626

2727
[target.'cfg(any(target_os = "macos", windows, target_os = "linux"))'.dependencies]
2828
tauri-plugin-autostart = "2"
29+
tauri-plugin-single-instance = "2"
2930
serde = { version = "1", features = ["derive"] }
3031
serde_json = "1"
3132
tokio = { version = "1", features = ["time"] }

src-tauri/src/lib.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,26 @@ async fn download_and_install_update(app: tauri::AppHandle) -> Result<(), String
154154

155155
#[cfg_attr(mobile, tauri::mobile_entry_point)]
156156
pub fn run() {
157-
tauri::Builder::default()
157+
let mut builder = tauri::Builder::default();
158+
159+
// 单例插件必须是第一个注册的插件
160+
#[cfg(desktop)]
161+
{
162+
builder = builder.plugin(tauri_plugin_single_instance::init(|app, args, cwd| {
163+
println!("检测到新实例启动,聚焦到现有窗口");
164+
println!("启动参数: {:?}", args);
165+
println!("工作目录: {:?}", cwd);
166+
167+
// 当用户尝试打开新实例时,聚焦到现有的主窗口
168+
if let Some(window) = app.get_webview_window("main") {
169+
let _ = window.show();
170+
let _ = window.set_focus();
171+
let _ = window.unminimize();
172+
}
173+
}));
174+
}
175+
176+
builder
158177
.plugin(tauri_plugin_opener::init())
159178
.plugin(tauri_plugin_shell::init())
160179
.plugin(tauri_plugin_fs::init())

src-tauri/tauri.conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "UserBank",
4-
"version": "0.2.0",
4+
"version": "0.1.2",
55
"identifier": "com.userbank.app",
66
"build": {
77
"beforeDevCommand": "npm run dev",
@@ -48,7 +48,7 @@
4848
"https://github.com/MixLabPro/userbank/releases/latest/download/update.json"
4949
],
5050
"dialog": true,
51-
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IENGOTYxM0Q1OTg1MUQ1RDUKUldUVjFWR1kxUk9XenczUnMvMTJsR1JnMmxlQjVkSmhTWE5HNk8rUUc3V0VRSWtwQnJyTzVDQ0QK",
51+
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDY1N0MyQzQ5RTk5NTA3NkIKUldSckI1WHBTU3g4WmVHTDdodjNnTHhCSms3cU51dmdWVTBiSzlhMHUrZWxZbDNUWm1rWlRDT3MK",
5252
"windows":{
5353
"installMode": "passive"
5454
}

src/main.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import App from './App.tsx'
33
import './index.css'
44
import './i18n'
55

6-
// // 禁止右键菜单
7-
// document.addEventListener('contextmenu', (e) => {
8-
// e.preventDefault();
9-
// });
6+
// 禁止右键菜单
7+
document.addEventListener('contextmenu', (e) => {
8+
e.preventDefault();
9+
});
1010

11-
// // 禁止F12开发者工具
12-
// document.addEventListener('keydown', (e) => {
13-
// if (e.key === 'F12' ||
14-
// (e.ctrlKey && e.shiftKey && e.key === 'I') ||
15-
// (e.ctrlKey && e.shiftKey && e.key === 'C') ||
16-
// (e.ctrlKey && e.key === 'u')) {
17-
// e.preventDefault();
18-
// }
19-
// });
11+
// 禁止F12开发者工具
12+
document.addEventListener('keydown', (e) => {
13+
if (e.key === 'F12' ||
14+
(e.ctrlKey && e.shiftKey && e.key === 'I') ||
15+
(e.ctrlKey && e.shiftKey && e.key === 'C') ||
16+
(e.ctrlKey && e.key === 'u')) {
17+
e.preventDefault();
18+
}
19+
});
2020

2121
// 禁止选择文本
2222
// document.addEventListener('selectstart', (e) => {

src/pages/Index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ const Index = () => {
477477
onClick={() => setShowSettings(false)}
478478
/>
479479
{/* 设置面板 */}
480-
<div className="absolute right-0 top-full mt-4 w-100 bg-white rounded-2xl shadow-lg shadow-gray-900/5 border border-gray-100 z-50 transform transition-all duration-300 scale-100 opacity-100">
480+
<div className="absolute right-0 top-full mt-4 w-120 bg-white rounded-2xl shadow-lg shadow-gray-900/5 border border-gray-100 z-50 transform transition-all duration-300 scale-100 opacity-100">
481481
<div className="p-8">
482482
{/* 设置标题 */}
483483
<div className="flex items-center justify-between mb-8">

update.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": "0.1.2",
3+
"platforms": {
4+
"windows-x86_64": {
5+
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVUVjFWR1kxUk9XejFPd05qcjBpaGxXZ25tazNtL0JYdmdLY1lwV24rdlY0Sy9Ycmd1cWJDeWg2aGc3MTAxSXV2U0YvNnBLY0laNWpONEFUekJlSW1JSFJ4UXZNTHNoNVE0PQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzQ5MjYyODQwCWZpbGU6VXNlckJhbmtfMC4xLjFfeDY0LXNldHVwLmV4ZQozdUVtQzhjNWl0U0NaYzlGUW1tM3Q1VDNLUWVJQjB2L3BFTlNBa0dWYjAyT3V5UkR1VXZTWTlXRmUwUWtCWngvZUVBU3VteklycWlDOUI0NDYyMndDdz09Cg==",
6+
"url": "https://github.com/MixLabPro/userbank/releases/download/0.1.2/UserBank_0.1.2_x64-setup.exe"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)