diff --git a/src-tauri/proto/AchievementInfo.proto b/src-tauri/proto/AchievementInfo.proto deleted file mode 100644 index 380d2587..00000000 --- a/src-tauri/proto/AchievementInfo.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto3"; - -message AchievementProtoFieldInfo { - uint32 id = 1; - uint32 status = 2; - uint32 total_progress = 3; - uint32 current_progress = 4; - uint32 finish_timestamp = 5; -} - -message AchievementItem { - uint32 pre = 1; - uint32 group = 2; - string name = 3; - string description = 4; -} - -message MethodRvaConfig { - uint32 do_cmd = 1; - uint32 update_normal_prop = 3; - uint32 new_string = 4; - uint32 find_game_object = 5; - uint32 event_system_update = 6; - uint32 simulate_pointer_click = 7; - uint32 to_int32 = 8; - uint32 tcp_state_ptr = 9; - uint32 shared_info_ptr = 10; - uint32 decompress = 11; -} - -message NativeLibConfig { - uint32 store_cmd_id = 1; - uint32 achievement_cmd_id = 2; - map method_rva = 10; -} - -message AchievementInfo { - string version = 1; - map group = 2; - map items = 3; - AchievementProtoFieldInfo pb_info = 4; - NativeLibConfig native_config = 5; -} \ No newline at end of file diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index b0079f05..2c1fbcaf 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -154,7 +154,7 @@ pub fn run_with_admin() -> Result<(), String> { return Err(format!("executable not found: {}", exe_path.display())); } - let elevated_arg = "--elevated-action=post_install"; + let elevated_arg = "--elevated"; // /C start "" "" --elevated-action=post_install let params = format!("/C start \"\" \"{}\" {}", exe_path.display(), elevated_arg); diff --git a/src-tauri/src/plugins.rs b/src-tauri/src/plugins.rs index b3a806de..9896a3ed 100644 --- a/src-tauri/src/plugins.rs +++ b/src-tauri/src/plugins.rs @@ -15,13 +15,7 @@ pub fn build_si_plugin() -> TauriPlugin { let args: Vec = argv.iter().map(|s| s.to_string()).collect(); // 如果包含提升约定参数,发出专门事件并短路退出 - if args.iter().any(|a| a.starts_with("--elevated-action")) - || args.iter().any(|a| a == "--elevated") - { - if let Err(e) = app.emit("elevated_launch", args.clone()) { - // 记录错误但不要 panic - eprintln!("emit elevated_launch failed: {}", e); - } + if args.iter().any(|a| a == "--elevated") { // 提升实例通常只负责传参或执行一次性任务,退出避免与主实例冲突 std::process::exit(0); } diff --git a/src-tauri/src/yae/mod.rs b/src-tauri/src/yae/mod.rs index f8709eaf..2a407f0f 100644 --- a/src-tauri/src/yae/mod.rs +++ b/src-tauri/src/yae/mod.rs @@ -23,7 +23,7 @@ fn read_rva(key: &str) -> i32 { } // 读取配置文件 -fn read_conf(path: &str) -> i32 { +pub fn read_conf(path: &str) -> i32 { // 编译时嵌入 JSON 文件,值都是32位整数 let data = include_str!("../../lib/conf.json"); let json: Value = serde_json::from_str(data).expect("Invalid JSON"); diff --git a/src-tauri/src/yae/proto.rs b/src-tauri/src/yae/proto.rs index 515c3e3b..17103fdd 100644 --- a/src-tauri/src/yae/proto.rs +++ b/src-tauri/src/yae/proto.rs @@ -1,7 +1,8 @@ //! Yae 成就信息的 Protobuf 定义 -//! @since Beta v0.8.7 +//! @since Beta v0.7.9 #![cfg(target_os = "windows")] +use crate::yae::read_conf; use prost::encoding::{decode_key, WireType}; use prost::DecodeError; use prost::Message; @@ -140,6 +141,8 @@ pub fn parse_achi_list(bytes: &[u8]) -> Result, DecodeError> { let value = prost::encoding::decode_varint(&mut inner)? as u32; dict.insert(tag, value); } + // 输出 dict + println!("{:?}", dict); // dict 至少需要两个 key if dict.len() > 2 { dicts.push(dict) @@ -147,14 +150,20 @@ pub fn parse_achi_list(bytes: &[u8]) -> Result, DecodeError> { } } + let _id = read_conf("id") as u32; + let _status = read_conf("status") as u32; + let _cur = read_conf("currentProgress") as u32; + let _ts = read_conf("finishTimestamp") as u32; + let achievements = dicts .into_iter() .map(|d| UiafAchiItem { - id: d.get(&15).copied().unwrap_or(0), - status: d.get(&11).copied().unwrap_or(0), - current: d.get(&13).copied().unwrap_or(0), - timestamp: d.get(&7).copied().unwrap_or(0), + id: d.get(&_id).copied().unwrap_or(0), + status: d.get(&_status).copied().unwrap_or(0), + current: d.get(&_cur).copied().unwrap_or(0), + timestamp: d.get(&_ts).copied().unwrap_or(0), }) + .filter(|a| a.status != 0) .collect(); Ok(achievements) diff --git a/src/pages/common/PageAchi.vue b/src/pages/common/PageAchi.vue index ec21c9ec..ac3b5759 100644 --- a/src/pages/common/PageAchi.vue +++ b/src/pages/common/PageAchi.vue @@ -350,6 +350,7 @@ async function toYae(): Promise { } async function tryParseYaeAchi(payload: TGApp.Plugins.Yae.AchiListRes): Promise { + console.log(payload); if (payload.length === 0) { showSnackbar.warn(`未从Yae获取到成就数据`); return;