mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 增加自动选最大页码功能
This commit is contained in:
@@ -163,7 +163,7 @@ async function handleRead(fromAuto = false) {
|
||||
busy.value = true;
|
||||
errorText.value = '';
|
||||
syncResultText.value = '';
|
||||
statusText.value = fromAuto ? '自动读取中…' : '正在读取…';
|
||||
statusText.value = fromAuto ? '自动读取中…' : '正在读取…';
|
||||
try {
|
||||
await refreshContext();
|
||||
|
||||
@@ -181,6 +181,7 @@ async function handleRead(fromAuto = false) {
|
||||
}
|
||||
}
|
||||
|
||||
statusText.value = '检查分页(每页 100)…';
|
||||
const adapter = resolveAdapter(location.href);
|
||||
const parsed = await adapter.parseAdvertisingCost();
|
||||
const mergedItems = mergeAdvertisingItems(batch.value?.items ?? [], parsed.items);
|
||||
|
||||
@@ -42,13 +42,13 @@ function showLauncher() {
|
||||
zIndex: '2147483646',
|
||||
border: '0',
|
||||
borderRadius: '999px',
|
||||
padding: '10px 14px',
|
||||
background: '#0f172a',
|
||||
padding: '10px 16px',
|
||||
background: '#1677ff',
|
||||
color: '#fff',
|
||||
fontSize: '12px',
|
||||
fontWeight: '600',
|
||||
fontSize: '13px',
|
||||
fontWeight: '500',
|
||||
cursor: 'pointer',
|
||||
boxShadow: '0 8px 20px rgb(15 23 42 / 0.25)',
|
||||
boxShadow: '0 6px 16px rgba(22, 119, 255, 0.35)',
|
||||
} as CSSStyleDeclaration);
|
||||
btn.addEventListener('click', () => {
|
||||
minimized = false;
|
||||
|
||||
@@ -2,7 +2,25 @@
|
||||
all: initial;
|
||||
}
|
||||
|
||||
/* Ant Design 风格 token(不引入组件库,仅对齐色板与圆角) */
|
||||
.ecbi-panel {
|
||||
--ecbi-primary: #1677ff;
|
||||
--ecbi-primary-hover: #4096ff;
|
||||
--ecbi-primary-active: #0958d9;
|
||||
--ecbi-primary-bg: #e6f4ff;
|
||||
--ecbi-text: rgba(0, 0, 0, 0.88);
|
||||
--ecbi-text-secondary: rgba(0, 0, 0, 0.45);
|
||||
--ecbi-text-tertiary: rgba(0, 0, 0, 0.25);
|
||||
--ecbi-border: #d9d9d9;
|
||||
--ecbi-border-secondary: #f0f0f0;
|
||||
--ecbi-fill: #f5f5f5;
|
||||
--ecbi-bg: #ffffff;
|
||||
--ecbi-success: #52c41a;
|
||||
--ecbi-error: #ff4d4f;
|
||||
--ecbi-radius: 8px;
|
||||
--ecbi-radius-lg: 12px;
|
||||
--ecbi-radius-sm: 6px;
|
||||
|
||||
position: fixed;
|
||||
z-index: 2147483646;
|
||||
width: 380px;
|
||||
@@ -10,17 +28,17 @@
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #ffffff;
|
||||
color: #0f172a;
|
||||
border-radius: var(--ecbi-radius-lg);
|
||||
border: 1px solid var(--ecbi-border-secondary);
|
||||
background: var(--ecbi-bg);
|
||||
color: var(--ecbi-text);
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgb(15 23 42 / 0.12),
|
||||
0 4px 6px -4px rgb(15 23 42 / 0.08);
|
||||
0 6px 16px 0 rgb(0 0 0 / 0.08),
|
||||
0 3px 6px -4px rgb(0 0 0 / 0.12),
|
||||
0 9px 28px 8px rgb(0 0 0 / 0.05);
|
||||
font-family:
|
||||
ui-sans-serif,
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
'Segoe UI',
|
||||
Roboto,
|
||||
'Helvetica Neue',
|
||||
@@ -28,7 +46,7 @@
|
||||
'Noto Sans',
|
||||
sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
line-height: 1.5714;
|
||||
}
|
||||
|
||||
.ecbi-header {
|
||||
@@ -36,23 +54,24 @@
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
background: #0f172a;
|
||||
color: #f8fafc;
|
||||
padding: 12px 14px;
|
||||
background: var(--ecbi-primary);
|
||||
color: #fff;
|
||||
cursor: move;
|
||||
user-select: none;
|
||||
border-radius: var(--ecbi-radius-lg) var(--ecbi-radius-lg) 0 0;
|
||||
}
|
||||
|
||||
.ecbi-header h1 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.ecbi-header p {
|
||||
margin: 2px 0 0;
|
||||
font-size: 11px;
|
||||
opacity: 0.75;
|
||||
font-size: 12px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.ecbi-header-actions {
|
||||
@@ -63,23 +82,23 @@
|
||||
.ecbi-icon-btn {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #e2e8f0;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 6px;
|
||||
color: #fff;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: var(--ecbi-radius-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ecbi-icon-btn:hover {
|
||||
background: rgb(255 255 255 / 0.12);
|
||||
background: rgb(255 255 255 / 0.16);
|
||||
}
|
||||
|
||||
.ecbi-body {
|
||||
padding: 12px;
|
||||
padding: 14px;
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.ecbi-row {
|
||||
@@ -90,32 +109,36 @@
|
||||
}
|
||||
|
||||
.ecbi-label {
|
||||
color: #64748b;
|
||||
color: var(--ecbi-text-secondary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.ecbi-input,
|
||||
.ecbi-select {
|
||||
width: 100%;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
padding: 6px 8px;
|
||||
border: 1px solid var(--ecbi-border);
|
||||
border-radius: var(--ecbi-radius);
|
||||
padding: 6px 11px;
|
||||
font-size: 13px;
|
||||
outline: none;
|
||||
background: #fff;
|
||||
color: #0f172a;
|
||||
background: var(--ecbi-bg);
|
||||
color: var(--ecbi-text);
|
||||
box-sizing: border-box;
|
||||
transition:
|
||||
border-color 0.2s,
|
||||
box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.ecbi-input:focus,
|
||||
.ecbi-select:focus {
|
||||
border-color: #94a3b8;
|
||||
border-color: var(--ecbi-primary);
|
||||
box-shadow: 0 0 0 2px rgb(22 119 255 / 0.2);
|
||||
}
|
||||
|
||||
.ecbi-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ecbi-actions {
|
||||
@@ -125,53 +148,64 @@
|
||||
|
||||
.ecbi-btn {
|
||||
flex: 1;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #cbd5e1;
|
||||
background: #fff;
|
||||
padding: 8px 10px;
|
||||
border-radius: var(--ecbi-radius);
|
||||
border: 1px solid var(--ecbi-border);
|
||||
background: var(--ecbi-bg);
|
||||
color: var(--ecbi-text);
|
||||
padding: 6px 12px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
font-weight: 400;
|
||||
line-height: 1.5714;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
color 0.2s,
|
||||
border-color 0.2s,
|
||||
background 0.2s;
|
||||
}
|
||||
|
||||
.ecbi-btn:disabled {
|
||||
opacity: 0.5;
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.ecbi-btn-primary {
|
||||
border-color: #059669;
|
||||
background: #059669;
|
||||
border-color: var(--ecbi-primary);
|
||||
background: var(--ecbi-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.ecbi-btn-primary:hover:not(:disabled) {
|
||||
background: #047857;
|
||||
border-color: var(--ecbi-primary-hover);
|
||||
background: var(--ecbi-primary-hover);
|
||||
}
|
||||
|
||||
.ecbi-btn-primary:active:not(:disabled) {
|
||||
border-color: var(--ecbi-primary-active);
|
||||
background: var(--ecbi-primary-active);
|
||||
}
|
||||
|
||||
.ecbi-btn-ghost:hover:not(:disabled) {
|
||||
background: #f8fafc;
|
||||
color: var(--ecbi-primary);
|
||||
border-color: var(--ecbi-primary);
|
||||
}
|
||||
|
||||
.ecbi-card {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
padding: 10px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid var(--ecbi-border-secondary);
|
||||
border-radius: var(--ecbi-radius-lg);
|
||||
padding: 12px;
|
||||
background: var(--ecbi-fill);
|
||||
}
|
||||
|
||||
.ecbi-card h2 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: #64748b;
|
||||
color: var(--ecbi-text-secondary);
|
||||
}
|
||||
|
||||
.ecbi-fee {
|
||||
font-weight: 700;
|
||||
color: #e11d48;
|
||||
font-weight: 600;
|
||||
color: var(--ecbi-error);
|
||||
}
|
||||
|
||||
.ecbi-list {
|
||||
@@ -187,23 +221,23 @@
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
color: #475569;
|
||||
padding: 2px 0;
|
||||
color: var(--ecbi-text-secondary);
|
||||
padding: 3px 0;
|
||||
}
|
||||
|
||||
.ecbi-muted {
|
||||
color: #94a3b8;
|
||||
color: var(--ecbi-text-tertiary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.ecbi-error {
|
||||
color: #e11d48;
|
||||
color: var(--ecbi-error);
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.ecbi-ok {
|
||||
color: #047857;
|
||||
color: var(--ecbi-success);
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
@@ -211,17 +245,17 @@
|
||||
.ecbi-link {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #0369a1;
|
||||
color: var(--ecbi-primary);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ecbi-link:hover {
|
||||
text-decoration: underline;
|
||||
color: var(--ecbi-primary-hover);
|
||||
}
|
||||
|
||||
/* —— 读取日历(贡献图) —— */
|
||||
/* —— 读取日历(贡献图,蓝色阶) —— */
|
||||
.ecbi-heat {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -236,11 +270,9 @@
|
||||
}
|
||||
|
||||
.ecbi-heat-title {
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: #64748b;
|
||||
color: var(--ecbi-text-secondary);
|
||||
}
|
||||
|
||||
.ecbi-heat-body {
|
||||
@@ -266,7 +298,7 @@
|
||||
width: 14px;
|
||||
font-size: 9px;
|
||||
line-height: 11px;
|
||||
color: #94a3b8;
|
||||
color: var(--ecbi-text-tertiary);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@@ -286,7 +318,7 @@
|
||||
height: 14px;
|
||||
font-size: 9px;
|
||||
line-height: 14px;
|
||||
color: #94a3b8;
|
||||
color: var(--ecbi-text-tertiary);
|
||||
white-space: nowrap;
|
||||
width: max-content;
|
||||
max-width: none;
|
||||
@@ -298,7 +330,7 @@
|
||||
.ecbi-heat-cell {
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
border-radius: 2px;
|
||||
border-radius: 3px;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
display: block;
|
||||
@@ -320,19 +352,19 @@ button.ecbi-heat-cell:disabled {
|
||||
}
|
||||
|
||||
.ecbi-heat-l1 {
|
||||
background: #bbf7d0;
|
||||
background: #bae0ff;
|
||||
}
|
||||
|
||||
.ecbi-heat-l2 {
|
||||
background: #86efac;
|
||||
background: #69b1ff;
|
||||
}
|
||||
|
||||
.ecbi-heat-l3 {
|
||||
background: #22c55e;
|
||||
background: #1677ff;
|
||||
}
|
||||
|
||||
.ecbi-heat-l4 {
|
||||
background: #15803d;
|
||||
background: #0958d9;
|
||||
}
|
||||
|
||||
.ecbi-heat-out {
|
||||
@@ -340,16 +372,16 @@ button.ecbi-heat-cell:disabled {
|
||||
}
|
||||
|
||||
.ecbi-heat-page {
|
||||
outline: 1px dashed #0369a1;
|
||||
outline: 1px dashed var(--ecbi-primary);
|
||||
outline-offset: 0;
|
||||
}
|
||||
|
||||
.ecbi-heat-today:not(.ecbi-heat-selected) {
|
||||
box-shadow: inset 0 0 0 1px #64748b;
|
||||
box-shadow: inset 0 0 0 1px var(--ecbi-text-secondary);
|
||||
}
|
||||
|
||||
.ecbi-heat-selected {
|
||||
outline: 2px solid #0f172a;
|
||||
outline: 2px solid var(--ecbi-text);
|
||||
outline-offset: 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { PlatformAdapter } from '@/platform/core/PlatformAdapter';
|
||||
import type { AdvertisingCostBatch, PageContext } from '@/types/advertisingCost';
|
||||
|
||||
import { ensurePageSize100 } from './ensurePageSize';
|
||||
import {
|
||||
isPddPromotionOverviewUrl,
|
||||
parsePromotionItems,
|
||||
@@ -56,6 +57,9 @@ export class PddPlatformAdapter implements PlatformAdapter {
|
||||
throw new Error(dateInfo.message ?? '未能识别单日报表日期');
|
||||
}
|
||||
|
||||
// 读取前把「每页」自动切到 100,减少分页漏读
|
||||
await ensurePageSize100();
|
||||
|
||||
const items = parsePromotionItems(dateInfo.feeDate);
|
||||
if (items.length === 0) {
|
||||
throw new Error('未解析到商品推广费,请确认表格已加载且包含「总花费」列');
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
import { PDD_SELECTORS } from './selectors';
|
||||
|
||||
const TARGET_PAGE_SIZE = 100;
|
||||
|
||||
function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function dispatchMouse(el: HTMLElement, type: string): void {
|
||||
el.dispatchEvent(
|
||||
new MouseEvent(type, {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
view: window,
|
||||
buttons: 1,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/** Ant Design Select 开合依赖 mousedown,单用 click() 首次常打不开 */
|
||||
function pointerClick(el: HTMLElement): void {
|
||||
dispatchMouse(el, 'pointerdown');
|
||||
dispatchMouse(el, 'mousedown');
|
||||
dispatchMouse(el, 'pointerup');
|
||||
dispatchMouse(el, 'mouseup');
|
||||
dispatchMouse(el, 'click');
|
||||
}
|
||||
|
||||
function findPageSizeSelect(doc: Document = document): HTMLElement | null {
|
||||
const wrap =
|
||||
doc.querySelector(PDD_SELECTORS.overviewTable) ??
|
||||
doc.querySelector(PDD_SELECTORS.paginationWrap) ??
|
||||
doc;
|
||||
const perPage = wrap.querySelector(PDD_SELECTORS.perPageText);
|
||||
const li = perPage?.closest('li') ?? wrap.querySelector('.anq-pagination-total-text');
|
||||
const select =
|
||||
(li?.querySelector(PDD_SELECTORS.pageSizeSelect) as HTMLElement | null) ??
|
||||
(wrap.querySelector(
|
||||
`${PDD_SELECTORS.paginationWrap} ${PDD_SELECTORS.pageSizeSelect}`,
|
||||
) as HTMLElement | null);
|
||||
return select;
|
||||
}
|
||||
|
||||
function readCurrentPageSize(select: Element): number | undefined {
|
||||
const item = select.querySelector(PDD_SELECTORS.pageSizeValue);
|
||||
const raw = (item?.getAttribute('title') || item?.textContent || '').trim();
|
||||
const value = Number(raw.replace(/[^\d]/g, ''));
|
||||
return Number.isFinite(value) && value > 0 ? value : undefined;
|
||||
}
|
||||
|
||||
function getCombobox(select: Element): HTMLInputElement | null {
|
||||
return select.querySelector('input[role="combobox"], .anq-select-selection-search-input');
|
||||
}
|
||||
|
||||
function isSelectOpen(select: Element): boolean {
|
||||
return getCombobox(select)?.getAttribute('aria-expanded') === 'true';
|
||||
}
|
||||
|
||||
/** 仅认「当前可见」的下拉,避免点到手动操作后残留的 hidden dropdown */
|
||||
function findVisibleDropdown(doc: Document = document): HTMLElement | null {
|
||||
const dropdowns = Array.from(doc.querySelectorAll('.anq-select-dropdown'));
|
||||
for (const el of dropdowns) {
|
||||
if (el.classList.contains('anq-select-dropdown-hidden')) continue;
|
||||
const style = window.getComputedStyle(el);
|
||||
if (style.display === 'none' || style.visibility === 'hidden') continue;
|
||||
if (style.pointerEvents === 'none') continue;
|
||||
return el as HTMLElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function isTargetOption(el: Element, target: number): boolean {
|
||||
const title = (el.getAttribute('title') || '').trim();
|
||||
const text = (el.textContent || '').replace(/\s+/g, ' ').trim();
|
||||
if (title === String(target)) return true;
|
||||
if (text === String(target)) return true;
|
||||
if (text === `${target}条` || text === `${target} 条`) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function findOptionIn(root: ParentNode, target: number): HTMLElement | null {
|
||||
const candidates = root.querySelectorAll(
|
||||
[
|
||||
'.anq-select-item-option',
|
||||
'[class*="select-item-option"]',
|
||||
'[role="option"]',
|
||||
].join(','),
|
||||
);
|
||||
for (const el of candidates) {
|
||||
if (el.classList.contains('anq-select-item-option-disabled')) continue;
|
||||
if (isTargetOption(el, target)) return el as HTMLElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function waitForVisibleOption(
|
||||
target: number,
|
||||
timeoutMs: number,
|
||||
doc: Document,
|
||||
): Promise<HTMLElement | null> {
|
||||
const started = Date.now();
|
||||
while (Date.now() - started < timeoutMs) {
|
||||
const dropdown = findVisibleDropdown(doc);
|
||||
if (dropdown) {
|
||||
const option = findOptionIn(dropdown, target);
|
||||
if (option) return option;
|
||||
}
|
||||
await sleep(80);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function waitUntilPageSize(
|
||||
select: Element,
|
||||
target: number,
|
||||
timeoutMs = 4000,
|
||||
): Promise<boolean> {
|
||||
const started = Date.now();
|
||||
while (Date.now() - started < timeoutMs) {
|
||||
if (readCurrentPageSize(select) === target) return true;
|
||||
await sleep(100);
|
||||
}
|
||||
return readCurrentPageSize(select) === target;
|
||||
}
|
||||
|
||||
async function openPageSizeSelect(select: HTMLElement, doc: Document): Promise<boolean> {
|
||||
const trigger =
|
||||
(select.querySelector('.anq-select-selector') as HTMLElement | null) ?? select;
|
||||
const input = getCombobox(select);
|
||||
|
||||
trigger.scrollIntoView({ block: 'center', inline: 'nearest' });
|
||||
await sleep(50);
|
||||
input?.focus({ preventScroll: true });
|
||||
|
||||
// 已打开则先关掉,保证重新挂载可见下拉(避免点到残留 hidden 节点)
|
||||
if (isSelectOpen(select) || findVisibleDropdown(doc)) {
|
||||
doc.body.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true }),
|
||||
);
|
||||
await sleep(120);
|
||||
}
|
||||
|
||||
pointerClick(trigger);
|
||||
|
||||
const started = Date.now();
|
||||
while (Date.now() - started < 1500) {
|
||||
if (isSelectOpen(select) && findVisibleDropdown(doc)) return true;
|
||||
await sleep(80);
|
||||
}
|
||||
|
||||
// 再试一次:部分 antd 版本首次 mousedown 被挡
|
||||
pointerClick(trigger);
|
||||
const retryStart = Date.now();
|
||||
while (Date.now() - retryStart < 1500) {
|
||||
if (isSelectOpen(select) && findVisibleDropdown(doc)) return true;
|
||||
await sleep(80);
|
||||
}
|
||||
return Boolean(isSelectOpen(select) && findVisibleDropdown(doc));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将推广商品表分页「每页」自动切到 100(若已是 100 则跳过)。
|
||||
*
|
||||
* 注意:首次进入页面时下拉选项不在 DOM;手动切换过后,antd 常把
|
||||
* `.anq-select-dropdown-hidden` 残留在 body。若只搜全局 option,
|
||||
* 会点到不可见节点「看似成功」或首次完全失败。因此必须:
|
||||
* 1) 用 mousedown 序列真正打开 Select
|
||||
* 2) 只点击「可见」dropdown 内的 100
|
||||
*/
|
||||
export async function ensurePageSize100(doc: Document = document): Promise<{
|
||||
changed: boolean;
|
||||
pageSize?: number;
|
||||
}> {
|
||||
const select = findPageSizeSelect(doc);
|
||||
if (!select) {
|
||||
return { changed: false };
|
||||
}
|
||||
|
||||
const current = readCurrentPageSize(select);
|
||||
if (current === TARGET_PAGE_SIZE) {
|
||||
return { changed: false, pageSize: current };
|
||||
}
|
||||
|
||||
const opened = await openPageSizeSelect(select, doc);
|
||||
if (!opened) {
|
||||
doc.body.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true }),
|
||||
);
|
||||
throw new Error(
|
||||
`未能打开每页条数下拉(当前 ${current ?? '未知'})。请先滚动到表格底部分页区后重试`,
|
||||
);
|
||||
}
|
||||
|
||||
const option = await waitForVisibleOption(TARGET_PAGE_SIZE, 2500, doc);
|
||||
if (!option) {
|
||||
doc.body.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true }),
|
||||
);
|
||||
throw new Error(
|
||||
`下拉已打开但未找到 ${TARGET_PAGE_SIZE} 选项,请确认分页支持该页大小`,
|
||||
);
|
||||
}
|
||||
|
||||
pointerClick(option);
|
||||
const ok = await waitUntilPageSize(select, TARGET_PAGE_SIZE);
|
||||
if (!ok) {
|
||||
throw new Error(`切换每页 ${TARGET_PAGE_SIZE} 未生效,请手动切换后重试`);
|
||||
}
|
||||
|
||||
await sleep(900);
|
||||
return { changed: true, pageSize: TARGET_PAGE_SIZE };
|
||||
}
|
||||
@@ -9,6 +9,11 @@ export const PDD_SELECTORS = {
|
||||
rangePickerInput: '.anq-picker-range .anq-picker-input input',
|
||||
/** 表头可能在 sticky 独立 table 里,需在整个 OverviewTable_wrap 内查找 */
|
||||
tableHeaderCell: 'thead th',
|
||||
/** 分页「每页」 */
|
||||
paginationWrap: '[class*="OverviewTable_paginationWrap"], .anq-pagination-wrapper',
|
||||
perPageText: '.anq-perpage-text',
|
||||
pageSizeSelect: '.anq-select',
|
||||
pageSizeValue: '.anq-select-selection-item',
|
||||
} as const;
|
||||
|
||||
/** 推广费列名:取「总花费(元)」 */
|
||||
|
||||
@@ -118,42 +118,42 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-[360px] flex-col gap-3 p-4">
|
||||
<div class="flex w-[360px] flex-col gap-3 bg-antd-bg p-4 text-antd-text">
|
||||
<header>
|
||||
<h1 class="text-base font-semibold tracking-tight">{{ EXTENSION_NAME }}</h1>
|
||||
<p class="mt-0.5 text-xs text-slate-500">
|
||||
<h1 class="text-base font-semibold tracking-tight text-antd-text">{{ EXTENSION_NAME }}</h1>
|
||||
<p class="mt-0.5 text-xs text-antd-text-secondary">
|
||||
Popup 负责配置与开关;业务操作在页内悬浮层完成。
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<section class="space-y-2 rounded-lg border border-slate-200 bg-white p-3">
|
||||
<h2 class="text-xs font-semibold uppercase tracking-wide text-slate-500">Open API 配置</h2>
|
||||
<label class="block text-xs text-slate-600">
|
||||
<section class="space-y-2 rounded-antd-lg border border-antd-border-secondary bg-white p-3 shadow-sm">
|
||||
<h2 class="text-xs font-semibold text-antd-text-secondary">Open API 配置</h2>
|
||||
<label class="block text-xs text-antd-text-secondary">
|
||||
Base URL
|
||||
<input
|
||||
v-model="apiBaseUrl"
|
||||
class="mt-1 w-full rounded-md border border-slate-200 px-2 py-1.5 text-sm outline-none focus:border-slate-400"
|
||||
class="mt-1 w-full rounded-antd border border-antd-border px-2.5 py-1.5 text-sm outline-none transition focus:border-antd-primary focus:shadow-[0_0_0_2px_rgba(22,119,255,0.2)]"
|
||||
placeholder="https://host/api"
|
||||
/>
|
||||
</label>
|
||||
<label class="block text-xs text-slate-600">
|
||||
<label class="block text-xs text-antd-text-secondary">
|
||||
API Key
|
||||
<input
|
||||
v-model="apiKey"
|
||||
type="password"
|
||||
class="mt-1 w-full rounded-md border border-slate-200 px-2 py-1.5 text-sm outline-none focus:border-slate-400"
|
||||
class="mt-1 w-full rounded-antd border border-antd-border px-2.5 py-1.5 text-sm outline-none transition focus:border-antd-primary focus:shadow-[0_0_0_2px_rgba(22,119,255,0.2)]"
|
||||
placeholder="sk_live_..."
|
||||
/>
|
||||
</label>
|
||||
<p class="text-[11px] leading-relaxed text-slate-400">
|
||||
<p class="text-[11px] leading-relaxed text-antd-text-tertiary">
|
||||
需要 scope:{{ OPEN_SCOPES.pddShopRead }}、{{ OPEN_SCOPES.pddGoodsAdFeeImport }}
|
||||
</p>
|
||||
|
||||
<div class="space-y-1">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs text-slate-600">默认渠道店铺</span>
|
||||
<span class="text-xs text-antd-text-secondary">默认渠道店铺</span>
|
||||
<button
|
||||
class="text-xs text-sky-700 hover:underline"
|
||||
class="text-xs text-antd-primary hover:text-antd-primary-hover hover:underline"
|
||||
type="button"
|
||||
:disabled="shopsLoading || busy"
|
||||
@click="loadShops"
|
||||
@@ -162,7 +162,7 @@ onMounted(async () => {
|
||||
</button>
|
||||
</div>
|
||||
<select
|
||||
class="w-full rounded-md border border-slate-200 px-2 py-1.5 text-sm"
|
||||
class="w-full rounded-antd border border-antd-border px-2.5 py-1.5 text-sm outline-none transition focus:border-antd-primary"
|
||||
:value="channelShopId ?? ''"
|
||||
@change="onShopChange"
|
||||
>
|
||||
@@ -174,7 +174,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="w-full rounded-md bg-slate-900 px-3 py-1.5 text-sm text-white hover:bg-slate-800"
|
||||
class="w-full rounded-antd border border-antd-border bg-white px-3 py-1.5 text-sm text-antd-text transition hover:border-antd-primary hover:text-antd-primary disabled:opacity-50"
|
||||
type="button"
|
||||
:disabled="busy"
|
||||
@click="persistSettings"
|
||||
@@ -183,15 +183,15 @@ onMounted(async () => {
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section class="space-y-2 rounded-lg border border-slate-200 bg-white p-3">
|
||||
<h2 class="text-xs font-semibold uppercase tracking-wide text-slate-500">页内悬浮层</h2>
|
||||
<p class="text-xs text-slate-500">
|
||||
<section class="space-y-2 rounded-antd-lg border border-antd-border-secondary bg-white p-3 shadow-sm">
|
||||
<h2 class="text-xs font-semibold text-antd-text-secondary">页内悬浮层</h2>
|
||||
<p class="text-xs text-antd-text-secondary">
|
||||
当前状态:
|
||||
<span class="font-medium text-slate-800">{{ panelVisible ? '已打开' : '未打开' }}</span>
|
||||
<span class="font-medium text-antd-text">{{ panelVisible ? '已打开' : '未打开' }}</span>
|
||||
</p>
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
class="flex-1 rounded-md bg-emerald-600 px-3 py-2 text-sm font-medium text-white hover:bg-emerald-500 disabled:opacity-50"
|
||||
class="flex-1 rounded-antd bg-antd-primary px-3 py-2 text-sm font-medium text-white transition hover:bg-antd-primary-hover disabled:opacity-50"
|
||||
type="button"
|
||||
:disabled="busy"
|
||||
@click="handleOpenPanel"
|
||||
@@ -199,7 +199,7 @@ onMounted(async () => {
|
||||
打开悬浮层
|
||||
</button>
|
||||
<button
|
||||
class="flex-1 rounded-md border border-slate-300 bg-white px-3 py-2 text-sm font-medium hover:bg-slate-50 disabled:opacity-50"
|
||||
class="flex-1 rounded-antd border border-antd-border bg-white px-3 py-2 text-sm font-medium text-antd-text transition hover:border-antd-primary hover:text-antd-primary disabled:opacity-50"
|
||||
type="button"
|
||||
:disabled="busy"
|
||||
@click="handleTogglePanel"
|
||||
@@ -207,10 +207,10 @@ onMounted(async () => {
|
||||
开关切换
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-[11px] text-slate-400">若提示无法连接页面脚本,请先刷新目标网页。</p>
|
||||
<p class="text-[11px] text-antd-text-tertiary">若提示无法连接页面脚本,请先刷新目标网页。</p>
|
||||
</section>
|
||||
|
||||
<p v-if="statusText" class="text-xs text-emerald-700">{{ statusText }}</p>
|
||||
<p v-if="errorText" class="text-xs text-rose-600">{{ errorText }}</p>
|
||||
<p v-if="statusText" class="text-xs text-antd-success">{{ statusText }}</p>
|
||||
<p v-if="errorText" class="text-xs text-antd-error">{{ errorText }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -7,4 +7,15 @@ body {
|
||||
margin: 0;
|
||||
min-width: 360px;
|
||||
min-height: 480px;
|
||||
color: rgba(0, 0, 0, 0.88);
|
||||
background: #ffffff;
|
||||
font-family:
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
'Segoe UI',
|
||||
Roboto,
|
||||
'Helvetica Neue',
|
||||
Arial,
|
||||
'Noto Sans',
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,33 @@
|
||||
export default {
|
||||
content: ['./src/**/*.{vue,ts,html}'],
|
||||
theme: {
|
||||
extend: {},
|
||||
extend: {
|
||||
colors: {
|
||||
antd: {
|
||||
primary: '#1677ff',
|
||||
'primary-hover': '#4096ff',
|
||||
'primary-active': '#0958d9',
|
||||
text: 'rgba(0, 0, 0, 0.88)',
|
||||
'text-secondary': 'rgba(0, 0, 0, 0.45)',
|
||||
'text-tertiary': 'rgba(0, 0, 0, 0.25)',
|
||||
border: '#d9d9d9',
|
||||
'border-secondary': '#f0f0f0',
|
||||
fill: '#f5f5f5',
|
||||
bg: '#ffffff',
|
||||
success: '#52c41a',
|
||||
error: '#ff4d4f',
|
||||
warning: '#faad14',
|
||||
},
|
||||
},
|
||||
borderRadius: {
|
||||
antd: '8px',
|
||||
'antd-lg': '12px',
|
||||
'antd-sm': '6px',
|
||||
},
|
||||
boxShadow: {
|
||||
antd: '0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)',
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user