diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 0c227c0..d030f48 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -33,11 +33,12 @@ "--godUrl https://restapi.amap.com/v3", "--godKey 21c2d970e1646bb9a795900dd00093ce", "--mqttVideoServer mqtt://10.8.30.71:30883", - "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", - "--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", - "--qnbkt dev-operational-service", + "--qnak 5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu", + "--qnsk w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5", + "--qnbkt anxinyun-test", + "--qndmn http://test.resources.anxinyun.cn", // "--qndmn http://resources.anxinyun.cn", - "--qndmn http://rhvqdivo5.hn-bkt.clouddn.com", + // "--qndmn http://rhvqdivo5.hn-bkt.clouddn.com", // click 开发 // "--clickHouseUrl http://10.8.30.71", // click 测试 diff --git a/api/app/lib/controllers/means/index.js b/api/app/lib/controllers/means/index.js index 11ca1e9..b01692e 100644 --- a/api/app/lib/controllers/means/index.js +++ b/api/app/lib/controllers/means/index.js @@ -154,6 +154,25 @@ async function delfolderFile (ctx, next) { } } } +async function upload (ctx, next) { + let fkey = null; + try { + const { files } = await parse(ctx.req); + const file = files[0]; + const fileInfo = await ctx.app.fs.attachment.upload(file); + fkey = fileInfo.key; + ctx.status = 200; + ctx.body = { uploaded: fkey }; + + } catch (err) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) + ctx.status = 400; + ctx.body = { + "message": '上传失败' + } + } +} + module.exports = { @@ -162,5 +181,6 @@ module.exports = { delFile, addFile, folderFileList, - delfolderFile + delfolderFile, + upload } \ No newline at end of file diff --git a/api/app/lib/routes/means/index.js b/api/app/lib/routes/means/index.js index f64de9f..bbff7a8 100644 --- a/api/app/lib/routes/means/index.js +++ b/api/app/lib/routes/means/index.js @@ -21,4 +21,7 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['DEL/file/:id'] = { content: '删除文件夹', visible: true }; router.del('/file/:id', means.delfolderFile); + + app.fs.api.logAttr['POSTattachments/:p'] = { content: '上传文件', visible: true }; + router.post('/attachments/:p', means.upload); }; \ No newline at end of file diff --git a/web/client/src/sections/means/containers/devOpsStandard.jsx b/web/client/src/sections/means/containers/devOpsStandard.jsx index 2fff1ee..8dc6966 100644 --- a/web/client/src/sections/means/containers/devOpsStandard.jsx +++ b/web/client/src/sections/means/containers/devOpsStandard.jsx @@ -10,7 +10,7 @@ import './style.less' const Rest = (props) => { - const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props + const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId, apiRoot } = props const { install, means } = actions const [pomsList, setPomsList] = useState([]); //项目 const [showPomsList, setShowPomsList] = useState([]); //项目 @@ -392,7 +392,7 @@ const Rest = (props) => {
文件*
{ setUploadData({}) }} onSuccess={(responseBody, file) => { - setUploadData({ name: file.name, size: file.size, @@ -559,7 +558,8 @@ function mapStateToProps (state) { overallProjectId: global.pepProjectId, // socket: webSocket.socket clientHeight: global.clientHeight, - qiniu: global.qiniu?.domain + qiniu: global.qiniu?.domain, + apiRoot: global.apiRoot }; } diff --git a/web/client/src/sections/means/containers/faultInformation.jsx b/web/client/src/sections/means/containers/faultInformation.jsx index 7ff3e08..be45dee 100644 --- a/web/client/src/sections/means/containers/faultInformation.jsx +++ b/web/client/src/sections/means/containers/faultInformation.jsx @@ -10,7 +10,7 @@ import './style.less' const Rest = (props) => { - const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props + const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId ,apiRoot} = props const { install, means } = actions const [pomsList, setPomsList] = useState([]); //项目 const [showPomsList, setShowPomsList] = useState([]); //项目 @@ -86,6 +86,7 @@ const Rest = (props) => { }, [fileId]) const fileList = (id) => { + dispatch(means.fileList({ projectId: id, type: 3 })).then((res => { if (res.success) { let data = res.payload.data @@ -391,7 +392,7 @@ const Rest = (props) => {
文件*
{ setUploadData({}) }} onSuccess={(responseBody, file) => { - setUploadData({ name: file.name, size: file.size, @@ -558,7 +558,8 @@ function mapStateToProps (state) { overallProjectId: global.pepProjectId, // socket: webSocket.socket clientHeight: global.clientHeight, - qiniu: global.qiniu?.domain + qiniu: global.qiniu?.domain, + apiRoot:global.apiRoot }; } diff --git a/web/client/src/sections/means/containers/projectMeans.jsx b/web/client/src/sections/means/containers/projectMeans.jsx index b1582fd..ee3e773 100644 --- a/web/client/src/sections/means/containers/projectMeans.jsx +++ b/web/client/src/sections/means/containers/projectMeans.jsx @@ -10,7 +10,7 @@ import './style.less' const Rest = (props) => { - const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props + const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId ,apiRoot} = props const { install, means } = actions const [pomsList, setPomsList] = useState([]); //项目 const [showPomsList, setShowPomsList] = useState([]); //项目 @@ -392,7 +392,7 @@ const Rest = (props) => {
文件*
{ setUploadData({}) }} onSuccess={(responseBody, file) => { - setUploadData({ name: file.name, size: file.size, @@ -559,7 +558,8 @@ function mapStateToProps (state) { overallProjectId: global.pepProjectId, // socket: webSocket.socket clientHeight: global.clientHeight, - qiniu: global.qiniu?.domain + qiniu: global.qiniu?.domain, + apiRoot:global.apiRoot }; } diff --git a/web/client/src/sections/means/containers/repairFQA.jsx b/web/client/src/sections/means/containers/repairFQA.jsx index 4172fee..b58816e 100644 --- a/web/client/src/sections/means/containers/repairFQA.jsx +++ b/web/client/src/sections/means/containers/repairFQA.jsx @@ -10,7 +10,7 @@ import './style.less' const Rest = (props) => { - const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId } = props + const { dispatch, actions, user, qiniu, loading, clientHeight, overallProjectId ,apiRoot} = props const { install, means } = actions const [pomsList, setPomsList] = useState([]); //项目 const [showPomsList, setShowPomsList] = useState([]); //项目 @@ -392,7 +392,7 @@ const Rest = (props) => {
文件*
{ setUploadData({}) }} onSuccess={(responseBody, file) => { - setUploadData({ name: file.name, size: file.size, @@ -559,7 +558,8 @@ function mapStateToProps (state) { overallProjectId: global.pepProjectId, // socket: webSocket.socket clientHeight: global.clientHeight, - qiniu: global.qiniu?.domain + qiniu: global.qiniu?.domain, + apiRoot:global.apiRoot }; } diff --git a/web/routes/attachment/index.js b/web/routes/attachment/index.js index 53eda71..1afd5f5 100644 --- a/web/routes/attachment/index.js +++ b/web/routes/attachment/index.js @@ -19,7 +19,7 @@ module.exports = { entry: function (app, router, opts) { const getApiRoot = async function (ctx) { - const { apiUrl, iotVcmpWeb, pomsMonitor, dcWeb,qiniu } = opts; + const { apiUrl, iotVcmpWeb, pomsMonitor, dcWeb, qiniu } = opts; ctx.status = 200; ctx.body = { @@ -27,7 +27,7 @@ module.exports = { iotVcmpWeb: iotVcmpWeb, pomsMonitor: pomsMonitor, dcWeb: dcWeb, - qiniu:qiniu + qiniu: qiniu }; }; @@ -53,32 +53,18 @@ module.exports = { let upload_ = async function (ctx, next) { let fkey = null; try { - // const { p } = ctx.params; - console.log(111,ctx); - const { files } = await parse(ctx.req); - // console.log(files); - const file = files[0]; - // const extname = path.extname(file.filename).toLowerCase(); - // if (!UploadPath[p]) { - // ctx.status = 400; - // ctx.body = JSON.stringify({ error: '附件存放的文件夹名称无效' }); - // return; - // } else if (UploadPath[p].indexOf(extname) < 0) { - // ctx.status = 400; - // ctx.body = JSON.stringify({ error: '文件格式无效' }); - // return; - // } else { - const fileInfo = await ctx.app.fs.attachment.upload(file); - fkey = fileInfo.key; - console.log(11,fileInfo); - ctx.body = { uploaded: fkey }; - // } + const { files } = await parse(ctx.req); + const file = files[0]; + const fileInfo = await ctx.app.fs.attachment.upload(file); + fkey = fileInfo.key; + ctx.body = { uploaded: fkey }; + } catch (err) { - ctx.status = 500; - ctx.fs.logger.error(err); - ctx.body = { err: 'upload error.' }; + ctx.status = 500; + ctx.fs.logger.error(err); + ctx.body = { err: 'upload error.' }; } - } + } router.use(download); router.get('/api/root', getApiRoot);