Browse Source

oss上传

master
nili 8 months ago
parent
commit
09363483a0
  1. 1
      .eslintignore
  2. 1
      dist/134.6fc81d91.async.js
  3. 1
      dist/134.957d5baa.async.js
  4. 3
      dist/169.57647c7d.async.js
  5. 3
      dist/169.c5babfbf.async.js
  6. 30
      dist/235.f7c67994.async.js
  7. 90
      dist/247.3fe8fb10.async.js
  8. 108
      dist/258.d191bbdb.async.js
  9. 233
      dist/269.4542f5a4.async.js
  10. 164
      dist/270.f1c2a3da.async.js
  11. 13
      dist/287.93586c34.async.js
  12. 13
      dist/287.b21721be.async.js
  13. 153
      dist/335.e3ecf74a.async.js
  14. 10
      dist/393.2a09f5b6.async.js
  15. 10
      dist/393.b64a7324.async.js
  16. 1
      dist/397.0ef2ea1f.async.js
  17. 1
      dist/397.fb5f72c1.async.js
  18. 83
      dist/51.d90b1fa5.async.js
  19. 83
      dist/51.e174e29e.async.js
  20. 246
      dist/531.47eea593.async.js
  21. 8
      dist/559.016bfdbb.async.js
  22. 8
      dist/559.683b9a7b.async.js
  23. 96
      dist/601.e46b1579.async.js
  24. 42
      dist/63.d3cf24e7.async.js
  25. 27
      dist/635.09454aea.async.js
  26. 27
      dist/635.84db70b9.async.js
  27. 40
      dist/676.a53a9987.async.js
  28. 30
      dist/706.1c4598f2.async.js
  29. 1
      dist/905.6e225d1b.async.js
  30. 1
      dist/905.745134cb.async.js
  31. 58
      dist/930.05171fe3.async.js
  32. 59
      dist/930.42e2019f.async.js
  33. 13
      dist/index.html
  34. 1
      dist/p__AdminManagement.4ce10001.async.js
  35. 1
      dist/p__AdminManagement.a0dd8c31.async.js
  36. 2
      dist/p__AdvRecordList.4131e6d9.async.js
  37. 1
      dist/p__AppManagement.032a6188.async.js
  38. 1
      dist/p__AppManagement.7cb3b3e5.async.js
  39. 2
      dist/p__DeviceOwnerApp.0a01face.async.js
  40. 1
      dist/p__SuperAdmin.d2274a04.async.js
  41. 1
      dist/p__SuperAdmin.ffff8e8d.async.js
  42. 1
      dist/p__User__Login__index.9d3ab92e.async.js
  43. 1
      dist/p__User__Login__index.da479be3.async.js
  44. 433
      dist/umi.04a1e043.js
  45. 426
      dist/umi.18c8c913.js
  46. 9
      package.json
  47. 4
      src/components/HeaderDropdown/index.tsx
  48. 5
      src/components/RightContent/AvatarDropdown.tsx
  49. 1
      src/components/RightContent/index.tsx
  50. 8
      src/pages/DeviceOwnerApp.tsx
  51. 124
      src/pages/OSSUpload.tsx
  52. 12
      src/pages/SuperAdmin.tsx
  53. 8
      src/services/matrix/admin.ts
  54. 2
      src/services/matrix/index.ts
  55. 45
      src/services/matrix/registerController.ts
  56. 44
      src/services/matrix/typings.d.ts
  57. 21
      src/utils/encryptUtil.ts

1
.eslintignore

@ -3,6 +3,7 @@
/config /config
.history .history
public public
src
dist dist
.umi .umi
mock mock

1
dist/134.6fc81d91.async.js

File diff suppressed because one or more lines are too long

1
dist/134.957d5baa.async.js

File diff suppressed because one or more lines are too long

3
dist/169.57647c7d.async.js

File diff suppressed because one or more lines are too long

3
dist/169.c5babfbf.async.js

File diff suppressed because one or more lines are too long

30
dist/235.f7c67994.async.js

File diff suppressed because one or more lines are too long

90
dist/247.3fe8fb10.async.js

File diff suppressed because one or more lines are too long

108
dist/258.d191bbdb.async.js

File diff suppressed because one or more lines are too long

233
dist/269.4542f5a4.async.js

File diff suppressed because one or more lines are too long

164
dist/270.f1c2a3da.async.js

File diff suppressed because one or more lines are too long

13
dist/287.93586c34.async.js

File diff suppressed because one or more lines are too long

