兼容异常,并给出示例

This commit is contained in:
aixianling
2024-04-23 15:10:24 +08:00
parent 482391d6d3
commit 45f727ed7e
4 changed files with 20 additions and 8 deletions

View File

@@ -6,8 +6,8 @@
* @returns {*}
*/
const getSign = (token, appKey, formData) => {
token = token.split("_")[0]
export const getSign = (token, appKey, formData) => {
token = token?.split("_")[0]
const t = (new Date()).getTime();
return {
t, sign: function (e) {
@@ -158,3 +158,4 @@ const getSign = (token, appKey, formData) => {
}(token + "&" + t + "&" + appKey + "&" + formData)
}
}

View File

@@ -86,6 +86,8 @@ export function sendChromeNotification(message) {
*/
export function sendAliexpressAPIMessage(message) {
message.type = 'aliexpress'
const {mtopConfig = {appKey: "12574478"}} = window
message.appKey = message.appKey || mtopConfig.appKey
return new Promise((resolve) => {
chrome.runtime.sendMessage(message, resolve)
})

View File

@@ -131,8 +131,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
headers['Content-Type'] = 'text/html';
headers.cookie = getAliexpressCookie();
const {_m_h5_c, _m_h5_tk} = cookie2Obj(headers.cookie)
const {mtopConfig = {appKey: "12574478"}} = window
const {appKey = mtopConfig.appKey, formData} = request
const {appKey, formData} = request
const {sign, t} = getSign(_m_h5_c || _m_h5_tk, appKey, formData)
const url = new URL(request.url)
let params = new URLSearchParams(url.search);
@@ -253,7 +252,7 @@ function getSheinCookie() {
function getAliexpressCookie() {
const url = new URL("https://www.aliexpress.com/");
const url = new URL("https://csp.aliexpress.com/");
let cStr = '';
chrome.cookies.getAll({domain: url.host}, (cookie) => {
cookie.map((c) => {

View File

@@ -69,8 +69,7 @@
<script>
import AiCopyFromAliExpress from "@/components/AiCopyFromAliExpress.vue";
import {sendChromeAPIMessage} from '@/api/chromeApi'
import {getImageMd5} from "@/utils/image.js"
import {sendAliexpressAPIMessage} from '@/api/chromeApi'
export default {
name: 'NiubiCopy',
@@ -138,7 +137,7 @@ export default {
upload_sign: res4.result.signature
}
}))*/
this.$http.post('/api/copyProduct/myPage', null, {
params: {
...this.search
@@ -154,11 +153,22 @@ export default {
handleClose() {
this.copyFromDlgShow = false
},
getAliexpressGoodsList() {
sendAliexpressAPIMessage({
type: "aliexpress",
url: "https://seller-acs.aliexpress.com/h5/mtop.global.merchant.self.product.manager.render.list/1.0/?jsv=2.7.2&appKey=30267743&v=1.0&timeout=15000&H5Request=true&url=mtop.global.merchant.self.product.manager.render.list&__channel-id__=701301&api=mtop.global.merchant.self.product.manager.render.list&type=originaljson&dataType=json&valueType=original&x-i18n-regionID=AE&data=%7B%22channelId%22%3A%22701301%22%2C%22jsonBody%22%3A%22%7B%5C%22tab%5C%22%3A%5C%22online_product%5C%22%2C%5C%22sort%5C%22%3A%7B%7D%2C%5C%22filter%5C%22%3A%7B%5C%22queryCategory%5C%22%3Anull%2C%5C%22lowerPrice%5C%22%3Anull%2C%5C%22upperPrice%5C%22%3Anull%2C%5C%22status%5C%22%3A%5C%220%5C%22%2C%5C%22productId%5C%22%3Anull%7D%2C%5C%22pagination%5C%22%3A%7B%5C%22pageSize%5C%22%3A10%2C%5C%22current%5C%22%3A2%7D%7D%22%2C%22from%22%3A%22SELF%22%2C%22bizParam%22%3A%22%7B%5C%22version%5C%22%3A%5C%22simple%5C%22%7D%22%7D"
}).then(res => {
console.log(res)
})
},
// 添加模板成功
handleSuccess() {
this.copyFromDlgShow = false
this.getList()
}
},
mounted() {
this.getAliexpressGoodsList()
}
}
</script>