Android: add Shortcut & Wallpaper menu to Game Card's context menu

This commit is contained in:
redphx
2024-10-19 16:53:55 +07:00
parent 63aaca7d61
commit 03efa528c8
4 changed files with 132 additions and 61 deletions

View File

@@ -3,6 +3,7 @@ import { BxIcon } from "@/utils/bx-icon";
import { AppInterface } from "@/utils/global";
import { ButtonStyle, CE, createButton } from "@/utils/html";
import { t } from "@/utils/translation";
import { parseDetailsPath } from "@/utils/utils";
export class ProductDetailsPage {
private static $btnShortcut = AppInterface && createButton({
@@ -20,17 +21,9 @@ export class ProductDetailsPage {
label: t('wallpaper'),
style: ButtonStyle.FOCUSABLE,
tabIndex: 0,
onClick: async e => {
try {
const matches = /\/games\/(?<titleSlug>[^\/]+)\/(?<productId>\w+)/.exec(window.location.pathname);
if (!matches?.groups) {
return;
}
const titleSlug = matches.groups.titleSlug.replaceAll('\%' + '7C', '-');
const productId = matches.groups.productId;
AppInterface.downloadWallpapers(titleSlug, productId);
} catch (e) {}
onClick: e => {
const details = parseDetailsPath(window.location.pathname);
details && AppInterface.downloadWallpapers(details.titleSlug, details.productId);
},
});