From e9342e7796004e4babdf0b085a5ccae791d4a3ae Mon Sep 17 00:00:00 2001 From: wenlele Date: Fri, 16 Sep 2022 10:35:15 +0800 Subject: [PATCH] qiniu --- .../problem/components/inspection.jsx | 34 +++++++++++++++++++ .../problem/components/statistics.jsx | 33 ++++++++++-------- .../sections/problem/containers/dataAlarm.jsx | 7 ++-- web/config.js | 20 ++++++++++- web/middlewares/attachment.js | 23 +++++++++++++ web/package.json | 3 +- web/routes/attachment/index.js | 20 +++++++++++ 7 files changed, 122 insertions(+), 18 deletions(-) create mode 100644 web/client/src/sections/problem/components/inspection.jsx create mode 100644 web/middlewares/attachment.js diff --git a/web/client/src/sections/problem/components/inspection.jsx b/web/client/src/sections/problem/components/inspection.jsx new file mode 100644 index 0000000..e7ef8c9 --- /dev/null +++ b/web/client/src/sections/problem/components/inspection.jsx @@ -0,0 +1,34 @@ + +import React, { useState, useEffect, useRef } from "react"; +import { connect } from "react-redux"; +import { DatePicker } from "@douyinfe/semi-ui"; + +const Inspection = ({ dispatch, actions, route }) => { + + console.log(route); + return ( + +
+
+
数据异常统计
+
开发中,敬请期待!
+
+ + + + +
+ ) +} + + +function mapStateToProps (state) { + const { auth, global, members } = state; + return { + // user: auth.user, + // actions: global.actions, + // global: global, + // members: members.data, + }; +} +export default connect(mapStateToProps)(Inspection); diff --git a/web/client/src/sections/problem/components/statistics.jsx b/web/client/src/sections/problem/components/statistics.jsx index 2136fa2..6a92d05 100644 --- a/web/client/src/sections/problem/components/statistics.jsx +++ b/web/client/src/sections/problem/components/statistics.jsx @@ -1,15 +1,18 @@ import React, { useState, useEffect, useRef } from "react"; import { connect } from "react-redux"; import { DatePicker } from "@douyinfe/semi-ui"; +import Inspection from "./inspection"; -const Statistics = ({ dispatch, actions, close, modalName, visible, appData }) => { - +const Statistics = ({ dispatch, actions, route }) => { + console.log(route); return ( -
-
-
数据异常统计
- {/* {route == 'useAbnormal' ? + : +
+
+
数据异常统计
+ {/* */} -
开发中,敬请期待!
-
- {/*
*/} - {/*
暂未开放敬请期待
+
开发中,敬请期待!
+
+ {/*
*/} + {/*
暂未开放敬请期待
暂未开放敬请期待
暂未开放敬请期待
暂未开放敬请期待
*/} - {/*
*/} + {/*
*/} - {/*
+ {/*
暂未开放 敬请期待
*/} - + + +
+ } -
) } diff --git a/web/client/src/sections/problem/containers/dataAlarm.jsx b/web/client/src/sections/problem/containers/dataAlarm.jsx index 0bce254..399063b 100644 --- a/web/client/src/sections/problem/containers/dataAlarm.jsx +++ b/web/client/src/sections/problem/containers/dataAlarm.jsx @@ -256,12 +256,15 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket }) => { } } return ( -
+
{/* 滞留提醒 */}
{abnormalLenght > 0 ?
当前滞留5个工单即将超时,请尽快处理!
: ""}
- + { + ctx.fs = ctx.fs || {}; + ctx.fs.attachment = attachment; + await next(); + }; + } +}; diff --git a/web/package.json b/web/package.json index 27b3bc2..1ed7077 100644 --- a/web/package.json +++ b/web/package.json @@ -60,6 +60,7 @@ "copy-to-clipboard": "^3.3.1", "cross-env": "^7.0.3", "ezuikit-js": "^0.6.1", + "fs-attachment": "^1.0.0", "fs-web-server-scaffold": "^1.0.6", "koa-better-http-proxy": "^0.2.5", "koa-proxy": "^1.0.0-alpha.3", @@ -79,4 +80,4 @@ "webpack-dev-server": "^3.11.2", "webpack-hot-middleware": "^2.25.0" } -} \ No newline at end of file +} diff --git a/web/routes/attachment/index.js b/web/routes/attachment/index.js index 7f4a78b..6c02488 100644 --- a/web/routes/attachment/index.js +++ b/web/routes/attachment/index.js @@ -29,6 +29,26 @@ module.exports = { }; }; + let download = async function (ctx, next) { + const { fetchUrl } = opts.qiniu; + if (ctx.path && ctx.path.includes(fetchUrl)) { + try { + const { filename } = ctx.request.query; + const fkey = decodeURI(ctx.path.slice(fetchUrl.length + 1)).replace(/\.json$/, '.js'); + const publicDownloadUrl = await app.fs.attachment.download(fkey); + ctx.status = 200; + if (filename) ctx.attachment(filename); + ctx.body = request.get(publicDownloadUrl); + } catch (err) { + ctx.fs.logger.error(err); + ctx.status = 404; + ctx.body = { error: 'file not found.' } + } + } else { + await next(); + } + } + let upload = async function (ctx, next) { try { const { files } = await parse(ctx.req);