From 298960f4dd5c54815e8e999d1e41ce4219904cb9 Mon Sep 17 00:00:00 2001 From: Kainoa Kanter Date: Thu, 11 May 2023 18:59:42 -0700 Subject: [PATCH] add (back) pwa install button to help menu --- locales/en-US.yml | 2 +- locales/ja-JP.yml | 1 + package.json | 2 +- packages/client/package.json | 1 + .../src/components/MkTutorialDialog.vue | 13 +++++ packages/client/src/scripts/helpMenu.ts | 9 ++++ .../src/ui/_common_/navbar-for-mobile.vue | 2 + packages/client/src/ui/_common_/navbar.vue | 2 + pnpm-lock.yaml | 53 +++++++++++++++++++ 9 files changed, 83 insertions(+), 2 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index bd32c836ac..a7ea78a72c 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1085,7 +1085,7 @@ apps: "Apps" sendModMail: "Send Moderation Notice" preventAiLearning: "Prevent AI bot scraping" preventAiLearningDescription: "Request third-party AI language models not to study content you upload, such as posts and images." - +pwa: "Install PWA" _sensitiveMediaDetection: description: "Reduces the effort of server moderation through automatically recognizing\ diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 4fc2f42d79..445d839b3e 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -975,6 +975,7 @@ customKaTeXMacroDescription: "数式入力を楽にするためのマクロを enableCustomKaTeXMacro: "カスタムKaTeXマクロを有効にする" preventAiLearning: "AIによる学習を防止" preventAiLearningDescription: "投稿したノート、添付した画像などのコンテンツを学習の対象にしないようAIに要求します。これはnoaiフラグをHTMLレスポンスに含めることによって実現されます。" +pwa: "PWAをインストール" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てられます。サーバーの負荷が少し増えます。" diff --git a/package.json b/package.json index 8aaa427a13..74c9506cfe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "14.0.0-dev8", + "version": "14.0.0-dev9", "codename": "aqua", "repository": { "type": "git", diff --git a/packages/client/package.json b/packages/client/package.json index 69346651d8..1735855037 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -9,6 +9,7 @@ }, "devDependencies": { "@discordapp/twemoji": "14.0.2", + "@khmyznikov/pwa-install": "^0.2.0", "@phosphor-icons/web": "^2.0.3", "@rollup/plugin-alias": "3.1.9", "@rollup/plugin-json": "4.1.0", diff --git a/packages/client/src/components/MkTutorialDialog.vue b/packages/client/src/components/MkTutorialDialog.vue index eafc882950..8fecc44294 100644 --- a/packages/client/src/components/MkTutorialDialog.vue +++ b/packages/client/src/components/MkTutorialDialog.vue @@ -180,6 +180,13 @@ primary show-only-to-register /> + + {{ i18n.ts.pwa }} @@ -201,6 +208,7 @@ import { defaultStore } from "@/store"; import { i18n } from "@/i18n"; import { $i } from "@/account"; import { instance } from "@/instance"; +import "@khmyznikov/pwa-install"; const isLocalTimelineAvailable = !instance.disableLocalTimeline || @@ -243,6 +251,11 @@ const tutorial = computed({ }, }); +function installPwa(ev: MouseEvent) { + const pwaInstall = document.getElementsByTagName("pwa-install")[0]; + pwaInstall.showDialog(); +} + function close(res) { tutorial.value = -1; dialog.close(); diff --git a/packages/client/src/scripts/helpMenu.ts b/packages/client/src/scripts/helpMenu.ts index 81e0a08ec6..c630d5a1b0 100644 --- a/packages/client/src/scripts/helpMenu.ts +++ b/packages/client/src/scripts/helpMenu.ts @@ -4,6 +4,7 @@ import { host } from "@/config"; import * as os from "@/os"; import XTutorial from "../components/MkTutorialDialog.vue"; import { i18n } from "@/i18n"; +import "@khmyznikov/pwa-install"; export function openHelpMenu_(ev: MouseEvent) { os.popupMenu( @@ -24,6 +25,14 @@ export function openHelpMenu_(ev: MouseEvent) { icon: "ph-lightbulb ph-bold ph-lg", to: "/about-calckey", }, + { + type: "button", + text: i18n.ts.pwa, + icon: "ph-export ph-bold ph-lg", + action: () => { + document.getElementsByTagName("pwa-install")[0].showDialog(); + } + }, { type: "button", text: i18n.ts.apps, diff --git a/packages/client/src/ui/_common_/navbar-for-mobile.vue b/packages/client/src/ui/_common_/navbar-for-mobile.vue index 39abb7c261..9ea373025b 100644 --- a/packages/client/src/ui/_common_/navbar-for-mobile.vue +++ b/packages/client/src/ui/_common_/navbar-for-mobile.vue @@ -105,6 +105,7 @@ {{ i18n.ts.note }} + +