Skip to content

Commit b3ec9e1

Browse files
author
李杰
committed
修改切号问题
1 parent bb7c98a commit b3ec9e1

9 files changed

Lines changed: 259 additions & 186 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
| 赞助商 (Sponsor) | 简介 (Description) |
1515
| :---: | :--- |
16-
| **🛒 [https://xiangzili.xyz](https://xiangzili.xyz)** | 作者自营买号地址,提供 Gemini Pro 成品号与 Plus 兑换码;购买账号即送 Antigravity 无感切号方案。感谢大家长期支持,另外如有合适的卡商资源,也欢迎联系我合作。 |
16+
| **🛒 [https://xiangzili.xyz](https://xiangzili.xyz)** | 作者自营买号地址,提供 Gemini Pro 成品号与 Codex Plus 兑换码;购买账号即送 Antigravity 无感切号方案。感谢大家长期支持,另外有号商有合适的账号资源,也欢迎联系我合作。 |
1717

1818
> 本工具旨在帮助用户高效管理多个 AI IDE 账号,支持一键切换、配额监控、自动唤醒与多开实例并行运行,助您充分利用不同账号的资源。
1919

src-tauri/src/modules/announcement.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ pub struct Announcement {
9797
#[serde(rename_all = "camelCase")]
9898
pub struct TopRightAdLocale {
9999
#[serde(default)]
100-
pub title: Option<String>,
101-
#[serde(default)]
102-
pub summary: Option<String>,
100+
pub text: Option<String>,
103101
#[serde(default)]
104102
pub badge: Option<String>,
105103
#[serde(default)]
@@ -112,10 +110,7 @@ pub struct TopRightAd {
112110
pub id: String,
113111
#[serde(default)]
114112
pub priority: i64,
115-
#[serde(default)]
116-
pub title: String,
117-
#[serde(default)]
118-
pub summary: String,
113+
pub text: String,
119114
#[serde(default)]
120115
pub badge: Option<String>,
121116
#[serde(default)]
@@ -486,11 +481,8 @@ fn apply_localized_top_right_ad(ad: &TopRightAd, locale: &str) -> TopRightAd {
486481

487482
if let Some(key) = matched_key {
488483
if let Some(localized_data) = locales.get(key) {
489-
if let Some(title) = &localized_data.title {
490-
localized.title = title.clone();
491-
}
492-
if let Some(summary) = &localized_data.summary {
493-
localized.summary = summary.clone();
484+
if let Some(text) = &localized_data.text {
485+
localized.text = text.clone();
494486
}
495487
if let Some(badge) = &localized_data.badge {
496488
localized.badge = Some(badge.clone());

src-tauri/src/modules/process.rs

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5668,6 +5668,8 @@ pub fn close_antigravity_instances(
56685668
user_data_dirs: &[String],
56695669
timeout_secs: u64,
56705670
) -> Result<(), String> {
5671+
#[cfg(target_os = "windows")]
5672+
let _ = timeout_secs;
56715673
let default_dir = crate::modules::instance::get_default_user_data_dir()
56725674
.ok()
56735675
.map(|value| normalize_path_for_compare(&value.to_string_lossy()))
@@ -5693,15 +5695,95 @@ pub fn close_antigravity_instances(
56935695
default_dir.as_deref(),
56945696
)
56955697
},
5696-
None,
5697-
None,
5698+
Some(request_antigravity_graceful_close as fn(u32)),
5699+
Some(2),
56985700
#[cfg(target_os = "windows")]
56995701
Some(log_antigravity_process_details_for_pids as fn(&[u32])),
57005702
#[cfg(not(target_os = "windows"))]
57015703
None,
57025704
)
57035705
}
57045706

5707+
fn request_antigravity_graceful_close(pid: u32) {
5708+
if pid == 0 || !is_pid_running(pid) {
5709+
return;
5710+
}
5711+
5712+
#[cfg(target_os = "macos")]
5713+
{
5714+
let script = format!(
5715+
"tell application \"System Events\" to set frontmost of (first process whose unix id is {}) to true\n\
5716+
tell application \"System Events\" to keystroke \"q\" using command down",
5717+
pid
5718+
);
5719+
match Command::new("osascript").args(["-e", &script]).output() {
5720+
Ok(output) => {
5721+
if output.status.success() {
5722+
crate::modules::logger::log_info(&format!(
5723+
"[AG Close] 已发送优雅退出请求 pid={}",
5724+
pid
5725+
));
5726+
} else {
5727+
let stderr = String::from_utf8_lossy(&output.stderr);
5728+
crate::modules::logger::log_warn(&format!(
5729+
"[AG Close] 优雅退出失败 pid={} err={}",
5730+
pid,
5731+
stderr.trim()
5732+
));
5733+
}
5734+
}
5735+
Err(err) => {
5736+
crate::modules::logger::log_warn(&format!(
5737+
"[AG Close] 调用 osascript 失败 pid={} err={}",
5738+
pid, err
5739+
));
5740+
}
5741+
}
5742+
}
5743+
5744+
#[cfg(target_os = "windows")]
5745+
{
5746+
use std::os::windows::process::CommandExt;
5747+
5748+
crate::modules::logger::log_info(&format!("[AG Close] graceful taskkill start pid={}", pid));
5749+
let output = Command::new("taskkill")
5750+
.args(["/PID", &pid.to_string(), "/T"])
5751+
.creation_flags(CREATE_NO_WINDOW)
5752+
.stdin(Stdio::null())
5753+
.stdout(Stdio::null())
5754+
.stderr(Stdio::null())
5755+
.output();
5756+
match output {
5757+
Ok(value) => {
5758+
if value.status.success() {
5759+
crate::modules::logger::log_info(&format!(
5760+
"[AG Close] graceful taskkill success pid={} status={}",
5761+
pid, value.status
5762+
));
5763+
} else {
5764+
crate::modules::logger::log_warn(&format!(
5765+
"[AG Close] graceful taskkill failed pid={} status={}",
5766+
pid, value.status
5767+
));
5768+
}
5769+
}
5770+
Err(err) => {
5771+
crate::modules::logger::log_warn(&format!(
5772+
"[AG Close] graceful taskkill error pid={} err={}",
5773+
pid, err
5774+
));
5775+
}
5776+
}
5777+
}
5778+
5779+
#[cfg(target_os = "linux")]
5780+
{
5781+
let _ = Command::new("kill")
5782+
.args(["-15", &pid.to_string()])
5783+
.output();
5784+
}
5785+
}
5786+
57055787
pub fn close_pid(pid: u32, timeout_secs: u64) -> Result<(), String> {
57065788
if pid == 0 {
57075789
return Err("PID 无效,无法关闭进程".to_string());

src/App.css

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,11 @@
123123
letter-spacing: 0.06em;
124124
}
125125

126-
.global-ad-slot-title {
126+
.global-promo-text {
127+
margin: 0;
127128
color: var(--text-primary);
128129
font-size: 12px;
129-
font-weight: 700;
130-
line-height: 1.3;
131-
white-space: nowrap;
132-
flex: 0 0 auto;
133-
max-width: 40%;
134-
overflow: hidden;
135-
text-overflow: ellipsis;
136-
}
137-
138-
.global-promo-desc {
139-
margin: 0;
140-
color: var(--text-secondary);
141-
font-size: 11px;
130+
font-weight: 600;
142131
line-height: 1.3;
143132
white-space: nowrap;
144133
overflow: hidden;
@@ -266,7 +255,7 @@
266255
display: none;
267256
}
268257

269-
.global-promo-desc {
258+
.global-promo-text {
270259
display: none;
271260
}
272261

src/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,8 +2874,7 @@ function MainApp() {
28742874
{topRightAdState.ad.badge || t('common.topRightAd.badge', '广告')}
28752875
</span>
28762876
<div className="global-promo-main">
2877-
<strong className="global-ad-slot-title">{topRightAdState.ad.title}</strong>
2878-
<p className="global-promo-desc">{topRightAdState.ad.summary}</p>
2877+
<p className="global-promo-text">{topRightAdState.ad.text}</p>
28792878
</div>
28802879
{topRightAdState.ad.ctaUrl ? (
28812880
<button className="global-ad-slot-action" onClick={handleTopRightAdClick}>

0 commit comments

Comments
 (0)