Skip to content

Commit 2d53f2b

Browse files
committed
便携版
1 parent d0c2f5c commit 2d53f2b

File tree

10 files changed

+94
-55
lines changed

10 files changed

+94
-55
lines changed

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@
1717

1818
## 安装方式
1919

20-
提供两种安装文件供用户选择
20+
提供两种安装版本供用户选择
2121

22-
**1. 使用`.exe`文件安装**
22+
### 安装版
23+
24+
**1. 使用`setup.exe``.msi`文件安装**
2325
适合大部分 Windows 用户,提供简洁的安装引导界面:
2426

25-
1. 下载 `一键启动_x64-setup.exe` (如:一键启动_1.0.0_x64-setup.exe)。
27+
1. 下载 `一键启动_x64-setup.exe``一键启动_x64_zh-CN.msi` (如:一键启动_1.0.0_x64-setup.exe,一键启动_1.0.0_x64_zh-CN.msi)。
2628
2. 双击文件后,按照提示完成安装。
2729
3. 安装完成后,桌面和“开始菜单”会创建快捷方式,点击即可启动程序。
2830

29-
**2. 使用`.msi`文件安装**
30-
适合高级用户或需要批量部署的场景:
31+
### 便携版
32+
33+
**使用`portable.exe`文件直接打开**
3134

32-
1. 下载 `一键启动_x64_zh-CN.msi` (如:一键启动_1.0.0_x64_zh-CN.msi)。
33-
2. 双击文件后,按照提示完成安装。
34-
3. 安装完成后,可以直接从“开始菜单”启动程序。
35+
1. **下载便携版**
36+
- 下载 `一键启动_portable.exe` (如:一键启动_1.0.0_portable.exe)。
37+
38+
2. **直接运行**
39+
- 双击 `一键启动_portable.exe` 文件即可启动程序,无需安装。
40+
- 所有数据(如配置文件、数据库)将存储在可执行文件所在的目录中,方便携带和迁移。
3541

3642
## 使用方式
3743

@@ -140,7 +146,11 @@ cargo tauri dev
140146
运行 Tauri 生产模式
141147

142148
```bash
149+
// 构建安装版
143150
cargo tauri build
151+
152+
// 构建便携版
153+
cargo tauri build --features portable
144154
```
145155

146156
构建完成后,生成的可执行文件将在 `/src-tauri/target/release/` 目录中,你可以将其分发给用户。

