route work
This commit is contained in:
@@ -303,3 +303,28 @@ pub fn debug_backtrace() -> String {
|
||||
let bt = backtrace::Backtrace::new();
|
||||
format!("{:?}", bt)
|
||||
}
|
||||
|
||||
pub fn debug_print_backtrace() {
|
||||
if is_debug_backtrace_enabled() {
|
||||
debug!("{}", debug_backtrace());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_debug_backtrace_enabled() -> bool {
|
||||
cfg_if! {
|
||||
if #[cfg(debug_assertions)] {
|
||||
cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
let rbenv = get_wasm_global_string_value("RUST_BACKTRACE").unwrap_or_default();
|
||||
}
|
||||
else
|
||||
{
|
||||
let rbenv = std::env::var("RUST_BACKTRACE").unwrap_or_default();
|
||||
}
|
||||
}
|
||||
rbenv == "1" || rbenv == "full"
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ pub fn is_browser() -> bool {
|
||||
return cache != 0;
|
||||
}
|
||||
|
||||
let res = Reflect::has(&global().as_ref(), &"window".into()).unwrap_or_default();
|
||||
let res = Reflect::has(&global().as_ref(), &"navigator".into()).unwrap_or_default();
|
||||
|
||||
CACHE.store(res as i8, Ordering::Relaxed);
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn is_browser_https() -> bool {
|
||||
return cache != 0;
|
||||
}
|
||||
|
||||
let res = js_sys::eval("window.location.protocol === 'https'")
|
||||
let res = js_sys::eval("self.location.protocol === 'https'")
|
||||
.map(|res| res.is_truthy())
|
||||
.unwrap_or_default();
|
||||
|
||||
@@ -44,6 +44,13 @@ pub fn is_browser_https() -> bool {
|
||||
res
|
||||
}
|
||||
|
||||
pub fn get_wasm_global_string_value<K: AsRef<str>>(key: K) -> Option<String> {
|
||||
let Ok(v) = Reflect::get(&global().as_ref(), &JsValue::from_str(key.as_ref())) else {
|
||||
return None;
|
||||
};
|
||||
v.as_string()
|
||||
}
|
||||
|
||||
#[derive(ThisError, Debug, Clone, Eq, PartialEq)]
|
||||
#[error("JsValue error")]
|
||||
pub struct JsValueError(String);
|
||||
|
Reference in New Issue
Block a user