Skip to content

Commit 4b58fb4

Browse files
committed
Merge branch 'refs/heads/master'
# Conflicts: # README.md
2 parents 37db64c + 243aee6 commit 4b58fb4

File tree

9 files changed

+104
-19
lines changed

9 files changed

+104
-19
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,23 @@
5151

5252
## 版本说明
5353

54-
### v1.0.4 | 2025-08-27
54+
### v1.0.5 | 2025-09-30
5555

5656
#### ✨ 新增功能
5757

58-
- 支持创建 **编组级快捷方式**(编组内右键),运行编组快捷方式时会自动打开编组中的全部资源
59-
- 支持双击编辑资源路径,并可为资源设置启动参数(⚠️ 如果路径包含空格,需要使用引号包裹)
58+
- 支持资源启动间隔设置(可在设置页设置)
6059

61-
#### 🔧 优化与改进
60+
#### 历史版本
6261

63-
- 优化了设置页的交互与体验
64-
- 修复了一些已知漏洞,提升了稳定性
62+
- v1.0.4 | 2025-08-27
6563

66-
#### 历史版本
64+
** ✨ 新增功能
65+
- 支持创建 **编组级快捷方式**(编组内右键),运行编组快捷方式时会自动打开编组中的全部资源
66+
- 支持双击编辑资源路径,并可为资源设置启动参数(⚠️ 如果路径包含空格,需要使用引号包裹)
67+
68+
** 🔧 优化与改进
69+
- 优化了设置页的交互与体验
70+
- 修复了一些已知漏洞,提升了稳定性
6771

6872
- v1.0.3 | 2025-03-09
6973

package.json

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

src-tauri/Cargo.lock

Lines changed: 8 additions & 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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "one-click-launch"
3-
version = "1.0.4"
3+
version = "1.0.5"
44
description = "One Click Launch"
55
authors = ["Silwings"]
66
edition = "2024"
@@ -41,6 +41,7 @@ lazy_static = "1.5.0"
4141
itertools = "0.14.0"
4242
dirs = "5.0.1"
4343
shlex = "1.3.0"
44+
humantime = "2.3.0"
4445

4546
[features]
4647
portable = []

src-tauri/src/api/launcher_api.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{path::Path, process::Command};
1+
use std::{path::Path, process::Command, time::Duration};
22

