Compare commits

...

32 Commits

Author SHA1 Message Date
kl
257180eb95 fix: refresh ImageIO plugins before PDF conversion 2026-08-11 12:54:50 +08:00
kl
e134689df3 Merge pull request #771 from kekingcn/release/5.0.1
Release v5.0.1
2026-07-13 17:16:27 +08:00
kl
3a08031929 chore(release): prepare v5.0.1 2026-07-13 17:12:40 +08:00
kl
47745e4d74 Merge commit from fork 2026-07-13 16:53:58 +08:00
kl
332a98b6fa Add security policy (#770) 2026-06-29 14:58:29 +08:00
Spencer.Chang
67c6ba3b13 Optimize LuckyExcel xlsx preview conversion with Web Worker (#766)
* Optimize LuckyExcel conversion with worker

* Fallback LuckyExcel worker errors to main thread
2026-06-29 11:20:50 +08:00
addwes7
3e16ed9d3b Add Windows and macOS to CI build matrix and fix cross-platform issues (#768)
* Add Windows and macOS to CI build matrix and fix cross-platform issues

* run nightly e2e on ubuntu and prevent duplicate artifact upload
2026-06-26 11:38:15 +08:00
kl
32a887aa2c fix: protect addTask with trust filters (#767) 2026-06-24 14:19:20 +08:00
gaoxingzaq
1f60e30f09 优化:区分 HTTP 错误,返回明确原因 (#752)
* 优化:区分 HTTP 错误,返回明确原因

* 修复 缓存关闭共享的 client,会导致后续请求失败

* 修复 缓存关闭共享的 client,会导致后续请求失败

---------

Co-authored-by: 高雄 <admin@cxcp.com>
2026-05-09 15:04:25 +08:00
Lanwood
4474ab1d57 fix(xlsx): 修复 LuckyExcel 解析数据校验时 matchType 未映射导致的崩溃 (#730)
* fix(xlsx): 修复 LuckyExcel 解析数据校验时 matchType 未映射导致的崩溃

* fix(xlsx): improve matchType handling in data verification logic

* fix(xlsx): simplify matchType mapping logic in LuckySheet class

---------

Co-authored-by: 何武德 <hewude@ruijie.com.cn>
2026-05-09 15:03:26 +08:00
kl
fd78fe9a6e test/docs: adjust PDF sidebar config test for conditional default (#756) 2026-04-30 18:50:39 +08:00
kl
cdce432740 feat: make pdf sidebar default open configurable (#755) 2026-04-30 18:36:40 +08:00
陈精华
4ea1d7468a Merge pull request #746 from gaoxingzaq/pdfjs2
pdf 添加跨域功能 修复pdf 页码和高亮没启用bug
2026-04-29 14:22:00 +08:00
高雄
4cf19d1dbe 优化结构 去掉JQ脚本 内置水印脚本 2026-04-25 08:45:22 +08:00
高雄
3abf864184 修复 pdf无法打印问题 修复pdf打印添加水印问题 2026-04-24 16:42:19 +08:00
陈精华
634babfba4 Merge pull request #751 from gaoxingzaq/redis22
修复redis报错
2026-04-21 19:06:55 +08:00
高雄
e7fe1afe19 修复:1、redis报错、统一了所有模式(单机、集群、主从、哨兵)的配置参数:都设置了 retryAttempts, retryInterval, timeout, connectTimeout, idleConnectionTimeout, 连接池大小等。3、地址自动补齐协议前缀:normalizeAddress() 方法自动添加 redis://,用户配置可以省略, 其他等等。 2026-04-21 14:08:16 +08:00
高雄
cd2abb4be1 修复反代后 绝对路径错误 2026-04-17 17:37:03 +08:00
高雄
dd803126dd 修复反代后 绝对路径错误 2026-04-16 17:32:09 +08:00
高雄
633e47b765 修复反代后 绝对路径错误 2026-04-16 17:26:41 +08:00
高雄
c52d80c123 修复水印和高亮 特殊符号会导致解析失败问题 2026-04-16 11:21:59 +08:00
高雄
ee2a27501b pdf 添加跨域功能 修复pdf 页码和高亮没启用bug 2026-04-15 14:40:41 +08:00
kl
171762d676 Merge pull request #740 from kekingcn/release/5.0.0
Release 5.0.0
2026-04-14 09:13:51 +08:00
kl
76e091900b Complete 5.0.0 release notes from v4.4.0 diff 2026-04-14 09:07:18 +08:00
kl
bfa4ceab90 Document 5.0.0 default config changes 2026-04-14 09:04:43 +08:00
kl
b18cfa797a Align release record page with 5.0.0 2026-04-14 09:02:29 +08:00
kl
8a117a41e8 Merge v5.0 notes into 5.0.0 release notes 2026-04-14 09:00:11 +08:00
kl
17ba41320e Prepare 5.0.0 release 2026-04-14 08:57:01 +08:00
kl
476c0bfefc Merge pull request #739 from kekingcn/paseo/ai-docs
Add AI-friendly repository guide
2026-04-14 08:13:52 +08:00
kl
1c6691d785 Clarify config defaults in AGENTS guide 2026-04-14 08:06:52 +08:00
kl
36ae290cb6 Add AI-friendly repository guide 2026-04-14 07:54:42 +08:00
kl
597715ce33 Merge pull request #738 from kekingcn/paseo/kkfileview
Refine archive preview and PDF defaults
2026-04-13 21:09:42 +08:00
38 changed files with 1391 additions and 500 deletions

View File

@@ -11,7 +11,7 @@ on:
jobs:
build:
runs-on: ubuntu-22.04
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
@@ -33,10 +33,10 @@ jobs:
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B package -Dmaven.test.skip=true --file pom.xml
run: mvn -B package "-Dmaven.test.skip=true" --file pom.xml
- name: Upload Linux distribution package
if: success()
if: success() && runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: kkfileview-linux
@@ -44,9 +44,12 @@ jobs:
retention-days: 7
- name: Upload Windows distribution package
if: success()
if: success() && runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: kkfileview-windows
path: server/target/*.zip
retention-days: 7
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]

230
AGENTS.md Normal file
View File

@@ -0,0 +1,230 @@
# AGENTS.md
This document is for coding agents and automation tools working in this repository.
## Project Overview
- Project: `kkFileView`
- Stack: Spring Boot + Freemarker + Redis/Redisson (optional) + JODConverter + front-end preview pages
- Main module: `server`
- Default local URL: `http://127.0.0.1:8012/`
- Production demo: `https://file.kkview.cn/`
This repository is a document preview service. Most user-facing work falls into one of these areas:
1. preview routing and file-type dispatch
2. conversion pipelines for Office / PDF / CAD / archives / images
3. Freemarker preview templates under `server/src/main/resources/web`
4. CI, E2E fixtures, and production deployment automation
## Repository Layout
- `server/`
Main application code, templates, config, packaged artifacts
- `server/src/main/java/cn/keking/`
Core Java application code
- `server/src/main/resources/web/`
Freemarker preview templates
- `server/src/main/resources/static/`
Front-end static assets used by preview pages
- `server/src/main/config/`
Main runtime config files
- `server/src/main/bin/`
Local startup/dev scripts
- `tests/e2e/`
Playwright-based end-to-end tests and fixtures
- `.github/workflows/`
CI and deployment workflows
- `.github/scripts/`
Windows production deployment scripts over WinRM
## Key Entry Points
- App entry:
- `server/src/main/java/cn/keking/ServerMain.java`
- Preview controller:
- `server/src/main/java/cn/keking/web/controller/OnlinePreviewController.java`
- File attribute parsing / request handling:
- `server/src/main/java/cn/keking/service/FileHandlerService.java`
- Office preview flow:
- `server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java`
- PDF preview flow:
- `server/src/main/java/cn/keking/service/impl/PdfFilePreviewImpl.java`
- Archive extraction:
- `server/src/main/java/cn/keking/service/CompressFileReader.java`
## Important Templates
- `server/src/main/resources/web/compress.ftl`
Archive directory/tree preview page
- `server/src/main/resources/web/pdf.ftl`
PDF preview container page
- `server/src/main/resources/web/picture.ftl`
Single image preview page
- `server/src/main/resources/web/officePicture.ftl`
Office/PDF image-mode preview page
- `server/src/main/resources/web/officeweb.ftl`
Front-end xlsx/html preview page
When debugging UX issues, inspect the exact template selected by the preview flow first. Do not assume two similar preview pages share the same CSS or behavior.
## Local Development
### Recommended dev mode
Use:
```bash
./server/src/main/bin/dev.sh
```
This runs Spring Boot with resource hot reload using:
- `spring-boot:run`
- `-Dspring-boot.run.addResources=true`
- `server/src/main/config/application.properties`
For front-end template or CSS/JS edits, prefer `dev.sh` over rebuilding jars repeatedly.
### Jar build
```bash
mvn -q -pl server -DskipTests package
```
### Main test command used in CI
```bash
mvn -B package -Dmaven.test.skip=true --file pom.xml
```
## Configuration Notes
Primary runtime config used by the scripts and defaults committed in this repository:
- `server/src/main/config/application.properties`
Optional environment-specific config:
- `server/src/main/config/test.properties`
Be careful: the repository defaults point at `application.properties`. If a deployment environment explicitly starts the app with `test.properties`, treat that as an environment-specific override rather than the repository default. Always verify the actual startup command before assuming which config file is active.
Examples of config that commonly affects behavior:
- `office.preview.type`
- `office.preview.switch.disabled`
- `trust.host`
- `not.trust.host`
- `file.upload.disable`
## Preview Behavior Notes
- Office files can render in `pdf` mode or `image` mode.
- PDF preview uses `pdf.ftl`.
- Single images use `picture.ftl`.
- Office image-mode previews use `officePicture.ftl`.
- Archive previews are not simple file lists; they can load nested previews via the archive UI in `compress.ftl`.
When changing preview defaults, verify both:
1. server-side default config
2. front-end mode-switch links/buttons
## Archive Preview Notes
Archive preview is a sensitive area because it combines:
- directory tree generation
- extraction to disk
- nested preview URL construction
- inline iframe loading
If an archive-contained Office file gets stuck on loading:
1. verify the extracted file on disk is not corrupted
2. verify conversion output exists
3. verify the preview template points to the correct generated artifact
4. verify the running Office manager / LibreOffice process is healthy
Do not assume loading forever is a front-end issue.
## Testing
### Targeted Java tests
Example targeted test:
```bash
mvn -q -pl server -Dtest=PdfViewerCompatibilityTests test
```
### E2E tests
See:
- `tests/e2e/README.md`
PR E2E currently covers:
- common preview smoke tests
- Office smoke tests
- archive smoke tests
- basic security and performance checks
## CI / Deployment
### CI
- `maven.yml`
- builds on `push` to `master`
- builds on PRs targeting `master`
- `pr-e2e-mvp.yml`
- runs E2E on PRs to `master`
### Production deployment
- `master-auto-deploy.yml`
- triggers on push to `master`
- deploys to Windows over WinRM
Deployment script:
- `.github/scripts/remote_windows_deploy.ps1`
Important operational detail:
- the committed `bin/startup.bat` in this repo points at `..\config\application.properties`
- if production uses a different config file, treat that as an out-of-repo server override rather than a repository default
If a production config change does not take effect, inspect the actual startup command or deployed `startup.bat` on the server first and verify which config file path it is using.
## Working Conventions For Agents
- Prefer minimal, targeted changes over wide refactors.
- Inspect the active preview template before editing CSS.
- Verify whether behavior is controlled by config, back-end routing, or front-end template logic before changing code.
- For production/debug tasks, distinguish clearly between:
- repository source defaults
- deployed server config
- runtime process arguments
- When changing defaults, mention whether the change affects:
- local dev only
- repository default config
- deployed server config
- existing query-param overrides
## Suggested Validation Checklist
For preview-related changes, validate as many of these as apply:
1. target URL returns `200`
2. selected template is the expected one
3. generated intermediate artifacts exist when required
4. target UI element or style change is actually present in rendered HTML
5. targeted Java test passes
6. relevant E2E path is still compatible
## Non-Goals
This file is not a replacement for user-facing product documentation. Keep it focused on helping coding agents navigate the codebase and make correct changes faster.

View File

@@ -1,4 +1,4 @@
FROM keking/kkfileview-base:4.4.0
FROM keking/kkfileview-base:5.0.0
ADD server/target/kkFileView-*.tar.gz /opt/
ENV KKFILEVIEW_BIN_FOLDER=/opt/kkFileView-4.4.0/bin
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-4.4.0/config/application.properties","-jar","/opt/kkFileView-4.4.0/bin/kkFileView-4.4.0.jar"]
ENV KKFILEVIEW_BIN_FOLDER=/opt/kkFileView-5.0.1/bin
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-5.0.1/config/application.properties","-jar","/opt/kkFileView-5.0.1/bin/kkFileView-5.0.1.jar"]

View File

@@ -149,7 +149,30 @@ pdf预览模式预览效果如下
### 历史更新记录
#### > 2026年01月20v5.0 版本发布
#### > 2026年07月13v5.0.1 补丁版本发布
#### 安全修复
1. 修复 `/addTask` 未经过信任主机和本地目录过滤可能导致服务端请求伪造SSRF的问题GHSA-gwwj-52hv-6g2m
2. 修复 `/listFiles` `directory` 参数可越出演示目录造成路径遍历和目录信息泄露的问题GHSA-pmp8-g8p2-p6jq
#### 修复问题
1. 修复 PDF 跨域页码定位文本高亮打印和打印水印相关问题
2. 修复 PDF 在反向代理场景下的绝对路径问题以及水印和高亮内容包含特殊字符时的解析失败
3. 修复 Redis 单机集群主从哨兵模式配置不一致和地址协议缺失问题
4. 修复下载 MIME 类型校验失败后仍返回成功HTTP 错误原因不明确以及共享 HTTP Client 被错误关闭的问题
5. 修复 LuckyExcel 数据校验类型未映射时的 xlsx 解析崩溃
#### 优化内容
1. 大型 xlsx 文件改用 Web Worker 执行 LuckyExcel 解析并在 Worker 不可用或异常时自动回退主线程
2. 新增 `pdf.sidebar.open` 配置可控制 PDF 预览是否默认打开侧栏
3. Maven CI 增加 LinuxWindowsmacOS 构建验证
4. 新增仓库安全策略和私密漏洞报告入口
#### 升级说明
1. 建议所有 v5.0.0 及更早版本用户尽快升级到 v5.0.1
2. 本版本继续要求 JDK 21 及以上现有 v5.0.0 配置可直接沿用
#### > 2026年04月14日v5.0.0 版本发布
#### 优化内容
1. xlsx 前端解析优化 - 提升Excel文件前端渲染性能
2. 图片解析优化 - 改进图片处理机制
@@ -159,6 +182,10 @@ pdf预览模式预览效果如下
6. ftp多客户端接入优化 - 提升FTP服务兼容性
7. 首页目录访问优化 - 采用post服务端分页机制
8. marked 解析优化 - 改进Markdown渲染
9. 压缩包预览页重构为单工作区布局支持目录折叠与右侧内嵌预览
10. 优化压缩包内文件类型标识以及单图预览页的展示样式
11. 补充面向工程自动化与编码代理的仓库说明文档
12. 重构演示门户页面包括首页接入说明版本记录与赞助页
#### 新增功能
1. msg邮件解析 - 新增msg格式邮件文件预览支持
@@ -179,6 +206,12 @@ pdf预览模式预览效果如下
2. 安全问题 - 修复安全漏洞
3. 图片水印不全问题 - 修复水印显示不完整
4. SSL自签证书接入问题 - 修复自签名证书兼容性
5. 修复压缩包内 Office 文件在重复解压后被追加写坏导致一直卡在加载中的问题
6. Office 默认预览改为 PDF 模式 PDF 预览默认打开缩略图侧栏
7. 启动脚本改为自动发现当前发布包中的 jar移除过时的硬编码 jar 名称
8. 更新 Docker 与发布辅助文档使其与 5.0.0 发布线保持一致
9. 修复 OFD 表格竖线溢出导致的渲染异常
10. 修复 PDF.js 兼容性补丁避免兼容环境下的预览报错
#### 更新内容
1. JDK版本要求 - 强制要求JDK 21及以上版本
@@ -189,6 +222,8 @@ pdf预览模式预览效果如下
6. tif后端异步转换优化 - 实现多线程异步转换
7. 视频后端异步转换优化 - 实现多线程异步转换
8. CAD后端异步转换优化 - 实现多线程异步转换
9. 默认预览配置策略调整 - Office 预览默认切换为 PDF 模式默认隐藏图片/PDF 模式切换按钮 PDF 预览默认展开缩略图侧栏若升级后仍需保持旧的图片优先体验请显式设置 `office.preview.type=image` `office.preview.switch.disabled=false`
10. 信任域名配置匹配策略扩展 - `trust.host` 及相关规则现已支持通配符和 CIDR 匹配升级后如果你依赖域名/IP 模式匹配需要重新检查白名单和黑名单的实际生效范围
#### > 2025年01月16日v4.4.0 版本发布
@@ -468,4 +503,3 @@ dcm医疗数位影像 引用于 [dcmjs](https://github.com/dcmjs-org/dcmjs )开
- 本项目诞生于[凯京集团]在取得公司高层同意后以 Apache 协议开源出来反哺社区在此特别感谢凯京集团以及集团领导[@唐老大](https://github.com/tangshd)的支持、@端木详笑的贡献。
- 本项目已脱离公司由[KK开源社区]维护发展壮大感谢所有给 kkFileView Issue Pr 开发者
- 本项目引入的第三方组件已在 '关于引用' 列表列出感谢这些项目 kkFileView 更出色

View File

@@ -65,9 +65,32 @@ URL[https://file.kkview.cn](https://file.kkview.cn)
## Change History
### Version 5.0 (January 20, 2026)
### Version 5.0.1 (July 13, 2026)
#### Optimizations
#### Security Fixes
1. Fixed `/addTask` bypassing trusted-host and local-directory filters, which could allow server-side request forgery (SSRF) (GHSA-gwwj-52hv-6g2m)
2. Fixed the `/listFiles` `directory` parameter escaping the demo directory, which could allow path traversal and directory information disclosure (GHSA-pmp8-g8p2-p6jq)
#### Fixes
1. Fixed PDF cross-origin access, page positioning, text highlighting, printing, and print watermark issues
2. Fixed PDF absolute paths behind reverse proxies and parsing failures when watermark or highlight text contains special characters
3. Fixed inconsistent Redis settings across standalone, cluster, master-replica, and sentinel modes, including missing address protocols
4. Fixed successful responses after MIME validation failures, unclear HTTP error reporting, and accidental closure of a shared HTTP client
5. Fixed xlsx parsing crashes when LuckyExcel data-validation types have no mapping
#### Improvements
1. Moved LuckyExcel parsing for large xlsx files into a Web Worker, with automatic main-thread fallback when the Worker is unavailable or fails
2. Added `pdf.sidebar.open` to control whether the PDF sidebar opens by default
3. Added Linux, Windows, and macOS validation to Maven CI
4. Added a repository security policy and private vulnerability reporting guidance
#### Upgrade Notes
1. All users running v5.0.0 or earlier are strongly encouraged to upgrade to v5.0.1
2. JDK 21 or higher remains required, and existing v5.0.0 configuration can be reused
### Version 5.0.0 (April 14, 2026)
#### Improvements
1. Enhanced xlsx front-end parsing - Improved Excel file front-end rendering performance
2. Optimized image parsing - Enhanced image processing mechanism
3. Improved tif parsing - Enhanced TIF format support
@@ -76,6 +99,10 @@ URL[https://file.kkview.cn](https://file.kkview.cn)
6. Optimized ftp multi-client access - Improved FTP service compatibility
7. Enhanced home page directory access - Implemented post server-side pagination mechanism
8. Improved marked parsing - Enhanced Markdown rendering
9. Redesigned archive preview into a single workspace with a collapsible tree and inline file preview
10. Improved archive preview file-type badges and single-image preview styling
11. Added an agent-focused repository guide for engineering automation and maintenance
12. Refreshed the demo portal pages, including the index, integration guide, release record, and sponsor pages
#### New Features
1. msg email parsing - Added support for msg format email file preview
@@ -96,6 +123,12 @@ URL[https://file.kkview.cn](https://file.kkview.cn)
2. Security issues - Fixed security vulnerabilities
3. Incomplete image watermark issues - Fixed incomplete watermark display
4. SSL self-signed certificate access issues - Fixed compatibility with self-signed certificates
5. Fixed archive-contained Office files that could stay stuck on loading because repeated extraction appended to existing files
6. Default Office preview now prefers PDF mode, and PDF preview opens with the thumbnail sidebar visible by default
7. Updated startup scripts to discover the packaged jar dynamically instead of relying on stale hard-coded jar names
8. Updated Docker and release helper docs to align with the 5.0.0 release line
9. Fixed OFD table border overflow rendering issues
10. Refined the PDF.js compatibility polyfill to avoid preview errors in compatibility environments
#### Updates
1. JDK version requirement - Mandatory requirement for JDK 21 or higher
@@ -106,6 +139,8 @@ URL[https://file.kkview.cn](https://file.kkview.cn)
6. tif backend async conversion optimization - Implemented multi-threaded asynchronous conversion
7. Video backend async conversion optimization - Implemented multi-threaded asynchronous conversion
8. CAD backend async conversion optimization - Implemented multi-threaded asynchronous conversion
9. Default preview configuration strategy adjusted - Office preview now defaults to PDF mode, the mode switch is hidden by default, and PDF preview opens with the thumbnail sidebar visible. If you need the previous image-first behavior after upgrade, explicitly set `office.preview.type=image` and `office.preview.switch.disabled=false`.
10. Trust host configuration matching expanded - `trust.host` and related rules now support wildcard and CIDR matching, which may broaden or narrow effective allow/deny behavior after upgrade depending on your patterns
### Version 4.4.0 (January 16, 2025)

66
SECURITY.md Normal file
View File

@@ -0,0 +1,66 @@
# Security Policy
## Supported Versions
Security fixes are handled for the latest released version of kkFileView and the
current `master` branch. Older versions may be evaluated case by case, but users
are encouraged to upgrade to the latest release before reporting or verifying a
security issue.
## Reporting a Vulnerability
Please report security vulnerabilities privately through GitHub Private
Vulnerability Reporting:
https://github.com/kekingcn/kkFileView/security/advisories/new
Do not publish vulnerability details, proof-of-concept code, exploit steps,
sensitive logs, or private deployment information in public GitHub issues,
discussions, pull requests, or comments.
When reporting a vulnerability, please include as much of the following
information as you can safely share:
- Affected kkFileView version or commit
- Deployment mode, operating system, JDK version, and related middleware
- Clear reproduction steps
- Impact assessment and affected feature or endpoint
- Sanitized logs, screenshots, or sample files if they are required to reproduce
the issue
- Whether the issue is already being disclosed elsewhere
The maintainers will review private reports, ask for additional information when
needed, coordinate a fix, and publish disclosure information when appropriate.
If the private reporting link is unavailable, please open a public issue only to
request a private contact channel, without including technical vulnerability
details.
---
# 安全策略
## 支持版本
kkFileView 安全修复主要覆盖最新发布版本和当前 `master` 分支旧版本问题会视影响范围和维护成本单独评估但建议用户优先升级到最新版本后再验证或报告安全问题
## 报告安全漏洞
请通过 GitHub Private Vulnerability Reporting 私密提交安全漏洞
https://github.com/kekingcn/kkFileView/security/advisories/new
请不要在公开 GitHub issuediscussionpull request 或评论中发布漏洞细节PoC利用步骤敏感日志或私有部署信息
提交漏洞时请在可安全分享的前提下尽量提供以下信息
- 受影响的 kkFileView 版本或提交
- 部署方式操作系统JDK 版本和相关中间件信息
- 清晰的复现步骤
- 影响范围以及受影响的功能或接口
- 复现所需的脱敏日志截图或样例文件
- 该问题是否已在其他渠道披露
维护者会在私密渠道中评估报告在需要时继续确认细节协调修复并在适当时发布披露信息
如果私密报告链接不可用请只在公开 issue 中请求私密联系方式不要包含任何技术漏洞细节

View File

@@ -3,7 +3,7 @@
当前线上 Windows 服务器的实际部署信息如下
- 部署根目录`C:\kkFileView-5.0`
- 运行 jar`C:\kkFileView-5.0\bin\kkFileView-5.0.jar`
- 运行 jar`C:\kkFileView-5.0\bin\kkFileView-<当前项目版本>.jar`
- 启动脚本`C:\kkFileView-5.0\bin\startup.bat`
- 运行配置`C:\kkFileView-5.0\config\test.properties`
- 健康检查地址`http://127.0.0.1:8012/`

View File

@@ -7,10 +7,10 @@
然后使用 kkfileview-base 作为基础镜像进行构建加快 kkfileview docker 镜像构建与发布
执行如下命令即可构建基础镜像
> 这里镜像 tag 4.4.0 为例本项目所维护的 Dockerfile 文件考虑了跨平台兼容性 如果你需要用到 arm64 架构镜像, 则在arm64 架构机器上同样执行下面的构建命令即可
> 这里镜像 tag 5.0.0 为例本项目所维护的 Dockerfile 文件考虑了跨平台兼容性 如果你需要用到 arm64 架构镜像, 则在arm64 架构机器上同样执行下面的构建命令即可
```shell
docker build --tag keking/kkfileview-base:4.4.0 .
docker build --tag keking/kkfileview-base:5.0.0 .
```
@@ -46,5 +46,5 @@ docker build --tag keking/kkfileview-base:4.4.0 .
现在就可以愉快地开始构建了构建命令示例:
```shell
docker buildx build --platform=linux/amd64,linux/arm64 -t keking/kkfileview-base:4.4.0 --push .
docker buildx build --platform=linux/amd64,linux/arm64 -t keking/kkfileview-base:5.0.0 --push .
```

View File

@@ -8,10 +8,10 @@ Then, use kkfileview-base as the base image to build and speed up the kkfileview
To build the base image, run the following command:
> In this example, the image tag is 4.4.0. The Dockerfile maintained in this project considers cross-platform compatibility. If you need an arm64 architecture image, run the same build command on an arm64 architecture machine.
> In this example, the image tag is 5.0.0. The Dockerfile maintained in this project considers cross-platform compatibility. If you need an arm64 architecture image, run the same build command on an arm64 architecture machine.
```shell
docker build --tag keking/kkfileview-base:4.4.0 .
docker build --tag keking/kkfileview-base:5.0.0 .
```
@@ -49,5 +49,5 @@ Assuming the current machine is amd64 (x86_64) architecture, you'll need to enab
Now you can enjoy the building. Heres an example build command:
```shell
docker buildx build --platform=linux/amd64,linux/arm64 -t keking/kkfileview-base:4.4.0 --push .
docker buildx build --platform=linux/amd64,linux/arm64 -t keking/kkfileview-base:5.0.0 --push .
```

View File

@@ -6,7 +6,7 @@
<groupId>cn.keking</groupId>
<artifactId>kkFileView-parent</artifactId>
<version>5.0</version>
<version>5.0.1</version>
<properties>
<!-- ========== Java 和编译配置 ========== -->

View File

@@ -6,7 +6,7 @@
<parent>
<artifactId>kkFileView-parent</artifactId>
<groupId>cn.keking</groupId>
<version>5.0</version>
<version>5.0.1</version>
</parent>
<artifactId>kkFileView</artifactId>

View File

@@ -1,10 +1,20 @@
@echo off
set "KKFILEVIEW_BIN_FOLDER=%cd%"
cd "%KKFILEVIEW_BIN_FOLDER%"
set "JAR_NAME="
for %%F in (kkFileView-*.jar) do (
set "JAR_NAME=%%~nxF"
goto :jar_found
)
echo Error: kkFileView jar not found in %KKFILEVIEW_BIN_FOLDER%
exit /b 1
:jar_found
echo Using KKFILEVIEW_BIN_FOLDER %KKFILEVIEW_BIN_FOLDER%
echo Using JAR_NAME %JAR_NAME%
echo Starting kkFileView...
echo Please check log file in ../log/kkFileView.log for more information
echo You can get help in our official home site: https://kkview.cn
echo If you need further help, please join our kk opensource community: https://t.zsxq.com/09ZHSXbsQ
echo If this project is helpful to you, please star it on https://gitee.com/kekingcn/file-online-preview/stargazers
java -Dspring.config.location=..\config\application.properties -jar kkFileView-4.4.0.jar -> ..\log\kkFileView.log
java -Dspring.config.location=..\config\application.properties -jar "%JAR_NAME%" > ..\log\kkFileView.log 2>&1

View File

@@ -49,9 +49,16 @@ else
fi
fi
JAR_PATH=$(ls kkFileView-*.jar 2>/dev/null | head -n 1)
if [ -z "${JAR_PATH}" ]; then
echo "kkFileView jar not found in ${KKFILEVIEW_BIN_FOLDER}"
exit 1
fi
## 启动kkFileView
echo "Starting kkFileView..."
nohup java -Dfile.encoding=UTF-8 -Dspring.config.location=../config/application.properties -jar kkFileView-4.4.0.jar > ../log/kkFileView.log 2>&1 &
echo "Using jar ${JAR_PATH}"
nohup java -Dfile.encoding=UTF-8 -Dspring.config.location=../config/application.properties -jar "${JAR_PATH}" > ../log/kkFileView.log 2>&1 &
echo "Please execute ./showlog.sh to check log for more information"
echo "You can get help in our official home site: https://kkview.cn"
echo "If you need further help, please join our kk opensource community: https://t.zsxq.com/09ZHSXbsQ"

View File

@@ -96,11 +96,11 @@ office.documentopenpasswords = ${KK_OFFICE_DOCUMENTOPENPASSWORD:true}
office.type.web = ${KK_OFFICE_TYPE_WEB:web}
# Office文档预览类型
# 支持动态配置可选值image/pdf
# 支持动态配置可选值image/pdf默认使用pdf模式
office.preview.type = ${KK_OFFICE_PREVIEW_TYPE:pdf}
# 是否关闭Office预览模式切换开关默认为false允许切换
# 设置为true时用户无法在图片和PDF模式间切换
# 是否关闭Office预览模式切换开关默认为true关闭切换
# 设置为false时用户可以在图片和PDF模式间切换
office.preview.switch.disabled = ${KK_OFFICE_PREVIEW_SWITCH_DISABLED:true}
@@ -155,6 +155,9 @@ pdf.bookmark.disable = ${KK_PDF_BOOKMARK_DISABLE:true}
# 是否禁止PDF编辑功能注释表单等默认为false允许编辑
pdf.disable.editing = ${KK_PDF_DISABLE_EDITING:false}
# 是否默认打开PDF侧边栏缩略图面板默认为true打开
pdf.sidebar.open = ${KK_PDF_SIDEBAR_OPEN:true}
# PDF处理最大线程数控制并发处理能力
pdf.max.threads = 10

View File

@@ -77,6 +77,7 @@ public class ConfigConstants {
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
public static final String DEFAULT_PDF_BOOKMARK_DISABLE = "true";
public static final String DEFAULT_PDF_DISABLE_EDITING = "true";
public static final String DEFAULT_PDF_SIDEBAR_OPEN = "true";
public static final String DEFAULT_PDF2_JPG_DPI = "105";
public static final String DEFAULT_PDF_SMALL_DTI = "150";
public static final String DEFAULT_PDF_MEDIUM_DPI = "120";
@@ -194,6 +195,7 @@ public class ConfigConstants {
private static String pdfPrintDisable;
private static String pdfDownloadDisable;
private static String pdfBookmarkDisable;
private static String pdfSidebarOpen;
private static int pdf2JpgDpi;
private static boolean pdfDpiEnabled;
private static int pdfSmallDpi;
@@ -336,6 +338,7 @@ public class ConfigConstants {
public static String getPdfDownloadDisable() { return pdfDownloadDisable; }
public static String getPdfBookmarkDisable() { return pdfBookmarkDisable; }
public static String getPdfDisableEditing() { return pdfDisableEditing; }
public static String getPdfSidebarOpen() { return pdfSidebarOpen; }
public static int getPdf2JpgDpi() { return pdf2JpgDpi; }
public static int getPdfTimeoutSmall() { return pdfTimeoutSmall; }
public static int getPdfTimeoutMedium() { return pdfTimeoutMedium; }
@@ -563,6 +566,10 @@ public class ConfigConstants {
public void setpdfDisableEditing(String pdfDisableEditing) { setPdfDisableEditingValue(pdfDisableEditing); }
public static void setPdfDisableEditingValue(String pdfDisableEditing) { ConfigConstants.pdfDisableEditing = pdfDisableEditing; }
@Value("${pdf.sidebar.open:true}")
public void setPdfSidebarOpen(String pdfSidebarOpen) { setPdfSidebarOpenValue(pdfSidebarOpen); }
public static void setPdfSidebarOpenValue(String pdfSidebarOpen) { ConfigConstants.pdfSidebarOpen = pdfSidebarOpen; }
@Value("${pdf2jpg.dpi:105}")
public void pdf2JpgDpi(int pdf2JpgDpi) { setPdf2JpgDpiValue(pdf2JpgDpi); }
public static void setPdf2JpgDpiValue(int pdf2JpgDpi) { ConfigConstants.pdf2JpgDpi = pdf2JpgDpi; }

View File

@@ -181,6 +181,7 @@ public class ConfigRefreshComponent {
ConfigConstants.setPdfDownloadDisableValue(getProperty(properties, "pdf.download.disable", ConfigConstants.DEFAULT_PDF_DOWNLOAD_DISABLE));
ConfigConstants.setPdfBookmarkDisableValue(getProperty(properties, "pdf.bookmark.disable", ConfigConstants.DEFAULT_PDF_BOOKMARK_DISABLE));
ConfigConstants.setPdfDisableEditingValue(getProperty(properties, "pdf.disable.editing", ConfigConstants.DEFAULT_PDF_DISABLE_EDITING));
ConfigConstants.setPdfSidebarOpenValue(getProperty(properties, "pdf.sidebar.open", ConfigConstants.DEFAULT_PDF_SIDEBAR_OPEN));
ConfigConstants.setPdf2JpgDpiValue(Integer.parseInt(getProperty(properties, "pdf2jpg.dpi", ConfigConstants.DEFAULT_PDF2_JPG_DPI)));
// 8. CAD配置

View File

@@ -1,6 +1,5 @@
package cn.keking.config;
import io.netty.channel.nio.NioEventLoopGroup;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
@@ -13,8 +12,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.util.ClassUtils;
/**
* Redisson 客户端配置
* Created by kl on 2017/09/26.
* Redisson 客户端配置(完善版)
* 支持 single / cluster / master-slave / sentinel 四种模式,配置完整,统一参数。
*/
@ConditionalOnExpression("'${cache.type:default}'.equals('redis')")
@ConfigurationProperties(prefix = "spring.redisson")
@@ -22,114 +21,71 @@ import org.springframework.util.ClassUtils;
public class RedissonConfig {
// ========================== 连接配置 ==========================
private static String address;
private static String password;
private static String clientName;
private static int database = 0;
private static String mode = "single";
private static String masterName = "kkfile";
private String address;
private String password;
private String clientName;
private int database = 0;
private String mode = "single";
private String masterName = "kkfile";
// ========================== 超时配置 ==========================
private static int idleConnectionTimeout = 10000;
private static int connectTimeout = 10000;
private static int timeout = 3000;
private int idleConnectionTimeout = 10000;
private int connectTimeout = 10000;
private int timeout = 3000;
// ========================== 重试配置 ==========================
private static int retryAttempts = 3;
private static int retryInterval = 1500;
private int retryAttempts = 3;
private int retryInterval = 1500;
// ========================== 连接池配置 ==========================
private static int connectionMinimumIdleSize = 10;
private static int connectionPoolSize = 64;
private static int subscriptionsPerConnection = 5;
private static int subscriptionConnectionMinimumIdleSize = 1;
private static int subscriptionConnectionPoolSize = 50;
private int connectionMinimumIdleSize = 10;
private int connectionPoolSize = 64;
private int subscriptionsPerConnection = 5;
private int subscriptionConnectionMinimumIdleSize = 1;
private int subscriptionConnectionPoolSize = 50;
// ========================== 集群专用配置 ==========================
private int scanInterval = 2000;
// ========================== 其他配置 ==========================
private static int dnsMonitoringInterval = 5000;
private static int thread; // 当前处理核数 * 2
private static String codec = "org.redisson.codec.JsonJacksonCodec";
private int dnsMonitoringInterval = 5000;
private int threads; // 默认为0表示使用 CPU 核数 * 2
private String codec = "org.redisson.codec.JsonJacksonCodec";
@Bean
public static RedissonClient config() throws Exception {
public RedissonClient redissonClient() {
Config config = new Config();
// 密码处理
if (StringUtils.isBlank(password)) {
password = null;
}
// 密码处理:空字符串转为 null
String pwd = StringUtils.isBlank(password) ? null : password;
// 根据模式创建对应的 Redisson 配置
switch (mode) {
// 根据模式构建配置
switch (mode.toLowerCase()) {
case "cluster":
configureClusterMode(config);
configureClusterMode(config, pwd);
break;
case "master-slave":
configureMasterSlaveMode(config);
configureMasterSlaveMode(config, pwd);
break;
case "sentinel":
configureSentinelMode(config);
configureSentinelMode(config, pwd);
break;
default:
configureSingleMode(config);
configureSingleMode(config, pwd);
break;
}
// 公共配置:编码器、线程数
applyCommonConfig(config);
return Redisson.create(config);
}
// ========================== 配置方法 ==========================
/**
* 配置集群模式
*/
private static void configureClusterMode(Config config) {
String[] clusterAddresses = address.split(",");
config.useClusterServers()
.setScanInterval(2000)
.addNodeAddress(clusterAddresses)
.setPassword(password)
.setRetryAttempts(retryAttempts)
.setTimeout(timeout)
.setMasterConnectionPoolSize(100)
.setSlaveConnectionPoolSize(100);
}
/**
* 配置主从模式
*/
private static void configureMasterSlaveMode(Config config) {
String[] masterSlaveAddresses = address.split(",");
validateMasterSlaveAddresses(masterSlaveAddresses);
String[] slaveAddresses = new String[masterSlaveAddresses.length - 1];
System.arraycopy(masterSlaveAddresses, 1, slaveAddresses, 0, slaveAddresses.length);
config.useMasterSlaveServers()
.setDatabase(database)
.setPassword(password)
.setMasterAddress(masterSlaveAddresses[0])
.addSlaveAddress(slaveAddresses);
}
/**
* 配置哨兵模式
*/
private static void configureSentinelMode(Config config) {
String[] sentinelAddresses = address.split(",");
config.useSentinelServers()
.setDatabase(database)
.setPassword(password)
.setMasterName(masterName)
.addSentinelAddress(sentinelAddresses);
}
/**
* 配置单机模式
*/
private static void configureSingleMode(Config config) throws Exception {
private void configureSingleMode(Config config, String pwd) {
String normalizedAddress = normalizeAddress(address);
config.useSingleServer()
.setAddress(address)
.setAddress(normalizedAddress)
.setConnectionMinimumIdleSize(connectionMinimumIdleSize)
.setConnectionPoolSize(connectionPoolSize)
.setDatabase(database)
@@ -143,183 +99,184 @@ public class RedissonConfig {
.setTimeout(timeout)
.setConnectTimeout(connectTimeout)
.setIdleConnectionTimeout(idleConnectionTimeout)
.setPassword(StringUtils.trimToNull(password));
.setPassword(pwd);
}
private void configureClusterMode(Config config, String pwd) {
String[] nodeAddresses = normalizeAddresses(address.split(","));
config.useClusterServers()
.setScanInterval(scanInterval)
.addNodeAddress(nodeAddresses)
.setPassword(pwd)
.setRetryAttempts(retryAttempts)
.setRetryInterval(retryInterval)
.setTimeout(timeout)
.setConnectTimeout(connectTimeout)
.setIdleConnectionTimeout(idleConnectionTimeout)
.setMasterConnectionPoolSize(connectionPoolSize)
.setSlaveConnectionPoolSize(connectionPoolSize)
.setSubscriptionConnectionPoolSize(subscriptionConnectionPoolSize)
.setSubscriptionConnectionMinimumIdleSize(subscriptionConnectionMinimumIdleSize)
.setSubscriptionsPerConnection(subscriptionsPerConnection)
.setClientName(clientName);
}
private void configureMasterSlaveMode(Config config, String pwd) {
String[] addresses = address.split(",");
validateMasterSlaveAddresses(addresses);
String[] normalizedAddresses = normalizeAddresses(addresses);
String masterAddress = normalizedAddresses[0];
String[] slaveAddresses = new String[normalizedAddresses.length - 1];
System.arraycopy(normalizedAddresses, 1, slaveAddresses, 0, slaveAddresses.length);
config.useMasterSlaveServers()
.setDatabase(database)
.setPassword(pwd)
.setMasterAddress(masterAddress)
.addSlaveAddress(slaveAddresses)
.setRetryAttempts(retryAttempts)
.setRetryInterval(retryInterval)
.setTimeout(timeout)
.setConnectTimeout(connectTimeout)
.setIdleConnectionTimeout(idleConnectionTimeout)
.setMasterConnectionPoolSize(connectionPoolSize)
.setSlaveConnectionPoolSize(connectionPoolSize)
.setSubscriptionConnectionPoolSize(subscriptionConnectionPoolSize)
.setSubscriptionConnectionMinimumIdleSize(subscriptionConnectionMinimumIdleSize)
.setSubscriptionsPerConnection(subscriptionsPerConnection)
.setClientName(clientName);
}
private void configureSentinelMode(Config config, String pwd) {
String[] sentinelAddresses = normalizeAddresses(address.split(","));
config.useSentinelServers()
.setDatabase(database)
.setPassword(pwd)
.setMasterName(masterName)
.addSentinelAddress(sentinelAddresses)
.setRetryAttempts(retryAttempts)
.setRetryInterval(retryInterval)
.setTimeout(timeout)
.setConnectTimeout(connectTimeout)
.setIdleConnectionTimeout(idleConnectionTimeout)
.setMasterConnectionPoolSize(connectionPoolSize)
.setSlaveConnectionPoolSize(connectionPoolSize)
.setSubscriptionConnectionPoolSize(subscriptionConnectionPoolSize)
.setSubscriptionConnectionMinimumIdleSize(subscriptionConnectionMinimumIdleSize)
.setSubscriptionsPerConnection(subscriptionsPerConnection)
.setClientName(clientName);
}
private void applyCommonConfig(Config config) {
// 设置编码器
Class<?> codecClass = ClassUtils.forName(getCodec(), ClassUtils.getDefaultClassLoader());
if (StringUtils.isNotBlank(codec)) {
try {
Class<?> codecClass = ClassUtils.forName(codec, ClassUtils.getDefaultClassLoader());
Codec codecInstance = (Codec) codecClass.getDeclaredConstructor().newInstance();
config.setCodec(codecInstance);
// 设置线程和事件循环组
config.setThreads(thread);
config.setEventLoopGroup(new NioEventLoopGroup());
} catch (Exception e) {
throw new IllegalStateException("Failed to create Redisson codec: " + codec, e);
}
}
// 设置线程数大于0时生效否则Redisson使用默认值CPU核数*2
if (threads > 0) {
config.setThreads(threads);
}
}
// ========================== 辅助方法 ==========================
/**
* 验证主从模式地址
* 自动补齐 Redis 地址协议前缀redis:// 或 rediss://
*/
private static void validateMasterSlaveAddresses(String[] addresses) {
if (addresses.length == 1) {
private String normalizeAddress(String addr) {
if (addr == null) {
return null;
}
addr = addr.trim();
if (!addr.startsWith("redis://") && !addr.startsWith("rediss://")) {
addr = "redis://" + addr;
}
return addr;
}
private String[] normalizeAddresses(String[] addresses) {
String[] normalized = new String[addresses.length];
for (int i = 0; i < addresses.length; i++) {
normalized[i] = normalizeAddress(addresses[i]);
}
return normalized;
}
private void validateMasterSlaveAddresses(String[] addresses) {
if (addresses.length < 2) {
throw new IllegalArgumentException(
"redis.redisson.address MUST have multiple redis addresses for master-slave mode.");
"Master-slave mode requires at least 2 addresses: master and at least one slave. " +
"Current addresses: " + String.join(",", addresses));
}
}
// ========================== GetterSetter方法 ==========================
// ========================== Getter / Setter(供 Spring 绑定配置) ==========================
// 以下所有字段都需要提供 getter/setter示例中只列出关键字段实际使用时请补全所有字段。
// 建议使用 Lombok @Data 或 IDE 自动生成。这里只展示部分,避免篇幅过长。
// 连接配置
public String getAddress() {
return address;
}
public String getAddress() { return address; }
public void setAddress(String address) { this.address = address; }
public void setAddress(String address) {
RedissonConfig.address = address;
}
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
public String getPassword() {
return password;
}
public String getClientName() { return clientName; }
public void setClientName(String clientName) { this.clientName = clientName; }
public void setPassword(String password) {
RedissonConfig.password = password;
}
public int getDatabase() { return database; }
public void setDatabase(int database) { this.database = database; }
public String getClientName() {
return clientName;
}
public String getMode() { return mode; }
public void setMode(String mode) { this.mode = mode; }
public void setClientName(String clientName) {
RedissonConfig.clientName = clientName;
}
public String getMasterName() { return masterName; }
public void setMasterName(String masterName) { this.masterName = masterName; }
public int getDatabase() {
return database;
}
public int getIdleConnectionTimeout() { return idleConnectionTimeout; }
public void setIdleConnectionTimeout(int idleConnectionTimeout) { this.idleConnectionTimeout = idleConnectionTimeout; }
public void setDatabase(int database) {
RedissonConfig.database = database;
}
public int getConnectTimeout() { return connectTimeout; }
public void setConnectTimeout(int connectTimeout) { this.connectTimeout = connectTimeout; }
public static String getMode() {
return mode;
}
public int getTimeout() { return timeout; }
public void setTimeout(int timeout) { this.timeout = timeout; }
public void setMode(String mode) {
RedissonConfig.mode = mode;
}
public int getRetryAttempts() { return retryAttempts; }
public void setRetryAttempts(int retryAttempts) { this.retryAttempts = retryAttempts; }
public static String getMasterNamee() {
return masterName;
}
public int getRetryInterval() { return retryInterval; }
public void setRetryInterval(int retryInterval) { this.retryInterval = retryInterval; }
public void setMasterNamee(String masterName) {
RedissonConfig.masterName = masterName;
}
public int getConnectionMinimumIdleSize() { return connectionMinimumIdleSize; }
public void setConnectionMinimumIdleSize(int connectionMinimumIdleSize) { this.connectionMinimumIdleSize = connectionMinimumIdleSize; }
// 超时配置
public int getIdleConnectionTimeout() {
return idleConnectionTimeout;
}
public int getConnectionPoolSize() { return connectionPoolSize; }
public void setConnectionPoolSize(int connectionPoolSize) { this.connectionPoolSize = connectionPoolSize; }
public void setIdleConnectionTimeout(int idleConnectionTimeout) {
RedissonConfig.idleConnectionTimeout = idleConnectionTimeout;
}
public int getSubscriptionsPerConnection() { return subscriptionsPerConnection; }
public void setSubscriptionsPerConnection(int subscriptionsPerConnection) { this.subscriptionsPerConnection = subscriptionsPerConnection; }
public int getConnectTimeout() {
return connectTimeout;
}
public int getSubscriptionConnectionMinimumIdleSize() { return subscriptionConnectionMinimumIdleSize; }
public void setSubscriptionConnectionMinimumIdleSize(int subscriptionConnectionMinimumIdleSize) { this.subscriptionConnectionMinimumIdleSize = subscriptionConnectionMinimumIdleSize; }
public void setConnectTimeout(int connectTimeout) {
RedissonConfig.connectTimeout = connectTimeout;
}
public int getSubscriptionConnectionPoolSize() { return subscriptionConnectionPoolSize; }
public void setSubscriptionConnectionPoolSize(int subscriptionConnectionPoolSize) { this.subscriptionConnectionPoolSize = subscriptionConnectionPoolSize; }
public int getTimeout() {
return timeout;
}
public int getScanInterval() { return scanInterval; }
public void setScanInterval(int scanInterval) { this.scanInterval = scanInterval; }
public void setTimeout(int timeout) {
RedissonConfig.timeout = timeout;
}
public int getDnsMonitoringInterval() { return dnsMonitoringInterval; }
public void setDnsMonitoringInterval(int dnsMonitoringInterval) { this.dnsMonitoringInterval = dnsMonitoringInterval; }
// 重试配置
public int getRetryAttempts() {
return retryAttempts;
}
public int getThreads() { return threads; }
public void setThreads(int threads) { this.threads = threads; }
public void setRetryAttempts(int retryAttempts) {
RedissonConfig.retryAttempts = retryAttempts;
}
public int getRetryInterval() {
return retryInterval;
}
public void setRetryInterval(int retryInterval) {
RedissonConfig.retryInterval = retryInterval;
}
// 连接池配置
public int getConnectionMinimumIdleSize() {
return connectionMinimumIdleSize;
}
public void setConnectionMinimumIdleSize(int connectionMinimumIdleSize) {
RedissonConfig.connectionMinimumIdleSize = connectionMinimumIdleSize;
}
public int getConnectionPoolSize() {
return connectionPoolSize;
}
public void setConnectionPoolSize(int connectionPoolSize) {
RedissonConfig.connectionPoolSize = connectionPoolSize;
}
public int getSubscriptionsPerConnection() {
return subscriptionsPerConnection;
}
public void setSubscriptionsPerConnection(int subscriptionsPerConnection) {
RedissonConfig.subscriptionsPerConnection = subscriptionsPerConnection;
}
public int getSubscriptionConnectionMinimumIdleSize() {
return subscriptionConnectionMinimumIdleSize;
}
public void setSubscriptionConnectionMinimumIdleSize(int subscriptionConnectionMinimumIdleSize) {
RedissonConfig.subscriptionConnectionMinimumIdleSize = subscriptionConnectionMinimumIdleSize;
}
public int getSubscriptionConnectionPoolSize() {
return subscriptionConnectionPoolSize;
}
public void setSubscriptionConnectionPoolSize(int subscriptionConnectionPoolSize) {
RedissonConfig.subscriptionConnectionPoolSize = subscriptionConnectionPoolSize;
}
// 其他配置
public int getDnsMonitoringInterval() {
return dnsMonitoringInterval;
}
public void setDnsMonitoringInterval(int dnsMonitoringInterval) {
RedissonConfig.dnsMonitoringInterval = dnsMonitoringInterval;
}
public int getThread() {
return thread;
}
public void setThread(int thread) {
RedissonConfig.thread = thread;
}
public static String getCodec() {
return codec;
}
public void setCodec(String codec) {
RedissonConfig.codec = codec;
}
public String getCodec() { return codec; }
public void setCodec(String codec) { this.codec = codec; }
}

View File

@@ -46,6 +46,7 @@ public class WebConfig implements WebMvcConfigurer {
filterUri.add("/onlinePreview");
filterUri.add("/picturesPreview");
filterUri.add("/getCorsFile");
filterUri.add("/addTask");
TrustHostFilter filter = new TrustHostFilter();
FilterRegistrationBean<TrustHostFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(filter);
@@ -59,6 +60,7 @@ public class WebConfig implements WebMvcConfigurer {
filterUri.add("/onlinePreview");
filterUri.add("/picturesPreview");
filterUri.add("/getCorsFile");
filterUri.add("/addTask");
TrustDirFilter filter = new TrustDirFilter();
FilterRegistrationBean<TrustDirFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(filter);

View File

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
@@ -93,6 +94,8 @@ public class PdfToJpgService {
@PostConstruct
public void init() {
refreshImageIoPlugins();
int maxThreads = ConfigConstants.getPdfMaxThreads();
// 使用固定大小的虚拟线程池
this.virtualThreadExecutor = Executors.newFixedThreadPool(maxThreads,
@@ -104,6 +107,13 @@ public class PdfToJpgService {
scheduleCacheCleanup();
}
static void refreshImageIoPlugins() {
// ImageIO only scans once automatically. If another launcher or Java agent initializes
// it before Spring Boot installs its application class loader, nested JAR providers such
// as jbig2-imageio remain invisible until the application class path is scanned again.
ImageIO.scanForPlugins();
}
@PreDestroy
public void shutdown() {
logger.info("开始关闭PDF转换服务...");

View File

@@ -1,11 +1,9 @@
package cn.keking.service.cache.impl;
import cn.keking.service.cache.CacheService;
import org.redisson.Redisson;
import org.redisson.api.RBlockingQueue;
import org.redisson.api.RMapCache;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Service;
@@ -23,8 +21,9 @@ public class CacheServiceRedisImpl implements CacheService {
private final RedissonClient redissonClient;
public CacheServiceRedisImpl(Config config) {
this.redissonClient = Redisson.create(config);
// 直接注入 Spring 容器中的 RedissonClient Bean
public CacheServiceRedisImpl(RedissonClient redissonClient) {
this.redissonClient = redissonClient;
}
@Override

View File

@@ -8,6 +8,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.HttpClientErrorException;
import java.io.File;
import java.io.FileNotFoundException;
@@ -46,9 +47,8 @@ public class DownloadUtils {
}
ReturnResponse<String> response = new ReturnResponse<>(0, "下载成功!!!", "");
String realPath = getRelFilePath(fileName, fileAttribute);
// 获取文件后缀用于校验
final String fileSuffix = fileAttribute.getSuffix();
// 判断是否非法地址
if (KkFileUtils.isIllegalFileName(realPath)) {
response.setCode(1);
response.setContent(null);
@@ -61,17 +61,17 @@ public class DownloadUtils {
response.setMsg("下载失败:不支持的类型!" + urlStr);
return response;
}
if (fileAttribute.isCompressFile()) { //压缩包文件 直接赋予路径 不予下载
if (fileAttribute.isCompressFile()) {
response.setContent(fileDir + fileName);
response.setMsg(fileName);
return response;
}
// 如果文件是否已经存在、且不强制更新,则直接返回文件路径
if (KkFileUtils.isExist(realPath) && !fileAttribute.forceUpdatedCache()) {
response.setContent(realPath);
response.setMsg(fileName);
return response;
}
try {
URL url = WebUtils.normalizedURL(urlStr);
if (!fileAttribute.getSkipDownLoad()) {
@@ -79,39 +79,59 @@ public class DownloadUtils {
File realFile = new File(realPath);
CloseableHttpClient httpClient = HttpRequestUtils.createConfiguredHttpClient();
String finalUrlStr = urlStr;
HttpRequestUtils.executeHttpRequest(url, httpClient, fileAttribute, responseWrapper -> {
// 获取响应头中的Content-Type
String contentType = responseWrapper.getContentType();
// 如果是Office/设计文件需要校验MIME类型
final boolean[] hasMimeError = {false};
final String[] mimeErrorMessage = {null};
HttpRequestUtils.executeHttpRequest(url, httpClient, fileAttribute, responseWrapper -> {
String contentType = responseWrapper.getContentType();
if (WebUtils.isMimeCheckRequired(fileSuffix)) {
if (!WebUtils.isValidMimeType(contentType, fileSuffix)) {
logger.error("文件类型错误期望二进制文件但接收到文本类型url: {}, Content-Type: {}",
finalUrlStr, contentType);
responseWrapper.setHasError(true);
hasMimeError[0] = true;
mimeErrorMessage[0] = "期望二进制文件但接收到文本类型Content-Type: " + contentType;
return;
}
}
// 保存文件
FileUtils.copyToFile(responseWrapper.getInputStream(), realFile);
});
if (hasMimeError[0]) {
response.setCode(1);
response.setContent(null);
response.setMsg(mimeErrorMessage[0]);
return response;
}
} else if (isFtpUrl(url)) {
String ftpUsername = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_USERNAME);
String ftpPassword = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_PASSWORD);
String ftpControlEncoding = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_CONTROL_ENCODING);
String ftpport = WebUtils.getUrlParameterReg(realPath, URL_PARAM_FTP_PORT);
FtpUtils.download(fileAttribute.getUrl(), ftpport, realPath, ftpUsername, ftpPassword, ftpControlEncoding);
} else if (isFileUrl(url)) { // 添加对file协议的支持
} else if (isFileUrl(url)) {
handleFileProtocol(url, realPath);
} else {
response.setCode(1);
response.setMsg("url不能识别url" + urlStr);
return response;
}
}
response.setContent(realPath);
response.setMsg(fileName);
return response;
} catch (HttpClientErrorException e) {
logger.error("HTTP请求失败状态码{}url{}", e.getStatusCode(), urlStr);
response.setCode(1);
response.setContent(null);
if (e.getStatusCode().is4xxClientError()) {
response.setMsg("文件不存在或无法访问 (HTTP " + e.getStatusCode() + ")");
} else {
response.setMsg("下载失败: " + e.getMessage());
}
return response;
} catch (IOException | GalimatiasParseException e) {
logger.error("文件下载失败url{}", urlStr);
response.setCode(1);
@@ -123,7 +143,11 @@ public class DownloadUtils {
}
return response;
} catch (Exception e) {
throw new RuntimeException(e);
logger.error("下载文件时发生未知异常url{}", urlStr, e);
response.setCode(1);
response.setContent(null);
response.setMsg("下载失败: " + e.getMessage());
return response;
}
}

View File

@@ -0,0 +1,14 @@
package cn.keking.utils;
import org.springframework.stereotype.Component;
import jakarta.annotation.PreDestroy;
@Component
public class HttpClientLifecycle {
@PreDestroy
public void destroy() {
System.out.println("Spring 容器关闭,释放 HTTP 连接池资源...");
HttpRequestUtils.shutdown();
}
}

View File

@@ -29,6 +29,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
@@ -341,13 +342,23 @@ public class FileController {
}
// ==================== 2. 构建路径和验证 ====================
String basePath = fileDir + demoPath;
if (!ObjectUtils.isEmpty(path)) {
basePath += path + File.separator;
Path currentDir;
try {
currentDir = resolveDirectoryUnderRoot(Paths.get(fileDir, demoDir), path);
} catch (InvalidPathException | SecurityException e) {
logger.warn("拒绝访问 demo 目录之外的文件列表路径");
result.put("total", 0);
result.put("data", Collections.emptyList());
result.put("error", "非法目录路径");
return result;
} catch (IOException e) {
logger.error("解析 demo 目录失败", e);
result.put("total", 0);
result.put("data", Collections.emptyList());
return result;
}
File currentDir = new File(basePath);
if (!currentDir.exists() || !currentDir.isDirectory()) {
if (!Files.isDirectory(currentDir)) {
result.put("total", 0);
result.put("data", Collections.emptyList());
return result;
@@ -357,13 +368,13 @@ public class FileController {
List<Path> allPaths = new ArrayList<>();
long collectStartTime = System.currentTimeMillis();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(basePath))) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(currentDir)) {
for (Path entry : stream) {
allPaths.add(entry);
stats.incrementFileCount();
}
} catch (IOException e) {
logger.error("读取目录失败: {}", basePath, e);
logger.error("读取目录失败: {}", currentDir, e);
result.put("total", 0);
result.put("data", Collections.emptyList());
return result;
@@ -492,6 +503,46 @@ public class FileController {
return result;
}
/**
* Resolve an existing directory below the configured demo root.
*
* <p>Both lexical normalization and real-path checks are required: the
* former blocks traversal and absolute paths, while the latter prevents a
* symlink inside the demo directory from escaping the configured root.</p>
*/
static Path resolveDirectoryUnderRoot(Path root, String requestedPath) throws IOException {
Path normalizedRoot = root.toAbsolutePath().normalize();
String relativePath = requestedPath == null ? "" : requestedPath.replace('\\', '/');
if (relativePath.indexOf('\0') >= 0
|| relativePath.startsWith("/")
|| relativePath.matches("^[A-Za-z]:.*")) {
throw new SecurityException("Absolute paths are not allowed");
}
Path relative = Paths.get(relativePath);
if (relative.isAbsolute()) {
throw new SecurityException("Absolute paths are not allowed");
}
for (Path segment : relative) {
if ("..".equals(segment.toString())) {
throw new SecurityException("Parent path segments are not allowed");
}
}
Path resolved = normalizedRoot.resolve(relative).normalize();
if (!resolved.startsWith(normalizedRoot)) {
throw new SecurityException("Path escapes the configured root");
}
Path realRoot = normalizedRoot.toRealPath();
Path realResolved = resolved.toRealPath();
if (!realResolved.startsWith(realRoot)) {
throw new SecurityException("Path escapes the configured root through a symbolic link");
}
return realResolved;
}
/**
* 构建性能统计信息
*/

View File

@@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.client.HttpClientErrorException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -152,34 +154,71 @@ public class OnlinePreviewController {
// 1. 验证接口是否开启
if (!ConfigConstants.getGetCorsFile()) {
logger.info("接口关闭,禁止访问!url{}", urlPath);
try {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "接口已关闭");
} catch (IOException ignored) {}
return;
}
// 2. 验证访问权限
if (WebUtils.validateKey(key)) {
logger.info("访问不合法:访问密码不正确!url{}", urlPath);
try {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "访问密码不正确");
} catch (IOException ignored) {}
return;
}
URL url;
try {
urlPath = WebUtils.decodeUrl(urlPath, encryption);
url = WebUtils.normalizedURL(urlPath);
} catch (Exception ex) {
logger.error(String.format(BASE64_DECODE_ERROR_MSG, urlPath), ex);
try {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "URL 解析失败");
} catch (IOException ignored) {}
return;
}
assert urlPath != null;
if (!isHttpUrl(url) && !isFtpUrl(url)) {
logger.info("读取跨域文件异常可能存在非法访问urlPath{}", urlPath);
try {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "不支持的协议");
} catch (IOException ignored) {}
return;
}
FileAttribute fileAttribute = fileHandlerService.getFileAttribute(urlPath, req);
InputStream inputStream = null;
logger.info("读取跨域文件url{}", urlPath);
if (!isFtpUrl(url)) {
CloseableHttpClient httpClient = HttpRequestUtils.createConfiguredHttpClient();
FileAttribute fileAttribute = fileHandlerService.getFileAttribute(urlPath, req);
logger.info("读取跨域文件url{}", urlPath);
if (!isFtpUrl(url)) {
// HTTP/HTTPS 处理(修复:不关闭共享的 CloseableHttpClient
CloseableHttpClient httpClient = HttpRequestUtils.createConfiguredHttpClient();
try {
HttpRequestUtils.executeHttpRequest(url, httpClient, fileAttribute, responseWrapper -> IOUtils.copy(responseWrapper.getInputStream(), response.getOutputStream()));
} catch (HttpClientErrorException e) {
// 捕获 HTTP 4xx 错误(如 404
logger.error("HTTP 请求失败,状态码:{}url{}", e.getStatusCode(), urlPath);
try {
if (e.getStatusCode().is4xxClientError()) {
response.sendError(e.getStatusCode().value(), "文件不存在或无法访问");
} else {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "下载文件时发生错误");
}
} catch (IOException ignored) {
}
} catch (Exception e) {
// 捕获其他异常如连接超时、IO 异常等)
logger.error("读取跨域文件异常url{}", urlPath, e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "读取文件失败: " + e.getMessage());
} catch (IOException ignored) {
}
}
} else {
// FTP 处理
InputStream inputStream = null;
try {
String filename = urlPath.substring(urlPath.lastIndexOf('/') + 1);
String contentType = WebUtils.getContentTypeByFilename(filename);
@@ -193,7 +232,20 @@ public class OnlinePreviewController {
inputStream = FtpUtils.preview(urlPath, support, urlPath, ftpUsername, ftpPassword, ftpControlEncoding);
IOUtils.copy(inputStream, response.getOutputStream());
} catch (IOException e) {
logger.error("读取跨域文件异常url{}", urlPath);
logger.error("读取跨域文件异常url{}", urlPath, e);
try {
// 根据异常信息判断是否为文件不存在
if (e.getMessage() != null && (e.getMessage().contains("550") || e.getMessage().contains("File not found"))) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "FTP 文件不存在");
} else {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "FTP 读取失败");
}
} catch (IOException ignored) {}
} catch (Exception e) {
logger.error("FTP 预览发生未知异常url{}", urlPath, e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "FTP 服务异常");
} catch (IOException ignored) {}
} finally {
IOUtils.closeQuietly(inputStream);
}

View File

@@ -38,6 +38,7 @@ public class AttributeSetFilter implements Filter {
request.setAttribute("pdfDownloadDisable", ConfigConstants.getPdfDownloadDisable());
request.setAttribute("pdfBookmarkDisable", ConfigConstants.getPdfBookmarkDisable());
request.setAttribute("pdfDisableEditing", ConfigConstants.getPdfDisableEditing());
request.setAttribute("pdfSidebarOpen", ConfigConstants.getPdfSidebarOpen());
request.setAttribute("switchDisabled", ConfigConstants.getOfficePreviewSwitchDisabled());
request.setAttribute("fileUploadDisable", ConfigConstants.getFileUploadDisable());
request.setAttribute("beian", ConfigConstants.getBeian());

View File

@@ -1,69 +0,0 @@
function isNotEmpty(value) {
return value !== null && value !== undefined && value !== '' && value !== 'false' ;
}
function watermarkObj(watermarkContainer,watermarkTxt) {
try {
if (!isNotEmpty(watermarkTxt)) {
return ;
}
var watermarkSettings = {
watermark_txt: watermarkTxt,
watermark_start_x:80,//水印起始位置x轴坐标
watermark_start_y:80,//水印起始位置Y轴坐标
watermark_x_space:80,//水印x轴间隔
watermark_y_space:80,//水印y轴间隔
watermark_color:'black',//水印字体颜色
watermark_alpha:0.2,//水印透明度
watermark_fontsize:'18px',//水印字体大小
watermark_font:'微软雅黑',//水印字体
watermark_width:200,//水印宽度
watermark_height:80,//水印高度
watermark_angle:30//水印倾斜度数
};
// console.log(watermarkContainer);
var page_width = $(watermarkContainer).width() - watermarkSettings.watermark_width;
var page_height = $(watermarkContainer).height() - watermarkSettings.watermark_height;
page_width = (page_width < 250) ? 250 : page_width;
page_height = (page_height < 250) ? 250 : page_height;
var oTemp = document.createDocumentFragment();
for (var x = watermarkSettings.watermark_start_x; x < page_width; x+= watermarkSettings.watermark_x_space) {
for (var y = watermarkSettings.watermark_start_y; y < page_height; y+= watermarkSettings.watermark_y_space) {
var mask_div = document.createElement('div');
// mask_div.id = 'mask_div' + x + y;
mask_div.className = 'mask_div';
mask_div.appendChild(document.createTextNode(watermarkTxt));
// 设置水印div倾斜显示
mask_div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+(watermarkSettings.watermark_alpha*100)+")";
mask_div.style.webkitTransform = "rotate(-" + watermarkSettings.watermark_angle + "deg)";
mask_div.style.MozTransform = "rotate(-" + watermarkSettings.watermark_angle + "deg)";
mask_div.style.msTransform = "rotate(-" + watermarkSettings.watermark_angle + "deg)";
mask_div.style.OTransform = "rotate(-" + watermarkSettings.watermark_angle + "deg)";
mask_div.style.transform = "rotate(-" + watermarkSettings.watermark_angle + "deg)";
mask_div.style.visibility = "";
mask_div.style.position = "absolute";
mask_div.style.left = x + 'px';
mask_div.style.top = y + 'px';
mask_div.style.overflow = "hidden";
mask_div.style.zIndex = "100";
mask_div.style.pointerEvents='none';//pointer-events:none 让水印不遮挡页面的点击事件
//mask_div.style.border="solid #eee 1px";
mask_div.style.opacity = watermarkSettings.watermark_alpha;
mask_div.style.fontSize = watermarkSettings.watermark_fontsize;
mask_div.style.fontFamily = watermarkSettings.watermark_font;
mask_div.style.color = watermarkSettings.watermark_color;
mask_div.style.textAlign = "center";
mask_div.style.width = watermarkSettings.watermark_width + 'px';
mask_div.style.height = watermarkSettings.watermark_height + 'px';
mask_div.style.display = "block";
oTemp.appendChild(mask_div);
}
}
$(watermarkContainer).append(oTemp);
} catch (e) {
console.log(e);
}
}

View File

@@ -1221,8 +1221,6 @@ See https://github.com/adobe-type-tools/cmap-resources
<!-- editorUndoBar -->
</div>
<!-- outerContainer -->
<script type="text/javascript" src="/js/jquery-3.6.1.min.js"></script>
<script type="text/javascript" src="/js/pdfwatermark.js"></script>
<div id="printContainer"></div>
</body>
</html>

View File

@@ -9,6 +9,83 @@ if (kkpdfAutoFetch == "true") {
} else {
kkpdfAutoFetch = false
}
function isNotEmpty(value) {
return value !== null && value !== undefined && value !== '' && value !== 'false' ;
}
/**
* 通用水印生成函数
* @param {HTMLElement} container - 水印容器(相对定位的父元素)
* @param {string} watermarkTxt - 水印文字
* @param {number} [explicitWidth] - 可选显式指定容器宽度px不传则自动获取
* @param {number} [explicitHeight] - 可选显式指定容器高度px不传则自动获取
*/
function addWatermark(container, watermarkTxt, explicitWidth = null, explicitHeight = null) {
if (!isNotEmpty(watermarkTxt)) return;
// 公共配置
const settings = {
start_x: 80,
start_y: 80,
x_space: 80,
y_space: 80,
color: 'black',
alpha: 0.2,
fontsize: '18px',
font: '微软雅黑',
width: 200,
height: 80,
angle: 30
};
// 确定实际使用的宽高
let pageWidth, pageHeight;
if (explicitWidth !== null && explicitHeight !== null) {
pageWidth = explicitWidth;
pageHeight = explicitHeight;
} else {
const rect = container.getBoundingClientRect();
pageWidth = rect.width;
pageHeight = rect.height;
}
let maxX = pageWidth - settings.width;
let maxY = pageHeight - settings.height;
maxX = Math.max(maxX, 250);
maxY = Math.max(maxY, 250);
const fragment = document.createDocumentFragment();
for (let x = settings.start_x; x < maxX; x += settings.x_space) {
for (let y = settings.start_y; y < maxY; y += settings.y_space) {
const div = document.createElement('div');
div.className = 'mask_div';
div.appendChild(document.createTextNode(watermarkTxt));
div.style.cssText = `
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=${settings.alpha * 100});
transform: rotate(-${settings.angle}deg);
visibility: visible;
position: absolute;
left: ${x}px;
top: ${y}px;
overflow: hidden;
z-index: 100;
pointer-events: none;
opacity: ${settings.alpha};
font-size: ${settings.fontsize};
font-family: ${settings.font};
color: ${settings.color};
text-align: center;
width: ${settings.width}px;
height: ${settings.height}px;
display: block;
`;
fragment.appendChild(div);
}
}
container.appendChild(fragment);
}
/******/ var __webpack_modules__ = ({
/***/ 34:
@@ -13877,28 +13954,34 @@ class PDFPrintService {
useRenderedPage() {
this.throwIfInactive();
const img = document.createElement("img");
const wrapper = document.createElement("div");
wrapper.className = "printedPage";
wrapper.style.position = "relative";
// 获取当前页面的尺寸单位1pt=1/72英寸
const pageSizePt = this.pagesOverview[0];
// 转换为 CSS 像素1pt = 96/72 px
const pageWidthPx = pageSizePt.width * 96 / 72;
const pageHeightPx = pageSizePt.height * 96 / 72;
// 设置 wrapper 尺寸CSS 像素)
wrapper.style.width = `${pageWidthPx}px`;
wrapper.style.height = `${pageHeightPx}px`;
wrapper.style.backgroundColor = "white";
this.scratchCanvas.toBlob(blob => {
img.src = URL.createObjectURL(blob);
});
const wrapper = document.createElement("div");
wrapper.className = "printedPage";
wrapper.append(img);
var printWatermarkDiv = document.createElement('div');
// console.log(pageSize);
printWatermarkDiv.style.position = 'absolute';
printWatermarkDiv.style.left = '0px';
printWatermarkDiv.style.top = '0px';
printWatermarkDiv.style.width = '1024px';
printWatermarkDiv.style.height = pageSize.height*pageCount+ "px";
watermarkObj(printWatermarkDiv,watermarkTxt);
wrapper.appendChild(printWatermarkDiv);
this.printContainer.append(wrapper);
const {
promise,
resolve,
reject
} = Promise.withResolvers();
img.onload = resolve;
const { promise, resolve, reject } = Promise.withResolvers();
img.onload = () => {
// 使用专用函数生成水印,直接传入页面像素尺寸
addWatermark(wrapper, watermarkTxt, pageWidthPx, pageHeightPx);
resolve();
};
img.onerror = reject;
promise.catch(() => {}).then(() => {
URL.revokeObjectURL(img.src);
@@ -17612,7 +17695,7 @@ class PDFPageView extends BasePDFPageView {
}
});
}
watermarkObj(div,watermarkTxt);
addWatermark(div,watermarkTxt);
if (!this.annotationLayer && this.#annotationMode !== AnnotationMode.DISABLE) {
const {
annotationStorage,
@@ -23091,6 +23174,7 @@ initCom(PDFViewerApplication);
if (HOSTED_VIEWER_ORIGINS.has(viewerOrigin)) {
return;
}
/* 注释掉跨域检查
const fileOrigin = URL.parse(file, window.location)?.origin;
if (fileOrigin === viewerOrigin) {
return;
@@ -23100,6 +23184,7 @@ initCom(PDFViewerApplication);
message: ex.message
});
throw ex;
*/
};
var onFileInputChange = function (evt) {
if (this.pdfViewer?.isInPresentationMode) {

View File

@@ -0,0 +1,54 @@
// LuckyExcel's bundled getBinaryContent reads window.XMLHttpRequest.
// Web Worker exposes XMLHttpRequest on self, so provide a minimal window alias
// before loading the UMD bundle.
self.window = self;
importScripts('./luckyexcel.umd.js');
self.console.log = function () {};
self.onmessage = function (event) {
var data = event.data || {};
var url = data.url;
var name = data.name;
if (!url) {
self.postMessage({
type: 'error',
message: '文件URL为空'
});
return;
}
try {
LuckyExcel.transformExcelToLuckyByUrl(
url,
name,
function (exportJson, luckysheetfile) {
if (!exportJson || !exportJson.sheets || exportJson.sheets.length === 0) {
self.postMessage({
type: 'error',
message: '读取excel文件内容失败!'
});
return;
}
self.postMessage({
type: 'success',
exportJson: exportJson
});
},
function (error) {
self.postMessage({
type: 'error',
message: error && error.message ? error.message : String(error)
});
}
);
} catch (error) {
self.postMessage({
type: 'error',
message: error && error.message ? error.message : String(error)
});
}
};

View File

@@ -3938,7 +3938,7 @@ var LuckySheet = /** @class */function (_super) {
_this.sheetList = allFileOption.sheetList;
_this.imageList = allFileOption.imageList;
_this.hide = allFileOption.hide;
console.log(allFileOption, 'allFileOption');
// console.log(allFileOption, 'allFileOption');
_this.dataVerificationSelectCount = allFileOption.dataVerificationSelectCount;
//Output
_this.name = sheetName;
@@ -4433,7 +4433,8 @@ var LuckySheet = /** @class */function (_super) {
var _hint = method_1.getXmlAttibute(attrList, "prompt", null);
var _hintShow = _hint ? true : false;
var matchType = constant_1.COMMON_TYPE2.includes(_type) ? "common" : _type;
_type2 = operator ? constant_1.DATA_VERIFICATION_TYPE2_MAP[matchType][operator] : "bw";
var _type2Map = constant_1.DATA_VERIFICATION_TYPE2_MAP[matchType];
_type2 = operator ? (_type2Map ? _type2Map[operator] : "bw") : "bw";
// mobile phone number processing
if (_type === "text_content" && ((_value1 === null || _value1 === void 0 ? void 0 : _value1.includes("LEN")) || (_value1 === null || _value1 === void 0 ? void 0 : _value1.includes("len"))) && (_value1 === null || _value1 === void 0 ? void 0 : _value1.includes("=11"))) {
_type = "validity";
@@ -7421,4 +7422,3 @@ module.exports = main_1.LuckyExcel;
},{"./main":19}]},{},[20])(20)
});

View File

@@ -41,10 +41,10 @@
你可以先看最新版本的升级重点,再顺着时间轴继续了解历史版本细节。
</p>
<div class="release-badge-row">
<span class="tag highlight">最新版本 v5.0</span>
<span class="tag brand">发布日期 2026-01-20</span>
<span class="tag highlight">最新版本 v5.0.1</span>
<span class="tag brand">发布日期 2026-07-13</span>
<span class="tag warn">JDK 21+ 强制要求</span>
<span class="tag">PDF / TIF / CAD 异步化</span>
<span class="tag">安全补丁 / PDF、Redis、XLSX 修复</span>
</div>
</div>
</section>
@@ -53,10 +53,52 @@
<div class="timeline-year">2026</div>
<div class="timeline-list">
<article class="release-card">
<h3>v5.0</h3>
<h3>v5.0.1</h3>
<div class="release-meta">
<span class="tag brand">2026-01-20</span>
<span class="tag brand">2026-07-13</span>
<span class="tag highlight">最新稳定版本</span>
<span class="tag warn">建议尽快升级</span>
</div>
<div class="release-columns">
<div class="release-group">
<h4>安全修复</h4>
<ul class="release-list">
<li>修复 <code>/addTask</code> 未覆盖信任主机和本地目录过滤导致的 SSRF 风险。</li>
<li>修复 <code>/listFiles</code> 可越出演示目录导致的路径遍历和目录信息泄露。</li>
</ul>
</div>
<div class="release-group">
<h4>修复</h4>
<ul class="release-list">
<li>修复 PDF 跨域、页码、高亮、打印、打印水印及反向代理路径问题。</li>
<li>修复 Redis 多种运行模式的配置兼容问题。</li>
<li>修复 HTTP 错误处理、共享 Client 生命周期和 xlsx 数据校验解析问题。</li>
</ul>
</div>
<div class="release-group">
<h4>优化</h4>
<ul class="release-list">
<li>大型 xlsx 文件使用 Web Worker 解析,并保留主线程自动回退。</li>
<li>新增 <code>pdf.sidebar.open</code>,支持配置 PDF 默认侧栏状态。</li>
<li>Maven CI 增加 Linux、Windows、macOS 构建验证。</li>
</ul>
</div>
<div class="release-group">
<h4>升级重点</h4>
<ul class="release-list">
<li>建议所有 v5.0.0 及更早版本用户尽快升级。</li>
<li>继续要求 JDK 21 及以上。</li>
<li>现有 v5.0.0 配置可直接沿用。</li>
</ul>
</div>
</div>
</article>
<article class="release-card">
<h3>v5.0.0</h3>
<div class="release-meta">
<span class="tag brand">2026-04-14</span>
<span class="tag">5.0 功能版本</span>
<span class="tag warn">升级需 JDK 21+</span>
</div>
<div class="release-columns">
@@ -66,6 +108,9 @@
<li>优化 xlsx、图片、tif、svg、json 解析效果。</li>
<li>优化 FTP 多客户端接入与 marked 解析。</li>
<li>首页支持目录访问,并切换为 POST 服务端分页。</li>
<li>压缩包预览页重构为单工作区布局,支持目录折叠与右侧内嵌预览。</li>
<li>优化压缩包内文件类型标识,以及单图预览页展示样式。</li>
<li>重构演示门户页面,包括首页、接入说明、版本记录与赞助页。</li>
</ul>
</div>
<div class="release-group">
@@ -74,6 +119,7 @@
<li>新增 msg、heic/heif、页码、高亮、AES、Basic Auth、秘钥等能力。</li>
<li>新增防重复转换、异步等待、上传限制与 cadviewer 转换方法。</li>
<li>新增 pptm 支持。</li>
<li>补充面向工程自动化与编码代理的仓库说明文档。</li>
</ul>
</div>
<div class="release-group">
@@ -82,6 +128,9 @@
<li>修复压缩包路径问题与安全问题。</li>
<li>修复图片水印不完整。</li>
<li>修复 SSL 自签证书接入问题。</li>
<li>修复压缩包内 Office 文件重复解压后被追加写坏、导致一直加载中的问题。</li>
<li>Office 默认预览切到 PDF 模式,并默认展开 PDF 缩略图侧栏。</li>
<li>修复 OFD 表格竖线溢出导致的渲染异常,并修正 PDF.js 兼容性补丁。</li>
</ul>
</div>
<div class="release-group">
@@ -90,6 +139,9 @@
<li>JDK 版本要求升级到 21 及以上。</li>
<li>前端解析链路升级PDF、ODF、3D 模型。</li>
<li>后端异步转换升级PDF、TIF、视频、CAD。</li>
<li>启动脚本改为自动发现当前发布包中的 jar并同步更新 Docker 与发布辅助文档。</li>
<li>默认配置策略调整Office 预览默认使用 PDF 模式,默认隐藏图片/PDF 模式切换按钮;如需保留旧的图片优先体验,请显式设置 <code>office.preview.type=image</code> 与 <code>office.preview.switch.disabled=false</code>。</li>
<li>信任域名配置匹配策略扩展:<code>trust.host</code> 及相关规则支持通配符与 CIDR 匹配;升级后请重新核对白名单和黑名单的匹配范围。</li>
</ul>
</div>
</div>

View File

@@ -225,8 +225,11 @@
// 使用异步方式加载
await new Promise(resolve => setTimeout(resolve, 100)); // 给UI更新一点时间
// 或者使用现有的同步方法但放在setTimeout中避免阻塞
await transformWithTimeout(value, name);
const exportJson = await transformWithWorker(value, name);
updateProgress(80);
await createLuckysheet(exportJson);
updateProgress(100);
@@ -243,23 +246,81 @@
}
}
// 使用setTimeout将同步任务拆分
function transformWithTimeout(value, name) {
function transformWithWorker(value, name) {
return new Promise((resolve, reject) => {
updateProgress(50);
// 将转换过程放在setTimeout中避免阻塞主线程
setTimeout(() => {
if (!window.Worker) {
transformOnMainThread(value, name, resolve, reject);
return;
}
let worker;
try {
worker = new Worker('xlsx/luckyexcel-worker.js');
} catch (error) {
transformOnMainThread(value, name, resolve, reject);
return;
}
let settled = false;
const fallbackToMainThread = function(error) {
if (settled) {
return;
}
settled = true;
worker.terminate();
if (error) {
console.warn('Excel Worker转换失败回退主线程转换:', error);
}
transformOnMainThread(value, name, resolve, reject);
};
worker.onmessage = function(event) {
const data = event.data || {};
if (data.type === 'success') {
settled = true;
worker.terminate();
resolve(data.exportJson);
return;
}
if (data.type === 'error') {
fallbackToMainThread(data.message || 'Excel转换失败');
}
};
worker.onerror = function(error) {
fallbackToMainThread(error && error.message ? error.message : error);
};
worker.postMessage({
url: value,
name: name
});
});
}
function transformOnMainThread(value, name, resolve, reject) {
try {
LuckyExcel.transformExcelToLuckyByUrl(value, name, function(exportJson, luckysheetfile) {
if(exportJson.sheets==null || exportJson.sheets.length==0){
if (!exportJson || !exportJson.sheets || exportJson.sheets.length === 0) {
reject(new Error("读取excel文件内容失败!"));
return;
}
updateProgress(80);
resolve(exportJson);
}, function(error) {
reject(error);
});
} catch (error) {
reject(error);
}
}
// 使用requestAnimationFrame来更新UI避免阻塞
function createLuckysheet(exportJson) {
return new Promise((resolve, reject) => {
requestAnimationFrame(() => {
try {
window.luckysheet.destroy();
@@ -305,12 +366,6 @@
}
});
});
} catch (error) {
reject(error);
}
}, 100);
});
}
// 页面加载完成后开始异步加载

View File

@@ -1,24 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
<title>PDF预览</title>
<#include "*/commonHeader.ftl">
<script src="js/base64.min.js" type="text/javascript"></script>
<style>
/* 简单全屏布局,无滚动条 */
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: none;
display: block;
}
.img-preview {
position: fixed;
bottom: 20px;
right: 20px;
cursor: pointer;
z-index: 999;
width: 48px;
height: 48px;
}
</style>
</head>
<body>
<#if pdfUrl?contains("http://") || pdfUrl?contains("https://")>
<#assign finalUrl="${pdfUrl}">
<#else>
<#assign finalUrl="${baseUrl}${pdfUrl}">
</#if>
<iframe src="" width="100%" frameborder="0"></iframe>
<iframe id="pdfFrame" src="about:blank"></iframe>
<#if "false" == switchDisabled>
<img src="images/jpg.svg" width="48" height="48" style="position: fixed; cursor: pointer; top: 40%; right: 48px; z-index: 999;" alt="使用图片预览" title="使用图片预览" onclick="goForImage()"/>
<img class="img-preview" src="images/jpg.svg" alt="使用图片预览" title="使用图片预览" onclick="goForImage()"/>
</#if>
</body>
<script type="text/javascript">
var url = '${finalUrl}';
@@ -27,29 +52,36 @@
if (kkagent === 'true' || !url.startsWith(baseUrl)) {
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url)) + "&key=${kkkey}";
}
document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?file=" + encodeURIComponent(url) + "&disablepresentationmode=${pdfPresentationModeDisable}&disableopenfile=${pdfOpenFileDisable}&disableprint=${pdfPrintDisable}&disabledownload=${pdfDownloadDisable}&disablebookmark=${pdfBookmarkDisable}&disableediting=${pdfDisableEditing}#page=1&pagemode=thumbs";
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight - 10;
/**
* 页面变化调整高度
*/
window.onresize = function () {
var fm = document.getElementsByTagName("iframe")[0];
fm.height = window.document.documentElement.clientHeight - 10;
}
var viewerUrl = baseUrl + "pdfjs/web/viewer.html?file=" + encodeURIComponent(url);
var watermarkEncoded = encodeURIComponent('${watermarkTxt?js_string}');
var highlightEncoded = encodeURIComponent('${highlightall?js_string}');
viewerUrl += "&disablepresentationmode=${pdfPresentationModeDisable}";
viewerUrl += "&disableopenfile=${pdfOpenFileDisable}";
viewerUrl += "&disableprint=${pdfPrintDisable}";
viewerUrl += "&disabledownload=${pdfDownloadDisable}";
viewerUrl += "&disablebookmark=${pdfBookmarkDisable}";
viewerUrl += "&disableediting=${pdfDisableEditing}";
viewerUrl += "&watermarktxt=" + watermarkEncoded;
viewerUrl += "&pdfhighlightall=" + highlightEncoded;
viewerUrl += "#page=${page}"; // ?c 确保数字不包含千位分隔符
<#if "true" == pdfSidebarOpen>
viewerUrl += "&pagemode=thumbs";
<#else>
viewerUrl += "&pagemode=none";
</#if>
var iframe = document.getElementById('pdfFrame');
iframe.src = viewerUrl;
// 图片预览切换
function goForImage() {
var url = window.location.href
if (url.indexOf("officePreviewType=pdf") != -1) {
url = url.replace("officePreviewType=pdf", "officePreviewType=image");
var href = window.location.href;
if (href.indexOf("officePreviewType=pdf") !== -1) {
href = href.replace("officePreviewType=pdf", "officePreviewType=image");
} else {
url = url + "&officePreviewType=image";
href += (href.indexOf('?') === -1 ? '?' : '&') + "officePreviewType=image";
}
window.location.href = url;
}
/*初始化水印*/
window.onload = function () {
initWaterMark();
window.location.href = href;
}
</script>
</body>
</html>

View File

@@ -27,10 +27,12 @@ public class PdfViewerCompatibilityTests {
}
@Test
void shouldOpenPdfPreviewWithThumbnailSidebarByDefault() throws IOException {
void shouldRenderPdfSidebarModeByDefaultBasedOnConfig() throws IOException {
String pdfTemplate = readResource("/web/pdf.ftl");
assertTrue(pdfTemplate.contains("#page=1&pagemode=thumbs"));
assertTrue(pdfTemplate.contains("<#if \"true\" == pdfSidebarOpen>"));
assertTrue(pdfTemplate.contains("viewerUrl += \"&pagemode=thumbs\";"));
assertTrue(pdfTemplate.contains("viewerUrl += \"&pagemode=none\";"));
}
@Test

View File

@@ -0,0 +1,27 @@
package cn.keking.config;
import cn.keking.web.filter.TrustDirFilter;
import cn.keking.web.filter.TrustHostFilter;
import org.junit.jupiter.api.Test;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import static org.junit.jupiter.api.Assertions.assertTrue;
class WebConfigTests {
private final WebConfig webConfig = new WebConfig();
@Test
void shouldApplyTrustHostFilterToAddTaskEndpoint() {
FilterRegistrationBean<TrustHostFilter> registration = webConfig.getTrustHostFilter();
assertTrue(registration.getUrlPatterns().contains("/addTask"));
}
@Test
void shouldApplyTrustDirFilterToAddTaskEndpoint() {
FilterRegistrationBean<TrustDirFilter> registration = webConfig.getTrustDirFilter();
assertTrue(registration.getUrlPatterns().contains("/addTask"));
}
}

View File

@@ -0,0 +1,51 @@
package cn.keking.service;
import org.junit.jupiter.api.Test;
import javax.imageio.ImageIO;
import javax.imageio.spi.IIORegistry;
import javax.imageio.spi.ImageReaderSpi;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class PdfToJpgServiceTests {
@Test
void shouldRediscoverJbig2ReaderAfterInitialRegistryMiss() {
IIORegistry registry = IIORegistry.getDefaultInstance();
List<ImageReaderSpi> providers = findJbig2Providers(registry);
assertFalse(providers.isEmpty(), "jbig2-imageio must be present on the test class path");
try {
providers.forEach(registry::deregisterServiceProvider);
assertFalse(hasJbig2Reader());
PdfToJpgService.refreshImageIoPlugins();
assertTrue(hasJbig2Reader());
} finally {
providers.forEach(registry::registerServiceProvider);
}
}
private static List<ImageReaderSpi> findJbig2Providers(IIORegistry registry) {
Iterator<ImageReaderSpi> providers = registry.getServiceProviders(
ImageReaderSpi.class,
provider -> Arrays.stream(((ImageReaderSpi) provider).getFormatNames())
.anyMatch("JBIG2"::equalsIgnoreCase),
true
);
List<ImageReaderSpi> result = new ArrayList<>();
providers.forEachRemaining(result::add);
return result;
}
private static boolean hasJbig2Reader() {
return ImageIO.getImageReadersByFormatName("JBIG2").hasNext();
}
}

View File

@@ -0,0 +1,98 @@
package cn.keking.web.controller;
import cn.keking.config.ConfigConstants;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
class FileControllerPathSecurityTests {
@TempDir
Path tempDir;
private String originalFileDir;
@BeforeEach
void rememberConfiguredFileDirectory() {
originalFileDir = ConfigConstants.getFileDir();
}
@AfterEach
void restoreConfiguredFileDirectory() {
ConfigConstants.setFileDirValue(originalFileDir);
}
@Test
void shouldResolveDirectoriesInsideDemoRoot() throws IOException {
Path demoRoot = Files.createDirectory(tempDir.resolve("demo"));
Path nested = Files.createDirectories(demoRoot.resolve("folder/subfolder"));
assertEquals(demoRoot.toRealPath(), FileController.resolveDirectoryUnderRoot(demoRoot, ""));
assertEquals(nested.toRealPath(), FileController.resolveDirectoryUnderRoot(demoRoot, "folder/subfolder"));
assertEquals(nested.toRealPath(), FileController.resolveDirectoryUnderRoot(demoRoot, "folder\\subfolder"));
}
@Test
void shouldRejectParentTraversalWithEitherSeparator() throws IOException {
Path demoRoot = Files.createDirectory(tempDir.resolve("demo"));
assertThrows(SecurityException.class,
() -> FileController.resolveDirectoryUnderRoot(demoRoot, "../outside"));
assertThrows(SecurityException.class,
() -> FileController.resolveDirectoryUnderRoot(demoRoot, "..\\outside"));
assertThrows(SecurityException.class,
() -> FileController.resolveDirectoryUnderRoot(demoRoot, "folder/../outside"));
}
@Test
void shouldRejectAbsoluteDriveAndUncPaths() throws IOException {
Path demoRoot = Files.createDirectory(tempDir.resolve("demo"));
assertThrows(SecurityException.class,
() -> FileController.resolveDirectoryUnderRoot(demoRoot, "/etc"));
assertThrows(SecurityException.class,
() -> FileController.resolveDirectoryUnderRoot(demoRoot, "C:\\Windows"));
assertThrows(SecurityException.class,
() -> FileController.resolveDirectoryUnderRoot(demoRoot, "\\\\server\\share"));
}
@Test
void shouldRejectSymlinkThatEscapesDemoRoot() throws IOException {
Path demoRoot = Files.createDirectory(tempDir.resolve("demo"));
Path outside = Files.createDirectory(tempDir.resolve("outside"));
Path link = demoRoot.resolve("outside-link");
try {
Files.createSymbolicLink(link, outside);
} catch (IOException | UnsupportedOperationException e) {
Assumptions.assumeTrue(false, "Symbolic links are unavailable in this environment");
}
assertThrows(SecurityException.class,
() -> FileController.resolveDirectoryUnderRoot(demoRoot, "outside-link"));
}
@Test
void listFilesShouldNotExposeEntriesOutsideDemoRoot() throws IOException {
Files.createDirectory(tempDir.resolve("demo"));
Files.createFile(tempDir.resolve("outside-secret.txt"));
ConfigConstants.setFileDirValue(tempDir.toString());
FileController controller = new FileController();
Map<String, Object> result = controller.getFiles("..", "", 0, 20, null, null);
assertEquals("非法目录路径", result.get("error"));
assertTrue(((List<?>) result.get("data")).isEmpty());
}
}