init
This commit is contained in:
12
frontend/plugins/01.splash-screen.client.ts
Normal file
12
frontend/plugins/01.splash-screen.client.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
import { SplashScreen } from "@capacitor/splash-screen";
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
if (!Capacitor.isNativePlatform()) {
|
||||
return;
|
||||
}
|
||||
|
||||
void SplashScreen.hide().catch(() => {
|
||||
// Ignore hide errors if the native splash is already gone.
|
||||
});
|
||||
});
|
||||
5
frontend/plugins/auth-init.client.ts
Normal file
5
frontend/plugins/auth-init.client.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default defineNuxtPlugin(async () => {
|
||||
const { refreshMe } = useAuth();
|
||||
await refreshMe();
|
||||
});
|
||||
|
||||
9
frontend/plugins/native-push.client.ts
Normal file
9
frontend/plugins/native-push.client.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default defineNuxtPlugin(async () => {
|
||||
const { initializeNativePush, isNativeApp } = usePush();
|
||||
|
||||
if (!isNativeApp()) {
|
||||
return;
|
||||
}
|
||||
|
||||
await initializeNativePush();
|
||||
});
|
||||
15
frontend/plugins/primevue.client.ts
Normal file
15
frontend/plugins/primevue.client.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import Aura from "@primeuix/themes/aura";
|
||||
import PrimeVue from "primevue/config";
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
nuxtApp.vueApp.use(PrimeVue, {
|
||||
theme: {
|
||||
preset: Aura,
|
||||
options: {
|
||||
darkModeSelector: ".app-dark"
|
||||
}
|
||||
},
|
||||
ripple: true,
|
||||
inputVariant: "filled"
|
||||
});
|
||||
});
|
||||
20
frontend/plugins/push-context.client.ts
Normal file
20
frontend/plugins/push-context.client.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export default defineNuxtPlugin(async () => {
|
||||
const { token } = useAuth();
|
||||
const anonymousClientId = useState<string | null>("anonymous-push-client-id", () => null);
|
||||
const { syncServiceWorkerContext, syncNativeSubscription, isNativeApp } = usePush();
|
||||
|
||||
if (isNativeApp()) {
|
||||
await syncNativeSubscription();
|
||||
} else {
|
||||
await syncServiceWorkerContext();
|
||||
}
|
||||
|
||||
watch([token, anonymousClientId], () => {
|
||||
if (isNativeApp()) {
|
||||
void syncNativeSubscription();
|
||||
return;
|
||||
}
|
||||
|
||||
void syncServiceWorkerContext();
|
||||
});
|
||||
});
|
||||
23
frontend/plugins/pwa.client.ts
Normal file
23
frontend/plugins/pwa.client.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
export default defineNuxtPlugin(async () => {
|
||||
const { setInstallPromptEvent, isNativeApp } = usePush();
|
||||
|
||||
if (isNativeApp()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ("serviceWorker" in navigator) {
|
||||
await navigator.serviceWorker.register("/sw.js");
|
||||
}
|
||||
|
||||
window.addEventListener("beforeinstallprompt", (event) => {
|
||||
event.preventDefault();
|
||||
setInstallPromptEvent(event as Event & {
|
||||
prompt: () => Promise<void>;
|
||||
userChoice: Promise<{ outcome: "accepted" | "dismissed"; platform: string }>;
|
||||
});
|
||||
});
|
||||
|
||||
window.addEventListener("appinstalled", () => {
|
||||
setInstallPromptEvent(null);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user