Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wfs_export
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yexing
wfs_export
Commits
e04e6148
Commit
e04e6148
authored
Jan 05, 2026
by
yexing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
107a897b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
34 deletions
+30
-34
plugin/.version
+2
-2
plugin/dist.crx
+0
-0
plugin/dist/js/main.js
+13
-15
plugin/dist/manifest.json
+2
-2
plugin/src/base.js
+6
-6
plugin/src/main.js
+1
-1
plugin/src/task.js
+6
-8
No files found.
plugin/.version
View file @
e04e6148
3.5.0
3.5.3
\ No newline at end of file
\ No newline at end of file
plugin/dist.crx
View file @
e04e6148
No preview for this file type
plugin/dist/js/main.js
View file @
e04e6148
...
@@ -383,15 +383,15 @@ var G = (function (exports) {
...
@@ -383,15 +383,15 @@ var G = (function (exports) {
if
(
!
(
this
.
uri
&&
this
.
partnerId
))
{
if
(
!
(
this
.
uri
&&
this
.
partnerId
))
{
throw
new
Error
(
`uri:
${
this
.
uri
}
, partnerId:
${
this
.
partnerId
}
`
);
throw
new
Error
(
`uri:
${
this
.
uri
}
, partnerId:
${
this
.
partnerId
}
`
);
}
}
this
.
_ext
=
this
.
options
.
ext
||
"csv"
;
// 扩展名
this
.
_retryLimit
=
6
;
this
.
_retryLimit
=
6
;
this
.
_retryCount
=
0
;
this
.
_retryCount
=
0
;
}
}
getFileName
(
sf
)
{
getFileName
(
sf
)
{
const
ext
=
this
.
options
.
ext
||
'csv'
;
let
name
=
this
.
names
.
showName
;
let
name
=
this
.
names
.
showName
;
name
=
this
.
options
.
noLowerCase
?
name
:
name
.
toLowerCase
();
name
=
this
.
options
.
noLowerCase
?
name
:
name
.
toLowerCase
();
sf
=
sf
===
undefined
||
sf
===
null
?
''
:
' '
+
sf
;
sf
=
sf
===
undefined
||
sf
===
null
?
''
:
' '
+
sf
;
return
`
${
this
.
partnerId
}
#
${
name
}
#
${
this
.
desc
}${
sf
}
.
${
ext
}
`
;
return
`
${
this
.
partnerId
}
#
${
name
}
#
${
this
.
desc
}${
sf
}
.
${
this
.
_
ext
}
`
;
}
}
async
_retry
(
args
)
{
async
_retry
(
args
)
{
if
(
++
this
.
_retryCount
<
this
.
_retryLimit
)
{
if
(
++
this
.
_retryCount
<
this
.
_retryLimit
)
{
...
@@ -409,7 +409,7 @@ var G = (function (exports) {
...
@@ -409,7 +409,7 @@ var G = (function (exports) {
const
url
=
new
URL
(
`
${
this
.
uri
}${
this
.
names
.
apiName
||
''
}
`
);
const
url
=
new
URL
(
`
${
this
.
uri
}${
this
.
names
.
apiName
||
''
}
`
);
const
method
=
this
.
options
.
method
||
'GET'
;
const
method
=
this
.
options
.
method
||
'GET'
;
const
callback
=
this
.
options
.
callback
;
const
callback
=
this
.
options
.
callback
;
const
ext
=
this
.
options
.
ext
||
'csv'
;
const
sign
=
this
.
options
.
sign
;
next
|=
this
.
options
.
next
;
next
|=
this
.
options
.
next
;
let
body
=
this
.
options
.
body
;
let
body
=
this
.
options
.
body
;
...
@@ -438,23 +438,21 @@ var G = (function (exports) {
...
@@ -438,23 +438,21 @@ var G = (function (exports) {
console
.
error
(
`重试回调,
${
e
.
message
}
`
);
console
.
error
(
`重试回调,
${
e
.
message
}
`
);
return
this
.
_retry
(
arguments
);
return
this
.
_retry
(
arguments
);
}
}
}
else
if
(
ext
==
'json'
)
{
}
else
if
(
sign
==
'json'
)
{
const
json
=
await
response
.
json
();
const
json
=
await
response
.
json
();
if
(
Object
.
keys
(
json
).
length
===
0
)
{
if
(
Object
.
keys
(
json
).
length
===
0
)
{
return
true
;
return
true
;
}
}
const
csv
=
JSON2CSV
(
json
);
const
csv
=
JSON2CSV
(
json
);
blob
=
new
Blob
([
csv
],
{
type
:
"text/csv"
});
blob
=
new
Blob
([
csv
],
{
type
:
"text/csv"
});
this
.
options
.
ext
=
"csv"
;
}
else
{
}
else
{
blob
=
await
response
.
blob
();
blob
=
await
response
.
blob
();
}
}
if
(
blob
===
undefined
||
blob
===
null
)
return
false
;
if
(
blob
===
undefined
||
blob
===
null
)
return
false
;
if
(
next
)
return
blob
;
if
(
next
)
return
blob
;
const
fn
=
this
.
getFileName
();
const
fn
=
this
.
getFileName
();
if
(
ext
===
'zip'
)
{
if
(
sign
===
'zip'
)
{
const
newFn
=
fn
.
replace
(
/
\.\w
+$/g
,
".csv"
);
return
renameZipFile
(
blob
,
fn
);
return
renameZipFile
(
blob
,
newFn
);
}
}
return
createZip
([
blob
],
[
fn
]);
return
createZip
([
blob
],
[
fn
]);
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -914,7 +912,7 @@ var G = (function (exports) {
...
@@ -914,7 +912,7 @@ var G = (function (exports) {
reportDate
,
reportDate
,
},
},
{
{
ext
:
"zip"
,
sign
:
"zip"
,
}
}
),
),
new
Task
(
new
Task
(
...
@@ -926,7 +924,7 @@ var G = (function (exports) {
...
@@ -926,7 +924,7 @@ var G = (function (exports) {
reportDate
,
reportDate
,
},
},
{
{
ext
:
"zip"
,
sign
:
"zip"
,
}
}
)
)
);
);
...
@@ -1122,7 +1120,7 @@ var G = (function (exports) {
...
@@ -1122,7 +1120,7 @@ var G = (function (exports) {
fromDate
,
fromDate
,
toDate
,
toDate
,
},
},
{
ext
:
"json"
,
isMmonthly
:
true
}
{
sign
:
"json"
,
isMmonthly
:
true
}
),
),
new
Task
(
new
Task
(
{
{
...
@@ -1134,7 +1132,7 @@ var G = (function (exports) {
...
@@ -1134,7 +1132,7 @@ var G = (function (exports) {
toDate
,
toDate
,
type
:
"MCS"
,
type
:
"MCS"
,
},
},
{
ext
:
"json"
,
isMmonthly
:
true
}
{
sign
:
"json"
,
isMmonthly
:
true
}
),
),
new
TaskGroup
(
new
TaskGroup
(
...
@@ -1148,7 +1146,7 @@ var G = (function (exports) {
...
@@ -1148,7 +1146,7 @@ var G = (function (exports) {
fromDate
,
fromDate
,
toDate
:
cut
?
cutOffDate
:
toDate
,
toDate
:
cut
?
cutOffDate
:
toDate
,
},
},
{
ext
:
"json"
}
{
sign
:
"json"
}
),
),
new
Task
(
new
Task
(
{
{
...
@@ -1159,7 +1157,7 @@ var G = (function (exports) {
...
@@ -1159,7 +1157,7 @@ var G = (function (exports) {
fromDate
:
cut
?
cutOffDate
:
fromDate
,
fromDate
:
cut
?
cutOffDate
:
fromDate
,
toDate
,
toDate
,
},
},
{
ext
:
"json"
}
{
sign
:
"json"
}
),
),
].
slice
(...
se
)
].
slice
(...
se
)
),
),
...
@@ -1322,7 +1320,7 @@ var G = (function (exports) {
...
@@ -1322,7 +1320,7 @@ var G = (function (exports) {
let
fn
=
task
.
getFileName
();
let
fn
=
task
.
getFileName
();
const
isJson
=
fn
.
endsWith
(
'.json'
);
const
isJson
=
fn
.
endsWith
(
'.json'
);
if
(
!
isJson
)
fn
=
fn
.
replace
(
/
\.\w
+$/g
,
".zip"
);
if
(
!
isJson
)
fn
=
fn
.
replace
(
/
\.\w
+$/g
,
".zip"
);
if
(
(
isSingle
||
isJson
)
&&
!
await
checkLog
(
fn
)
)
{
if
(
isSingle
||
isJson
?
!
await
checkLog
(
fn
):
false
)
{
console
.
log
(
`
${
pf
}
skip2`
);
console
.
log
(
`
${
pf
}
skip2`
);
continue
;
continue
;
}
}
...
...
plugin/dist/manifest.json
View file @
e04e6148
{
"name"
:
"WalmartExports"
,
"description"
:
"导出沃尔玛报表"
,
"version"
:
"3.5.0"
,
"manifest_version"
:
3
,
"background"
:{
"service_worker"
:
"./js/background.js"
},
"permissions"
:[
"tabs"
,
"activeTab"
,
"scripting"
,
"notifications"
,
"storage"
,
"alarms"
],
"action"
:{
"default_title"
:
"WalmartExports"
,
"default_popup"
:
"popup.html"
,
"default_icon"
:{
"16"
:
"icon.png"
,
"32"
:
"icon.png"
,
"48"
:
"icon.png"
,
"128"
:
"icon.png"
}},
"icons"
:{
"16"
:
"icon.png"
,
"32"
:
"icon.png"
,
"48"
:
"icon.png"
,
"128"
:
"icon.png"
},
"web_accessible_resources"
:[{
"resources"
:[
"src/main.js"
],
"matches"
:[
"<all_urls>"
]}],
"host_permissions"
:[
"https://seller.walmart.com/*"
,
"https://advertising.walmart.com/*"
,
"https://login.account.wal-mart.com/*"
,
"https://marketplace.walmartapis.com/*"
,
"https://walmart.meinuosha.com/*"
],
"content_scripts"
:[{
"matches"
:[
"https://seller.walmart.com/*"
,
"https://advertising.walmart.com/*"
,
"https://login.account.wal-mart.com/*"
,
"https://marketplace.walmartapis.com/*"
,
"https://walmart.meinuosha.com/*"
],
"js"
:[
"./js/main.js"
]}]}
{
"name"
:
"WalmartExports"
,
"description"
:
"导出沃尔玛报表"
,
"version"
:
"3.5.3"
,
"manifest_version"
:
3
,
"background"
:{
"service_worker"
:
"./js/background.js"
},
"permissions"
:[
"tabs"
,
"activeTab"
,
"scripting"
,
"notifications"
,
"storage"
,
"alarms"
],
"action"
:{
"default_title"
:
"WalmartExports"
,
"default_popup"
:
"popup.html"
,
"default_icon"
:{
"16"
:
"icon.png"
,
"32"
:
"icon.png"
,
"48"
:
"icon.png"
,
"128"
:
"icon.png"
}},
"icons"
:{
"16"
:
"icon.png"
,
"32"
:
"icon.png"
,
"48"
:
"icon.png"
,
"128"
:
"icon.png"
},
"web_accessible_resources"
:[{
"resources"
:[
"src/main.js"
],
"matches"
:[
"<all_urls>"
]}],
"host_permissions"
:[
"https://seller.walmart.com/*"
,
"https://advertising.walmart.com/*"
,
"https://login.account.wal-mart.com/*"
,
"https://marketplace.walmartapis.com/*"
,
"https://walmart.meinuosha.com/*"
],
"content_scripts"
:[{
"matches"
:[
"https://seller.walmart.com/*"
,
"https://advertising.walmart.com/*"
,
"https://login.account.wal-mart.com/*"
,
"https://marketplace.walmartapis.com/*"
,
"https://walmart.meinuosha.com/*"
],
"js"
:[
"./js/main.js"
]}]}
\ No newline at end of file
\ No newline at end of file
plugin/src/base.js
View file @
e04e6148
...
@@ -413,7 +413,7 @@ export async function createTasks(uri, fromDate, toDate) {
...
@@ -413,7 +413,7 @@ export async function createTasks(uri, fromDate, toDate) {
reportDate
,
reportDate
,
},
},
{
{
ext
:
"zip"
,
sign
:
"zip"
,
}
}
),
),
new
Task
(
new
Task
(
...
@@ -425,7 +425,7 @@ export async function createTasks(uri, fromDate, toDate) {
...
@@ -425,7 +425,7 @@ export async function createTasks(uri, fromDate, toDate) {
reportDate
,
reportDate
,
},
},
{
{
ext
:
"zip"
,
sign
:
"zip"
,
}
}
)
)
);
);
...
@@ -621,7 +621,7 @@ export async function createTasks(uri, fromDate, toDate) {
...
@@ -621,7 +621,7 @@ export async function createTasks(uri, fromDate, toDate) {
fromDate
,
fromDate
,
toDate
,
toDate
,
},
},
{
ext
:
"json"
,
isMmonthly
:
true
}
{
sign
:
"json"
,
isMmonthly
:
true
}
),
),
new
Task
(
new
Task
(
{
{
...
@@ -633,7 +633,7 @@ export async function createTasks(uri, fromDate, toDate) {
...
@@ -633,7 +633,7 @@ export async function createTasks(uri, fromDate, toDate) {
toDate
,
toDate
,
type
:
"MCS"
,
type
:
"MCS"
,
},
},
{
ext
:
"json"
,
isMmonthly
:
true
}
{
sign
:
"json"
,
isMmonthly
:
true
}
),
),
new
TaskGroup
(
new
TaskGroup
(
...
@@ -647,7 +647,7 @@ export async function createTasks(uri, fromDate, toDate) {
...
@@ -647,7 +647,7 @@ export async function createTasks(uri, fromDate, toDate) {
fromDate
,
fromDate
,
toDate
:
cut
?
cutOffDate
:
toDate
,
toDate
:
cut
?
cutOffDate
:
toDate
,
},
},
{
ext
:
"json"
}
{
sign
:
"json"
}
),
),
new
Task
(
new
Task
(
{
{
...
@@ -658,7 +658,7 @@ export async function createTasks(uri, fromDate, toDate) {
...
@@ -658,7 +658,7 @@ export async function createTasks(uri, fromDate, toDate) {
fromDate
:
cut
?
cutOffDate
:
fromDate
,
fromDate
:
cut
?
cutOffDate
:
fromDate
,
toDate
,
toDate
,
},
},
{
ext
:
"json"
}
{
sign
:
"json"
}
),
),
].
slice
(...
se
)
].
slice
(...
se
)
),
),
...
...
plugin/src/main.js
View file @
e04e6148
...
@@ -38,7 +38,7 @@ export async function run(options = {}) {
...
@@ -38,7 +38,7 @@ export async function run(options = {}) {
let
fn
=
task
.
getFileName
();
let
fn
=
task
.
getFileName
();
const
isJson
=
fn
.
endsWith
(
'.json'
);
const
isJson
=
fn
.
endsWith
(
'.json'
);
if
(
!
isJson
)
fn
=
fn
.
replace
(
/
\.\w
+$/g
,
".zip"
);
if
(
!
isJson
)
fn
=
fn
.
replace
(
/
\.\w
+$/g
,
".zip"
);
if
(
(
isSingle
||
isJson
)
&&
!
await
checkLog
(
fn
)
)
{
if
(
isSingle
||
isJson
?
!
await
checkLog
(
fn
):
false
)
{
console
.
log
(
`
${
pf
}
skip2`
);
console
.
log
(
`
${
pf
}
skip2`
);
continue
;
continue
;
}
}
...
...
plugin/src/task.js
View file @
e04e6148
...
@@ -59,15 +59,15 @@ export class Task {
...
@@ -59,15 +59,15 @@ export class Task {
if
(
!
(
this
.
uri
&&
this
.
partnerId
))
{
if
(
!
(
this
.
uri
&&
this
.
partnerId
))
{
throw
new
Error
(
`uri:
${
this
.
uri
}
, partnerId:
${
this
.
partnerId
}
`
);
throw
new
Error
(
`uri:
${
this
.
uri
}
, partnerId:
${
this
.
partnerId
}
`
);
}
}
this
.
_ext
=
this
.
options
.
ext
||
"csv"
// 扩展名
this
.
_retryLimit
=
6
this
.
_retryLimit
=
6
this
.
_retryCount
=
0
this
.
_retryCount
=
0
}
}
getFileName
(
sf
)
{
getFileName
(
sf
)
{
const
ext
=
this
.
options
.
ext
||
'csv'
;
let
name
=
this
.
names
.
showName
;
let
name
=
this
.
names
.
showName
;
name
=
this
.
options
.
noLowerCase
?
name
:
name
.
toLowerCase
();
name
=
this
.
options
.
noLowerCase
?
name
:
name
.
toLowerCase
();
sf
=
sf
===
undefined
||
sf
===
null
?
''
:
' '
+
sf
;
sf
=
sf
===
undefined
||
sf
===
null
?
''
:
' '
+
sf
;
return
`
${
this
.
partnerId
}
#
${
name
}
#
${
this
.
desc
}${
sf
}
.
${
ext
}
`
;
return
`
${
this
.
partnerId
}
#
${
name
}
#
${
this
.
desc
}${
sf
}
.
${
this
.
_
ext
}
`
;
}
}
async
_retry
(
args
)
{
async
_retry
(
args
)
{
if
(
++
this
.
_retryCount
<
this
.
_retryLimit
)
{
if
(
++
this
.
_retryCount
<
this
.
_retryLimit
)
{
...
@@ -85,7 +85,7 @@ export class Task {
...
@@ -85,7 +85,7 @@ export class Task {
const
url
=
new
URL
(
`
${
this
.
uri
}${
this
.
names
.
apiName
||
''
}
`
);
const
url
=
new
URL
(
`
${
this
.
uri
}${
this
.
names
.
apiName
||
''
}
`
);
const
method
=
this
.
options
.
method
||
'GET'
;
const
method
=
this
.
options
.
method
||
'GET'
;
const
callback
=
this
.
options
.
callback
;
const
callback
=
this
.
options
.
callback
;
const
ext
=
this
.
options
.
ext
||
'csv'
;
const
sign
=
this
.
options
.
sign
;
next
|=
this
.
options
.
next
;
next
|=
this
.
options
.
next
;
let
body
=
this
.
options
.
body
;
let
body
=
this
.
options
.
body
;
...
@@ -114,23 +114,21 @@ export class Task {
...
@@ -114,23 +114,21 @@ export class Task {
console
.
error
(
`重试回调,
${
e
.
message
}
`
);
console
.
error
(
`重试回调,
${
e
.
message
}
`
);
return
this
.
_retry
(
arguments
);
return
this
.
_retry
(
arguments
);
}
}
}
else
if
(
ext
==
'json'
)
{
}
else
if
(
sign
==
'json'
)
{
const
json
=
await
response
.
json
();
const
json
=
await
response
.
json
();
if
(
Object
.
keys
(
json
).
length
===
0
)
{
if
(
Object
.
keys
(
json
).
length
===
0
)
{
return
true
;
return
true
;
}
}
const
csv
=
JSON2CSV
(
json
);
const
csv
=
JSON2CSV
(
json
);
blob
=
new
Blob
([
csv
],
{
type
:
"text/csv"
});
blob
=
new
Blob
([
csv
],
{
type
:
"text/csv"
});
this
.
options
.
ext
=
"csv"
;
}
else
{
}
else
{
blob
=
await
response
.
blob
();
blob
=
await
response
.
blob
();
}
}
if
(
blob
===
undefined
||
blob
===
null
)
return
false
;
if
(
blob
===
undefined
||
blob
===
null
)
return
false
;
if
(
next
)
return
blob
;
if
(
next
)
return
blob
;
const
fn
=
this
.
getFileName
();
const
fn
=
this
.
getFileName
();
if
(
ext
===
'zip'
)
{
if
(
sign
===
'zip'
)
{
const
newFn
=
fn
.
replace
(
/
\.\w
+$/g
,
".csv"
);
return
renameZipFile
(
blob
,
fn
);
return
renameZipFile
(
blob
,
newFn
);
}
}
return
createZip
([
blob
],
[
fn
]);
return
createZip
([
blob
],
[
fn
]);
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
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