@yorha2b-lab/autodev 2.1.6 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
1
2
|
import { initOSS } from '../utils/utils'
|
|
2
|
-
import { useState, useEffect } from 'react'
|
|
3
3
|
import { UploadOutlined } from '@ant-design/icons'
|
|
4
4
|
import { Button, Tree, Radio, Input, Upload, Select, Cascader, Checkbox, DatePicker, InputNumber, TreeSelect, AutoComplete } from 'antd'
|
|
5
5
|
|
|
6
|
-
const AliyunOSSUpload = ({
|
|
6
|
+
const AliyunOSSUpload = ({ value, onChange, ...restProps }) => {
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const { oss, url, path, options, ...originUploadProps } = restProps
|
|
9
|
+
|
|
10
|
+
const [OSSData, setOSSData] = useState(oss)
|
|
9
11
|
|
|
10
12
|
const init = async () => {
|
|
11
13
|
try {
|
|
12
|
-
const result = await initOSS()
|
|
14
|
+
const result = await initOSS(url, options)
|
|
13
15
|
setOSSData(result)
|
|
14
16
|
} catch (err) {
|
|
15
17
|
console.log(err)
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
init()
|
|
21
|
-
}, [])
|
|
22
|
-
|
|
23
21
|
const handleChange = ({ fileList }) => onChange?.([...fileList])
|
|
24
22
|
|
|
25
23
|
const onRemove = file => {
|
|
@@ -36,11 +34,8 @@ const AliyunOSSUpload = ({ path, style, value, disabled, onChange }) => {
|
|
|
36
34
|
})
|
|
37
35
|
|
|
38
36
|
const beforeUpload = async file => {
|
|
39
|
-
if (!OSSData) {
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
42
37
|
const expire = Number(OSSData.expire) * 1000
|
|
43
|
-
if (expire < Date.now()) {
|
|
38
|
+
if (expire < Date.now() || !OSSData) {
|
|
44
39
|
await init()
|
|
45
40
|
}
|
|
46
41
|
file.url = `${OSSData.dir ?? path}/${file.uid}_${file.name}`.replace(/\/\//g, '/')
|
|
@@ -55,10 +50,11 @@ const AliyunOSSUpload = ({ path, style, value, disabled, onChange }) => {
|
|
|
55
50
|
data: getExtraData,
|
|
56
51
|
action: OSSData?.host,
|
|
57
52
|
onChange: handleChange,
|
|
53
|
+
...originUploadProps
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
return (
|
|
61
|
-
<Upload {...uploadProps}
|
|
57
|
+
<Upload {...uploadProps}>
|
|
62
58
|
<Button icon={<UploadOutlined />}>选择文件</Button>
|
|
63
59
|
</Upload>
|
|
64
60
|
)
|
|
@@ -3,6 +3,16 @@ import { request } from './request'
|
|
|
3
3
|
|
|
4
4
|
//常用工具函数,使用前确保已安装对应模块
|
|
5
5
|
|
|
6
|
+
export const parseExcel = async file => {
|
|
7
|
+
/* const arrayBuffer = await file.arrayBuffer()
|
|
8
|
+
const XLSX = require('xlsx')
|
|
9
|
+
const workbook = XLSX.read(arrayBuffer, { type: 'array' })
|
|
10
|
+
const firstSheetName = workbook.SheetNames?.[0]
|
|
11
|
+
const worksheet = workbook.Sheets[firstSheetName]
|
|
12
|
+
const excelData = XLSX.utils.sheet_to_json(worksheet, { header: 1 })
|
|
13
|
+
return excelData.filter(item => item.length > 0) */
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
export const initOSS = async (url, options) => {
|
|
7
17
|
/* const OSS = require('ali-oss')
|
|
8
18
|
const crypto = require('crypto-js')
|
|
@@ -16,7 +26,7 @@ export const initOSS = async (url, options) => {
|
|
|
16
26
|
],
|
|
17
27
|
}))
|
|
18
28
|
const signature = crypto.enc.Base64.stringify(crypto.HmacSHA1(policy, accessKeySecret))
|
|
19
|
-
return { client, policy, signature, ...response?.data } */
|
|
29
|
+
return { client, policy, signature,host: `https://${bucket}.${endpoint.split('//')[1]}`, ...response?.data } */
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
export const formatQuery = (params, formItems) => {
|