|
|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useState } from 'react'
|
|
|
+import React, { useState, useEffect } from 'react'
|
|
|
import { Button, Table, Input, Message, Loading } from '@alifd/next';
|
|
|
import { CustomMessage } from '@/components/CustomMessage'
|
|
|
|
|
|
@@ -7,14 +7,38 @@ export default function DesignPic() {
|
|
|
// 添加状态管理表格数据
|
|
|
const [tableData, setTableData] = useState<any[]>([]);
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
+ const [isPage, setIsPage] = useState(true);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ is_temu_design()
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ const is_temu_design = async () => {
|
|
|
+ try {
|
|
|
+ // 获取当前活动标签页
|
|
|
+ const [tab] = await browser.tabs.query({ active: true, currentWindow: true });
|
|
|
+
|
|
|
+ // 获取页面域名
|
|
|
+ if (tab.url) {
|
|
|
+ const url = tab.url
|
|
|
+ console.log('当前页面域名:', url);
|
|
|
+ if (url.includes('main/customize-goods')) {
|
|
|
+ // temu定制页面
|
|
|
+ setIsPage(false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取当前页面域名时出错:', error);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
const pic_render = (value: any, index: any, record: any) => {
|
|
|
return (
|
|
|
<>
|
|
|
{
|
|
|
record.file ? <>
|
|
|
- <img className='size-20' src={record.file}/></> : <>
|
|
|
- <span>暂无图片</span>
|
|
|
+ <img className='size-20' src={record.file} /></> : <>
|
|
|
+ <span>暂无图片</span>
|
|
|
</>
|
|
|
}
|
|
|
</>
|
|
|
@@ -486,15 +510,21 @@ export default function DesignPic() {
|
|
|
return (
|
|
|
<Loading visible={loading} fullScreen>
|
|
|
<div className='w-3xl h-fit'>
|
|
|
- <Button type="primary" style={{ marginBottom: '10px', marginRight: '10px' }}
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ disabled={isPage}
|
|
|
+ style={{ marginBottom: '10px', marginRight: '10px' }}
|
|
|
onClick={() => {
|
|
|
getPicData()
|
|
|
}}>获取定制数据</Button>
|
|
|
- <Button disabled={!tableData.length} type="primary" style={{ marginBottom: '10px', marginRight: '10px' }}
|
|
|
+ <Button
|
|
|
+ disabled={(!tableData.length) || isPage}
|
|
|
+ type="primary"
|
|
|
+ style={{ marginBottom: '10px', marginRight: '10px' }}
|
|
|
onClick={() => {
|
|
|
uploadPic()
|
|
|
}}>上传定制信息</Button>
|
|
|
- <span className='text-red-500'>ps:上传图片过程中请勿关闭插件</span>
|
|
|
+ <span className='text-red-500'>ps:需在Temu定制商品内容页面获取数据,且上传图片过程中请勿关闭插件</span>
|
|
|
<Table dataSource={dataSourceWithIndex}>
|
|
|
<Table.Column title="图片" cell={pic_render} />
|
|
|
<Table.Column title="定制SKU" cell={name_render} />
|