mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-04-30 20:16:44 +00:00
Compare commits
19 Commits
paseo/ai-d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd78fe9a6e | ||
|
|
cdce432740 | ||
|
|
4ea1d7468a | ||
|
|
4cf19d1dbe | ||
|
|
3abf864184 | ||
|
|
634babfba4 | ||
|
|
e7fe1afe19 | ||
|
|
cd2abb4be1 | ||
|
|
dd803126dd | ||
|
|
633e47b765 | ||
|
|
c52d80c123 | ||
|
|
ee2a27501b | ||
|
|
171762d676 | ||
|
|
76e091900b | ||
|
|
bfa4ceab90 | ||
|
|
b18cfa797a | ||
|
|
8a117a41e8 | ||
|
|
17ba41320e | ||
|
|
476c0bfefc |
@@ -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/
|
ADD server/target/kkFileView-*.tar.gz /opt/
|
||||||
ENV KKFILEVIEW_BIN_FOLDER=/opt/kkFileView-4.4.0/bin
|
ENV KKFILEVIEW_BIN_FOLDER=/opt/kkFileView-5.0.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"]
|
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-5.0.0/config/application.properties","-jar","/opt/kkFileView-5.0.0/bin/kkFileView-5.0.0.jar"]
|
||||||
|
|||||||
15
README.cn.md
15
README.cn.md
@@ -149,7 +149,7 @@ pdf预览模式预览效果如下
|
|||||||
|
|
||||||
### 历史更新记录
|
### 历史更新记录
|
||||||
|
|
||||||
#### > 2026年01月20日,v5.0 版本发布 :
|
#### > 2026年04月14日,v5.0.0 版本发布 :
|
||||||
#### 优化内容
|
#### 优化内容
|
||||||
1. xlsx 前端解析优化 - 提升Excel文件前端渲染性能
|
1. xlsx 前端解析优化 - 提升Excel文件前端渲染性能
|
||||||
2. 图片解析优化 - 改进图片处理机制
|
2. 图片解析优化 - 改进图片处理机制
|
||||||
@@ -159,6 +159,10 @@ pdf预览模式预览效果如下
|
|||||||
6. ftp多客户端接入优化 - 提升FTP服务兼容性
|
6. ftp多客户端接入优化 - 提升FTP服务兼容性
|
||||||
7. 首页目录访问优化 - 采用post服务端分页机制
|
7. 首页目录访问优化 - 采用post服务端分页机制
|
||||||
8. marked 解析优化 - 改进Markdown渲染
|
8. marked 解析优化 - 改进Markdown渲染
|
||||||
|
9. 压缩包预览页重构为单工作区布局,支持目录折叠与右侧内嵌预览
|
||||||
|
10. 优化压缩包内文件类型标识,以及单图预览页的展示样式
|
||||||
|
11. 补充面向工程自动化与编码代理的仓库说明文档
|
||||||
|
12. 重构演示门户页面,包括首页、接入说明、版本记录与赞助页
|
||||||
|
|
||||||
#### 新增功能
|
#### 新增功能
|
||||||
1. msg邮件解析 - 新增msg格式邮件文件预览支持
|
1. msg邮件解析 - 新增msg格式邮件文件预览支持
|
||||||
@@ -179,6 +183,12 @@ pdf预览模式预览效果如下
|
|||||||
2. 安全问题 - 修复安全漏洞
|
2. 安全问题 - 修复安全漏洞
|
||||||
3. 图片水印不全问题 - 修复水印显示不完整
|
3. 图片水印不全问题 - 修复水印显示不完整
|
||||||
4. SSL自签证书接入问题 - 修复自签名证书兼容性
|
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及以上版本
|
1. JDK版本要求 - 强制要求JDK 21及以上版本
|
||||||
@@ -189,6 +199,8 @@ pdf预览模式预览效果如下
|
|||||||
6. tif后端异步转换优化 - 实现多线程异步转换
|
6. tif后端异步转换优化 - 实现多线程异步转换
|
||||||
7. 视频后端异步转换优化 - 实现多线程异步转换
|
7. 视频后端异步转换优化 - 实现多线程异步转换
|
||||||
8. CAD后端异步转换优化 - 实现多线程异步转换
|
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 版本发布 :
|
#### > 2025年01月16日,v4.4.0 版本发布 :
|
||||||
|
|
||||||
@@ -468,4 +480,3 @@ dcm医疗数位影像 引用于 [dcmjs](https://github.com/dcmjs-org/dcmjs )开
|
|||||||
- 本项目诞生于[凯京集团],在取得公司高层同意后以 Apache 协议开源出来反哺社区,在此特别感谢凯京集团,以及集团领导[@唐老大](https://github.com/tangshd)的支持、@端木详笑的贡献。
|
- 本项目诞生于[凯京集团],在取得公司高层同意后以 Apache 协议开源出来反哺社区,在此特别感谢凯京集团,以及集团领导[@唐老大](https://github.com/tangshd)的支持、@端木详笑的贡献。
|
||||||
- 本项目已脱离公司由[KK开源社区]维护发展壮大,感谢所有给 kkFileView 提 Issue 、Pr 开发者
|
- 本项目已脱离公司由[KK开源社区]维护发展壮大,感谢所有给 kkFileView 提 Issue 、Pr 开发者
|
||||||
- 本项目引入的第三方组件已在 '关于引用' 列表列出,感谢这些项目,让 kkFileView 更出色
|
- 本项目引入的第三方组件已在 '关于引用' 列表列出,感谢这些项目,让 kkFileView 更出色
|
||||||
|
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -65,9 +65,9 @@ URL:[https://file.kkview.cn](https://file.kkview.cn)
|
|||||||
|
|
||||||
## Change History
|
## Change History
|
||||||
|
|
||||||
### Version 5.0 (January 20, 2026)
|
### Version 5.0.0 (April 14, 2026)
|
||||||
|
|
||||||
#### Optimizations
|
#### Improvements
|
||||||
1. Enhanced xlsx front-end parsing - Improved Excel file front-end rendering performance
|
1. Enhanced xlsx front-end parsing - Improved Excel file front-end rendering performance
|
||||||
2. Optimized image parsing - Enhanced image processing mechanism
|
2. Optimized image parsing - Enhanced image processing mechanism
|
||||||
3. Improved tif parsing - Enhanced TIF format support
|
3. Improved tif parsing - Enhanced TIF format support
|
||||||
@@ -76,6 +76,10 @@ URL:[https://file.kkview.cn](https://file.kkview.cn)
|
|||||||
6. Optimized ftp multi-client access - Improved FTP service compatibility
|
6. Optimized ftp multi-client access - Improved FTP service compatibility
|
||||||
7. Enhanced home page directory access - Implemented post server-side pagination mechanism
|
7. Enhanced home page directory access - Implemented post server-side pagination mechanism
|
||||||
8. Improved marked parsing - Enhanced Markdown rendering
|
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
|
#### New Features
|
||||||
1. msg email parsing - Added support for msg format email file preview
|
1. msg email parsing - Added support for msg format email file preview
|
||||||
@@ -96,6 +100,12 @@ URL:[https://file.kkview.cn](https://file.kkview.cn)
|
|||||||
2. Security issues - Fixed security vulnerabilities
|
2. Security issues - Fixed security vulnerabilities
|
||||||
3. Incomplete image watermark issues - Fixed incomplete watermark display
|
3. Incomplete image watermark issues - Fixed incomplete watermark display
|
||||||
4. SSL self-signed certificate access issues - Fixed compatibility with self-signed certificates
|
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
|
#### Updates
|
||||||
1. JDK version requirement - Mandatory requirement for JDK 21 or higher
|
1. JDK version requirement - Mandatory requirement for JDK 21 or higher
|
||||||
@@ -106,6 +116,8 @@ URL:[https://file.kkview.cn](https://file.kkview.cn)
|
|||||||
6. tif backend async conversion optimization - Implemented multi-threaded asynchronous conversion
|
6. tif backend async conversion optimization - Implemented multi-threaded asynchronous conversion
|
||||||
7. Video 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
|
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)
|
### Version 4.4.0 (January 16, 2025)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
当前线上 Windows 服务器的实际部署信息如下:
|
当前线上 Windows 服务器的实际部署信息如下:
|
||||||
|
|
||||||
- 部署根目录:`C:\kkFileView-5.0`
|
- 部署根目录:`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\bin\startup.bat`
|
||||||
- 运行配置:`C:\kkFileView-5.0\config\test.properties`
|
- 运行配置:`C:\kkFileView-5.0\config\test.properties`
|
||||||
- 健康检查地址:`http://127.0.0.1:8012/`
|
- 健康检查地址:`http://127.0.0.1:8012/`
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
然后使用 kkfileview-base 作为基础镜像进行构建,加快 kkfileview docker 镜像构建与发布。
|
然后使用 kkfileview-base 作为基础镜像进行构建,加快 kkfileview docker 镜像构建与发布。
|
||||||
|
|
||||||
执行如下命令即可构建基础镜像:
|
执行如下命令即可构建基础镜像:
|
||||||
> 这里镜像 tag 以 4.4.0 为例,本项目所维护的 Dockerfile 文件考虑了跨平台兼容性。 如果你需要用到 arm64 架构镜像, 则在arm64 架构机器上同样执行下面的构建命令即可
|
> 这里镜像 tag 以 5.0.0 为例,本项目所维护的 Dockerfile 文件考虑了跨平台兼容性。 如果你需要用到 arm64 架构镜像, 则在arm64 架构机器上同样执行下面的构建命令即可
|
||||||
|
|
||||||
```shell
|
```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
|
```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 .
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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:
|
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
|
```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. Here’s an example build command:
|
Now you can enjoy the building. Here’s an example build command:
|
||||||
|
|
||||||
```shell
|
```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 .
|
||||||
```
|
```
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>cn.keking</groupId>
|
<groupId>cn.keking</groupId>
|
||||||
<artifactId>kkFileView-parent</artifactId>
|
<artifactId>kkFileView-parent</artifactId>
|
||||||
<version>5.0</version>
|
<version>5.0.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- ========== Java 和编译配置 ========== -->
|
<!-- ========== Java 和编译配置 ========== -->
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>kkFileView-parent</artifactId>
|
<artifactId>kkFileView-parent</artifactId>
|
||||||
<groupId>cn.keking</groupId>
|
<groupId>cn.keking</groupId>
|
||||||
<version>5.0</version>
|
<version>5.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>kkFileView</artifactId>
|
<artifactId>kkFileView</artifactId>
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
@echo off
|
@echo off
|
||||||
set "KKFILEVIEW_BIN_FOLDER=%cd%"
|
set "KKFILEVIEW_BIN_FOLDER=%cd%"
|
||||||
cd "%KKFILEVIEW_BIN_FOLDER%"
|
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 KKFILEVIEW_BIN_FOLDER %KKFILEVIEW_BIN_FOLDER%
|
||||||
|
echo Using JAR_NAME %JAR_NAME%
|
||||||
echo Starting kkFileView...
|
echo Starting kkFileView...
|
||||||
echo Please check log file in ../log/kkFileView.log for more information
|
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 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 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
|
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
|
||||||
|
|||||||
@@ -49,9 +49,16 @@ else
|
|||||||
fi
|
fi
|
||||||
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
|
## 启动kkFileView
|
||||||
echo "Starting 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 "Please execute ./showlog.sh to check log for more information"
|
||||||
echo "You can get help in our official home site: https://kkview.cn"
|
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 you need further help, please join our kk opensource community: https://t.zsxq.com/09ZHSXbsQ"
|
||||||
|
|||||||
@@ -96,11 +96,11 @@ office.documentopenpasswords = ${KK_OFFICE_DOCUMENTOPENPASSWORD:true}
|
|||||||
office.type.web = ${KK_OFFICE_TYPE_WEB:web}
|
office.type.web = ${KK_OFFICE_TYPE_WEB:web}
|
||||||
|
|
||||||
# Office文档预览类型
|
# Office文档预览类型
|
||||||
# 支持动态配置,可选值:image/pdf
|
# 支持动态配置,可选值:image/pdf,默认使用pdf模式
|
||||||
office.preview.type = ${KK_OFFICE_PREVIEW_TYPE:pdf}
|
office.preview.type = ${KK_OFFICE_PREVIEW_TYPE:pdf}
|
||||||
|
|
||||||
# 是否关闭Office预览模式切换开关,默认为false(允许切换)
|
# 是否关闭Office预览模式切换开关,默认为true(关闭切换)
|
||||||
# 设置为true时,用户无法在图片和PDF模式间切换
|
# 设置为false时,用户可以在图片和PDF模式间切换
|
||||||
office.preview.switch.disabled = ${KK_OFFICE_PREVIEW_SWITCH_DISABLED:true}
|
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编辑功能(注释、表单等),默认为false(允许编辑)
|
||||||
pdf.disable.editing = ${KK_PDF_DISABLE_EDITING:false}
|
pdf.disable.editing = ${KK_PDF_DISABLE_EDITING:false}
|
||||||
|
|
||||||
|
# 是否默认打开PDF侧边栏(缩略图面板),默认为true(打开)
|
||||||
|
pdf.sidebar.open = ${KK_PDF_SIDEBAR_OPEN:true}
|
||||||
|
|
||||||
# PDF处理最大线程数,控制并发处理能力
|
# PDF处理最大线程数,控制并发处理能力
|
||||||
pdf.max.threads = 10
|
pdf.max.threads = 10
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public class ConfigConstants {
|
|||||||
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
|
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
|
||||||
public static final String DEFAULT_PDF_BOOKMARK_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_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_PDF2_JPG_DPI = "105";
|
||||||
public static final String DEFAULT_PDF_SMALL_DTI = "150";
|
public static final String DEFAULT_PDF_SMALL_DTI = "150";
|
||||||
public static final String DEFAULT_PDF_MEDIUM_DPI = "120";
|
public static final String DEFAULT_PDF_MEDIUM_DPI = "120";
|
||||||
@@ -194,6 +195,7 @@ public class ConfigConstants {
|
|||||||
private static String pdfPrintDisable;
|
private static String pdfPrintDisable;
|
||||||
private static String pdfDownloadDisable;
|
private static String pdfDownloadDisable;
|
||||||
private static String pdfBookmarkDisable;
|
private static String pdfBookmarkDisable;
|
||||||
|
private static String pdfSidebarOpen;
|
||||||
private static int pdf2JpgDpi;
|
private static int pdf2JpgDpi;
|
||||||
private static boolean pdfDpiEnabled;
|
private static boolean pdfDpiEnabled;
|
||||||
private static int pdfSmallDpi;
|
private static int pdfSmallDpi;
|
||||||
@@ -336,6 +338,7 @@ public class ConfigConstants {
|
|||||||
public static String getPdfDownloadDisable() { return pdfDownloadDisable; }
|
public static String getPdfDownloadDisable() { return pdfDownloadDisable; }
|
||||||
public static String getPdfBookmarkDisable() { return pdfBookmarkDisable; }
|
public static String getPdfBookmarkDisable() { return pdfBookmarkDisable; }
|
||||||
public static String getPdfDisableEditing() { return pdfDisableEditing; }
|
public static String getPdfDisableEditing() { return pdfDisableEditing; }
|
||||||
|
public static String getPdfSidebarOpen() { return pdfSidebarOpen; }
|
||||||
public static int getPdf2JpgDpi() { return pdf2JpgDpi; }
|
public static int getPdf2JpgDpi() { return pdf2JpgDpi; }
|
||||||
public static int getPdfTimeoutSmall() { return pdfTimeoutSmall; }
|
public static int getPdfTimeoutSmall() { return pdfTimeoutSmall; }
|
||||||
public static int getPdfTimeoutMedium() { return pdfTimeoutMedium; }
|
public static int getPdfTimeoutMedium() { return pdfTimeoutMedium; }
|
||||||
@@ -563,6 +566,10 @@ public class ConfigConstants {
|
|||||||
public void setpdfDisableEditing(String pdfDisableEditing) { setPdfDisableEditingValue(pdfDisableEditing); }
|
public void setpdfDisableEditing(String pdfDisableEditing) { setPdfDisableEditingValue(pdfDisableEditing); }
|
||||||
public static void setPdfDisableEditingValue(String pdfDisableEditing) { ConfigConstants.pdfDisableEditing = 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}")
|
@Value("${pdf2jpg.dpi:105}")
|
||||||
public void pdf2JpgDpi(int pdf2JpgDpi) { setPdf2JpgDpiValue(pdf2JpgDpi); }
|
public void pdf2JpgDpi(int pdf2JpgDpi) { setPdf2JpgDpiValue(pdf2JpgDpi); }
|
||||||
public static void setPdf2JpgDpiValue(int pdf2JpgDpi) { ConfigConstants.pdf2JpgDpi = pdf2JpgDpi; }
|
public static void setPdf2JpgDpiValue(int pdf2JpgDpi) { ConfigConstants.pdf2JpgDpi = pdf2JpgDpi; }
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ public class ConfigRefreshComponent {
|
|||||||
ConfigConstants.setPdfDownloadDisableValue(getProperty(properties, "pdf.download.disable", ConfigConstants.DEFAULT_PDF_DOWNLOAD_DISABLE));
|
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.setPdfBookmarkDisableValue(getProperty(properties, "pdf.bookmark.disable", ConfigConstants.DEFAULT_PDF_BOOKMARK_DISABLE));
|
||||||
ConfigConstants.setPdfDisableEditingValue(getProperty(properties, "pdf.disable.editing", ConfigConstants.DEFAULT_PDF_DISABLE_EDITING));
|
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)));
|
ConfigConstants.setPdf2JpgDpiValue(Integer.parseInt(getProperty(properties, "pdf2jpg.dpi", ConfigConstants.DEFAULT_PDF2_JPG_DPI)));
|
||||||
|
|
||||||
// 8. CAD配置
|
// 8. CAD配置
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.keking.config;
|
package cn.keking.config;
|
||||||
|
|
||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.redisson.Redisson;
|
import org.redisson.Redisson;
|
||||||
import org.redisson.api.RedissonClient;
|
import org.redisson.api.RedissonClient;
|
||||||
@@ -13,8 +12,8 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redisson 客户端配置
|
* Redisson 客户端配置(完善版)
|
||||||
* Created by kl on 2017/09/26.
|
* 支持 single / cluster / master-slave / sentinel 四种模式,配置完整,统一参数。
|
||||||
*/
|
*/
|
||||||
@ConditionalOnExpression("'${cache.type:default}'.equals('redis')")
|
@ConditionalOnExpression("'${cache.type:default}'.equals('redis')")
|
||||||
@ConfigurationProperties(prefix = "spring.redisson")
|
@ConfigurationProperties(prefix = "spring.redisson")
|
||||||
@@ -22,114 +21,71 @@ import org.springframework.util.ClassUtils;
|
|||||||
public class RedissonConfig {
|
public class RedissonConfig {
|
||||||
|
|
||||||
// ========================== 连接配置 ==========================
|
// ========================== 连接配置 ==========================
|
||||||
private static String address;
|
private String address;
|
||||||
private static String password;
|
private String password;
|
||||||
private static String clientName;
|
private String clientName;
|
||||||
private static int database = 0;
|
private int database = 0;
|
||||||
private static String mode = "single";
|
private String mode = "single";
|
||||||
private static String masterName = "kkfile";
|
private String masterName = "kkfile";
|
||||||
|
|
||||||
// ========================== 超时配置 ==========================
|
// ========================== 超时配置 ==========================
|
||||||
private static int idleConnectionTimeout = 10000;
|
private int idleConnectionTimeout = 10000;
|
||||||
private static int connectTimeout = 10000;
|
private int connectTimeout = 10000;
|
||||||
private static int timeout = 3000;
|
private int timeout = 3000;
|
||||||
|
|
||||||
// ========================== 重试配置 ==========================
|
// ========================== 重试配置 ==========================
|
||||||
private static int retryAttempts = 3;
|
private int retryAttempts = 3;
|
||||||
private static int retryInterval = 1500;
|
private int retryInterval = 1500;
|
||||||
|
|
||||||
// ========================== 连接池配置 ==========================
|
// ========================== 连接池配置 ==========================
|
||||||
private static int connectionMinimumIdleSize = 10;
|
private int connectionMinimumIdleSize = 10;
|
||||||
private static int connectionPoolSize = 64;
|
private int connectionPoolSize = 64;
|
||||||
private static int subscriptionsPerConnection = 5;
|
private int subscriptionsPerConnection = 5;
|
||||||
private static int subscriptionConnectionMinimumIdleSize = 1;
|
private int subscriptionConnectionMinimumIdleSize = 1;
|
||||||
private static int subscriptionConnectionPoolSize = 50;
|
private int subscriptionConnectionPoolSize = 50;
|
||||||
|
|
||||||
|
// ========================== 集群专用配置 ==========================
|
||||||
|
private int scanInterval = 2000;
|
||||||
|
|
||||||
// ========================== 其他配置 ==========================
|
// ========================== 其他配置 ==========================
|
||||||
private static int dnsMonitoringInterval = 5000;
|
private int dnsMonitoringInterval = 5000;
|
||||||
private static int thread; // 当前处理核数量 * 2
|
private int threads; // 默认为0,表示使用 CPU 核数 * 2
|
||||||
private static String codec = "org.redisson.codec.JsonJacksonCodec";
|
private String codec = "org.redisson.codec.JsonJacksonCodec";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public static RedissonClient config() throws Exception {
|
public RedissonClient redissonClient() {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
|
|
||||||
// 密码处理
|
// 密码处理:空字符串转为 null
|
||||||
if (StringUtils.isBlank(password)) {
|
String pwd = StringUtils.isBlank(password) ? null : password;
|
||||||
password = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据模式创建对应的 Redisson 配置
|
// 根据模式构建配置
|
||||||
switch (mode) {
|
switch (mode.toLowerCase()) {
|
||||||
case "cluster":
|
case "cluster":
|
||||||
configureClusterMode(config);
|
configureClusterMode(config, pwd);
|
||||||
break;
|
break;
|
||||||
case "master-slave":
|
case "master-slave":
|
||||||
configureMasterSlaveMode(config);
|
configureMasterSlaveMode(config, pwd);
|
||||||
break;
|
break;
|
||||||
case "sentinel":
|
case "sentinel":
|
||||||
configureSentinelMode(config);
|
configureSentinelMode(config, pwd);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
configureSingleMode(config);
|
configureSingleMode(config, pwd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 公共配置:编码器、线程数
|
||||||
|
applyCommonConfig(config);
|
||||||
return Redisson.create(config);
|
return Redisson.create(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================== 配置方法 ==========================
|
// ========================== 配置方法 ==========================
|
||||||
|
|
||||||
/**
|
private void configureSingleMode(Config config, String pwd) {
|
||||||
* 配置集群模式
|
String normalizedAddress = normalizeAddress(address);
|
||||||
*/
|
|
||||||
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 {
|
|
||||||
config.useSingleServer()
|
config.useSingleServer()
|
||||||
.setAddress(address)
|
.setAddress(normalizedAddress)
|
||||||
.setConnectionMinimumIdleSize(connectionMinimumIdleSize)
|
.setConnectionMinimumIdleSize(connectionMinimumIdleSize)
|
||||||
.setConnectionPoolSize(connectionPoolSize)
|
.setConnectionPoolSize(connectionPoolSize)
|
||||||
.setDatabase(database)
|
.setDatabase(database)
|
||||||
@@ -143,183 +99,184 @@ public class RedissonConfig {
|
|||||||
.setTimeout(timeout)
|
.setTimeout(timeout)
|
||||||
.setConnectTimeout(connectTimeout)
|
.setConnectTimeout(connectTimeout)
|
||||||
.setIdleConnectionTimeout(idleConnectionTimeout)
|
.setIdleConnectionTimeout(idleConnectionTimeout)
|
||||||
.setPassword(StringUtils.trimToNull(password));
|
.setPassword(pwd);
|
||||||
|
|
||||||
// 设置编码器
|
|
||||||
Class<?> codecClass = ClassUtils.forName(getCodec(), ClassUtils.getDefaultClassLoader());
|
|
||||||
Codec codecInstance = (Codec) codecClass.getDeclaredConstructor().newInstance();
|
|
||||||
config.setCodec(codecInstance);
|
|
||||||
// 设置线程和事件循环组
|
|
||||||
config.setThreads(thread);
|
|
||||||
config.setEventLoopGroup(new NioEventLoopGroup());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void configureClusterMode(Config config, String pwd) {
|
||||||
* 验证主从模式地址
|
String[] nodeAddresses = normalizeAddresses(address.split(","));
|
||||||
*/
|
config.useClusterServers()
|
||||||
private static void validateMasterSlaveAddresses(String[] addresses) {
|
.setScanInterval(scanInterval)
|
||||||
if (addresses.length == 1) {
|
.addNodeAddress(nodeAddresses)
|
||||||
throw new IllegalArgumentException(
|
.setPassword(pwd)
|
||||||
"redis.redisson.address MUST have multiple redis addresses for master-slave mode.");
|
.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) {
|
||||||
|
// 设置编码器
|
||||||
|
if (StringUtils.isNotBlank(codec)) {
|
||||||
|
try {
|
||||||
|
Class<?> codecClass = ClassUtils.forName(codec, ClassUtils.getDefaultClassLoader());
|
||||||
|
Codec codecInstance = (Codec) codecClass.getDeclaredConstructor().newInstance();
|
||||||
|
config.setCodec(codecInstance);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException("Failed to create Redisson codec: " + codec, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 设置线程数(大于0时生效,否则Redisson使用默认值:CPU核数*2)
|
||||||
|
if (threads > 0) {
|
||||||
|
config.setThreads(threads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================== Getter和Setter方法 ==========================
|
// ========================== 辅助方法 ==========================
|
||||||
|
|
||||||
// 连接配置
|
/**
|
||||||
public String getAddress() {
|
* 自动补齐 Redis 地址协议前缀(redis:// 或 rediss://)
|
||||||
return address;
|
*/
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddress(String address) {
|
private String[] normalizeAddresses(String[] addresses) {
|
||||||
RedissonConfig.address = address;
|
String[] normalized = new String[addresses.length];
|
||||||
|
for (int i = 0; i < addresses.length; i++) {
|
||||||
|
normalized[i] = normalizeAddress(addresses[i]);
|
||||||
|
}
|
||||||
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
private void validateMasterSlaveAddresses(String[] addresses) {
|
||||||
return password;
|
if (addresses.length < 2) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Master-slave mode requires at least 2 addresses: master and at least one slave. " +
|
||||||
|
"Current addresses: " + String.join(",", addresses));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassword(String password) {
|
// ========================== Getter / Setter(供 Spring 绑定配置) ==========================
|
||||||
RedissonConfig.password = password;
|
// 以下所有字段都需要提供 getter/setter,示例中只列出关键字段,实际使用时请补全所有字段。
|
||||||
}
|
// 建议使用 Lombok @Data 或 IDE 自动生成。这里只展示部分,避免篇幅过长。
|
||||||
|
|
||||||
public String getClientName() {
|
public String getAddress() { return address; }
|
||||||
return clientName;
|
public void setAddress(String address) { this.address = address; }
|
||||||
}
|
|
||||||
|
|
||||||
public void setClientName(String clientName) {
|
public String getPassword() { return password; }
|
||||||
RedissonConfig.clientName = clientName;
|
public void setPassword(String password) { this.password = password; }
|
||||||
}
|
|
||||||
|
|
||||||
public int getDatabase() {
|
public String getClientName() { return clientName; }
|
||||||
return database;
|
public void setClientName(String clientName) { this.clientName = clientName; }
|
||||||
}
|
|
||||||
|
|
||||||
public void setDatabase(int database) {
|
public int getDatabase() { return database; }
|
||||||
RedissonConfig.database = database;
|
public void setDatabase(int database) { this.database = database; }
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMode() {
|
public String getMode() { return mode; }
|
||||||
return mode;
|
public void setMode(String mode) { this.mode = mode; }
|
||||||
}
|
|
||||||
|
|
||||||
public void setMode(String mode) {
|
public String getMasterName() { return masterName; }
|
||||||
RedissonConfig.mode = mode;
|
public void setMasterName(String masterName) { this.masterName = masterName; }
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMasterNamee() {
|
public int getIdleConnectionTimeout() { return idleConnectionTimeout; }
|
||||||
return masterName;
|
public void setIdleConnectionTimeout(int idleConnectionTimeout) { this.idleConnectionTimeout = idleConnectionTimeout; }
|
||||||
}
|
|
||||||
|
|
||||||
public void setMasterNamee(String masterName) {
|
public int getConnectTimeout() { return connectTimeout; }
|
||||||
RedissonConfig.masterName = masterName;
|
public void setConnectTimeout(int connectTimeout) { this.connectTimeout = connectTimeout; }
|
||||||
}
|
|
||||||
|
|
||||||
// 超时配置
|
public int getTimeout() { return timeout; }
|
||||||
public int getIdleConnectionTimeout() {
|
public void setTimeout(int timeout) { this.timeout = timeout; }
|
||||||
return idleConnectionTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdleConnectionTimeout(int idleConnectionTimeout) {
|
public int getRetryAttempts() { return retryAttempts; }
|
||||||
RedissonConfig.idleConnectionTimeout = idleConnectionTimeout;
|
public void setRetryAttempts(int retryAttempts) { this.retryAttempts = retryAttempts; }
|
||||||
}
|
|
||||||
|
|
||||||
public int getConnectTimeout() {
|
public int getRetryInterval() { return retryInterval; }
|
||||||
return connectTimeout;
|
public void setRetryInterval(int retryInterval) { this.retryInterval = retryInterval; }
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnectTimeout(int connectTimeout) {
|
public int getConnectionMinimumIdleSize() { return connectionMinimumIdleSize; }
|
||||||
RedissonConfig.connectTimeout = connectTimeout;
|
public void setConnectionMinimumIdleSize(int connectionMinimumIdleSize) { this.connectionMinimumIdleSize = connectionMinimumIdleSize; }
|
||||||
}
|
|
||||||
|
|
||||||
public int getTimeout() {
|
public int getConnectionPoolSize() { return connectionPoolSize; }
|
||||||
return timeout;
|
public void setConnectionPoolSize(int connectionPoolSize) { this.connectionPoolSize = connectionPoolSize; }
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeout(int timeout) {
|
public int getSubscriptionsPerConnection() { return subscriptionsPerConnection; }
|
||||||
RedissonConfig.timeout = timeout;
|
public void setSubscriptionsPerConnection(int subscriptionsPerConnection) { this.subscriptionsPerConnection = subscriptionsPerConnection; }
|
||||||
}
|
|
||||||
|
|
||||||
// 重试配置
|
public int getSubscriptionConnectionMinimumIdleSize() { return subscriptionConnectionMinimumIdleSize; }
|
||||||
public int getRetryAttempts() {
|
public void setSubscriptionConnectionMinimumIdleSize(int subscriptionConnectionMinimumIdleSize) { this.subscriptionConnectionMinimumIdleSize = subscriptionConnectionMinimumIdleSize; }
|
||||||
return retryAttempts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRetryAttempts(int retryAttempts) {
|
public int getSubscriptionConnectionPoolSize() { return subscriptionConnectionPoolSize; }
|
||||||
RedissonConfig.retryAttempts = retryAttempts;
|
public void setSubscriptionConnectionPoolSize(int subscriptionConnectionPoolSize) { this.subscriptionConnectionPoolSize = subscriptionConnectionPoolSize; }
|
||||||
}
|
|
||||||
|
|
||||||
public int getRetryInterval() {
|
public int getScanInterval() { return scanInterval; }
|
||||||
return retryInterval;
|
public void setScanInterval(int scanInterval) { this.scanInterval = scanInterval; }
|
||||||
}
|
|
||||||
|
|
||||||
public void setRetryInterval(int retryInterval) {
|
public int getDnsMonitoringInterval() { return dnsMonitoringInterval; }
|
||||||
RedissonConfig.retryInterval = retryInterval;
|
public void setDnsMonitoringInterval(int dnsMonitoringInterval) { this.dnsMonitoringInterval = dnsMonitoringInterval; }
|
||||||
}
|
|
||||||
|
|
||||||
// 连接池配置
|
public int getThreads() { return threads; }
|
||||||
public int getConnectionMinimumIdleSize() {
|
public void setThreads(int threads) { this.threads = threads; }
|
||||||
return connectionMinimumIdleSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnectionMinimumIdleSize(int connectionMinimumIdleSize) {
|
public String getCodec() { return codec; }
|
||||||
RedissonConfig.connectionMinimumIdleSize = connectionMinimumIdleSize;
|
public void setCodec(String codec) { this.codec = codec; }
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
package cn.keking.service.cache.impl;
|
package cn.keking.service.cache.impl;
|
||||||
|
|
||||||
import cn.keking.service.cache.CacheService;
|
import cn.keking.service.cache.CacheService;
|
||||||
import org.redisson.Redisson;
|
|
||||||
import org.redisson.api.RBlockingQueue;
|
import org.redisson.api.RBlockingQueue;
|
||||||
import org.redisson.api.RMapCache;
|
import org.redisson.api.RMapCache;
|
||||||
import org.redisson.api.RedissonClient;
|
import org.redisson.api.RedissonClient;
|
||||||
import org.redisson.config.Config;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -23,8 +21,9 @@ public class CacheServiceRedisImpl implements CacheService {
|
|||||||
|
|
||||||
private final RedissonClient redissonClient;
|
private final RedissonClient redissonClient;
|
||||||
|
|
||||||
public CacheServiceRedisImpl(Config config) {
|
// 直接注入 Spring 容器中的 RedissonClient Bean
|
||||||
this.redissonClient = Redisson.create(config);
|
public CacheServiceRedisImpl(RedissonClient redissonClient) {
|
||||||
|
this.redissonClient = redissonClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class AttributeSetFilter implements Filter {
|
|||||||
request.setAttribute("pdfDownloadDisable", ConfigConstants.getPdfDownloadDisable());
|
request.setAttribute("pdfDownloadDisable", ConfigConstants.getPdfDownloadDisable());
|
||||||
request.setAttribute("pdfBookmarkDisable", ConfigConstants.getPdfBookmarkDisable());
|
request.setAttribute("pdfBookmarkDisable", ConfigConstants.getPdfBookmarkDisable());
|
||||||
request.setAttribute("pdfDisableEditing", ConfigConstants.getPdfDisableEditing());
|
request.setAttribute("pdfDisableEditing", ConfigConstants.getPdfDisableEditing());
|
||||||
|
request.setAttribute("pdfSidebarOpen", ConfigConstants.getPdfSidebarOpen());
|
||||||
request.setAttribute("switchDisabled", ConfigConstants.getOfficePreviewSwitchDisabled());
|
request.setAttribute("switchDisabled", ConfigConstants.getOfficePreviewSwitchDisabled());
|
||||||
request.setAttribute("fileUploadDisable", ConfigConstants.getFileUploadDisable());
|
request.setAttribute("fileUploadDisable", ConfigConstants.getFileUploadDisable());
|
||||||
request.setAttribute("beian", ConfigConstants.getBeian());
|
request.setAttribute("beian", ConfigConstants.getBeian());
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1221,8 +1221,6 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||||||
<!-- editorUndoBar -->
|
<!-- editorUndoBar -->
|
||||||
</div>
|
</div>
|
||||||
<!-- outerContainer -->
|
<!-- 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>
|
<div id="printContainer"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -9,6 +9,83 @@ if (kkpdfAutoFetch == "true") {
|
|||||||
} else {
|
} else {
|
||||||
kkpdfAutoFetch = false
|
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__ = ({
|
/******/ var __webpack_modules__ = ({
|
||||||
|
|
||||||
/***/ 34:
|
/***/ 34:
|
||||||
@@ -13874,37 +13951,43 @@ class PDFPrintService {
|
|||||||
};
|
};
|
||||||
return new Promise(renderNextPage);
|
return new Promise(renderNextPage);
|
||||||
}
|
}
|
||||||
useRenderedPage() {
|
useRenderedPage() {
|
||||||
this.throwIfInactive();
|
this.throwIfInactive();
|
||||||
const img = document.createElement("img");
|
const img = document.createElement("img");
|
||||||
this.scratchCanvas.toBlob(blob => {
|
|
||||||
img.src = URL.createObjectURL(blob);
|
|
||||||
});
|
|
||||||
const wrapper = document.createElement("div");
|
const wrapper = document.createElement("div");
|
||||||
wrapper.className = "printedPage";
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
wrapper.append(img);
|
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);
|
this.printContainer.append(wrapper);
|
||||||
const {
|
|
||||||
promise,
|
const { promise, resolve, reject } = Promise.withResolvers();
|
||||||
resolve,
|
img.onload = () => {
|
||||||
reject
|
// 使用专用函数生成水印,直接传入页面像素尺寸
|
||||||
} = Promise.withResolvers();
|
addWatermark(wrapper, watermarkTxt, pageWidthPx, pageHeightPx);
|
||||||
img.onload = resolve;
|
resolve();
|
||||||
|
};
|
||||||
img.onerror = reject;
|
img.onerror = reject;
|
||||||
promise.catch(() => {}).then(() => {
|
promise.catch(() => {}).then(() => {
|
||||||
URL.revokeObjectURL(img.src);
|
URL.revokeObjectURL(img.src);
|
||||||
});
|
});
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
performPrint() {
|
performPrint() {
|
||||||
this.throwIfInactive();
|
this.throwIfInactive();
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -17612,7 +17695,7 @@ class PDFPageView extends BasePDFPageView {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
watermarkObj(div,watermarkTxt);
|
addWatermark(div,watermarkTxt);
|
||||||
if (!this.annotationLayer && this.#annotationMode !== AnnotationMode.DISABLE) {
|
if (!this.annotationLayer && this.#annotationMode !== AnnotationMode.DISABLE) {
|
||||||
const {
|
const {
|
||||||
annotationStorage,
|
annotationStorage,
|
||||||
@@ -23083,24 +23166,26 @@ initCom(PDFViewerApplication);
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
const HOSTED_VIEWER_ORIGINS = new Set(["null", "http://mozilla.github.io", "https://mozilla.github.io"]);
|
const HOSTED_VIEWER_ORIGINS = new Set(["null", "http://mozilla.github.io", "https://mozilla.github.io"]);
|
||||||
var validateFileURL = function (file) {
|
var validateFileURL = function (file) {
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const viewerOrigin = URL.parse(window.location)?.origin || "null";
|
const viewerOrigin = URL.parse(window.location)?.origin || "null";
|
||||||
if (HOSTED_VIEWER_ORIGINS.has(viewerOrigin)) {
|
if (HOSTED_VIEWER_ORIGINS.has(viewerOrigin)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fileOrigin = URL.parse(file, window.location)?.origin;
|
/* 注释掉跨域检查
|
||||||
if (fileOrigin === viewerOrigin) {
|
const fileOrigin = URL.parse(file, window.location)?.origin;
|
||||||
return;
|
if (fileOrigin === viewerOrigin) {
|
||||||
}
|
return;
|
||||||
const ex = new Error("file origin does not match viewer's");
|
}
|
||||||
PDFViewerApplication._documentError("pdfjs-loading-error", {
|
const ex = new Error("file origin does not match viewer's");
|
||||||
message: ex.message
|
PDFViewerApplication._documentError("pdfjs-loading-error", {
|
||||||
});
|
message: ex.message
|
||||||
throw ex;
|
});
|
||||||
};
|
throw ex;
|
||||||
|
*/
|
||||||
|
};
|
||||||
var onFileInputChange = function (evt) {
|
var onFileInputChange = function (evt) {
|
||||||
if (this.pdfViewer?.isInPresentationMode) {
|
if (this.pdfViewer?.isInPresentationMode) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -41,10 +41,10 @@
|
|||||||
你可以先看最新版本的升级重点,再顺着时间轴继续了解历史版本细节。
|
你可以先看最新版本的升级重点,再顺着时间轴继续了解历史版本细节。
|
||||||
</p>
|
</p>
|
||||||
<div class="release-badge-row">
|
<div class="release-badge-row">
|
||||||
<span class="tag highlight">最新版本 v5.0</span>
|
<span class="tag highlight">最新版本 v5.0.0</span>
|
||||||
<span class="tag brand">发布日期 2026-01-20</span>
|
<span class="tag brand">发布日期 2026-04-14</span>
|
||||||
<span class="tag warn">JDK 21+ 强制要求</span>
|
<span class="tag warn">JDK 21+ 强制要求</span>
|
||||||
<span class="tag">PDF / TIF / CAD 异步化</span>
|
<span class="tag">压缩包工作区预览 / PDF 默认模式</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -53,9 +53,9 @@
|
|||||||
<div class="timeline-year">2026</div>
|
<div class="timeline-year">2026</div>
|
||||||
<div class="timeline-list">
|
<div class="timeline-list">
|
||||||
<article class="release-card">
|
<article class="release-card">
|
||||||
<h3>v5.0</h3>
|
<h3>v5.0.0</h3>
|
||||||
<div class="release-meta">
|
<div class="release-meta">
|
||||||
<span class="tag brand">2026-01-20</span>
|
<span class="tag brand">2026-04-14</span>
|
||||||
<span class="tag highlight">最新稳定版本</span>
|
<span class="tag highlight">最新稳定版本</span>
|
||||||
<span class="tag warn">升级需 JDK 21+</span>
|
<span class="tag warn">升级需 JDK 21+</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -66,6 +66,9 @@
|
|||||||
<li>优化 xlsx、图片、tif、svg、json 解析效果。</li>
|
<li>优化 xlsx、图片、tif、svg、json 解析效果。</li>
|
||||||
<li>优化 FTP 多客户端接入与 marked 解析。</li>
|
<li>优化 FTP 多客户端接入与 marked 解析。</li>
|
||||||
<li>首页支持目录访问,并切换为 POST 服务端分页。</li>
|
<li>首页支持目录访问,并切换为 POST 服务端分页。</li>
|
||||||
|
<li>压缩包预览页重构为单工作区布局,支持目录折叠与右侧内嵌预览。</li>
|
||||||
|
<li>优化压缩包内文件类型标识,以及单图预览页展示样式。</li>
|
||||||
|
<li>重构演示门户页面,包括首页、接入说明、版本记录与赞助页。</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="release-group">
|
<div class="release-group">
|
||||||
@@ -74,6 +77,7 @@
|
|||||||
<li>新增 msg、heic/heif、页码、高亮、AES、Basic Auth、秘钥等能力。</li>
|
<li>新增 msg、heic/heif、页码、高亮、AES、Basic Auth、秘钥等能力。</li>
|
||||||
<li>新增防重复转换、异步等待、上传限制与 cadviewer 转换方法。</li>
|
<li>新增防重复转换、异步等待、上传限制与 cadviewer 转换方法。</li>
|
||||||
<li>新增 pptm 支持。</li>
|
<li>新增 pptm 支持。</li>
|
||||||
|
<li>补充面向工程自动化与编码代理的仓库说明文档。</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="release-group">
|
<div class="release-group">
|
||||||
@@ -82,6 +86,9 @@
|
|||||||
<li>修复压缩包路径问题与安全问题。</li>
|
<li>修复压缩包路径问题与安全问题。</li>
|
||||||
<li>修复图片水印不完整。</li>
|
<li>修复图片水印不完整。</li>
|
||||||
<li>修复 SSL 自签证书接入问题。</li>
|
<li>修复 SSL 自签证书接入问题。</li>
|
||||||
|
<li>修复压缩包内 Office 文件重复解压后被追加写坏、导致一直加载中的问题。</li>
|
||||||
|
<li>Office 默认预览切到 PDF 模式,并默认展开 PDF 缩略图侧栏。</li>
|
||||||
|
<li>修复 OFD 表格竖线溢出导致的渲染异常,并修正 PDF.js 兼容性补丁。</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="release-group">
|
<div class="release-group">
|
||||||
@@ -90,6 +97,9 @@
|
|||||||
<li>JDK 版本要求升级到 21 及以上。</li>
|
<li>JDK 版本要求升级到 21 及以上。</li>
|
||||||
<li>前端解析链路升级:PDF、ODF、3D 模型。</li>
|
<li>前端解析链路升级:PDF、ODF、3D 模型。</li>
|
||||||
<li>后端异步转换升级:PDF、TIF、视频、CAD。</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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,55 +1,87 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
|
||||||
<title>PDF预览</title>
|
<title>PDF预览</title>
|
||||||
<#include "*/commonHeader.ftl">
|
<#include "*/commonHeader.ftl">
|
||||||
<script src="js/base64.min.js" type="text/javascript"></script>
|
<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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<#if pdfUrl?contains("http://") || pdfUrl?contains("https://")>
|
<#if pdfUrl?contains("http://") || pdfUrl?contains("https://")>
|
||||||
<#assign finalUrl="${pdfUrl}">
|
<#assign finalUrl="${pdfUrl}">
|
||||||
<#else>
|
<#else>
|
||||||
<#assign finalUrl="${baseUrl}${pdfUrl}">
|
<#assign finalUrl="${baseUrl}${pdfUrl}">
|
||||||
</#if>
|
</#if>
|
||||||
<iframe src="" width="100%" frameborder="0"></iframe>
|
|
||||||
|
<iframe id="pdfFrame" src="about:blank"></iframe>
|
||||||
|
|
||||||
<#if "false" == switchDisabled>
|
<#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>
|
</#if>
|
||||||
</body>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var url = '${finalUrl}';
|
var url = '${finalUrl}';
|
||||||
var kkagent = '${kkagent}';
|
var kkagent = '${kkagent}';
|
||||||
var baseUrl = '${baseUrl}'.endsWith('/') ? '${baseUrl}' : '${baseUrl}' + '/';
|
var baseUrl = '${baseUrl}'.endsWith('/') ? '${baseUrl}' : '${baseUrl}' + '/';
|
||||||
if (kkagent === 'true' || !url.startsWith(baseUrl)) {
|
if (kkagent === 'true' || !url.startsWith(baseUrl)) {
|
||||||
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url))+ "&key=${kkkey}";
|
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() {
|
function goForImage() {
|
||||||
var url = window.location.href
|
var href = window.location.href;
|
||||||
if (url.indexOf("officePreviewType=pdf") != -1) {
|
if (href.indexOf("officePreviewType=pdf") !== -1) {
|
||||||
url = url.replace("officePreviewType=pdf", "officePreviewType=image");
|
href = href.replace("officePreviewType=pdf", "officePreviewType=image");
|
||||||
} else {
|
} else {
|
||||||
url = url + "&officePreviewType=image";
|
href += (href.indexOf('?') === -1 ? '?' : '&') + "officePreviewType=image";
|
||||||
}
|
}
|
||||||
window.location.href = url;
|
window.location.href = href;
|
||||||
}
|
|
||||||
|
|
||||||
/*初始化水印*/
|
|
||||||
window.onload = function () {
|
|
||||||
initWaterMark();
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ public class PdfViewerCompatibilityTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldOpenPdfPreviewWithThumbnailSidebarByDefault() throws IOException {
|
void shouldRenderPdfSidebarModeByDefaultBasedOnConfig() throws IOException {
|
||||||
String pdfTemplate = readResource("/web/pdf.ftl");
|
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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user