feat(desktop): add promotion marquee and proxy fix

This commit is contained in:
leokun
2026-09-04 23:07:41 +08:00
parent 900364229e
commit 8fbbcd5ae9
20 changed files with 145 additions and 154 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ pub(super) const OS_HEADER: &str = "X-Cursor-Assistant-OS";
pub(super) const APP_VERSION_HEADER: &str = "X-Cursor-Assistant-Version";
pub(super) const DISABLED_AD_IDS_HEADER: &str = "disable-ad-ids";
pub(super) const LANGUAGE_HEADER: &str = "accept-language";
const ADS_IMAGE_ROUTE: &str = "/__byok-api__/api/ads/images";
const ADS_IMAGE_ROUTE: &str = "/__byok-api__/api/promotions/images";
const MAX_AD_IMAGE_BYTES: usize = 10 * 1024 * 1024;
const IMAGE_EXTENSIONS: &[&str] = &["png", "jpg", "gif", "webp", "avif"];
+6 -3
View File
@@ -111,10 +111,13 @@ fn proxy_error(error: impl std::fmt::Display) -> Response<Body> {
pub fn api_router(service: ControlService) -> Router {
Router::new()
.route("/__byok-api__/api/ads", get(ads::get))
.route("/__byok-api__/api/ads/images/{file_name}", get(ads::image))
.route("/__byok-api__/api/promotions", get(ads::get))
.route(
"/__byok-api__/api/ads/{ad_id}/dismissals",
"/__byok-api__/api/promotions/images/{file_name}",
get(ads::image),
)
.route(
"/__byok-api__/api/promotions/{ad_id}/dismissals",
post(ads::dismiss),
)
.route(
+2
View File
@@ -5,6 +5,7 @@ use serde_json::Value;
use crate::{Error, Result};
const NO_PROXY_KEY: &str = "http.noProxy";
const KEYS: [&str; 5] = [
"http.proxy",
"http.proxyKerberosServicePrincipal",
@@ -60,6 +61,7 @@ fn write(settings: &BTreeMap<String, Value>) -> Result<()> {
pub fn write_proxy_settings(proxy_url: &str) -> Result<()> {
let mut settings = read()?;
settings.remove(NO_PROXY_KEY);
settings.insert(KEYS[0].into(), Value::String(proxy_url.into()));
settings.insert(KEYS[1].into(), Value::String(proxy_url.into()));
settings.insert(KEYS[2].into(), Value::String("on".into()));