diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d77bdf..117412f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,31 @@ # Changelog +## [0.1.7](https://github.com/pi-docket/ConvertX-CN/releases/tag/v0.1.7) (2026-01-20) + +### 🐛 Bug Fixes + +- **登入問題**: 修復遠端部署時登入後被導回登入頁的問題 + - 將 Cookie `sameSite` 從 `strict` 改為 `lax` + - 新增 Cookie `path` 設定確保覆蓋整個應用 + - 新增 `TRUST_PROXY` 環境變數支援 reverse proxy + +### 🚀 Features + +- **Dockerfile 擴充**: 直接內建進階功能(不再分 Full 版) + - 新增 `texlive-lang-arabic` 阿拉伯語 LaTeX 支援 + - 新增 `texlive-lang-other` 希伯來語等 LaTeX 支援 + - 新增 `python3-opencv` 電腦視覺轉換支援 + - 新增 `libavcodec-extra` 額外影片編解碼器 +- **Locale**: 預設改為 `zh_TW.UTF-8` 確保中文 PDF 正確顯示 +- **Pandoc**: PDF 引擎改用 `pdflatex` 提高相容性 + +### 📝 Docs + +- 更新 compose.yaml 加入 `TRUST_PROXY` 說明 +- 新增遠端部署注意事項 + +--- + ## [0.1.6](https://github.com/pi-docket/ConvertX-CN/releases/tag/v0.1.6) (2026-01-20) ### Features diff --git a/Dockerfile b/Dockerfile index 23678b6..16b48e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,19 @@ # ============================================================================== # ConvertX-CN 官方 Docker Image -# 版本:v0.1.6 +# 版本:v0.1.7 # ============================================================================== # # 📦 Image 說明: # - 這是 ConvertX-CN 官方 Docker Hub Image 的生產 Dockerfile -# - 目標:在功能完整性與 image 體積間取得平衡 -# - 適合一般使用者日常文件轉換需求 +# - 已內建完整功能,無需額外擴充 # # 🌍 內建語言支援: # - OCR: 英文、繁體中文、簡體中文、日文、韓文、德文、法文 # - Locale: en_US, zh_TW, zh_CN, ja_JP, ko_KR, de_DE, fr_FR -# - 字型: Noto CJK, Liberation, 自訂中文字型 +# - 字型: Noto CJK, Liberation, 標楷體 +# - LaTeX: CJK、德文、法文、阿拉伯語、希伯來語 # -# 📊 Image 大小:約 4-6 GB -# -# 💡 如需完整 65 種 OCR 語言或進階功能,請參考: -# - Dockerfile.full (完整版,使用者自行 build) -# - 文件:docs/docker.md +# 📊 Image 大小:約 5-7 GB # # ============================================================================== @@ -73,14 +69,11 @@ FROM base AS release # ============================================================================== # # ✅ 核心轉換工具:完整保留 -# ✅ TexLive:最小集合(支援 CJK、德文、法文) +# ✅ TexLive:完整 CJK + 德法 + 阿拉伯/希伯來語 # ✅ OCR:7 種主要語言 -# ✅ 字型:Noto CJK + Liberation -# -# ❌ 未內建(體積過大,請參考 Dockerfile.full): -# - texlive-full(約 +3GB) -# - 65 種 OCR 語言(約 +2GB) -# - fonts-noto-extra(約 +500MB) +# ✅ 字型:Noto CJK + Liberation + 標楷體 +# ✅ OpenCV:電腦視覺轉換支援 +# ✅ 額外影片編解碼器 # # ============================================================================== RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -104,17 +97,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ poppler-utils \ potrace \ resvg \ + # === 額外影片編解碼器 === + libavcodec-extra \ # === LibreOffice (headless) === libreoffice \ - # === TexLive 最小集合(取代 texlive-full)=== - # texlive-base: LaTeX 核心 - # texlive-latex-base: 基本 LaTeX 類別 - # texlive-latex-recommended: 常用套件(geometry, hyperref 等) - # texlive-fonts-recommended: 基本字型(Computer Modern 等) - # texlive-xetex: XeTeX 引擎(Unicode/CJK 支援必需) - # texlive-lang-cjk: 中日韓 LaTeX 支援 - # texlive-lang-german: 德文 LaTeX 支援 - # texlive-lang-french: 法文 LaTeX 支援 + # === TexLive 完整語言支援 === texlive-base \ texlive-latex-base \ texlive-latex-recommended \ @@ -123,17 +110,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ texlive-lang-cjk \ texlive-lang-german \ texlive-lang-french \ + texlive-lang-arabic \ + texlive-lang-other \ latexmk \ lmodern \ # === Pandoc 文件轉換 === pandoc \ - # === OCR 支援(僅限指定語言)=== - # eng: 英文 - # chi_tra/chi_sim: 繁/簡中文 - # jpn: 日文 - # kor: 韓文 - # deu: 德文 - # fra: 法文 + # === OCR 支援(7 種語言)=== tesseract-ocr \ tesseract-ocr-eng \ tesseract-ocr-chi-tra \ @@ -142,21 +125,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ tesseract-ocr-kor \ tesseract-ocr-deu \ tesseract-ocr-fra \ - # === 字型(精簡版)=== - # fonts-noto-core: Noto Sans/Serif Latin(歐語基礎) - # fonts-noto-color-emoji: Emoji 支援(僅此一套) - # fonts-liberation: Liberation 字型(Arial/Times 替代) - # ❌ 已移除:fonts-noto-extra(包含過多語言) - # ❌ 已移除:fonts-liberation2(重複) + # === 字型 === fonts-noto-cjk \ fonts-noto-core \ fonts-noto-color-emoji \ fonts-liberation \ - # === Python 依賴(精簡)=== + # === Python 依賴 + OpenCV === python3 \ python3-pip \ python3-numpy \ python3-tinycss2 \ + python3-opencv \ pipx \ # === 系統工具 === locales \ @@ -179,7 +158,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ENV PATH="/root/.local/bin:${PATH}" # ============================================================================== -# 設定 locale(僅限指定語言) +# 設定 locale(支援中文 PDF 避免亂碼) # ============================================================================== RUN sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ sed -i 's/# zh_TW.UTF-8 UTF-8/zh_TW.UTF-8 UTF-8/' /etc/locale.gen && \ @@ -190,8 +169,9 @@ RUN sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ sed -i 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen && \ locale-gen -ENV LANG=en_US.UTF-8 -ENV LC_ALL=en_US.UTF-8 +# 預設使用 zh_TW.UTF-8 確保中文 PDF 正確顯示 +ENV LANG=zh_TW.UTF-8 +ENV LC_ALL=zh_TW.UTF-8 # ============================================================================== # 安裝自訂字型(標楷體等台灣常用字型) @@ -228,8 +208,8 @@ EXPOSE 3000/tcp # ============================================================================== # Calibre 需要 ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox" -# Pandoc PDF 引擎 -ENV PANDOC_PDF_ENGINE=xelatex +# Pandoc PDF 引擎(使用 pdflatex 以獲得最佳相容性) +ENV PANDOC_PDF_ENGINE=pdflatex # Node 環境 ENV NODE_ENV=production diff --git a/compose.yaml b/compose.yaml index fc365e5..a3c36c9 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,13 +3,18 @@ # # 🎉 這是完整版 image,已內建所有轉換依賴: # - LibreOffice (headless) -# - TexLive Full -# - Tesseract OCR + 中日韓英德語言包 -# - CJK 字型(Noto CJK、微軟核心字型、標楷體) -# - Pandoc、FFmpeg、ImageMagick 等所有轉換器 +# - TexLive(CJK + 阿拉伯/希伯來語) +# - Tesseract OCR + 中日韓英德法語言包 +# - CJK 字型(Noto CJK、標楷體) +# - Pandoc、FFmpeg、ImageMagick、OpenCV 等所有轉換器 # # ✅ 使用者不需要自己寫 Dockerfile # ✅ 直接 docker compose up -d 即可使用 +# +# ⚠️ 遠端部署注意事項: +# 若透過 Nginx/Traefik 等 reverse proxy 存取,請設定: +# - HTTP_ALLOWED=true(若 proxy 處理 HTTPS) +# - 或 TRUST_PROXY=true(讓應用正確判斷 HTTPS) # ============================================================================== services: @@ -28,6 +33,7 @@ services: # === 安全設定 === - HTTP_ALLOWED=false # 是否允許非 HTTPS 連線(僅本地測試時設為 true) + - TRUST_PROXY=false # 透過 reverse proxy 時設為 true(正確判斷 HTTPS) - ALLOW_UNAUTHENTICATED=false # 是否允許未登入使用(僅本地測試時設為 true) # === 檔案管理 === diff --git a/package.json b/package.json index 00d1370..e7abb7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "convertx-frontend", - "version": "0.1.6", + "version": "0.1.7", "scripts": { "dev": "bun run --watch src/index.tsx", "hot": "bun run --hot src/index.tsx", diff --git a/src/helpers/env.ts b/src/helpers/env.ts index 9ae232f..313c69b 100644 --- a/src/helpers/env.ts +++ b/src/helpers/env.ts @@ -3,6 +3,9 @@ export const ACCOUNT_REGISTRATION = process.env.ACCOUNT_REGISTRATION?.toLowerCas export const HTTP_ALLOWED = process.env.HTTP_ALLOWED?.toLowerCase() === "true" || false; +// Trust proxy headers (X-Forwarded-*) for correct HTTPS detection behind reverse proxy +export const TRUST_PROXY = process.env.TRUST_PROXY?.toLowerCase() === "true" || false; + export const ALLOW_UNAUTHENTICATED = process.env.ALLOW_UNAUTHENTICATED?.toLowerCase() === "true" || false; diff --git a/src/pages/user.tsx b/src/pages/user.tsx index 2e55194..63d4896 100644 --- a/src/pages/user.tsx +++ b/src/pages/user.tsx @@ -10,12 +10,31 @@ import { ALLOW_UNAUTHENTICATED, HIDE_HISTORY, HTTP_ALLOWED, + TRUST_PROXY, WEBROOT, } from "../helpers/env"; import { localeService } from "../i18n/service"; export let FIRST_RUN = db.query("SELECT * FROM users").get() === null || false; +// ============================================================================== +// Cookie 設定輔助函數 +// ============================================================================== +// 解決遠端部署時登入失敗的問題: +// 1. sameSite: "lax" - 允許導航時傳送 Cookie(strict 會阻擋) +// 2. path: WEBROOT || "/" - 確保 Cookie 覆蓋整個應用 +// 3. secure: 考慮 TRUST_PROXY 設定 +// ============================================================================== +function getCookieOptions() { + return { + httpOnly: true, + secure: !HTTP_ALLOWED && !TRUST_PROXY ? true : false, + maxAge: 60 * 60 * 24 * 7, // 7 days + sameSite: "lax" as const, + path: WEBROOT || "/", + }; +} + export const userService = new Elysia({ name: "user/service" }) .use( jwt({ @@ -224,13 +243,10 @@ export const user = new Elysia() }; } - // set cookie + // set cookie with proper options for remote deployment auth.set({ value: accessToken, - httpOnly: true, - secure: !HTTP_ALLOWED, - maxAge: 60 * 60 * 24 * 7, - sameSite: "strict", + ...getCookieOptions(), }); return redirect(`${WEBROOT}/`, 302); @@ -353,13 +369,10 @@ export const user = new Elysia() }; } - // set cookie + // set cookie with proper options for remote deployment auth.set({ value: accessToken, - httpOnly: true, - secure: !HTTP_ALLOWED, - maxAge: 60 * 60 * 24 * 7, - sameSite: "strict", + ...getCookieOptions(), }); return redirect(`${WEBROOT}/`, 302);