13
dist/287.b21721be.async.js

File diff suppressed because one or more lines are too long

153
dist/335.e3ecf74a.async.js

File diff suppressed because one or more lines are too long

10
dist/393.2a09f5b6.async.js

File diff suppressed because one or more lines are too long

10
dist/393.b64a7324.async.js

File diff suppressed because one or more lines are too long

1
dist/397.0ef2ea1f.async.js

File diff suppressed because one or more lines are too long

1
dist/397.fb5f72c1.async.js

File diff suppressed because one or more lines are too long

83
dist/51.d90b1fa5.async.js

File diff suppressed because one or more lines are too long

83
dist/51.e174e29e.async.js

File diff suppressed because one or more lines are too long

246
dist/531.47eea593.async.js

File diff suppressed because one or more lines are too long

8
dist/559.016bfdbb.async.js

File diff suppressed because one or more lines are too long

8
dist/559.683b9a7b.async.js

File diff suppressed because one or more lines are too long

96
dist/601.e46b1579.async.js

File diff suppressed because one or more lines are too long

42
dist/63.d3cf24e7.async.js

File diff suppressed because one or more lines are too long

27
dist/635.09454aea.async.js

File diff suppressed because one or more lines are too long

27
dist/635.84db70b9.async.js

File diff suppressed because one or more lines are too long

40
dist/676.a53a9987.async.js

File diff suppressed because one or more lines are too long

30
dist/706.1c4598f2.async.js

File diff suppressed because one or more lines are too long

1
dist/905.6e225d1b.async.js

File diff suppressed because one or more lines are too long

1
dist/905.745134cb.async.js

File diff suppressed because one or more lines are too long

58
dist/930.05171fe3.async.js

File diff suppressed because one or more lines are too long

59
dist/930.42e2019f.async.js

File diff suppressed because one or more lines are too long

13
dist/index.html

@ -1,13 +1,16 @@
<!DOCTYPE html><html><head> <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Ant Design Pro</title> <title>Ant Design Pro</title>
<link rel="stylesheet" href="/umi.1ca9308c.css"> <link rel="stylesheet" href="/umi.1ca9308c.css">
<script async="" src="/scripts/loading.js"></script> <script async src="/scripts/loading.js"></script>
<script>!function(){"use strict";var t="/".replace(/([^/])$/,"$1/"),e=location.pathname,n=e.startsWith(t)&&decodeURI("/".concat(e.slice(t.length)));if(n){var a=document,c=a.head,r=a.createElement.bind(a),i=function(t,e,n){var a,c=e.r[t]||(null===(a=Object.entries(e.r).find((function(e){var n=e[0];return new RegExp("^".concat(n.replace(/\/:[^/]+/g,"/[^/]+").replace("/*","/.+"),"$")).test(t)})))||void 0===a?void 0:a[1]);return null==c?void 0:c.map((function(t){var a=e.f[t][1],c=e.f[t][0];return{type:c.split(".").pop(),url:"".concat(n.publicPath).concat(c),attrs:[["data-".concat(e.b),"".concat(e.p,":").concat(a)]]}}))}(n,{"p":"ant-design-pro","b":"webpack","f":[["p__AppManagement.7cb3b3e5.async.js",39],["51.e174e29e.async.js",51],["63.d3cf24e7.async.js",63],["134.6fc81d91.async.js",134],["169.57647c7d.async.js",169],["p__Welcome.61596037.async.js",185],["235.f7c67994.async.js",235],["247.3fe8fb10.async.js",247],["258.d191bbdb.async.js",258],["287.b21721be.async.js",287],["t__plugin-layout__Layout.6cae69f5.chunk.css",301],["t__plugin-layout__Layout.afe80231.async.js",301],["335.e3ecf74a.async.js",335],["p__User__Login__index.9d3ab92e.async.js",366],["p__DeviceOwnerApp.0a01face.async.js",371],["390.41467286.async.js",390],["393.b64a7324.async.js",393],["397.fb5f72c1.async.js",397],["p__SuperAdmin.d2274a04.async.js",455],["531.47eea593.async.js",531],["p__Bind.b6ee068f.async.js",557],["559.016bfdbb.async.js",559],["p__404.0c100574.async.js",571],["635.84db70b9.async.js",635],["p__AdminManagement.a0dd8c31.async.js",816],["p__AdvRecordList.4131e6d9.async.js",857],["905.6e225d1b.async.js",905],["930.42e2019f.async.js",930]],"r":{"/*":[22,26],"/":[3,10,11,21,23,26],"/welcome":[3,4,5,16,21,27,10,11,23,26],"/super":[1,2,3,4,6,7,18,27,10,11,21,23,26],"/adminList":[1,4,6,9,24,3,10,11,21,23,26],"/bind":[3,4,16,17,20,21,27,10,11,23,26],"/appList":[0,1,2,3,4,6,9,12,17,19,26,27,10,11,21,23],"/advList/:code":[1,2,3,4,6,8,9,12,19,21,25,26,27,10,11,23],"/app/:code":[1,2,3,4,6,8,9,12,14,19,21,26,27,10,11,23],"/user/login":[2,3,4,6,9,13,19]}},{publicPath:"/"});null==i||i.forEach((function(t){var e,n=t.type,a=t.url;if("js"===n)(e=r("script")).src=a,e.async=!0;else{if("css"!==n)return;(e=r("link")).href=a,e.rel="preload",e.as="style"}t.attrs.forEach((function(t){e.setAttribute(t[0],t[1]||"")})),c.appendChild(e)}))}}();</script>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="/umi.04a1e043.js"></script> <script src="/umi.18c8c913.js"></script>
</body>
</body></html> </html>

