Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bkunyun
Commits
d0a1655b
Commit
d0a1655b
authored
Jun 14, 2022
by
吴永生#A02208
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 文件传输开发
parent
644ad72e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
0 deletions
+132
-0
useGlobalStore.ts
src/hooks/useGlobalStore.ts
+18
-0
fileList.ts
src/store/modules/fileList.ts
+72
-0
tusUpload.js
src/utils/Upload/tusUpload.js
+0
-0
helper.ts
src/utils/helper.ts
+42
-0
No files found.
src/hooks/useGlobalStore.ts
0 → 100644
View file @
d0a1655b
/*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-13 16:50:40
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-13 21:09:24
* @FilePath: /bkunyun/src/hooks/useGlobalStore.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import
{
useContext
}
from
'react'
;
import
{
MobXProviderContext
}
from
'mobx-react'
;
import
{
Stores
}
from
'@/store'
;
export
default
function
useGlobalStore
<
T
extends
keyof
Stores
>
(
storeName
:
T
)
{
const
context
=
useContext
(
MobXProviderContext
)
as
Stores
;
return
context
[
storeName
];
}
\ No newline at end of file
src/store/modules/fileList.ts
0 → 100644
View file @
d0a1655b
/*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-13 17:00:19
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-14 11:06:13
* @FilePath: /bkunyun/src/store/modules/upload.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import
{
makeAutoObservable
}
from
"mobx"
;
interface
IUploadInfo
{
id
:
string
,
open
:
boolean
,
list
:
any
,
isPermanence
:
boolean
,
}
/** 存储地图派单websocket推送数据状态的store */
class
FileList
{
constructor
()
{
makeAutoObservable
(
this
);
}
/** 文件上传列表 */
fileList
:
IUploadInfo
[]
=
[];
setFileList
(
val
:
IUploadInfo
[])
{
this
.
fileList
=
val
}
/** 设置文件上传信息 */
setUploadInfo
(
id
:
string
,
val
:
IUploadInfo
)
{
const
newFileList
=
this
.
fileList
?.
map
((
item
)
=>
{
if
(
item
.
id
===
id
){
return
val
}
return
item
})
this
.
fileList
=
newFileList
}
setUploadInfoOpen
(
id
:
string
,
val
:
boolean
)
{
const
newFileList
=
this
.
fileList
?.
map
((
item
)
=>
{
if
(
item
.
id
===
id
){
return
{...
item
,
open
:
val
};
}
return
item
;
})
this
.
fileList
=
newFileList
}
setUploadInfoList
(
id
:
string
,
val
:
any
)
{
const
newFileList
=
this
.
fileList
?.
map
((
item
)
=>
{
if
(
item
.
id
===
id
){
return
{...
item
,
list
:
val
}
}
return
item
})
this
.
fileList
=
newFileList
}
setUploadInfoIsPermanence
(
id
:
string
,
val
:
boolean
)
{
const
newFileList
=
this
.
fileList
?.
map
((
item
)
=>
{
if
(
item
.
id
===
id
){
return
{...
item
,
isPermanence
:
val
}
}
return
item
})
this
.
fileList
=
newFileList
}
}
export
default
new
FileList
();
src/utils/Upload/tusUpload.js
0 → 100644
View file @
d0a1655b
This diff is collapsed.
Click to expand it.
src/utils/helper.ts
0 → 100644
View file @
d0a1655b
/*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-13 17:23:49
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-13 17:28:59
* @FilePath: /bkunyun/src/utils/helper.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const
getTrueLength
=
(
str
:
string
)
=>
{
//获取字符串的真实长度(字节长度)
let
len
=
str
.
length
,
truelen
=
0
;
for
(
let
x
=
0
;
x
<
len
;
x
++
)
{
if
(
str
.
charCodeAt
(
x
)
>
128
)
{
truelen
+=
2
;
}
else
{
truelen
+=
1
;
}
}
return
truelen
;
}
export
const
verifyLettersNumbersCertainChars4
=
(
str
:
string
)
=>
{
if
(
str
.
slice
(
0
,
1
)
===
"."
)
{
return
false
;
}
if
(
getTrueLength
(
str
)
>
127
)
{
return
false
;
}
let
validString
=
/^
[\u
4e00-
\u
9fa5_0-9a-zA-Z-_.
]
+$/
;
return
validString
.
test
(
str
);
};
export
const
verifyLettersNumbersCertainChars5
=
(
str
:
string
)
=>
{
if
(
str
.
slice
(
0
,
1
)
===
"."
)
{
return
false
;
}
if
(
getTrueLength
(
str
)
>
127
)
{
return
false
;
}
let
validString
=
/^
[\u
4e00-
\u
9fa5_0-9a-zA-Z
\/
-_.
]
+$/
;
return
validString
.
test
(
str
);
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment