| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- // Prevents additional console window on Windows in release, DO NOT REMOVE!!
- #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
- mod commands;
- mod steam_auth;
- mod browser_automation;
- mod api_client;
- mod config;
- mod key_storage;
- mod machine;
- mod storage;
- mod updater;
- mod error;
- mod security;
- mod heartbeat;
- use commands::*;
- use browser_automation::*;
- use api_client::{ApiConfig as BackendApiConfig, initialize_api_client};
- use config::*;
- fn main() {
- // 阶段二:安全检查
- if let Err(e) = security::perform_all_security_checks() {
- eprintln!("安全检查失败: {}", e);
- // 在生产环境中,安全检查失败应该立即退出
- if !cfg!(debug_assertions) {
- std::process::exit(1);
- }
- }
- // 初始化存储系统
- if let Err(e) = storage::init_storage() {
- eprintln!("Failed to initialize storage: {}", e);
- // 存储初始化失败不应该阻止程序启动
- }
- // 初始化应用配置和API客户端
- let app_config = AppConfig::load().unwrap_or_else(|e| {
- eprintln!("Failed to load config: {}, using defaults", e);
- AppConfig::default()
- });
- // 初始化API客户端
- let api_config = BackendApiConfig {
- base_url: app_config.api.base_url.clone(),
- timeout: app_config.api.timeout,
- software_code: app_config.api.software_code.clone(),
- };
- if let Err(e) = initialize_api_client(api_config) {
- eprintln!("Failed to initialize API client: {}", e);
- // API客户端初始化失败也不阻止程序启动,用户可以在运行时重新配置
- }
- tauri::Builder::default()
- .invoke_handler(tauri::generate_handler![
- // Steam本地功能
- generate_steam_code,
- fetch_confirmations,
- accept_confirmation,
- deny_confirmation,
- save_steam_account,
- load_steam_accounts,
- launch_browser_session,
- execute_automated_shopping,
- // project-local steam-msg commands
- save_steam_guard_file,
- save_steam_account_to_project,
- list_project_steam_accounts,
- delete_project_steam_account,
- export_mafile_to_path,
- get_steam_wallet_balance,
- read_proxy_config,
- write_proxy_config,
- test_proxy_configuration,
- verify_steam_login,
- // 后端API调用
- initialize_backend_api,
- user_register,
- user_login,
- user_unbind,
- user_recharge,
- user_heartbeat,
- secure_heartbeat,
- user_logout,
- activate_card,
- get_steam_account_limit,
- get_steam_accounts,
- create_steam_account,
- bind_steam_account,
- update_steam_account,
- delete_steam_account,
- get_announcements,
- health_check,
- get_public_key,
- get_client_configs,
- // 配置管理
- get_app_config,
- update_api_url,
- get_api_base_url,
- // 机器码和存储
- get_machine_code,
- store_user_info,
- get_stored_user_info,
- get_user_profile,
- get_system_username,
- clear_stored_user_info,
- minimize_window,
- close_window,
- stop_all_processes,
- rsa_encrypt_aes_key,
- secure_get_announcements,
- secure_user_login,
- secure_user_register,
- forgot_password_request,
- secure_user_unbind,
- secure_user_change_password,
- secure_user_recharge,
- store_rsa_public_key,
- has_stored_rsa_key,
- clear_stored_rsa_key,
- rsa_encrypt_aes_key_by_stored_key,
- get_rsa_key_version,
- // 安全通信模块命令
- initialize_security_client,
- check_security_initialized,
- get_security_status,
- refresh_security_keys,
- reset_security_client,
- sync_hmac_key,
- secure_buff_filter_options,
- secure_buff_goods_attr_list,
- secure_buff_selection_config,
- secure_buff_selection_start,
- secure_buff_selection_log,
- secure_buff_selection_result,
- secure_buff_selection_stop,
- secure_keys_hmac,
- // 密钥管理命令
- get_key_manager_status,
- get_hmac_key_status,
- // 心跳管理命令
- get_heartbeat_state_command,
- stop_heartbeat_command,
- get_heartbeat_config_command,
- read_text_file,
- // 更新相关
- // updater::check_for_updates,
- // updater::manual_update_check,
- // updater::start_manual_update
- ])
- .setup(|app| {
- heartbeat::set_app_handle(app.handle().clone());
- Ok(())
- })
- .run(tauri::generate_context!())
- .expect("error while running tauri application");
- }
|