1
dist/p__AdminManagement.4ce10001.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AdminManagement.a0dd8c31.async.js

File diff suppressed because one or more lines are too long

2
dist/p__AdvRecordList.2fce5070.async.js → dist/p__AdvRecordList.4131e6d9.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AppManagement.032a6188.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AppManagement.7cb3b3e5.async.js

File diff suppressed because one or more lines are too long

2
dist/p__DeviceOwnerApp.6709cb8d.async.js → dist/p__DeviceOwnerApp.0a01face.async.js

File diff suppressed because one or more lines are too long

1
dist/p__SuperAdmin.d2274a04.async.js

File diff suppressed because one or more lines are too long

1
dist/p__SuperAdmin.ffff8e8d.async.js

File diff suppressed because one or more lines are too long

1
dist/p__User__Login__index.9d3ab92e.async.js

File diff suppressed because one or more lines are too long

1
dist/p__User__Login__index.da479be3.async.js

File diff suppressed because one or more lines are too long

433
dist/umi.04a1e043.js

File diff suppressed because one or more lines are too long

426
dist/umi.18c8c913.js

File diff suppressed because one or more lines are too long

9
package.json

@ -4,7 +4,6 @@
"private": true, "private": true,
"description": "An out-of-box UI solution for enterprise applications", "description": "An out-of-box UI solution for enterprise applications",
"scripts": { "scripts": {
"openapi": "max openapi",
"analyze": "cross-env ANALYZE=1 max build", "analyze": "cross-env ANALYZE=1 max build",
"build": "max build", "build": "max build",
"deploy": "npm run build && npm run gh-pages", "deploy": "npm run build && npm run gh-pages",
@ -19,6 +18,7 @@
"lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src ", "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src ",
"lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
"lint:prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\" --end-of-line auto", "lint:prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\" --end-of-line auto",
"openapi": "max openapi",
"prepare": "husky install", "prepare": "husky install",
"prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"", "prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"",
"preview": "npm run build && max preview --port 8000", "preview": "npm run build && max preview --port 8000",
@ -50,6 +50,7 @@
"@ant-design/icons": "^4.8.1", "@ant-design/icons": "^4.8.1",
"@ant-design/pro-components": "^2.6.48", "@ant-design/pro-components": "^2.6.48",
"@umijs/route-utils": "^2.2.2", "@umijs/route-utils": "^2.2.2",
"ali-oss": "^6.20.0",
"antd": "^5.13.2", "antd": "^5.13.2",
"antd-style": "^3.6.1", "antd-style": "^3.6.1",
"classnames": "^2.5.1", "classnames": "^2.5.1",
@ -61,11 +62,13 @@
"rc-util": "^5.38.1", "rc-util": "^5.38.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-helmet-async": "^1.3.0" "react-helmet-async": "^1.3.0",
"spark-md5": "^3.0.2"
}, },
"devDependencies": { "devDependencies": {
"@ant-design/pro-cli": "^3.3.0", "@ant-design/pro-cli": "^3.3.0",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@types/ali-oss": "^6.16.11",
"@types/classnames": "^2.3.1", "@types/classnames": "^2.3.1",
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/history": "^4.7.11", "@types/history": "^4.7.11",
@ -74,7 +77,7 @@
"@types/react": "^18.2.48", "@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18", "@types/react-dom": "^18.2.18",
"@types/react-helmet": "^6.1.11", "@types/react-helmet": "^6.1.11",
"@umijs/fabric": "^2.14.1", "@types/spark-md5": "^3.0.4", "@umijs/fabric": "^2.14.1",
"@umijs/lint": "^4.1.1", "@umijs/lint": "^4.1.1",
"@umijs/max": "^4.1.1", "@umijs/max": "^4.1.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",

4
src/components/HeaderDropdown/index.tsx

@ -1,8 +1,8 @@
import { Dropdown } from 'antd'; import { Dropdown } from 'antd';
import type { DropDownProps } from 'antd/es/dropdown';
import React from 'react';
import { createStyles } from 'antd-style'; import { createStyles } from 'antd-style';
import type { DropDownProps } from 'antd/es/dropdown';
import classNames from 'classnames'; import classNames from 'classnames';
import React from 'react';
const useStyles = createStyles(({ token }) => { const useStyles = createStyles(({ token }) => {
return { return {

5
src/components/RightContent/AvatarDropdown.tsx

@ -1,14 +1,14 @@
import { outLogin } from '@/services/ant-design-pro/api';
import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons'; import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
import { history, useModel } from '@umijs/max'; import { history, useModel } from '@umijs/max';
import { Spin } from 'antd'; import { Spin } from 'antd';
import { createStyles } from 'antd-style'; import { createStyles } from 'antd-style';
import { stringify } from 'querystring'; import { stringify } from 'querystring';
import type { MenuInfo } from 'rc-menu/lib/interface';
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { flushSync } from 'react-dom'; import { flushSync } from 'react-dom';
import HeaderDropdown from '../HeaderDropdown'; import HeaderDropdown from '../HeaderDropdown';
import type { MenuInfo } from 'rc-menu/lib/interface';
export type GlobalHeaderRightProps = { export type GlobalHeaderRightProps = {
menu?: boolean; menu?: boolean;
children?: React.ReactNode; children?: React.ReactNode;
@ -43,7 +43,6 @@ export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu, childre
* 退 url * 退 url
*/ */
const loginOut = async () => { const loginOut = async () => {
const { search, pathname } = window.location; const { search, pathname } = window.location;
const urlParams = new URL(window.location.href).searchParams; const urlParams = new URL(window.location.href).searchParams;
/** 此方法会跳转到 redirect 参数所在的位置 */ /** 此方法会跳转到 redirect 参数所在的位置 */

1
src/components/RightContent/index.tsx

@ -1,6 +1,5 @@
import { QuestionCircleOutlined } from '@ant-design/icons'; import { QuestionCircleOutlined } from '@ant-design/icons';
import { SelectLang as UmiSelectLang } from '@umijs/max'; import { SelectLang as UmiSelectLang } from '@umijs/max';
import React from 'react';
export type SiderTheme = 'light' | 'dark'; export type SiderTheme = 'light' | 'dark';

8
src/pages/DeviceOwnerApp.tsx

@ -17,7 +17,13 @@ import { useParams } from 'react-router-dom';
import { advList } from '../services/matrix/admin'; import { advList } from '../services/matrix/admin';
// import { RequestOptionsType, ProFieldRequestData } from "@ant-design/pro-utils"; // import { RequestOptionsType, ProFieldRequestData } from "@ant-design/pro-utils";
import { deviceList, incomeDaily1, incomeOverview1, offline, online } from '@/services/matrix/device'; import {
deviceList,
incomeDaily1,
incomeOverview1,
offline,
online,
} from '@/services/matrix/device';
import { Column } from '@ant-design/charts'; import { Column } from '@ant-design/charts';
import type { ActionType } from '@ant-design/pro-components'; import type { ActionType } from '@ant-design/pro-components';
import moment from 'moment'; import moment from 'moment';

124
src/pages/OSSUpload.tsx

@ -0,0 +1,124 @@
import { toMD5 } from '@/utils/encryptUtil';
import OSS from 'ali-oss';
import { message, Upload, UploadFile, UploadProps } from 'antd';
import React, { useEffect, useState } from 'react';
import { getSts } from '../services/matrix/admin';
interface OSSUploadProps {
onUploadSuccess?: (fileUrl: string) => void;
onUploadError?: (error: any) => void;
}
const OSSUpload: React.FC<OSSUploadProps> = ({ onUploadSuccess, onUploadError }) => {
const [uploading, setUploading] = useState(false);
const [fileList, setFileList] = useState<UploadFile[]>([]);
const [ossClient, setOssClient] = useState<OSS | null>(null);
const { Dragger } = Upload;
useEffect(() => {
async function initOssClient() {
try {
const stsResponse = await getSts(); // 假设你有一个 getSTS 函数可以获取 STS 凭证
if (
!stsResponse.data ||
!stsResponse.data.accessKeySecret ||
!stsResponse.data.accessKeyId
) {
message.error('初始化失败,请稍后再试');
return;
}
const client = new OSS({
region: 'oss-cn-beijing',
accessKeyId: stsResponse.data.accessKeyId,
accessKeySecret: stsResponse.data.accessKeySecret,
stsToken: stsResponse.data.securityToken,
bucket: stsResponse.data.bucket,
});
setOssClient(client);
} catch (error) {
message.error('初始化 OSS 客户端失败');
if (onUploadError) {
onUploadError(error);
}
}
}
initOssClient();
}, [onUploadError]);
const onRemove = (file: UploadFile) => {
const files = (fileList || []).filter((v) => v.url !== file.url);
setFileList(files);
};
const handleUpload: UploadProps['customRequest'] = async (options) => {
const { file } = options;
if (file instanceof File) {
setUploading(true);
try {
const md5 = await toMD5(file);
const fileName = `matrix/${md5}.${file.name.split('.').pop()}`;
await ossClient?.put(fileName, file, {
headers: {
'Content-Type': file.type,
},
});
const fileUrl = `https://apks.bzgames.cn/${fileName}`;
if (onUploadSuccess) {
onUploadSuccess(fileUrl);
}
setUploading(false);
// 将上传成功的文件信息添加到 fileList
setFileList((prevFileList) => [
...prevFileList,
{
uid: file.uid,
name: file.name + ':' + fileUrl,
status: 'done',
url: fileUrl,
},
]);
} catch (error) {
message.error('文件上传失败');
if (onUploadError) {
onUploadError(error);
}
setFileList((prevFileList) => [
...prevFileList,
{
uid: file.uid,
name: file.name,
status: 'error',
},
]);
} finally {
setUploading(false);
}
} else {
message.error('上传文件类型错误');
}
};
return (
<Dragger
fileList={fileList}
multiple
customRequest={handleUpload}
onRemove={onRemove}
disabled={uploading || !ossClient}
onPreview={async (file) => {
await navigator.clipboard.writeText(file.url || '');
message.success('链接复制成功 ' + file.url);
}}
>
<p className="ant-upload-drag-icon">
<i className="anticon anticon-inbox" />
</p>
<p className="ant-upload-text"></p>
<p className="ant-upload-hint">使 MD5 </p>
</Dragger>
);
};
export default OSSUpload;

12
src/pages/SuperAdmin.tsx

@ -25,6 +25,7 @@ import { ColumnsType } from 'antd/es/table';
import TabPane from 'antd/es/tabs/TabPane'; import TabPane from 'antd/es/tabs/TabPane';
import moment from 'moment'; import moment from 'moment';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import OSSUpload from './OSSUpload';
// import { RequestOptionsType, ProFieldRequestData } from "@ant-design/pro-utils"; // import { RequestOptionsType, ProFieldRequestData } from "@ant-design/pro-utils";
@ -316,7 +317,7 @@ const SuperAdmin: React.FC = () => {
<Form.List name="scheduleTime"> <Form.List name="scheduleTime">
{(fields, { add, remove }) => ( {(fields, { add, remove }) => (
<> <>
{fields.map(({ key, name, ...restField }) => ( {fields.map(({ key, name }) => (
<div key={key}> <div key={key}>
<Form.Item <Form.Item
name={[name, 'time']} name={[name, 'time']}
@ -325,11 +326,7 @@ const SuperAdmin: React.FC = () => {
> >
<DatePicker format="YYYY-MM-DD HH:mm" showTime={{ format: 'HH:mm' }} /> <DatePicker format="YYYY-MM-DD HH:mm" showTime={{ format: 'HH:mm' }} />
</Form.Item> </Form.Item>
<MinusCircleOutlined <MinusCircleOutlined onClick={() => remove(name)} />
onClick={() => remove(name)}
onPointerEnterCapture={undefined}
onPointerLeaveCapture={undefined}
/>
</div> </div>
))} ))}
<Form.Item> <Form.Item>
@ -344,6 +341,9 @@ const SuperAdmin: React.FC = () => {
</Modal> </Modal>
</div> </div>
</TabPane> </TabPane>
<TabPane tab="上传资源" key="3">
<OSSUpload />
</TabPane>
</Tabs> </Tabs>
</PageContainer> </PageContainer>
); );

8
src/services/matrix/admin.ts

@ -80,6 +80,14 @@ export async function deleteWhiteList(
}); });
} }
/** 此处后端没有提供注释 GET /api/admin/getSTS */
export async function getSts(options?: { [key: string]: any }) {
return request<API.RSTSInfo>('/api/admin/getSTS', {
method: 'GET',
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/grantApp */ /** 此处后端没有提供注释 POST /api/admin/grantApp */
export async function grantApp( export async function grantApp(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象) // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)

2
src/services/matrix/index.ts

@ -7,9 +7,11 @@ import * as appController from './appController';
import * as device from './device'; import * as device from './device';
import * as loginController from './loginController'; import * as loginController from './loginController';
import * as matrixController from './matrixController'; import * as matrixController from './matrixController';
import * as registerController from './registerController';
export default { export default {
matrixController, matrixController,
loginController, loginController,
registerController,
admin, admin,
device, device,
appController, appController,

45
src/services/matrix/registerController.ts

@ -0,0 +1,45 @@
// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';
/** 此处后端没有提供注释 GET /api/citrus/register/getApp */
export async function getApp(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.getAppParams,
options?: { [key: string]: any },
) {
return request<API.RMatrixAppBo>('/api/citrus/register/getApp', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/citrus/register/sendCode */
export async function sendCode(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.sendCodeParams,
options?: { [key: string]: any },
) {
return request<API.RVoid>('/api/citrus/register/sendCode', {
method: 'POST',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/citrus/register/submitRegister */
export async function submitRegister(body: API.RegisterBo, options?: { [key: string]: any }) {
return request<API.RVoid>('/api/citrus/register/submitRegister', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}

44
src/services/matrix/typings.d.ts

@ -78,6 +78,10 @@ declare namespace API {
appId?: string; appId?: string;
}; };
type getAppParams = {
inviteCode: string;
};
type grantAppParams = { type grantAppParams = {
appIds: string; appIds: string;
adminId: number; adminId: number;
@ -207,6 +211,13 @@ declare namespace API {
secret?: string; secret?: string;
}; };
type MatrixAppBo = {
name?: string;
code?: string;
img?: string;
url?: string;
};
type MatrixMockSchedule = { type MatrixMockSchedule = {
id?: number; id?: number;
appId?: number; appId?: number;
@ -278,6 +289,13 @@ declare namespace API {
data?: CurrentUser; data?: CurrentUser;
}; };
type RegisterBo = {
mobile?: string;
code?: string;
pwd?: string;
inviteCode?: string;
};
type RInviteInfo = { type RInviteInfo = {
code?: number; code?: number;
message?: string; message?: string;
@ -338,6 +356,12 @@ declare namespace API {
data?: MatrixAdmin; data?: MatrixAdmin;
}; };
type RMatrixAppBo = {
code?: number;
message?: string;
data?: MatrixAppBo;
};
type ROverviewBo = { type ROverviewBo = {
code?: number; code?: number;
message?: string; message?: string;
@ -362,12 +386,32 @@ declare namespace API {
data?: string; data?: string;
}; };
type RSTSInfo = {
code?: number;
message?: string;
data?: STSInfo;
};
type RVoid = { type RVoid = {
code?: number; code?: number;
message?: string; message?: string;
data?: Record<string, any>; data?: Record<string, any>;
}; };
type sendCodeParams = {
mobile: string;
};
type STSInfo = {
securityToken?: string;
expiration?: string;
accessKeySecret?: string;
accessKeyId?: string;
stsRole?: string;
bucket?: string;
endpoint?: string;
};
type updateScoreParams = { type updateScoreParams = {
score: number; score: number;
}; };

21
src/utils/encryptUtil.ts

@ -0,0 +1,21 @@
import SparkMD5 from 'spark-md5';
async function toMD5(file: File): Promise<string> {
return new Promise((resolve, reject) => {
const spark = new SparkMD5.ArrayBuffer();
const fileReader = new FileReader();
fileReader.onload = (e) => {
spark.append(e.target?.result as ArrayBuffer);
resolve(spark.end());
};
fileReader.onerror = (err) => {
reject(err);
};
fileReader.readAsArrayBuffer(file);
});
}
export { toMD5 };
Loading…
Cancel
Save