feat: add portable mode support and improve update handling

- Add portable.ini marker file creation in GitHub Actions for portable builds
- Implement is_portable_mode() command to detect portable execution
- Redirect portable users to GitHub releases page for manual updates
- Change update URL to point to latest releases page
- Integrate portable mode detection in Settings UI
This commit is contained in:
Jason
2025-09-24 11:25:33 +08:00
parent 20f0dd7e1c
commit 9ede0ad27d
6 changed files with 45 additions and 1 deletions

View File

@@ -674,7 +674,7 @@ pub async fn check_for_updates(handle: tauri::AppHandle) -> Result<bool, String>
handle
.opener()
.open_url(
"https://github.com/farion1231/cc-switch/releases",
"https://github.com/farion1231/cc-switch/releases/latest",
None::<String>,
)
.map_err(|e| format!("打开更新页面失败: {}", e))?;
@@ -682,6 +682,17 @@ pub async fn check_for_updates(handle: tauri::AppHandle) -> Result<bool, String>
Ok(true)
}
/// 判断是否为便携版(绿色版)运行
#[tauri::command]
pub async fn is_portable_mode() -> Result<bool, String> {
let exe_path = std::env::current_exe().map_err(|e| format!("获取可执行路径失败: {}", e))?;
if let Some(dir) = exe_path.parent() {
Ok(dir.join("portable.ini").is_file())
} else {
Ok(false)
}
}
/// VS Code: 获取用户 settings.json 状态
#[tauri::command]
pub async fn get_vscode_settings_status() -> Result<ConfigStatus, String> {

View File

@@ -377,6 +377,7 @@ pub fn run() {
commands::get_settings,
commands::save_settings,
commands::check_for_updates,
commands::is_portable_mode,
commands::get_vscode_settings_status,
commands::read_vscode_settings,
commands::write_vscode_settings,