Skip to content

Commit

Permalink
Merge pull request #59 from Mikachu2333/master
Browse files Browse the repository at this point in the history
fix: typos and format with clippy
  • Loading branch information
Alex-Beng authored Jan 16, 2025
2 parents 7cad913 + 09c8e64 commit 971f747
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "yap"
version = "5.2.0"
version = "5.3.0"
edition = "2021"
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[package.metadata.winres]
LegalCopyright = "Copyright Alex-Beng © 2024"
LegalCopyright = "Copyright Alex-Beng (c) 2024-2025"
FileDescription = "Yap for Genshin"

[dependencies]
Expand Down
6 changes: 3 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ fn main() {
// }

let mut version = 0;
version |= 4 << 48;
version |= 6 << 32;
version |= 5 << 48;
version |= 3 << 32;
version |= 0 << 16;
version |= 71;
version |= 2;

res.set_version_info(VersionInfo::FILEVERSION, version)
.set_version_info(VersionInfo::PRODUCTVERSION, version)
Expand Down
3 changes: 2 additions & 1 deletion models/all_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,8 @@
"龙冠武士的金哨",
"折光的胚芽",
"惑光的阔叶",
"迷光的蜷叶之心小灯草",
"迷光的蜷叶之心",
"小灯草",
"慕风蘑菇",
"蒲公英籽",
"钩钩果",
Expand Down
42 changes: 24 additions & 18 deletions src/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
use std::io::stdin;
use std::process;
use std::ptr::null_mut;
use std::time::Duration;
use std::thread;
use std::time::Duration;

use crate::dto::GithubTag;

use log::error;
use reqwest::blocking::Client;
use reqwest::header::{HeaderValue, USER_AGENT};
use winapi::shared::windef::HWND;
use winapi::shared::minwindef::BOOL;
use winapi::shared::windef::HWND;
use winapi::um::securitybaseapi::{AllocateAndInitializeSid, CheckTokenMembership, FreeSid};
use winapi::um::winnt::{SID_IDENTIFIER_AUTHORITY, SECURITY_NT_AUTHORITY, PSID, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS};
use winapi::um::winnt::{
DOMAIN_ALIAS_RID_ADMINS, PSID, SECURITY_BUILTIN_DOMAIN_RID, SECURITY_NT_AUTHORITY,
SID_IDENTIFIER_AUTHORITY,
};

#[derive(Clone, Copy)]
pub struct WindowHandle {
pub struct WindowHandle {
pub hwnd: HWND,
}

Expand All @@ -27,7 +30,7 @@ impl WindowHandle {
Some(WindowHandle { hwnd })
}
}

pub fn as_ptr(&self) -> HWND {
self.hwnd
}
Expand All @@ -46,13 +49,11 @@ pub fn error_and_quit_no_input(msg: &str) -> ! {
process::exit(0);
}


pub fn sleep(ms: u32) {
let time = Duration::from_millis(ms as u64);
thread::sleep(time);
}


// 管理员权限
unsafe fn is_admin_unsafe() -> bool {
let mut authority: SID_IDENTIFIER_AUTHORITY = SID_IDENTIFIER_AUTHORITY {
Expand All @@ -64,7 +65,12 @@ unsafe fn is_admin_unsafe() -> bool {
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0,
0,
0,
&mut group as *mut PSID,
);
if b != 0 {
Expand All @@ -79,15 +85,13 @@ unsafe fn is_admin_unsafe() -> bool {
}

pub fn is_admin() -> bool {
unsafe {
is_admin_unsafe()
}
unsafe { is_admin_unsafe() }
}

// 版本更新
static mut VERSION: String = String::new();
unsafe fn get_version_unsafe() -> String {
if VERSION.is_empty() {
if VERSION == String::new() {
let s = include_str!("../../Cargo.toml");
for line in s.lines() {
if line.starts_with("version = ") {
Expand All @@ -102,21 +106,23 @@ unsafe fn get_version_unsafe() -> String {
}

pub fn get_version() -> String {
unsafe {
get_version_unsafe()
}
unsafe { get_version_unsafe() }
}

pub fn check_update() -> Option<String> {
let client = Client::new();

let resp = client.get("https://api.github.com/repos/Alex-Beng/Yap/tags")
let resp = client
.get("https://api.github.com/repos/Alex-Beng/Yap/tags")
.timeout(Duration::from_secs(5))
.header(USER_AGENT, HeaderValue::from_static("reqwest"))
.send().ok()?.json::<Vec<GithubTag>>().ok()?;
.send()
.ok()?
.json::<Vec<GithubTag>>()
.ok()?;

let latest = if resp.is_empty() {
return None
return None;
} else {
resp[0].name.clone()
};
Expand Down

0 comments on commit 971f747

Please sign in to comment.