This commit is contained in:
2026-09-26 19:30:59 +10:00
commit bf2e0626fd
83 changed files with 13583 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
/**
* Копирование номера телефона в буфер обмена.
* Повторяет поведение assets/java/java.js: на мобильных устройствах
* инициируется звонок, на десктопе номер копируется и показывается
* всплывающее уведомление, исчезающее через секунду.
*/
export function usePhoneCopy() {
const toastVisible = ref(false);
const toastMessage = ref("");
let hideTimer: ReturnType<typeof setTimeout> | undefined;
const showToast = (text: string) => {
toastMessage.value = text;
toastVisible.value = true;
clearTimeout(hideTimer);
hideTimer = setTimeout(() => {
toastVisible.value = false;
}, 1000);
};
const copyPhone = async (number: string, phoneHref: string) => {
const isMobile = /Mobi|Android|iPhone|iPad|iPod/i.test(
navigator.userAgent,
);
if (isMobile) {
window.location.href = phoneHref;
return;
}
try {
await navigator.clipboard.writeText(number);
showToast("Номер скопирован!");
} catch {
// Fallback для браузеров без Clipboard API
const fallbackInput = document.createElement("input");
fallbackInput.value = number;
document.body.appendChild(fallbackInput);
fallbackInput.select();
try {
document.execCommand("copy");
showToast("Номер скопирован!");
} catch {
showToast("Не удалось скопировать.");
}
document.body.removeChild(fallbackInput);
}
};
onBeforeUnmount(() => clearTimeout(hideTimer));
return { toastVisible, toastMessage, copyPhone };
}
+45
View File
@@ -0,0 +1,45 @@
/**
* Анимация появления элементов при прокрутке.
* Полностью повторяет поведение assets/java/java.js: IntersectionObserver
* с порогом 0.15 и отступом снизу -50px добавляет класс «active».
*/
export function useReveal() {
if (import.meta.server) return;
let observer: IntersectionObserver | null = null;
const activateAll = () => {
document
.querySelectorAll(".reveal, .reveal-left, .reveal-right, .reveal-scale")
.forEach((element) => element.classList.add("active"));
};
onMounted(async () => {
await nextTick();
if (typeof IntersectionObserver === "undefined") {
activateAll();
return;
}
observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("active");
}
});
},
{ threshold: 0.15, rootMargin: "0px 0px -50px 0px" },
);
document
.querySelectorAll(".reveal, .reveal-left, .reveal-right, .reveal-scale")
.forEach((element) => observer?.observe(element));
});
onBeforeUnmount(() => {
observer?.disconnect();
observer = null;
});
}