add and use isWindows helper fn

This commit is contained in:
llama 2025-10-18 09:45:24 +08:00
parent 7048730503
commit c973f0f786
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3
2 changed files with 9 additions and 1 deletions

View file

@ -1,13 +1,16 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { isWindows } from "@tslib/platform";
export interface PostProtoOptions {
/** True by default. Shows a dialog with the error message, then rethrows. */
alertOnError?: boolean;
// whether to use the "anki:" custom protocol or not
customProtocol?: boolean;
}
const CUSTOM_PROTOCOL_URI = (navigator.platform.indexOf("Win") == -1) ? "anki://localhost" : "http://anki.localhost";
const CUSTOM_PROTOCOL_URI = isWindows() ? "http://anki.localhost" : "anki://localhost" ;
export async function postProto<T>(
method: string,

View file

@ -10,6 +10,11 @@ export function isApplePlatform(): boolean {
);
}
export function isWindows(): boolean {
const platform = window.navigator["platform" + ""];
return platform.startsWith("Win");
}
export function isDesktop(): boolean {
return !(/iphone|ipad|ipod|android/i.test(window.navigator.userAgent));
}