📄 Lectures: pdf.js viewer в модалке вместо Google Viewer

- vite.config.ts: копирование pdf.worker + cMaps
- LecturesPage.tsx: react-pdf viewer с навигацией по страницам
- Скачивание через Telegram.WebApp.downloadFile (без изменений)
- Убрал Google Docs Viewer — приватность
This commit is contained in:
2026-09-27 12:31:31 +03:00
parent f83028b105
commit b1756ec822
4 changed files with 899 additions and 55 deletions
+616 -4
View File
@@ -10,6 +10,7 @@
"dependencies": { "dependencies": {
"react": "^19.2.7", "react": "^19.2.7",
"react-dom": "^19.2.7", "react-dom": "^19.2.7",
"react-pdf": "^11.0.0",
"react-router-dom": "^7.18.1" "react-router-dom": "^7.18.1"
}, },
"devDependencies": { "devDependencies": {
@@ -24,7 +25,8 @@
"globals": "^17.7.0", "globals": "^17.7.0",
"typescript": "~6.0.2", "typescript": "~6.0.2",
"typescript-eslint": "^8.62.0", "typescript-eslint": "^8.62.0",
"vite": "^8.1.1" "vite": "^8.1.1",
"vite-plugin-static-copy": "^4.1.1"
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
@@ -545,6 +547,271 @@
"@jridgewell/sourcemap-codec": "^1.4.14" "@jridgewell/sourcemap-codec": "^1.4.14"
} }
}, },
"node_modules/@napi-rs/canvas": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-1.0.9.tgz",
"integrity": "sha512-QviPdJImDi/jMAvBfqaw+19BndMd/sizXVW3NnpMd3VJGz++QXkOHcP9kWR/smHG0hNjHeyuHFyrx/5lD0oNcQ==",
"license": "MIT",
"optional": true,
"workspaces": [
"e2e/*"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
},
"optionalDependencies": {
"@napi-rs/canvas-android-arm64": "1.0.9",
"@napi-rs/canvas-darwin-arm64": "1.0.9",
"@napi-rs/canvas-darwin-x64": "1.0.9",
"@napi-rs/canvas-linux-arm-gnueabihf": "1.0.9",
"@napi-rs/canvas-linux-arm64-gnu": "1.0.9",
"@napi-rs/canvas-linux-arm64-musl": "1.0.9",
"@napi-rs/canvas-linux-riscv64-gnu": "1.0.9",
"@napi-rs/canvas-linux-x64-gnu": "1.0.9",
"@napi-rs/canvas-linux-x64-musl": "1.0.9",
"@napi-rs/canvas-win32-arm64-msvc": "1.0.9",
"@napi-rs/canvas-win32-x64-msvc": "1.0.9"
}
},
"node_modules/@napi-rs/canvas-android-arm64": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-android-arm64/-/canvas-android-arm64-1.0.9.tgz",
"integrity": "sha512-4LGXk2/0HVzE29K8SzML5WubgCp++B1FH3qgl35XmSZE+lLdr6P9VRQEnZ0MCLZMTSuJP41yyhtoiVNEuvrTIA==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-darwin-arm64": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-arm64/-/canvas-darwin-arm64-1.0.9.tgz",
"integrity": "sha512-YNdfLBzY0W/Pep9fo2L6RmoNlNksnn05LRnX66W63R3ij58S25QOTcjdtEt2v8+PnCESzqZsYzUo+QPeIR44NA==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-darwin-x64": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-x64/-/canvas-darwin-x64-1.0.9.tgz",
"integrity": "sha512-ceZQSknTEcy3dOXoekv59LTCkXjvnLsq+VW5PeNNDHEPQbRS5Ervkm1EaDa7WLAjiYWMLuSQTRTHao1dEX4prg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm-gnueabihf": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm-gnueabihf/-/canvas-linux-arm-gnueabihf-1.0.9.tgz",
"integrity": "sha512-XhfI0Wwv4llhd6nnWDtY3kQKjq0r+y1i91PlJlJI24ag2U9WrnwbG1qS3+fDLEyouwEVFchiKkTEHozK+5iUNA==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm64-gnu": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-gnu/-/canvas-linux-arm64-gnu-1.0.9.tgz",
"integrity": "sha512-012oiYtKaE7i9oxc8q7nraT7kDOpLcaCmFLzVe9Ty34RHDdoDzbWLrVh827CNxYh/EADX1eSikA3ymLjo/nNuw==",
"cpu": [
"arm64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm64-musl": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-musl/-/canvas-linux-arm64-musl-1.0.9.tgz",
"integrity": "sha512-Ls5UWYFFn63casTZEczbeyEg3vRDRkv9lscuGwfchtY5yLLQhgOB8SN4YGxmfJ5vTaBwZ2YUxBS3NtmjJmFXdA==",
"cpu": [
"arm64"
],
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-riscv64-gnu": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-riscv64-gnu/-/canvas-linux-riscv64-gnu-1.0.9.tgz",
"integrity": "sha512-hLKEGxV7ZiRHqndePTokgDMdBlo/rDfzg7P4p4QIv9pUhuYobnu3R2NIFLCRghG0nwfo+s2sw+c1xZFeCmEAsw==",
"cpu": [
"riscv64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-x64-gnu": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-gnu/-/canvas-linux-x64-gnu-1.0.9.tgz",
"integrity": "sha512-6kaz3w0QMy77PDWk6rJ1ksIihdad3qzEyX2o2oGT8GwCaypfT5mhjr8buOO5hstyLxcWXDScuz56RsINLtBPIQ==",
"cpu": [
"x64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-x64-musl": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-musl/-/canvas-linux-x64-musl-1.0.9.tgz",
"integrity": "sha512-xrGvmS3v55hmZ86ls/kBLVNMUTYio3f6Ik0DireemG994VfPAwiA3ZXA0Uf1bByctkB3NQ1Sfb+H5bkdUnnzfQ==",
"cpu": [
"x64"
],
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-win32-arm64-msvc": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-arm64-msvc/-/canvas-win32-arm64-msvc-1.0.9.tgz",
"integrity": "sha512-yjmVS3ArZeRVCP7jqbPq4rpZa/BhTeI7ELE2XqJg3snICQBDevLZyArxswHkiTnT34KRic33/4fLirrHI+SY8A==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-win32-x64-msvc": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-x64-msvc/-/canvas-win32-x64-msvc-1.0.9.tgz",
"integrity": "sha512-QlSYQdMQslB81nlABo9wNfQ6npFhE7/O+saCZdqVGueGanyRk4jCogD5EwQenfP3kIq9e+mm6GreQBjX5MrA8g==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/wasm-runtime": { "node_modules/@napi-rs/wasm-runtime": {
"version": "1.1.6", "version": "1.1.6",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.6.tgz", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.6.tgz",
@@ -902,7 +1169,7 @@
"version": "19.2.17", "version": "19.2.17",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz",
"integrity": "sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==", "integrity": "sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==",
"dev": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"csstype": "^3.2.2" "csstype": "^3.2.2"
@@ -1227,6 +1494,33 @@
"url": "https://github.com/sponsors/epoberezkin" "url": "https://github.com/sponsors/epoberezkin"
} }
}, },
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
"dev": true,
"license": "ISC",
"dependencies": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/anymatch/node_modules/picomatch": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/balanced-match": { "node_modules/balanced-match": {
"version": "4.0.4", "version": "4.0.4",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
@@ -1250,6 +1544,19 @@
"node": ">=6.0.0" "node": ">=6.0.0"
} }
}, },
"node_modules/binary-extensions": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
"integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "5.0.8", "version": "5.0.8",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz",
@@ -1263,6 +1570,19 @@
"node": "20 || >=22" "node": "20 || >=22"
} }
}, },
"node_modules/braces": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"dev": true,
"license": "MIT",
"dependencies": {
"fill-range": "^7.1.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/browserslist": { "node_modules/browserslist": {
"version": "4.28.7", "version": "4.28.7",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.7.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.7.tgz",
@@ -1318,6 +1638,53 @@
], ],
"license": "CC-BY-4.0" "license": "CC-BY-4.0"
}, },
"node_modules/chokidar": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
"dev": true,
"license": "MIT",
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
"glob-parent": "~5.1.2",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.6.0"
},
"engines": {
"node": ">= 8.10.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/chokidar/node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"license": "ISC",
"dependencies": {
"is-glob": "^4.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/clsx": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
"integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/convert-source-map": { "node_modules/convert-source-map": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
@@ -1357,7 +1724,7 @@
"version": "3.2.3", "version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
"dev": true, "devOptional": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/debug": { "node_modules/debug": {
@@ -1385,6 +1752,15 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/detect-libc": { "node_modules/detect-libc": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
@@ -1402,6 +1778,18 @@
"dev": true, "dev": true,
"license": "ISC" "license": "ISC"
}, },
"node_modules/es-toolkit": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.52.0.tgz",
"integrity": "sha512-XTNEJQh1tY1ZJVcf6ayP/2n4ZPyaHlW2FWs7xvw5ddPuhUVjLD3olQVQS7kf58JbAB48iL0uL/jerTrjtV3lDA==",
"license": "MIT",
"workspaces": [
"docs",
"benchmarks",
"tests/types",
"tests/browser-compat"
]
},
"node_modules/escalade": { "node_modules/escalade": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
@@ -1662,6 +2050,19 @@
"node": ">=16.0.0" "node": ">=16.0.0"
} }
}, },
"node_modules/fill-range": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"dev": true,
"license": "MIT",
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/find-up": { "node_modules/find-up": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
@@ -1788,6 +2189,19 @@
"node": ">=0.8.19" "node": ">=0.8.19"
} }
}, },
"node_modules/is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dev": true,
"license": "MIT",
"dependencies": {
"binary-extensions": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/is-extglob": { "node_modules/is-extglob": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -1811,6 +2225,16 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/isexe": { "node_modules/isexe": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@@ -1822,7 +2246,6 @@
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/jsesc": { "node_modules/jsesc": {
@@ -2185,6 +2608,18 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"license": "MIT",
"dependencies": {
"js-tokens": "^3.0.0 || ^4.0.0"
},
"bin": {
"loose-envify": "cli.js"
}
},
"node_modules/lru-cache": { "node_modules/lru-cache": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
@@ -2195,6 +2630,41 @@
"yallist": "^3.0.2" "yallist": "^3.0.2"
} }
}, },
"node_modules/make-cancellable-promise": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/make-cancellable-promise/-/make-cancellable-promise-2.0.0.tgz",
"integrity": "sha512-3SEQqTpV9oqVsIWqAcmDuaNeo7yBO3tqPtqGRcKkEo0lrzD3wqbKG9mkxO65KoOgXqj+zH2phJ2LiAsdzlogSw==",
"license": "MIT",
"funding": {
"url": "https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1"
}
},
"node_modules/make-event-props": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/make-event-props/-/make-event-props-2.0.0.tgz",
"integrity": "sha512-G/hncXrl4Qt7mauJEXSg3AcdYzmpkIITTNl5I+rH9sog5Yw0kK6vseJjCaPfOXqOqQuPUP89Rkhfz5kPS8ijtw==",
"license": "MIT",
"funding": {
"url": "https://github.com/wojtekmaj/make-event-props?sponsor=1"
}
},
"node_modules/merge-refs": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-refs/-/merge-refs-2.0.0.tgz",
"integrity": "sha512-3+B21mYK2IqUWnd2EivABLT7ueDhb0b8/dGK8LoFQPrU61YITeCMn14F7y7qZafWNZhUEKb24cJdiT5Wxs3prg==",
"license": "MIT",
"funding": {
"url": "https://github.com/wojtekmaj/merge-refs?sponsor=1"
},
"peerDependencies": {
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/minimatch": { "node_modules/minimatch": {
"version": "10.2.5", "version": "10.2.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz",
@@ -2254,6 +2724,16 @@
"node": ">=18" "node": ">=18"
} }
}, },
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/optionator": { "node_modules/optionator": {
"version": "0.9.4", "version": "0.9.4",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
@@ -2304,6 +2784,19 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/p-map": {
"version": "7.0.8",
"resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.8.tgz",
"integrity": "sha512-MitaVsCuCFIvOLLPIU7NnfrZvS9H9h7kwMUkDo+T2pEISaJD48IV9S8iIdXB7PsvvdxyYcsSTTrr90XKsbulNw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/path-exists": { "node_modules/path-exists": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -2324,6 +2817,18 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/pdfjs-dist": {
"version": "6.3.289",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-6.3.289.tgz",
"integrity": "sha512-ZHjSVpDa3D6izMq8/04lvkhkATUmL9px6ChPaXc1k6nU2Mrhlg1/7F0bdUqCwUjw3NsPTfPZsMDUU6ZIcRaeQw==",
"license": "Apache-2.0",
"engines": {
"node": ">=22.13.0 || >=24"
},
"optionalDependencies": {
"@napi-rs/canvas": "^1.0.0"
}
},
"node_modules/picocolors": { "node_modules/picocolors": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
@@ -2414,6 +2919,36 @@
"react": "^19.2.8" "react": "^19.2.8"
} }
}, },
"node_modules/react-pdf": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/react-pdf/-/react-pdf-11.0.0.tgz",
"integrity": "sha512-x4Ierg3Sl+gOoqd0pVOQndiuFKeGcXQmUNtaSH0D/cs2nUW1HBDlFBT2Z8jDsDJv0Kh//jlOJT21ERyQtlRe7A==",
"license": "MIT",
"dependencies": {
"clsx": "^2.0.0",
"dequal": "^2.0.3",
"es-toolkit": "^1.52.0",
"make-cancellable-promise": "^2.0.0",
"make-event-props": "^2.0.0",
"merge-refs": "^2.0.0",
"pdfjs-dist": "6.3.289",
"tiny-invariant": "^1.0.0",
"warning": "^4.0.0"
},
"funding": {
"url": "https://github.com/wojtekmaj/react-pdf?sponsor=1"
},
"peerDependencies": {
"@types/react": "^19.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/react-router": { "node_modules/react-router": {
"version": "7.18.1", "version": "7.18.1",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.1.tgz", "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.1.tgz",
@@ -2452,6 +2987,32 @@
"react-dom": ">=18" "react-dom": ">=18"
} }
}, },
"node_modules/readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dev": true,
"license": "MIT",
"dependencies": {
"picomatch": "^2.2.1"
},
"engines": {
"node": ">=8.10.0"
}
},
"node_modules/readdirp/node_modules/picomatch": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/rolldown": { "node_modules/rolldown": {
"version": "1.1.5", "version": "1.1.5",
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.1.5.tgz", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.1.5.tgz",
@@ -2541,6 +3102,12 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/tiny-invariant": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==",
"license": "MIT"
},
"node_modules/tinyglobby": { "node_modules/tinyglobby": {
"version": "0.2.17", "version": "0.2.17",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
@@ -2558,6 +3125,19 @@
"url": "https://github.com/sponsors/SuperchupuDev" "url": "https://github.com/sponsors/SuperchupuDev"
} }
}, },
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
},
"node_modules/ts-api-utils": { "node_modules/ts-api-utils": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz",
@@ -2756,6 +3336,38 @@
} }
} }
}, },
"node_modules/vite-plugin-static-copy": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/vite-plugin-static-copy/-/vite-plugin-static-copy-4.1.1.tgz",
"integrity": "sha512-GrlA8YklrAfSyxJ4M3fdQLOo9oNkp56IM9FYgX/WtEgeIFkPwhu4wzpufBCIuNKCa6Fn77FkRdYxkHqV0FwjAw==",
"dev": true,
"license": "MIT",
"dependencies": {
"chokidar": "^3.6.0",
"p-map": "^7.0.4",
"picocolors": "^1.1.1",
"tinyglobby": "^0.2.17"
},
"engines": {
"node": "^22.0.0 || >=24.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/sapphi-red"
},
"peerDependencies": {
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/warning": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
"license": "MIT",
"dependencies": {
"loose-envify": "^1.0.0"
}
},
"node_modules/which": { "node_modules/which": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+3 -1
View File
@@ -12,6 +12,7 @@
"dependencies": { "dependencies": {
"react": "^19.2.7", "react": "^19.2.7",
"react-dom": "^19.2.7", "react-dom": "^19.2.7",
"react-pdf": "^11.0.0",
"react-router-dom": "^7.18.1" "react-router-dom": "^7.18.1"
}, },
"devDependencies": { "devDependencies": {
@@ -26,6 +27,7 @@
"globals": "^17.7.0", "globals": "^17.7.0",
"typescript": "~6.0.2", "typescript": "~6.0.2",
"typescript-eslint": "^8.62.0", "typescript-eslint": "^8.62.0",
"vite": "^8.1.1" "vite": "^8.1.1",
"vite-plugin-static-copy": "^4.1.1"
} }
} }
+254 -46
View File
@@ -1,14 +1,18 @@
import { useEffect, useState } from 'react'; import { useEffect, useState, useMemo } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { Document, Page, pdfjs } from 'react-pdf';
import { useLanguage } from '../i18n/LanguageContext'; import { useLanguage } from '../i18n/LanguageContext';
import { fonts, radius } from '../styles/theme'; import { fonts, radius } from '../styles/theme';
import { getLectures, type LectureListItem } from '../api'; import { getLectures, type LectureListItem } from '../api';
// pdf.js worker + cMaps (для кириллицы и польских букв)
pdfjs.GlobalWorkerOptions.workerSrc = '/pdf-worker/pdf.worker.min.mjs';
/** /**
* LecturesPage — список лекций по уровню пользователя. * LecturesPage — список лекций + модалка с pdf.js viewer.
* *
* Открытие: через Telegram.WebApp.openLink() — открывает PDF в браузере. * PDF рендерится через pdf.js в canvas — работает в Telegram WebView.
* Скачивание: через Telegram.WebApp.downloadFile() — скачивает файл. * Скачивание — через Telegram.WebApp.downloadFile.
*/ */
const LecturesPage: React.FC = () => { const LecturesPage: React.FC = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -17,6 +21,14 @@ const LecturesPage: React.FC = () => {
const [level, setLevel] = useState('A1'); const [level, setLevel] = useState('A1');
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const [activeLecture, setActiveLecture] = useState<LectureListItem | null>(null);
// Состояние pdf.js viewer
const [numPages, setNumPages] = useState<number>(0);
const [pageNumber, setPageNumber] = useState<number>(1);
const [pdfLoading, setPdfLoading] = useState(false);
const [pdfError, setPdfError] = useState<string | null>(null);
const [pageWidth, setPageWidth] = useState<number>(window.innerWidth - 40);
const brandColor = '#2ECC71'; const brandColor = '#2ECC71';
const lectureColor = '#4FA9E8'; const lectureColor = '#4FA9E8';
@@ -32,6 +44,12 @@ const LecturesPage: React.FC = () => {
...extra, ...extra,
}); });
// pdf.js options — обязательно вне компонента или useMemo
const pdfOptions = useMemo(() => ({
cMapUrl: '/cmaps/',
cMapPacked: true,
}), []);
useEffect(() => { useEffect(() => {
getLectures() getLectures()
.then((data) => { .then((data) => {
@@ -46,32 +64,38 @@ const LecturesPage: React.FC = () => {
}); });
}, []); }, []);
// Обновляем ширину страницы при ресайзе
useEffect(() => {
const handleResize = () => {
setPageWidth(window.innerWidth - 40);
};
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
const getFileUrl = (lecture: LectureListItem): string => { const getFileUrl = (lecture: LectureListItem): string => {
return `https://api.filwordspl.com${lecture.file_url}`; return `https://api.filwordspl.com${lecture.file_url}`;
}; };
/**
* Открыть лекцию: в Telegram — через openLink (Safari/Chrome),
* в браузере — через window.open.
*/
const handleOpenLecture = (lecture: LectureListItem) => { const handleOpenLecture = (lecture: LectureListItem) => {
const url = getFileUrl(lecture); setActiveLecture(lecture);
setPageNumber(1);
setNumPages(0);
setPdfError(null);
setPdfLoading(true);
};
if (window.Telegram?.WebApp?.openLink) { const handleCloseLecture = () => {
window.Telegram.WebApp.openLink(url); setActiveLecture(null);
} else { setPageNumber(1);
window.open(url, '_blank'); setNumPages(0);
} setPdfError(null);
setPdfLoading(false);
}; };
/**
* Скачать лекцию: в Telegram — через downloadFile,
* в браузере — через скрытую ссылку.
*/
const handleDownloadLecture = (lecture: LectureListItem) => { const handleDownloadLecture = (lecture: LectureListItem) => {
const url = getFileUrl(lecture); const url = getFileUrl(lecture);
// Telegram WebApp имеет свой метод downloadFile
if (window.Telegram?.WebApp?.downloadFile) { if (window.Telegram?.WebApp?.downloadFile) {
window.Telegram.WebApp.downloadFile({ window.Telegram.WebApp.downloadFile({
url, url,
@@ -80,7 +104,6 @@ const LecturesPage: React.FC = () => {
return; return;
} }
// Fallback — обычное скачивание через ссылку
const a = document.createElement('a'); const a = document.createElement('a');
a.href = url; a.href = url;
a.download = `${lecture.title}.${lecture.file_type}`; a.download = `${lecture.title}.${lecture.file_type}`;
@@ -99,7 +122,7 @@ const LecturesPage: React.FC = () => {
fontFamily: fonts.main, fontFamily: fonts.main,
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
padding: '24px', padding: '16px',
position: 'relative', position: 'relative',
overflow: 'hidden', overflow: 'hidden',
}}> }}>
@@ -114,26 +137,29 @@ const LecturesPage: React.FC = () => {
{/* Заголовок */} {/* Заголовок */}
<div style={{ <div style={{
display: 'flex', alignItems: 'center', gap: '10px', display: 'flex', alignItems: 'center', gap: '8px',
marginBottom: '24px', marginBottom: '16px',
}}> }}>
<button <button
onClick={() => navigate('/learning')} onClick={() => navigate('/learning')}
style={{ style={{
...glass({ padding: '10px 14px', borderRadius: radius.md }), ...glass({ padding: '8px 12px', borderRadius: radius.md }),
color: textColor, fontSize: '14px', fontWeight: 600, cursor: 'pointer', color: textColor, fontSize: '14px', fontWeight: 600, cursor: 'pointer',
flexShrink: 0,
}} }}
> >
← ←
</button> </button>
<h1 style={{ <h1 style={{
fontSize: '22px', fontWeight: 800, margin: 0, color: textColor, flex: 1, fontSize: '18px', fontWeight: 800, margin: 0, color: textColor, flex: 1,
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
}}> }}>
📄 {t('lectures') || 'Лекции'} 📄 {t('lectures') || 'Лекции'}
</h1> </h1>
<span style={{ <span style={{
...glass({ padding: '6px 12px', borderRadius: radius.sm }), ...glass({ padding: '4px 10px', borderRadius: radius.sm }),
fontSize: '14px', fontWeight: 800, color: brandColor, fontSize: '13px', fontWeight: 800, color: brandColor,
flexShrink: 0,
}}> }}>
{level} {level}
</span> </span>
@@ -149,9 +175,7 @@ const LecturesPage: React.FC = () => {
⚠️ {error} ⚠️ {error}
</div> </div>
) : lectures.length === 0 ? ( ) : lectures.length === 0 ? (
<div style={{ <div style={{ textAlign: 'center', padding: '60px 20px', color: subColor }}>
textAlign: 'center', padding: '60px 20px', color: subColor,
}}>
<div style={{ fontSize: '64px', marginBottom: '16px' }}>📭</div> <div style={{ fontSize: '64px', marginBottom: '16px' }}>📭</div>
<p style={{ fontSize: '16px', marginBottom: '8px', fontWeight: 600 }}> <p style={{ fontSize: '16px', marginBottom: '8px', fontWeight: 600 }}>
{t('lecturesEmpty') || 'Лекции в разработке'} {t('lecturesEmpty') || 'Лекции в разработке'}
@@ -161,14 +185,12 @@ const LecturesPage: React.FC = () => {
</p> </p>
</div> </div>
) : ( ) : (
<div style={{ <div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}>
display: 'flex', flexDirection: 'column', gap: '12px',
}}>
{lectures.map((lecture) => ( {lectures.map((lecture) => (
<div <div
key={lecture.id} key={lecture.id}
style={{ style={{
padding: '18px 20px', padding: '14px 16px',
borderRadius: radius.lg, borderRadius: radius.lg,
border: '1px solid rgba(255,255,255,0.7)', border: '1px solid rgba(255,255,255,0.7)',
background: 'rgba(255,255,255,0.55)', background: 'rgba(255,255,255,0.55)',
@@ -177,17 +199,19 @@ const LecturesPage: React.FC = () => {
boxShadow: '0 6px 20px rgba(31,38,73,0.08), inset 0 1px 0 rgba(255,255,255,0.85)', boxShadow: '0 6px 20px rgba(31,38,73,0.08), inset 0 1px 0 rgba(255,255,255,0.85)',
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
gap: '16px', gap: '10px',
width: '100%',
boxSizing: 'border-box',
}} }}
> >
{/* Клик по иконке/названию — открыть */}
<button <button
onClick={() => handleOpenLecture(lecture)} onClick={() => handleOpenLecture(lecture)}
style={{ style={{
flex: 1, flex: 1,
minWidth: 0,
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
gap: '16px', gap: '12px',
border: 'none', border: 'none',
background: 'transparent', background: 'transparent',
cursor: 'pointer', cursor: 'pointer',
@@ -196,31 +220,29 @@ const LecturesPage: React.FC = () => {
fontFamily: fonts.main, fontFamily: fonts.main,
}} }}
> >
<div style={{ fontSize: '32px', flexShrink: 0 }}> <div style={{ fontSize: '28px', flexShrink: 0 }}>
{lecture.file_type === 'pdf' ? '📕' : lecture.file_type === 'html' ? '🌐' : '📄'} {lecture.file_type === 'pdf' ? '📕' : lecture.file_type === 'html' ? '🌐' : '📄'}
</div> </div>
<div style={{ flex: 1, minWidth: 0 }}> <div style={{ flex: 1, minWidth: 0 }}>
<div style={{ <div style={{
fontSize: '16px', fontWeight: 700, color: textColor, fontSize: '15px', fontWeight: 700, color: textColor,
marginBottom: '4px', marginBottom: '2px',
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
}}> }}>
{lecture.title} {lecture.title}
</div> </div>
<div style={{ <div style={{ fontSize: '11px', color: subColor, opacity: 0.7 }}>
fontSize: '11px', color: subColor, opacity: 0.7,
}}>
{lecture.file_type.toUpperCase()} · {lecture.file_size_kb} KB {lecture.file_type.toUpperCase()} · {lecture.file_size_kb} KB
</div> </div>
</div> </div>
</button> </button>
{/* Кнопка скачать */}
<button <button
onClick={() => handleDownloadLecture(lecture)} onClick={() => handleDownloadLecture(lecture)}
style={{ style={{
width: '44px', width: '40px',
height: '44px', height: '40px',
minWidth: '40px',
borderRadius: radius.md, borderRadius: radius.md,
border: `1px solid ${brandColor}30`, border: `1px solid ${brandColor}30`,
background: `${brandColor}15`, background: `${brandColor}15`,
@@ -248,6 +270,192 @@ const LecturesPage: React.FC = () => {
Filwords PL © 2026 Filwords PL © 2026
</div> </div>
</div> </div>
{/* ============ МОДАЛКА С PDF.JS VIEWER ============ */}
{activeLecture && (
<div
style={{
position: 'fixed',
top: 0, left: 0, right: 0, bottom: 0,
background: 'rgba(20,22,35,0.95)',
zIndex: 1000,
display: 'flex',
flexDirection: 'column',
padding: '8px',
boxSizing: 'border-box',
}}
>
{/* Заголовок модалки */}
<div style={{
display: 'flex',
alignItems: 'center',
gap: '8px',
padding: '8px 12px',
background: 'rgba(255,255,255,0.95)',
borderRadius: radius.md,
marginBottom: '8px',
flexShrink: 0,
}}>
<button
onClick={handleCloseLecture}
style={{
padding: '6px 12px',
borderRadius: radius.sm,
border: 'none',
background: 'rgba(0,0,0,0.05)',
color: textColor,
fontSize: '14px',
fontWeight: 600,
cursor: 'pointer',
flexShrink: 0,
}}
>
←
</button>
<div style={{
flex: 1, minWidth: 0,
fontSize: '13px', fontWeight: 700, color: textColor,
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
}}>
{activeLecture.title}
</div>
<button
onClick={() => handleDownloadLecture(activeLecture)}
style={{
padding: '6px 12px',
borderRadius: radius.sm,
border: 'none',
background: `${brandColor}20`,
color: brandColor,
fontSize: '13px',
fontWeight: 700,
cursor: 'pointer',
flexShrink: 0,
}}
>
⬇
</button>
</div>
{/* PDF viewer */}
<div style={{
flex: 1,
background: '#FFFFFF',
borderRadius: radius.md,
overflow: 'auto',
minHeight: 0,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
padding: '8px 0',
position: 'relative',
}}>
{pdfLoading && (
<div style={{
position: 'absolute', top: '20px',
padding: '8px 16px',
background: 'rgba(0,0,0,0.7)',
color: '#FFF',
borderRadius: radius.md,
fontSize: '13px',
zIndex: 10,
}}>
⏳ Загрузка PDF...
</div>
)}
{pdfError && (
<div style={{
padding: '40px 20px',
color: '#E74C3C',
fontSize: '14px',
textAlign: 'center',
}}>
⚠️ {pdfError}
</div>
)}
<Document
file={getFileUrl(activeLecture)}
options={pdfOptions}
onLoadSuccess={({ numPages }) => {
setNumPages(numPages);
setPdfLoading(false);
}}
onLoadError={(err) => {
console.error('PDF load error:', err);
setPdfError('Не удалось загрузить PDF');
setPdfLoading(false);
}}
loading=""
>
<Page
pageNumber={pageNumber}
width={pageWidth}
renderTextLayer={false}
renderAnnotationLayer={false}
/>
</Document>
{/* Навигация по страницам */}
{numPages > 1 && (
<div style={{
display: 'flex',
alignItems: 'center',
gap: '12px',
padding: '12px',
position: 'sticky',
bottom: '0',
background: 'rgba(255,255,255,0.95)',
borderRadius: radius.md,
marginTop: '12px',
}}>
<button
onClick={() => setPageNumber(p => Math.max(1, p - 1))}
disabled={pageNumber <= 1}
style={{
padding: '8px 16px',
borderRadius: radius.sm,
border: 'none',
background: pageNumber <= 1 ? 'rgba(0,0,0,0.05)' : brandColor,
color: pageNumber <= 1 ? '#999' : '#FFF',
fontSize: '16px',
fontWeight: 700,
cursor: pageNumber <= 1 ? 'default' : 'pointer',
}}
>
←
</button>
<div style={{
fontSize: '14px',
fontWeight: 700,
color: textColor,
minWidth: '80px',
textAlign: 'center',
}}>
{pageNumber} / {numPages}
</div>
<button
onClick={() => setPageNumber(p => Math.min(numPages, p + 1))}
disabled={pageNumber >= numPages}
style={{
padding: '8px 16px',
borderRadius: radius.sm,
border: 'none',
background: pageNumber >= numPages ? 'rgba(0,0,0,0.05)' : brandColor,
color: pageNumber >= numPages ? '#999' : '#FFF',
fontSize: '16px',
fontWeight: 700,
cursor: pageNumber >= numPages ? 'default' : 'pointer',
}}
>
→
</button>
</div>
)}
</div>
</div>
)}
</div> </div>
); );
}; };
+26 -4
View File
@@ -1,10 +1,32 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import path from 'node:path';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const pdfjsDistPath = path.dirname(require.resolve('pdfjs-dist/package.json'));
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [
react(),
viteStaticCopy({
targets: [
// pdf.worker.min.mjs — worker для pdf.js
{
src: path.join(pdfjsDistPath, 'build', 'pdf.worker.min.mjs'),
dest: 'pdf-worker',
},
// cMaps — для кириллицы и польских букв
{
src: path.join(pdfjsDistPath, 'cmaps', '*'),
dest: 'cmaps',
},
],
}),
],
build: { build: {
chunkSizeWarningLimit: 1000, chunkSizeWarningLimit: 1000,
}, },
}) });