mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
Compare commits
7 Commits
1544c535de
...
23269ad9d1
| Author | SHA1 | Date | |
|---|---|---|---|
| 23269ad9d1 | |||
| 57b0a10c4d | |||
| 26f5308d9a | |||
| 4f1600296c | |||
| 1a120d2378 | |||
| a0fb279b29 | |||
| 1d78207004 |
@@ -78,6 +78,7 @@ export default function Gallery({
|
||||
<GalleryFullscreen
|
||||
dialogRef={dialogRef}
|
||||
images={images}
|
||||
nsfw={nsfw}
|
||||
currentIndex={currentIndex}
|
||||
direction={direction}
|
||||
goToPrevious={goToPrevious}
|
||||
@@ -124,7 +125,7 @@ export default function Gallery({
|
||||
>
|
||||
<GalleryImage
|
||||
src={network.getImageUrl(images[currentIndex])}
|
||||
nfsw={nsfw.includes(currentIndex)}
|
||||
nfsw={nsfw.includes(images[currentIndex])}
|
||||
/>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
@@ -188,6 +189,7 @@ export default function Gallery({
|
||||
function GalleryFullscreen({
|
||||
dialogRef,
|
||||
images,
|
||||
nsfw,
|
||||
currentIndex,
|
||||
direction,
|
||||
goToPrevious,
|
||||
@@ -197,6 +199,7 @@ function GalleryFullscreen({
|
||||
}: {
|
||||
dialogRef: React.RefObject<HTMLDialogElement | null>;
|
||||
images: number[];
|
||||
nsfw: number[];
|
||||
currentIndex: number;
|
||||
direction: number;
|
||||
goToPrevious: () => void;
|
||||
@@ -237,10 +240,12 @@ function GalleryFullscreen({
|
||||
|
||||
if (dialogRef.current?.open) {
|
||||
window.addEventListener("mousemove", handleMouseMove);
|
||||
window.addEventListener("touchstart", handleMouseMove);
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("mousemove", handleMouseMove);
|
||||
window.removeEventListener("touchstart", handleMouseMove);
|
||||
if (hideTimeoutRef.current) {
|
||||
clearTimeout(hideTimeoutRef.current);
|
||||
}
|
||||
@@ -316,7 +321,7 @@ function GalleryFullscreen({
|
||||
<img
|
||||
src={network.getImageUrl(images[currentIndex])}
|
||||
alt=""
|
||||
className="w-full h-full object-contain rounded-xl"
|
||||
className="w-full h-full object-contain rounded-xl select-none"
|
||||
/>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
@@ -361,7 +366,7 @@ function GalleryFullscreen({
|
||||
className={`flex-shrink-0 w-16 h-16 rounded-lg overflow-hidden transition-all ${
|
||||
index === currentIndex
|
||||
? "ring-2 ring-primary scale-110 "
|
||||
: "opacity-60 hover:opacity-100"
|
||||
: `${nsfw.includes(imageId) ? "blur-sm hover:blur-none" : "opacity-60 hover:opacity-100"}`
|
||||
}`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
@@ -373,7 +378,7 @@ function GalleryFullscreen({
|
||||
<img
|
||||
src={network.getResampledImageUrl(imageId)}
|
||||
alt={`Thumbnail ${index + 1}`}
|
||||
className="w-full h-full object-cover"
|
||||
className={`w-full h-full object-cover select-none`}
|
||||
/>
|
||||
</button>
|
||||
))}
|
||||
@@ -405,7 +410,7 @@ function GalleryImage({ src, nfsw }: { src: string; nfsw: boolean }) {
|
||||
<img
|
||||
src={src}
|
||||
alt=""
|
||||
className={`w-full h-full object-contain transition-all duration-300 ${!show ? "blur-xl" : ""}`}
|
||||
className={`w-full h-full object-cover transition-all duration-300 ${!show ? "blur-xl" : ""}`}
|
||||
/>
|
||||
{!show && (
|
||||
<>
|
||||
|
||||
@@ -261,6 +261,7 @@ export const i18nData = {
|
||||
"File Size": "文件大小",
|
||||
"Tag": "标签",
|
||||
"Optional": "可选",
|
||||
"Download": "下载",
|
||||
},
|
||||
},
|
||||
"zh-TW": {
|
||||
@@ -525,6 +526,7 @@ export const i18nData = {
|
||||
"File Size": "檔案大小",
|
||||
"Tag": "標籤",
|
||||
"Optional": "可選",
|
||||
"Download": "下載",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -187,7 +187,7 @@ function PinnedResourcesCarousel({
|
||||
</div>
|
||||
</div>
|
||||
{resources.length > 1 && (
|
||||
<div className="absolute bottom-4 left-1/2 transform -translate-x-1/2 flex gap-2 z-10">
|
||||
<div className="absolute bottom-2 left-1/2 transform -translate-x-1/2 flex gap-2 z-10">
|
||||
{resources.map((_, index) => (
|
||||
<button
|
||||
key={index}
|
||||
|
||||
@@ -898,8 +898,6 @@ function CloudflarePopup({ file }: { file: RFile }) {
|
||||
<h3 className={"font-bold m-2"}>
|
||||
{downloadToken ? t("Verification successful") : t("Verifying your request")}
|
||||
</h3>
|
||||
{!downloadToken && (
|
||||
<>
|
||||
<div className={"h-20 w-full"}>
|
||||
<Turnstile
|
||||
siteKey={app.cloudflareTurnstileSiteKey!}
|
||||
@@ -911,14 +909,7 @@ function CloudflarePopup({ file }: { file: RFile }) {
|
||||
}}
|
||||
></Turnstile>
|
||||
</div>
|
||||
<p className={"text-xs text-base-content/80 m-2"}>
|
||||
{t(
|
||||
"Please check your network if the verification takes too long or the captcha does not appear.",
|
||||
)}
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
{downloadToken && (
|
||||
{downloadToken ? (
|
||||
<div className="p-2">
|
||||
<a
|
||||
href={network.getFileDownloadLink(file.id, downloadToken)}
|
||||
@@ -932,7 +923,11 @@ function CloudflarePopup({ file }: { file: RFile }) {
|
||||
{t("Download")}
|
||||
</a>
|
||||
</div>
|
||||
) : <p className={"text-xs text-base-content/80 m-2"}>
|
||||
{t(
|
||||
"Please check your network if the verification takes too long or the captcha does not appear.",
|
||||
)}
|
||||
</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
2
main.go
2
main.go
@@ -19,6 +19,8 @@ func main() {
|
||||
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
|
||||
}))
|
||||
|
||||
app.Use(middleware.UnsupportedRegionMiddleware)
|
||||
|
||||
app.Use(middleware.ErrorHandler)
|
||||
|
||||
app.Use(middleware.RealUserMiddleware)
|
||||
|
||||
@@ -32,6 +32,7 @@ func FrontendMiddleware(c fiber.Ctx) error {
|
||||
}
|
||||
|
||||
if _, err := os.Stat(file); path == "/" || os.IsNotExist(err) {
|
||||
c.Set("Cache-Control", "no-cache")
|
||||
return serveIndexHtml(c)
|
||||
} else {
|
||||
c.Set("Cache-Control", "public, max-age=31536000, immutable")
|
||||
|
||||
29
server/middleware/unsupported_region_middleware.go
Normal file
29
server/middleware/unsupported_region_middleware.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func UnsupportedRegionMiddleware(c fiber.Ctx) error {
|
||||
path := string(c.Request().URI().Path())
|
||||
|
||||
// Skip static file requests
|
||||
if strings.Contains(path, ".") {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
// Skip API requests
|
||||
if strings.HasPrefix(path, "/api") {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
if string(c.Request().Header.Peek("Unsupported-Region")) == "true" {
|
||||
// Return a 403 Forbidden response with an empty html for unsupported regions
|
||||
c.Response().Header.Add("Content-Type", "text/html")
|
||||
c.Status(fiber.StatusForbidden)
|
||||
return c.SendString("<html></html>")
|
||||
}
|
||||
return c.Next()
|
||||
}
|
||||
Reference in New Issue
Block a user