Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
ruitu-fahuoyi-exension
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖健文
ruitu-fahuoyi-exension
Commits
5919c7e2
Commit
5919c7e2
authored
Mar 18, 2024
by
刘燕芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save
parent
2e9e01f8
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
801 additions
and
37 deletions
+801
-37
index.ts
src/background/index.ts
+28
-19
bookingV2.ts
src/content/bookingV2.ts
+315
-11
index.ts
src/content/index.ts
+2
-2
index.tsx
src/popup/components/WayBillModel/index.tsx
+11
-1
index.ts
src/types/index.ts
+445
-4
No files found.
src/background/index.ts
View file @
5919c7e2
import
{
Tabs
}
from
"antd"
;
import
{
Tabs
}
from
"antd"
;
import
{
factoryContentUrls
,
bookingV2Urls
,
homeUrl
,
tmIssueUrl
,
tbIssueUrl
,
tbIssueUrls
}
from
"../config"
;
import
{
factoryContentUrls
,
bookingV2Urls
,
homeUrl
,
tmIssueUrl
,
tbIssueUrl
,
tbIssueUrls
}
from
"../config"
;
import
{
StartPrint
,
Print
,
ACTION
}
from
"../types"
;
import
{
ACTION
}
from
"../types"
;
const
tmNameSiffix
=
[
'旗舰店'
,
'专卖店'
,
'专营店'
]
const
tmNameSiffix
=
[
'旗舰店'
,
'专卖店'
,
'专营店'
]
// platform: PlatformCode,// 平台编码,淘系及其他平台订单模板的为0,拼多多订单的为1,京东订单的为2
// platform: PlatformCode,// 平台编码,淘系及其他平台订单模板的为0,拼多多订单的为1,京东订单的为2
const
PlatfromsMap
=
new
Map
([
const
PlatfromsMap
=
new
Map
([
...
@@ -13,49 +13,58 @@ let monitoringRemoveTabId = new Map();
...
@@ -13,49 +13,58 @@ let monitoringRemoveTabId = new Map();
let
result_sendResponse
:
boolean
=
false
let
result_sendResponse
:
boolean
=
false
let
tb_user
:
any
=
{}
let
tb_user
:
any
=
{}
let
taIssueId
:
any
=
null
let
taIssueId
:
any
=
null
chrome
.
runtime
.
onMessage
.
addListener
(
async
function
(
message
,
sender
,
sendResponse
)
{
chrome
.
runtime
.
onMessage
.
addListener
(
function
(
message
,
sender
,
sendResponse
)
{
console
.
log
(
'message'
,
message
);
// console.log('message1',message,sender
);
if
(
message
.
action
===
ACTION
.
task
)
{
if
(
message
.
action
===
ACTION
.
task
)
{
if
(
JSON
.
stringify
(
tb_user
)
===
"{}"
)
{
if
(
JSON
.
stringify
(
tb_user
)
===
"{}"
)
{
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前千牛登录账号信息获取失败'
})
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前千牛登录账号信息获取失败'
})
console
.
log
(
111
);
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"当前千牛登录账号信息获取失败,请登录千牛账号后重试!"
});
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"当前千牛登录账号信息获取失败,请登录千牛账号后重试!"
});
return
true
return
true
}
else
{
}
else
{
chrome
.
storage
.
sync
.
remove
(
"info"
)
chrome
.
storage
.
sync
.
remove
(
"info"
)
if
(
message
.
value
.
seller
.
seller_name
!==
tb_user
.
userNick
){
if
(
message
.
value
.
seller
.
seller_name
!==
tb_user
.
userNick
){
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!'
})
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!'
})
console
.
log
(
222
);
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!"
});
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!"
});
return
true
return
true
}
}
}
}
chrome
.
tabs
.
query
({
chrome
.
tabs
.
query
({
url
:
tbIssueUrls
url
:
tbIssueUrls
},
async
function
(
tabs
)
{
},
function
(
tabs
)
{
// 如果图动力登录的账号和千牛云登录的账号不一致,则popup页面爆红
// 如果图动力登录的账号和千牛云登录的账号不一致,则popup页面爆红
console
.
log
(
'tabs'
,
tabs
);
console
.
log
(
'tabs'
,
tabs
);
tabs
&&
tabs
.
forEach
(
tab
=>
{
tabs
&&
tabs
.
forEach
(
tab
=>
{
// chrome.tabs.sendMessage(tab.id!, message)
chrome
.
tabs
.
update
(
tab
.
id
!
,
{
active
:
true
},
function
(
tab1
)
{});
chrome
.
tabs
.
update
(
tab
.
id
!
,
{
active
:
true
},
function
(
tab1
)
{});
chrome
.
tabs
.
sendMessage
(
tab
.
id
!
,
{
action
:
ACTION
.
task
,
value
:
message
.
value
},
res
=>
{
chrome
.
tabs
.
sendMessage
(
tab
.
id
!
,
{
action
:
ACTION
.
task
,
value
:
message
.
value
},
res
=>
{
console
.
log
(
'res'
,
res
);
console
.
log
(
'res'
,
res
,
new
Date
().
getTime
()
);
if
(
res
){
if
(
res
){
console
.
log
(
3333
);
sendResponse
(
res
);
sendResponse
(
res
);
chrome
.
tabs
.
update
(
sender
.
tab
!
.
id
!
,
{
active
:
true
},
function
(
tab1
)
{});
chrome
.
tabs
.
update
(
sender
.
tab
!
.
id
!
,
{
active
:
true
},
function
(
tab1
)
{});
}
}
})
})
})
})
if
(
tabs
.
length
==
0
){
if
(
tabs
.
length
==
0
){
console
.
log
(
444
);
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"请打开千牛商家工作台"
});
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"请打开千牛商家工作台"
});
alert
(
'请打开千牛商家工作台'
)
alert
(
'请打开千牛商家工作台'
)
}
}
})
})
}
else
if
(
message
.
action
===
'getUserLoginData'
){
}
else
if
(
message
.
action
===
'getUserLoginData'
){
console
.
log
(
2222
);
getUserLoginData
()
let
awaitResultFun
=
()
=>
{
await
getUserLoginData
()
if
(
result_sendResponse
){
sendResponse
()
sendResponse
()
}
else
{
setTimeout
(()
=>
{
awaitResultFun
()
},
500
);
}
}
awaitResultFun
()
}
}
return
true
;
return
true
;
})
})
chrome
.
tabs
.
onUpdated
.
addListener
(
async
(
tabId
,
changeInfo
,
tab
)
=>
{
chrome
.
tabs
.
onUpdated
.
addListener
(
async
(
tabId
,
changeInfo
,
tab
)
=>
{
...
@@ -80,11 +89,17 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
...
@@ -80,11 +89,17 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
result_sendResponse
=
true
;
result_sendResponse
=
true
;
return
return
};
};
// taIssueId&&chrome.tabs.remove(taIssueId)
chrome
.
tabs
.
query
({
chrome
.
tabs
.
query
({
url
:[
tbIssueUrl
]
url
:[
tbIssueUrl
]
},
async
function
(
tabs
)
{
},
async
function
(
tabs
)
{
console
.
log
(
tabs
);
console
.
log
(
'tabs'
,
tabs
);
if
(
!
tabs
.
length
||
(
tabs
.
length
&&!
monitoringRemoveTabId
.
has
(
tabs
[
0
].
id
))){
let
complete_tabs
:
any
=
[]
if
(
tabs
.
length
){
complete_tabs
=
tabs
.
filter
(
item
=>
item
.
status
===
'complete'
)
}
console
.
log
(
'complete_tabs'
,
complete_tabs
);
if
(
!
complete_tabs
.
length
){
taIssueId
=
await
createTab
(
tbIssueUrl
);
taIssueId
=
await
createTab
(
tbIssueUrl
);
}
}
})
})
...
@@ -121,7 +136,6 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
...
@@ -121,7 +136,6 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
// }
// }
let
id
:
any
=
tab
.
id
let
id
:
any
=
tab
.
id
result_sendResponse
=
true
;
result_sendResponse
=
true
;
console
.
log
(
4444
);
}
else
{
}
else
{
console
.
log
(
5555
);
console
.
log
(
5555
);
}
}
...
@@ -138,14 +152,9 @@ async function getUserLoginData(){
...
@@ -138,14 +152,9 @@ async function getUserLoginData(){
result_sendResponse
=
false
result_sendResponse
=
false
monitoringRemoveTabId
.
clear
()
monitoringRemoveTabId
.
clear
()
console
.
log
(
'taIssueId'
,
taIssueId
);
console
.
log
(
'taIssueId'
,
taIssueId
);
taIssueId
&&
chrome
.
tabs
.
remove
(
taIssueId
);
taIssueId
&&
chrome
.
tabs
.
remove
(
taIssueId
);
let
tabId
=
await
createTab
(
homeUrl
);
let
tabId
=
await
createTab
(
homeUrl
);
monitoringRemoveTabId
.
set
(
tabId
,
""
);
monitoringRemoveTabId
.
set
(
tabId
,
""
);
await
newTab
()
return
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
resolve
()
})
}
}
function
newTab
(){
function
newTab
(){
return
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
return
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
...
...
src/content/bookingV2.ts
View file @
5919c7e2
This diff is collapsed.
Click to expand it.
src/content/index.ts
View file @
5919c7e2
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
{
message
}
from
"antd"
;
import
{
message
}
from
"antd"
;
import
{
ACTION
,
Print
,
StartPrint
}
from
"../types"
;
import
{
ACTION
}
from
"../types"
;
import
BookingV2
from
"./bookingV2"
import
BookingV2
from
"./bookingV2"
type
Params
=
{
type
Params
=
{
...
@@ -29,7 +29,7 @@ window.addEventListener("message",function(message:any){
...
@@ -29,7 +29,7 @@ window.addEventListener("message",function(message:any){
//发货易页面
//发货易页面
chrome
.
runtime
.
onMessage
.
addListener
(
function
(
message
,
sender
,
response
)
{
chrome
.
runtime
.
onMessage
.
addListener
(
function
(
message
,
sender
,
response
)
{
console
.
log
(
"发货易页面"
,
message
);
console
.
log
(
"发货易页面"
,
message
,
sender
);
if
(
message
.
action
===
ACTION
.
task
)
{
if
(
message
.
action
===
ACTION
.
task
)
{
let
result
=
null
;
let
result
=
null
;
(
async
()
=>
{
(
async
()
=>
{
...
...
src/popup/components/WayBillModel/index.tsx
View file @
5919c7e2
...
@@ -41,7 +41,14 @@ const WayBillModel = function () {
...
@@ -41,7 +41,14 @@ const WayBillModel = function () {
}
}
})
})
},
[])
},
[])
const
delayDate
=
(
time
:
number
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
//console.log(‘开始执行‘)
resolve
(
'status'
)
},
time
)
})
}
useEffect
(()
=>
{
useEffect
(()
=>
{
getLogin
()
getLogin
()
...
@@ -82,6 +89,9 @@ const WayBillModel = function () {
...
@@ -82,6 +89,9 @@ const WayBillModel = function () {
initTime
++
initTime
++
getLogin
()
getLogin
()
chrome
.
runtime
.
sendMessage
({
action
:
'getUserLoginData'
},
async
()
=>
{
chrome
.
runtime
.
sendMessage
({
action
:
'getUserLoginData'
},
async
()
=>
{
console
.
log
(
111
,
new
Date
().
getTime
());
// await delayDate(1000)
// console.log(222,new Date().getTime());
let
userData
:
any
=
await
getStorageItem
(
"tb_user"
)
let
userData
:
any
=
await
getStorageItem
(
"tb_user"
)
console
.
log
(
'userData'
,
userData
,
new
Date
().
getMinutes
(),
new
Date
().
getSeconds
());
console
.
log
(
'userData'
,
userData
,
new
Date
().
getMinutes
(),
new
Date
().
getSeconds
());
if
(
userData
==
null
)
{
if
(
userData
==
null
)
{
...
...
src/types/index.ts
View file @
5919c7e2
This diff is collapsed.
Click to expand it.
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