Showing
3 changed files
with
10 additions
and
11 deletions
@@ -13,13 +13,14 @@ | @@ -13,13 +13,14 @@ | ||
13 | "antd-mobile": "^5.38.1", | 13 | "antd-mobile": "^5.38.1", |
14 | "antd-mobile-icons": "^0.3.0", | 14 | "antd-mobile-icons": "^0.3.0", |
15 | "axios": "^1.7.9", | 15 | "axios": "^1.7.9", |
16 | + "lodash": "^4.17.11", | ||
16 | "react": "^18.3.1", | 17 | "react": "^18.3.1", |
17 | "react-dom": "^18.3.1", | 18 | "react-dom": "^18.3.1", |
18 | - "react-router-dom": "^7.1.1", | ||
19 | - "lodash": "^4.17.11" | 19 | + "react-router-dom": "^7.1.1" |
20 | }, | 20 | }, |
21 | "devDependencies": { | 21 | "devDependencies": { |
22 | "@eslint/js": "^9.17.0", | 22 | "@eslint/js": "^9.17.0", |
23 | + "@types/lodash": "^4.17.7", | ||
23 | "@types/node": "^22.10.5", | 24 | "@types/node": "^22.10.5", |
24 | "@types/react": "^18.3.18", | 25 | "@types/react": "^18.3.18", |
25 | "@types/react-dom": "^18.3.5", | 26 | "@types/react-dom": "^18.3.5", |
@@ -33,7 +34,6 @@ | @@ -33,7 +34,6 @@ | ||
33 | "postcss-px-to-viewport": "^1.1.1", | 34 | "postcss-px-to-viewport": "^1.1.1", |
34 | "typescript": "~5.6.2", | 35 | "typescript": "~5.6.2", |
35 | "typescript-eslint": "^8.18.2", | 36 | "typescript-eslint": "^8.18.2", |
36 | - "vite": "^5.3.4", | ||
37 | - "@types/lodash": "^4.17.7" | 37 | + "vite": "^5.3.4" |
38 | } | 38 | } |
39 | } | 39 | } |
@@ -8,22 +8,21 @@ interface pdfPreviewProps { | @@ -8,22 +8,21 @@ interface pdfPreviewProps { | ||
8 | const pdfPreview = (props: pdfPreviewProps) => { | 8 | const pdfPreview = (props: pdfPreviewProps) => { |
9 | const [filePath, setFilePath] = useState<string>(); | 9 | const [filePath, setFilePath] = useState<string>(); |
10 | 10 | ||
11 | + const _origin = window.location.origin; | ||
12 | + | ||
11 | useEffect(()=>{ | 13 | useEffect(()=>{ |
12 | if (props.url) { | 14 | if (props.url) { |
13 | - setFilePath(props.url); | 15 | + const _url = encodeURIComponent(props.url); |
16 | + setFilePath(_url); | ||
14 | } | 17 | } |
15 | },[props.url]) | 18 | },[props.url]) |
16 | 19 | ||
17 | - | ||
18 | return ( | 20 | return ( |
19 | <div className={'pdfPreview'}> | 21 | <div className={'pdfPreview'}> |
20 | - {/* pdf属性 page 跳转到指定页码,navpanes 控制左侧的缩略图预览导航是否默认打开。0-关闭,1-打开*/} | ||
21 | - {/* navpanes=0&scrollbars=0&toolbar=0&statusbar=0 去除缩略图和工具栏 */} | ||
22 | - {/* view=FitH,top 为全屏展示 */} | ||
23 | <iframe | 22 | <iframe |
24 | title="pdf-preview" | 23 | title="pdf-preview" |
25 | style={{ width: '100%', height: '100%' }} | 24 | style={{ width: '100%', height: '100%' }} |
26 | - src={`${filePath}#page=1&navpanes=0&scrollbars=0&toolbar=0&statusbar=0&view=FitH,top`} | 25 | + src={`${_origin}/pdf/web/viewer.html?file=${filePath}`} |
27 | /> | 26 | /> |
28 | </div> | 27 | </div> |
29 | ); | 28 | ); |
@@ -105,7 +105,7 @@ const ProductionList: React.FC = () => { | @@ -105,7 +105,7 @@ const ProductionList: React.FC = () => { | ||
105 | ...it, | 105 | ...it, |
106 | url: results?.[index] || '' | 106 | url: results?.[index] || '' |
107 | } | 107 | } |
108 | - }) | 108 | + }) || []; |
109 | localStorage.setItem('sxPreViewListStorage', JSON.stringify(sxPreViewList)); | 109 | localStorage.setItem('sxPreViewListStorage', JSON.stringify(sxPreViewList)); |
110 | localStorage.setItem('sxListPath', `${location?.pathname}${location?.search}`); | 110 | localStorage.setItem('sxListPath', `${location?.pathname}${location?.search}`); |
111 | navigate(`/production/detail?name=${sxPreViewList?.[0]?.name}`, { replace: true }); | 111 | navigate(`/production/detail?name=${sxPreViewList?.[0]?.name}`, { replace: true }); |