components.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export {}
88
/* prettier-ignore */
99
declare module 'vue' {
1010
export interface GlobalComponents {
11-
ElButton: typeof import('element-plus/es')['ElButton']
1211
ElInput: typeof import('element-plus/es')['ElInput']
1312
ElOption: typeof import('element-plus/es')['ElOption']
1413
ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"@vitejs/plugin-vue": "^5.0.5",
2828
"babel-plugin-component": "^1.1.1",
2929
"typescript": "^5.2.2",
30-
"unplugin-auto-import": "^19.1.0",
31-
"unplugin-vue-components": "^28.4.0",
30+
"unplugin-auto-import": "^19.1.1",
31+
"unplugin-vue-components": "^28.4.1",
3232
"vite": "^5.3.1",
3333
"vue-tsc": "^2.1.10"
3434
}

src-tauri/Cargo.lock

Lines changed: 23 additions & 8 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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-wo
2626
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
2727
tauri-plugin-os = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
2828
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
29+
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
2930
serde = { version = "1", features = ["derive"] }
3031
serde_json = "1"
3132
thiserror = "2.0.3"
@@ -38,3 +39,6 @@ tokio = { version = "1.43.0", features = ["full"] }
3839
rand = "0.8.5"
3940
lazy_static = "1.5.0"
4041
itertools = "0.14.0"
42+
43+
[features]
44+
portable = []

src-tauri/src/lib.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub struct WindowContext {
3535
pub tray_icon: TrayIcon,
3636
}
3737

38+
#[cfg(not(feature = "portable"))]
3839
fn get_db_path() -> Result<PathBuf> {
3940
// 获取用户的 AppData 目录路径
4041
let app_data = env::var("APPDATA")?;
@@ -45,6 +46,29 @@ fn get_db_path() -> Result<PathBuf> {
4546
.join("data")
4647
.join("one_click_launch.db");
4748

49+
Ok(db_path)
50+
}
51+
52+
#[cfg(feature = "portable")]
53+
fn get_db_path() -> Result<PathBuf> {
54+
// 便携版:使用当前可执行文件的目录
55+
let exe_path = env::current_exe()?;
56+
let db_path = exe_path
57+
.parent()
58+
.ok_or_else(|| {
59+
std::io::Error::new(std::io::ErrorKind::Other, "Cannot get executable directory")
60+
})?
61+
.join("data")
62+
.join("one_click_launch.db");
63+
64+
Ok(db_path)
65+
}
66+
67+
async fn init_db() -> Result<DatabaseManager> {
68+
let db_path = get_db_path()?;
69+
70+
debug!("db_path:{:?}", db_path);
71+
4872
// 确保目录存在
4973
if let Some(parent) = db_path.parent() {
5074
if !parent.exists() {
@@ -59,15 +83,6 @@ fn get_db_path() -> Result<PathBuf> {
5983
info!("Database file created at {:?}", db_path);
6084
}
6185

62-
Ok(db_path)
63-
}
64-
65-
async fn init_db() -> Result<DatabaseManager> {
66-
let db_path = get_db_path()?;
67-
68-
// 打印数据库路径用于调试
69-
debug!("db_path:{:?}", db_path);
70-
7186
// 创建连接池
7287
let pool = SqlitePoolOptions::new()
7388
.max_connections(5)
@@ -122,6 +137,7 @@ pub async fn run() -> Result<()> {
122137
app.emit("single-instance", Payload { args: argv, cwd })
123138
.unwrap();
124139
}))
140+
.plugin(tauri_plugin_window_state::Builder::default().build())
125141
.plugin(tauri_plugin_shell::init())
126142
.plugin(tauri_plugin_dialog::init())
127143
.plugin(tauri_plugin_os::init())

src/main.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createApp } from "vue";
22
import { createPinia } from 'pinia';
3-
import ElementPlus from 'element-plus'
43
import App from "./App.vue";
54
import '@fortawesome/fontawesome-free/css/all.css';
65
import '@fortawesome/fontawesome-free/js/all.js';
@@ -28,6 +27,5 @@ const app = createApp(App);
2827

2928
app.use(Toast, options);
3029
app.use(createPinia());
31-
app.use(ElementPlus);
3230

3331
app.mount("#app");

src/settings.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
</div>
5252
</div>
5353

54-
<!-- 按钮 -->
55-
<button @click="loadCloseMainPanel">刷新</button>
56-
5754
</div>
5855
</template>
5956

yarn.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ superjson@^2.2.1:
825825
dependencies:
826826
copy-anything "^3.0.2"
827827

828-
tinyglobby@^0.2.10, tinyglobby@^0.2.11:
828+
tinyglobby@^0.2.11, tinyglobby@^0.2.12:
829829
version "0.2.12"
830830
resolved "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.12.tgz"
831831
integrity sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww==
@@ -855,7 +855,7 @@ ufo@^1.5.4:
855855
resolved "https://registry.npmmirror.com/ufo/-/ufo-1.5.4.tgz"
856856
integrity sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==
857857

858-
unimport@^4.1.1:
858+
unimport@^4.1.2:
859859
version "4.1.2"
860860
resolved "https://registry.npmmirror.com/unimport/-/unimport-4.1.2.tgz"
861861
integrity sha512-oVUL7PSlyVV3QRhsdcyYEMaDX8HJyS/CnUonEJTYA3//bWO+o/4gG8F7auGWWWkrrxBQBYOO8DKe+C53ktpRXw==
@@ -875,15 +875,15 @@ unimport@^4.1.1:
875875
unplugin "^2.2.0"
876876
unplugin-utils "^0.2.4"
877877

878-
unplugin-auto-import@^19.1.0:
879-
version "19.1.0"
880-
resolved "https://registry.npmmirror.com/unplugin-auto-import/-/unplugin-auto-import-19.1.0.tgz"
881-
integrity sha512-B+TGBEBHqY9aR+7YfShfLujETOHstzpV+yaqgy5PkfV0QG7Py+TYMX7vJ9W4SrysHR+UzR+gzcx/nuZjmPeclA==
878+
unplugin-auto-import@^19.1.1:
879+
version "19.1.1"
880+
resolved "https://registry.npmmirror.com/unplugin-auto-import/-/unplugin-auto-import-19.1.1.tgz"
881+
integrity sha512-sCGZZrSR1Bc8RfN8Q0RUDxXtC20rdAt7UB4lDyq8MNtKVHiXXh+5af6Nz4JRp9Q+7HjnbgQfQox0TkEymjdUAQ==
882882
dependencies:
883883
local-pkg "^1.0.0"
884884
magic-string "^0.30.17"
885885
picomatch "^4.0.2"
886-
unimport "^4.1.1"
886+
unimport "^4.1.2"
887887
unplugin "^2.2.0"
888888
unplugin-utils "^0.2.4"
889889

@@ -895,17 +895,17 @@ unplugin-utils@^0.2.4:
895895
pathe "^2.0.2"
896896
picomatch "^4.0.2"
897897

898-
unplugin-vue-components@^28.4.0:
899-
version "28.4.0"
900-
resolved "https://registry.npmmirror.com/unplugin-vue-components/-/unplugin-vue-components-28.4.0.tgz"
901-
integrity sha512-fnamX2RiKM30nPK4tihEas+bHnbLICo6MmOiP4jGg7fAlgNEuaLvN9yx96JwZDOYfLQcrNzikDdPhZ8k6pkhMg==
898+
unplugin-vue-components@^28.4.1:
899+
version "28.4.1"
900+
resolved "https://registry.npmmirror.com/unplugin-vue-components/-/unplugin-vue-components-28.4.1.tgz"
901+
integrity sha512-niGSc0vJD9ueAnsqcfAldmtpkppZ09B6p2G1dL7X5S8KPdgbk1P+txPwaaDCe7N+eZh2VG1aAypLXkuJs3OSUg==
902902
dependencies:
903903
chokidar "^3.6.0"
904904
debug "^4.4.0"
905905
local-pkg "^1.0.0"
906906
magic-string "^0.30.17"
907907
mlly "^1.7.4"
908-
tinyglobby "^0.2.10"
908+
tinyglobby "^0.2.12"
909909
unplugin "^2.2.0"
910910
unplugin-utils "^0.2.4"
911911

0 commit comments

Comments
 (0)