Browse Source

下载完成

dev
wenlele 2 years ago
parent
commit
c6c7364cc2
  1. 1
      web/client/src/layout/actions/global.js
  2. 2
      web/client/src/layout/reducers/global.js
  3. 48
      web/client/src/sections/means/containers/projectMeans.jsx
  4. 3
      web/routes/attachment/index.js

1
web/client/src/layout/actions/global.js

@ -41,6 +41,7 @@ export function initApiRoot () {
iotVcmpWeb:res.iotVcmpWeb, iotVcmpWeb:res.iotVcmpWeb,
pomsMonitor:res.pomsMonitor, pomsMonitor:res.pomsMonitor,
dcWeb:res.dcWeb, dcWeb:res.dcWeb,
qiniu:res.qiniu,
} }
}) })
}); });

2
web/client/src/layout/reducers/global.js

@ -14,6 +14,7 @@ function global (state = {
iotVcmpWeb: '', iotVcmpWeb: '',
pomsMonitor:'', pomsMonitor:'',
dcWeb:'', dcWeb:'',
qiniu:{}
}, action) { }, action) {
const payload = action.payload; const payload = action.payload;
switch (action.type) { switch (action.type) {
@ -36,6 +37,7 @@ function global (state = {
iotVcmpWeb: payload.iotVcmpWeb, iotVcmpWeb: payload.iotVcmpWeb,
pomsMonitor:payload.pomsMonitor, pomsMonitor:payload.pomsMonitor,
dcWeb:payload.dcWeb, dcWeb:payload.dcWeb,
qiniu:payload.qiniu,
}).toJS(); }).toJS();
case PEPPROJECTID: case PEPPROJECTID:
return Immutable.fromJS(state).merge({ return Immutable.fromJS(state).merge({

48
web/client/src/sections/means/containers/projectMeans.jsx

@ -10,7 +10,7 @@ import './style.less'
const Rest = (props) => { const Rest = (props) => {
const { dispatch, actions, user, loading, clientHeight, overallProjectId } = props const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props
const { install, means } = actions const { install, means } = actions
const [pomsList, setPomsList] = useState([]); // const [pomsList, setPomsList] = useState([]); //
const [showPomsList, setShowPomsList] = useState([]); // const [showPomsList, setShowPomsList] = useState([]); //
@ -26,6 +26,8 @@ const Rest = (props) => {
const [dataSource, setDataSource] = useState([]) // const [dataSource, setDataSource] = useState([]) //
const [query, setQuery] = useState({ limit: 10, page: 0 }) const [query, setQuery] = useState({ limit: 10, page: 0 })
const [count, setCount] = useState(0) const [count, setCount] = useState(0)
const [videoModalV, setVideoModalV] = useState(false);
const [videoUrl, setvideoUrl] = useState(null);
@ -101,10 +103,8 @@ const Rest = (props) => {
} }
}) })
} }
console.log(treeData);
treeDataList(treeData) treeDataList(treeData)
let datas = params || query let datas = params || query
console.log(fileIds);
dispatch(means.folderFileList({ fileId: JSON.stringify(fileIds), ...datas })).then((res => { dispatch(means.folderFileList({ fileId: JSON.stringify(fileIds), ...datas })).then((res => {
if (res.success) { if (res.success) {
setDataSource(res.payload.data?.rows || []) setDataSource(res.payload.data?.rows || [])
@ -165,7 +165,7 @@ const Rest = (props) => {
title: '文件名', title: '文件名',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
render: (text) => text?.length > 30 ? <div title={text}>{text.slice(0,30)}...</div> : text render: (text) => text?.length > 30 ? <div title={text}>{text.slice(0, 30)}...</div> : text
}, },
{ {
title: '文件大小', title: '文件大小',
@ -197,7 +197,7 @@ const Rest = (props) => {
下载 下载
</a></Button> </a></Button>
<Button theme='borderless' type='primary' style={{ marginRight: 8 }} onClick={() => { <Button theme='borderless' type='primary' style={{ marginRight: 8 }} onClick={() => {
preview(r.url)
}}> }}>
预览 预览
</Button> </Button>
@ -244,6 +244,18 @@ const Rest = (props) => {
}, },
]; ];
const preview = (url) => {
let link = encodeURI(`${qiniu}/${url}`)
if (url.indexOf("pdf") !== -1) {
window.open(link)
} else if (url.indexOf("png") !== -1 || url.indexOf("jpg") !== -1) {
setVideoModalV(true)
setvideoUrl(link)
} else {
window.open(`https://view.officeapps.live.com/op/view.aspx?src=${link}`)
}
}
return ( return (
// <div> // <div>
<div style={{ width: '100%', height: clientHeight - 72, display: 'flex', }}> <div style={{ width: '100%', height: clientHeight - 72, display: 'flex', }}>
@ -464,7 +476,27 @@ const Rest = (props) => {
</div> */} </div> */}
</div> </div>
</div> </div>
{
videoModalV ?
<Modal
visible={true}
destroyOnClose
closable={false}
onCancel={() => {
setVideoModalV(false)
setvideoUrl('')
}} width={400}
footer={null}>
<img src={videoUrl} style={{ width: 350 }} />
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<Button theme='solid' type='secondary' onClick={() => {
setVideoModalV(false)
setvideoUrl('')
}}>关闭</Button>
</div>
</Modal>
: ''
}
</div > </div >
// </div> // </div>
) )
@ -472,14 +504,14 @@ const Rest = (props) => {
function mapStateToProps (state) { function mapStateToProps (state) {
const { auth, global, members, webSocket } = state; const { auth, global, members, webSocket } = state;
return { return {
// loading: members.isRequesting, // loading: members.isRequesting,
user: auth.user, user: auth.user,
actions: global.actions, actions: global.actions,
overallProjectId: global.pepProjectId, overallProjectId: global.pepProjectId,
// socket: webSocket.socket // socket: webSocket.socket
clientHeight: global.clientHeight clientHeight: global.clientHeight,
qiniu: global.qiniu?.domain
}; };
} }

3
web/routes/attachment/index.js

@ -19,7 +19,7 @@ module.exports = {
entry: function (app, router, opts) { entry: function (app, router, opts) {
const getApiRoot = async function (ctx) { const getApiRoot = async function (ctx) {
const { apiUrl, iotVcmpWeb, pomsMonitor, dcWeb } = opts; const { apiUrl, iotVcmpWeb, pomsMonitor, dcWeb,qiniu } = opts;
ctx.status = 200; ctx.status = 200;
ctx.body = { ctx.body = {
@ -27,6 +27,7 @@ module.exports = {
iotVcmpWeb: iotVcmpWeb, iotVcmpWeb: iotVcmpWeb,
pomsMonitor: pomsMonitor, pomsMonitor: pomsMonitor,
dcWeb: dcWeb, dcWeb: dcWeb,
qiniu:qiniu
}; };
}; };

Loading…
Cancel
Save