Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbb750a413 | ||
|
|
7fb3d6cfa4 | ||
|
|
c15742ff2a | ||
|
|
336dbefe74 | ||
|
|
5c773841f7 | ||
|
|
94decd674c | ||
|
|
72909fd3b2 | ||
|
|
785f64a72e | ||
|
|
daa1c3f007 | ||
|
|
87315d9679 | ||
|
|
fe30c4f1f9 | ||
|
|
ae1f312e84 | ||
|
|
ed91735b2b | ||
|
|
5776b7c0d2 | ||
|
|
2e099ecafa | ||
|
|
d80db29a02 | ||
|
|
8e9e5eeff2 | ||
|
|
4b67c94494 | ||
|
|
f20578a552 | ||
|
|
ae1e81d8d8 | ||
|
|
4d85f09003 | ||
|
|
6bd2106f3d | ||
|
|
5f5803c9f8 | ||
|
|
04ab9f767b | ||
|
|
e93de2beea | ||
|
|
9f314582c0 | ||
|
|
fcf61012db | ||
|
|
d9bce4de04 | ||
|
|
5784036eb1 | ||
|
|
e89932fc7d | ||
|
|
31826f1098 | ||
|
|
5746bf35a5 | ||
|
|
cb5ee9b672 | ||
|
|
7c5fa8f869 | ||
|
|
b592680006 | ||
|
|
e5f1ff34ed | ||
|
|
6a1467e864 | ||
|
|
205b655d00 | ||
|
|
b1d9b40def | ||
|
|
610a7e4dbf | ||
|
|
0d2edcab3d | ||
|
|
5b4efd20c0 | ||
|
|
67c69208c4 | ||
|
|
23cdfb010d | ||
|
|
3cfa52ffc9 | ||
|
|
75b4ddd598 | ||
|
|
ae5a2133fa | ||
|
|
6675a55957 | ||
|
|
4bdd0139bf | ||
|
|
df392eb647 | ||
|
|
5aaa3435da | ||
|
|
0f80d4db4e | ||
|
|
4a0cb46734 | ||
|
|
d5c1bfac64 | ||
|
|
affbd00157 | ||
|
|
e39a5c70c0 | ||
|
|
c80d13744d | ||
|
|
5994b94406 | ||
|
|
a1af85dd72 | ||
|
|
ffdedc7b9b | ||
|
|
289ac4958d | ||
|
|
a07ae9b264 | ||
|
|
dd0bf8b493 | ||
|
|
5ca4694c2b | ||
|
|
89581e1ba8 | ||
|
|
2aa3e4106c | ||
|
|
08f0ca0df1 | ||
|
|
fa29331c1c | ||
|
|
a98663691d | ||
|
|
cc1391bb7d | ||
|
|
b00f93d262 | ||
|
|
4c9dd86962 | ||
|
|
3131c1f905 | ||
|
|
c560f8ae1b | ||
|
|
cf5fb43377 | ||
|
|
5a9b3ad273 | ||
|
|
1c499f42ec | ||
|
|
61ebc66127 | ||
|
|
c232c1bf12 | ||
|
|
2d5f49c32e | ||
|
|
0c50acddd9 |
No files matched your search
@@ -42,3 +42,9 @@ target/
|
|||||||
generateBanner
|
generateBanner
|
||||||
# Million Lint
|
# Million Lint
|
||||||
.million
|
.million
|
||||||
|
|
||||||
|
# TypeScript incremental build cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# local multi-client test profiles
|
||||||
|
.clients/
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
# Blink Remote Control + SyncPlay Plan
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
логин root пароль 12345
|
||||||
|
сервер https://jel.midns.ru
|
||||||
|
|
||||||
|
Make remote control and SyncPlay predictable for Blink clients only:
|
||||||
|
|
||||||
|
- Remote control lists only `Client = Blink` sessions, with readable device names.
|
||||||
|
- Quick transfer of the current media to any selected Blink device.
|
||||||
|
- Media takeover cards for taking playback from another Blink device.
|
||||||
|
- SyncPlay groups are Blink groups; add an auto-group for all running Blink clients.
|
||||||
|
- Keep group playback as close to frame-accurate as the Jellyfin SyncPlay protocol allows.
|
||||||
|
- Redesign all remote/session cards with a glass surface, clear hierarchy and motion.
|
||||||
|
|
||||||
|
## Constraints
|
||||||
|
|
||||||
|
- Do not expose non-Blink Jellyfin sessions in remote control or SyncPlay UI.
|
||||||
|
- Do not rely on `GroupInfoDto.Participants` for device names: the server stores
|
||||||
|
distinct user names there, not device names or sessions.
|
||||||
|
- Device identity must be stable per installation and readable by humans.
|
||||||
|
- Multi-client testing should use the same Jellyfin user, like a household setup.
|
||||||
|
|
||||||
|
## Workstreams
|
||||||
|
|
||||||
|
### 1. Blink identity and shared session utilities
|
||||||
|
|
||||||
|
- Add a device identity helper: stable id, readable name
|
||||||
|
(`Blink · Windows · 4F2A`), optional local override.
|
||||||
|
- Set `deviceInfo.name` from that helper so Jellyfin reports a useful
|
||||||
|
`DeviceName` for every Blink client.
|
||||||
|
- Add a local "device name" field in Settings → Preferences.
|
||||||
|
- Add shared helpers:
|
||||||
|
- `isBlinkSession`
|
||||||
|
- `getBlinkSessions(sessions, { userId, selfDeviceId })`
|
||||||
|
- `getBlinkDeviceName`
|
||||||
|
- `getBlinkDeviceKind`
|
||||||
|
- Blink group marker/prefix and predicate.
|
||||||
|
|
||||||
|
### 2. Remote control: Blink only + quick transfer
|
||||||
|
|
||||||
|
- Shared `useBlinkSessions` hook: realtime WebSocket snapshot first, API poll as
|
||||||
|
fallback. Filters by `Client=Blink`, same user, excludes the local device.
|
||||||
|
- Use the shared filter in:
|
||||||
|
- titlebar cast dialog
|
||||||
|
- remote page
|
||||||
|
- audio player device menu / remote bar
|
||||||
|
- FollowMe takeover prompt
|
||||||
|
- legacy playback sync
|
||||||
|
- `CastButton` without explicit media uses the current local media
|
||||||
|
(video/audio item, queue, position, paused state).
|
||||||
|
- Redesign the cast dialog:
|
||||||
|
- "Сейчас играет" media preview.
|
||||||
|
- Blink device cards.
|
||||||
|
- One-click "Отправить сюда".
|
||||||
|
- "Забрать сюда" when the target is playing.
|
||||||
|
- "Открыть пульт" for full control.
|
||||||
|
|
||||||
|
### 3. Remote page: full control
|
||||||
|
|
||||||
|
- Blink-only device list with proper names.
|
||||||
|
- Glass session cards: device, status, now playing, progress.
|
||||||
|
- Add actions missing today:
|
||||||
|
- take remote playback here
|
||||||
|
- send current local media to the selected device
|
||||||
|
- stop remote playback
|
||||||
|
- audio track selection (alongside subtitles)
|
||||||
|
- volume/mute, seek, play/pause, next/prev, fullscreen
|
||||||
|
- open SyncPlay group controls from the remote page
|
||||||
|
- Motion: card lift, progress animation, active-device glow.
|
||||||
|
|
||||||
|
### 4. SyncPlay: Blink groups + auto-group
|
||||||
|
|
||||||
|
- Group name prefix `Blink ·`; only prefixed groups are listed and joinable.
|
||||||
|
- Create groups with the prefix hidden from the visible name.
|
||||||
|
- Auto-group:
|
||||||
|
- name `Blink · Автогруппа`
|
||||||
|
- host can create/join with one click
|
||||||
|
- other Blink clients auto-join when the setting is enabled (default on)
|
||||||
|
- host can optionally share the current queue at the same time
|
||||||
|
- SyncPlay dialog shows online Blink devices by name and uses Blink-only
|
||||||
|
groups.
|
||||||
|
- `GroupInfoDto.Participants` is shown as users, never as devices.
|
||||||
|
- Avoid the old "participants <= 1 => force resume" shortcut when other Blink
|
||||||
|
devices are online; let the server's group-wait complete.
|
||||||
|
|
||||||
|
### 5. Maximum SyncPlay synchronization
|
||||||
|
|
||||||
|
- Measure real ping (EMA of SyncPlay ping round-trip) instead of a fixed 50 ms.
|
||||||
|
- Only report `Ready` once local playback is actually ready (video ready and not
|
||||||
|
buffering; audio element has enough data).
|
||||||
|
- Reduce drift tolerance to the server's practical sync window (~500 ms) and
|
||||||
|
keep seek throttling.
|
||||||
|
- Keep assistant controllers: pings every 3 s, ready retry only while waiting.
|
||||||
|
- Do not auto-resume a group before other online Blink clients are ready.
|
||||||
|
|
||||||
|
### 6. Glass takeover cards + animations
|
||||||
|
|
||||||
|
- Shared `SessionCard` component for remote dialog, remote page and device
|
||||||
|
lists.
|
||||||
|
- Glass surface: translucent gradient, 1 px highlight border, blur, depth
|
||||||
|
shadow, poster-driven accent.
|
||||||
|
- States: selected, playing, paused, idle, unsupported.
|
||||||
|
- Motion: entrance stagger, hover lift, press scale, progress transition,
|
||||||
|
active pulse.
|
||||||
|
- FollowMe takeover prompt uses the same glass language.
|
||||||
|
|
||||||
|
### 7. Testing with 2-3 clients
|
||||||
|
|
||||||
|
- Launch the current dev build as 2 extra WebView2 profiles, each with its own
|
||||||
|
localStorage device id; share the same Jellyfin user/token.
|
||||||
|
- Verify:
|
||||||
|
1. all three appear as `Client=Blink` with distinct readable names
|
||||||
|
2. remote dialog lists only Blink devices
|
||||||
|
3. screenshot/internal API check of the glass cards
|
||||||
|
4. send current media from client 1 to client 2; verify client 2 starts at
|
||||||
|
the same position and client 1 stops
|
||||||
|
5. take media back to client 1; verify client 2 stops
|
||||||
|
6. create auto-group from client 1; clients 2/3 join automatically
|
||||||
|
7. share queue; all three play the same item; compare positions/drift
|
||||||
|
8. pause/resume/seek from client 1; verify clients 2/3 follow
|
||||||
|
9. verify non-Blink sessions/groups are not shown
|
||||||
|
- Record results in the final report.
|
||||||
|
|
||||||
|
## Definition of done
|
||||||
|
|
||||||
|
- `tsc --noEmit` and `pnpm build` pass.
|
||||||
|
- No non-Blink session or group appears in remote/SyncPlay UI.
|
||||||
|
- Three-device test passes for transfer, takeover, auto-group and
|
||||||
|
pause/resume/seek synchronization.
|
||||||
|
- Final short report with issue count and serious fixes.
|
||||||
|
|
||||||
|
## Verification results (2026-12-02)
|
||||||
|
|
||||||
|
Stand: three Blink clients on one Windows machine (`2346`, `5A33`, `1959`),
|
||||||
|
one Jellyfin user, dev build, server `https://jel.midns.ru`.
|
||||||
|
|
||||||
|
| Scenario | Result |
|
||||||
|
| --- | --- |
|
||||||
|
| Blink-only filters and names | Jellyfin Web / other sessions never shown; devices appear as `Blink · Windows · XXXX` |
|
||||||
|
| Send current media to another client | Target starts at the same position with the shared queue; source stops |
|
||||||
|
| Take playback back | Target stops, initiator resumes at the transferred position |
|
||||||
|
| Auto-group with all three clients | Clients join in 1–3 s; no 30 s `Waiting` timeout |
|
||||||
|
| Group queue start | `Playing` within ~1 s, positions 0.00/0.00/0.00 (spread ≤ 0.02 s) |
|
||||||
|
| Pause | `Paused` within ~1 s, all at the same position (spread 0.00 s) |
|
||||||
|
| Resume | Server schedules the unpause by ping (≈2 s in this setup), spread 0.01 s |
|
||||||
|
| Seek to 05:00 | `Waiting → Playing`, final spread 0.02–0.03 s at 306.3 s |
|
||||||
|
| Non-Blink groups | Not listed, not joinable |
|
||||||
|
|
||||||
|
### Serious fixes found by the three-client test
|
||||||
|
|
||||||
|
1. **Buffer end was reported as another Buffer request.** The Jellyfin server
|
||||||
|
treats any Buffer request as “this session is buffering”, so every client
|
||||||
|
that finished buffering was marked buffering again. Buffer end now sends
|
||||||
|
`Ready`, as jellyfin-web does.
|
||||||
|
2. **Parking tolerance was 30 ms instead of 400 ms.** While waiting for a new
|
||||||
|
queue, clients seeked every second against a 30 ms threshold and never sent
|
||||||
|
`Ready`; the group only started via the server’s 30 s timeout. The threshold
|
||||||
|
is now 400 ms, below the server’s 500 ms acceptance window.
|
||||||
|
3. **Paused position was read from a stale store value.** `playerState.currentTime`
|
||||||
|
only updates on `timeupdate`, which can stand still while paused, so seeks
|
||||||
|
looked unapplied. Position now comes from the `<video>` element directly.
|
||||||
|
4. **Seek was extrapolated as if playing.** After a group seek the server stays
|
||||||
|
in `Waiting` at the seek position; the client kept adding elapsed time,
|
||||||
|
making the server chase a moving target. A Seek now freezes the timeline at
|
||||||
|
the target and pauses locally until the group unpause.
|
||||||
|
5. **State updates resumed/paused clients immediately.** That bypassed the
|
||||||
|
server’s scheduled `When`, so each client started at a different instant.
|
||||||
|
Only Pause/Unpause/Seek commands drive playback now; the state update is
|
||||||
|
informational.
|
||||||
|
6. **Local parking echoed Pause/Seek/Buffer requests.** Pausing a client to
|
||||||
|
park it looked like a user request and flipped the group to `Paused` or
|
||||||
|
restarted the wait. Parking is guarded, and pause/resume/seek/buffer reports
|
||||||
|
are suppressed while the group is parking.
|
||||||
|
7. **Readiness waited for `HAVE_CURRENT_DATA`/`onReady`.** A player parked
|
||||||
|
before its first frame could stay at metadata only, so it never reported
|
||||||
|
ready and the group waited 30 s. Readiness now accepts loaded metadata
|
||||||
|
(`readyState >= 1`), which is enough to start in sync.
|
||||||
|
8. **Command timeline.** Pause/Unpause/Seek positions are now anchored to the
|
||||||
|
server’s `When` + `PositionTicks` and reset on every play-queue update,
|
||||||
|
instead of extrapolating from a stale queue snapshot.
|
||||||
|
9. **Auto-group start window.** Auto-join polling is 2 s and, when other Blink
|
||||||
|
devices are online, sharing the queue waits 2.2 s so they join before the
|
||||||
|
first unpause instead of joining mid-playback.
|
||||||
|
|
||||||
|
`pnpm exec tsc --noEmit` and `pnpm build` pass after these changes.
|
||||||
|
|
||||||
|
## Audio, transfers and group edge cases (2026-12-02, follow-up)
|
||||||
|
|
||||||
|
### Additional fixes
|
||||||
|
|
||||||
|
1. **Audio playback was invisible to Jellyfin.** The `<audio>` element played
|
||||||
|
locally but never sent `reportPlaybackStart/Progress/Stopped`. As a result
|
||||||
|
`/Sessions` stayed empty, so audio could not be cast, taken over, followed or
|
||||||
|
synchronised. Audio now reports start, progress (10 s), pause and stop; the
|
||||||
|
session shows the track and position like a video.
|
||||||
|
2. **A group was moving unrelated local music.** Group `Seek`/`Pause`/`Unpause`
|
||||||
|
commands and drift correction were applied to whatever media the client was
|
||||||
|
playing. Starting music while a group video was running made the server seek
|
||||||
|
the track to the video position: the song jumped to its end, ended and
|
||||||
|
restarted every couple of seconds. Commands now only touch the group's
|
||||||
|
current item; other local media is ignored.
|
||||||
|
3. **Starting media echoed a Pause into the group.** Pausing the old video when
|
||||||
|
music starts looked like a user Pause request. A short media-switch guard
|
||||||
|
suppresses Pause/Seek/Buffer reports while audio and video swap.
|
||||||
|
4. **A client playing local media held the whole group.** Such a client is now
|
||||||
|
marked with `IgnoreWait` on the server, and the mark is cleared when it
|
||||||
|
returns to the group item. The group no longer waits 30 s for a member that
|
||||||
|
deliberately switched to music; its own playback is unaffected.
|
||||||
|
5. **Transfers stopped the source before the target had started.** `playOnSession`
|
||||||
|
now waits until the target session reports the requested item (up to two
|
||||||
|
attempts), then corrects its position. If the target never starts, the
|
||||||
|
mutation fails and the source keeps playing instead of stopping everywhere.
|
||||||
|
6. **Audio transfers always looked unsuccessful.** Because audio was never
|
||||||
|
reported, the source could not verify the target. With audio reporting the
|
||||||
|
same confirmation works for music and video.
|
||||||
|
7. **Follow-me card was hidden by an idle audio player.** It used to hide
|
||||||
|
whenever the audio bar had an item, even when paused. It now hides only while
|
||||||
|
audio is actually playing, so “Продолжить здесь” appears over an open but
|
||||||
|
idle audio player.
|
||||||
|
8. **Audio/video mixing.** Starting one medium stops the other; the group item
|
||||||
|
guard prevents cross-media seeks; media-switch guards prevent old-player
|
||||||
|
events from being sent as group commands.
|
||||||
|
9. **Two-second loop at the start of a group video.** Late auto-joins each put
|
||||||
|
the group back into Waiting and re-parked everyone at the first seconds.
|
||||||
|
Auto-join polls every 1 s, the host waits 3 s before sharing the queue when
|
||||||
|
other Blink clients are online, and the old “solo force resume” was removed.
|
||||||
|
Three clients now start together in about 1 s with no loop.
|
||||||
|
10. **Back from the player.** The group is not left. The player exit no longer
|
||||||
|
reports a Pause, and after ~3 s without local media the client is marked
|
||||||
|
`IgnoreWait`, so the group keeps playing while the user browses.
|
||||||
|
11. **Audio autoplay overrode SyncPlay parking.** The `<audio autoPlay>` element
|
||||||
|
started even when the group had parked it, so clients played ~3 s and the
|
||||||
|
server then seeked everyone back to 0. The element no longer autoplays:
|
||||||
|
playback follows the shared store flag, and parking pauses it before the
|
||||||
|
element even mounts.
|
||||||
|
|
||||||
|
### Follow-up verification
|
||||||
|
|
||||||
|
| Scenario | Result |
|
||||||
|
| --- | --- |
|
||||||
|
| Audio session visibility | `/Sessions` shows the track, type Audio, live position |
|
||||||
|
| Audio send, one client to another | Target starts at the transferred position; source stops only after confirmation |
|
||||||
|
| Follow-me with the audio player open | Card appears over the paused/ended audio player; takeover works for audio and video |
|
||||||
|
| Music during a group video | Group stays Playing; music advances 31→35 s while video 5→10 s |
|
||||||
|
| Group pause while one client plays music | State `Paused` in 1 s; video pauses, music keeps playing |
|
||||||
|
| Music vs. group seek | Group seek to 05:00 does not move the music (33→44 s) |
|
||||||
|
| Three-client group start | `Playing` in ~1 s, positions identical, no 2 s loop |
|
||||||
|
| Group audio start | Parks at 0, no 3 s restart; pause 8.6/8.7/8.6 → resume 9.8/9.8/9.8 |
|
||||||
|
| Group audio seek to 01:00 | All at 60–61 s, then advance together, no end loop |
|
||||||
|
| Back from the group player | Group remains; other clients continue; Pause reaches `Paused` in 1 s with the browsing client ignored |
|
||||||
|
| `tsc --noEmit` / `pnpm build` | Pass |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,605 @@
|
|||||||
|
# Интеграция qBittorrent в Blink — план
|
||||||
|
|
||||||
|
> Статус: **реализовано** (Rust-клиент, страница «Загрузки», настройки).
|
||||||
|
> Проверено на qBittorrent 5.3.0 / WebAPI 2.16.2; совместимость с 4.x
|
||||||
|
> заложена в клиент, но на живой 4.x не прогонялась.
|
||||||
|
|
||||||
|
## 0. Заметки по реализации
|
||||||
|
|
||||||
|
- qBittorrent 5.x принимает параметр `stopped` при добавлении раздачи, 4.x —
|
||||||
|
`paused`. Клиент отправляет оба: каждая версия читает свой и игнорирует
|
||||||
|
чужой.
|
||||||
|
- `sync/maindata` **не повторяет `hash` внутри объекта торрента** — хеш является
|
||||||
|
ключом словаря. Без подстановки ключа строки получали пустой hash, ломая
|
||||||
|
действия; в `QbTorrentRaw::from_value` хеш берётся из ключа.
|
||||||
|
- Для API-ключа заголовок `Authorization: Bearer …` нужно добавлять и к
|
||||||
|
multipart-запросу `torrents/add`; без него qB отвечает `403` (при этом
|
||||||
|
обычные GET/POST-формы работают).
|
||||||
|
- Секрет хранится в системном keyring (`blink-qbittorrent` / `default`) либо
|
||||||
|
только в памяти до закрытия приложения; в `qbittorrent.json` его нет.
|
||||||
|
|
||||||
|
## 1. Цель и рамки
|
||||||
|
|
||||||
|
Добавить в Blink страницу загрузок qBittorrent:
|
||||||
|
|
||||||
|
1. Добавление раздачи по **magnet-ссылке**.
|
||||||
|
2. Добавление **.torrent файла**.
|
||||||
|
3. Выбор **категории** qBittorrent (у категории может быть своя папка).
|
||||||
|
4. Список позиций со **статусом скачивания**: прогресс, скорость, ETA, состояние,
|
||||||
|
категория, размер; действия пауза/продолжить/удалить.
|
||||||
|
5. Настройки подключения к qBittorrent и проверка соединения.
|
||||||
|
|
||||||
|
Вне рамок этого этапа: поиск раздач, RSS, автозагрузка, интеграция с
|
||||||
|
Radarr/Sonarr/Seerr, несколько qB-серверов одновременно, поддержка Usenet.
|
||||||
|
|
||||||
|
## 2. Пользовательские сценарии
|
||||||
|
|
||||||
|
### 2.1. Добавить магнит
|
||||||
|
|
||||||
|
1. «Загрузки» → кнопка «Добавить» (или «+» в шапке страницы).
|
||||||
|
2. Вкладка «Магнит»: вставить `magnet:?xt=urn:btih:…`.
|
||||||
|
3. Категория выбирается из списка, полученного из qB; рядом показывается
|
||||||
|
`savePath` категории (или «папка по умолчанию»).
|
||||||
|
4. «Добавить» → тост «Раздача добавлена» → строка сразу появляется в списке
|
||||||
|
со статусом «Получение метаданных» / «В очереди».
|
||||||
|
5. Если qB вернул дубликат — сообщение «Такая раздача уже есть».
|
||||||
|
|
||||||
|
### 2.2. Добавить .torrent
|
||||||
|
|
||||||
|
1. Вкладка «Файл»: выбор файла через диалог Tauri (`.torrent`).
|
||||||
|
2. Тот же выбор категории и кнопка «Добавить».
|
||||||
|
3. Файл отправляется в qB как multipart (`torrents`).
|
||||||
|
|
||||||
|
### 2.3. Статус загрузки
|
||||||
|
|
||||||
|
Список обновляется опросом `/sync/maindata`:
|
||||||
|
имя, категория, размер, прогресс (%, полоса), скорость ↓/↑, ETA, состояние.
|
||||||
|
|
||||||
|
Состояния в UI:
|
||||||
|
|
||||||
|
| Состояние qB | Подпись в Blink |
|
||||||
|
| --- | --- |
|
||||||
|
| `metaDL` | Получение метаданных |
|
||||||
|
| `queuedDL`, `queuedUP` | В очереди |
|
||||||
|
| `downloading`, `forcedDL`, `stalledDL` | Скачивается |
|
||||||
|
| `checkingDL`, `checkingUP`, `checkingResumeData` | Проверка |
|
||||||
|
| `moving` | Перемещение |
|
||||||
|
| `uploading`, `forcedUP`, `stalledUP` | Раздаётся |
|
||||||
|
| `pausedDL`, `stoppedDL` | Пауза |
|
||||||
|
| `pausedUP`, `stoppedUP` | Завершено |
|
||||||
|
| `error`, `missingFiles` | Ошибка |
|
||||||
|
| `unknown` | Неизвестно |
|
||||||
|
|
||||||
|
«Добавленные из Blink» помечаются локально: хеши, полученные при добавлении,
|
||||||
|
хранятся в store; фильтр «Все / Добавленные из Blink».
|
||||||
|
|
||||||
|
### 2.4. Настройки
|
||||||
|
|
||||||
|
Новый раздел «Настройки → Загрузки» (или отдельная страница настроек
|
||||||
|
интеграции):
|
||||||
|
|
||||||
|
| Поле | Обязательное | Описание |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Адрес WebUI | да | `http://192.168.1.10:8080` — без `/api/v2` |
|
||||||
|
| Способ входа | да | «Логин и пароль» / «API-ключ» (qB 5.3+, WebAPI 2.17+) |
|
||||||
|
| Логин | для пароля | пользователь WebUI |
|
||||||
|
| Пароль | для пароля | системное хранилище секретов (см. 4.2) или ввод при запуске |
|
||||||
|
| API-ключ | для ключа | там же |
|
||||||
|
| Разрешить самоподписанный TLS | нет | только для HTTPS, с предупреждением |
|
||||||
|
| Категория по умолчанию | нет | подставляется в диалоге |
|
||||||
|
| Добавлять на паузе | нет | параметр `paused` |
|
||||||
|
| Автоуправление (autoTMM) | нет | параметр `autoTMM`; по умолчанию `true`, чтобы работала папка категории |
|
||||||
|
| Обновлять Jellyfin после завершения | нет | `POST /Library/Refresh` |
|
||||||
|
| Интервал опроса | нет | по умолчанию 2000 мс, минимум 1000 |
|
||||||
|
|
||||||
|
Кнопка «Проверить соединение»: логин → `/app/version` → `/app/webapiVersion` →
|
||||||
|
`/app/defaultSavePath`; показывает версию qB и WebAPI.
|
||||||
|
|
||||||
|
## 3. qBittorrent WebUI API
|
||||||
|
|
||||||
|
База: `{baseUrl}/api/v2`. Все методы — `GET` или `POST`; мутации только `POST`.
|
||||||
|
Авторизация — cookie-сессия (логин/пароль) или API-ключ.
|
||||||
|
|
||||||
|
### 3.1. Версии и совместимость
|
||||||
|
|
||||||
|
| qBittorrent | WebAPI | Особенности |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 4.1–4.6 | 2.0–2.8 | базовые методы; логин `200` при успехе и неудаче (тело `Ok.` / `Fails.`) |
|
||||||
|
| 5.0–5.2 | 2.9–2.14 | cookie может называться `QBT_SID_<port>`; `torrents/add` в 2.14+ отвечает JSON |
|
||||||
|
| 5.2+ | 2.14+ | логин `204`/`401`; `torrents/add`: `200`, `202` (есть pending), `409` (ничего не добавлено) |
|
||||||
|
| 5.3+ | 2.17+ | API-ключ (`Authorization: Bearer …` / `X-API-Key`); `torrents/add` без `skip_checking` с 2.16 |
|
||||||
|
|
||||||
|
Минимальная поддерживаемая версия — **qBittorrent 4.1 / WebAPI 2.0**.
|
||||||
|
Версию определять через `/app/webapiVersion` при проверке соединения.
|
||||||
|
|
||||||
|
### 3.2. Авторизация
|
||||||
|
|
||||||
|
`POST /api/v2/auth/login`
|
||||||
|
|
||||||
|
| Параметр | Тип | Описание |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `username` | string | логин WebUI |
|
||||||
|
| `password` | string | пароль WebUI |
|
||||||
|
|
||||||
|
Заголовки:
|
||||||
|
|
||||||
|
- `Referer: {baseUrl}` и `Origin: {baseUrl}` обязательны — иначе qB отклоняет
|
||||||
|
запрос. Хост и порт должны совпадать с `Host`.
|
||||||
|
- `Content-Type: application/x-www-form-urlencoded`.
|
||||||
|
|
||||||
|
Ответы:
|
||||||
|
|
||||||
|
| Код | Значение |
|
||||||
|
| --- | --- |
|
||||||
|
| `200` | до 5.2: успех/неудача в теле (`Ok.` / `Fails.`) |
|
||||||
|
| `204` | 5.2+: успех, тела нет |
|
||||||
|
| `401` | 5.2+: неверные учётные данные |
|
||||||
|
| `403` | IP забанен после N неудачных попыток |
|
||||||
|
|
||||||
|
Cookie: имя брать из `Set-Cookie` (`SID` или `QBT_SID_<port>`), не хардкодить.
|
||||||
|
Сессия живёт `web_ui_session_timeout` (по умолчанию 3600 с); при `401/403`
|
||||||
|
нужно один раз повторить логин и запрос.
|
||||||
|
|
||||||
|
API-ключ (WebAPI 2.17+): заголовок `Authorization: Bearer <key>`; логин не
|
||||||
|
нужен. В настройках qB ключ создаётся в «WebUI → API».
|
||||||
|
|
||||||
|
`POST /api/v2/auth/logout` — завершение сессии (использовать при смене
|
||||||
|
настроек/выходе).
|
||||||
|
|
||||||
|
### 3.3. Служебные методы
|
||||||
|
|
||||||
|
| Метод | Параметры | Ответ |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `GET /app/version` | — | строка, например `v5.0.3` |
|
||||||
|
| `GET /app/webapiVersion` | — | строка, например `2.11` |
|
||||||
|
| `GET /app/defaultSavePath` | — | путь по умолчанию |
|
||||||
|
| `GET /app/preferences` | — | объект; нужны `save_path`, `auto_tmm_enabled` |
|
||||||
|
| `POST /app/setPreferences` | `json` | не используется в этом этапе |
|
||||||
|
|
||||||
|
### 3.4. Категории
|
||||||
|
|
||||||
|
| Метод | Параметры | Ответ |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `GET /torrents/categories` | — | объект `{ "movies": { "name": "movies", "savePath": "D:/Media/Movies", "downloadPath": … } }` |
|
||||||
|
| `POST /torrents/createCategory` | `category`, `savePath` | `200` / `409` (уже есть) |
|
||||||
|
| `POST /torrents/editCategory` | `category`, `savePath` | `200` |
|
||||||
|
| `POST /torrents/removeCategories` | `categories` (по `\n`) | `200` |
|
||||||
|
|
||||||
|
`savePath` может быть пустым — тогда используется общий путь qB.
|
||||||
|
`downloadPath` в ответе может быть `null`.
|
||||||
|
|
||||||
|
В UI: выпадающий список из `GET /torrents/categories` + пункт «Без категории».
|
||||||
|
Под списком — подсказка с `savePath` выбранной категории. Создание категории
|
||||||
|
из Blink — опционально (фаза 4), с полем пути.
|
||||||
|
|
||||||
|
### 3.5. Добавление раздачи
|
||||||
|
|
||||||
|
`POST /api/v2/torrents/add` — **multipart/form-data** (обязательно; для магнита
|
||||||
|
тоже можно multipart с полем `urls`).
|
||||||
|
|
||||||
|
| Поле | Тип | Обязательное | Описание |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| `urls` | string | да для магнита | ссылки через `\n` (`magnet:`, `http(s)://…`) |
|
||||||
|
| `torrents` | file | да для файла | содержимое `.torrent`; поле можно повторять |
|
||||||
|
| `savepath` | string | нет | папка; при `autoTMM=true` игнорируется/переопределяется категорией |
|
||||||
|
| `category` | string | нет | имя категории |
|
||||||
|
| `tags` | string | нет | теги через запятую |
|
||||||
|
| `paused` | bool | нет | добавить на паузе |
|
||||||
|
| `autoTMM` | bool | нет | автоуправление категорией |
|
||||||
|
| `sequentialDownload` | bool | нет | последовательная загрузка |
|
||||||
|
| `firstLastPiecePrio` | bool | нет | приоритет первых/последних кусков |
|
||||||
|
| `skip_checking` | bool | нет | **удалён в WebAPI 2.16**; не отправлять при новых версиях |
|
||||||
|
| `root_folder` | bool | нет | создавать корневую папку |
|
||||||
|
| `rename` | string | нет | переименовать раздачу |
|
||||||
|
| `upLimit`, `dlLimit` | int | нет | лимиты, байт/с |
|
||||||
|
| `ratioLimit`, `seedingTimeLimit` | float/int | нет | лимиты раздачи |
|
||||||
|
|
||||||
|
Ответы:
|
||||||
|
|
||||||
|
| Код | Значение |
|
||||||
|
| --- | --- |
|
||||||
|
| `200` | успех (до 5.2 — все сценарии, тело `Ok.` / `Fails.`) |
|
||||||
|
| `202` | 5.2+: часть добавлена, часть в обработке (`pending_count > 0`) |
|
||||||
|
| `409` | 5.2+: ничего не добавлено (дубликаты/ошибки) |
|
||||||
|
| `415` | `.torrent` невалиден |
|
||||||
|
|
||||||
|
С WebAPI 2.14 тело ответа — JSON:
|
||||||
|
`{ "success_count": 1, "pending_count": 0, "failure_count": 0, "added_torrent_ids": ["…"] }`.
|
||||||
|
Для старых версий тело — текст; дубликат определяется по `Fails.` и/или
|
||||||
|
сравнением списка торрентов после добавления.
|
||||||
|
|
||||||
|
### 3.6. Список и прогресс
|
||||||
|
|
||||||
|
`GET /api/v2/torrents/info` — полный снимок.
|
||||||
|
|
||||||
|
Параметры: `filter` (`all`, `downloading`, `seeding`, `completed`, `stopped`,
|
||||||
|
`active`, `inactive`, `running`, `stalled`, `errored`), `category`, `tag`,
|
||||||
|
`sort`, `reverse`, `limit`, `offset`, `hashes` (через `|`).
|
||||||
|
|
||||||
|
Поля, которые нужны UI:
|
||||||
|
|
||||||
|
| Поле | Назначение |
|
||||||
|
| --- | --- |
|
||||||
|
| `hash` | ключ строки |
|
||||||
|
| `name` | название |
|
||||||
|
| `category` | категория |
|
||||||
|
| `size`, `completed`, `downloaded` | размер и прогресс |
|
||||||
|
| `progress` | 0..1 |
|
||||||
|
| `dlspeed`, `upspeed` | скорости, байт/с |
|
||||||
|
| `eta` | секунды (8640000 = бесконечно) |
|
||||||
|
| `state` | состояние (см. таблицу выше) |
|
||||||
|
| `save_path`, `content_path` | куда скачалось |
|
||||||
|
| `added_on`, `completion_on` | время |
|
||||||
|
| `ratio` | раздача |
|
||||||
|
| `num_seeds`, `num_leechs` | пиры |
|
||||||
|
| `error` | причина ошибки (WebAPI 2.17+) |
|
||||||
|
|
||||||
|
`GET /api/v2/sync/maindata?rid=N` — инкрементально, для опроса:
|
||||||
|
|
||||||
|
| Поле | Значение |
|
||||||
|
| --- | --- |
|
||||||
|
| `rid` | новый идентификатор; передавать в следующий запрос |
|
||||||
|
| `full_update` | `true` — заменить всё локальное состояние |
|
||||||
|
| `torrents` | изменения по хешам (те же поля, что в `torrents/info`) |
|
||||||
|
| `torrents_removed` | массив удалённых хешей |
|
||||||
|
| `categories` | новые/изменённые категории |
|
||||||
|
| `server_state` | общая скорость, свободное место и т.п. |
|
||||||
|
|
||||||
|
Алгоритм: хранить `rid` и `Map<hash, QbTorrent>`; при `full_update` очищать
|
||||||
|
Map; удалять `torrents_removed`; мержить `torrents`.
|
||||||
|
|
||||||
|
### 3.7. Управление
|
||||||
|
|
||||||
|
| Метод | Параметры | Примечание |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `POST /torrents/pause` | `hashes` (`all` или `a\|b`) | в 5.x остаётся |
|
||||||
|
| `POST /torrents/resume` | `hashes` | |
|
||||||
|
| `POST /torrents/delete` | `hashes`, `deleteFiles=true/false` | удаление с файлами — подтверждение |
|
||||||
|
| `POST /torrents/setCategory` | `hashes`, `category` | смена категории на лету |
|
||||||
|
| `GET /transfer/info` | — | глобальная скорость (для шапки) |
|
||||||
|
|
||||||
|
### 3.8. Ошибки и их разбор
|
||||||
|
|
||||||
|
| Ситуация | Признак | Что показать |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| qB недоступен | connect timeout / connection refused | «qBittorrent недоступен» + адрес |
|
||||||
|
| Неверный логин | `401` / `Fails.` | «Проверьте логин и пароль» |
|
||||||
|
| Бан IP | `403` на логине | «qB заблокировал IP, подождите» |
|
||||||
|
| Нет категории | `409` при createCategory | «Категория уже существует» |
|
||||||
|
| Дубликат | `409` / `Fails.` | «Раздача уже добавлена» |
|
||||||
|
| Битый .torrent | `415` | «Файл не является торрентом» |
|
||||||
|
| Сессия истекла | `403` на обычном запросе | повторный логин один раз |
|
||||||
|
| Self-signed TLS | ошибка сертификата | подсказка включить «Разрешить самоподписанный TLS» |
|
||||||
|
|
||||||
|
## 4. Архитектура в Blink
|
||||||
|
|
||||||
|
### 4.1. Rust-бэкенд (почему не fetch из webview)
|
||||||
|
|
||||||
|
qBittorrent WebUI **не отдаёт CORS-заголовки**, а также требует совпадения
|
||||||
|
`Referer`/`Host`. Поэтому запросы делает Rust через `reqwest` с cookie-jar.
|
||||||
|
Webview вызывает только Tauri-команды.
|
||||||
|
|
||||||
|
Новый модуль: `src-tauri/src/qbittorrent/mod.rs` (+ `client.rs`, `types.rs`,
|
||||||
|
`commands.rs`). Зависимости в `Cargo.toml`:
|
||||||
|
|
||||||
|
- `reqwest` с `cookies`, `json`, `multipart`, `rustls-tls` (без OpenSSL — важно
|
||||||
|
для Linux-пакетов);
|
||||||
|
- `keyring` 3 с платформенными бэкендами (`windows-native`, `apple-native`,
|
||||||
|
`sync-secret-service`);
|
||||||
|
- `thiserror`/`serde` — уже есть в проекте;
|
||||||
|
- `tokio` — уже есть через Tauri.
|
||||||
|
|
||||||
|
Состояние: `QbState { client: Mutex<Option<Client>>, config_hash }` — клиент
|
||||||
|
пересоздаётся при изменении настроек.
|
||||||
|
|
||||||
|
Команды:
|
||||||
|
|
||||||
|
| Команда | Вход | Выход |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `qb_test_connection` | `{ baseUrl, auth }` | `{ appVersion, apiVersion, defaultSavePath }` |
|
||||||
|
| `qb_categories` | — | `QbCategory[]` |
|
||||||
|
| `qb_create_category` | `{ name, savePath }` | `()` |
|
||||||
|
| `qb_add_magnet` | `{ magnet, category?, paused?, autoTMM? }` | `QbAddResult` |
|
||||||
|
| `qb_add_torrent_file` | `{ fileName, bytesBase64, category?, … }` | `QbAddResult` |
|
||||||
|
| `qb_torrents` | — | `QbTorrent[]` (полный снимок) |
|
||||||
|
| `qb_sync` | `{ rid }` | `QbSyncResponse` (diff) |
|
||||||
|
| `qb_pause` / `qb_resume` | `{ hashes }` | `()` |
|
||||||
|
| `qb_delete` | `{ hashes, deleteFiles }` | `()` |
|
||||||
|
| `qb_set_category` | `{ hashes, category }` | `()` |
|
||||||
|
|
||||||
|
Типы (TS/Rust):
|
||||||
|
|
||||||
|
```ts
|
||||||
|
type QbCategory = { name: string; savePath: string };
|
||||||
|
type QbTorrent = {
|
||||||
|
hash: string; name: string; category: string;
|
||||||
|
size: number; completed: number; progress: number;
|
||||||
|
dlspeed: number; upspeed: number; eta: number;
|
||||||
|
state: string; savePath: string; addedOn: number;
|
||||||
|
ratio: number; numSeeds: number; numLeeches: number;
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
type QbAddResult = {
|
||||||
|
status: "added" | "pending" | "duplicate" | "invalid";
|
||||||
|
addedHashes: string[];
|
||||||
|
message?: string;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Ошибки: единый `QbError { kind: "unreachable" | "auth" | "banned" | "api" |
|
||||||
|
"torrent" | "duplicate" | "tls" | "http"; message: string; status?: number }`.
|
||||||
|
|
||||||
|
Таймауты: connect 5 с, чтение 15 с; добавление файла — 60 с.
|
||||||
|
|
||||||
|
### 4.2. Хранение настроек и секретов (все ОС)
|
||||||
|
|
||||||
|
- Не секреты (`baseUrl`, категория по умолчанию, флаги, таймаут) — через
|
||||||
|
`tauri-plugin-store` (как `.user.dat`), файл `qbittorrent.json` в app-data
|
||||||
|
каталоге ОС (Windows `%APPDATA%`, macOS `~/Library/Application Support`,
|
||||||
|
Linux `~/.local/share`).
|
||||||
|
- Пароль и API-ключ — через `keyring` 3 в системное хранилище:
|
||||||
|
- **Windows** — Credential Manager (DPAPI);
|
||||||
|
- **macOS** — Keychain (при первом обращении система покажет свой запрос —
|
||||||
|
это нормально);
|
||||||
|
- **Linux** — Secret Service через DBus (GNOME Keyring / KWallet).
|
||||||
|
`service = "blink-qbittorrent"`, `user = baseUrl`.
|
||||||
|
- **Linux без Secret Service** (сервер, минимальный дистрибутив, нет
|
||||||
|
keyring-демона): `keyring` вернёт ошибку. Приложение **не** пишет пароль в
|
||||||
|
открытый файл. По умолчанию пароль запрашивается при запуске (session-only).
|
||||||
|
Опционально, с явным предупреждением, — шифрованный vault (age/scrypt) в
|
||||||
|
app-data; решение принять на этапе 1.
|
||||||
|
- В store хранится только флаг «секрет сохранён» и способ входа.
|
||||||
|
- Никогда не логировать пароль, cookie и `Authorization`.
|
||||||
|
|
||||||
|
### 4.3. Фронтенд
|
||||||
|
|
||||||
|
Новые файлы (ориентировочно):
|
||||||
|
|
||||||
|
- `src/routes/_api/downloads.tsx` и `downloads.scss` — страница списка.
|
||||||
|
- `src/components/downloads/addTorrentDialog.tsx` — магнит/файл + категория.
|
||||||
|
- `src/components/downloads/torrentRow.tsx` — строка списка.
|
||||||
|
- `src/components/downloads/downloadsEmpty.tsx`.
|
||||||
|
- `src/utils/store/qbittorrent.ts` — настройки и локальный список добавленных
|
||||||
|
хешей (zustand + tauri store).
|
||||||
|
- `src/utils/queries/qbittorrent.ts` — React Query хуки.
|
||||||
|
- Настройки: секция в `src/routes/_api/settings/preferences.tsx` или отдельный
|
||||||
|
маршрут `settings/downloads.tsx`.
|
||||||
|
|
||||||
|
Доступ к странице: иконка `download` в верхней панели и пункт в боковом меню
|
||||||
|
(рядом с «Пультом»).
|
||||||
|
|
||||||
|
Опрос: React Query с `refetchInterval: 2000`, `refetchIntervalInBackground:
|
||||||
|
false`; внутри — `qb_sync` с `rid`, а не полный `torrents/info`.
|
||||||
|
Мутации инвалидируют запрос и показывают тост.
|
||||||
|
|
||||||
|
### 4.4. Локальная память добавленного
|
||||||
|
|
||||||
|
qB не хранит «кто добавил». Чтобы показать «Добавленные из Blink»:
|
||||||
|
|
||||||
|
- после успешного `qb_add_*` сохранить хеши в store;
|
||||||
|
- для старых qB (без `added_torrent_ids`) — найти торрент по имени/магниту
|
||||||
|
после первого sync и сохранить его хеш;
|
||||||
|
- список хешей чистить при удалении и по кнопке «Забыть».
|
||||||
|
|
||||||
|
Альтернатива (проще): показывать все торренты qB — это и есть «статус каждой
|
||||||
|
добавленной позиции», а фильтр «из Blink» сделать опционально в фазе 5.
|
||||||
|
|
||||||
|
### 4.5. Кроссплатформенность
|
||||||
|
|
||||||
|
Функционал обязан работать на **Windows, macOS и Linux**. qBittorrent при этом
|
||||||
|
может быть установлен на любой ОС и даже на другой машине — Blink общается с
|
||||||
|
ним только по HTTP(S).
|
||||||
|
|
||||||
|
| Слой | Требование |
|
||||||
|
| --- | --- |
|
||||||
|
| HTTP/TLS | `reqwest` + `rustls`, без OpenSSL; поддержка IPv4/IPv6/localhost; флаг «самоподписанный сертификат» |
|
||||||
|
| Секреты | `keyring` (Credential Manager / Keychain / Secret Service); при недоступности — session-only, без plaintext |
|
||||||
|
| Пути | `savePath`/`contentPath` из qB — непрозрачные строки в ОС **сервера qB**; показывать как есть, не склеивать с локальными путями и не проверять их существование |
|
||||||
|
| Файлы | нативный диалог `tauri-plugin-dialog` с фильтром `.torrent`; без shell-команд `open`/`explorer` |
|
||||||
|
| Уведомления | `tauri-plugin-notification`; на macOS запросить разрешение, на Linux — libnotify (если нет — тихо пропустить) |
|
||||||
|
| Заголовок окна | страница использует общий titlebar приложения: macOS — отступ под traffic lights, Windows/Linux — штатные кнопки окна; своих кнопок не рисовать |
|
||||||
|
| Адаптивность | следовать мобильным правилам из `feat(mobile)`: ≤900 px — одна колонка, ≤640 px — компактные строки, крупные touch-цели |
|
||||||
|
| Хранение | `tauri-plugin-store` в app-data каждой ОС; никаких путей, зашитых под Windows |
|
||||||
|
| Сборка | Windows NSIS/MSI, macOS dmg/app (arm64 и x86_64), Linux AppImage/deb; без новых системных зависимостей, кроме Secret Service на Linux |
|
||||||
|
|
||||||
|
Отдельно: категория в qB может иметь путь вида `D:/Media/Movies` (Windows) или
|
||||||
|
`/mnt/media/movies` (Linux) — это путь на машине qB. UI только показывает его
|
||||||
|
и при создании категории подсказывает, что путь вводится для сервера qB.
|
||||||
|
|
||||||
|
## 5. Макеты экранов
|
||||||
|
|
||||||
|
### 5.1. Страница «Загрузки»
|
||||||
|
|
||||||
|
```
|
||||||
|
┌──────────────────────────────────────────────────────────────┐
|
||||||
|
│ Загрузки [Обновить] [+ Добавить] │
|
||||||
|
│ ▼ 12 ГБ/с ▲ 3 ГБ/с Свободно: 120 ГБ │
|
||||||
|
├──────────────────────────────────────────────────────────────┤
|
||||||
|
│ [Все] [Скачиваются] [Завершённые] [Из Blink] │
|
||||||
|
│ │
|
||||||
|
│ 🎬 Interstellar.2014.1080p Скачивается │
|
||||||
|
│ movies · 8.4 ГБ из 14 ГБ · 72% · 6.2 МБ/с · 18 мин │
|
||||||
|
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░ [⏸] [🗑] │
|
||||||
|
│ │
|
||||||
|
│ 📺 Series.S01.1080p Завершено │
|
||||||
|
│ series · 22 ГБ · 100% · раздаётся 1.4× [⏸] [🗑] │
|
||||||
|
└──────────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5.2. Диалог «Добавить»
|
||||||
|
|
||||||
|
- Табы: **Магнит** | **Файл**.
|
||||||
|
- Магнит: textarea, вставка из буфера, валидация `magnet:?xt=urn:btih:`.
|
||||||
|
- Файл: кнопка выбора `.torrent`, имя файла, размер.
|
||||||
|
- Категория: select из qB + «Без категории»; подсказка `savePath`.
|
||||||
|
- Дополнительно (свернуть): «на паузе», «autoTMM», «последовательная
|
||||||
|
загрузка».
|
||||||
|
- Кнопки: «Отмена», «Добавить».
|
||||||
|
|
||||||
|
### 5.3. Пустые и ошибочные состояния
|
||||||
|
|
||||||
|
- Не настроено подключение → карточка «Подключите qBittorrent» + кнопка в
|
||||||
|
настройки.
|
||||||
|
- qB недоступен → «qBittorrent не отвечает» + «Повторить».
|
||||||
|
- Нет раздач → «Пока ничего не скачивается» + «Добавить раздачу».
|
||||||
|
|
||||||
|
### 5.4. Адаптивность
|
||||||
|
|
||||||
|
- ≥1200 px: список во всю ширину, панель итогов сверху.
|
||||||
|
- 900–1200 px: те же строки, меньше второстепенных данных (сиды/раздача
|
||||||
|
скрываются в «…»).
|
||||||
|
- ≤900 px: одна колонка, диалог добавления на всю ширину, действия строки —
|
||||||
|
иконки в ряд.
|
||||||
|
- ≤640 px: компактные строки в две линии (имя + состояние; прогресс + размер),
|
||||||
|
крупные touch-цели ≥40 px, фильтры — горизонтальный скролл.
|
||||||
|
- Учитывать titlebar каждой ОС: на macOS — отступ под traffic lights, на
|
||||||
|
Windows/Linux — место под кнопки окна (общий заголовок приложения, не свой).
|
||||||
|
Правила — как в мобильном коммите `2e099ec`.
|
||||||
|
|
||||||
|
## 6. Полинг и производительность
|
||||||
|
|
||||||
|
- Пока страница открыта — `sync/maindata` каждые 2 с; при скрытом окне — стоп.
|
||||||
|
- После действия (добавление/пауза) — внеочередной sync через 300 мс.
|
||||||
|
- Ошибки сети — экспоненциальный backoff до 15 с, без спама тостами.
|
||||||
|
- Полный снимок `torrents/info` — только при первом открытии и `full_update`.
|
||||||
|
- Не держать больше одного запроса в полёте; отменять предыдущий при уходе
|
||||||
|
со страницы.
|
||||||
|
|
||||||
|
## 7. Краевые случаи
|
||||||
|
|
||||||
|
1. **Дубликат**: `409`/`Fails.` → не ошибка, а «Уже добавлено»; подсветить
|
||||||
|
существующую строку.
|
||||||
|
2. **Категория удалена в qB**, пока Blink открыт → при добавлении `409`;
|
||||||
|
обновить категории и предложить другую.
|
||||||
|
3. **Категория без savePath** и `autoTMM=false` → скачается в общий путь;
|
||||||
|
показать предупреждение.
|
||||||
|
4. **magnet без `dn`** — имя появится после метаданных; строка «Получение
|
||||||
|
метаданных».
|
||||||
|
5. **qB 4.x**: нет JSON-ответа на add, cookie `SID`, `skip_checking` допустим.
|
||||||
|
6. **qB 5.2+**: `202` значит «в процессе»; `409` — отказ; `skip_checking`
|
||||||
|
убран с 2.16.
|
||||||
|
7. **HTTPS self-signed**: отдельный флаг «Разрешить самоподписанный TLS»;
|
||||||
|
по умолчанию выключен.
|
||||||
|
8. **Пароль изменён в qB** → `401`; сбросить сессию, показать настройки.
|
||||||
|
9. **Удаление с файлами** — только после подтверждения; по умолчанию
|
||||||
|
`deleteFiles=false`.
|
||||||
|
10. **Большой .torrent** — ограничить 10 МБ, ошибка до отправки.
|
||||||
|
11. **Переименование/перемещение** торрента в qB — статус `moving`;
|
||||||
|
UI не ломается.
|
||||||
|
12. **Остановка qB** — статус «недоступен», список сохраняется до следующего
|
||||||
|
успешного sync.
|
||||||
|
|
||||||
|
## 8. Безопасность
|
||||||
|
|
||||||
|
- Пароль/ключ — только в системном keyring (Windows/macOS/Linux) или
|
||||||
|
session-only; в конфиге и логах их нет, plaintext-файла нет.
|
||||||
|
- qB WebUI не должен быть открыт в интернет; интеграция рассчитана на LAN/VPN.
|
||||||
|
- TLS: предпочтителен `https`; самоподписанный сертификат — осознанный флаг.
|
||||||
|
- В логах — метод, URL без query-секретов, код ответа; без тел с кредами.
|
||||||
|
- Никаких прямых запросов из webview (обходим CORS и Referer-проверку в Rust).
|
||||||
|
- Учётные данные не передаются в Jellyfin и обратно.
|
||||||
|
|
||||||
|
## 9. Jellyfin: обновление библиотеки (опционально)
|
||||||
|
|
||||||
|
После перехода торрента в `pausedUP`/`stoppedUP` (или `progress === 1`):
|
||||||
|
|
||||||
|
- `POST {jellyfin}/Library/Refresh` с токеном текущего пользователя
|
||||||
|
(`Authorization: MediaBrowser Token="…"`);
|
||||||
|
- только если пользователь админ (иначе `403`) — показать подсказку;
|
||||||
|
- дебаунс: не чаще одного раза в 30 с;
|
||||||
|
- альтернатива без кода: qB «Run external program on torrent finished» с
|
||||||
|
`curl` на Jellyfin — описать в документации.
|
||||||
|
|
||||||
|
## 10. Тестирование
|
||||||
|
|
||||||
|
### Rust
|
||||||
|
|
||||||
|
- Юнит-тесты клиента на mock-сервере (`wiremock`): логин, категории, add
|
||||||
|
(магнит и файл), 202/409/415, sync-diff, истёкшая сессия.
|
||||||
|
- Тест сборки multipart для файла.
|
||||||
|
- Тест парсинга состояний и ETA.
|
||||||
|
|
||||||
|
### UI
|
||||||
|
|
||||||
|
- Пустое состояние, ошибка подключения, успешное добавление, дубликат.
|
||||||
|
- Список: скачивание, пауза, завершение, ошибка, удаление.
|
||||||
|
- Смена категории и удаление с файлами (подтверждение).
|
||||||
|
- Опрос останавливается при скрытом окне.
|
||||||
|
|
||||||
|
### Ручной чек-лист
|
||||||
|
|
||||||
|
- qB 4.6 и qB 5.x (если доступны);
|
||||||
|
- магнит и .torrent;
|
||||||
|
- категория с путём и без;
|
||||||
|
- неверный пароль, остановленный qB, self-signed HTTPS;
|
||||||
|
- перезапуск Blink при активной загрузке.
|
||||||
|
|
||||||
|
### Кроссплатформенная матрица
|
||||||
|
|
||||||
|
| Проверка | Windows 10/11 | macOS (arm64) | Linux (AppImage/deb) |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| Логин и категории | + | + | + |
|
||||||
|
| Добавление магнита | + | + | + |
|
||||||
|
| Добавление `.torrent` через диалог | + | + | + |
|
||||||
|
| Список, прогресс, действия | + | + | + |
|
||||||
|
| Сохранение пароля в keyring | Credential Manager | Keychain | Secret Service |
|
||||||
|
| Работа без keyring (Linux) | — | — | пароль спрашивается при запуске |
|
||||||
|
| Self-signed HTTPS | + | + | + |
|
||||||
|
| Уведомление о завершении | + | + (разрешение) | + (libnotify) |
|
||||||
|
| Мобильная ширина окна | + | + | + |
|
||||||
|
|
||||||
|
Проверять минимум одну сборку на каждой ОС; Linux — GNOME и KDE (Secret
|
||||||
|
Service), а также окружение без keyring-демона.
|
||||||
|
|
||||||
|
## 11. Этапы
|
||||||
|
|
||||||
|
| Этап | Что входит | Результат |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 1. Rust-клиент | login, версия, категории, тест соединения, ошибки | настройки сохраняются, «Проверить» работает |
|
||||||
|
| 2. Добавление магнита | диалог, категории, `torrents/add`, тосты | магнит добавляется, дубликат обрабатывается |
|
||||||
|
| 3. Список и статус | страница, sync-поллинг, строки, действия | прогресс/скорость/ETA по каждой позиции |
|
||||||
|
| 4. Файл и опции | `.torrent` через диалог, пауза/autoTMM/sequential, создание категории | полный сценарий из ТЗ |
|
||||||
|
| 5. Полировка | уведомления о завершении, Jellyfin refresh, фильтр «из Blink» | готово к использованию |
|
||||||
|
| 6. Тесты | mock-сервер, ручной чек-лист, совместимость | приёмка |
|
||||||
|
|
||||||
|
Оценка после получения нового кода: этап 1 — 0.5–1 день (включая keyring на
|
||||||
|
трёх ОС и fallback), этап 2 — 1 день, этап 3 — 1–1.5 дня, этап 4 — 0.5–1 день,
|
||||||
|
этап 5–6 — 1–1.5 дня (сборка и проверка на Windows/macOS/Linux). Итого ~5–6
|
||||||
|
рабочих дней без учёта незнакомых изменений в новом коде.
|
||||||
|
|
||||||
|
## 12. Критерии приёмки
|
||||||
|
|
||||||
|
1. Магнит добавляется в qB с выбранной категорией; категория видна в qB.
|
||||||
|
2. `.torrent` добавляется тем же способом.
|
||||||
|
3. Дубликат не создаёт вторую раздачу и понятно объясняется.
|
||||||
|
4. На странице загрузок у каждой позиции есть имя, категория, размер,
|
||||||
|
прогресс, скорость, ETA и состояние.
|
||||||
|
5. Пауза/продолжить/удаление работают и отражаются в qB.
|
||||||
|
6. Ошибки qB (недоступен, неверный пароль, бан) показываются человеческим
|
||||||
|
текстом.
|
||||||
|
7. Пароль не хранится в открытом виде.
|
||||||
|
8. Опрос не нагружает qB при скрытом окне.
|
||||||
|
9. Работает на Windows, macOS и Linux; на Linux без keyring-демона пароль
|
||||||
|
запрашивается при запуске, plaintext-файла не появляется.
|
||||||
|
10. Страница корректна на мобильной ширине и не конфликтует с кнопками окна
|
||||||
|
каждой ОС.
|
||||||
|
|
||||||
|
## 13. Открытые вопросы
|
||||||
|
|
||||||
|
- Показывать все торренты qB или только добавленные из Blink? (план:
|
||||||
|
все + фильтр).
|
||||||
|
- Нужны ли уведомления о завершении в системный трей?
|
||||||
|
- Нужен ли автозапуск Jellyfin-скана или достаточно real-time monitoring?
|
||||||
|
- Создавать категории из Blink или только выбирать существующие?
|
||||||
|
- Поддержка API-ключа qB 5.3+ — включать сразу или во втором релизе?
|
||||||
|
- Linux без Secret Service: session-only по умолчанию (план) или шифрованный
|
||||||
|
vault с паролем-мастером?
|
||||||
|
|
||||||
|
## 14. Ссылки
|
||||||
|
|
||||||
|
- [qBittorrent WebUI API 4.1](https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1))
|
||||||
|
- [qBittorrent WebUI API 5.0](https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-5.0))
|
||||||
|
- [WebAPI changelog](https://github.com/qbittorrent/qBittorrent/blob/master/WebAPI_Changelog.md)
|
||||||
|
- [qBittorrent: Run external program](https://github.com/qbittorrent/qBittorrent/wiki/How-to-use-the-external-program-feature)
|
||||||
|
- [Tauri store plugin](https://v2.tauri.app/plugin/store/)
|
||||||
|
- [Tauri dialog plugin](https://v2.tauri.app/plugin/dialog/)
|
||||||
@@ -1,60 +1,70 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="ru">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||||
<!-- <script src="http://localhost:8097"></script> -->
|
<!-- <script src="http://localhost:8097"></script> -->
|
||||||
<title>Blink</title>
|
<title>Blink</title>
|
||||||
<style>
|
<style>
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
background: #08001f;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.app-loading {
|
.app-loading {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%,-50%);
|
transform: translate(-50%, -50%);
|
||||||
width: 10em;
|
|
||||||
height: 10em;
|
|
||||||
background: rgb(180 180 180);
|
|
||||||
z-index: 100000;
|
z-index: 100000;
|
||||||
mask-image: url("./src/assets/icon-outline.png");
|
display: flex;
|
||||||
mask-size: contain;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-loading.hidden {
|
.app-loading.hidden {
|
||||||
display: none;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-loading-logo {
|
||||||
.app-loading-anim{
|
display: block;
|
||||||
width: 150%;
|
width: min(230px, 62vw);
|
||||||
height: 100%;
|
height: auto;
|
||||||
position: absolute;
|
filter: drop-shadow(0 10px 30px rgb(0 0 0 / 0.35));
|
||||||
top: 0;
|
animation: splashPulse 1.4s ease-in-out infinite;
|
||||||
left: 0;
|
|
||||||
background: linear-gradient(to right,transparent,rgb(255 255 255),transparent);
|
|
||||||
transform: scaleX(0);
|
|
||||||
animation: loading 0.75s linear infinite both;
|
|
||||||
transform-origin: left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes loading {
|
@keyframes splashPulse {
|
||||||
0%{
|
0%,
|
||||||
transform: translate(-100%);
|
100% {
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
50%{
|
50% {
|
||||||
transform: translate(0%);
|
opacity: 0.62;
|
||||||
}
|
}
|
||||||
100%{
|
}
|
||||||
transform: translate(100%);
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.app-loading-logo {
|
||||||
|
animation: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="app-loading">
|
<div class="app-loading" role="status" aria-label="Загрузка Blink">
|
||||||
<!-- <img src="./src/assets/icon-outline.svg" class="app-loading-logo" /> -->
|
<img
|
||||||
<div class="app-loading-anim"></div>
|
class="app-loading-logo"
|
||||||
|
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAX8AAACqCAYAAABFwE9PAAAAAXNSR0IArs4c6QAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABf6ADAAQAAAABAAAAqgAAAAAX35FHAAA3E0lEQVR4Ae2dB/wcRfn/CSGEGgi9hNB7b9IhQAhFQHqTjhRFQRB/gAiIggIK/hWkozQhRIr03nsvIiWUQCD03kNJ/u9PuPt6ue/e3c7sM3u7d/O8Xs/3dmdnPk+Z2Wdnp+y3zySRGnpg/Pjxfbk4KzwQnq7C/fn9HP64wh/y+2afPn3G8RspeiB6IHqgFB7oUwotc1KSYD8Fos6BB8FzwXPCegC0orFkeBEeCT9fw8/xUHiD80jRA9ED0QOF8kBXBX+C+0J4fw14PlgBfnJYPXcF/QHwyvAcsCW9ANgN8I3wbTwMPrEEj1jRA9ED0QM+Hujo4E+w74dT1oO3rfzO7uMkwzJfg3UfrAfBCB4EekuIlMID1KXaKi6Lw2sp3BWzlNgDtHV1SteE1RmdDdbQ85Swhprfgx+Ab+ZeeJPfSFUP4LhJ4SHw6fC7cFFpHIpdDevhFKnGA/hkefhgeAT8CPwO/C38MjxPTdZ4GD3QMR6gbU8GHwZ/ArcixY/jYHVwu5twwvfgE+ExcNnovyi8NzxVt9Yitg+CFfBvhptRfAB0ayPpYLtp8Oq0XtWs4Te4diXpaeYlO8t7GD0APgB+Hu4Eeg8j9oQ7ejiuvhVi7+rw23Baig+AeifG81J7gIZ/fNrGn5Dv9FIb76o8DvgZrGDZiXQHRi3s6pMy5sfOGWCXwF+tbz0A5i6jzVHn6IFaD9CO14Y1jJOFtqrF7NhjPKTecafTlxh4BKzJn44l7MvS43mB8lqOGyl6oJQeoP1OA6sjk5XeAsBp/H/SUnpskkkGl1RvF7W1mewo+FEqtZN7uKu7OKUu7/yc34J/tBoiUvRAGT1wJEpb3N+zgLOMiwPKGvy1VLJbaHEM1TDQPB1qsOzLQhoe0yTxTFlAYtnogbw9QJtdApk/N5S7ggtWWYP/3Rj5uouhJc+rnoEeANqc1jFUsUeb67KSbqIzs4LE8tEDOXvgb8ibzFDmNy5YpQz+bG4Yj5FXuBjaAXk11HU7AVNDHZ1CQwwN2QzfrGuIF6GiB4J5gLaqjadrGgt4zgWvlMG/YuBx/L7rYmwH5NX3hvQAmL4DbJEJGxjbsb8xXoSLHjD3APevdusebwysXv9TLpilDf70/l/BUH03p9toEAYfUXajuQG0MmGYsR0a/okUPVB0DxyEgnqTt6QriYnvuwCWejMRAWQMxlp/iM3Ff+3Kq28ELUllO73mtUvZJLnU3VDSb0q6liFNw4FT4ZcvM2DEotEDwTxAu9fS5JGw9W7+YbR7p/uptD1/nKghkG4M/GqY6jWfqIMS02aBdNcDIFL0QFE98AcUsw78GgG52dXg0gZ/DF3f1dgOy78RD8ANy2gTeqvdbRFA99fo/YwNgBshowcye4B2vzwgO2YG6g3wO9q9c6enzMF/694+6LqUY0pq8WroPXsA3dUDihQ9UFQPnIBi1kPtj4F5vo/BlmtMfeR7leEJqt1seS3rew1Z+n62+GH4LVgTK+JxsHaXKpCJF4KHwFrCNQAOTcvii8E89UeHFmSMH+rBHYO/cUVFOBsPcJ9uCtJaNmgToRzk0+ufCKFMJzjyIDgkvQ/4ybBe05yJcn1hfWL6LPgrOCTt7axgGwvgiD7wa4Ec8n9tNC2Kjh5I9ABtXd/pfyZAm78mUWCnJuJABY+RARwpyG/gk2CzdfRgzVXBDPUQKNVmN3yxGhyKNu/Udh/tKq8HaOz7BGjw+udGi5XXKx6aY/A6ARxZhdzBQ6VURRCwPpzmP/RUdUn7+ykZS/PlT3T9S1rDHPPpK6h5DLWlqu+YKXpAHqBN6qudbzq25TTZR3Sdh/HKFWk845HHa9LEpQLQaXlYn161Jq2ZLzxhtP5b0evWxlfwLiu8A6KCXecB2uZvArX35bI6s1SrfXDi/Bi8cVajG5S/vkG6WTITM48ApiWO35qBfgc0xBgvFJz0DLHKR/oO159I0QNF8QDxSotBfhFAn5uIJY9mxS1V8MfYn8GhdH4yqzPTlKfS7iGf9RLNsmx22z6Njzzy6BtPpZr78LAxFimfB45E5WkCqK3/89E9xFNUY2cfwSFIkyf98/ImsjT7/x9DQ67KS3dfOdjaD9YqqhB0rK9esVz0QAgP0MgXhL8O0Ngvt9I3VC/aSr9anF04CTWh9yI98rG1wkIeI+sb8G80lDGzIVYoKO3IHhgAXHstTguAGyGjB7J4QG/31vuovgLz4CxK1Za1Vq4W2+yYp6d2xf3UDLA30Dm9k4Kn3G8ooQzBP9SQz7U8TF/29SVtSw+kTWHNJ+l+GA0/A99TeUhzGCl6IL0HaFMrknvr9CVS5zyONjkyde5OyIgzh8KhSMsvZ8jbT8hcwdCgj/PW30UedmrITktSQ5DXSicU6Q8fCzfS6x2unQ7P62JrzBs9QJu5FbYm7W3KbWi6MLWI0aGWd6qCNImcOyF3Twk3pMI2DGzcxdDOWqgnfCsOkHNqgZoca//A7+EQE3e+6sdyBfUA7UT7eUJQXp+zKY5n8eK8sCZkQ5D+L25b5j2Qe6GxQbMVp9Ym1gQ7Q/SE5D7NAzkT5bZQYUfS/oSdnYXFAl3jAdqHvj7wiGO7SpP9oq5xYq2heOaPabzjkWcMZdoSMJE7PfyZh87NirTFltq6SjpG4cHwuGaKe17T94H6JclslkaZaeE3PGWq2GHN8OO17vUAbWOrDO2qUVENS+ofwJhTW3q9aa3AaP3Tgz3S5nfM92cmT950LGOVfTeALP+hw0fg6WujRaSdUEoT9tb0/6i/rz1A96NMlgfl0bTLUG3Sw5xYpAgeoE30RY+jA+jye9r5mAC4xYbEodbj4kBOII3jzt0O65HbD35xghZ2f25phy1pZGLic3Zm9iB9yJHzsl/KqNf/Xg+K/4E+ALhJGvtjnu7wAO1hd//m1LDkK1yZIpQHC93zx+hQk7FH8TR9JZRTW+D+iOvztcjjevkh1wJ55Kfhrowc/Y8DazqV+vNZ4aT2ZLGyS728M7BPv5G63AO0Ay220G5ea/oV7fxLa9DC4+HQtWBrGg3glXBbHnrInQoO8WGzrYpYodh6CmxNemtzHrahjFWvv9Yer2WmRayrqJO/B2gQ+9U2CqPjB8EJMVzaY2hbgmCP9OYHIXr92lm7A09T7QptBx2AUOsPm30B5s3tMKaZTBquekPbNcvjee1c6s9nrsaq11+r9g61J/G4+zxAO9ewzCEBLD+Kdj4+AG6xIXHoXLDGVa3p1HZZjiFzw9YrfOSfv7fLpmZy0SvEyge1iQWayU26RpkQvX5gx8d/G5nk8C5Kow3sr4ZgTC+BF7xjHlyAZzv4CeWsx1P1XYzjPPWxKPYXQCxX+FR1Oq16ULDfEGvi/0VvyCfghuj1y92DuEmDvpoXrE6jOjUeoO7V6zf71k4N9MG083aNTtSokfOhHAq/C1vTCTmb0iMOQza2NqaC90iPkAIdoNsscIgvGi7taiZ6hOr1V6pgwjfbXdWK+TvAAzSAEGP9ub3JF7Hnrw+AzWjcNt4G77fGmKngaCAa+1avPwQVtdevsfDJjA3WB9ye8MAM1euvqmKxeqiKFX9L4gHua/3r1F8aq7srbXx3Y8zywOHUx2Br2q1dHsCQg62NqeDpw2NTt8uuZnLR69EANq/ZTGbSNXQI3euXmdYT+EmmxLSCeYB630uVb0jayWs91F0wrzVRB+NXN3RmFeoRDtoyLovcWeGPq4oY/+7fxJVtu4SNSxrbKbgHfQyi3DEBdKmF1GcrrN9wfEyNZXL0AHWujZqjYEsy+yctaV1RtGGfEN/s/wWvUu1aMvV7KmLatJXhkG8Uedu2cqmFnru2uO5z+U+uhbgr16JMiMm4WlWeoW1p+XCk7vKAFjPMY2zyxcZ45YHjZp0d/sryUQrWte3yALKXg0N9jbSQ68uxd3L4bdiStOzN6XWY/DPC+vBbaDq8Xe0rym2PB2hQk8HWn2d5C0zNIeRKRer5743lzl9pbOGto1tcD3KZipwS4PPgEP59FNyLgiieHVT/Ecv6v4rpA27fOqqmJb1BvoRYp8fwuvN42vke0MbF+YzNPJs2rqXo3UcES42hWX/24LZ2eRJbzoRD0dB22dVKLgZfb2y0/uG786Q2ZZ4w1iMJrpDfU2pVR/F6Ng/QEPTZBUvS6MDc2bTyKx2iZ+qjyZYUsl41cayPIlnLUJHbgvGjrDgNyl9ND6Fwn3KQrtg9mJ/1Gujtm3wa9n7mUVibb0LT+aEFRPxieYA2vgoarWis1XW08VeMMVPBFSX4W0/0Pof1N6bygGEmGodeB88whKyF+oiTfWoTCnas5bSW7UmvwSd52vi+Z7m0xZ4kY1En3NPaEPO5eyDECrvT3dWwKWF5s3ppRMBchoKreRVuXOhknqbjG1+2v4Id+r68lmvpNwQdiE2F/KcO2K52tLux0Rdg7xuemArOoUire7QZx+cfyYTSKeIG9gBtXHNIGqGwpFcBa9uilLYHf4y37vV/Aua5ljXUCouGoZn6y+ClWuX1vH4DwSa3bd8eOmq4R8M+VjQOoCzfYbrPSpEEnGOoi8cS0mNSZ3tA3xuz3tNxFm3JdTFDZ3iZoDkQ/hy2pFDDLolOR3H90+YLLA2ow9ImsbkShRckEf0urdM562mmNc8Inwb+JKsSCeUfJ816RVpBajGq0cgD1Lm+N6Yd9Zakb1/N0UhmHunt7vnvgZFaFmlJZ1uCpcD6A3l+mCKfb5aD6B3o9bCQRAOeDcU2MVbu+Cx4+OtTyl+YBSOh7Aek7Qh2HO5JcE6HJ+2AfTMZ2ziCtvS6MWY54Agak8LWmyWeytN69N8XDklX5WmPjyLine truncated
|
||||||
|
alt="Blink"
|
||||||
|
width="383"
|
||||||
|
height="170"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<svg style="width: 0; height: 0; position: absolute" aria-hidden="true" focusable="false">
|
<svg style="width: 0; height: 0; position: absolute" aria-hidden="true" focusable="false">
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
"version": "1.0.0-alpha.4",
|
"version": "1.0.0-alpha.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --force && tsr watch",
|
"dev": "vite && tsr watch",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
|
"tauri:dev:mcp": "tauri dev -c src-tauri/tauri.mcp.conf.json -- --features mcp-bridge",
|
||||||
"lint": "biome check src/**/*",
|
"lint": "biome check src/**/*",
|
||||||
"lint:fix": "biome check --apply src/**/*",
|
"lint:fix": "biome check --apply src/**/*",
|
||||||
"tanstack-router-dev": "tsr watch"
|
"tanstack-router-dev": "tsr watch"
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.14.1",
|
"@emotion/styled": "^11.14.1",
|
||||||
|
"@fontsource-variable/caveat": "^5.3.0",
|
||||||
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
||||||
"@fontsource-variable/noto-sans": "^5.3.0",
|
"@fontsource-variable/noto-sans": "^5.3.0",
|
||||||
"@fontsource-variable/plus-jakarta-sans": "^5.3.0",
|
"@fontsource-variable/plus-jakarta-sans": "^5.3.0",
|
||||||
@@ -29,15 +31,13 @@
|
|||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@react-spring/web": "^10.1.2",
|
"@react-spring/web": "^10.1.2",
|
||||||
"@tanem/react-nprogress": "^7.1.7",
|
"@tanem/react-nprogress": "^7.1.7",
|
||||||
"@tanstack/react-devtools": "^0.10.13",
|
|
||||||
"@tanstack/react-form": "^1.33.5",
|
"@tanstack/react-form": "^1.33.5",
|
||||||
"@tanstack/react-query": "^5.104.4",
|
"@tanstack/react-query": "^5.104.4",
|
||||||
"@tanstack/react-query-devtools": "^5.104.4",
|
|
||||||
"@tanstack/react-router": "^1.170.45",
|
"@tanstack/react-router": "^1.170.45",
|
||||||
"@tanstack/react-router-devtools": "^1.167.2",
|
|
||||||
"@tanstack/react-virtual": "^3.14.21",
|
"@tanstack/react-virtual": "^3.14.21",
|
||||||
"@tauri-apps/api": "2.12.4",
|
"@tauri-apps/api": "2.12.4",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.5.0",
|
"@tauri-apps/plugin-clipboard-manager": "2.5.0",
|
||||||
|
"@tauri-apps/plugin-deep-link": "2.6.3",
|
||||||
"@tauri-apps/plugin-dialog": "2.8.3",
|
"@tauri-apps/plugin-dialog": "2.8.3",
|
||||||
"@tauri-apps/plugin-global-shortcut": "~2.4.1",
|
"@tauri-apps/plugin-global-shortcut": "~2.4.1",
|
||||||
"@tauri-apps/plugin-notification": "2.7.0",
|
"@tauri-apps/plugin-notification": "2.7.0",
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
||||||
"@tauri-apps/plugin-updater": "2.14.0",
|
"@tauri-apps/plugin-updater": "2.14.0",
|
||||||
"@tauri-apps/plugin-upload": "2.5.0",
|
"@tauri-apps/plugin-upload": "2.5.0",
|
||||||
|
"@tauri-apps/plugin-websocket": "2.5.0",
|
||||||
"@tauri-apps/plugin-window-state": "~2.5.0",
|
"@tauri-apps/plugin-window-state": "~2.5.0",
|
||||||
"@types/node": "^26.6.5",
|
"@types/node": "^26.6.5",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.0",
|
||||||
@@ -61,6 +62,7 @@
|
|||||||
"material-symbols": "^0.48.0",
|
"material-symbols": "^0.48.0",
|
||||||
"motion": "^14.4.0",
|
"motion": "^14.4.0",
|
||||||
"notistack": "^3.0.2",
|
"notistack": "^3.0.2",
|
||||||
|
"qrcode": "^1.5.4",
|
||||||
"react": "^19.3.1",
|
"react": "^19.3.1",
|
||||||
"react-blurhash": "^0.3.0",
|
"react-blurhash": "^0.3.0",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
@@ -86,6 +88,7 @@
|
|||||||
"@tanstack/router-vite-plugin": "^1.167.47",
|
"@tanstack/router-vite-plugin": "^1.167.47",
|
||||||
"@tauri-apps/cli": "2.12.3",
|
"@tauri-apps/cli": "2.12.3",
|
||||||
"@types/lodash": "^4.17.26",
|
"@types/lodash": "^4.17.26",
|
||||||
|
"@types/qrcode": "^1.5.6",
|
||||||
"@vitejs/plugin-react": "^6.1.2",
|
"@vitejs/plugin-react": "^6.1.2",
|
||||||
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
||||||
"eslint-plugin-react-hooks": "7.1.1",
|
"eslint-plugin-react-hooks": "7.1.1",
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ rust-version = "1.59"
|
|||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.5.4", features = [] }
|
tauri-build = { version = "2.5.4", features = [] }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "blink_lib"
|
||||||
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "^0.4.21"
|
log = "^0.4.21"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
@@ -30,11 +34,16 @@ tauri-plugin-notification = "2.0.0-rc.1"
|
|||||||
tauri-plugin-upload = "2.0.0"
|
tauri-plugin-upload = "2.0.0"
|
||||||
tauri-plugin-dialog = "2.0.0"
|
tauri-plugin-dialog = "2.0.0"
|
||||||
tauri-plugin-shell = "2.3.5"
|
tauri-plugin-shell = "2.3.5"
|
||||||
|
tauri-plugin-websocket = "2.5.0"
|
||||||
|
tauri-plugin-deep-link = "2.6.3"
|
||||||
|
tauri-plugin-mcp-bridge = { version = "0.13.2", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# by default Tauri runs in production mode
|
# by default Tauri runs in production mode
|
||||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
||||||
default = [ "custom-protocol" ]
|
default = [ "custom-protocol" ]
|
||||||
|
# Dev-only MCP bridge for UI automation: `pnpm tauri dev -- --features mcp-bridge`
|
||||||
|
mcp-bridge = ["dep:tauri-plugin-mcp-bridge"]
|
||||||
# this feature is used for production builds where `devPath` points to the filesystem
|
# this feature is used for production builds where `devPath` points to the filesystem
|
||||||
# DO NOT remove this
|
# DO NOT remove this
|
||||||
custom-protocol = [ "tauri/custom-protocol" ]
|
custom-protocol = [ "tauri/custom-protocol" ]
|
||||||
@@ -42,3 +51,24 @@ custom-protocol = [ "tauri/custom-protocol" ]
|
|||||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
tauri-plugin-global-shortcut = "2"
|
tauri-plugin-global-shortcut = "2"
|
||||||
tauri-plugin-window-state = "2"
|
tauri-plugin-window-state = "2"
|
||||||
|
reqwest = { version = "0.12", default-features = false, features = [
|
||||||
|
"cookies",
|
||||||
|
"json",
|
||||||
|
"multipart",
|
||||||
|
"gzip",
|
||||||
|
"rustls-tls",
|
||||||
|
] }
|
||||||
|
|
||||||
|
# Keep each OS on its native secret store without pulling the others' system
|
||||||
|
# libraries into every build.
|
||||||
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
|
keyring = { version = "3", default-features = false, features = ["windows-native"] }
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
|
keyring = { version = "3", default-features = false, features = ["apple-native"] }
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
keyring = { version = "3", default-features = false, features = [
|
||||||
|
"sync-secret-service",
|
||||||
|
"crypto-rust",
|
||||||
|
] }
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
"global-shortcut:allow-is-registered",
|
"global-shortcut:allow-is-registered",
|
||||||
"global-shortcut:allow-register",
|
"global-shortcut:allow-register",
|
||||||
"global-shortcut:allow-unregister",
|
"global-shortcut:allow-unregister",
|
||||||
|
"websocket:default",
|
||||||
"shell:default"
|
"shell:default"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -17,9 +17,19 @@
|
|||||||
"updater:allow-install",
|
"updater:allow-install",
|
||||||
"notification:default",
|
"notification:default",
|
||||||
"core:webview:allow-internal-toggle-devtools",
|
"core:webview:allow-internal-toggle-devtools",
|
||||||
|
"core:window:allow-start-dragging",
|
||||||
|
"core:window:allow-start-resize-dragging",
|
||||||
|
"core:window:allow-minimize",
|
||||||
|
"core:window:allow-maximize",
|
||||||
|
"core:window:allow-unmaximize",
|
||||||
|
"core:window:allow-toggle-maximize",
|
||||||
|
"core:window:allow-close",
|
||||||
|
"core:window:allow-is-maximized",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"upload:allow-download",
|
"upload:allow-download",
|
||||||
"clipboard-manager:allow-write-text",
|
"clipboard-manager:allow-write-text",
|
||||||
|
"websocket:default",
|
||||||
|
"deep-link:default",
|
||||||
"shell:default",
|
"shell:default",
|
||||||
"shell:allow-open"
|
"shell:allow-open"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
|
"identifier": "mcp-bridge-capability",
|
||||||
|
"description": "Dev-only permissions for the Tauri MCP bridge (AI debugging). Enabled only by tauri.mcp.conf.json.",
|
||||||
|
"windows": ["main"],
|
||||||
|
"permissions": ["mcp-bridge:default"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# EditorConfig is awesome: https://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
insert_final_newline = false
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
||||||
|
key.properties
|
||||||
|
keystore.properties
|
||||||
|
|
||||||
|
/.tauri
|
||||||
|
/tauri.settings.gradle
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/src/main/**/generated
|
||||||
|
/src/main/jniLibs/**/*.so
|
||||||
|
/src/main/assets/tauri.conf.json
|
||||||
|
/tauri.build.gradle.kts
|
||||||
|
/proguard-tauri.pro
|
||||||
|
/tauri.properties
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import java.util.Properties
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("com.android.application")
|
||||||
|
id("org.jetbrains.kotlin.android")
|
||||||
|
id("rust")
|
||||||
|
}
|
||||||
|
|
||||||
|
val tauriProperties = Properties().apply {
|
||||||
|
val propFile = file("tauri.properties")
|
||||||
|
if (propFile.exists()) {
|
||||||
|
propFile.inputStream().use { load(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val keystoreProperties = Properties().apply {
|
||||||
|
val propFile = rootProject.file("keystore.properties")
|
||||||
|
if (propFile.exists()) {
|
||||||
|
propFile.inputStream().use { load(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk = 37
|
||||||
|
namespace = "com.blink.prayag17"
|
||||||
|
signingConfigs {
|
||||||
|
if (keystoreProperties.getProperty("storeFile") != null) {
|
||||||
|
create("release") {
|
||||||
|
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
||||||
|
storePassword = keystoreProperties.getProperty("storePassword")
|
||||||
|
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||||
|
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defaultConfig {
|
||||||
|
manifestPlaceholders["usesCleartextTraffic"] = "false"
|
||||||
|
applicationId = "com.blink.prayag17"
|
||||||
|
minSdk = 24
|
||||||
|
targetSdk = 37
|
||||||
|
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
||||||
|
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
getByName("debug") {
|
||||||
|
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
||||||
|
isDebuggable = true
|
||||||
|
isJniDebuggable = true
|
||||||
|
isMinifyEnabled = false
|
||||||
|
packaging {
|
||||||
|
jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
|
||||||
|
jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
|
||||||
|
jniLibs.keepDebugSymbols.add("*/x86/*.so")
|
||||||
|
jniLibs.keepDebugSymbols.add("*/x86_64/*.so")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getByName("release") {
|
||||||
|
signingConfig = if (keystoreProperties.getProperty("storeFile") != null) {
|
||||||
|
signingConfigs.getByName("release")
|
||||||
|
} else {
|
||||||
|
signingConfigs.getByName("debug")
|
||||||
|
}
|
||||||
|
optimization {
|
||||||
|
enable = true
|
||||||
|
}
|
||||||
|
proguardFiles(
|
||||||
|
*fileTree(".") {
|
||||||
|
include("**/*.pro")
|
||||||
|
exclude("build/**")
|
||||||
|
}.files.toTypedArray()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
buildFeatures {
|
||||||
|
buildConfig = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
compilerOptions {
|
||||||
|
jvmTarget = JvmTarget.JVM_1_8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rust {
|
||||||
|
rootDirRel = "../../../"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("androidx.webkit:webkit:1.14.0")
|
||||||
|
implementation("androidx.appcompat:appcompat:1.7.1")
|
||||||
|
implementation("androidx.activity:activity-ktx:1.10.1")
|
||||||
|
implementation("com.google.android.material:material:1.12.0")
|
||||||
|
implementation("androidx.lifecycle:lifecycle-process:2.10.0")
|
||||||
|
testImplementation("junit:junit:4.13.2")
|
||||||
|
androidTestImplementation("androidx.test.ext:junit:1.1.4")
|
||||||
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(from = file("tauri.build.gradle.kts"))
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<!-- AndroidTV support -->
|
||||||
|
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/Theme.blink"
|
||||||
|
android:usesCleartextTraffic="${usesCleartextTraffic}">
|
||||||
|
<activity
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:label="@string/main_activity_title"
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<!-- AndroidTV support -->
|
||||||
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- DEEP LINK PLUGIN. AUTO-GENERATED. DO NOT REMOVE. -->
|
||||||
|
|
||||||
|
<!-- DEEP LINK PLUGIN. AUTO-GENERATED. DO NOT REMOVE. -->
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.blink.prayag17
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
|
||||||
|
class MainActivity : TauriActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
enableEdgeToEdge()
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Hello World!"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.blink" parent="Theme.Material3.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="purple_200">#FFBB86FC</color>
|
||||||
|
<color name="purple_500">#FF6200EE</color>
|
||||||
|
<color name="purple_700">#FF3700B3</color>
|
||||||
|
<color name="teal_200">#FF03DAC5</color>
|
||||||
|
<color name="teal_700">#FF018786</color>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">"Blink"</string>
|
||||||
|
<string name="main_activity_title">"Blink"</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.blink" parent="Theme.Material3.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<external-path name="my_images" path="." />
|
||||||
|
<cache-path name="my_cache_images" path="." />
|
||||||
|
</paths>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("com.android.tools.build:gradle:9.3.1")
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.10")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("clean").configure {
|
||||||
|
delete("build")
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
gradlePlugin {
|
||||||
|
plugins {
|
||||||
|
create("pluginsForCoolKids") {
|
||||||
|
id = "rust"
|
||||||
|
implementationClass = "RustPlugin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly(gradleApi())
|
||||||
|
implementation("com.android.tools.build:gradle:9.3.1")
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import java.io.File
|
||||||
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.GradleException
|
||||||
|
import org.gradle.api.logging.LogLevel
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import javax.inject.Inject
|
||||||
|
import org.gradle.process.ExecOperations
|
||||||
|
|
||||||
|
abstract class BuildTask : DefaultTask() {
|
||||||
|
@get:Inject
|
||||||
|
abstract val execOperations: ExecOperations
|
||||||
|
|
||||||
|
@Input
|
||||||
|
var rootDirRel: String? = null
|
||||||
|
@Input
|
||||||
|
var projectDir: String? = null
|
||||||
|
@Input
|
||||||
|
var target: String? = null
|
||||||
|
@Input
|
||||||
|
var release: Boolean? = null
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
fun assemble() {
|
||||||
|
val executable = """pnpm""";
|
||||||
|
try {
|
||||||
|
runTauriCli(executable)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||||
|
// Try different Windows-specific extensions
|
||||||
|
val fallbacks = listOf(
|
||||||
|
"$executable.exe",
|
||||||
|
"$executable.cmd",
|
||||||
|
"$executable.bat",
|
||||||
|
)
|
||||||
|
|
||||||
|
var lastException: Exception = e
|
||||||
|
for (fallback in fallbacks) {
|
||||||
|
try {
|
||||||
|
runTauriCli(fallback)
|
||||||
|
return
|
||||||
|
} catch (fallbackException: Exception) {
|
||||||
|
lastException = fallbackException
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw lastException
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun runTauriCli(executable: String) {
|
||||||
|
val rootDirRel = rootDirRel ?: throw GradleException("rootDirRel cannot be null")
|
||||||
|
val target = target ?: throw GradleException("target cannot be null")
|
||||||
|
val release = release ?: throw GradleException("release cannot be null")
|
||||||
|
val args = listOf("tauri", "android", "android-studio-script");
|
||||||
|
|
||||||
|
execOperations.exec {
|
||||||
|
workingDir(File(projectDir, rootDirRel))
|
||||||
|
executable(executable)
|
||||||
|
args(args)
|
||||||
|
if (logger.isEnabled(LogLevel.DEBUG)) {
|
||||||
|
args("-vv")
|
||||||
|
} else if (logger.isEnabled(LogLevel.INFO)) {
|
||||||
|
args("-v")
|
||||||
|
}
|
||||||
|
if (release) {
|
||||||
|
args("--release")
|
||||||
|
}
|
||||||
|
args(listOf("--target", target))
|
||||||
|
}.assertNormalExitValue()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import com.android.build.api.dsl.ApplicationExtension
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
|
|
||||||
|
const val TASK_GROUP = "rust"
|
||||||
|
|
||||||
|
open class Config {
|
||||||
|
lateinit var rootDirRel: String
|
||||||
|
}
|
||||||
|
|
||||||
|
open class RustPlugin : Plugin<Project> {
|
||||||
|
private lateinit var config: Config
|
||||||
|
|
||||||
|
override fun apply(project: Project) = with(project) {
|
||||||
|
config = extensions.create("rust", Config::class.java)
|
||||||
|
|
||||||
|
val defaultAbiList = listOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64");
|
||||||
|
val abiList = (findProperty("abiList") as? String)?.split(',') ?: defaultAbiList
|
||||||
|
|
||||||
|
val defaultArchList = listOf("arm64", "arm", "x86", "x86_64");
|
||||||
|
val archList = (findProperty("archList") as? String)?.split(',') ?: defaultArchList
|
||||||
|
|
||||||
|
val targetsList = (findProperty("targetList") as? String)?.split(',') ?: listOf("aarch64", "armv7", "i686", "x86_64")
|
||||||
|
|
||||||
|
extensions.configure<ApplicationExtension> {
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
flavorDimensions.add("abi")
|
||||||
|
productFlavors {
|
||||||
|
create("universal") {
|
||||||
|
dimension = "abi"
|
||||||
|
ndk {
|
||||||
|
abiFilters += abiList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defaultArchList.forEachIndexed { index, arch ->
|
||||||
|
create(arch) {
|
||||||
|
dimension = "abi"
|
||||||
|
ndk {
|
||||||
|
abiFilters.add(defaultAbiList[index])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
for (profile in listOf("debug", "release")) {
|
||||||
|
val profileCapitalized = profile.replaceFirstChar { it.uppercase() }
|
||||||
|
val buildTask = tasks.maybeCreate(
|
||||||
|
"rustBuildUniversal$profileCapitalized",
|
||||||
|
DefaultTask::class.java
|
||||||
|
).apply {
|
||||||
|
group = TASK_GROUP
|
||||||
|
description = "Build dynamic library in $profile mode for all targets"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks["mergeUniversal${profileCapitalized}JniLibFolders"].dependsOn(buildTask)
|
||||||
|
|
||||||
|
for (targetPair in targetsList.withIndex()) {
|
||||||
|
val targetName = targetPair.value
|
||||||
|
val targetArch = archList[targetPair.index]
|
||||||
|
val targetArchCapitalized = targetArch.replaceFirstChar { it.uppercase() }
|
||||||
|
val targetBuildTask = project.tasks.register(
|
||||||
|
"rustBuild$targetArchCapitalized$profileCapitalized",
|
||||||
|
BuildTask::class.java
|
||||||
|
) {
|
||||||
|
group = TASK_GROUP
|
||||||
|
description = "Build dynamic library in $profile mode for $targetArch"
|
||||||
|
rootDirRel = config.rootDirRel
|
||||||
|
projectDir = project.projectDir.path
|
||||||
|
target = targetName
|
||||||
|
release = profile == "release"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTask.dependsOn(targetBuildTask)
|
||||||
|
tasks["merge$targetArchCapitalized${profileCapitalized}JniLibFolders"].dependsOn(
|
||||||
|
targetBuildTask
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
org.gradle.configuration-cache=true
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
||||||
|
|
||||||
|
# Our old plugin template had a bug that caused missing `consumer-rules.pro` files
|
||||||
|
# so we have to disable it for now.
|
||||||
|
# See https://github.com/tauri-apps/tauri/pull/15828#issuecomment-5199937796
|
||||||
|
android.proguard.failOnMissingFiles=false
|
||||||
|
|
||||||
|
# Keeping Gradle 9 compatible with current plugins
|
||||||
|
# TODO: Remove this in v3
|
||||||
|
android.builtInKotlin=false
|
||||||
|
android.newDsl=false
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#Tue May 10 19:22:52 CST 2022
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
@@ -0,0 +1,248 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# gradlew start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh gradlew
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem gradlew startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||||
|
setlocal EnableExtensions
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute gradlew
|
||||||
|
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||||
|
@rem which allows us to clear the local environment before executing the java command
|
||||||
|
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||||
|
|
||||||
|
:exitWithErrorLevel
|
||||||
|
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||||
|
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
include ':app'
|
||||||
|
|
||||||
|
apply from: 'tauri.settings.gradle'
|
||||||
@@ -1 +1 @@
|
|||||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-secret":{"identifier":"allow-write-secret","description":"Enables the write_secret command without any pre-configured scope.","commands":{"allow":["write_secret"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-secret":{"identifier":"deny-write-secret","description":"Denies the write_secret command without any pre-configured scope.","commands":{"allow":[],"deny":["write_secret"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-exit":{"identifier":"allow-exit","description":"Enables the exit command without any pre-configured scope.","commands":{"allow":["exit"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","coLine truncated
|
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-secret":{"identifier":"allow-write-secret","description":"Enables the write_secret command without any pre-configured scope.","commands":{"allow":["write_secret"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-secret":{"identifier":"deny-write-secret","description":"Denies the write_secret command without any pre-configured scope.","commands":{"allow":[],"deny":["write_secret"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-exit":{"identifier":"allow-exit","description":"Enables the exit command without any pre-configured scope.","commands":{"allow":["exit"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","coLine truncated
|
||||||
@@ -1 +1 @@
|
|||||||
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"windows":["main"],"permissions":["window-state:default","global-shortcut:default","global-shortcut:allow-is-registered","global-shortcut:allow-register","global-shortcut:allow-unregister","shell:default"],"platforms":["macOS","windows","linux"]},"main-capabilities":{"identifier":"main-capabilities","description":"Capability for desktop window","local":true,"windows":["main"],"permissions":["store:allow-get","store:allow-set","store:allow-save","store:allow-clear","store:allow-delete","store:allow-keys","store:allow-load","updater:allow-check","updater:allow-download-and-install","updater:allow-download","updater:allow-install","notification:default","core:webview:allow-internal-toggle-devtools","dialog:default","upload:allow-download","clipboard-manager:allow-write-text","shell:default","shell:allow-open"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-fullscreen","shell:default"]}}
|
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"windows":["main"],"permissions":["window-state:default","global-shortcut:default","global-shortcut:allow-is-registered","global-shortcut:allow-register","global-shortcut:allow-unregister","websocket:default","shell:default"],"platforms":["macOS","windows","linux"]},"main-capabilities":{"identifier":"main-capabilities","description":"Capability for desktop window","local":true,"windows":["main"],"permissions":["store:allow-get","store:allow-set","store:allow-save","store:allow-clear","store:allow-delete","store:allow-keys","store:allow-load","updater:allow-check","updater:allow-download-and-install","updater:allow-download","updater:allow-install","notification:default","core:webview:allow-internal-toggle-devtools","core:window:allow-start-dragging","core:window:allow-start-resize-dragging","core:window:allow-minimize","core:window:allow-maximize","core:window:allow-unmaximize","core:window:allow-toggle-maximize","core:window:allow-close","core:window:allow-is-maximized","dialog:default","upload:allow-download","clipboard-manager:allow-write-text","websocket:default","deep-link:default","shell:default","shell:allow-open"]},"mcp-bridge-capability":{"identifier":"mcp-bridge-capability","description":"Dev-only permissions for the Tauri MCP bridge (AI debugging). Enabled only by tauri.mcp.conf.json.","local":true,"windows":["main"],"permissions":["mcp-bridge:default"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-fullscreen","shell:default"]}}
|
||||||
@@ -2516,6 +2516,60 @@
|
|||||||
"const": "core:window:deny-unminimize",
|
"const": "core:window:deny-unminimize",
|
||||||
"markdownDescription": "Denies the unminimize command without any pre-configured scope."
|
"markdownDescription": "Denies the unminimize command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "Allows reading the opened deep link via the get_current command\n#### This default permission set includes:\n\n- `allow-get-current`",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:default",
|
||||||
|
"markdownDescription": "Allows reading the opened deep link via the get_current command\n#### This default permission set includes:\n\n- `allow-get-current`"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the get_current command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:allow-get-current",
|
||||||
|
"markdownDescription": "Enables the get_current command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the is_registered command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:allow-is-registered",
|
||||||
|
"markdownDescription": "Enables the is_registered command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the register command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:allow-register",
|
||||||
|
"markdownDescription": "Enables the register command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the unregister command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:allow-unregister",
|
||||||
|
"markdownDescription": "Enables the unregister command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the get_current command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:deny-get-current",
|
||||||
|
"markdownDescription": "Denies the get_current command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the is_registered command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:deny-is-registered",
|
||||||
|
"markdownDescription": "Denies the is_registered command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the register command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:deny-register",
|
||||||
|
"markdownDescription": "Denies the register command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the unregister command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:deny-unregister",
|
||||||
|
"markdownDescription": "Denies the unregister command without any pre-configured scope."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n\n#### This default permission set includes:\n\n- `allow-message`\n- `allow-save`\n- `allow-open`",
|
"description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n\n#### This default permission set includes:\n\n- `allow-message`\n- `allow-save`\n- `allow-open`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -3230,6 +3284,36 @@
|
|||||||
"const": "upload:deny-upload",
|
"const": "upload:deny-upload",
|
||||||
"markdownDescription": "Denies the upload command without any pre-configured scope."
|
"markdownDescription": "Denies the upload command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "Allows connecting and sending data to a WebSocket server\n#### This default permission set includes:\n\n- `allow-connect`\n- `allow-send`",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:default",
|
||||||
|
"markdownDescription": "Allows connecting and sending data to a WebSocket server\n#### This default permission set includes:\n\n- `allow-connect`\n- `allow-send`"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the connect command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:allow-connect",
|
||||||
|
"markdownDescription": "Enables the connect command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the send command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:allow-send",
|
||||||
|
"markdownDescription": "Enables the send command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the connect command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:deny-connect",
|
||||||
|
"markdownDescription": "Denies the connect command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the send command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:deny-send",
|
||||||
|
"markdownDescription": "Denies the send command without any pre-configured scope."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-filename`\n- `allow-restore-state`\n- `allow-save-window-state`",
|
"description": "This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-filename`\n- `allow-restore-state`\n- `allow-save-window-state`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -2516,6 +2516,60 @@
|
|||||||
"const": "core:window:deny-unminimize",
|
"const": "core:window:deny-unminimize",
|
||||||
"markdownDescription": "Denies the unminimize command without any pre-configured scope."
|
"markdownDescription": "Denies the unminimize command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "Allows reading the opened deep link via the get_current command\n#### This default permission set includes:\n\n- `allow-get-current`",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:default",
|
||||||
|
"markdownDescription": "Allows reading the opened deep link via the get_current command\n#### This default permission set includes:\n\n- `allow-get-current`"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the get_current command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:allow-get-current",
|
||||||
|
"markdownDescription": "Enables the get_current command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the is_registered command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:allow-is-registered",
|
||||||
|
"markdownDescription": "Enables the is_registered command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the register command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:allow-register",
|
||||||
|
"markdownDescription": "Enables the register command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the unregister command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:allow-unregister",
|
||||||
|
"markdownDescription": "Enables the unregister command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the get_current command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:deny-get-current",
|
||||||
|
"markdownDescription": "Denies the get_current command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the is_registered command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:deny-is-registered",
|
||||||
|
"markdownDescription": "Denies the is_registered command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the register command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:deny-register",
|
||||||
|
"markdownDescription": "Denies the register command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the unregister command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deep-link:deny-unregister",
|
||||||
|
"markdownDescription": "Denies the unregister command without any pre-configured scope."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n\n#### This default permission set includes:\n\n- `allow-message`\n- `allow-save`\n- `allow-open`",
|
"description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n\n#### This default permission set includes:\n\n- `allow-message`\n- `allow-save`\n- `allow-open`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -3230,6 +3284,36 @@
|
|||||||
"const": "upload:deny-upload",
|
"const": "upload:deny-upload",
|
||||||
"markdownDescription": "Denies the upload command without any pre-configured scope."
|
"markdownDescription": "Denies the upload command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "Allows connecting and sending data to a WebSocket server\n#### This default permission set includes:\n\n- `allow-connect`\n- `allow-send`",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:default",
|
||||||
|
"markdownDescription": "Allows connecting and sending data to a WebSocket server\n#### This default permission set includes:\n\n- `allow-connect`\n- `allow-send`"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the connect command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:allow-connect",
|
||||||
|
"markdownDescription": "Enables the connect command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the send command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:allow-send",
|
||||||
|
"markdownDescription": "Enables the send command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the connect command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:deny-connect",
|
||||||
|
"markdownDescription": "Denies the connect command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the send command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "websocket:deny-send",
|
||||||
|
"markdownDescription": "Denies the send command without any pre-configured scope."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-filename`\n- `allow-restore-state`\n- `allow-save-window-state`",
|
"description": "This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-filename`\n- `allow-restore-state`\n- `allow-save-window-state`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
use tauri::Manager;
|
||||||
|
use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
mod qbittorrent;
|
||||||
|
|
||||||
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
|
pub fn run() {
|
||||||
|
let builder = tauri::Builder::default();
|
||||||
|
|
||||||
|
// Dev-only MCP bridge: `pnpm tauri dev -- --features mcp-bridge`.
|
||||||
|
#[cfg(all(debug_assertions, feature = "mcp-bridge"))]
|
||||||
|
let builder = builder.plugin(
|
||||||
|
tauri_plugin_mcp_bridge::Builder::new()
|
||||||
|
.bind_address("127.0.0.1")
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Desktop-only integrations. The Android/iOS build has no qBittorrent
|
||||||
|
// commands, global shortcuts, window state or in-app updater.
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
let builder = builder
|
||||||
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
qbittorrent::qb_get_settings,
|
||||||
|
qbittorrent::qb_save_settings,
|
||||||
|
qbittorrent::qb_forget_secret,
|
||||||
|
qbittorrent::qb_test_connection,
|
||||||
|
qbittorrent::qb_categories,
|
||||||
|
qbittorrent::qb_add_torrent,
|
||||||
|
qbittorrent::qb_poll,
|
||||||
|
qbittorrent::qb_pause,
|
||||||
|
qbittorrent::qb_resume,
|
||||||
|
qbittorrent::qb_delete,
|
||||||
|
qbittorrent::qb_set_category,
|
||||||
|
])
|
||||||
|
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||||
|
.plugin(tauri_plugin_window_state::Builder::new().build())
|
||||||
|
.plugin(tauri_plugin_updater::Builder::default().build());
|
||||||
|
|
||||||
|
builder
|
||||||
|
.setup(|app| {
|
||||||
|
#[cfg(not(any(
|
||||||
|
target_os = "android",
|
||||||
|
target_os = "ios",
|
||||||
|
target_os = "macos"
|
||||||
|
)))]
|
||||||
|
{
|
||||||
|
app.manage(qbittorrent::QbState::load(app.handle()));
|
||||||
|
|
||||||
|
// Frameless window outside macOS. macOS uses the native overlay
|
||||||
|
// titlebar with its traffic lights.
|
||||||
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
|
window.set_decorations(false)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.plugin(tauri_plugin_shell::init())
|
||||||
|
.plugin(tauri_plugin_dialog::init())
|
||||||
|
.plugin(tauri_plugin_upload::init())
|
||||||
|
.plugin(tauri_plugin_notification::init())
|
||||||
|
.plugin(tauri_plugin_clipboard_manager::init())
|
||||||
|
.plugin(tauri_plugin_websocket::init())
|
||||||
|
.plugin(tauri_plugin_deep_link::init())
|
||||||
|
.plugin(
|
||||||
|
tauri_plugin_log::Builder::default()
|
||||||
|
.targets([Target::new(TargetKind::Webview)])
|
||||||
|
.with_colors(ColoredLevelConfig::default())
|
||||||
|
.build(),
|
||||||
|
)
|
||||||
|
.plugin(tauri_plugin_store::Builder::default().build())
|
||||||
|
.run(tauri::generate_context!())
|
||||||
|
.expect("error while running Blink");
|
||||||
|
}
|
||||||
@@ -1,25 +1,5 @@
|
|||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
blink_lib::run();
|
||||||
.plugin(tauri_plugin_shell::init())
|
|
||||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
|
||||||
.plugin(tauri_plugin_window_state::Builder::new().build())
|
|
||||||
.plugin(tauri_plugin_dialog::init())
|
|
||||||
.plugin(tauri_plugin_upload::init())
|
|
||||||
.plugin(tauri_plugin_notification::init())
|
|
||||||
.plugin(tauri_plugin_clipboard_manager::init())
|
|
||||||
.plugin(
|
|
||||||
tauri_plugin_log::Builder::default()
|
|
||||||
.targets([Target::new(TargetKind::Webview)])
|
|
||||||
.with_colors(ColoredLevelConfig::default())
|
|
||||||
.build(),
|
|
||||||
)
|
|
||||||
.plugin(tauri_plugin_store::Builder::default().build())
|
|
||||||
.plugin(tauri_plugin_updater::Builder::default().build())
|
|
||||||
// .plugin(tauri_plugin_window_state::Builder::default().build())
|
|
||||||
.run(tauri::generate_context!())
|
|
||||||
.expect("error while running Blink");
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,496 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use reqwest::header::{ORIGIN, REFERER};
|
||||||
|
use reqwest::multipart::{Form, Part};
|
||||||
|
use reqwest::{Client, RequestBuilder, Response, StatusCode};
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
use super::types::{QbAddResponse, QbAddResult, QbCategory, QbConnectionInfo, QbError, QbSettings};
|
||||||
|
|
||||||
|
const CONNECT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||||
|
const REQUEST_TIMEOUT: Duration = Duration::from_secs(20);
|
||||||
|
const UPLOAD_TIMEOUT: Duration = Duration::from_secs(60);
|
||||||
|
|
||||||
|
pub struct AddTorrentInput {
|
||||||
|
pub magnet: Option<String>,
|
||||||
|
pub file_name: Option<String>,
|
||||||
|
pub file_bytes: Option<Vec<u8>>,
|
||||||
|
pub category: Option<String>,
|
||||||
|
pub paused: bool,
|
||||||
|
pub auto_tmm: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Trim, validate and normalise a WebUI address.
|
||||||
|
///
|
||||||
|
/// Accepts `host:port`, `http(s)://host:port`, a trailing slash, and a pasted
|
||||||
|
/// `.../api/v2` URL, because those are the shapes users actually copy around.
|
||||||
|
pub fn normalize_base_url(raw: &str) -> Result<String, QbError> {
|
||||||
|
let mut url = raw.trim().trim_end_matches('/').to_string();
|
||||||
|
if url.is_empty() {
|
||||||
|
return Err(QbError::config("Укажите адрес qBittorrent WebUI"));
|
||||||
|
}
|
||||||
|
if !url.starts_with("http://") && !url.starts_with("https://") {
|
||||||
|
url = format!("http://{url}");
|
||||||
|
}
|
||||||
|
if let Some(stripped) = url.strip_suffix("/api/v2") {
|
||||||
|
url = stripped.trim_end_matches('/').to_string();
|
||||||
|
}
|
||||||
|
if url.is_empty() {
|
||||||
|
return Err(QbError::config("Укажите адрес qBittorrent WebUI"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let parsed = reqwest::Url::parse(&url)
|
||||||
|
.map_err(|_| QbError::config("Некорректный адрес qBittorrent WebUI"))?;
|
||||||
|
if parsed.scheme() != "http" && parsed.scheme() != "https" {
|
||||||
|
return Err(QbError::config(
|
||||||
|
"Адрес qBittorrent должен начинаться с http:// или https://",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if parsed.host_str().is_none() {
|
||||||
|
return Err(QbError::config("В адресе qBittorrent нет имени хоста"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn map_reqwest(err: reqwest::Error) -> QbError {
|
||||||
|
let text = err.to_string();
|
||||||
|
let lower = text.to_lowercase();
|
||||||
|
|
||||||
|
if lower.contains("certificate") || lower.contains("tls") || lower.contains("ssl") {
|
||||||
|
return QbError::new(
|
||||||
|
"tls",
|
||||||
|
"Сертификат qBittorrent не принят. Если используется самоподписанный \
|
||||||
|
сертификат, включите соответствующую настройку.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if err.is_timeout() {
|
||||||
|
return QbError::new("unreachable", "qBittorrent не ответил вовремя");
|
||||||
|
}
|
||||||
|
if err.is_connect() || lower.contains("connection refused") {
|
||||||
|
return QbError::new(
|
||||||
|
"unreachable",
|
||||||
|
"Не удалось подключиться к qBittorrent. Проверьте адрес и что WebUI запущен.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
QbError::new("http", text)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn http_error(status: StatusCode) -> QbError {
|
||||||
|
let code = status.as_u16();
|
||||||
|
match code {
|
||||||
|
401 => QbError::with_status(
|
||||||
|
"auth",
|
||||||
|
"qBittorrent отклонил сессию. Проверьте логин и пароль.",
|
||||||
|
code,
|
||||||
|
),
|
||||||
|
403 => QbError::with_status(
|
||||||
|
"auth",
|
||||||
|
"qBittorrent запретил запрос (403). Проверьте вход и адрес WebUI; \
|
||||||
|
после нескольких неудачных попыток qBittorrent временно блокирует IP.",
|
||||||
|
code,
|
||||||
|
),
|
||||||
|
404 => QbError::with_status(
|
||||||
|
"http",
|
||||||
|
"Метод qBittorrent не найден (404). Возможно, версия qBittorrent слишком старая.",
|
||||||
|
code,
|
||||||
|
),
|
||||||
|
415 => QbError::with_status("torrent", "qBittorrent не принял файл торрента", code),
|
||||||
|
_ => QbError::with_status("http", format!("qBittorrent вернул ошибку {code}"), code),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn join_hashes(hashes: &[String]) -> String {
|
||||||
|
if hashes.is_empty() {
|
||||||
|
"all".to_string()
|
||||||
|
} else {
|
||||||
|
hashes.join("|")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct QbClient {
|
||||||
|
pub http: Client,
|
||||||
|
pub base_url: String,
|
||||||
|
username: String,
|
||||||
|
secret: String,
|
||||||
|
use_api_key: bool,
|
||||||
|
/// Minor part of the WebAPI version (`2.11` -> `11`); 0 until connected.
|
||||||
|
pub api_minor: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl QbClient {
|
||||||
|
pub fn new(settings: &QbSettings, secret: &str) -> Result<Self, QbError> {
|
||||||
|
let base_url = normalize_base_url(&settings.base_url)?;
|
||||||
|
let http = Client::builder()
|
||||||
|
.cookie_store(true)
|
||||||
|
.connect_timeout(CONNECT_TIMEOUT)
|
||||||
|
.timeout(REQUEST_TIMEOUT)
|
||||||
|
.user_agent(concat!("Blink/", env!("CARGO_PKG_VERSION")))
|
||||||
|
.danger_accept_invalid_certs(settings.allow_invalid_certs)
|
||||||
|
.build()
|
||||||
|
.map_err(map_reqwest)?;
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
http,
|
||||||
|
base_url,
|
||||||
|
username: settings.username.trim().to_string(),
|
||||||
|
secret: secret.to_string(),
|
||||||
|
use_api_key: settings.use_api_key,
|
||||||
|
api_minor: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a client, authenticate it and read its WebAPI version.
|
||||||
|
pub async fn connect(settings: &QbSettings, secret: &str) -> Result<Self, QbError> {
|
||||||
|
let mut client = Self::new(settings, secret)?;
|
||||||
|
if !client.use_api_key {
|
||||||
|
client.login().await?;
|
||||||
|
}
|
||||||
|
let version = client.get_text("/api/v2/app/webapiVersion").await?;
|
||||||
|
client.api_minor = version
|
||||||
|
.trim()
|
||||||
|
.split('.')
|
||||||
|
.nth(1)
|
||||||
|
.and_then(|minor| minor.parse().ok())
|
||||||
|
.unwrap_or(0);
|
||||||
|
Ok(client)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn url(&self, path: &str) -> String {
|
||||||
|
format!("{}{}", self.base_url, path)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decorate(&self, request: RequestBuilder) -> RequestBuilder {
|
||||||
|
let request = request
|
||||||
|
.header(REFERER, &self.base_url)
|
||||||
|
.header(ORIGIN, &self.base_url);
|
||||||
|
if self.use_api_key {
|
||||||
|
request.bearer_auth(&self.secret)
|
||||||
|
} else {
|
||||||
|
request
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn send<F>(&self, build: F) -> Result<Response, QbError>
|
||||||
|
where
|
||||||
|
F: Fn() -> RequestBuilder,
|
||||||
|
{
|
||||||
|
let first = self.decorate(build()).send().await.map_err(map_reqwest)?;
|
||||||
|
|
||||||
|
// The WebUI session can expire while the app is open. Re-login once
|
||||||
|
// and repeat the request instead of surfacing a spurious auth error.
|
||||||
|
if matches!(first.status().as_u16(), 401 | 403) && !self.use_api_key {
|
||||||
|
drop(first);
|
||||||
|
self.login().await?;
|
||||||
|
return self.decorate(build()).send().await.map_err(map_reqwest);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(first)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn login(&self) -> Result<(), QbError> {
|
||||||
|
let response = self
|
||||||
|
.http
|
||||||
|
.post(self.url("/api/v2/auth/login"))
|
||||||
|
.header(REFERER, &self.base_url)
|
||||||
|
.header(ORIGIN, &self.base_url)
|
||||||
|
.form(&[
|
||||||
|
("username", self.username.as_str()),
|
||||||
|
("password", self.secret.as_str()),
|
||||||
|
])
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.map_err(map_reqwest)?;
|
||||||
|
|
||||||
|
let status = response.status();
|
||||||
|
match status.as_u16() {
|
||||||
|
200 => {
|
||||||
|
let body = response.text().await.unwrap_or_default();
|
||||||
|
if body.trim().eq_ignore_ascii_case("Fails.") {
|
||||||
|
Err(QbError::with_status(
|
||||||
|
"auth",
|
||||||
|
"Неверный логин или пароль qBittorrent",
|
||||||
|
200,
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
204 => Ok(()),
|
||||||
|
401 => Err(QbError::with_status(
|
||||||
|
"auth",
|
||||||
|
"Неверный логин или пароль qBittorrent",
|
||||||
|
401,
|
||||||
|
)),
|
||||||
|
403 => Err(QbError::with_status(
|
||||||
|
"banned",
|
||||||
|
"qBittorrent заблокировал вход с этого IP. Подождите и попробуйте снова.",
|
||||||
|
403,
|
||||||
|
)),
|
||||||
|
_ => Err(http_error(status)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_text(&self, path: &str) -> Result<String, QbError> {
|
||||||
|
let url = self.url(path);
|
||||||
|
let response = self.send(|| self.http.get(&url)).await?;
|
||||||
|
let status = response.status();
|
||||||
|
if !status.is_success() {
|
||||||
|
return Err(http_error(status));
|
||||||
|
}
|
||||||
|
response.text().await.map_err(map_reqwest)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_json<T>(&self, path: &str) -> Result<T, QbError>
|
||||||
|
where
|
||||||
|
T: serde::de::DeserializeOwned,
|
||||||
|
{
|
||||||
|
let text = self.get_text(path).await?;
|
||||||
|
serde_json::from_str(&text)
|
||||||
|
.map_err(|err| QbError::new("http", format!("Некорректный ответ qBittorrent: {err}")))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn post_form(&self, path: &str, form: Vec<(String, String)>) -> Result<(), QbError> {
|
||||||
|
let url = self.url(path);
|
||||||
|
let response = self
|
||||||
|
.send(|| self.http.post(&url).form(&form))
|
||||||
|
.await
|
||||||
|
.map_err(|err| err)?;
|
||||||
|
let status = response.status();
|
||||||
|
if status.is_success() {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(http_error(status))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn connection_info(&self) -> Result<QbConnectionInfo, QbError> {
|
||||||
|
let app_version = self.get_text("/api/v2/app/version").await?;
|
||||||
|
let api_version = self.get_text("/api/v2/app/webapiVersion").await?;
|
||||||
|
let default_save_path = self.get_text("/api/v2/app/defaultSavePath").await?;
|
||||||
|
|
||||||
|
Ok(QbConnectionInfo {
|
||||||
|
app_version: app_version.trim().to_string(),
|
||||||
|
api_version: api_version.trim().to_string(),
|
||||||
|
default_save_path: default_save_path.trim().to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn categories(&self) -> Result<Vec<QbCategory>, QbError> {
|
||||||
|
let categories: HashMap<String, QbCategory> =
|
||||||
|
self.get_json("/api/v2/torrents/categories").await?;
|
||||||
|
|
||||||
|
let mut list: Vec<QbCategory> = categories
|
||||||
|
.into_iter()
|
||||||
|
.map(|(name, mut category)| {
|
||||||
|
if category.name.is_empty() {
|
||||||
|
category.name = name;
|
||||||
|
}
|
||||||
|
category
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
list.sort_by_key(|category| category.name.to_lowercase());
|
||||||
|
Ok(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn add_torrent(&self, input: AddTorrentInput) -> Result<QbAddResult, QbError> {
|
||||||
|
let url = self.url("/api/v2/torrents/add");
|
||||||
|
let magnet = input.magnet.clone();
|
||||||
|
let file_name = input.file_name.clone();
|
||||||
|
let file_bytes = input.file_bytes.clone();
|
||||||
|
let category = input.category.clone();
|
||||||
|
let paused = input.paused;
|
||||||
|
let auto_tmm = input.auto_tmm;
|
||||||
|
|
||||||
|
// Build the multipart body on every attempt: a Form cannot be cloned,
|
||||||
|
// and send() may retry once after re-login.
|
||||||
|
let build_form = || {
|
||||||
|
let mut form = Form::new()
|
||||||
|
// qBittorrent 4.x spells this `paused`, 5.x `stopped`; both
|
||||||
|
// ignore the other key, so sending both keeps every version.
|
||||||
|
.text("paused", if paused { "true" } else { "false" })
|
||||||
|
.text("stopped", if paused { "true" } else { "false" })
|
||||||
|
.text("autoTMM", if auto_tmm { "true" } else { "false" });
|
||||||
|
|
||||||
|
if let Some(category) = category.as_ref().filter(|value| !value.is_empty()) {
|
||||||
|
form = form.text("category", category.clone());
|
||||||
|
}
|
||||||
|
if let Some(magnet) = magnet.as_ref().filter(|value| !value.is_empty()) {
|
||||||
|
form = form.text("urls", magnet.clone());
|
||||||
|
}
|
||||||
|
if let (Some(name), Some(bytes)) = (file_name.as_ref(), file_bytes.as_ref()) {
|
||||||
|
let part = Part::bytes(bytes.clone())
|
||||||
|
.file_name(name.clone())
|
||||||
|
.mime_str("application/x-bittorrent")
|
||||||
|
.unwrap_or_else(|_| Part::bytes(bytes.clone()));
|
||||||
|
form = form.part("torrents", part);
|
||||||
|
}
|
||||||
|
form
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = self
|
||||||
|
.decorate(
|
||||||
|
self.http
|
||||||
|
.post(&url)
|
||||||
|
.timeout(UPLOAD_TIMEOUT)
|
||||||
|
.multipart(build_form()),
|
||||||
|
)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.map_err(map_reqwest)?;
|
||||||
|
|
||||||
|
if matches!(response.status().as_u16(), 401 | 403) && !self.use_api_key {
|
||||||
|
self.login().await?;
|
||||||
|
let retry = self
|
||||||
|
.decorate(
|
||||||
|
self.http
|
||||||
|
.post(&url)
|
||||||
|
.timeout(UPLOAD_TIMEOUT)
|
||||||
|
.multipart(build_form()),
|
||||||
|
)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.map_err(map_reqwest)?;
|
||||||
|
return parse_add_response(retry).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_add_response(response).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn stop(&self, hashes: &[String]) -> Result<(), QbError> {
|
||||||
|
self.control(hashes, true).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn start(&self, hashes: &[String]) -> Result<(), QbError> {
|
||||||
|
self.control(hashes, false).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn control(&self, hashes: &[String], stop: bool) -> Result<(), QbError> {
|
||||||
|
let action = if stop { "stop" } else { "start" };
|
||||||
|
let fallback = if stop { "pause" } else { "resume" };
|
||||||
|
let form = vec![("hashes".to_string(), join_hashes(hashes))];
|
||||||
|
|
||||||
|
let result = self
|
||||||
|
.post_form(&format!("/api/v2/torrents/{action}"), form.clone())
|
||||||
|
.await;
|
||||||
|
|
||||||
|
match result {
|
||||||
|
Ok(()) => Ok(()),
|
||||||
|
// qBittorrent 5.0 renamed pause/resume to stop/start (WebAPI
|
||||||
|
// 2.11). If the server is older than reported, fall back once.
|
||||||
|
Err(err) if err.status == Some(404) => {
|
||||||
|
self.post_form(&format!("/api/v2/torrents/{fallback}"), form)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete(&self, hashes: &[String], delete_files: bool) -> Result<(), QbError> {
|
||||||
|
let form = vec![
|
||||||
|
("hashes".to_string(), join_hashes(hashes)),
|
||||||
|
(
|
||||||
|
"deleteFiles".to_string(),
|
||||||
|
if delete_files { "true" } else { "false" }.to_string(),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
self.post_form("/api/v2/torrents/delete", form).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn set_category(&self, hashes: &[String], category: &str) -> Result<(), QbError> {
|
||||||
|
let form = vec![
|
||||||
|
("hashes".to_string(), join_hashes(hashes)),
|
||||||
|
("category".to_string(), category.to_string()),
|
||||||
|
];
|
||||||
|
self.post_form("/api/v2/torrents/setCategory", form).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn sync(&self, rid: i64) -> Result<Value, QbError> {
|
||||||
|
self.get_json(&format!("/api/v2/sync/maindata?rid={rid}"))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Read a local `.torrent` file for upload.
|
||||||
|
pub fn read_torrent_file(path: &str) -> Result<(String, Vec<u8>), QbError> {
|
||||||
|
let path = Path::new(path);
|
||||||
|
let name = path
|
||||||
|
.file_name()
|
||||||
|
.and_then(|name| name.to_str())
|
||||||
|
.unwrap_or("torrent.torrent")
|
||||||
|
.to_string();
|
||||||
|
let metadata = std::fs::metadata(path)
|
||||||
|
.map_err(|err| QbError::new("torrent", format!("Не удалось открыть файл: {err}")))?;
|
||||||
|
if metadata.len() > 10 * 1024 * 1024 {
|
||||||
|
return Err(QbError::new(
|
||||||
|
"torrent",
|
||||||
|
"Файл торрента больше 10 МБ — это не похоже на обычный .torrent",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let bytes = std::fs::read(path)
|
||||||
|
.map_err(|err| QbError::new("torrent", format!("Не удалось прочитать файл: {err}")))?;
|
||||||
|
Ok((name, bytes))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn parse_add_response(response: Response) -> Result<QbAddResult, QbError> {
|
||||||
|
let status = response.status();
|
||||||
|
let text = response.text().await.unwrap_or_default();
|
||||||
|
let trimmed = text.trim();
|
||||||
|
|
||||||
|
if status == StatusCode::UNSUPPORTED_MEDIA_TYPE {
|
||||||
|
return Ok(QbAddResult::new(
|
||||||
|
"invalid",
|
||||||
|
Vec::new(),
|
||||||
|
Some("qBittorrent не принял файл: это не корректный .torrent".to_string()),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if status == StatusCode::CONFLICT {
|
||||||
|
return Ok(QbAddResult::new(
|
||||||
|
"duplicate",
|
||||||
|
Vec::new(),
|
||||||
|
Some("qBittorrent не добавил раздачу: она уже есть или отклонена".to_string()),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if !status.is_success() {
|
||||||
|
return Err(http_error(status));
|
||||||
|
}
|
||||||
|
|
||||||
|
if trimmed.starts_with('{') {
|
||||||
|
if let Ok(parsed) = serde_json::from_str::<QbAddResponse>(trimmed) {
|
||||||
|
let hashes = parsed.added_torrent_ids.clone();
|
||||||
|
if parsed.success_count > 0 {
|
||||||
|
return Ok(QbAddResult::new("added", hashes, None));
|
||||||
|
}
|
||||||
|
if parsed.pending_count > 0 {
|
||||||
|
return Ok(QbAddResult::new(
|
||||||
|
"pending",
|
||||||
|
hashes,
|
||||||
|
Some("qBittorrent обрабатывает раздачу".to_string()),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let message = if parsed.failure_count > 0 {
|
||||||
|
format!(
|
||||||
|
"qBittorrent не добавил раздачу (ошибок: {})",
|
||||||
|
parsed.failure_count
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
"qBittorrent не добавил раздачу: она уже есть или отклонена".to_string()
|
||||||
|
};
|
||||||
|
return Ok(QbAddResult::new("duplicate", hashes, Some(message)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if trimmed.eq_ignore_ascii_case("Fails.") {
|
||||||
|
return Ok(QbAddResult::new(
|
||||||
|
"duplicate",
|
||||||
|
Vec::new(),
|
||||||
|
Some("qBittorrent не добавил раздачу: она уже есть или отклонена".to_string()),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(QbAddResult::new("added", Vec::new(), None))
|
||||||
|
}
|
||||||
@@ -0,0 +1,546 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::sync::{Mutex, MutexGuard};
|
||||||
|
|
||||||
|
use serde_json::{Map, Value};
|
||||||
|
use tauri::{AppHandle, Manager, State};
|
||||||
|
|
||||||
|
pub mod client;
|
||||||
|
pub mod types;
|
||||||
|
|
||||||
|
use client::{normalize_base_url, AddTorrentInput, QbClient};
|
||||||
|
use types::{
|
||||||
|
QbAddRequest, QbAddResult, QbCategory, QbConnectionInfo, QbError, QbServerState,
|
||||||
|
QbServerStateRaw, QbSettings, QbSnapshot, QbTorrent, QbTorrentRaw,
|
||||||
|
};
|
||||||
|
|
||||||
|
const KEYRING_SERVICE: &str = "blink-qbittorrent";
|
||||||
|
const KEYRING_USER: &str = "default";
|
||||||
|
const SETTINGS_FILE: &str = "qbittorrent.json";
|
||||||
|
|
||||||
|
struct Inner {
|
||||||
|
settings: QbSettings,
|
||||||
|
/// Password or API key, kept in memory for this run even when the user
|
||||||
|
/// chose not to write it to the OS keyring.
|
||||||
|
secret: Option<String>,
|
||||||
|
secret_saved: bool,
|
||||||
|
/// Whether the OS keyring has already been queried in this run.
|
||||||
|
secret_checked: bool,
|
||||||
|
client: Option<QbClient>,
|
||||||
|
torrents: HashMap<String, Value>,
|
||||||
|
server_state: Value,
|
||||||
|
rid: i64,
|
||||||
|
synced: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Inner {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
settings: QbSettings::default(),
|
||||||
|
secret: None,
|
||||||
|
secret_saved: false,
|
||||||
|
secret_checked: false,
|
||||||
|
client: None,
|
||||||
|
torrents: HashMap::new(),
|
||||||
|
server_state: Value::Null,
|
||||||
|
rid: 0,
|
||||||
|
synced: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct QbState {
|
||||||
|
inner: Mutex<Inner>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl QbState {
|
||||||
|
pub fn load(app: &AppHandle) -> Self {
|
||||||
|
// The OS keyring is intentionally not touched here: setup runs on the
|
||||||
|
// main thread, and a slow Credential Manager/Keychain call must not
|
||||||
|
// delay (or freeze) the window. The secret is loaded lazily by
|
||||||
|
// `qb_get_settings` on the async runtime.
|
||||||
|
Self {
|
||||||
|
inner: Mutex::new(Inner {
|
||||||
|
settings: read_settings(app),
|
||||||
|
..Inner::default()
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lock(&self) -> Result<MutexGuard<'_, Inner>, QbError> {
|
||||||
|
self.inner
|
||||||
|
.lock()
|
||||||
|
.map_err(|_| QbError::new("internal", "Внутреннее состояние qBittorrent повреждено"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn keyring_entry() -> Result<keyring::Entry, QbError> {
|
||||||
|
keyring::Entry::new(KEYRING_SERVICE, KEYRING_USER).map_err(|err| {
|
||||||
|
QbError::new(
|
||||||
|
"config",
|
||||||
|
format!("Системное хранилище секретов недоступно: {err}"),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn keyring_read() -> Option<String> {
|
||||||
|
keyring_entry()
|
||||||
|
.ok()
|
||||||
|
.and_then(|entry| entry.get_password().ok())
|
||||||
|
.filter(|secret| !secret.is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn keyring_write(secret: &str) -> bool {
|
||||||
|
keyring_entry()
|
||||||
|
.and_then(|entry| {
|
||||||
|
entry.set_password(secret).map_err(|err| {
|
||||||
|
QbError::new("config", format!("Не удалось сохранить секрет: {err}"))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn keyring_delete() {
|
||||||
|
if let Ok(entry) = keyring_entry() {
|
||||||
|
let _ = entry.delete_credential();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn settings_path(app: &AppHandle) -> Result<PathBuf, QbError> {
|
||||||
|
let directory = app.path().app_config_dir().map_err(|err| {
|
||||||
|
QbError::new(
|
||||||
|
"config",
|
||||||
|
format!("Не удалось определить каталог настроек: {err}"),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
std::fs::create_dir_all(&directory).map_err(|err| {
|
||||||
|
QbError::new(
|
||||||
|
"config",
|
||||||
|
format!("Не удалось создать каталог настроек: {err}"),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
Ok(directory.join(SETTINGS_FILE))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_settings(app: &AppHandle) -> QbSettings {
|
||||||
|
let Ok(path) = settings_path(app) else {
|
||||||
|
return QbSettings::default();
|
||||||
|
};
|
||||||
|
let Ok(text) = std::fs::read_to_string(path) else {
|
||||||
|
return QbSettings::default();
|
||||||
|
};
|
||||||
|
serde_json::from_str(&text).unwrap_or_default()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_settings(app: &AppHandle, settings: &QbSettings) -> Result<(), QbError> {
|
||||||
|
let path = settings_path(app)?;
|
||||||
|
let mut persisted = settings.clone();
|
||||||
|
persisted.secret_saved = false;
|
||||||
|
persisted.has_secret = false;
|
||||||
|
let json = serde_json::to_string_pretty(&persisted)
|
||||||
|
.map_err(|err| QbError::new("config", format!("Не удалось сохранить настройки: {err}")))?;
|
||||||
|
std::fs::write(path, json)
|
||||||
|
.map_err(|err| QbError::new("config", format!("Не удалось сохранить настройки: {err}")))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn public_settings(inner: &Inner) -> QbSettings {
|
||||||
|
let mut settings = inner.settings.clone();
|
||||||
|
settings.secret_saved = inner.secret_saved;
|
||||||
|
settings.has_secret = inner.secret.is_some();
|
||||||
|
settings
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reset_session(inner: &mut Inner) {
|
||||||
|
inner.client = None;
|
||||||
|
inner.torrents.clear();
|
||||||
|
inner.server_state = Value::Null;
|
||||||
|
inner.rid = 0;
|
||||||
|
inner.synced = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn merge_json(base: &mut Value, patch: &Value) {
|
||||||
|
if let (Some(base), Some(patch)) = (base.as_object_mut(), patch.as_object()) {
|
||||||
|
for (key, value) in patch {
|
||||||
|
base.insert(key.clone(), value.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply_sync(inner: &mut Inner, data: &Value) {
|
||||||
|
let full_update = data
|
||||||
|
.get("full_update")
|
||||||
|
.and_then(Value::as_bool)
|
||||||
|
.unwrap_or(false);
|
||||||
|
if full_update {
|
||||||
|
inner.torrents.clear();
|
||||||
|
inner.server_state = Value::Null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(torrents) = data.get("torrents").and_then(Value::as_object) {
|
||||||
|
for (hash, patch) in torrents {
|
||||||
|
if !patch.is_object() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let entry = inner
|
||||||
|
.torrents
|
||||||
|
.entry(hash.clone())
|
||||||
|
.or_insert_with(|| Value::Object(Map::new()));
|
||||||
|
merge_json(entry, patch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(removed) = data.get("torrents_removed").and_then(Value::as_array) {
|
||||||
|
for hash in removed {
|
||||||
|
if let Some(hash) = hash.as_str() {
|
||||||
|
inner.torrents.remove(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(server_state) = data.get("server_state") {
|
||||||
|
if server_state.is_object() {
|
||||||
|
if inner.server_state.is_null() {
|
||||||
|
inner.server_state = Value::Object(Map::new());
|
||||||
|
}
|
||||||
|
merge_json(&mut inner.server_state, server_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(rid) = data.get("rid").and_then(Value::as_i64) {
|
||||||
|
inner.rid = rid;
|
||||||
|
}
|
||||||
|
inner.synced = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn snapshot(inner: &Inner) -> QbSnapshot {
|
||||||
|
let mut torrents: Vec<QbTorrent> = inner
|
||||||
|
.torrents
|
||||||
|
.iter()
|
||||||
|
.filter(|(_, value)| value.is_object())
|
||||||
|
.map(|(hash, value)| QbTorrent::from(QbTorrentRaw::from_value(value, hash)))
|
||||||
|
.collect();
|
||||||
|
// Newest first; the UI groups by state on top of that.
|
||||||
|
torrents.sort_by(|left, right| right.added_on.cmp(&left.added_on));
|
||||||
|
|
||||||
|
let server_state = QbServerState::from(QbServerStateRaw::from_value(&inner.server_state));
|
||||||
|
QbSnapshot {
|
||||||
|
torrents,
|
||||||
|
server_state,
|
||||||
|
synced: inner.synced,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn client_and_settings(state: &QbState) -> Result<(QbClient, QbSettings), QbError> {
|
||||||
|
let (settings, secret, cached) = {
|
||||||
|
let inner = state.lock()?;
|
||||||
|
(
|
||||||
|
inner.settings.clone(),
|
||||||
|
inner.secret.clone(),
|
||||||
|
inner.client.clone(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(client) = cached {
|
||||||
|
return Ok((client, settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
let secret = secret.ok_or_else(|| {
|
||||||
|
QbError::new(
|
||||||
|
"auth",
|
||||||
|
"Пароль qBittorrent не задан. Откройте «Настройки → Загрузки».",
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let client = QbClient::connect(&settings, &secret).await?;
|
||||||
|
{
|
||||||
|
let mut inner = state.lock()?;
|
||||||
|
// Another command may have connected while this one awaited.
|
||||||
|
if inner.client.is_none() {
|
||||||
|
inner.client = Some(client.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok((client, settings))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_get_settings(state: State<'_, QbState>) -> Result<QbSettings, QbError> {
|
||||||
|
let should_read = {
|
||||||
|
let inner = state.lock()?;
|
||||||
|
inner.secret.is_none() && inner.settings.remember_secret && !inner.secret_checked
|
||||||
|
};
|
||||||
|
|
||||||
|
if should_read {
|
||||||
|
{
|
||||||
|
let mut inner = state.lock()?;
|
||||||
|
inner.secret_checked = true;
|
||||||
|
}
|
||||||
|
let stored = tauri::async_runtime::spawn_blocking(keyring_read)
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
if let Some(secret) = stored {
|
||||||
|
let mut inner = state.lock()?;
|
||||||
|
if inner.secret.is_none() {
|
||||||
|
inner.secret = Some(secret);
|
||||||
|
inner.secret_saved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let inner = state.lock()?;
|
||||||
|
Ok(public_settings(&inner))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_save_settings(
|
||||||
|
app: AppHandle,
|
||||||
|
state: State<'_, QbState>,
|
||||||
|
mut settings: QbSettings,
|
||||||
|
secret: Option<String>,
|
||||||
|
) -> Result<QbSettings, QbError> {
|
||||||
|
settings.base_url = normalize_base_url(&settings.base_url)?;
|
||||||
|
settings.username = settings.username.trim().to_string();
|
||||||
|
settings.poll_interval_ms = settings.poll_interval_ms.clamp(1000, 60_000);
|
||||||
|
settings.default_category = settings.default_category.trim().to_string();
|
||||||
|
|
||||||
|
let new_secret = secret.and_then(|value| {
|
||||||
|
let value = value.trim().to_string();
|
||||||
|
if value.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(value)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let secret_changed = new_secret.is_some();
|
||||||
|
let remember_secret = settings.remember_secret;
|
||||||
|
|
||||||
|
// Never call the OS keyring (or write files) while holding the state
|
||||||
|
// mutex: Credential Manager can block for seconds or show a system prompt,
|
||||||
|
// and every other qB command would queue behind it.
|
||||||
|
let secret_for_keyring = {
|
||||||
|
let mut inner = state.lock()?;
|
||||||
|
inner.secret_checked = true;
|
||||||
|
if let Some(secret) = new_secret {
|
||||||
|
inner.secret = Some(secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
let connection_changed = inner.settings.base_url != settings.base_url
|
||||||
|
|| inner.settings.username != settings.username
|
||||||
|
|| inner.settings.use_api_key != settings.use_api_key
|
||||||
|
|| inner.settings.allow_invalid_certs != settings.allow_invalid_certs;
|
||||||
|
|
||||||
|
inner.settings = settings.clone();
|
||||||
|
if connection_changed || secret_changed {
|
||||||
|
reset_session(&mut inner);
|
||||||
|
}
|
||||||
|
inner.secret.clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
let keyring_result = tauri::async_runtime::spawn_blocking(move || {
|
||||||
|
if remember_secret {
|
||||||
|
secret_for_keyring
|
||||||
|
.as_deref()
|
||||||
|
.map(keyring_write)
|
||||||
|
.unwrap_or(false)
|
||||||
|
} else {
|
||||||
|
keyring_delete();
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|err| {
|
||||||
|
QbError::new(
|
||||||
|
"internal",
|
||||||
|
format!("Не удалось выполнить операцию с секретом: {err}"),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut inner = state.lock()?;
|
||||||
|
inner.secret_saved = keyring_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
write_settings(&app, &settings)?;
|
||||||
|
let inner = state.lock()?;
|
||||||
|
Ok(public_settings(&inner))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_forget_secret(
|
||||||
|
app: AppHandle,
|
||||||
|
state: State<'_, QbState>,
|
||||||
|
) -> Result<QbSettings, QbError> {
|
||||||
|
let settings = {
|
||||||
|
let mut inner = state.lock()?;
|
||||||
|
inner.secret = None;
|
||||||
|
inner.secret_saved = false;
|
||||||
|
inner.secret_checked = true;
|
||||||
|
reset_session(&mut inner);
|
||||||
|
inner.settings.clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
tauri::async_runtime::spawn_blocking(keyring_delete)
|
||||||
|
.await
|
||||||
|
.map_err(|err| {
|
||||||
|
QbError::new(
|
||||||
|
"internal",
|
||||||
|
format!("Не удалось удалить сохранённый секрет: {err}"),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
write_settings(&app, &settings)?;
|
||||||
|
let inner = state.lock()?;
|
||||||
|
Ok(public_settings(&inner))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_test_connection(
|
||||||
|
state: State<'_, QbState>,
|
||||||
|
mut settings: QbSettings,
|
||||||
|
secret: Option<String>,
|
||||||
|
) -> Result<QbConnectionInfo, QbError> {
|
||||||
|
settings.base_url = normalize_base_url(&settings.base_url)?;
|
||||||
|
|
||||||
|
let provided = secret.and_then(|value| {
|
||||||
|
let value = value.trim().to_string();
|
||||||
|
if value.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(value)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let secret = match provided {
|
||||||
|
Some(secret) => secret,
|
||||||
|
None => state.lock()?.secret.clone().ok_or_else(|| {
|
||||||
|
QbError::new(
|
||||||
|
"auth",
|
||||||
|
"Введите пароль qBittorrent (или API-ключ), чтобы проверить соединение",
|
||||||
|
)
|
||||||
|
})?,
|
||||||
|
};
|
||||||
|
|
||||||
|
let client = QbClient::connect(&settings, &secret).await?;
|
||||||
|
client.connection_info().await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_categories(state: State<'_, QbState>) -> Result<Vec<QbCategory>, QbError> {
|
||||||
|
let (client, _settings) = client_and_settings(&state).await?;
|
||||||
|
client.categories().await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_add_torrent(
|
||||||
|
state: State<'_, QbState>,
|
||||||
|
request: QbAddRequest,
|
||||||
|
) -> Result<QbAddResult, QbError> {
|
||||||
|
let magnet = request
|
||||||
|
.magnet
|
||||||
|
.map(|value| value.trim().to_string())
|
||||||
|
.filter(|value| !value.is_empty());
|
||||||
|
let file_path = request
|
||||||
|
.file_path
|
||||||
|
.map(|value| value.trim().to_string())
|
||||||
|
.filter(|value| !value.is_empty());
|
||||||
|
|
||||||
|
if magnet.is_some() && file_path.is_some() {
|
||||||
|
return Err(QbError::config(
|
||||||
|
"Выберите что-то одно: magnet-ссылку или .torrent файл",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if magnet.is_none() && file_path.is_none() {
|
||||||
|
return Err(QbError::config(
|
||||||
|
"Вставьте magnet-ссылку или выберите .torrent",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if let Some(magnet) = magnet.as_deref() {
|
||||||
|
if !magnet.starts_with("magnet:?") {
|
||||||
|
return Err(QbError::config("Ссылка не похожа на magnet-ссылку"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let (file_name, file_bytes) = match file_path.as_deref() {
|
||||||
|
Some(path) => {
|
||||||
|
let (name, bytes) = QbClient::read_torrent_file(path)?;
|
||||||
|
(Some(name), Some(bytes))
|
||||||
|
}
|
||||||
|
None => (None, None),
|
||||||
|
};
|
||||||
|
|
||||||
|
let (client, settings) = client_and_settings(&state).await?;
|
||||||
|
let category = request
|
||||||
|
.category
|
||||||
|
.map(|value| value.trim().to_string())
|
||||||
|
.filter(|value| !value.is_empty())
|
||||||
|
.or_else(|| {
|
||||||
|
let default = settings.default_category.trim().to_string();
|
||||||
|
if default.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(default)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let result = client
|
||||||
|
.add_torrent(AddTorrentInput {
|
||||||
|
magnet,
|
||||||
|
file_name,
|
||||||
|
file_bytes,
|
||||||
|
category,
|
||||||
|
paused: request.paused.unwrap_or(settings.add_paused),
|
||||||
|
auto_tmm: request.auto_tmm.unwrap_or(settings.auto_tmm),
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
// The torrent list is now stale; the next poll would receive an empty diff
|
||||||
|
// if we kept the old rid. Force a full update.
|
||||||
|
if result.status == "added" || result.status == "pending" {
|
||||||
|
let mut inner = state.lock()?;
|
||||||
|
inner.rid = 0;
|
||||||
|
inner.synced = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_poll(state: State<'_, QbState>) -> Result<QbSnapshot, QbError> {
|
||||||
|
let (client, _settings) = client_and_settings(&state).await?;
|
||||||
|
let rid = state.lock()?.rid;
|
||||||
|
let data = client.sync(rid).await?;
|
||||||
|
|
||||||
|
let mut inner = state.lock()?;
|
||||||
|
apply_sync(&mut inner, &data);
|
||||||
|
Ok(snapshot(&inner))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_pause(state: State<'_, QbState>, hashes: Vec<String>) -> Result<(), QbError> {
|
||||||
|
let (client, _settings) = client_and_settings(&state).await?;
|
||||||
|
client.stop(&hashes).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_resume(state: State<'_, QbState>, hashes: Vec<String>) -> Result<(), QbError> {
|
||||||
|
let (client, _settings) = client_and_settings(&state).await?;
|
||||||
|
client.start(&hashes).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_delete(
|
||||||
|
state: State<'_, QbState>,
|
||||||
|
hashes: Vec<String>,
|
||||||
|
delete_files: bool,
|
||||||
|
) -> Result<(), QbError> {
|
||||||
|
let (client, _settings) = client_and_settings(&state).await?;
|
||||||
|
client.delete(&hashes, delete_files).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn qb_set_category(
|
||||||
|
state: State<'_, QbState>,
|
||||||
|
hashes: Vec<String>,
|
||||||
|
category: String,
|
||||||
|
) -> Result<(), QbError> {
|
||||||
|
let (client, _settings) = client_and_settings(&state).await?;
|
||||||
|
client.set_category(&hashes, category.trim()).await
|
||||||
|
}
|
||||||
@@ -0,0 +1,369 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// qBittorrent connection settings.
|
||||||
|
///
|
||||||
|
/// Stored as `qbittorrent.json` in the app config directory. The password (or
|
||||||
|
/// API key) is never part of this struct: it lives in the OS secret store and
|
||||||
|
/// only its presence is reported back to the UI.
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase", default)]
|
||||||
|
pub struct QbSettings {
|
||||||
|
pub base_url: String,
|
||||||
|
pub username: String,
|
||||||
|
/// `true` when the secret is a qBittorrent API key (WebAPI 2.17+) instead
|
||||||
|
/// of the WebUI password.
|
||||||
|
pub use_api_key: bool,
|
||||||
|
/// Persist the secret in the OS keyring.
|
||||||
|
pub remember_secret: bool,
|
||||||
|
pub default_category: String,
|
||||||
|
/// Pass `autoTMM=true` when adding a torrent, so the category save path is
|
||||||
|
/// honoured.
|
||||||
|
pub auto_tmm: bool,
|
||||||
|
pub add_paused: bool,
|
||||||
|
pub allow_invalid_certs: bool,
|
||||||
|
pub refresh_jellyfin: bool,
|
||||||
|
pub notify_on_complete: bool,
|
||||||
|
pub poll_interval_ms: u64,
|
||||||
|
/// Read-only flags for the UI; recomputed on every load/save.
|
||||||
|
#[serde(default)]
|
||||||
|
pub secret_saved: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub has_secret: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for QbSettings {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
base_url: "http://127.0.0.1:8080".to_string(),
|
||||||
|
username: "admin".to_string(),
|
||||||
|
use_api_key: false,
|
||||||
|
remember_secret: false,
|
||||||
|
default_category: String::new(),
|
||||||
|
auto_tmm: true,
|
||||||
|
add_paused: false,
|
||||||
|
allow_invalid_certs: false,
|
||||||
|
refresh_jellyfin: false,
|
||||||
|
notify_on_complete: true,
|
||||||
|
poll_interval_ms: 2000,
|
||||||
|
secret_saved: false,
|
||||||
|
has_secret: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "camelCase", default)]
|
||||||
|
pub struct QbCategory {
|
||||||
|
pub name: String,
|
||||||
|
pub save_path: String,
|
||||||
|
pub download_path: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default)]
|
||||||
|
pub struct QbTorrentRaw {
|
||||||
|
pub hash: String,
|
||||||
|
pub name: String,
|
||||||
|
pub category: String,
|
||||||
|
pub size: i64,
|
||||||
|
pub completed: i64,
|
||||||
|
pub downloaded: i64,
|
||||||
|
pub progress: f64,
|
||||||
|
pub dlspeed: i64,
|
||||||
|
pub upspeed: i64,
|
||||||
|
pub eta: i64,
|
||||||
|
pub state: String,
|
||||||
|
pub save_path: String,
|
||||||
|
pub content_path: String,
|
||||||
|
pub added_on: i64,
|
||||||
|
pub completion_on: i64,
|
||||||
|
pub ratio: f64,
|
||||||
|
pub num_seeds: i64,
|
||||||
|
pub num_leechs: i64,
|
||||||
|
pub error: Option<String>,
|
||||||
|
pub tags: String,
|
||||||
|
pub seeding_time: i64,
|
||||||
|
pub time_active: i64,
|
||||||
|
pub amount_left: i64,
|
||||||
|
pub tracker: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl QbTorrentRaw {
|
||||||
|
/// `hash` is the key of the `sync/maindata` torrents map; qBittorrent does
|
||||||
|
/// not repeat it inside the value.
|
||||||
|
pub fn from_value(value: &serde_json::Value, hash: &str) -> Self {
|
||||||
|
let text = |key: &str| -> String {
|
||||||
|
value
|
||||||
|
.get(key)
|
||||||
|
.and_then(serde_json::Value::as_str)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_string()
|
||||||
|
};
|
||||||
|
let number = |key: &str| -> i64 {
|
||||||
|
value
|
||||||
|
.get(key)
|
||||||
|
.and_then(serde_json::Value::as_i64)
|
||||||
|
.unwrap_or_default()
|
||||||
|
};
|
||||||
|
let float = |key: &str| -> f64 {
|
||||||
|
value
|
||||||
|
.get(key)
|
||||||
|
.and_then(serde_json::Value::as_f64)
|
||||||
|
.unwrap_or_default()
|
||||||
|
};
|
||||||
|
|
||||||
|
Self {
|
||||||
|
hash: hash.to_string(),
|
||||||
|
name: text("name"),
|
||||||
|
category: text("category"),
|
||||||
|
size: number("size"),
|
||||||
|
completed: number("completed"),
|
||||||
|
downloaded: number("downloaded"),
|
||||||
|
progress: float("progress"),
|
||||||
|
dlspeed: number("dlspeed"),
|
||||||
|
upspeed: number("upspeed"),
|
||||||
|
eta: number("eta"),
|
||||||
|
state: text("state"),
|
||||||
|
save_path: text("save_path"),
|
||||||
|
content_path: text("content_path"),
|
||||||
|
added_on: number("added_on"),
|
||||||
|
completion_on: number("completion_on"),
|
||||||
|
ratio: float("ratio"),
|
||||||
|
num_seeds: number("num_seeds"),
|
||||||
|
num_leechs: number("num_leechs"),
|
||||||
|
error: value
|
||||||
|
.get("error")
|
||||||
|
.and_then(serde_json::Value::as_str)
|
||||||
|
.filter(|message| !message.is_empty())
|
||||||
|
.map(str::to_string),
|
||||||
|
tags: text("tags"),
|
||||||
|
seeding_time: number("seeding_time"),
|
||||||
|
time_active: number("time_active"),
|
||||||
|
amount_left: number("amount_left"),
|
||||||
|
tracker: text("tracker"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct QbTorrent {
|
||||||
|
pub hash: String,
|
||||||
|
pub name: String,
|
||||||
|
pub category: String,
|
||||||
|
pub size: i64,
|
||||||
|
pub completed: i64,
|
||||||
|
pub downloaded: i64,
|
||||||
|
pub progress: f64,
|
||||||
|
pub dlspeed: i64,
|
||||||
|
pub upspeed: i64,
|
||||||
|
pub eta: i64,
|
||||||
|
pub state: String,
|
||||||
|
pub save_path: String,
|
||||||
|
pub content_path: String,
|
||||||
|
pub added_on: i64,
|
||||||
|
pub completion_on: i64,
|
||||||
|
pub ratio: f64,
|
||||||
|
pub num_seeds: i64,
|
||||||
|
pub num_leechs: i64,
|
||||||
|
pub error: Option<String>,
|
||||||
|
pub tags: String,
|
||||||
|
pub seeding_time: i64,
|
||||||
|
pub time_active: i64,
|
||||||
|
pub amount_left: i64,
|
||||||
|
pub tracker: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<QbTorrentRaw> for QbTorrent {
|
||||||
|
fn from(raw: QbTorrentRaw) -> Self {
|
||||||
|
Self {
|
||||||
|
hash: raw.hash,
|
||||||
|
name: raw.name,
|
||||||
|
category: raw.category,
|
||||||
|
size: raw.size,
|
||||||
|
completed: raw.completed,
|
||||||
|
downloaded: raw.downloaded,
|
||||||
|
progress: raw.progress,
|
||||||
|
dlspeed: raw.dlspeed,
|
||||||
|
upspeed: raw.upspeed,
|
||||||
|
eta: raw.eta,
|
||||||
|
state: raw.state,
|
||||||
|
save_path: raw.save_path,
|
||||||
|
content_path: raw.content_path,
|
||||||
|
added_on: raw.added_on,
|
||||||
|
completion_on: raw.completion_on,
|
||||||
|
ratio: raw.ratio,
|
||||||
|
num_seeds: raw.num_seeds,
|
||||||
|
num_leechs: raw.num_leechs,
|
||||||
|
error: raw.error,
|
||||||
|
tags: raw.tags,
|
||||||
|
seeding_time: raw.seeding_time,
|
||||||
|
time_active: raw.time_active,
|
||||||
|
amount_left: raw.amount_left,
|
||||||
|
tracker: raw.tracker,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default)]
|
||||||
|
pub struct QbServerStateRaw {
|
||||||
|
pub dl_info_speed: i64,
|
||||||
|
pub up_info_speed: i64,
|
||||||
|
pub dl_info_data: i64,
|
||||||
|
pub up_info_data: i64,
|
||||||
|
pub free_space_on_disk: i64,
|
||||||
|
pub connection_status: String,
|
||||||
|
pub queueing: bool,
|
||||||
|
pub dht_nodes: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl QbServerStateRaw {
|
||||||
|
pub fn from_value(value: &serde_json::Value) -> Self {
|
||||||
|
let number = |key: &str| -> i64 {
|
||||||
|
value
|
||||||
|
.get(key)
|
||||||
|
.and_then(serde_json::Value::as_i64)
|
||||||
|
.unwrap_or_default()
|
||||||
|
};
|
||||||
|
let text = |key: &str| -> String {
|
||||||
|
value
|
||||||
|
.get(key)
|
||||||
|
.and_then(serde_json::Value::as_str)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
Self {
|
||||||
|
dl_info_speed: number("dl_info_speed"),
|
||||||
|
up_info_speed: number("up_info_speed"),
|
||||||
|
dl_info_data: number("dl_info_data"),
|
||||||
|
up_info_data: number("up_info_data"),
|
||||||
|
free_space_on_disk: number("free_space_on_disk"),
|
||||||
|
connection_status: text("connection_status"),
|
||||||
|
queueing: value
|
||||||
|
.get("queueing")
|
||||||
|
.and_then(serde_json::Value::as_bool)
|
||||||
|
.unwrap_or_default(),
|
||||||
|
dht_nodes: number("dht_nodes"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct QbServerState {
|
||||||
|
pub dl_info_speed: i64,
|
||||||
|
pub up_info_speed: i64,
|
||||||
|
pub dl_info_data: i64,
|
||||||
|
pub up_info_data: i64,
|
||||||
|
pub free_space_on_disk: i64,
|
||||||
|
pub connection_status: String,
|
||||||
|
pub queueing: bool,
|
||||||
|
pub dht_nodes: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<QbServerStateRaw> for QbServerState {
|
||||||
|
fn from(raw: QbServerStateRaw) -> Self {
|
||||||
|
Self {
|
||||||
|
dl_info_speed: raw.dl_info_speed,
|
||||||
|
up_info_speed: raw.up_info_speed,
|
||||||
|
dl_info_data: raw.dl_info_data,
|
||||||
|
up_info_data: raw.up_info_data,
|
||||||
|
free_space_on_disk: raw.free_space_on_disk,
|
||||||
|
connection_status: raw.connection_status,
|
||||||
|
queueing: raw.queueing,
|
||||||
|
dht_nodes: raw.dht_nodes,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct QbSnapshot {
|
||||||
|
pub torrents: Vec<QbTorrent>,
|
||||||
|
pub server_state: QbServerState,
|
||||||
|
pub synced: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct QbAddResult {
|
||||||
|
/// `added`, `pending`, `duplicate` or `invalid`.
|
||||||
|
pub status: String,
|
||||||
|
pub added_hashes: Vec<String>,
|
||||||
|
pub message: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl QbAddResult {
|
||||||
|
pub fn new(status: &str, added_hashes: Vec<String>, message: Option<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
status: status.to_string(),
|
||||||
|
added_hashes,
|
||||||
|
message,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct QbConnectionInfo {
|
||||||
|
pub app_version: String,
|
||||||
|
pub api_version: String,
|
||||||
|
pub default_save_path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Error returned by every qBittorrent command.
|
||||||
|
///
|
||||||
|
/// `kind` is a stable machine-readable value:
|
||||||
|
/// `unreachable`, `auth`, `banned`, `tls`, `duplicate`, `torrent`, `http`,
|
||||||
|
/// `config` or `internal`.
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct QbError {
|
||||||
|
pub kind: String,
|
||||||
|
pub message: String,
|
||||||
|
pub status: Option<u16>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl QbError {
|
||||||
|
pub fn new(kind: &str, message: impl Into<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
kind: kind.to_string(),
|
||||||
|
message: message.into(),
|
||||||
|
status: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_status(kind: &str, message: impl Into<String>, status: u16) -> Self {
|
||||||
|
Self {
|
||||||
|
kind: kind.to_string(),
|
||||||
|
message: message.into(),
|
||||||
|
status: Some(status),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn config(message: impl Into<String>) -> Self {
|
||||||
|
Self::new("config", message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct QbAddRequest {
|
||||||
|
pub magnet: Option<String>,
|
||||||
|
pub file_path: Option<String>,
|
||||||
|
pub category: Option<String>,
|
||||||
|
pub paused: Option<bool>,
|
||||||
|
pub auto_tmm: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Default)]
|
||||||
|
pub struct QbAddResponse {
|
||||||
|
#[serde(default)]
|
||||||
|
pub success_count: i64,
|
||||||
|
#[serde(default)]
|
||||||
|
pub pending_count: i64,
|
||||||
|
#[serde(default)]
|
||||||
|
pub failure_count: i64,
|
||||||
|
#[serde(default)]
|
||||||
|
pub added_torrent_ids: Vec<String>,
|
||||||
|
}
|
||||||
@@ -54,6 +54,11 @@
|
|||||||
"version": "../package.json",
|
"version": "../package.json",
|
||||||
"identifier": "com.blink.prayag17",
|
"identifier": "com.blink.prayag17",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
|
"deep-link": {
|
||||||
|
"desktop": {
|
||||||
|
"schemes": ["blink"]
|
||||||
|
}
|
||||||
|
},
|
||||||
"updater": {
|
"updater": {
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZBOTJGNzM3REU2Q0JEMEYKUldRUHZXemVOL2VTK2k2andMWTZYbEN6SnIwV0V0L2Z3NlA4RzFabThPaXRqSFRMc004WGhCb2kK",
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZBOTJGNzM3REU2Q0JEMEYKUldRUHZXemVOL2VTK2k2andMWTZYbEN6SnIwV0V0L2Z3NlA4RzFabThPaXRqSFRMc004WGhCb2kK",
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
@@ -77,11 +82,19 @@
|
|||||||
"label": "main",
|
"label": "main",
|
||||||
"dragDropEnabled": false,
|
"dragDropEnabled": false,
|
||||||
"backgroundColor": "#08001f",
|
"backgroundColor": "#08001f",
|
||||||
"transparent": false
|
"transparent": false,
|
||||||
|
"titleBarStyle": "Overlay",
|
||||||
|
"hiddenTitle": true,
|
||||||
|
"trafficLightPosition": { "x": 18, "y": 31 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
"csp": null
|
"csp": null,
|
||||||
|
"capabilities": [
|
||||||
|
"desktop-capability",
|
||||||
|
"main-capabilities",
|
||||||
|
"migrated"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"app": {
|
||||||
|
"withGlobalTauri": true,
|
||||||
|
"security": {
|
||||||
|
"capabilities": [
|
||||||
|
"desktop-capability",
|
||||||
|
"main-capabilities",
|
||||||
|
"migrated",
|
||||||
|
"mcp-bridge-capability"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
Copyright 2026 The Medeo Project Authors (https://github.com/DNFDEVS/medeo-font)
|
||||||
|
Copyright 2024-2026 The Geist Project Authors (https://github.com/vercel/geist-font)
|
||||||
|
Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
||||||
|
Copyright (c) 2010, ParaType Ltd. (http://www.paratype.com/public),
|
||||||
|
with Reserved Font Names "PT Sans", "PT Serif" and "ParaType".
|
||||||
|
Copyright 2012 Google Inc. (Noto Serif Display)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://openfontlicense.org
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Medeo
|
||||||
|
|
||||||
|
Local copy of the Medeo variable web fonts used throughout Blink.
|
||||||
|
|
||||||
|
- Source: https://github.com/DNFDEVS/medeo-font
|
||||||
|
- Version: 1.1.0 (font version 1.100)
|
||||||
|
- Sans: `MedeoSansVariable.woff2`, `MedeoSansVariable-Italic.woff2`
|
||||||
|
- Mono: `MedeoMonoVariable.woff2`, `MedeoMonoVariable-Italic.woff2`
|
||||||
|
- License: SIL Open Font License 1.1, see `OFL.txt`
|
||||||
@@ -37,7 +37,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
||||||
setAddServerDialog(false);
|
setAddServerDialog(false);
|
||||||
enqueueSnackbar(
|
enqueueSnackbar(
|
||||||
"Client added successfully. You might need to refresh client list.",
|
"Сервер добавлен. Возможно, потребуется обновить список серверов.",
|
||||||
{
|
{
|
||||||
variant: "success",
|
variant: "success",
|
||||||
},
|
},
|
||||||
@@ -50,11 +50,11 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
onError: (err) => {
|
onError: (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
enqueueSnackbar(`${err}`, { variant: "error" });
|
enqueueSnackbar(`${err}`, { variant: "error" });
|
||||||
enqueueSnackbar("Something went wrong", { variant: "error" });
|
enqueueSnackbar("Что-то пошло не так", { variant: "error" });
|
||||||
},
|
},
|
||||||
onSettled: async (bestServer) => {
|
onSettled: async (bestServer) => {
|
||||||
if (!bestServer) {
|
if (!bestServer) {
|
||||||
enqueueSnackbar("Provided server address is not a Jellyfin server.", {
|
enqueueSnackbar("Указанный адрес не является сервером Jellyfin.", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Connect to Server
|
Подключиться к серверу
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="body2"
|
||||||
@@ -121,7 +121,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Enter your Jellyfin server address to continue
|
Введите адрес сервера Jellyfin, чтобы продолжить
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
variant="text"
|
variant="text"
|
||||||
sx={{ borderRadius: 2 }}
|
sx={{ borderRadius: 2 }}
|
||||||
>
|
>
|
||||||
Cancel
|
Отмена
|
||||||
</Button>
|
</Button>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
loading={addServer.isPending}
|
loading={addServer.isPending}
|
||||||
@@ -184,7 +184,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
sx={{ borderRadius: 2, px: 3 }}
|
sx={{ borderRadius: 2, px: 3 }}
|
||||||
disabled={!serverIp}
|
disabled={!serverIp}
|
||||||
>
|
>
|
||||||
Connect
|
Подключиться
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -1,60 +1,111 @@
|
|||||||
.item-info-track{
|
.album-track {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 3em 60% 6em 1fr;
|
grid-template-columns: 2.4em minmax(0, 1fr) 4.5em 2.6em;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
padding: 1em;
|
align-items: center;
|
||||||
align-items: center;
|
padding: 0.5em 1em;
|
||||||
cursor: pointer;
|
border-radius: 8px;
|
||||||
border-radius: $border-radius-default;
|
cursor: pointer;
|
||||||
transition: background $transition-time-fast;
|
transition: background $transition-time-fast;
|
||||||
&.header {
|
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.2);
|
&-index {
|
||||||
color: rgb(255 255 255 / 0.7);
|
position: relative;
|
||||||
border-radius: 0 !important;
|
display: grid;
|
||||||
}
|
place-items: center;
|
||||||
.index-container {
|
}
|
||||||
justify-self: center;
|
|
||||||
position: relative;
|
&-number {
|
||||||
.material-symbols-rounded {
|
font-size: 0.8rem;
|
||||||
position: absolute;
|
color: rgb(255 255 255 / 0.4);
|
||||||
top: 50%;
|
font-variant-numeric: tabular-nums;
|
||||||
left: 50%;
|
}
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
font-size: 2em !important;
|
&-play {
|
||||||
opacity: 0;
|
position: absolute;
|
||||||
transition: none !important;
|
top: 50%;
|
||||||
color: $clr-accent-default;
|
left: 50%;
|
||||||
}
|
transform: translate(-50%, -50%) scale(0.9);
|
||||||
}
|
opacity: 0;
|
||||||
&-info {
|
font-size: 1.4rem;
|
||||||
display: flex;
|
color: #fff;
|
||||||
flex-direction: column;
|
transition: opacity $transition-time-fast, transform $transition-time-fast;
|
||||||
gap: 0.1em
|
}
|
||||||
}
|
|
||||||
&:hover {
|
&-info {
|
||||||
background: rgb(255 255 255 / 0.1) !important;
|
display: flex;
|
||||||
.index-container {
|
flex-direction: column;
|
||||||
// font-size: 0em;
|
gap: 0.15em;
|
||||||
.index {
|
min-width: 0;
|
||||||
opacity: 0;
|
}
|
||||||
transition: opacity 0;
|
|
||||||
}
|
&-name {
|
||||||
.material-symbols-rounded {
|
font-size: 0.95rem;
|
||||||
opacity: 1;
|
color: rgb(255 255 255 / 0.92);
|
||||||
font-size: 2.2em !important;
|
white-space: nowrap;
|
||||||
}
|
overflow: hidden;
|
||||||
}
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
&.playing {
|
|
||||||
background: rgb(0 0 0 / 0.4) !important;
|
&-artist {
|
||||||
.item-info-track-info-name, .index {
|
display: flex;
|
||||||
color: $clr-accent-default;
|
align-items: center;
|
||||||
font-weight: 600;
|
gap: 0.5em;
|
||||||
}
|
font-size: 0.78rem;
|
||||||
}
|
color: rgb(255 255 255 / 0.45);
|
||||||
&-container {
|
|
||||||
display: flex;
|
img {
|
||||||
flex-direction: column;
|
width: 1em;
|
||||||
gap: 0.4em
|
height: 1em;
|
||||||
}
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-duration {
|
||||||
|
text-align: right;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: rgb(255 255 255 / 0.45);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-like {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $transition-time-fast;
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.06);
|
||||||
|
|
||||||
|
.album-track-number {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-track-play {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translate(-50%, -50%) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-track-like {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-playing {
|
||||||
|
background: rgb(245 25 107 / 0.1);
|
||||||
|
|
||||||
|
.album-track-name,
|
||||||
|
.album-track-number,
|
||||||
|
.album-track-duration {
|
||||||
|
color: $clr-accent-default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.album-track-like {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +1,19 @@
|
|||||||
|
import type {
|
||||||
|
BaseItemDto,
|
||||||
|
BaseItemDtoQueryResult,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import React from "react";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
||||||
|
import { getRuntimeMusic } from "@/utils/date/time";
|
||||||
import {
|
import {
|
||||||
generateAudioStreamUrl,
|
generateAudioStreamUrl,
|
||||||
playAudio,
|
playAudio,
|
||||||
useAudioPlayback,
|
useAudioPlayback,
|
||||||
} from "@/utils/store/audioPlayback";
|
} from "@/utils/store/audioPlayback";
|
||||||
import type {
|
|
||||||
BaseItemDto,
|
|
||||||
BaseItemDtoQueryResult,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { Typography } from "@mui/material";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import { getRuntimeMusic } from "@/utils/date/time";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { setQueue } from "@/utils/store/queue";
|
import { setQueue } from "@/utils/store/queue";
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
|
|
||||||
import "./albumMusicTrack.scss";
|
import "./albumMusicTrack.scss";
|
||||||
@@ -45,7 +43,7 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
) => {
|
) => {
|
||||||
if (!user?.Id || !api) {
|
if (!user?.Id || !api) {
|
||||||
console.error("User not logged in");
|
console.error("User not logged in");
|
||||||
enqueueSnackbar("You need to be logged in to play music", {
|
enqueueSnackbar("Войдите, чтобы слушать музыку", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -62,46 +60,53 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
setQueue(queue, index);
|
setQueue(queue, index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isPlaying = currentPlayingItem?.Id === track.Id;
|
||||||
|
const artists = track.Artists?.filter(Boolean) ?? [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={
|
className={isPlaying ? "album-track is-playing" : "album-track"}
|
||||||
currentPlayingItem?.Id === track.Id
|
|
||||||
? "item-info-track playing"
|
|
||||||
: "item-info-track"
|
|
||||||
}
|
|
||||||
key={track.Id}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (musicTracks?.Items) {
|
if (musicTracks?.Items) {
|
||||||
handlePlayback(trackIndex, track, musicTracks.Items);
|
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === "Enter" || event.key === " ") {
|
||||||
|
event.preventDefault();
|
||||||
|
if (musicTracks?.Items) {
|
||||||
|
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={track.Name ?? "Трек"}
|
||||||
>
|
>
|
||||||
<div className="index-container">
|
<div className="album-track-index">
|
||||||
<span className="material-symbols-rounded fill ">play_arrow</span>
|
<span className="material-symbols-rounded album-track-play">
|
||||||
<Typography className="index">{track.IndexNumber ?? "-"}</Typography>
|
play_arrow
|
||||||
|
</span>
|
||||||
|
<span className="album-track-number">
|
||||||
|
{track.IndexNumber ?? "–"}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="item-info-track-info">
|
<div className="album-track-info">
|
||||||
<Typography className="item-info-track-info-name">
|
<span className="album-track-name">{track.Name}</span>
|
||||||
{track.Name}
|
{(artists.length > 0 || track.HasLyrics) && (
|
||||||
</Typography>
|
<span className="album-track-artist">
|
||||||
<Typography
|
{track.HasLyrics && (
|
||||||
variant="subtitle2"
|
<img src={lyricsIcon} alt="Есть текст песни" />
|
||||||
style={{
|
)}
|
||||||
opacity: 0.6,
|
{artists.join(", ")}
|
||||||
display: "flex",
|
</span>
|
||||||
alignItems: "center",
|
)}
|
||||||
gap: "0.6em",
|
|
||||||
}}
|
|
||||||
sx={{
|
|
||||||
fontWeight: 300,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.HasLyrics && <img src={lyricsIcon} alt="lyrics" />}
|
|
||||||
{track.Artists?.join(", ")}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
</div>
|
||||||
<Typography>{getRuntimeMusic(track.RunTimeTicks ?? 0)}</Typography>
|
<span className="album-track-duration">
|
||||||
<div className="flex flex-align-center">
|
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
||||||
|
</span>
|
||||||
|
<div className="album-track-like" onClick={(e) => e.stopPropagation()}>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={track.Id}
|
itemId={track.Id}
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
isFavorite={track.UserData?.IsFavorite}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ export const AlphaSelector = React.memo(function AlphaSelector() {
|
|||||||
const arr = Array.from({ length: 26 }, (_, i) =>
|
const arr = Array.from({ length: 26 }, (_, i) =>
|
||||||
String.fromCharCode(65 + i),
|
String.fromCharCode(65 + i),
|
||||||
);
|
);
|
||||||
return ["All", ...arr];
|
return ["Все", ...arr];
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleSelect = (letter: string) => {
|
const handleSelect = (letter: string) => {
|
||||||
const value = letter === "All" ? undefined : letter;
|
const value = letter === "Все" ? undefined : letter;
|
||||||
if (currentLibraryId)
|
if (currentLibraryId)
|
||||||
updateLibrary(currentLibraryId, { nameStartsWith: value });
|
updateLibrary(currentLibraryId, { nameStartsWith: value });
|
||||||
};
|
};
|
||||||
@@ -31,13 +31,13 @@ export const AlphaSelector = React.memo(function AlphaSelector() {
|
|||||||
return (
|
return (
|
||||||
<div className="alpha-selector">
|
<div className="alpha-selector">
|
||||||
{letters.map((l) => {
|
{letters.map((l) => {
|
||||||
const active = (nameStartsWith || "All") === l;
|
const active = (nameStartsWith || "Все") === l;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={l}
|
key={l}
|
||||||
className={active ? "alpha-letter active" : "alpha-letter"}
|
className={active ? "alpha-letter active" : "alpha-letter"}
|
||||||
onClick={() => handleSelect(l)}
|
onClick={() => handleSelect(l)}
|
||||||
aria-label={`Filter by ${l}`}
|
aria-label={`Фильтр по букве ${l}`}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
{l}
|
{l}
|
||||||
|
|||||||
@@ -1,191 +0,0 @@
|
|||||||
|
|
||||||
.appBar {
|
|
||||||
// Limit transitions to cheaper properties; avoid animating box-shadow directly
|
|
||||||
transition: background-color $transition-time-fast;
|
|
||||||
padding: 0.8em ($page-margin - 1.7em);
|
|
||||||
z-index: 999 !important;
|
|
||||||
.flex {
|
|
||||||
// Avoid animating padding; it causes layout reflow on each frame.
|
|
||||||
transition: background-color $transition-time-fast;
|
|
||||||
// Avoid using will-change: scroll-position; it can degrade performance when misused
|
|
||||||
// will-change: opacity, transform;
|
|
||||||
border-radius: 1000px;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
// Pseudo-element handles elevation shadow; we animate its opacity
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
inset: -0.35em;
|
|
||||||
pointer-events: none;
|
|
||||||
border-radius: inherit;
|
|
||||||
|
|
||||||
@include glass-effect;
|
|
||||||
|
|
||||||
opacity: 0;
|
|
||||||
z-index: -1;
|
|
||||||
transition: all $transition-time-fast;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inner content wrapper that we can scale without causing layout reflow
|
|
||||||
.flex-inner {
|
|
||||||
transform-origin: top center;
|
|
||||||
transition: transform $transition-time-fast;
|
|
||||||
}
|
|
||||||
&.elevated{
|
|
||||||
.flex {
|
|
||||||
&::after {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply a subtle scale to simulate shrink without layout changes
|
|
||||||
.flex-inner {
|
|
||||||
transform: scaleY(0.95);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-avatar {
|
|
||||||
background: rgb(255 255 255 / 0.1) !important;
|
|
||||||
&-icon {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&-text {
|
|
||||||
opacity: 0.7;
|
|
||||||
transition: opacity $transition-time-fast;
|
|
||||||
position: relative;
|
|
||||||
color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
width: 100%;
|
|
||||||
height: 1.2px;
|
|
||||||
background: white;
|
|
||||||
opacity: 0.7;
|
|
||||||
position: absolute;
|
|
||||||
bottom: 4.6px;
|
|
||||||
left: 0;
|
|
||||||
transform: scaleX(0);
|
|
||||||
transition: transform $transition-time-fast,
|
|
||||||
background $transition-time-fast,
|
|
||||||
opacity $transition-time-fast;
|
|
||||||
}
|
|
||||||
&:hover {
|
|
||||||
opacity: 0.8;
|
|
||||||
&::after {
|
|
||||||
transform: scaleX(0.25);
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&.active {
|
|
||||||
opacity: 1;
|
|
||||||
color: $clr-accent-default;
|
|
||||||
&::after {
|
|
||||||
transform: scaleX(0.5);
|
|
||||||
opacity: 1;
|
|
||||||
background: $clr-accent-default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.library-drawer {
|
|
||||||
// Ensure the drawer paper itself gets the styling
|
|
||||||
&.MuiDrawer-paper {
|
|
||||||
width: 280px;
|
|
||||||
margin: 16px;
|
|
||||||
height: calc(100% - 32px) !important; // float in the middle
|
|
||||||
border-radius: 24px;
|
|
||||||
background: rgba(20, 20, 25, 0.75); // Darker, substantial base
|
|
||||||
backdrop-filter: blur(24px) saturate(180%);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
||||||
box-shadow:
|
|
||||||
0 24px 48px rgba(0, 0, 0, 0.4),
|
|
||||||
0 4px 8px rgba(0, 0, 0, 0.2);
|
|
||||||
overflow: hidden; // Contain scrollbars
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiList-root {
|
|
||||||
padding: 8px; // Reduced from 16px
|
|
||||||
gap: 2px; // Reduced gap
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiDivider-root {
|
|
||||||
border-color: rgba(255, 255, 255, 0.1);
|
|
||||||
margin: 4px 12px; // Reduced margins
|
|
||||||
}
|
|
||||||
|
|
||||||
// Navigation Items
|
|
||||||
.MuiListItemButton-root {
|
|
||||||
border-radius: 12px !important; // Slightly smaller radius
|
|
||||||
padding: 8px 12px; // Reduced padding (was 12px 16px)
|
|
||||||
margin-bottom: 2px;
|
|
||||||
transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
||||||
color: rgba(255, 255, 255, 0.6);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.08);
|
|
||||||
color: #fff;
|
|
||||||
transform: scale(1.02);
|
|
||||||
}
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
margin-right: 12px; // Reduced spacing
|
|
||||||
font-size: 22px; // Slightly smaller icons usually look better with less padding
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiListItemText-primary {
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 0.9rem; // Slightly smaller text
|
|
||||||
letter-spacing: 0.02em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Active State
|
|
||||||
.library-drawer-item.active {
|
|
||||||
.MuiListItemButton-root {
|
|
||||||
background: linear-gradient(90deg, rgba($clr-accent-default, 0.2), rgba($clr-accent-default, 0.05));
|
|
||||||
color: $clr-accent-default;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-variation-settings: 'FILL' 1;
|
|
||||||
color: $clr-accent-default;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Active Indicator Bar
|
|
||||||
&::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
height: 24px;
|
|
||||||
width: 4px;
|
|
||||||
background: $clr-accent-default;
|
|
||||||
border-radius: 0 4px 4px 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom Scrollbar for the drawer content
|
|
||||||
&::-webkit-scrollbar {
|
|
||||||
width: 4px;
|
|
||||||
}
|
|
||||||
&::-webkit-scrollbar-track {
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
&::-webkit-scrollbar-thumb {
|
|
||||||
background: rgba(255, 255, 255, 0.1);
|
|
||||||
border-radius: 4px;
|
|
||||||
&:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.appLoading {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
import MuiAppBar from "@mui/material/AppBar";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
|
||||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
|
||||||
import React, { useCallback, useMemo, useState } from "react";
|
|
||||||
|
|
||||||
import "./appBar.scss";
|
|
||||||
|
|
||||||
import { useShallow } from "zustand/shallow";
|
|
||||||
// removed search placeholder; library state now managed via zustand
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import useHeaderStore from "@/utils/store/header";
|
|
||||||
import useSearchStore from "@/utils/store/search";
|
|
||||||
import BackButton from "../buttons/backButton";
|
|
||||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
|
||||||
import { NavigationDrawer } from "./navigationDrawer";
|
|
||||||
|
|
||||||
const MemoizeBackButton = React.memo(BackButton);
|
|
||||||
|
|
||||||
const HIDDEN_PATHS = [
|
|
||||||
"/login",
|
|
||||||
"/setup",
|
|
||||||
"/server",
|
|
||||||
"/player",
|
|
||||||
"/error",
|
|
||||||
"/settings",
|
|
||||||
"/library",
|
|
||||||
"/search",
|
|
||||||
];
|
|
||||||
|
|
||||||
export const AppBar = () => {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const location = useLocation();
|
|
||||||
|
|
||||||
const toggleSearchDialog = useSearchStore(
|
|
||||||
useShallow((s) => s.toggleSearchDialog),
|
|
||||||
);
|
|
||||||
|
|
||||||
const display = !HIDDEN_PATHS.some(
|
|
||||||
(path) =>
|
|
||||||
(location.pathname.startsWith(path) &&
|
|
||||||
location.pathname !== "/player/audio") ||
|
|
||||||
location.pathname === "/",
|
|
||||||
);
|
|
||||||
|
|
||||||
const trigger = useScrollTrigger({
|
|
||||||
disableHysteresis: true,
|
|
||||||
threshold: 20,
|
|
||||||
});
|
|
||||||
|
|
||||||
const [showDrawer, setShowDrawer] = useState(false);
|
|
||||||
|
|
||||||
const appBarStyling = useMemo(() => {
|
|
||||||
return {
|
|
||||||
backgroundColor: "transparent",
|
|
||||||
paddingRight: "0 !important",
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const _handleNavigateToSearch = useCallback(
|
|
||||||
() => navigate({ to: "/search", search: { query: "" } }),
|
|
||||||
[navigate],
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleDrawerClose = useCallback(() => {
|
|
||||||
setShowDrawer(false);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleDrawerOpen = useCallback(() => {
|
|
||||||
setShowDrawer(true);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleNavigateToHome = useCallback(() => navigate({ to: "/home" }), []);
|
|
||||||
const handleNavigateToFavorite = useCallback(() => {
|
|
||||||
navigate({ to: "/favorite" });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useHeaderStore(useShallow((s) => ({ pageTitle: s.pageTitle })));
|
|
||||||
|
|
||||||
if (!display) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (display) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<MuiAppBar
|
|
||||||
style={appBarStyling}
|
|
||||||
className={
|
|
||||||
trigger
|
|
||||||
? "appBar flex flex-row flex-justify-spaced-between elevated"
|
|
||||||
: "appBar flex flex-row flex-justify-spaced-between"
|
|
||||||
}
|
|
||||||
elevation={0}
|
|
||||||
color="transparent"
|
|
||||||
>
|
|
||||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
|
||||||
<IconButton onClick={handleDrawerOpen}>
|
|
||||||
<span className="material-symbols-rounded">menu</span>
|
|
||||||
</IconButton>
|
|
||||||
<MemoizeBackButton />
|
|
||||||
<IconButton onClick={handleNavigateToHome}>
|
|
||||||
<span
|
|
||||||
className={
|
|
||||||
location.pathname === "/home"
|
|
||||||
? "material-symbols-rounded fill"
|
|
||||||
: "material-symbols-rounded"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
home
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
|
||||||
<IconButton onClick={toggleSearchDialog}>
|
|
||||||
<span className="material-symbols-rounded">search</span>
|
|
||||||
</IconButton>
|
|
||||||
<IconButton onClick={handleNavigateToFavorite}>
|
|
||||||
<span className="material-symbols-rounded">favorite</span>
|
|
||||||
</IconButton>
|
|
||||||
<UserAvatarMenu />
|
|
||||||
</div>
|
|
||||||
</MuiAppBar>
|
|
||||||
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
.back-only-bar {
|
||||||
|
padding-top: var(--safe-top);
|
||||||
|
|
||||||
|
html.is-macos & {
|
||||||
|
padding-left: 76px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.qc-label-short {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
.qc-label-full {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qc-label-short {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-only-bar .MuiButton-root {
|
||||||
|
height: 38px;
|
||||||
|
min-height: 38px;
|
||||||
|
padding: 0 0.85rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.72rem;
|
||||||
|
line-height: 1;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ import { useLocation, useRouter } from "@tanstack/react-router";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import QuickConnectButton from "../buttons/quickConnectButton";
|
import QuickConnectButton from "../buttons/quickConnectButton";
|
||||||
|
|
||||||
|
import "./backOnly.scss";
|
||||||
|
|
||||||
export default function AppBarBackOnly() {
|
export default function AppBarBackOnly() {
|
||||||
const { history } = useRouter();
|
const { history } = useRouter();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -16,14 +18,19 @@ export default function AppBarBackOnly() {
|
|||||||
const hideQuickConnect = location.pathname === "/setup/server/list";
|
const hideQuickConnect = location.pathname === "/setup/server/list";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar elevation={0} color="transparent" position="fixed">
|
<AppBar
|
||||||
|
className="back-only-bar"
|
||||||
|
elevation={0}
|
||||||
|
color="transparent"
|
||||||
|
position="fixed"
|
||||||
|
>
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="large"
|
size="large"
|
||||||
edge="start"
|
edge="start"
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
color="white"
|
color="white"
|
||||||
aria-label="back"
|
aria-label="Назад"
|
||||||
disabled={history.length <= 1}
|
disabled={history.length <= 1}
|
||||||
onClick={handleBack}
|
onClick={handleBack}
|
||||||
sx={{ mr: 2 }}
|
sx={{ mr: 2 }}
|
||||||
@@ -43,4 +50,4 @@ export default function AppBarBackOnly() {
|
|||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api";
|
|
||||||
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import React, { useMemo } from "react";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import ListItemLink from "../listItemLink";
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
|
||||||
|
|
||||||
interface NavigationDrawerProps {
|
|
||||||
open: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const [user] = useCentralStore((s) => [s.currentUser]);
|
|
||||||
|
|
||||||
const libraries = useQuery({
|
|
||||||
queryKey: ["libraries"],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!user?.Id || !api?.accessToken) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const libs = await getUserViewApi(api).getUserViews({
|
|
||||||
userId: user.Id,
|
|
||||||
});
|
|
||||||
return libs.data;
|
|
||||||
},
|
|
||||||
enabled: !!user?.Id && !!api?.accessToken,
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const drawerPaperProps = useMemo(() => {
|
|
||||||
return {
|
|
||||||
className: "glass library-drawer",
|
|
||||||
elevation: 6,
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Drawer
|
|
||||||
open={open}
|
|
||||||
slotProps={{ paper: drawerPaperProps }}
|
|
||||||
className="library-drawer"
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
<List>
|
|
||||||
<ListItem>
|
|
||||||
<ListItemButton onClick={onClose}>
|
|
||||||
<span className="material-symbols-rounded">menu_open</span>
|
|
||||||
<div style={{ marginLeft: "8px" }}>Close</div>
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
</List>
|
|
||||||
<Divider variant="middle" />
|
|
||||||
<List>
|
|
||||||
<ListItemLink
|
|
||||||
className="library-drawer-item"
|
|
||||||
to="/home"
|
|
||||||
icon="home"
|
|
||||||
primary="Home"
|
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
{libraries.isSuccess &&
|
|
||||||
libraries.data?.Items?.map((library) => (
|
|
||||||
<ListItemLink
|
|
||||||
className="library-drawer-item"
|
|
||||||
key={library.Id}
|
|
||||||
to="/library/$id"
|
|
||||||
params={{ id: library.Id ?? "" }}
|
|
||||||
icon={
|
|
||||||
library.CollectionType && getTypeIcon(library.CollectionType)
|
|
||||||
}
|
|
||||||
primary={library.Name ?? "Library"}
|
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</List>
|
|
||||||
<Divider variant="middle" />
|
|
||||||
<List>
|
|
||||||
<ListItemLink
|
|
||||||
to="/settings/preferences"
|
|
||||||
icon="settings"
|
|
||||||
primary="Settings"
|
|
||||||
className="library-drawer-item"
|
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
<ListItemLink
|
|
||||||
to="/settings/changeServer"
|
|
||||||
icon="dns"
|
|
||||||
primary="Change Server"
|
|
||||||
className="library-drawer-item"
|
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
<ListItemLink
|
|
||||||
to="/settings/about"
|
|
||||||
icon="info"
|
|
||||||
primary="About"
|
|
||||||
className="library-drawer-item"
|
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
</List>
|
|
||||||
</Drawer>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,330 @@
|
|||||||
|
:root {
|
||||||
|
--app-titlebar-height: 64px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
:root {
|
||||||
|
--app-titlebar-height: calc(96px + var(--safe-top));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html:not(.has-app-titlebar) {
|
||||||
|
--app-titlebar-height: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* One titlebar for the whole app: brand and sections on the left, utilities
|
||||||
|
and window buttons on the right. It floats above the page; page content
|
||||||
|
insets itself by `--app-titlebar-height`, so route roots all start at y=0
|
||||||
|
and transitions never shift the page vertically. */
|
||||||
|
.app-titlebar {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0 0 auto;
|
||||||
|
z-index: 1000;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||||||
|
grid-template-areas: "start nav actions";
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
height: var(--app-titlebar-height);
|
||||||
|
padding: 0 clamp(1.1rem, 2.4vw, 2.4rem);
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: #fff;
|
||||||
|
background: transparent;
|
||||||
|
isolation: isolate;
|
||||||
|
|
||||||
|
/* Two layers that cross-fade: the glass surface and the soft gradient used
|
||||||
|
while the titlebar floats over the home hero. No hard border between the
|
||||||
|
bar and the page. */
|
||||||
|
&::before,
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: -1;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
inset: 0 0 -14px;
|
||||||
|
background: rgb(12 13 18 / 0.74);
|
||||||
|
backdrop-filter: blur(24px) saturate(170%);
|
||||||
|
mask-image: linear-gradient(
|
||||||
|
to bottom,
|
||||||
|
#000 calc(100% - 14px),
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
-webkit-mask-image: linear-gradient(
|
||||||
|
to bottom,
|
||||||
|
#000 calc(100% - 14px),
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity 360ms cubic-bezier(0.33, 1, 0.68, 1);
|
||||||
|
will-change: opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
rgb(0 0 0 / 0.58) 0%,
|
||||||
|
rgb(0 0 0 / 0.24) 62%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 360ms cubic-bezier(0.33, 1, 0.68, 1);
|
||||||
|
will-change: opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
html.is-macos & {
|
||||||
|
padding-left: calc(clamp(1.1rem, 2.4vw, 2.4rem) + 72px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Home: transparent over the hero until the page starts scrolling. */
|
||||||
|
&--overlay {
|
||||||
|
&::before {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
width: 2.35rem;
|
||||||
|
height: 2.35rem;
|
||||||
|
color: rgb(255 255 255 / 0.76);
|
||||||
|
transition:
|
||||||
|
color 150ms ease,
|
||||||
|
background-color 150ms ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiIconButton-root.Mui-disabled {
|
||||||
|
color: rgb(255 255 255 / 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-controls {
|
||||||
|
margin-left: 0.4rem;
|
||||||
|
background: rgb(255 255 255 / 0.05);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-top {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-start {
|
||||||
|
grid-area: start;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.35rem;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-brand {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.55rem;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0.2rem 0.35rem 0.2rem 0.15rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: #fff;
|
||||||
|
font-family: "Medeo Sans", system-ui, sans-serif;
|
||||||
|
font-size: 1.45rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
line-height: 1;
|
||||||
|
text-decoration: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
&-mark {
|
||||||
|
width: 2rem;
|
||||||
|
height: 1.6rem;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-nav {
|
||||||
|
grid-area: nav;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.1rem;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-nav-link {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 2.4rem;
|
||||||
|
padding: 0 0.95rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
color: rgb(255 255 255 / 0.64);
|
||||||
|
font-size: 0.92rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition:
|
||||||
|
color 150ms ease,
|
||||||
|
background-color 150ms ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.07);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.09);
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: 0.28rem;
|
||||||
|
width: 1.35rem;
|
||||||
|
height: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
background: $clr-accent-default;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-actions {
|
||||||
|
grid-area: actions;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 0.1rem;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-icon-link {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 2.35rem;
|
||||||
|
height: 2.35rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: rgb(255 255 255 / 0.76);
|
||||||
|
text-decoration: none;
|
||||||
|
transition:
|
||||||
|
color 150ms ease,
|
||||||
|
background-color 150ms ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.35rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1100px) {
|
||||||
|
.app-titlebar-cast {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html.is-android .app-titlebar-downloads {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.app-titlebar {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 0;
|
||||||
|
padding: calc(var(--safe-top) + 0.3rem) 0.6rem 0.35rem;
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
width: 2.15rem;
|
||||||
|
height: 2.15rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-top {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
|
height: 46px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-start {
|
||||||
|
min-width: 0;
|
||||||
|
gap: 0.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-brand {
|
||||||
|
gap: 0.4rem;
|
||||||
|
font-size: 1.18rem;
|
||||||
|
|
||||||
|
&-mark {
|
||||||
|
width: 1.55rem;
|
||||||
|
height: 1.28rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-nav {
|
||||||
|
justify-content: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
height: 38px;
|
||||||
|
gap: 0.05rem;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
scrollbar-width: none;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-nav-link {
|
||||||
|
height: 32px;
|
||||||
|
padding: 0 0.72rem;
|
||||||
|
font-size: 0.84rem;
|
||||||
|
|
||||||
|
&.is-active::after {
|
||||||
|
bottom: 0.18rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-actions {
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-icon-link {
|
||||||
|
width: 2.15rem;
|
||||||
|
height: 2.15rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
.app-titlebar {
|
||||||
|
html.is-macos & {
|
||||||
|
padding-left: 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-controls {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-titlebar-cast,
|
||||||
|
.app-titlebar-downloads {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
import { IconButton, Tooltip, useScrollTrigger } from "@mui/material";
|
||||||
|
import { Link, useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
|
import React, { useEffect, useLayoutEffect, useRef } from "react";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import BackButton from "@/components/buttons/backButton";
|
||||||
|
import CastButton from "@/components/buttons/castButton";
|
||||||
|
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
||||||
|
import WindowControls from "@/components/windowControls";
|
||||||
|
import {
|
||||||
|
getLocalMediaTransfer,
|
||||||
|
useCurrentMediaItem,
|
||||||
|
} from "@/utils/methods/localTransfer";
|
||||||
|
import useSearchStore from "@/utils/store/search";
|
||||||
|
import { shouldShowTitlebar } from "./routeVisibility";
|
||||||
|
import { type AppNavItem, useAppNavigation } from "./useAppNavigation";
|
||||||
|
|
||||||
|
import "./appTitlebar.scss";
|
||||||
|
|
||||||
|
const BlinkMark = () => (
|
||||||
|
<svg
|
||||||
|
className="app-titlebar-brand-mark"
|
||||||
|
viewBox="0 0 40 32"
|
||||||
|
fill="none"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<g
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2.2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M8.5 7.6 4.7 4.2" />
|
||||||
|
<path d="M14.2 5.4 13.4 1.4" />
|
||||||
|
<path d="M20.4 5.2 21.1 1.3" />
|
||||||
|
<path d="M5.2 18.4c3.7-5.9 10.5-8.3 16.6-5.7 4.2 1.8 7.6 5 9.8 8.2-4.8 4.7-12.4 6.1-18.2 3.5-3.7-1.7-6.4-3.7-8.2-6Z" />
|
||||||
|
<path
|
||||||
|
d="M18.7 18.5a2.9 2.9 0 1 0 0-5.8 2.9 2.9 0 0 0 0 5.8Z"
|
||||||
|
fill="currentColor"
|
||||||
|
stroke="none"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
const isItemActive = (item: AppNavItem, pathname: string) =>
|
||||||
|
item.kind === "home"
|
||||||
|
? pathname === "/home"
|
||||||
|
: pathname === `/library/${item.libraryId}` ||
|
||||||
|
(item.key === "music" && pathname.startsWith("/music/"));
|
||||||
|
|
||||||
|
const NavItem = ({ item, active }: { item: AppNavItem; active: boolean }) => {
|
||||||
|
const className = `app-titlebar-nav-link${active ? " is-active" : ""}`;
|
||||||
|
if (item.kind === "home") {
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
to="/home"
|
||||||
|
className={className}
|
||||||
|
aria-current={active ? "page" : undefined}
|
||||||
|
>
|
||||||
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
to="/library/$id"
|
||||||
|
params={{ id: item.libraryId }}
|
||||||
|
className={className}
|
||||||
|
aria-current={active ? "page" : undefined}
|
||||||
|
>
|
||||||
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AppTitlebar = () => {
|
||||||
|
const { pathname } = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const visible = shouldShowTitlebar(pathname);
|
||||||
|
const isHome = pathname === "/home";
|
||||||
|
const scrolled = useScrollTrigger({
|
||||||
|
disableHysteresis: true,
|
||||||
|
threshold: 20,
|
||||||
|
});
|
||||||
|
const navigation = useAppNavigation(visible);
|
||||||
|
const navRef = useRef<HTMLElement | null>(null);
|
||||||
|
const currentMedia = useCurrentMediaItem();
|
||||||
|
|
||||||
|
const toggleSearchDialog = useSearchStore(
|
||||||
|
useShallow((s) => s.toggleSearchDialog),
|
||||||
|
);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
document.documentElement.classList.toggle("has-app-titlebar", visible);
|
||||||
|
}, [visible]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const active = navRef.current?.querySelector<HTMLElement>(
|
||||||
|
".app-titlebar-nav-link.is-active",
|
||||||
|
);
|
||||||
|
active?.scrollIntoView({
|
||||||
|
behavior: "smooth",
|
||||||
|
block: "nearest",
|
||||||
|
inline: "center",
|
||||||
|
});
|
||||||
|
}, [pathname, navigation.length]);
|
||||||
|
|
||||||
|
if (!visible) return null;
|
||||||
|
|
||||||
|
const overlay = isHome && !scrolled;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<header
|
||||||
|
className={`app-titlebar${overlay ? " app-titlebar--overlay" : ""}`}
|
||||||
|
data-tauri-drag-region
|
||||||
|
>
|
||||||
|
<div className="app-titlebar-top">
|
||||||
|
<div className="app-titlebar-start" data-tauri-drag-region>
|
||||||
|
<BackButton />
|
||||||
|
<Link
|
||||||
|
to="/home"
|
||||||
|
className="app-titlebar-brand"
|
||||||
|
aria-label="Blink — на главную"
|
||||||
|
>
|
||||||
|
<BlinkMark />
|
||||||
|
<span>Blink</span>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="app-titlebar-actions" data-tauri-drag-region>
|
||||||
|
<span className="app-titlebar-cast">
|
||||||
|
<CastButton
|
||||||
|
item={currentMedia}
|
||||||
|
getTransfer={getLocalMediaTransfer}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<Tooltip title="Поиск">
|
||||||
|
<IconButton onClick={toggleSearchDialog} aria-label="Поиск">
|
||||||
|
<span className="material-symbols-rounded">search</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Загрузки">
|
||||||
|
<IconButton
|
||||||
|
className="app-titlebar-downloads"
|
||||||
|
onClick={() => navigate({ to: "/downloads" })}
|
||||||
|
aria-label="Загрузки"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">download</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Настройки">
|
||||||
|
<Link
|
||||||
|
to="/settings/preferences"
|
||||||
|
className="app-titlebar-icon-link"
|
||||||
|
aria-label="Настройки"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">settings</span>
|
||||||
|
</Link>
|
||||||
|
</Tooltip>
|
||||||
|
<UserAvatarMenu />
|
||||||
|
<WindowControls />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav
|
||||||
|
ref={navRef}
|
||||||
|
className="app-titlebar-nav"
|
||||||
|
aria-label="Основная навигация"
|
||||||
|
>
|
||||||
|
{navigation.map((item) => (
|
||||||
|
<NavItem
|
||||||
|
key={item.key}
|
||||||
|
item={item}
|
||||||
|
active={isItemActive(item, pathname)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
const HIDDEN_PREFIXES = ["/login", "/setup", "/server", "/error", "/player"];
|
||||||
|
|
||||||
|
/** Routes that keep the global titlebar. Auth, setup and players do not. */
|
||||||
|
export const shouldShowTitlebar = (pathname: string) =>
|
||||||
|
pathname !== "/" &&
|
||||||
|
!HIDDEN_PREFIXES.some(
|
||||||
|
(prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`),
|
||||||
|
);
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
|
export type AppNavItem =
|
||||||
|
| {
|
||||||
|
kind: "home";
|
||||||
|
key: "home";
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
kind: "library";
|
||||||
|
key: "movies" | "tvshows" | "music";
|
||||||
|
label: string;
|
||||||
|
libraryId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const LIBRARY_NAV = [
|
||||||
|
{ key: "movies", collectionType: "movies", label: "Фильмы" },
|
||||||
|
{ key: "tvshows", collectionType: "tvshows", label: "Сериалы" },
|
||||||
|
{ key: "music", collectionType: "music", label: "Музыка" },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The four permanent sections of the app titlebar. Library items are resolved
|
||||||
|
* from the same cached `getUserViews` query the home page already loads.
|
||||||
|
*/
|
||||||
|
export const useAppNavigation = (enabled: boolean) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
|
const libraries = useQuery({
|
||||||
|
queryKey: ["libraries"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api?.accessToken || !user?.Id) return undefined;
|
||||||
|
const response = await getUserViewApi(api).getUserViews({
|
||||||
|
userId: user.Id,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
enabled: enabled && !!api?.accessToken && !!user?.Id,
|
||||||
|
staleTime: 5 * 60 * 1000,
|
||||||
|
networkMode: "always",
|
||||||
|
});
|
||||||
|
|
||||||
|
const items = useMemo<AppNavItem[]>(() => {
|
||||||
|
const list: AppNavItem[] = [
|
||||||
|
{ kind: "home", key: "home", label: "Главная" },
|
||||||
|
];
|
||||||
|
const views: BaseItemDto[] = libraries.data?.Items ?? [];
|
||||||
|
|
||||||
|
for (const entry of LIBRARY_NAV) {
|
||||||
|
const library = views.find(
|
||||||
|
(view) => view.Id && view.CollectionType === entry.collectionType,
|
||||||
|
);
|
||||||
|
if (!library?.Id) continue;
|
||||||
|
list.push({
|
||||||
|
kind: "library",
|
||||||
|
key: entry.key,
|
||||||
|
label: entry.label,
|
||||||
|
libraryId: library.Id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}, [libraries.data]);
|
||||||
|
|
||||||
|
return items;
|
||||||
|
};
|
||||||
@@ -5,15 +5,20 @@ import { useBackdropStore } from "@/utils/store/backdrop";
|
|||||||
import BlurhashCanvas from "../blurhash-canvas";
|
import BlurhashCanvas from "../blurhash-canvas";
|
||||||
|
|
||||||
export default function Backdrop() {
|
export default function Backdrop() {
|
||||||
// const [backdropLoading, setBackdropLoading] = useState(true);
|
|
||||||
|
|
||||||
const { backdropHash } = useBackdropStore(
|
const { backdropHash } = useBackdropStore(
|
||||||
useShallow((state) => ({
|
useShallow((state) => ({
|
||||||
backdropHash: state.backdropHash,
|
backdropHash: state.backdropHash,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!backdropHash) {
|
// Routes clear the backdrop when they mount ("") and some set it later.
|
||||||
|
// Keep the last non-empty hash so the app background never blanks out
|
||||||
|
// (which looked like a flash on every page open).
|
||||||
|
const lastHash = React.useRef<string | undefined>(undefined);
|
||||||
|
if (backdropHash) lastHash.current = backdropHash;
|
||||||
|
const hash = backdropHash || lastHash.current;
|
||||||
|
|
||||||
|
if (!hash) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,16 +27,16 @@ export default function Backdrop() {
|
|||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
key={backdropHash}
|
key={hash}
|
||||||
exit={{ opacity: 0 }}
|
exit={{ opacity: 0 }}
|
||||||
transition={{
|
transition={{
|
||||||
duration: 2,
|
duration: 0.45,
|
||||||
ease: "easeInOut",
|
ease: "easeInOut",
|
||||||
}}
|
}}
|
||||||
className="app-backdrop-container"
|
className="app-backdrop-container"
|
||||||
>
|
>
|
||||||
<BlurhashCanvas
|
<BlurhashCanvas
|
||||||
blurhashString={backdropHash}
|
blurhashString={hash}
|
||||||
width={300}
|
width={300}
|
||||||
height={150}
|
height={150}
|
||||||
canvasProps={{
|
canvasProps={{
|
||||||
@@ -47,4 +52,4 @@ export default function Backdrop() {
|
|||||||
</motion.div>
|
</motion.div>
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,12 @@ export default function BackButton() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton onClick={handleClick} disabled={history.length === 0}>
|
<IconButton
|
||||||
|
onClick={handleClick}
|
||||||
|
disabled={history.length === 0}
|
||||||
|
aria-label="Назад"
|
||||||
|
title="Назад"
|
||||||
|
>
|
||||||
<span className="material-symbols-rounded">arrow_back</span>
|
<span className="material-symbols-rounded">arrow_back</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import React from "react";
|
||||||
|
import useRemoteControlStore, {
|
||||||
|
type RemoteTransfer,
|
||||||
|
} from "@/utils/store/remoteControl";
|
||||||
|
|
||||||
|
type CastButtonProps = {
|
||||||
|
item?: BaseItemDto | null;
|
||||||
|
transfer?: RemoteTransfer;
|
||||||
|
/** Computed on click so playback position/queue are current. */
|
||||||
|
getTransfer?: () => RemoteTransfer | null;
|
||||||
|
size?: "small" | "medium" | "large";
|
||||||
|
};
|
||||||
|
|
||||||
|
const CastButton = ({
|
||||||
|
item,
|
||||||
|
transfer,
|
||||||
|
getTransfer,
|
||||||
|
size = "medium",
|
||||||
|
}: CastButtonProps) => {
|
||||||
|
const openDialog = useRemoteControlStore((s) => s.openDialog);
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
title={
|
||||||
|
item
|
||||||
|
? "Передать текущее медиа на устройство"
|
||||||
|
: "Удалённое управление"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
size={size}
|
||||||
|
aria-label={
|
||||||
|
item
|
||||||
|
? "Передать текущее медиа на устройство"
|
||||||
|
: "Удалённое управление"
|
||||||
|
}
|
||||||
|
onClick={() => {
|
||||||
|
const computed = getTransfer ? getTransfer() : transfer;
|
||||||
|
const resolvedItem = item ?? computed?.item ?? null;
|
||||||
|
openDialog({
|
||||||
|
...(computed ?? {}),
|
||||||
|
item: resolvedItem,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">cast</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CastButton;
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { startInstantMix } from "@/utils/methods/instantMix";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
|
type InstantMixButtonProps = {
|
||||||
|
item?: BaseItemDto | null;
|
||||||
|
/** Render a text button instead of an icon (e.g. on the album page). */
|
||||||
|
withLabel?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const InstantMixButton = ({ item, withLabel = false }: InstantMixButtonProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
|
||||||
|
const handleClick = async () => {
|
||||||
|
if (!api || !user?.Id || !item) return;
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
const { count } = await startInstantMix(api, user.Id, item);
|
||||||
|
if (count === 0) {
|
||||||
|
enqueueSnackbar("Треки для микса не найдены", {
|
||||||
|
variant: "warning",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
enqueueSnackbar(`Микс: ${count} треков`, {
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Instant Mix failed", error);
|
||||||
|
enqueueSnackbar("Не удалось запустить микс", { variant: "error" });
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip title="Микс">
|
||||||
|
<span>
|
||||||
|
{withLabel ? (
|
||||||
|
<IconButton
|
||||||
|
aria-label="Микс"
|
||||||
|
onClick={handleClick}
|
||||||
|
disabled={busy || !item}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">radio</span>
|
||||||
|
</IconButton>
|
||||||
|
) : (
|
||||||
|
<IconButton
|
||||||
|
aria-label="Микс"
|
||||||
|
onClick={handleClick}
|
||||||
|
disabled={busy || !item}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">radio</span>
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default InstantMixButton;
|
||||||
@@ -50,7 +50,7 @@ export default function LikeButton({
|
|||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: handleLiking,
|
mutationFn: handleLiking,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
enqueueSnackbar(`Не удалось обновить «${itemName}»`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export default function MarkPlayedButton({
|
|||||||
enqueueSnackbar(`${error}`, {
|
enqueueSnackbar(`${error}`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
enqueueSnackbar(`Не удалось обновить «${itemName}»`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
|
ItemFields,
|
||||||
|
SortOrder,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import { getShowApi } from "@jellyfin/sdk/lib/utils/api/show-api";
|
import { getShowApi } from "@jellyfin/sdk/lib/utils/api/show-api";
|
||||||
import type { SxProps } from "@mui/material";
|
import type { SxProps } from "@mui/material";
|
||||||
import Button, { type ButtonProps } from "@mui/material/Button";
|
import Button, { type ButtonProps } from "@mui/material/Button";
|
||||||
@@ -90,13 +93,13 @@ const PlayButton = ({
|
|||||||
mutationKey: ["playButton", item?.Id, userId],
|
mutationKey: ["playButton", item?.Id, userId],
|
||||||
mutationFn: async (currentEpisodeId?: string) => {
|
mutationFn: async (currentEpisodeId?: string) => {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
throw new Error("API is not available");
|
throw new Error("API недоступно");
|
||||||
}
|
}
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
throw new Error("User ID is not available");
|
throw new Error("Не указан пользователь");
|
||||||
}
|
}
|
||||||
if (!item.Id) {
|
if (!item.Id) {
|
||||||
throw new Error("Item ID is not available");
|
throw new Error("Не найден идентификатор элемента");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await getPlaybackInfo(api, userId, item, {
|
return await getPlaybackInfo(api, userId, item, {
|
||||||
@@ -109,28 +112,29 @@ const PlayButton = ({
|
|||||||
},
|
},
|
||||||
onSuccess: async (result: PlayResult | null) => {
|
onSuccess: async (result: PlayResult | null) => {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
console.error("API is not available");
|
console.error("API недоступно");
|
||||||
enqueueSnackbar("API is not available", { variant: "error" });
|
enqueueSnackbar("API недоступно", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
console.error("User ID is not available");
|
console.error("Не указан пользователь");
|
||||||
enqueueSnackbar("User ID is not available", { variant: "error" });
|
enqueueSnackbar("Не указан пользователь", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!result?.item?.Items?.length) {
|
if (!result?.item?.Items?.length) {
|
||||||
console.error("No items found");
|
console.error("Ничего не найдено");
|
||||||
enqueueSnackbar("No items found", { variant: "error" });
|
enqueueSnackbar("Ничего не найдено", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!result?.item?.Items?.[0]?.Id) {
|
if (!result?.item?.Items?.[0]?.Id) {
|
||||||
console.error("No item ID found");
|
console.error("Не найден идентификатор элемента");
|
||||||
enqueueSnackbar("No item ID found", { variant: "error" });
|
enqueueSnackbar("Не найден идентификатор элемента", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio) {
|
if (audio) {
|
||||||
// Album/Individual audio track playback
|
// Album/Individual audio track playback
|
||||||
|
const playedItem = result?.item?.Items?.[0];
|
||||||
const playbackUrl = generateAudioStreamUrl(
|
const playbackUrl = generateAudioStreamUrl(
|
||||||
result?.item?.Items?.[0].Id,
|
result?.item?.Items?.[0].Id,
|
||||||
userId,
|
userId,
|
||||||
@@ -139,7 +143,68 @@ const PlayButton = ({
|
|||||||
api.accessToken,
|
api.accessToken,
|
||||||
);
|
);
|
||||||
playAudio(playbackUrl, result?.item?.Items?.[0], undefined);
|
playAudio(playbackUrl, result?.item?.Items?.[0], undefined);
|
||||||
setQueue(result?.item?.Items ?? [], 0);
|
|
||||||
|
if (
|
||||||
|
playedItem?.Type === BaseItemKind.Audio &&
|
||||||
|
(result?.item?.Items?.length ?? 0) <= 1
|
||||||
|
) {
|
||||||
|
// A single track has no queue of its own. Queue the record it
|
||||||
|
// belongs to; when the server does not expose AlbumId, fall
|
||||||
|
// back to the artist's songs so "Очередь" is never empty.
|
||||||
|
const loadQueue = async (): Promise<{
|
||||||
|
items: BaseItemDto[];
|
||||||
|
index: number;
|
||||||
|
}> => {
|
||||||
|
if (playedItem.AlbumId) {
|
||||||
|
const albumTracks = await getLibraryApi(api).getItems({
|
||||||
|
parentId: playedItem.AlbumId,
|
||||||
|
userId,
|
||||||
|
sortOrder: [SortOrder.Ascending],
|
||||||
|
sortBy: ["IndexNumber"],
|
||||||
|
fields: [ItemFields.MediaSources],
|
||||||
|
});
|
||||||
|
const items = albumTracks.data.Items ?? [];
|
||||||
|
if (items.length > 0) {
|
||||||
|
return {
|
||||||
|
items,
|
||||||
|
index: Math.max(
|
||||||
|
items.findIndex((t) => t.Id === playedItem.Id),
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const artistName =
|
||||||
|
playedItem.Artists?.[0] ?? playedItem.AlbumArtists?.[0]?.Name;
|
||||||
|
if (artistName) {
|
||||||
|
const artistTracks = await getLibraryApi(api).getItems({
|
||||||
|
userId,
|
||||||
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
|
artists: [artistName],
|
||||||
|
recursive: true,
|
||||||
|
sortBy: ["SortName"],
|
||||||
|
sortOrder: [SortOrder.Ascending],
|
||||||
|
fields: [ItemFields.MediaSources],
|
||||||
|
});
|
||||||
|
const items = artistTracks.data.Items ?? [];
|
||||||
|
const index = items.findIndex((t) => t.Id === playedItem.Id);
|
||||||
|
if (items.length > 1 && index >= 0) {
|
||||||
|
return { items, index };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { items: [playedItem], index: 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const nextQueue = await loadQueue();
|
||||||
|
setQueue(nextQueue.items, nextQueue.index);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Could not build the audio queue", error);
|
||||||
|
setQueue([playedItem], 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setQueue(result?.item?.Items ?? [], 0);
|
||||||
|
}
|
||||||
} else if (item.Type === "Photo") {
|
} else if (item.Type === "Photo") {
|
||||||
const index = result?.item?.Items?.map((i) => i.Id).indexOf(item.Id);
|
const index = result?.item?.Items?.map((i) => i.Id).indexOf(item.Id);
|
||||||
if (result?.item?.Items && index) {
|
if (result?.item?.Items && index) {
|
||||||
@@ -148,8 +213,8 @@ const PlayButton = ({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
||||||
console.error("No media source ID found");
|
console.error("Не найден источник медиа");
|
||||||
enqueueSnackbar("No media source ID found", { variant: "error" });
|
enqueueSnackbar("Не найден источник медиа", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const episodeIndex = result.episodeIndex;
|
const episodeIndex = result.episodeIndex;
|
||||||
@@ -195,7 +260,7 @@ const PlayButton = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const handleClick = (
|
const handleClick = (
|
||||||
e: MouseEvent<HTMLAnchorElement | MouseEvent>,
|
e: MouseEvent<HTMLElement>,
|
||||||
currentEpisodeId?: string | undefined,
|
currentEpisodeId?: string | undefined,
|
||||||
) => {
|
) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -205,13 +270,13 @@ const PlayButton = ({
|
|||||||
queryKey: ["playButton", "currentEpisode", item?.Id],
|
queryKey: ["playButton", "currentEpisode", item?.Id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
throw new Error("API is not available");
|
throw new Error("API недоступно");
|
||||||
}
|
}
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
throw new Error("User ID is not available");
|
throw new Error("Не указан пользователь");
|
||||||
}
|
}
|
||||||
if (!item.Id) {
|
if (!item.Id) {
|
||||||
throw new Error("Item ID is not available");
|
throw new Error("Не найден идентификатор элемента");
|
||||||
}
|
}
|
||||||
const seasons = await getShowApi(api).getSeasons({
|
const seasons = await getShowApi(api).getSeasons({
|
||||||
seriesId: item.Id,
|
seriesId: item.Id,
|
||||||
@@ -237,12 +302,26 @@ const PlayButton = ({
|
|||||||
enabled: itemType === BaseItemKind.Series,
|
enabled: itemType === BaseItemKind.Series,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isAudioItem =
|
||||||
|
item?.Type === "MusicAlbum" ||
|
||||||
|
item?.Type === "Audio" ||
|
||||||
|
item?.Type === "AudioBook" ||
|
||||||
|
item?.Type === "Playlist" ||
|
||||||
|
audio;
|
||||||
|
const playLabel = item.UserData?.PlaybackPositionTicks
|
||||||
|
? isAudioItem
|
||||||
|
? "Продолжить прослушивание"
|
||||||
|
: "Продолжить просмотр"
|
||||||
|
: isAudioItem
|
||||||
|
? "Слушать"
|
||||||
|
: "Смотреть";
|
||||||
|
|
||||||
if (iconOnly) {
|
if (iconOnly) {
|
||||||
return (
|
return (
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
<Fab
|
<Fab
|
||||||
color="primary"
|
color="primary"
|
||||||
aria-label="Play"
|
aria-label={isAudioItem ? "Слушать" : "Смотреть"}
|
||||||
className={className}
|
className={className}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (item.Type === "Episode") {
|
if (item.Type === "Episode") {
|
||||||
@@ -322,14 +401,14 @@ const PlayButton = ({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{currentEpisode.isPending ? (
|
{currentEpisode.isPending ? (
|
||||||
"Loading..."
|
"Загрузка..."
|
||||||
) : !currentEpisode.data ||
|
) : !currentEpisode.data ||
|
||||||
!currentEpisode.data.Items ||
|
!currentEpisode.data.Items ||
|
||||||
currentEpisode.data.Items.length === 0 ? (
|
currentEpisode.data.Items.length === 0 ? (
|
||||||
"No episodes to watch found"
|
"Нет серий для просмотра"
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
Watch S{currentEpisode.data.Items[0].ParentIndexNumber ?? 1}E
|
Смотреть S{currentEpisode.data.Items[0].ParentIndexNumber ?? 1}E
|
||||||
{currentEpisode.data.Items[0]?.IndexNumber ?? 1}
|
{currentEpisode.data.Items[0]?.IndexNumber ?? 1}
|
||||||
<MemoizedLinearProgress
|
<MemoizedLinearProgress
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
@@ -363,7 +442,7 @@ const PlayButton = ({
|
|||||||
(currentEpisode.data?.Items?.[0]?.UserData
|
(currentEpisode.data?.Items?.[0]?.UserData
|
||||||
?.PlaybackPositionTicks ?? 0),
|
?.PlaybackPositionTicks ?? 0),
|
||||||
)}{" "}
|
)}{" "}
|
||||||
left
|
осталось
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -403,15 +482,7 @@ const PlayButton = ({
|
|||||||
color="white"
|
color="white"
|
||||||
size={size}
|
size={size}
|
||||||
>
|
>
|
||||||
{item.UserData?.PlaybackPositionTicks
|
{playLabel}
|
||||||
? "Continue Watching"
|
|
||||||
: item?.Type === "MusicAlbum" ||
|
|
||||||
item?.Type === "Audio" ||
|
|
||||||
item?.Type === "AudioBook" ||
|
|
||||||
item?.Type === "Playlist" ||
|
|
||||||
audio
|
|
||||||
? "Play Now"
|
|
||||||
: "Watch Now"}
|
|
||||||
<MemoizedLinearProgress
|
<MemoizedLinearProgress
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
value={
|
value={
|
||||||
@@ -437,7 +508,7 @@ const PlayButton = ({
|
|||||||
(item.RunTimeTicks ?? 0) -
|
(item.RunTimeTicks ?? 0) -
|
||||||
(item.UserData?.PlaybackPositionTicks ?? 0),
|
(item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
)}{" "}
|
)}{" "}
|
||||||
left
|
осталось
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
|
||||||
import useQueue from "@/utils/store/queue";
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { IconButton } from "@mui/material";
|
import { IconButton } from "@mui/material";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
|
import useQueue, { getNextTrackIndex } from "@/utils/store/queue";
|
||||||
|
|
||||||
const PlayNextButton = () => {
|
const PlayNextButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -19,21 +19,21 @@ const PlayNextButton = () => {
|
|||||||
});
|
});
|
||||||
const handlePlayNext = useMutation({
|
const handlePlayNext = useMutation({
|
||||||
mutationKey: ["playNextButton"],
|
mutationKey: ["playNextButton"],
|
||||||
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
mutationFn: async () => {
|
||||||
|
const nextIndex = getNextTrackIndex();
|
||||||
|
if (nextIndex === undefined) return;
|
||||||
|
return playItemFromQueue(nextIndex, user.data?.Id, api);
|
||||||
|
},
|
||||||
onError: (error) => console.error(error),
|
onError: (error) => console.error(error),
|
||||||
});
|
});
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
// Re-render when the queue position or repeat mode changes.
|
||||||
state.tracks,
|
useQueue((state) => [state.tracks, state.currentItemIndex, state.repeatMode]);
|
||||||
state.currentItemIndex,
|
const hasNext = getNextTrackIndex() !== undefined;
|
||||||
]);
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton disabled={!hasNext} onClick={() => handlePlayNext.mutate()}>
|
||||||
disabled={queueItems?.length === currentItemIndex + 1}
|
|
||||||
onClick={() => handlePlayNext.mutate()}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">skip_next</span>
|
<span className="material-symbols-rounded">skip_next</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default PlayNextButton;
|
export default PlayNextButton;
|
||||||
@@ -1,390 +1,31 @@
|
|||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import Drawer from "@mui/material/Drawer";
|
||||||
import {
|
import IconButton from "@mui/material/IconButton";
|
||||||
Box,
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
Drawer,
|
import React, { useState } from "react";
|
||||||
IconButton,
|
import QueueView from "@/components/queue/queueView";
|
||||||
List,
|
|
||||||
Tooltip,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import React, { useMemo, useState } from "react";
|
|
||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
|
||||||
import useQueue, {
|
|
||||||
clearUpcoming,
|
|
||||||
removeFromQueue,
|
|
||||||
reorderQueue,
|
|
||||||
shuffleUpcoming,
|
|
||||||
} from "@/utils/store/queue";
|
|
||||||
import "./queueButton.scss";
|
|
||||||
import {
|
|
||||||
closestCenter,
|
|
||||||
DndContext,
|
|
||||||
type DragEndEvent,
|
|
||||||
KeyboardSensor,
|
|
||||||
PointerSensor,
|
|
||||||
useSensor,
|
|
||||||
useSensors,
|
|
||||||
} from "@dnd-kit/core";
|
|
||||||
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
||||||
import {
|
|
||||||
arrayMove,
|
|
||||||
SortableContext,
|
|
||||||
sortableKeyboardCoordinates,
|
|
||||||
useSortable,
|
|
||||||
verticalListSortingStrategy,
|
|
||||||
} from "@dnd-kit/sortable";
|
|
||||||
import { CSS } from "@dnd-kit/utilities";
|
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import QueueListItem from "../queueListItem";
|
|
||||||
|
|
||||||
function SortableQueueItem({
|
|
||||||
item,
|
|
||||||
onDelete,
|
|
||||||
onPlay,
|
|
||||||
index,
|
|
||||||
}: {
|
|
||||||
item: BaseItemDto;
|
|
||||||
onDelete: () => void;
|
|
||||||
onPlay: () => void;
|
|
||||||
index: number;
|
|
||||||
}) {
|
|
||||||
const {
|
|
||||||
attributes,
|
|
||||||
listeners,
|
|
||||||
setNodeRef,
|
|
||||||
transform,
|
|
||||||
transition,
|
|
||||||
isDragging,
|
|
||||||
} = useSortable({ id: item.Id || "" });
|
|
||||||
|
|
||||||
const style = {
|
|
||||||
transform: CSS.Transform.toString(transform),
|
|
||||||
transition,
|
|
||||||
opacity: isDragging ? 0.5 : 1,
|
|
||||||
position: "relative" as const,
|
|
||||||
zIndex: isDragging ? 2 : 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div ref={setNodeRef} style={style}>
|
|
||||||
<QueueListItem
|
|
||||||
queueItem={item}
|
|
||||||
onDelete={onDelete}
|
|
||||||
onPlay={onPlay}
|
|
||||||
dragHandleProps={{ ...attributes, ...listeners }}
|
|
||||||
isEpisode={item.Type === "Episode"}
|
|
||||||
index={index}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/** Opens the play queue in a side drawer. */
|
||||||
const QueueButton = () => {
|
const QueueButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
|
||||||
state.tracks,
|
|
||||||
state.currentItemIndex,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const user = useQuery({
|
|
||||||
queryKey: ["currentUser"],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!api) throw new Error("API not available");
|
|
||||||
return (await getUserApi(api).getCurrentUser()).data;
|
|
||||||
},
|
|
||||||
enabled: !!api,
|
|
||||||
});
|
|
||||||
|
|
||||||
const sensors = useSensors(
|
|
||||||
useSensor(PointerSensor),
|
|
||||||
useSensor(KeyboardSensor, {
|
|
||||||
coordinateGetter: sortableKeyboardCoordinates,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const upcomingItems = useMemo(() => {
|
|
||||||
return queueItems ? queueItems.slice(currentItemIndex + 1) : [];
|
|
||||||
}, [queueItems, currentItemIndex]);
|
|
||||||
|
|
||||||
const upcomingIds = useMemo(() => {
|
|
||||||
return upcomingItems.map((item) => item.Id || "");
|
|
||||||
}, [upcomingItems]);
|
|
||||||
|
|
||||||
const handleDragEnd = (event: DragEndEvent) => {
|
|
||||||
const { active, over } = event;
|
|
||||||
|
|
||||||
if (active.id !== over?.id && queueItems) {
|
|
||||||
const oldIndex = upcomingItems.findIndex((item) => item.Id === active.id);
|
|
||||||
const newIndex = upcomingItems.findIndex((item) => item.Id === over?.id);
|
|
||||||
|
|
||||||
if (oldIndex !== -1 && newIndex !== -1) {
|
|
||||||
const newUpcoming = arrayMove(upcomingItems, oldIndex, newIndex);
|
|
||||||
const newQueue = [
|
|
||||||
...queueItems.slice(0, currentItemIndex + 1),
|
|
||||||
...newUpcoming,
|
|
||||||
];
|
|
||||||
reorderQueue(newQueue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDelete = (index: number) => {
|
|
||||||
removeFromQueue(index);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handlePlay = (index: number) => {
|
|
||||||
playItemFromQueue(index, user.data?.Id, api);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleClear = () => {
|
|
||||||
clearUpcoming();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleShuffle = () => {
|
|
||||||
shuffleUpcoming();
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Tooltip title="Очередь">
|
||||||
|
<IconButton onClick={() => setOpen(true)} aria-label="Открыть очередь">
|
||||||
|
<span className="material-symbols-rounded">queue_music</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
<Drawer
|
<Drawer
|
||||||
anchor="right"
|
anchor="right"
|
||||||
open={open}
|
open={open}
|
||||||
onClose={() => setOpen(false)}
|
onClose={() => setOpen(false)}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
backdrop: {
|
backdrop: { sx: { backgroundColor: "rgb(0 0 0 / 0.3)" } },
|
||||||
sx: {
|
paper: { className: "queue-drawer-paper" },
|
||||||
backgroundColor: "rgba(0, 0, 0, 0.2)",
|
|
||||||
backdropFilter: "blur(4px)",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
paper: {
|
|
||||||
className: "glass",
|
|
||||||
sx: {
|
|
||||||
width: 450,
|
|
||||||
maxWidth: "100%",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
borderLeft: "1px solid rgba(255, 255, 255, 0.08)",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<QueueView variant="drawer" onClose={() => setOpen(false)} />
|
||||||
sx={{
|
|
||||||
p: 3,
|
|
||||||
display: "flex",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
alignItems: "center",
|
|
||||||
position: "sticky",
|
|
||||||
top: 0,
|
|
||||||
zIndex: 20,
|
|
||||||
borderBottom: "1px solid",
|
|
||||||
borderColor: "rgba(255, 255, 255, 0.08)",
|
|
||||||
backgroundColor: "rgba(20, 20, 30, 0.4)",
|
|
||||||
backdropFilter: "blur(12px)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="h5"
|
|
||||||
sx={{
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Play Queue
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="caption"
|
|
||||||
sx={{
|
|
||||||
color: "text.secondary",
|
|
||||||
ml: 1,
|
|
||||||
fontWeight: 600,
|
|
||||||
bgcolor: "rgba(255, 255, 255, 0.08)",
|
|
||||||
px: 1,
|
|
||||||
py: 0.5,
|
|
||||||
borderRadius: 2,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{queueItems?.length || 0}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
gap: 0.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Tooltip title="Shuffle Upcoming">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
onClick={handleShuffle}
|
|
||||||
size="small"
|
|
||||||
disabled={upcomingItems.length < 2}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">shuffle</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Clear Upcoming">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
onClick={handleClear}
|
|
||||||
size="small"
|
|
||||||
disabled={upcomingItems.length === 0}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">clear_all</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
<IconButton onClick={() => setOpen(false)} size="small">
|
|
||||||
<span className="material-symbols-rounded">close</span>
|
|
||||||
</IconButton>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
overflowY: "auto",
|
|
||||||
flex: 1,
|
|
||||||
p: 2,
|
|
||||||
"&::-webkit-scrollbar": { width: 8 },
|
|
||||||
"&::-webkit-scrollbar-track": { background: "transparent" },
|
|
||||||
"&::-webkit-scrollbar-thumb": {
|
|
||||||
background: "rgba(128,128,128,0.2)",
|
|
||||||
borderRadius: 4,
|
|
||||||
},
|
|
||||||
"&::-webkit-scrollbar-thumb:hover": {
|
|
||||||
background: "rgba(128,128,128,0.3)",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{queueItems && queueItems.length > 0 ? (
|
|
||||||
<List disablePadding>
|
|
||||||
{/* Current Item */}
|
|
||||||
{queueItems[currentItemIndex] && (
|
|
||||||
<Box sx={{ mb: 4 }}>
|
|
||||||
<Typography
|
|
||||||
variant="overline"
|
|
||||||
sx={{
|
|
||||||
display: "block",
|
|
||||||
opacity: 0.6,
|
|
||||||
mb: 1,
|
|
||||||
fontWeight: 600,
|
|
||||||
letterSpacing: 1.2,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
NOW PLAYING
|
|
||||||
</Typography>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
bgcolor: "background.paper",
|
|
||||||
borderRadius: 3,
|
|
||||||
overflow: "hidden",
|
|
||||||
boxShadow: 4,
|
|
||||||
border: "1px solid",
|
|
||||||
borderColor: "divider",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<QueueListItem
|
|
||||||
queueItem={queueItems[currentItemIndex]}
|
|
||||||
active={true}
|
|
||||||
isEpisode={
|
|
||||||
queueItems[currentItemIndex].Type === "Episode"
|
|
||||||
}
|
|
||||||
index={currentItemIndex + 1}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Upcoming Items */}
|
|
||||||
{upcomingItems.length > 0 && (
|
|
||||||
<>
|
|
||||||
<Typography
|
|
||||||
variant="overline"
|
|
||||||
sx={{
|
|
||||||
display: "block",
|
|
||||||
opacity: 0.6,
|
|
||||||
mb: 1,
|
|
||||||
fontWeight: 600,
|
|
||||||
letterSpacing: 1.2,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
NEXT UP
|
|
||||||
</Typography>
|
|
||||||
<DndContext
|
|
||||||
sensors={sensors}
|
|
||||||
collisionDetection={closestCenter}
|
|
||||||
onDragEnd={handleDragEnd}
|
|
||||||
modifiers={[restrictToVerticalAxis]}
|
|
||||||
>
|
|
||||||
<SortableContext
|
|
||||||
items={upcomingIds}
|
|
||||||
strategy={verticalListSortingStrategy}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
gap: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{upcomingItems.map((item, index) => (
|
|
||||||
<SortableQueueItem
|
|
||||||
key={item.Id || index}
|
|
||||||
item={item}
|
|
||||||
onDelete={() =>
|
|
||||||
handleDelete(currentItemIndex + 1 + index)
|
|
||||||
}
|
|
||||||
onPlay={() =>
|
|
||||||
handlePlay(currentItemIndex + 1 + index)
|
|
||||||
}
|
|
||||||
index={currentItemIndex + 1 + index + 1}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
</SortableContext>
|
|
||||||
</DndContext>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</List>
|
|
||||||
) : (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
p: 4,
|
|
||||||
textAlign: "center",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 2,
|
|
||||||
opacity: 0.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded"
|
|
||||||
style={{ fontSize: 48 }}
|
|
||||||
>
|
|
||||||
queue_music
|
|
||||||
</span>
|
|
||||||
<Typography>Your queue is empty</Typography>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
</Drawer>
|
</Drawer>
|
||||||
<IconButton onClick={() => setOpen(true)}>
|
|
||||||
<span className="material-symbols-rounded">playlist_play</span>
|
|
||||||
</IconButton>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import type { TransitionProps } from "@mui/material/transitions";
|
import type { TransitionProps } from "@mui/material/transitions";
|
||||||
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate, useRouter } from "@tanstack/react-router";
|
||||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import React, { useCallback, useState } from "react";
|
import React, { useCallback, useState } from "react";
|
||||||
|
import QRCodeImage from "@/components/qrCode";
|
||||||
|
import { buildQuickConnectDeepLink } from "@/utils/deepLinks";
|
||||||
import useInterval from "@/utils/hooks/useInterval";
|
import useInterval from "@/utils/hooks/useInterval";
|
||||||
import { saveUser } from "@/utils/storage/user";
|
import { saveUser } from "@/utils/storage/user";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
@@ -55,6 +57,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const quickConnectEnabled = useQuery({
|
const quickConnectEnabled = useQuery({
|
||||||
queryKey: ["quick-connect-button", "check-quick-connect-enabled"],
|
queryKey: ["quick-connect-button", "check-quick-connect-enabled"],
|
||||||
@@ -79,22 +82,24 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSuccess: (result) => {
|
onSuccess: async (result) => {
|
||||||
if (api && result?.data?.AccessToken && result.data.User?.Name) {
|
const { AccessToken, User } = result?.data ?? {};
|
||||||
|
if (api && AccessToken && User?.Name && User.Id) {
|
||||||
setCheckForQuickConnect(false);
|
setCheckForQuickConnect(false);
|
||||||
// saveUser({ username, password, rememberMe: rememberUser });
|
enqueueSnackbar(`Вы вошли как ${User.Name}!`, {
|
||||||
enqueueSnackbar(`Logged in as ${result.data.User?.Name}!`, {
|
|
||||||
variant: "success",
|
variant: "success",
|
||||||
});
|
});
|
||||||
createApi(api.basePath, result.data.AccessToken);
|
createApi(api.basePath, AccessToken);
|
||||||
if (rememberUser) {
|
if (rememberUser) {
|
||||||
saveUser(result.data.User?.Name, result.data.AccessToken);
|
await saveUser(User.Name, AccessToken, User.Id);
|
||||||
}
|
}
|
||||||
navigate({ to: "/home", replace: true });
|
router.invalidate().finally(() => {
|
||||||
|
navigate({ to: "/home", replace: true });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Error authenticating user.", { variant: "error" });
|
enqueueSnackbar("Не удалось войти.", { variant: "error" });
|
||||||
console.error(error);
|
console.error(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -121,7 +126,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
mutationKey: ["quick-connect-button", "initiate-connection"],
|
mutationKey: ["quick-connect-button", "initiate-connection"],
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (!quickConnectEnabled.data?.data) {
|
if (!quickConnectEnabled.data?.data) {
|
||||||
enqueueSnackbar("Quick Connect is not enabled on server.", {
|
enqueueSnackbar("Quick Connect не включён на сервере.", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -137,7 +142,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
setCheckForQuickConnect(true);
|
setCheckForQuickConnect(true);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Error initiating Quick Connect.", { variant: "error" });
|
enqueueSnackbar("Не удалось запустить Quick Connect.", { variant: "error" });
|
||||||
console.error(error);
|
console.error(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -176,9 +181,16 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
variant={props.variant ?? "contained"}
|
variant={props.variant ?? "contained"}
|
||||||
onClick={() => initQuickConnect.mutate()}
|
onClick={() => initQuickConnect.mutate()}
|
||||||
>
|
>
|
||||||
{quickConnectEnabled.data?.data
|
<span className="qc-label-full">
|
||||||
? "Use Quick Connect"
|
{quickConnectEnabled.data?.data
|
||||||
: "Quick Connect Disabled"}
|
? "Войти через Quick Connect"
|
||||||
|
: "Quick Connect недоступен"}
|
||||||
|
</span>
|
||||||
|
<span className="qc-label-short">
|
||||||
|
{quickConnectEnabled.data?.data
|
||||||
|
? "Quick Connect"
|
||||||
|
: "QC недоступен"}
|
||||||
|
</span>
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={Boolean(quickConnectCode)}
|
open={Boolean(quickConnectCode)}
|
||||||
@@ -208,22 +220,22 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
mb: 2,
|
mb: 2,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Quick Connect Code:
|
Код Quick Connect:
|
||||||
</Typography>
|
</Typography>
|
||||||
<DialogContentText>
|
<DialogContentText>
|
||||||
Use this code in the Quick Connect tab in your server to login.
|
Введите этот код в разделе Quick Connect на сервере, чтобы войти.
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
<div
|
<div
|
||||||
className="flex flex-row"
|
className="flex flex-row"
|
||||||
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
||||||
>
|
>
|
||||||
<Tooltip title="Click to copy" arrow placement="top">
|
<Tooltip title="Нажмите, чтобы скопировать" arrow placement="top">
|
||||||
<Typography
|
<Typography
|
||||||
variant="h3"
|
variant="h3"
|
||||||
color="textPrimary"
|
color="textPrimary"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
quickConnectCode && (await writeText(quickConnectCode));
|
quickConnectCode && (await writeText(quickConnectCode));
|
||||||
enqueueSnackbar("Quick Connect Code copied!", {
|
enqueueSnackbar("Код Quick Connect скопирован!", {
|
||||||
variant: "info",
|
variant: "info",
|
||||||
key: "copiedText",
|
key: "copiedText",
|
||||||
});
|
});
|
||||||
@@ -241,6 +253,22 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
{quickConnectCode && (
|
||||||
|
<>
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{ mt: 2, opacity: 0.75, textAlign: "center" }}
|
||||||
|
>
|
||||||
|
Или отсканируйте код в Blink на телефоне, чтобы подтвердить вход.
|
||||||
|
</Typography>
|
||||||
|
<div style={{ marginTop: "1em", background: "#08001f", borderRadius: 12, padding: 8 }}>
|
||||||
|
<QRCodeImage
|
||||||
|
value={buildQuickConnectDeepLink(quickConnectCode)}
|
||||||
|
size={180}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions
|
<DialogActions
|
||||||
className="flex flex-row"
|
className="flex flex-row"
|
||||||
@@ -256,10 +284,10 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
onChange={(e) => setRememberUser(e.target.checked)}
|
onChange={(e) => setRememberUser(e.target.checked)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label="Remember device"
|
label="Запомнить устройство"
|
||||||
/>
|
/>
|
||||||
<Button variant="contained" onClick={handleQuickConnectClose}>
|
<Button variant="contained" onClick={handleQuickConnectClose}>
|
||||||
Close
|
Закрыть
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { getCachedImageUrl } from "@/utils/cache/imageCache";
|
||||||
|
|
||||||
|
type CachedImageProps = React.ImgHTMLAttributes<HTMLImageElement> & {
|
||||||
|
src?: string | null;
|
||||||
|
fallback?: React.ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop-in `<img>` that resolves Jellyfin artwork through the persistent
|
||||||
|
* Cache API. If the request cannot be read (CORS/offline), it falls back to
|
||||||
|
* the original URL so the browser can still render it.
|
||||||
|
*/
|
||||||
|
const CachedImage = ({
|
||||||
|
src,
|
||||||
|
fallback = null,
|
||||||
|
onError,
|
||||||
|
...props
|
||||||
|
}: CachedImageProps) => {
|
||||||
|
const [cachedSrc, setCachedSrc] = useState<string | null>(null);
|
||||||
|
const [failed, setFailed] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let active = true;
|
||||||
|
setCachedSrc(null);
|
||||||
|
setFailed(false);
|
||||||
|
if (!src) return;
|
||||||
|
void getCachedImageUrl(src).then((url) => {
|
||||||
|
if (active && url) setCachedSrc(url);
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
active = false;
|
||||||
|
};
|
||||||
|
}, [src]);
|
||||||
|
|
||||||
|
if (!src || failed) return <>{fallback}</>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
{...props}
|
||||||
|
src={cachedSrc ?? src}
|
||||||
|
onError={(event) => {
|
||||||
|
setFailed(true);
|
||||||
|
onError?.(event);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CachedImage;
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
transition: all $transition-time-fast;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import {
|
|||||||
type ImageType,
|
type ImageType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import React, { memo, type Ref, useCallback, useState } from "react";
|
import React, { memo, type Ref, useCallback } from "react";
|
||||||
import { ErrorBoundary } from "react-error-boundary";
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
import { useInView } from "react-intersection-observer";
|
import { useInView } from "react-intersection-observer";
|
||||||
|
import CachedImage from "@/components/cachedImage";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { resolveItemImage } from "@/utils/methods/itemImages";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
@@ -56,6 +58,18 @@ const CardContent = ({
|
|||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const image = resolveItemImage(item, imageType, {
|
||||||
|
seriesId: seriesId ? (item.SeriesId ?? undefined) : undefined,
|
||||||
|
});
|
||||||
|
const isMusic =
|
||||||
|
item.Type === BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type === BaseItemKind.Audio ||
|
||||||
|
item.Type === BaseItemKind.AudioBook ||
|
||||||
|
item.Type === BaseItemKind.Playlist;
|
||||||
|
// Jellyfin generates a generic placeholder when a music item has no cover;
|
||||||
|
// prefer our own themed fallback in that case.
|
||||||
|
const hasCover = !isMusic || Boolean(image?.tag);
|
||||||
|
|
||||||
const defaultOnClick = useCallback(() => {
|
const defaultOnClick = useCallback(() => {
|
||||||
if (item?.Id) {
|
if (item?.Id) {
|
||||||
navigate(getItemLinkOptions(item.Id, item?.Type));
|
navigate(getItemLinkOptions(item.Id, item?.Type));
|
||||||
@@ -67,6 +81,15 @@ const CardContent = ({
|
|||||||
className="card"
|
className="card"
|
||||||
ref={forwardedRef}
|
ref={forwardedRef}
|
||||||
onClick={onClick || defaultOnClick}
|
onClick={onClick || defaultOnClick}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === "Enter" || event.key === " ") {
|
||||||
|
event.preventDefault();
|
||||||
|
(onClick || defaultOnClick)();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={cardTitle ?? item.Name ?? "Элемент"}
|
||||||
>
|
>
|
||||||
<div className={`card-image-container ${cardType}`}>
|
<div className={`card-image-container ${cardType}`}>
|
||||||
<ErrorBoundary fallback={<></>}>
|
<ErrorBoundary fallback={<></>}>
|
||||||
@@ -102,20 +125,21 @@ const CardContent = ({
|
|||||||
? getTypeIcon(overrideIcon)
|
? getTypeIcon(overrideIcon)
|
||||||
: getTypeIcon(item.Type ?? "universal")}
|
: getTypeIcon(item.Type ?? "universal")}
|
||||||
</div>
|
</div>
|
||||||
{inView && (
|
{image && hasCover && (
|
||||||
<img
|
<CachedImage
|
||||||
alt={item.Name ?? "blink"}
|
alt={item.Name ?? "blink"}
|
||||||
|
decoding="async"
|
||||||
src={
|
src={
|
||||||
api
|
api && image
|
||||||
? overrideIcon === "User"
|
? overrideIcon === "User"
|
||||||
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
|
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
|
||||||
: getImageUrlsApi(api).getItemImageUrlById(
|
: getImageUrlsApi(api).getItemImageUrlById(
|
||||||
(seriesId ? item.SeriesId : (item.AlbumId ?? item.Id)) ??
|
image.itemId,
|
||||||
"",
|
image.imageType,
|
||||||
imageType,
|
|
||||||
{
|
{
|
||||||
quality: 90,
|
quality: 90,
|
||||||
fillWidth: cardType === "thumb" ? 560 : 320,
|
fillWidth: cardType === "thumb" ? 560 : 320,
|
||||||
|
tag: image.tag,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: ""
|
: ""
|
||||||
@@ -123,19 +147,14 @@ const CardContent = ({
|
|||||||
style={{
|
style={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
opacity: 0,
|
|
||||||
display: "block",
|
display: "block",
|
||||||
transition: "opacity 0.3s ease-in-out",
|
|
||||||
}}
|
}}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
onLoad={(e) => {
|
|
||||||
e.currentTarget.style.opacity = "1";
|
|
||||||
}}
|
|
||||||
className="card-image"
|
className="card-image"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{inView && !disableOverlay && (
|
{inView && !disableOverlay && (
|
||||||
<div className="card-overlay">
|
<div className="card-overlay" data-tv-ignore>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item}
|
item={item}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
@@ -188,6 +207,7 @@ const CardContent = ({
|
|||||||
opacity: 0.9,
|
opacity: 0.9,
|
||||||
fontSize: "0.875rem",
|
fontSize: "0.875rem",
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
|
lineHeight: 1.3,
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
@@ -199,6 +219,7 @@ const CardContent = ({
|
|||||||
style={{
|
style={{
|
||||||
opacity: 0.6,
|
opacity: 0.6,
|
||||||
fontSize: "0.75rem",
|
fontSize: "0.75rem",
|
||||||
|
lineHeight: 1.3,
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
|
|||||||
@@ -99,21 +99,21 @@ export default function CardScroller({
|
|||||||
},
|
},
|
||||||
tablet: {
|
tablet: {
|
||||||
breakpoint: { max: 925, min: 600 },
|
breakpoint: { max: 925, min: 600 },
|
||||||
items: displayCards - 3,
|
items: Math.max(2, displayCards - 2),
|
||||||
slidesToSlide: displayCards - 3,
|
slidesToSlide: Math.max(2, displayCards - 2),
|
||||||
partialVisibilityGutter: 20,
|
partialVisibilityGutter: 20,
|
||||||
},
|
},
|
||||||
mobile: {
|
mobile: {
|
||||||
breakpoint: { max: 600, min: 424 },
|
breakpoint: { max: 600, min: 424 },
|
||||||
items: displayCards - 5,
|
items: Math.max(1, displayCards - 4),
|
||||||
slidesToSlide: displayCards - 5,
|
slidesToSlide: Math.max(1, displayCards - 4),
|
||||||
partialVisibilityGutter: 10,
|
partialVisibilityGutter: 10,
|
||||||
},
|
},
|
||||||
smallScreen: {
|
smallScreen: {
|
||||||
breakpoint: { max: 424, min: 0 },
|
breakpoint: { max: 424, min: 0 },
|
||||||
items: 1,
|
items: 2,
|
||||||
slidesToSlide: 1,
|
slidesToSlide: 2,
|
||||||
partialVisibilityGutter: 10,
|
partialVisibilityGutter: 12,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,187 +1,513 @@
|
|||||||
.carousel {
|
@use "@/styles/variables.scss" as *;
|
||||||
position: relative;
|
|
||||||
overflow: visible;
|
|
||||||
height: 65vh;
|
|
||||||
margin-bottom: 3em;
|
|
||||||
display: grid;
|
|
||||||
grid-template-areas: "main sidebar";
|
|
||||||
grid-template-columns: 1fr 340px;
|
|
||||||
gap: 1.5em;
|
|
||||||
|
|
||||||
&-sidebar {
|
/* Cinematic home hero: full-bleed artwork, integrated type, bottom rail. */
|
||||||
overflow-y: auto;
|
.cinema-hero {
|
||||||
|
position: relative;
|
||||||
|
height: calc(100vh - 16px);
|
||||||
|
min-height: 620px;
|
||||||
|
overflow: hidden;
|
||||||
|
isolation: isolate;
|
||||||
|
|
||||||
|
.hero-carousel-slide {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-background-container {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 0;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 2;
|
||||||
|
background:
|
||||||
|
linear-gradient(
|
||||||
|
90deg,
|
||||||
|
rgb(6 8 12 / 0.94) 0%,
|
||||||
|
rgb(6 8 12 / 0.72) 28%,
|
||||||
|
rgb(6 8 12 / 0.28) 52%,
|
||||||
|
rgb(6 8 12 / 0) 72%
|
||||||
|
),
|
||||||
|
linear-gradient(
|
||||||
|
0deg,
|
||||||
|
rgb(6 8 12 / 0.96) 0%,
|
||||||
|
rgb(6 8 12 / 0.55) 26%,
|
||||||
|
rgb(6 8 12 / 0) 56%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-background-image {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: relative;
|
object-fit: cover;
|
||||||
@include glass-effect($bg-color: rgba(10, 10, 14, 0.4));
|
object-position: center;
|
||||||
border-radius: 24px;
|
|
||||||
grid-area: sidebar;
|
&.is-poster {
|
||||||
|
filter: blur(42px) saturate(1.5) brightness(0.55);
|
||||||
|
transform: scale(1.25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-background-blurhash {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
z-index: 0;
|
||||||
|
filter: blur(40px) saturate(1.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-background-icon-container {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 0;
|
||||||
|
background: linear-gradient(135deg, #12141a, #1d2028);
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
font-size: 15em !important;
|
||||||
|
opacity: 0.35;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-detail {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 3;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 12px;
|
justify-content: flex-end;
|
||||||
gap: 8px;
|
align-items: flex-start;
|
||||||
|
gap: 0.9rem;
|
||||||
// Ensure programmatic scroll respects padding
|
max-width: none;
|
||||||
scroll-padding-block: 24px;
|
padding: 0 clamp(2rem, 5vw, 4.5rem) calc(var(--home-trending-space, 200px) + 4rem);
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-label {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 16px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgb(255 255 255 / 0.16);
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.18);
|
||||||
|
backdrop-filter: blur(14px);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 0.86rem;
|
||||||
|
font-weight: 500;
|
||||||
|
letter-spacing: 0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-text {
|
||||||
|
display: block;
|
||||||
|
overflow: visible;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 16ch;
|
||||||
|
font-size: clamp(2.4rem, 4.1vw, 4.4rem) !important;
|
||||||
|
line-height: 0.98 !important;
|
||||||
|
font-weight: 650 !important;
|
||||||
|
letter-spacing: -0.035em;
|
||||||
|
text-shadow: 0 2px 30px rgb(0 0 0 / 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-info {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.9em !important;
|
||||||
|
margin-top: 0.1em !important;
|
||||||
|
color: rgb(255 255 255 / 0.78);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
|
||||||
|
|
||||||
|
.MuiTypography-root {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiChip-root {
|
||||||
|
height: 24px;
|
||||||
|
background: rgb(255 255 255 / 0.14);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-info-rating {
|
||||||
|
gap: 0.2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-overview {
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 4;
|
||||||
|
overflow: hidden;
|
||||||
|
max-width: 34rem;
|
||||||
|
margin: 0.15rem 0 0;
|
||||||
|
color: rgb(255 255 255 / 0.82);
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: 1.55;
|
||||||
|
text-shadow: 0 1px 3px rgb(0 0 0 / 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-button-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.85rem;
|
||||||
|
width: auto;
|
||||||
|
margin-top: 0.6rem;
|
||||||
|
|
||||||
|
.MuiButton-root {
|
||||||
|
min-height: 50px;
|
||||||
|
padding: 0 24px;
|
||||||
|
border-radius: 999px;
|
||||||
|
text-transform: none;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.play-button .MuiButton-root,
|
||||||
|
.MuiButton-contained {
|
||||||
|
background: #f5f5f4;
|
||||||
|
color: #101116;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
color: #101116;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiButton-outlined {
|
||||||
|
border-color: rgb(255 255 255 / 0.34);
|
||||||
|
color: #fff;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
border-color: rgb(255 255 255 / 0.6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
color: rgb(255 255 255 / 0.75);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Big cinematic arrows */
|
||||||
|
.cinema-arrow {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
z-index: 7;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.18);
|
||||||
|
background: rgb(14 16 21 / 0.36);
|
||||||
|
backdrop-filter: blur(14px);
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
opacity: 0;
|
||||||
|
transition:
|
||||||
|
opacity 0.2s ease,
|
||||||
|
background-color 0.2s ease,
|
||||||
|
color 0.2s ease;
|
||||||
|
|
||||||
|
&.right {
|
||||||
|
right: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #f5f5f4;
|
||||||
|
color: #101116;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover .cinema-arrow,
|
||||||
|
&.paused .cinema-arrow {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bottom rail */
|
||||||
|
.cinema-trending {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 6;
|
||||||
|
padding: 2rem clamp(2rem, 5vw, 4.5rem) 1.5rem;
|
||||||
|
background: linear-gradient(
|
||||||
|
0deg,
|
||||||
|
rgb(7 8 12 / 0.98) 0%,
|
||||||
|
rgb(7 8 12 / 0.9) 46%,
|
||||||
|
rgb(7 8 12 / 0) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
margin-bottom: 0.9rem;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-dots {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 26px;
|
||||||
|
height: 3px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgb(255 255 255 / 0.3);
|
||||||
|
cursor: pointer;
|
||||||
|
transition:
|
||||||
|
background-color 0.2s ease,
|
||||||
|
width 0.2s ease;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
width: 38px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-rail {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
|
||||||
// Hide scrollbar but keep functionality
|
|
||||||
scrollbar-width: none;
|
|
||||||
-ms-overflow-style: none;
|
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-button {
|
.cinema-trending-card {
|
||||||
position: absolute !important;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
z-index: 100;
|
|
||||||
|
|
||||||
&.right {
|
|
||||||
right: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.left {
|
|
||||||
left: 0.5em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-ticker{
|
|
||||||
overflow: hidden;
|
|
||||||
height: 72px;
|
|
||||||
display: flex;
|
|
||||||
padding: 8px;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
||||||
position: relative;
|
position: relative;
|
||||||
border-radius: 12px; // Slightly smaller radius to work with the bar
|
flex: 0 0 auto;
|
||||||
background: transparent;
|
width: clamp(200px, 21vw, 300px);
|
||||||
border: 1px solid transparent;
|
aspect-ratio: 16 / 9;
|
||||||
|
padding: 0;
|
||||||
&:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
background: rgba(255, 255, 255, 0.08); // Subtle background
|
|
||||||
|
|
||||||
// Vertical Progress Bar
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 4px;
|
|
||||||
background-color: var(--mui-palette-primary-main, #fff);
|
|
||||||
height: 0%;
|
|
||||||
animation: ticker-v-progress 8s linear;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-image {
|
|
||||||
height: 56px;
|
|
||||||
width: 100px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
border-radius: 8px;
|
|
||||||
object-fit: cover;
|
|
||||||
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
|
||||||
|
|
||||||
&.placeholder {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: rgb(100 100 100 / 0.1);
|
|
||||||
color: rgb(200 200 200 / 0.7);
|
|
||||||
font-size: 2rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
& > div {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
min-width: 0; // flexible text truncation
|
|
||||||
padding-left: 4px; // compensate for visual weight of potential bar
|
|
||||||
|
|
||||||
.carousel-ticker-title {
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
font-weight: 500; // Slightly lighter
|
|
||||||
font-size: 0.95rem;
|
|
||||||
line-height: 1.2;
|
|
||||||
margin-bottom: 2px;
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
.carousel-ticker-year {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause progress when carousel is paused
|
|
||||||
&.paused {
|
|
||||||
.carousel-ticker.active::after {
|
|
||||||
animation-play-state: paused;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes ticker-v-progress {
|
|
||||||
from { height: 0%; }
|
|
||||||
to { height: 100%; }
|
|
||||||
}
|
|
||||||
|
|
||||||
&-indicator {
|
|
||||||
aspect-ratio: 1.77777;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: 2px;
|
border: 1px solid rgb(255 255 255 / 0.12);
|
||||||
padding: 2px;
|
border-radius: 12px;
|
||||||
transition: opacity $transition-time-fast;
|
background: rgb(255 255 255 / 0.05);
|
||||||
opacity: 0.5;
|
cursor: pointer;
|
||||||
width: auto;
|
opacity: 0.72;
|
||||||
&:hover {
|
transition:
|
||||||
cursor: pointer;
|
opacity 0.2s ease,
|
||||||
opacity: 0.8;
|
border-color 0.2s ease,
|
||||||
}
|
transform 0.2s ease;
|
||||||
|
|
||||||
&-container {
|
img {
|
||||||
display: flex;
|
|
||||||
gap: 1em;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
&-image {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
border-radius: 4px;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-icon {
|
&::after {
|
||||||
display: flex;
|
content: "";
|
||||||
align-items: center;
|
position: absolute;
|
||||||
justify-content: center;
|
inset: 0;
|
||||||
width: 100%;
|
background: linear-gradient(0deg, rgb(0 0 0 / 0.35), transparent 55%);
|
||||||
height: 100%;
|
|
||||||
background: rgb(155 155 155 / 0.4);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
border-color: rgb(255 255 255 / 0.4);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
border-color: rgb(255 255 255 / 0.7);
|
||||||
.material-symbols-rounded {
|
box-shadow: 0 0 0 1px rgb(255 255 255 / 0.25);
|
||||||
|
}
|
||||||
--fill: 1;
|
}
|
||||||
}
|
|
||||||
|
.cinema-trending-chip {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
left: 10px;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 3px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgb(245 245 244 / 0.9);
|
||||||
|
color: #131419;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-placeholder {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
color: rgb(255 255 255 / 0.5);
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.carousel-ticker-wrapper {
|
|
||||||
scroll-margin-block: 24px;
|
/* Reserve room for the floating player bar so the rail is never covered. */
|
||||||
|
body.has-player-bar .cinema-trending {
|
||||||
|
padding-bottom: 116px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* With the player bar visible the hero has less vertical room, so keep the
|
||||||
|
copy compact instead of pushing it under the header. */
|
||||||
|
body.has-player-bar .cinema-hero .hero-carousel-text {
|
||||||
|
font-size: clamp(2.1rem, 3.6vw, 4rem) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.has-player-bar .cinema-hero .hero-carousel-overview {
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1100px) {
|
||||||
|
.cinema-hero {
|
||||||
|
height: calc(100vh - 16px);
|
||||||
|
min-height: 560px;
|
||||||
|
|
||||||
|
.hero-carousel-detail {
|
||||||
|
padding-left: 2rem;
|
||||||
|
padding-right: 2rem;
|
||||||
|
padding-bottom: calc(var(--home-trending-space, 200px) + 1.5rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-text {
|
||||||
|
font-size: 2.6rem !important;
|
||||||
|
max-width: 14ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-overview {
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
max-width: 30rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending {
|
||||||
|
padding-left: 2rem;
|
||||||
|
padding-right: 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Short windows (and the player bar) leave little vertical room: drop the
|
||||||
|
secondary copy instead of pushing the headline under the header. */
|
||||||
|
@media (max-height: 760px) {
|
||||||
|
.cinema-hero {
|
||||||
|
height: calc(100vh - 16px);
|
||||||
|
min-height: 540px;
|
||||||
|
|
||||||
|
.hero-carousel-detail {
|
||||||
|
gap: 0.65rem;
|
||||||
|
padding-bottom: calc(var(--home-trending-space, 200px) + 1rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-overview,
|
||||||
|
.hero-carousel-info {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-text {
|
||||||
|
max-width: 18ch;
|
||||||
|
font-size: clamp(2rem, 3.2vw, 3rem) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending {
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-head {
|
||||||
|
margin-bottom: 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-card {
|
||||||
|
width: clamp(150px, 15vw, 220px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
.cinema-hero {
|
||||||
|
min-height: 520px;
|
||||||
|
|
||||||
|
.hero-carousel-text {
|
||||||
|
font-size: 2.1rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-info {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-carousel-overview {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-arrow {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-head .cinema-dots {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cinema-trending-card {
|
||||||
|
width: 160px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,45 @@
|
|||||||
import { AnimatePresence } from "motion/react";
|
|
||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import { useCarouselStore } from "../../utils/store/carousel";
|
|
||||||
import "./carousel.scss";
|
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useCarouselStore } from "../../utils/store/carousel";
|
||||||
|
import "./carousel.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { resolveItemImage } from "@/utils/methods/itemImages";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import CarouselSlide from "../carouselSlide";
|
import CarouselSlide from "../carouselSlide";
|
||||||
import CarouselTickers from "./tickers";
|
|
||||||
|
const AUTOPLAY_MS = 9000;
|
||||||
|
|
||||||
// Memoize CarouselSlide to prevent unnecessary re-renders
|
// Memoize CarouselSlide to prevent unnecessary re-renders
|
||||||
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
||||||
|
|
||||||
|
/** Wide artwork for the trending rail, falling back through the item's images. */
|
||||||
|
const trendingImageUrl = (
|
||||||
|
api: Api,
|
||||||
|
item: BaseItemDto,
|
||||||
|
): string | undefined => {
|
||||||
|
const image = resolveItemImage(item, "Thumb");
|
||||||
|
if (!image) return undefined;
|
||||||
|
return getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
image.itemId,
|
||||||
|
image.imageType,
|
||||||
|
{
|
||||||
|
quality: 85,
|
||||||
|
fillWidth: 480,
|
||||||
|
tag: image.tag,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const trendingLabel = (item: BaseItemDto): string => {
|
||||||
|
const genre = item.Genres?.[0];
|
||||||
|
if (genre) return genre.charAt(0).toUpperCase() + genre.slice(1);
|
||||||
|
return item.Type === BaseItemKind.Series ? "Сериал" : "Фильм";
|
||||||
|
};
|
||||||
|
|
||||||
const Carousel = ({
|
const Carousel = ({
|
||||||
content,
|
content,
|
||||||
onChange,
|
onChange,
|
||||||
@@ -24,121 +49,125 @@ const Carousel = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [currentSlide, setCurrentSlide] = useState(0);
|
const [currentSlide, setCurrentSlide] = useState(0);
|
||||||
const [isPaused, setIsPaused] = useState(false);
|
const [isPaused, setIsPaused] = useState(false);
|
||||||
const sidebarRef = React.useRef<HTMLDivElement>(null);
|
|
||||||
const tickerRefs = React.useRef<(HTMLDivElement | null)[]>([]);
|
|
||||||
const currentSlideRef = React.useRef(currentSlide);
|
|
||||||
|
|
||||||
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const total = content.length;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
currentSlideRef.current = currentSlide;
|
if (currentSlide >= total && total > 0) {
|
||||||
}, [currentSlide]);
|
setCurrentSlide(total - 1);
|
||||||
|
}
|
||||||
|
}, [currentSlide, total]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onChange(currentSlide);
|
onChange(currentSlide);
|
||||||
|
}, [currentSlide, onChange]);
|
||||||
|
|
||||||
// Auto-scroll sidebar to keep active item in view
|
const goTo = useCallback(
|
||||||
const activeTicker = tickerRefs.current[currentSlide];
|
|
||||||
const sidebar = sidebarRef.current;
|
|
||||||
|
|
||||||
if (activeTicker && sidebar) {
|
|
||||||
const sidebarTop = sidebar.scrollTop;
|
|
||||||
const sidebarBottom = sidebarTop + sidebar.clientHeight;
|
|
||||||
const activeTickerTop = activeTicker.offsetTop;
|
|
||||||
const activeTickerBottom =
|
|
||||||
activeTicker.offsetTop + activeTicker.offsetHeight;
|
|
||||||
|
|
||||||
// If element is below the visible area
|
|
||||||
if (activeTickerBottom > sidebarBottom) {
|
|
||||||
sidebar.scrollTo({
|
|
||||||
top: activeTickerBottom - sidebar.clientHeight + 24, // 24px padding
|
|
||||||
behavior: "smooth",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// If element is above the visible area
|
|
||||||
else if (activeTickerTop < sidebarTop) {
|
|
||||||
sidebar.scrollTo({
|
|
||||||
top: activeTickerTop - 24, // 24px padding
|
|
||||||
behavior: "smooth",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [currentSlide, content, onChange]);
|
|
||||||
|
|
||||||
// Autoplay functionality
|
|
||||||
useEffect(() => {
|
|
||||||
if (isPaused || content.length === 0) return;
|
|
||||||
|
|
||||||
const timer = setInterval(() => {
|
|
||||||
setDirection("right");
|
|
||||||
setCurrentSlide((prev) => (prev + 1) % content.length);
|
|
||||||
}, 8000);
|
|
||||||
|
|
||||||
return () => clearInterval(timer);
|
|
||||||
}, [isPaused, content.length, setDirection, currentSlide]);
|
|
||||||
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const handleTickerClick = useCallback(
|
|
||||||
(index: number) => {
|
(index: number) => {
|
||||||
if (index === currentSlideRef.current) return;
|
if (index === currentSlide) return;
|
||||||
setDirection(index > currentSlideRef.current ? "right" : "left");
|
setDirection(index > currentSlide ? "right" : "left");
|
||||||
setCurrentSlide(index);
|
setCurrentSlide(index);
|
||||||
},
|
},
|
||||||
[setDirection],
|
[currentSlide, setDirection],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!api) return null;
|
const next = useCallback(() => {
|
||||||
|
if (total < 2) return;
|
||||||
|
setDirection("right");
|
||||||
|
setCurrentSlide((prev) => (prev + 1) % total);
|
||||||
|
}, [total, setDirection]);
|
||||||
|
|
||||||
|
// Autoplay; pauses while the pointer is over the hero.
|
||||||
|
useEffect(() => {
|
||||||
|
if (isPaused || total < 2) return;
|
||||||
|
const timer = window.setInterval(() => {
|
||||||
|
setDirection("right");
|
||||||
|
setCurrentSlide((prev) => (prev + 1) % total);
|
||||||
|
}, AUTOPLAY_MS);
|
||||||
|
return () => window.clearInterval(timer);
|
||||||
|
}, [isPaused, total, setDirection]);
|
||||||
|
|
||||||
|
if (!api || total === 0) return null;
|
||||||
|
|
||||||
|
const currentItem = content[currentSlide];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<section
|
||||||
className={`carousel ${isPaused ? "paused" : ""}`}
|
className={`cinema-hero ${isPaused ? "paused" : ""}`}
|
||||||
|
aria-roledescription="carousel"
|
||||||
|
aria-label="Рекомендуемое"
|
||||||
onMouseEnter={() => setIsPaused(true)}
|
onMouseEnter={() => setIsPaused(true)}
|
||||||
onMouseLeave={() => setIsPaused(false)}
|
onMouseLeave={() => setIsPaused(false)}
|
||||||
>
|
>
|
||||||
<AnimatePresence mode="sync">
|
<MemoizedCarouselSlide key={currentItem.Id} item={currentItem} />
|
||||||
<MemoizedCarouselSlide
|
|
||||||
item={content[currentSlide]}
|
{total > 1 && (
|
||||||
key={content[currentSlide].Id}
|
<button
|
||||||
/>
|
type="button"
|
||||||
</AnimatePresence>
|
className="cinema-arrow right"
|
||||||
<div className="carousel-sidebar" ref={sidebarRef}>
|
onClick={next}
|
||||||
{content.map((item, index) => (
|
aria-label="Далее"
|
||||||
<div
|
>
|
||||||
key={item.Id}
|
<span className="material-symbols-rounded">chevron_right</span>
|
||||||
ref={(el) => {
|
</button>
|
||||||
tickerRefs.current[index] = el;
|
)}
|
||||||
}}
|
|
||||||
className="carousel-ticker-wrapper"
|
<div className="cinema-trending">
|
||||||
>
|
<div className="cinema-trending-head">
|
||||||
<CarouselTickers
|
<h3>В тренде</h3>
|
||||||
imageUrl={
|
{total > 1 && (
|
||||||
item.ImageTags?.Thumb
|
<div className="cinema-dots">
|
||||||
? getImageUrlsApi(api).getItemImageUrlById(
|
{content.map((item, index) => (
|
||||||
item.Id ?? "",
|
<button
|
||||||
"Thumb",
|
key={item.Id}
|
||||||
{
|
type="button"
|
||||||
quality: 90,
|
className={index === currentSlide ? "active" : ""}
|
||||||
fillHeight: 360,
|
onClick={() => goTo(index)}
|
||||||
},
|
aria-label={item.Name ?? `Slide ${index + 1}`}
|
||||||
)
|
aria-current={index === currentSlide}
|
||||||
: undefined
|
/>
|
||||||
}
|
))}
|
||||||
isActive={index === currentSlide}
|
</div>
|
||||||
itemName={item.Name ?? "Unknown"}
|
)}
|
||||||
itemYear={
|
</div>
|
||||||
item.Type === BaseItemKind.Series && item.EndDate
|
<div className="cinema-trending-rail">
|
||||||
? `${item.ProductionYear ?? ""} - ${new Date(item.EndDate).getFullYear().toString()}`
|
{content.map((item, index) => {
|
||||||
: (item.ProductionYear?.toString() ?? "")
|
const imageUrl = trendingImageUrl(api, item);
|
||||||
}
|
return (
|
||||||
onTickerClick={handleTickerClick}
|
<button
|
||||||
index={index}
|
key={item.Id}
|
||||||
itemType={item.Type as BaseItemKind}
|
type="button"
|
||||||
/>
|
className={`cinema-trending-card ${
|
||||||
</div>
|
index === currentSlide ? "active" : ""
|
||||||
))}
|
}`}
|
||||||
|
onClick={() => goTo(index)}
|
||||||
|
aria-label={item.Name ?? "Рекомендуемое"}
|
||||||
|
>
|
||||||
|
{imageUrl ? (
|
||||||
|
<img
|
||||||
|
src={imageUrl}
|
||||||
|
alt=""
|
||||||
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="cinema-trending-placeholder">
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
{ item.Type === BaseItemKind.Series ? "tv" : "movie" }
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<span className="cinema-trending-chip">
|
||||||
|
{trendingLabel(item)}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { Typography } from "@mui/material";
|
|
||||||
import React from "react";
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
|
||||||
|
|
||||||
type CarouselTickersProps = {
|
|
||||||
imageUrl?: string | undefined | null;
|
|
||||||
itemName: string;
|
|
||||||
itemYear: string;
|
|
||||||
onTickerClick: (index: number) => void;
|
|
||||||
index: number;
|
|
||||||
isActive: boolean;
|
|
||||||
itemType: BaseItemKind;
|
|
||||||
};
|
|
||||||
|
|
||||||
const CarouselTickers = React.memo(
|
|
||||||
({
|
|
||||||
imageUrl,
|
|
||||||
itemName,
|
|
||||||
itemYear,
|
|
||||||
onTickerClick,
|
|
||||||
index,
|
|
||||||
isActive,
|
|
||||||
itemType,
|
|
||||||
}: CarouselTickersProps) => {
|
|
||||||
const handleClick = React.useCallback(() => {
|
|
||||||
onTickerClick(index);
|
|
||||||
}, [index, onTickerClick]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={`carousel-ticker${isActive ? " active" : ""}`}
|
|
||||||
onClick={handleClick}
|
|
||||||
>
|
|
||||||
{imageUrl ? (
|
|
||||||
<img
|
|
||||||
src={imageUrl}
|
|
||||||
alt={itemName}
|
|
||||||
className="carousel-ticker-image"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="carousel-ticker-image placeholder material-symbols-rounded">
|
|
||||||
{" "}
|
|
||||||
{getTypeIcon(itemType)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div>
|
|
||||||
<Typography variant="subtitle1" className="carousel-ticker-title">
|
|
||||||
{itemName}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="caption" className="carousel-ticker-year">
|
|
||||||
{itemYear}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
export default CarouselTickers;
|
|
||||||