Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
梁杰芳
slm-fileview
Commits
58b1b50c
Commit
58b1b50c
authored
Apr 06, 2021
by
陈精华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复:pdf.js 跨域问题
parent
8f75df15
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
FilterConfiguration.java
...c/main/java/cn/keking/web/filter/FilterConfiguration.java
+0
-2
viewer.js
server/src/main/resources/static/pdfjs/web/viewer.js
+3
-5
pdf.ftl
server/src/main/resources/web/pdf.ftl
+6
-1
No files found.
server/src/main/java/cn/keking/web/filter/FilterConfiguration.java
View file @
58b1b50c
...
...
@@ -30,8 +30,6 @@ public class FilterConfiguration {
Set
<
String
>
filterUri
=
new
HashSet
<>();
filterUri
.
add
(
"/onlinePreview"
);
filterUri
.
add
(
"/picturesPreview"
);
filterUri
.
add
(
"/getCorsFile"
);
filterUri
.
add
(
"/addTask"
);
TrustHostFilter
filter
=
new
TrustHostFilter
();
FilterRegistrationBean
registrationBean
=
new
FilterRegistrationBean
();
registrationBean
.
setFilter
(
filter
);
...
...
server/src/main/resources/static/pdfjs/web/viewer.js
View file @
58b1b50c
...
...
@@ -2019,7 +2019,7 @@ var validateFileURL;
{
var
HOSTED_VIEWER_ORIGINS
=
[
"null"
,
"http://mozilla.github.io"
,
"https://mozilla.github.io"
];
validateFileURL
=
function
validateFileURL
(
file
,
base
)
{
validateFileURL
=
function
validateFileURL
(
file
)
{
if
(
file
===
undefined
)
{
return
;
}
...
...
@@ -2036,7 +2036,7 @@ var validateFileURL;
protocol
=
_ref11
.
protocol
;
if
(
origin
!==
viewerOrigin
&&
protocol
!==
"blob:"
)
{
return
(
base
.
endsWith
(
'/'
)
?
base
:
base
+
'/'
)
+
'getCorsFile?urlPath='
+
encodeURIComponent
(
file
);
throw
new
Error
(
"file origin does not match viewer's"
);
}
}
catch
(
ex
)
{
var
message
=
ex
&&
ex
.
message
;
...
...
@@ -2089,14 +2089,12 @@ function loadAndEnablePDFBug(enabledTabs) {
function
webViewerInitialized
()
{
var
appConfig
=
PDFViewerApplication
.
appConfig
;
var
file
;
var
base
;
var
disableDownload
;
var
queryString
=
document
.
location
.
search
.
substring
(
1
);
var
params
=
(
0
,
_ui_utils
.
parseQueryString
)(
queryString
);
file
=
"file"
in
params
?
params
.
file
:
_app_options
.
AppOptions
.
get
(
"defaultUrl"
);
base
=
'base'
in
params
?
params
.
base
:
appConfig
.
defaultUrl
;
disableDownload
=
'disabledownload'
in
params
?
params
.
disabledownload
:
'false'
;
validateFileURL
(
file
,
base
);
validateFileURL
(
file
);
var
fileInput
=
document
.
createElement
(
"input"
);
fileInput
.
id
=
appConfig
.
openFileInputName
;
fileInput
.
className
=
"fileInput"
;
...
...
server/src/main/resources/web/pdf.ftl
View file @
58b1b50c
...
...
@@ -21,7 +21,12 @@
</
#
if>
</body>
<script
type=
"text/javascript"
>
document
.
getElementsByTagName
(
'iframe'
)[
0
].
src
=
"${baseUrl}pdfjs/web/viewer.html?base=${baseUrl}&file="
+
encodeURIComponent
(
'${finalUrl}'
)
+
"&disabledownload=${pdfDownloadDisable}"
;
var
url
=
'${finalUrl}'
;
var
baseUrl
=
'${baseUrl}'
.
endsWith
(
'/'
)
?
'${baseUrl}'
:
'${baseUrl}'
+
'/'
;
if
(
!
url
.
startsWith
(
baseUrl
))
{
url
=
baseUrl
+
'getCorsFile?urlPath='
+
encodeURIComponent
(
url
);
}
document
.
getElementsByTagName
(
'iframe'
)[
0
].
src
=
"${baseUrl}pdfjs/web/viewer.html?file="
+
encodeURIComponent
(
url
)
+
"&disabledownload=${pdfDownloadDisable}"
;
document
.
getElementsByTagName
(
'iframe'
)[
0
].
height
=
document
.
documentElement
.
clientHeight
-
10
;
/**
* 页面变化调整高度
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment