mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-06 05:12:03 +08:00
feat(desktop): add promotion marquee and proxy fix
This commit is contained in:
@@ -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"];
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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()));
|
||||
|
||||
Reference in New Issue
Block a user