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
2e9e01f8
Commit
2e9e01f8
authored
Mar 16, 2024
by
刘燕芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save
parent
d4411315
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
62 deletions
+70
-62
index.ts
src/background/index.ts
+58
-47
config.ts
src/config.ts
+1
-0
bookingV2.ts
src/content/bookingV2.ts
+8
-14
index.ts
src/content/index.ts
+1
-1
index.tsx
src/popup/components/WayBillModel/index.tsx
+2
-0
No files found.
src/background/index.ts
View file @
2e9e01f8
import
{
factoryContentUrls
,
bookingV2Urls
,
homeUrl
,
tmIssueUrl
,
tbIssueUrl
}
from
"../config"
;
import
{
Tabs
}
from
"antd"
;
import
{
factoryContentUrls
,
bookingV2Urls
,
homeUrl
,
tmIssueUrl
,
tbIssueUrl
,
tbIssueUrls
}
from
"../config"
;
import
{
StartPrint
,
Print
,
ACTION
}
from
"../types"
;
const
tmNameSiffix
=
[
'旗舰店'
,
'专卖店'
,
'专营店'
]
// platform: PlatformCode,// 平台编码,淘系及其他平台订单模板的为0,拼多多订单的为1,京东订单的为2
...
...
@@ -10,37 +11,33 @@ const PlatfromsMap = new Map([
])
let
monitoringRemoveTabId
=
new
Map
();
let
result_sendResponse
:
boolean
=
false
let
tb_user
:
any
=
{}
let
taIssueId
:
any
=
null
chrome
.
runtime
.
onMessage
.
addListener
(
async
function
(
message
,
sender
,
sendResponse
)
{
console
.
log
(
'message'
,
message
);
if
(
message
.
action
===
ACTION
.
task
)
{
// 如果图动力登录的账号和千牛云登录的账号不一致,则popup页面爆红
let
userData
:
any
=
await
getStorageItem
(
'tb_user'
)
console
.
log
(
'111userData'
,
userData
);
sendResponse
(
11111
);
if
(
userData
==
null
)
{
// alert('请登录千牛商家工作台')
if
(
JSON
.
stringify
(
tb_user
)
===
"{}"
)
{
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前千牛登录账号信息获取失败'
})
sendResponse
({
status
:
-
200
,
msg
:
"当前千牛登录账号信息获取失败,请登录千牛账号后重试!"
});
return
true
;
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"当前千牛登录账号信息获取失败,请登录千牛账号后重试!"
});
return
true
}
else
{
chrome
.
storage
.
sync
.
remove
(
"info"
)
let
userDataJson
:
any
=
JSON
.
parse
(
userData
)
if
(
message
.
value
.
seller
!==
userDataJson
.
userNick
){
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前登录的千牛账号与图动力登录的账号信息不一致,请统一登录后重试!'
})
console
.
log
(
222
,
new
Date
().
getTime
(),
new
Date
().
getSeconds
());
sendResponse
({
status
:
-
200
,
msg
:
"当前登录的千牛账号与图动力登录的账号信息不一致,请统一登录后重试!"
});
console
.
log
(
333
,
new
Date
().
getTime
(),
new
Date
().
getSeconds
());
return
true
;
if
(
message
.
value
.
seller
.
seller_name
!==
tb_user
.
userNick
){
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!'
})
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!"
});
return
true
}
}
// chrome.storage.sync.set({"info":'当前登录的千牛账号与图动力登录的账号信息不一致,请统一登录后重试!'})
chrome
.
tabs
.
query
({
url
:
[
'https://item.upload.taobao.com/sell/merge/category.htm*'
]
url
:
tbIssueUrls
},
async
function
(
tabs
)
{
console
.
log
(
tabs
);
// 如果图动力登录的账号和千牛云登录的账号不一致,则popup页面爆红
console
.
log
(
'tabs'
,
tabs
);
tabs
&&
tabs
.
forEach
(
tab
=>
{
// chrome.tabs.sendMessage(tab.id!, message)
chrome
.
tabs
.
update
(
tab
.
id
!
,
{
active
:
true
},
function
(
tab1
)
{});
chrome
.
tabs
.
sendMessage
(
tab
.
id
!
,
{
action
:
ACTION
.
task
,
value
:
message
.
value
},
res
=>
{
console
.
log
(
'res'
,
res
);
if
(
res
){
sendResponse
(
res
);
chrome
.
tabs
.
update
(
sender
.
tab
!
.
id
!
,
{
active
:
true
},
function
(
tab1
)
{});
...
...
@@ -48,13 +45,13 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
})
})
if
(
tabs
.
length
==
0
){
sendResponse
({
status
:
-
200
,
msg
:
"请打开千牛商家工作台"
});
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"请打开千牛商家工作台"
});
alert
(
'请打开千牛商家工作台'
)
}
})
// let port = chrome.runtime.connect({ name: "bgSendMessage" })
// port.postMessage(message)
}
else
if
(
message
.
action
===
'getUserLoginData'
){
console
.
log
(
2222
);
await
getUserLoginData
()
sendResponse
()
}
...
...
@@ -72,7 +69,6 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
}
chrome
.
storage
.
sync
.
remove
(
"tb_user"
)
result_sendResponse
=
true
;
console
.
log
(
2222
);
return
}
if
(
tab
.
url
&&
tab
.
url
.
indexOf
(
"myseller.taobao.com/home.htm/QnworkbenchHome"
)
!=
-
1
)
{
...
...
@@ -82,15 +78,23 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
if
(
userNickCookie
===
null
||
userNickCookie
===
undefined
)
{
chrome
.
storage
.
sync
.
remove
(
"tb_user"
)
result_sendResponse
=
true
;
console
.
log
(
3333
);
return
};
chrome
.
tabs
.
query
({
url
:[
tbIssueUrl
]
},
async
function
(
tabs
)
{
console
.
log
(
tabs
);
if
(
!
tabs
.
length
||
(
tabs
.
length
&&!
monitoringRemoveTabId
.
has
(
tabs
[
0
].
id
))){
taIssueId
=
await
createTab
(
tbIssueUrl
);
}
})
let
tuDe1
=
decodeURI
(
userNickCookie
.
value
);
let
tuDe2
=
unescape
(
tuDe1
.
replace
(
/
\\(
u
[
0-9a-fA-F
]{4})
/gm
,
'%$1'
));
if
(
tuDe2
.
indexOf
(
":"
)
!=
-
1
)
tuDe2
=
tuDe2
.
split
(
":"
)[
0
];
let
createUrl
=
isTm
(
tuDe2
)
?
tmIssueUrl
:
tbIssueUrl
;
let
tabId
=
await
createTab
(
createUrl
);
monitoringRemoveTabId
.
set
(
tabId
,
tuDe2
);
}
if
(
tab
.
url
&&
(
tab
.
url
.
indexOf
(
"item.upload.taobao.com/sell/merge"
)
!=
-
1
||
tab
.
url
.
indexOf
(
"sell.publish.tmall.com/tmall/smart"
)
!=
-
1
))
{
...
...
@@ -104,6 +108,7 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
token
:
token
.
value
,
userNick
:
userNick
,
}
tb_user
=
userData
chrome
.
storage
.
sync
.
set
({
"tb_user"
:
JSON
.
stringify
(
userData
)})
console
.
log
(
"user data :"
,
userData
,
new
Date
().
getMinutes
(),
new
Date
().
getSeconds
());
// let serverNum = SoketDispatchManage.hosts[config.evn].length;
...
...
@@ -131,6 +136,10 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
async
function
getUserLoginData
(){
result_sendResponse
=
false
monitoringRemoveTabId
.
clear
()
console
.
log
(
'taIssueId'
,
taIssueId
);
taIssueId
&&
chrome
.
tabs
.
remove
(
taIssueId
);
let
tabId
=
await
createTab
(
homeUrl
);
monitoringRemoveTabId
.
set
(
tabId
,
""
);
await
newTab
()
...
...
@@ -200,11 +209,13 @@ function isTm(userNick:string) {
}
return
false
;
}
function
get
StorageItem
(
key
:
string
)
{
function
get
LocalStronges
(
url
:
string
,
name
:
string
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
chrome
.
storage
.
sync
.
get
([
key
],
(
item
)
=>
{
resolve
(
item
[
key
]);
chrome
.
storage
.
local
.
get
({
url
:
url
,
name
:
name
},
(
cookies
)
=>
{
resolve
(
cookies
);
})
})
}
src/config.ts
View file @
2e9e01f8
export
const
factoryContentUrls
=
[
"http://localhost:10823/*"
,
"*://*.rtxmdz.com/*"
]
export
const
bookingV2Urls
=
[
"https://myseller.taobao.com/*"
,
"https://loginmyseller.taobao.com/*"
]
export
const
tbIssueUrls
=
[
"https://item.upload.taobao.com/sell/merge/category.htm*"
]
export
const
homeUrl
=
"https://myseller.taobao.com/home.htm/QnworkbenchHome"
;
export
const
tbIssueUrl
=
"https://item.upload.taobao.com/sell/merge/category.htm"
export
const
tmIssueUrl
=
"https://sell.publish.tmall.com/tmall/smart/category.htm"
\ No newline at end of file
src/content/bookingV2.ts
View file @
2e9e01f8
...
...
@@ -8,11 +8,11 @@ async function booking(info: any) {
let
reqMsg
=
{
msg
:
''
,
status
:
-
200
,
task_id
:
''
task_id
:
info
.
task_id
};
if
(
!
userData
){
reqMsg
.
msg
=
"请刷新连接"
;
return
return
reqMsg
}
let
userDataJson
:
any
=
JSON
.
parse
(
userData
)
let
{
data
:
result
}
=
await
axios
.
post
(
'https://item.upload.taobao.com/sell/v2/submit.htm'
,
data
,
{
...
...
@@ -40,10 +40,11 @@ async function booking(info: any) {
if
(
rType
!=
"status"
)
{
let
msg
=
JSON
.
stringify
(
rJson
.
models
);
reqMsg
.
msg
=
msg
;
}
else
{
let
numIid
=
getUrlParam
(
rSuccessUrl
,
"primaryId"
);
reqMsg
.
task_id
=
numIid
;
}
// else {
// let numIid = getUrlParam(rSuccessUrl, "primaryId");
// reqMsg.goods_id = numIid;
// }
}
return
reqMsg
}
catch
(
e
)
{
...
...
@@ -52,13 +53,6 @@ async function booking(info: any) {
return
reqMsg
}
}
async
function
bookingV2
()
{
// fetch("https://trade.taobao.com/trade/itemlist/seller_sold_notice.htm?positionCode=stopSpiderTB;stopSpiderTM;tjb;quickCollectFunds;buyOne",{method: "POST",mode:'no-cors'}).then(res => {
// console.log('fetch 111',res);
// resolve(res)
// })
// })
}
function
getStorageItem
(
key
:
string
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
chrome
.
storage
.
sync
.
get
([
key
],
(
item
)
=>
{
...
...
@@ -94,5 +88,5 @@ function delayDate(time: number) {
}
export
default
{
booking
,
bookingV2
booking
}
\ No newline at end of file
src/content/index.ts
View file @
2e9e01f8
...
...
@@ -33,8 +33,8 @@ chrome.runtime.onMessage.addListener(function (message, sender, response) {
if
(
message
.
action
===
ACTION
.
task
)
{
let
result
=
null
;
(
async
()
=>
{
// result = await BookingV2.bookingV2();
result
=
await
BookingV2
.
booking
(
message
.
value
);
console
.
log
(
2222
,
result
,
new
Date
().
getTime
(),
new
Date
().
getSeconds
());
response
(
result
);
})();
}
...
...
src/popup/components/WayBillModel/index.tsx
View file @
2e9e01f8
...
...
@@ -51,6 +51,7 @@ const WayBillModel = function () {
let
userData
=
res
.
tb_user
if
(
userData
==
null
)
{
setIsLogin
(
false
)
setLink
(
false
)
setUser
({
userNick
:
''
,
cookie
:
''
,
token
:
''
})
...
...
@@ -85,6 +86,7 @@ const WayBillModel = function () {
console
.
log
(
'userData'
,
userData
,
new
Date
().
getMinutes
(),
new
Date
().
getSeconds
());
if
(
userData
==
null
)
{
setIsLogin
(
false
)
setLink
(
false
)
setUser
({
userNick
:
''
,
cookie
:
''
,
token
:
''
})
...
...
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