forked from 1b-agent/opencadstudio-upstream
fix: Donate button (Start tab gate + web window.open)
- Add DONATE to the Start-tab command allowlist; it was blocked there with "No drawing open" while REPORT/CHANGELOG/ABOUT were allowed, so the Donate button did nothing on the welcome screen. - Implement sys::open_url on wasm via web_sys window.open(_blank) — it was a no-op stub, so Donate, Release Notes and Send Feedback opened nothing on the web. The click is a user gesture, so the pop-up blocker allows it. Native + web build. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
3dd1276b6a
commit
93d136c5db
4 files changed
+12
-6
No files matched your search
+1
-1
@@ -36,7 +36,7 @@ impl OpenCADStudio {
|
||||
&& !matches!(
|
||||
cmd,
|
||||
"NEW" | "OPEN" | "EXIT" | "QUIT" | "REPORT" | "CHANGELOG" | "ABOUT"
|
||||
| "PLUGINS" | "PLUGINMANAGER"
|
||||
| "PLUGINS" | "PLUGINMANAGER" | "DONATE"
|
||||
)
|
||||
{
|
||||
self.command_line
|
||||
|
||||
+8
-5
@@ -1,17 +1,20 @@
|
||||
// Small platform shims for things the desktop build does natively but the web
|
||||
// (wasm) build must handle differently or skip.
|
||||
|
||||
/// Open a URL in the user's browser. On the desktop this launches the default
|
||||
/// handler; on the web the app already *is* in a browser, so for now this is a
|
||||
/// no-op (a real implementation would call `window.open`).
|
||||
/// Open a URL in the user's browser. The desktop launches the default handler;
|
||||
/// the web opens a new tab (the button click is a user gesture, so it isn't
|
||||
/// caught by the pop-up blocker). Focus of the opened page is left to the
|
||||
/// OS / browser.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn open_url(url: &str) {
|
||||
let _ = open::that(url);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn open_url(_url: &str) {
|
||||
// TODO(web): web_sys::window().open_with_url(_url)
|
||||
pub fn open_url(url: &str) {
|
||||
if let Some(window) = web_sys::window() {
|
||||
let _ = window.open_with_url_and_target(url, "_blank");
|
||||
}
|
||||
}
|
||||
|
||||
/// Turn an `rfd` file handle into a `PathBuf` the rest of the app keys on.
|
||||
|
||||
Reference in new issue
Block a user