convert mih web app from JS to WASm
This commit is contained in:
parent
eb213b01b6
commit
f9c71b656e
17 changed files with 78 additions and 127 deletions
3
mih_ui/lib/mih_helpers/mih_install_stub.dart
Normal file
3
mih_ui/lib/mih_helpers/mih_install_stub.dart
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
void triggerWebInstall() {
|
||||
// Safe no-op on Linux/Mobile
|
||||
}
|
||||
13
mih_ui/lib/mih_helpers/mih_install_web.dart
Normal file
13
mih_ui/lib/mih_helpers/mih_install_web.dart
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import 'dart:js_interop';
|
||||
|
||||
@JS('promptInstall')
|
||||
external void jsPromptInstall();
|
||||
|
||||
@JS('isInstallPromptAvailable')
|
||||
external bool jsIsInstallPromptAvailable();
|
||||
|
||||
void triggerWebInstall() {
|
||||
if (jsIsInstallPromptAvailable()) {
|
||||
jsPromptInstall();
|
||||
}
|
||||
}
|
||||
8
mih_ui/lib/mih_helpers/mih_utils_stub.dart
Normal file
8
mih_ui/lib/mih_helpers/mih_utils_stub.dart
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Create this file anywhere, e.g., lib/mih_config/mih_web_utils_stub.dart
|
||||
void openWebWindow(String url, [String? target]) {
|
||||
// Safe no-op or fallback on Linux (e.g., could use url_launcher if needed)
|
||||
}
|
||||
|
||||
bool isWebStandalone() {
|
||||
return false; // Always false on native Linux app
|
||||
}
|
||||
13
mih_ui/lib/mih_helpers/mih_utils_web.dart
Normal file
13
mih_ui/lib/mih_helpers/mih_utils_web.dart
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import 'package:web/web.dart' as web;
|
||||
|
||||
void openWebWindow(String url, [String? target]) {
|
||||
if (target != null) {
|
||||
web.window.open(url, target);
|
||||
} else {
|
||||
web.window.open(url);
|
||||
}
|
||||
}
|
||||
|
||||
bool isWebStandalone() {
|
||||
return web.window.matchMedia('(display-mode: standalone)').matches;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue