Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
glsx-common
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6574ea23
authored
Oct 03, 2021
by
limin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增 防抖节流方法 http默认post
1 parent
80bb979a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
3 deletions
dist/glsx-common.js
package.json
src/http.js
src/util.js
dist/glsx-common.js
View file @
6574ea2
This diff is collapsed.
Click to expand it.
package.json
View file @
6574ea2
{
"name"
:
"glsx-common"
,
"version"
:
"1.3.
7
"
,
"version"
:
"1.3.
8
"
,
"description"
:
"glsx common"
,
"main"
:
"./dist/glsx-common.js"
,
"private"
:
false
,
...
...
src/http.js
View file @
6574ea2
...
...
@@ -9,7 +9,8 @@ import axios from 'axios'
import
qs
from
'qs'
function
Http
(
options
=
{})
{
this
.
service
=
axios
.
create
({
withCredentials
:
true
withCredentials
:
true
,
method
:
'POST'
})
const
{
response
=
{},
...
...
src/util.js
View file @
6574ea2
...
...
@@ -150,6 +150,40 @@ export const Util = {
return
!
obj
||
JSON
.
stringify
(
obj
)
==
'{}'
},
debounce
:
function
(
fn
,
timer
)
{
var
t
=
null
return
function
()
{
if
(
t
)
{
clearTimeout
(
t
)
}
if
(
t
==
null
)
{
fn
.
apply
(
this
,
arguments
)
}
t
=
setTimeout
(()
=>
{
t
=
null
},
timer
)
}
},
throttle
:
function
(
fn
,
delay
)
{
var
t
=
null
var
begin
=
0
return
function
()
{
var
cur
=
new
Date
().
getTime
()
if
(
t
)
{
clearTimeout
(
t
)
}
if
(
cur
-
begin
>
delay
)
{
fn
.
apply
(
this
,
arguments
)
begin
=
cur
}
else
{
t
=
setTimeout
(()
=>
{
fn
.
apply
(
this
,
arguments
)
},
delay
)
}
}
},
// 创建签名
createSign
:
function
(
params
,
secret
,
noSignAttr
=
[],
way
=
'sha1'
)
{
delete
params
.
sign
...
...
@@ -158,7 +192,7 @@ export const Util = {
const
objQs
=
strQs
.
split
(
'&'
)
const
collect
=
objQs
.
reduce
((
collect
,
item
)
=>
{
const
[
key
,
value
]
=
item
.
split
(
'='
)
if
(
!
value
===
null
)
{
if
(
value
===
null
)
{
value
=
''
}
else
if
(
typeof
obj
===
'object'
)
{
value
=
JSON
.
stringify
(
value
)
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment