Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Vue CLI остаётся на последнем опубликованном в

## iframe и профиль Твой ФФ

Параметры `token`, `user_id`, `scopes` читаются из URL по примеру [rental-ui](https://github.com/profcomff/rental-ui/blob/main/src/store/profileStore.ts). Они сохраняются при внутренних переходах. Собственная шапка отсутствует, чтобы не дублировать шапку Твой ФФ. Область мини-приложения ограничена высотой iframe: содержимое прокручивается отдельно, а переключение печати и истории занимает постоянную нижнюю строку вне прокрутки. Если установленная оболочка обрезает iframe, высота и положение приложения подстраиваются под его видимую область через `IntersectionObserver`, без доступа к DOM родительского сайта. Это сохраняет доступ к меню в мобильных WebView; панель выбора файлов остаётся над ним, учитывается безопасная зона экрана.
Параметры `token`, `user_id`, `scopes` читаются из URL по примеру [rental-ui](https://github.com/profcomff/rental-ui/blob/main/src/store/profileStore.ts). Они сохраняются при внутренних переходах. Собственная шапка отсутствует, чтобы не дублировать шапку Твой ФФ. Переключение печати и истории расположено над содержимым в обычном потоке страницы, без закрепления у края экрана. Главная страница сразу показывает форму загрузки PDF без вводного заголовка.

Если передан токен, числовой `user_id` и хотя бы одно право `userdata.category.personal.read` / `userdata.category.credentials.read`, приложение автоматически запрашивает `GET /userdata/user/{id}` на том же API-хосте, что и сервис печати. Полученные поля `Личная информация / Полное имя` и `Учетные данные / Номер профсоюзного билета` заполняются по отдельности. Фамилия предлагается как первое слово ФИО и остаётся редактируемой. Уже начатый ввод не перезаписывается. При отсутствии данных или ошибке профиля остаётся ручной ввод. При доступной сессии профиля сохранённые реквизиты другого пользователя не подставляются.

Expand Down
91 changes: 18 additions & 73 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,64 +1,11 @@
<script setup lang="ts">
import {
ref,
watch,
onMounted,
onBeforeUnmount,
type CSSProperties,
} from "vue";
import { watch } from "vue";
import { useRoute } from "vue-router";
import AppIcon from "@/components/AppIcon.vue";
const route = useRoute();
const content = ref<HTMLElement | null>(null);
const visibleViewport = ref<CSSProperties>({});
let viewportObserver: IntersectionObserver | undefined;
let viewportRefresh: number | undefined;
function stopViewportRefresh() {
window.clearInterval(viewportRefresh);
viewportRefresh = undefined;
}
onMounted(() => {
if (window.self === window.top) return;
// The host may clip a cross-origin iframe. Its innerHeight still includes
// the clipped area; intersectionRect describes the part actually on screen.
viewportObserver = new IntersectionObserver(
([entry]) => {
if (!entry?.isIntersecting || entry.intersectionRect.height < 1) {
stopViewportRefresh();
return;
}
const visible = entry.intersectionRect;
const full = entry.boundingClientRect;
const clipped = visible.height < full.height - 1;
visibleViewport.value = !clipped
? {}
: {
height: `${Math.floor(visible.height)}px`,
marginTop: `${Math.max(0, Math.ceil(visible.top - full.top))}px`,
};
if (!clipped) stopViewportRefresh();
else if (viewportRefresh === undefined) {
// ponytail: recheck clipped cross-origin viewports at 5 Hz; replace
// with host viewport messages if the embedding app supplies them.
viewportRefresh = window.setInterval(() => {
viewportObserver?.unobserve(document.documentElement);
viewportObserver?.observe(document.documentElement);
}, 200);
}
},
{ threshold: [0, 1] },
);
// Observe the full document, whose size is independent of the adjusted shell.
viewportObserver.observe(document.documentElement);
});
onBeforeUnmount(() => {
viewportObserver?.disconnect();
stopViewportRefresh();
});
watch(
() => route.path,
() => {
content.value?.scrollTo({ top: 0 });
document.dispatchEvent(
new CustomEvent("change-header-layout", {
detail: {
Expand All @@ -69,28 +16,12 @@ watch(
}),
);
},
{ immediate: true, flush: "post" },
{ immediate: true },
);
</script>
<template>
<main class="app-shell" :style="visibleViewport">
<div ref="content" class="app-content">
<router-view />
<footer>
Бесплатная печать для членов профсоюза
<span>PDF · чёрно-белая печать</span>
<div>
Сделано в
<a
href="https://dyakov.space/"
target="_blank"
rel="noopener noreferrer"
>dyakov.space</a
>
</div>
</footer>
</div>
<nav class="bottom-nav" aria-label="Разделы печати">
<main class="app-shell">
<nav class="tabs" aria-label="Разделы печати">
<router-link
:to="{ path: '/', query: route.query }"
:class="{ active: route.path !== '/history' }"
Expand All @@ -102,5 +33,19 @@ watch(
><AppIcon name="history" />История</router-link
>
</nav>
<router-view />
<footer>
Бесплатная печать для членов профсоюза
<span>PDF · чёрно-белая печать</span>
<div>
Сделано в
<a
href="https://dyakov.space/"
target="_blank"
rel="noopener noreferrer"
>dyakov.space</a
>
</div>
</footer>
</main>
</template>
45 changes: 13 additions & 32 deletions src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
* {
box-sizing: border-box;
}
html,
body,
#app {
height: 100%;
overflow: hidden;
}
body {
margin: 0;
}
Expand Down Expand Up @@ -84,33 +78,20 @@ a {
border-radius: 5px;
}
.app-shell {
display: flex;
flex-direction: column;
width: 100%;
max-width: 620px;
height: 100%;
margin: 0 auto;
padding: 20px 22px 24px;
}
.app-content {
flex: 1;
min-height: 0;
overflow-y: auto;
overscroll-behavior-y: contain;
padding: 24px 22px;
}
.bottom-nav {
flex-shrink: 0;
width: 100%;
.tabs {
display: flex;
gap: 8px;
padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
margin-bottom: 20px;
padding: 4px;
border: 1px solid var(--border);
border-bottom: 0;
border-radius: 16px 16px 0 0;
border-radius: 13px;
background: #fff;
box-shadow: 0 -4px 18px #26344c08;
}
.bottom-nav a {
.tabs a {
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -124,11 +105,11 @@ a {
font-size: 14px;
font-weight: 600;
}
.bottom-nav a.active {
.tabs a.active {
background: var(--soft);
color: var(--accent);
}
.bottom-nav svg {
.tabs svg {
width: 18px;
height: 18px;
}
Expand Down Expand Up @@ -413,7 +394,7 @@ progress {
color: #6f8199;
background: #fff;
}
.app-content > footer {
.app-shell > footer {
border-top: 1px solid var(--border);
margin-top: 28px;
padding-top: 18px;
Expand All @@ -422,11 +403,11 @@ progress {
font-size: 10px;
line-height: 1.8;
}
.app-content > footer span {
.app-shell > footer span {
display: block;
font-size: 9px;
}
.app-content > footer div {
.app-shell > footer div {
margin-top: 8px;
}
.result-card {
Expand Down Expand Up @@ -699,8 +680,8 @@ input[type="checkbox"] {
}
}
@media (max-width: 440px) {
.app-content {
padding: 20px 14px 24px;
.app-shell {
padding: 16px 14px 24px;
}
.card {
padding: 20px;
Expand Down
5 changes: 0 additions & 5 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ onMounted(log_open_app);
@click_return="pin = ''"
/>
<section v-else>
<div class="page-heading">
<span class="eyebrow">Всё начинается с файла</span>
<h1>Что распечатаем?</h1>
<p>Загрузите PDF, а затем заберите распечатку у принтера.</p>
</div>
<SendTaskDialog @uploaded="uploaded" />
<aside class="how-it-works">
<h2>Как это работает</h2>
Expand Down
Loading
Loading