33
use anyhow::Result;
44
use rand::{Rng, distributions::Alphanumeric};
@@ -10,9 +10,11 @@ use tracing::info;
1010
use crate::{
1111
DatabaseManager,
1212
api::window_api,
13+
constants::RESOURCE_LAUNCH_INTERVAL,
1314
db::{
1415
launcher,
1516
launcher_resource::{self, CreateResourceParam, LauncherResource},
17+
settings,
1618
},
1719
error::OneClickLaunchError,
1820
events::{
@@ -330,7 +332,9 @@ pub async fn launch(app: AppHandle, launcher_id: i64) -> Result<(), OneClickLaun
330332
return Ok(());
331333
}
332334

333-
launch_resources(&app, &resources);
335+
let delay = get_launch_delay(&app).await?;
336+
337+
launch_resources(&app, &resources, delay).await;
334338

335339
EventDispatcher::<LauncherLaunched>::send_event(
336340
&app,
@@ -349,14 +353,18 @@ pub async fn open_path(app: AppHandle, path: &str) -> Result<(), OneClickLaunchE
349353
Ok(())
350354
}
351355

352-
pub fn launch_resources(app: &AppHandle, resources: &[LauncherResource]) {
353-
for resource in resources.iter() {
356+
pub async fn launch_resources(app: &AppHandle, resources: &[LauncherResource], delay: Duration) {
357+
for (i, resource) in resources.iter().enumerate() {
354358
if let Err(e) = open_using_default_program(app, resource.path.as_str()) {
355359
info!(
356360
"启动资源失败,资源名称: {:?},资源路径: {:?},错误信息: {:?}",
357361
&resource.name, &resource.path, e
358362
);
359363
}
364+
// 最后一个资源之后不再等待
365+
if i < resources.len() - 1 {
366+
tokio::time::sleep(delay).await;
367+
}
360368
}
361369
}
362370

@@ -445,3 +453,16 @@ fn current_exe_path_str() -> Result<String, OneClickLaunchError> {
445453
}
446454
Ok(app_path)
447455
}
456+
457+
pub async fn get_launch_delay(app: &AppHandle) -> Result<Duration> {
458+
let db: State<'_, DatabaseManager> = app.try_state().ok_or(
459+
OneClickLaunchError::ExecutionError("Unable to get DatabaseManager".to_string()),
460+
)?;
461+
462+
Ok(settings::read(&db.pool, RESOURCE_LAUNCH_INTERVAL)
463+
.await
464+
.unwrap_or_default()
465+
.map(|setting| setting.value)
466+
.map(|d| d.parse::<humantime::Duration>().unwrap().into())
467+
.unwrap_or_else(|| Duration::from_secs(0)))
468+
}

src-tauri/src/constants.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub static THEME_KEY: &str = "theme";
1111
pub static CLOSE_MAIN_PANEL_KEY: &str = "close_main_panel";
1212
pub static AUTO_START_LAUNCHER_IDS_KEY: &str = "auto_start_launcher_ids";
1313
pub static HIDE_AFTER_AUTO_START_KEY: &str = "hide_after_auto_start";
14+
pub static RESOURCE_LAUNCH_INTERVAL: &str = "resource_launch_interval";
1415
pub static CLOSE_MAIN_PANEL_EXIT: &str = "m2";
1516
pub static WINDOW_MIN_WIDTH: u32 = 800;
1617
pub static WINDOW_MIN_HEIGHT: u32 = 600;

src-tauri/src/events/system_listeners.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::time::Duration;
2+
13
use tauri::{AppHandle, Manager};
24
use tracing::{debug, error};
35

@@ -157,7 +159,11 @@ fn launch_auto_start_launchers(app: &AppHandle, payload: &ApplicationStartupComp
157159
{
158160
// 如果用户设置的自启启动器为空则不执行启动
159161
if !launcher_resources.is_empty() {
160-
launcher_api::launch_resources(&app_cloned, &launcher_resources);
162+
let delay = launcher_api::get_launch_delay(&app_cloned)
163+
.await
164+
.unwrap_or_else(|_e| Duration::from_secs(0));
165+
launcher_api::launch_resources(&app_cloned, &launcher_resources, delay)
166+
.await;
161167
debug!("自启启动器已启动. 启动器信息: {:?}", launcher_resources);
162168
let _ = EventDispatcher::<LauncherLaunched>::send_event(
163169
&app_cloned,

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": "一键启动",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"identifier": "one-click-launch",
66
"build": {
77
"beforeDevCommand": "yarn dev",

src/settings.vue

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
</el-select>
3838
</div>
3939

40+
<div class="setting-item">
41+
<div class="setting-label with-tooltip">
42+
<p class="setting-label">资源启动间隔</p>
43+
<el-tooltip content="多个资源启动时的时间间隔(单位:秒)" placement="top">
44+
<Help :class="['help', theme]" theme="outline" size="15" />
45+
</el-tooltip>
46+
</div>
47+
<el-select append-to=".home" v-model="resourceLaunchInterval" @change="saveResourceLaunchInterval"
48+
class="setting-select" placeholder="请选择间隔" style="width: 240px">
49+
<el-option v-for="option in launchIntervalOptions" :key="option.value" :label="option.label"
50+
:value="option.value" />
51+
</el-select>
52+
</div>
53+
4054
<div class="setting-item">
4155
<p class="setting-label">主题</p>
4256
<el-select append-to=".home" v-model="theme" @change="changeTheme" placeholder="请选择" class="setting-select">
@@ -86,7 +100,17 @@ export default {
86100
const closeMainPanel = ref("m1");
87101
// 初始状态提示
88102
const appVersion = ref('加载中...');
89-
103+
// 下拉选项配置
104+
const launchIntervalOptions = ref([
105+
{ value: '0s', label: '0 秒' },
106+
{ value: '1s', label: '1 秒' },
107+
{ value: '2s', label: '2 秒' },
108+
{ value: '3s', label: '3 秒' },
109+
{ value: '4s', label: '4 秒' },
110+
{ value: '5s', label: '5 秒' }
111+
]);
112+
// 间隔状态
113+
const resourceLaunchInterval = ref(0);
90114
// 主题相关
91115
const loadTheme = async () => {
92116
try {
@@ -166,6 +190,23 @@ export default {
166190
}
167191
};
168192
193+
// 加载已保存的间隔设置
194+
const loadResourceLaunchInterval = async () => {
195+
const savedInterval = await invoke("read_setting", { key: "resource_launch_interval" });
196+
console.log("savedInterval:", savedInterval);
197+
if (savedInterval?.value) {
198+
resourceLaunchInterval.value = savedInterval?.value;
199+
}
200+
};
201+
202+
// 保存间隔设置
203+
const saveResourceLaunchInterval = async () => {
204+
await invoke("save_setting", {
205+
key: "resource_launch_interval",
206+
value: resourceLaunchInterval.value + ""
207+
});
208+
};
209+
169210
// 其他设置
170211
const loadLaunchThenExit = async () => {
171212
try {
@@ -252,7 +293,8 @@ export default {
252293
loadLaunchThenExit(),
253294
loadCloseMainPanel(),
254295
loadHideAfterAutoStart(),
255-
getAppVersion()
296+
getAppVersion(),
297+
loadResourceLaunchInterval()
256298
]);
257299
});
258300
@@ -272,7 +314,10 @@ export default {
272314
saveCloseMainPanel,
273315
hideAfterAutoStart,
274316
toggleHideAfterAutoStart,
275-
openGitHubRepo
317+
openGitHubRepo,
318+
resourceLaunchInterval,
319+
launchIntervalOptions,
320+
saveResourceLaunchInterval
276321
};
277322
}
278323
};

0 commit comments

Comments
 (0)