Commit 31819c898e7d7c2f0db36e913ca7aa77b27ae0c0

Authored by 史婷婷
1 parent 01d3ee63

feat: pdf-安卓访问不了,解决

@@ -8,6 +8,8 @@ interface pdfPreviewProps { @@ -8,6 +8,8 @@ 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 const _url = encodeURIComponent(props.url); 15 const _url = encodeURIComponent(props.url);
@@ -20,7 +22,7 @@ const pdfPreview = (props: pdfPreviewProps) => { @@ -20,7 +22,7 @@ const pdfPreview = (props: pdfPreviewProps) => {
20 <iframe 22 <iframe
21 title="pdf-preview" 23 title="pdf-preview"
22 style={{ width: '100%', height: '100%' }} 24 style={{ width: '100%', height: '100%' }}
23 - src={`https://h5jianke.21tb.com/file/generic_mobile/web/viewer.html?file=${filePath}`} 25 + src={`${_origin}/pdf/web/viewer.html?file=${filePath}`}
24 /> 26 />
25 </div> 27 </div>
26 ); 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 });