Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions sau_frontend/src/views/PublishCenter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,19 @@ const defaultTabInit = {
publishStatus: null // 发布状态,包含message和type
}

// tab页数据 - 默认只有一个tab
// helper to create a fresh deep-copied tab from defaultTabInit
const makeNewTab = () => {
// prefer structuredClone when available (newer browsers/node), fallback to JSON
try {
return typeof structuredClone === 'function' ? structuredClone(defaultTabInit) : JSON.parse(JSON.stringify(defaultTabInit))
} catch (e) {
return JSON.parse(JSON.stringify(defaultTabInit))
}
}

// tab页数据 - 默认只有一个tab (use deep copy to avoid shared refs)
const tabs = reactive([
defaultTabInit
makeNewTab()
])

// 账号相关状态
Expand Down Expand Up @@ -568,9 +578,9 @@ const recommendedTopics = [
// 添加新tab
const addTab = () => {
tabCounter++
const newTab = defaultTabInit
newTab['name'] = `tab${tabCounter}`
newTab['label'] = `发布${tabCounter}`
const newTab = makeNewTab()
newTab.name = `tab${tabCounter}`
newTab.label = `发布${tabCounter}`
tabs.push(newTab)
activeTab.value = newTab.name
}
Expand Down
11 changes: 11 additions & 0 deletions uploader/douyin_uploader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ async def handle_product_dialog(self, page: Page, product_title: str):
"""处理商品编辑弹窗"""

await page.wait_for_timeout(2000)
await page.wait_for_selector('input[placeholder="请输入商品短标题"]', timeout=10000)
short_title_input = page.locator('input[placeholder="请输入商品短标题"]')
if not await short_title_input.count():
douyin_logger.error("[-] 未找到商品短标题输入框")
Expand Down Expand Up @@ -292,6 +293,7 @@ async def set_product_link(self, page: Page, product_link: str, product_title: s
"""设置商品链接功能"""
try:
# 定位"添加标签"文本,然后向上导航到容器,再找到下拉框
await page.wait_for_selector('text=添加标签', timeout=10000)
dropdown = page.get_by_text('添加标签').locator("..").locator("..").locator("..").locator(".semi-select").first
if not await dropdown.count():
douyin_logger.error("[-] 未找到标签下拉框")
Expand Down Expand Up @@ -321,6 +323,15 @@ async def set_product_link(self, page: Page, product_link: str, product_title: s
return False
await add_button.click()
douyin_logger.debug("[+] 成功点击'添加链接'按钮")
## 如果链接不可用
await page.wait_for_timeout(2000)
error_modal = page.locator('text=未搜索到对应商品')
if await error_modal.count():
confirm_button = page.locator('button:has-text("确定")')
await confirm_button.click()
# await page.wait_for_selector('.semi-modal-content', state='hidden', timeout=5000)
douyin_logger.error("[-] 商品链接无效")
return False

# 填写商品短标题
if not await self.handle_product_dialog(page, product_title):
Expand Down