Showing
4 changed files
with
17 additions
and
14 deletions
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; | @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; | ||
2 | import './index.less'; | 2 | import './index.less'; |
3 | 3 | ||
4 | interface pdfPreviewProps { | 4 | interface pdfPreviewProps { |
5 | - url: string | 5 | + url?: string |
6 | } | 6 | } |
7 | 7 | ||
8 | const pdfPreview = (props: pdfPreviewProps) => { | 8 | const pdfPreview = (props: pdfPreviewProps) => { |
@@ -19,13 +19,11 @@ const pdfPreview = (props: pdfPreviewProps) => { | @@ -19,13 +19,11 @@ const pdfPreview = (props: pdfPreviewProps) => { | ||
19 | <div className={'pdfPreview'}> | 19 | <div className={'pdfPreview'}> |
20 | {/* pdf属性 page 跳转到指定页码,navpanes 控制左侧的缩略图预览导航是否默认打开。0-关闭,1-打开*/} | 20 | {/* pdf属性 page 跳转到指定页码,navpanes 控制左侧的缩略图预览导航是否默认打开。0-关闭,1-打开*/} |
21 | {/* navpanes=0&scrollbars=0&toolbar=0&statusbar=0 去除缩略图和工具栏 */} | 21 | {/* navpanes=0&scrollbars=0&toolbar=0&statusbar=0 去除缩略图和工具栏 */} |
22 | - {/* frameborder=0 和view=FitH,top 为全屏展示 */} | 22 | + {/* view=FitH,top 为全屏展示 */} |
23 | <iframe | 23 | <iframe |
24 | title="pdf-preview" | 24 | title="pdf-preview" |
25 | style={{ width: '100%', height: '100%' }} | 25 | style={{ width: '100%', height: '100%' }} |
26 | - frameborder="0" | ||
27 | src={`${filePath}#page=1&navpanes=0&scrollbars=0&toolbar=0&statusbar=0&view=FitH,top`} | 26 | src={`${filePath}#page=1&navpanes=0&scrollbars=0&toolbar=0&statusbar=0&view=FitH,top`} |
28 | - // src={`${filePath}`} | ||
29 | /> | 27 | /> |
30 | </div> | 28 | </div> |
31 | ); | 29 | ); |
@@ -7,12 +7,13 @@ import {useSearchParams} from "react-router-dom"; | @@ -7,12 +7,13 @@ import {useSearchParams} from "react-router-dom"; | ||
7 | import {getCarouselSettings} from "@/api/apiConfig"; | 7 | import {getCarouselSettings} from "@/api/apiConfig"; |
8 | import _ from 'lodash'; | 8 | import _ from 'lodash'; |
9 | import { useNavigate } from 'react-router-dom'; | 9 | import { useNavigate } from 'react-router-dom'; |
10 | +import {ListType} from "@/pages/production/list"; | ||
10 | 11 | ||
11 | 12 | ||
12 | const ProductionDetail: React.FC = () => { | 13 | const ProductionDetail: React.FC = () => { |
13 | let navigate = useNavigate(); | 14 | let navigate = useNavigate(); |
14 | const [title, setTitle] = useState<string>(''); | 15 | const [title, setTitle] = useState<string>(''); |
15 | - const [filePathItem, setFilePathItem] = useState(); | 16 | + const [filePathItem, setFilePathItem] = useState<ListType>(); |
16 | // 自动预览 定时器 | 17 | // 自动预览 定时器 |
17 | const [preViewTimer, setPreViewTimer] = useState<any>(null); | 18 | const [preViewTimer, setPreViewTimer] = useState<any>(null); |
18 | 19 | ||
@@ -21,7 +22,7 @@ const ProductionDetail: React.FC = () => { | @@ -21,7 +22,7 @@ const ProductionDetail: React.FC = () => { | ||
21 | // // 通过 get 方法获取目标参数 | 22 | // // 通过 get 方法获取目标参数 |
22 | const name = params.get("name") || ""; | 23 | const name = params.get("name") || ""; |
23 | 24 | ||
24 | - const sxPreViewList = localStorage.getItem('sxPreViewListStorage') ? JSON.parse(localStorage.getItem('sxPreViewListStorage')) : []; | 25 | + const sxPreViewList: any[] = JSON.parse(localStorage.getItem('sxPreViewListStorage') || "[]") || []; |
25 | 26 | ||
26 | useEffect(() => { | 27 | useEffect(() => { |
27 | if (sxPreViewList?.length) { | 28 | if (sxPreViewList?.length) { |
@@ -77,14 +78,14 @@ const ProductionDetail: React.FC = () => { | @@ -77,14 +78,14 @@ const ProductionDetail: React.FC = () => { | ||
77 | <div className={'sxjx-content-main sxjx-layout-main-unfoot'}> | 78 | <div className={'sxjx-content-main sxjx-layout-main-unfoot'}> |
78 | <div className={'production-detail'}> | 79 | <div className={'production-detail'}> |
79 | <NavBar showBack={true} title={title} customBack={{onClick: () => { | 80 | <NavBar showBack={true} title={title} customBack={{onClick: () => { |
80 | - const _url = localStorage.getItem('sxListPath'); | 81 | + const _url = localStorage.getItem('sxListPath') || ''; |
81 | navigate(_url, { replace: true }); | 82 | navigate(_url, { replace: true }); |
82 | }}} | 83 | }}} |
83 | /> | 84 | /> |
84 | { | 85 | { |
85 | filePathItem?.type === 'mp4' ? <div className={'production-detail-video-box'}> | 86 | filePathItem?.type === 'mp4' ? <div className={'production-detail-video-box'}> |
86 | <VideoPlay | 87 | <VideoPlay |
87 | - key={filePathItem?.url} | 88 | + key={filePathItem?.url || ''} |
88 | url={filePathItem?.url || ''} | 89 | url={filePathItem?.url || ''} |
89 | className={'production-detail-video'} | 90 | className={'production-detail-video'} |
90 | /> | 91 | /> |
@@ -10,14 +10,15 @@ import {getFilePreview, getProductBook} from "@/api/apiConfig"; | @@ -10,14 +10,15 @@ import {getFilePreview, getProductBook} from "@/api/apiConfig"; | ||
10 | import {SpinLoading, Checkbox, Toast} from 'antd-mobile' | 10 | import {SpinLoading, Checkbox, Toast} from 'antd-mobile' |
11 | import { useNavigate, useLocation } from "react-router-dom"; | 11 | import { useNavigate, useLocation } from "react-router-dom"; |
12 | 12 | ||
13 | -interface ListType { | 13 | +export interface ListType { |
14 | id: string; | 14 | id: string; |
15 | fileId: string; | 15 | fileId: string; |
16 | name: string; | 16 | name: string; |
17 | + url?: string; | ||
17 | type: 'pdf' | 'mp4' | string | 18 | type: 'pdf' | 'mp4' | string |
18 | } | 19 | } |
19 | 20 | ||
20 | -type CheckboxValue = string; | 21 | +type CheckboxValue = string | number; |
21 | 22 | ||
22 | const ProductionList: React.FC = () => { | 23 | const ProductionList: React.FC = () => { |
23 | const [title, setTitle] = useState<string>(''); | 24 | const [title, setTitle] = useState<string>(''); |
@@ -49,7 +50,7 @@ const ProductionList: React.FC = () => { | @@ -49,7 +50,7 @@ const ProductionList: React.FC = () => { | ||
49 | setShow(false); | 50 | setShow(false); |
50 | getProductBook({pro_line: id}).then((res: any) => { | 51 | getProductBook({pro_line: id}).then((res: any) => { |
51 | setShow(true); | 52 | setShow(true); |
52 | - let _checkItems = []; | 53 | + let _checkItems: CheckboxValue[] = []; |
53 | const _list = res?.product_book?.map((item: any) => { | 54 | const _list = res?.product_book?.map((item: any) => { |
54 | _checkItems.push(item?.id); | 55 | _checkItems.push(item?.id); |
55 | const _arr = item?.guide_book_file_info_?.[0]?.name?.split('.') || []; | 56 | const _arr = item?.guide_book_file_info_?.[0]?.name?.split('.') || []; |
@@ -63,6 +64,7 @@ const ProductionList: React.FC = () => { | @@ -63,6 +64,7 @@ const ProductionList: React.FC = () => { | ||
63 | setList(_list) | 64 | setList(_list) |
64 | setCheckItems(_checkItems) | 65 | setCheckItems(_checkItems) |
65 | }).catch((e: any) => { | 66 | }).catch((e: any) => { |
67 | + console.log('e', e) | ||
66 | setShow(true); | 68 | setShow(true); |
67 | setList([]) | 69 | setList([]) |
68 | }) | 70 | }) |
@@ -98,17 +100,18 @@ const ProductionList: React.FC = () => { | @@ -98,17 +100,18 @@ const ProductionList: React.FC = () => { | ||
98 | // 使用Promise.all来并行地解决这些promise | 100 | // 使用Promise.all来并行地解决这些promise |
99 | Promise.all(promises) | 101 | Promise.all(promises) |
100 | .then((results: any) => { | 102 | .then((results: any) => { |
101 | - let sxPreViewList = _arr?.map((it: ListType, index: number) => { | 103 | + let sxPreViewList: ListType[] = _arr?.map((it: ListType, index: number) => { |
102 | return { | 104 | return { |
103 | ...it, | 105 | ...it, |
104 | - url: results?.[index] | 106 | + url: results?.[index] || '' |
105 | } | 107 | } |
106 | }) | 108 | }) |
107 | localStorage.setItem('sxPreViewListStorage', JSON.stringify(sxPreViewList)); | 109 | localStorage.setItem('sxPreViewListStorage', JSON.stringify(sxPreViewList)); |
108 | localStorage.setItem('sxListPath', `${location?.pathname}${location?.search}`); | 110 | localStorage.setItem('sxListPath', `${location?.pathname}${location?.search}`); |
109 | navigate(`/production/detail?name=${sxPreViewList?.[0]?.name}`, { replace: true }); | 111 | navigate(`/production/detail?name=${sxPreViewList?.[0]?.name}`, { replace: true }); |
110 | }) | 112 | }) |
111 | - .catch(err => { | 113 | + .catch((e: any) => { |
114 | + console.log('e', e) | ||
112 | localStorage.setItem('sxPreViewListStorage', ''); | 115 | localStorage.setItem('sxPreViewListStorage', ''); |
113 | localStorage.setItem('sxListPath', ''); | 116 | localStorage.setItem('sxListPath', ''); |
114 | }); | 117 | }); |
@@ -30,6 +30,7 @@ const ProductionManagement: React.FC = () => { | @@ -30,6 +30,7 @@ const ProductionManagement: React.FC = () => { | ||
30 | setList(_list) | 30 | setList(_list) |
31 | 31 | ||
32 | }).catch((e: any) => { | 32 | }).catch((e: any) => { |
33 | + console.log('e', e) | ||
33 | setShow(true); | 34 | setShow(true); |
34 | setList([]) | 35 | setList([]) |
35 | }) | 36 | }) |