提交品牌删除更新

This commit is contained in:
super
2026-03-26 17:39:20 +08:00
parent d0ca28ae2d
commit 7fcdf1a761
10 changed files with 5964 additions and 1211 deletions

3
.gitignore vendored
View File

@@ -33,3 +33,6 @@ backend-java/*.iml
# desktop app
desktop/
ERP-Demo/
xlsx/
app/__pycache__
backend/__pycache__

4205
app/user_data/2026_03_26.log Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version": "1.0.3"}
{"version": "1.0.13"}

View File

@@ -1,11 +1,17 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>亚马逊 - 南日AI</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Microsoft YaHei", "Noto Serif SC", "SimSun", "Songti SC", "Times New Roman", serif;
background: rgba(13, 13, 13, 1);
@@ -14,6 +20,7 @@
height: 100vh;
font-weight: bold;
}
.top-bar {
height: 56px;
display: flex;
@@ -22,12 +29,19 @@
padding: 0 16px;
border-bottom: 1px solid #2a2a2a;
}
.logo-area {
display: flex;
align-items: center;
gap: 10px;
}
.top-bar .app-name { font-size: 18px; font-weight: 600; color: #fff; }
.top-bar .app-name {
font-size: 18px;
font-weight: 600;
color: #fff;
}
.btn-home {
font-size: 13px;
color: #999;
@@ -36,7 +50,11 @@
border-radius: 6px;
transition: all 0.2s;
}
.btn-home:hover { color: #fff; background: #2a2a2a; }
.btn-home:hover {
color: #fff;
background: #2a2a2a;
}
/* 顶部栏目导航(容器化,便于后续增加栏目) */
.nav-tabs {
@@ -44,6 +62,7 @@
align-items: center;
gap: 0;
}
.nav-tab-group {
display: flex;
align-items: center;
@@ -51,6 +70,7 @@
background: rgba(77, 72, 72, 0.99);
border-radius: 10px;
}
.nav-tab-sep {
width: 1px;
height: 20px;
@@ -59,6 +79,7 @@
flex-shrink: 0;
opacity: 0.9;
}
.nav-tab {
padding: 8px 14px;
font-size: 13px;
@@ -69,14 +90,17 @@
cursor: pointer;
transition: all 0.2s;
}
.nav-tab:hover {
color: #fff;
background: #2a2a2a;
}
.nav-tab.active {
color: #3498db;
background: rgba(52, 152, 219, 0.2);
}
.top-right {
display: flex;
align-items: center;
@@ -87,6 +111,7 @@
display: flex;
height: calc(100vh - 56px);
}
/* 栏目内容容器:每个栏目一个 .tab-panel通过 data-panel 与导航对应 */
.tab-panel {
display: none;
@@ -94,9 +119,11 @@
min-width: 0;
min-height: 0;
}
.tab-panel.active {
display: flex;
}
.left-panel {
width: 380px;
background: #1e1e1e;
@@ -104,6 +131,7 @@
overflow-y: auto;
border-right: 1px solid #2a2a2a;
}
.right-panel {
flex: 1;
display: flex;
@@ -111,11 +139,13 @@
min-width: 0;
background: #1a1a1a;
}
.section-title {
font-size: 13px;
color: #bbb;
margin-bottom: 10px;
}
.upload-zone {
border: 1px dashed #3a3a3a;
border-radius: 10px;
@@ -125,9 +155,25 @@
margin-bottom: 20px;
transition: all 0.2s;
}
.upload-zone:hover { border-color: #3498db; background: #2a2a2a; }
.upload-zone .hint { color: #888; font-size: 13px; margin-bottom: 12px; }
.upload-zone .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.upload-zone:hover {
border-color: #3498db;
background: #2a2a2a;
}
.upload-zone .hint {
color: #888;
font-size: 13px;
margin-bottom: 12px;
}
.upload-zone .btns {
display: flex;
gap: 10px;
justify-content: center;
flex-wrap: wrap;
}
.opt-btn {
padding: 8px 16px;
font-size: 13px;
@@ -138,7 +184,14 @@
cursor: pointer;
transition: all 0.2s;
}
.opt-btn:hover { color: #fff; background: #333; border-color: #3498db; color: #3498db; }
.opt-btn:hover {
color: #fff;
background: #333;
border-color: #3498db;
color: #3498db;
}
.selected-files {
margin-top: 12px;
font-size: 12px;
@@ -146,8 +199,17 @@
max-height: 72px;
overflow-y: auto;
}
.selected-files span { display: block; margin: 4px 0; word-break: break-all; }
.option-group { margin-bottom: 20px; }
.selected-files span {
display: block;
margin: 4px 0;
word-break: break-all;
}
.option-group {
margin-bottom: 20px;
}
.radio-item {
display: flex;
align-items: flex-start;
@@ -159,16 +221,35 @@
border: 1px solid #2a2a2a;
margin-bottom: 8px;
}
.radio-item:hover { background: #2a2a2a; }
.radio-item input { margin-top: 3px; }
.radio-item .label { font-weight: 500; color: #e0e0e0; font-size: 13px; }
.radio-item .desc { font-size: 12px; color: #888; margin-top: 2px; font-weight: normal; }
.radio-item:hover {
background: #2a2a2a;
}
.radio-item input {
margin-top: 3px;
}
.radio-item .label {
font-weight: 500;
color: #e0e0e0;
font-size: 13px;
}
.radio-item .desc {
font-size: 12px;
color: #888;
margin-top: 2px;
font-weight: normal;
}
.run-row {
display: flex;
align-items: center;
gap: 12px;
margin-top: 16px;
}
.btn-run {
padding: 10px 22px;
background: #3498db;
@@ -179,9 +260,21 @@
cursor: pointer;
transition: all 0.2s;
}
.btn-run:hover { background: #2980b9; }
.btn-run:disabled { background: #555; cursor: not-allowed; color: #999; }
.loading-msg { color: #3498db; font-size: 13px; }
.btn-run:hover {
background: #2980b9;
}
.btn-run:disabled {
background: #555;
cursor: not-allowed;
color: #999;
}
.loading-msg {
color: #3498db;
font-size: 13px;
}
.template-download-row {
margin-top: 16px;
@@ -195,16 +288,22 @@
transition: all 0.25s ease;
cursor: pointer;
}
.template-download-row:hover {
border-color: #2e7d32;
background: linear-gradient(135deg, #2a2a2a 0%, #243324 100%);
box-shadow: 0 4px 12px rgba(46, 125, 50, 0.15);
}
.template-download-row:hover .template-download-text .title { color: #2ecc71; }
.template-download-row:hover .template-download-text .title {
color: #2ecc71;
}
.template-download-row:hover .template-download-icon {
transform: scale(1.05);
box-shadow: 0 6px 16px rgba(46, 125, 50, 0.45), inset 0 1px 0 rgba(255,255,255,0.15);
box-shadow: 0 6px 16px rgba(46, 125, 50, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.template-download-icon {
width: 48px;
height: 48px;
@@ -214,15 +313,28 @@
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 12px rgba(46, 125, 50, 0.35), inset 0 1px 0 rgba(255,255,255,0.1);
box-shadow: 0 4px 12px rgba(46, 125, 50, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
transition: transform 0.2s, box-shadow 0.2s;
}
.template-download-icon svg {
width: 28px;
height: 28px;
}
.template-download-text .title { font-size: 14px; color: #e0e0e0; font-weight: 600; display: block; }
.template-download-text .hint { font-size: 12px; color: #888; margin-top: 2px; font-weight: normal; }
.template-download-text .title {
font-size: 14px;
color: #e0e0e0;
font-weight: 600;
display: block;
}
.template-download-text .hint {
font-size: 12px;
color: #888;
margin-top: 2px;
font-weight: normal;
}
.panel-header {
padding: 16px 20px;
@@ -235,9 +347,11 @@
justify-content: space-between;
gap: 12px;
}
.panel-header-title {
flex: 1;
}
.btn-refresh-tasks {
padding: 6px 14px;
font-size: 12px;
@@ -249,17 +363,23 @@
transition: all 0.2s;
white-space: nowrap;
}
.btn-refresh-tasks:hover {
background: #333;
border-color: #3498db;
color: #3498db;
}
.task-list-wrap {
flex: 1;
overflow-y: auto;
padding: 16px;
}
.task-list { list-style: none; }
.task-list {
list-style: none;
}
.task-item {
display: flex;
align-items: center;
@@ -270,38 +390,155 @@
margin-bottom: 10px;
background: #1e1e1e;
}
.task-item .left { flex: 1; min-width: 0; }
.task-item .id { font-weight: 600; color: #e0e0e0; font-size: 13px; }
.task-item .files { font-size: 12px; color: #888; margin-top: 4px; }
.task-item .time { font-size: 12px; color: #666; margin-top: 2px; }
.task-item .left {
flex: 1;
min-width: 0;
}
.task-item .id {
font-weight: 600;
color: #e0e0e0;
font-size: 13px;
}
.task-item .files {
font-size: 12px;
color: #888;
margin-top: 4px;
}
.task-item .time {
font-size: 12px;
color: #666;
margin-top: 2px;
}
.task-item .status {
padding: 4px 10px;
border-radius: 6px;
font-size: 12px;
margin-right: 12px;
}
.task-item .status.pending { background: rgba(255,193,7,0.2); color: #d4a500; }
.task-item .status.running { background: rgba(52,152,219,0.2); color: #3498db; }
.task-item .status.success { background: rgba(46,204,113,0.2); color: #2ecc71; }
.task-item .status.failed { background: rgba(231,76,60,0.2); color: #e74c3c; }
.task-item .status.cancelled { background: rgba(149,165,166,0.2); color: #95a5a6; }
.task-item .progress-wrap { margin-top: 8px; margin-right: 8px; flex-shrink: 0; width: 120px; }
.task-item .progress-bar-bg { height: 6px; background: #2a2a2a; border-radius: 3px; overflow: hidden; }
.task-item .progress-bar-fill { height: 100%; background: #3498db; border-radius: 3px; transition: width 0.2s; }
.task-item .btn-cancel, .task-item .btn-delete {
padding: 6px 12px; font-size: 12px; border-radius: 6px; cursor: pointer; border: none; margin-left: 6px;
.task-item .status.pending {
background: rgba(255, 193, 7, 0.2);
color: #d4a500;
}
.task-item .status.running {
background: rgba(52, 152, 219, 0.2);
color: #3498db;
}
.task-item .status.success {
background: rgba(46, 204, 113, 0.2);
color: #2ecc71;
}
.task-item .status.failed {
background: rgba(231, 76, 60, 0.2);
color: #e74c3c;
}
.task-item .status.cancelled {
background: rgba(149, 165, 166, 0.2);
color: #95a5a6;
}
.task-item .progress-wrap {
margin-top: 8px;
margin-right: 8px;
flex-shrink: 0;
width: 120px;
}
.task-item .progress-bar-bg {
height: 6px;
background: #2a2a2a;
border-radius: 3px;
overflow: hidden;
}
.task-item .progress-bar-fill {
height: 100%;
background: #3498db;
border-radius: 3px;
transition: width 0.2s;
}
.task-item .btn-cancel,
.task-item .btn-delete {
padding: 6px 12px;
font-size: 12px;
border-radius: 6px;
cursor: pointer;
border: none;
margin-left: 6px;
transition: all 0.2s;
}
.task-item .btn-cancel { background: #e67e22; color: #fff; }
.task-item .btn-cancel:hover { background: #d35400; }
.task-item .btn-delete { background: #444; color: #ccc; }
.task-item .btn-delete:hover { background: #e74c3c; color: #fff; }
.task-item .task-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.run-row .progress-wrap { margin-top: 10px; width: 100%; max-width: 280px; }
.run-row .progress-bar-bg { height: 8px; background: #2a2a2a; border-radius: 4px; overflow: hidden; }
.run-row .progress-bar-fill { height: 100%; background: #3498db; border-radius: 4px; transition: width 0.2s; }
.run-row .btn-cancel-run { margin-left: 12px; padding: 8px 16px; background: #e67e22; color: #fff; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; }
.run-row .btn-cancel-run:hover { background: #d35400; }
.task-item .btn-cancel {
background: #e67e22;
color: #fff;
}
.task-item .btn-cancel:hover {
background: #d35400;
}
.task-item .btn-delete {
background: #444;
color: #ccc;
}
.task-item .btn-delete:hover {
background: #e74c3c;
color: #fff;
}
.task-item .task-right {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.run-row .progress-wrap {
margin-top: 10px;
width: 100%;
max-width: 280px;
}
.run-row .progress-bar-bg {
height: 8px;
background: #2a2a2a;
border-radius: 4px;
overflow: hidden;
}
.run-row .progress-bar-fill {
height: 100%;
background: #3498db;
border-radius: 4px;
transition: width 0.2s;
}
.run-row .btn-cancel-run {
margin-left: 12px;
padding: 8px 16px;
background: #e67e22;
color: #fff;
border: none;
border-radius: 6px;
font-size: 13px;
cursor: pointer;
}
.run-row .btn-cancel-run:hover {
background: #d35400;
}
.task-item .download {
padding: 6px 14px;
background: #3498db;
@@ -314,15 +551,29 @@
white-space: nowrap;
transition: all 0.2s;
}
.task-item .download:hover { background: #2980b9; color: #fff; }
.task-item .download.hide { display: none; }
.empty-tasks { text-align: center; color: #666; padding: 32px; font-size: 13px; }
.task-item .download:hover {
background: #2980b9;
color: #fff;
}
.task-item .download.hide {
display: none;
}
.empty-tasks {
text-align: center;
color: #666;
padding: 32px;
font-size: 13px;
}
.toast {
position: fixed;
bottom: 32px;
left: 50%;
transform: translateX(-50%);
background: rgba(0,0,0,0.85);
background: rgba(0, 0, 0, 0.85);
color: #fff;
padding: 12px 24px;
border-radius: 8px;
@@ -332,9 +583,13 @@
transition: opacity 0.3s;
border: 1px solid #333;
}
.toast.show { opacity: 1; }
.toast.show {
opacity: 1;
}
</style>
</head>
<body>
<header class="top-bar">
<div class="logo-area">
@@ -344,7 +599,12 @@
<nav class="nav-tabs">
<span class="nav-tab-group">
<button type="button" class="nav-tab active" data-panel="brandCheck">品牌检测</button>
<!-- 后续增加栏目时在此添加,例如:<button type="button" class="nav-tab" data-panel="other">其他栏目</button> -->
<button type="button" class="nav-tab"
onclick="window.location='/new_web_source/dedupe.html'">总数据去重</button>
<button type="button" class="nav-tab"
onclick="window.location='/new_web_source/convert.html'">格式转换</button>
<button type="button" class="nav-tab"
onclick="window.location='/new_web_source/split.html'">表格拆分</button>
</span>
<!-- 多组栏目时可用分隔符:<span class="nav-tab-sep" aria-hidden="true"></span> -->
</nav>
@@ -404,23 +664,33 @@
<button type="button" class="btn-run" id="btnRun">立即运行</button>
<span class="loading-msg" id="loadingMsg" style="display:none;">生成中,请稍候…</span>
<div class="progress-wrap" id="runProgressWrap" style="display:none;">
<div class="progress-bar-bg"><div class="progress-bar-fill" id="runProgressFill" style="width:0%;"></div></div>
<div class="progress-bar-bg">
<div class="progress-bar-fill" id="runProgressFill" style="width:0%;"></div>
</div>
<span class="hint" style="font-size:12px;color:#888;" id="runProgressText">0 / 0</span>
</div>
<!-- 当前文件行级进度(不经数据库中转,只读内存接口) -->
<div class="progress-wrap" id="runLineProgressWrap" style="display:none;">
<div class="progress-bar-bg"><div class="progress-bar-fill" id="runLineProgressFill" style="width:0%;"></div></div>
<div class="progress-bar-bg">
<div class="progress-bar-fill" id="runLineProgressFill" style="width:0%;"></div>
</div>
<span class="hint" style="font-size:12px;color:#888;" id="runLineProgressText">0 / 0</span>
</div>
<button type="button" class="btn-cancel-run" id="btnCancelRun" style="display:none;">取消生成</button>
<button type="button" class="btn-cancel-run" id="btnCancelRun"
style="display:none;">取消生成</button>
</div>
</div>
<div class="template-download-row" id="templateDownloadRow" role="button" tabindex="0" title="下载品牌文档格式模板(选择保存位置)">
<div class="template-download-row" id="templateDownloadRow" role="button" tabindex="0"
title="下载品牌文档格式模板(选择保存位置)">
<span class="template-download-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8 13h8M8 17h5" stroke="rgba(255,255,255,0.85)" stroke-width="1.5" stroke-linecap="round"/>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"
stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M8 13h8M8 17h5" stroke="rgba(255,255,255,0.85)" stroke-width="1.5"
stroke-linecap="round" />
</svg>
</span>
<span class="template-download-text">
@@ -428,12 +698,17 @@
<span class="hint">品牌文档格式_模板.xlsx · 点击选择保存位置</span>
</span>
</div>
<div class="template-download-row" id="templateDownloadRow2" role="button" tabindex="0" title="下载模板2以文件夹方式上传">
<div class="template-download-row" id="templateDownloadRow2" role="button" tabindex="0"
title="下载模板2以文件夹方式上传">
<span class="template-download-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3 7v10h4v-4h2v4h8v-4h2v4h2V7H3z" stroke="rgba(255,255,255,0.85)" stroke-width="1.5" stroke-linecap="round"/>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"
stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M3 7v10h4v-4h2v4h8v-4h2v4h2V7H3z" stroke="rgba(255,255,255,0.85)"
stroke-width="1.5" stroke-linecap="round" />
</svg>
</span>
<span class="template-download-text">
@@ -459,18 +734,18 @@
<div class="toast" id="toast"></div>
<script>
(function() {
(function () {
var selectedPaths = [];
var cachedTasks = [];
var api = window.pywebview && window.pywebview.api;
// 顶部栏目切换:点击 nav-tab 时显示对应 data-panel 的 tab-panel
document.querySelectorAll('.nav-tab').forEach(function(tab) {
tab.addEventListener('click', function() {
document.querySelectorAll('.nav-tab').forEach(function (tab) {
tab.addEventListener('click', function () {
var panelId = this.getAttribute('data-panel');
if (!panelId) return;
document.querySelectorAll('.nav-tab').forEach(function(t) { t.classList.remove('active'); });
document.querySelectorAll('.tab-panel').forEach(function(p) {
document.querySelectorAll('.nav-tab').forEach(function (t) { t.classList.remove('active'); });
document.querySelectorAll('.tab-panel').forEach(function (p) {
p.classList.toggle('active', p.getAttribute('data-panel') === panelId);
});
this.classList.add('active');
@@ -481,7 +756,7 @@
var el = document.getElementById('toast');
el.textContent = msg;
el.classList.add('show');
setTimeout(function() { el.classList.remove('show'); }, 2500);
setTimeout(function () { el.classList.remove('show'); }, 2500);
}
function renderSelected() {
@@ -491,14 +766,14 @@
return;
}
el.innerHTML = '已选 <b>' + selectedPaths.length + '</b> 个文件:<br>' +
selectedPaths.slice(0, 20).map(function(p) {
selectedPaths.slice(0, 20).map(function (p) {
var name = p.split(/[/\\]/).pop();
return '<span title="' + p + '">' + name + '</span>';
}).join('') +
(selectedPaths.length > 20 ? '<span>… 等 ' + selectedPaths.length + ' 个</span>' : '');
}
document.getElementById('btnSelectFiles').onclick = async function(e) {
document.getElementById('btnSelectFiles').onclick = async function (e) {
e.stopPropagation();
if (!api || !api.select_brand_xlsx_files) {
showToast('当前环境不支持文件选择,请在本机客户端中打开');
@@ -516,7 +791,7 @@
}
};
document.getElementById('templateDownloadRow').onclick = async function(e) {
document.getElementById('templateDownloadRow').onclick = async function (e) {
e.preventDefault();
if (api && api.save_template_xlsx) {
try {
@@ -533,11 +808,11 @@
}
window.location.href = '/static/品牌文档格式_模板.xlsx';
};
document.getElementById('templateDownloadRow').onkeydown = function(e) {
document.getElementById('templateDownloadRow').onkeydown = function (e) {
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); this.click(); }
};
document.getElementById('templateDownloadRow2').onclick = async function(e) {
document.getElementById('templateDownloadRow2').onclick = async function (e) {
e.preventDefault();
if (api && api.save_template_zip) {
try {
@@ -554,11 +829,11 @@
}
window.location.href = '/static/模板2-以文件夹方式上传.zip';
};
document.getElementById('templateDownloadRow2').onkeydown = function(e) {
document.getElementById('templateDownloadRow2').onkeydown = function (e) {
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); this.click(); }
};
document.getElementById('btnSelectFolder').onclick =async function(e) {
document.getElementById('btnSelectFolder').onclick = async function (e) {
e.stopPropagation();
if (!api || !api.select_brand_folder) {
showToast('当前环境不支持文件夹选择,请在本机客户端中打开');
@@ -573,8 +848,8 @@
credentials: 'same-origin',
body: JSON.stringify({ folder: folder })
})
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success && res.paths && res.paths.length) {
selectedPaths = res.paths;
renderSelected();
@@ -583,7 +858,7 @@
showToast(res.error || '该文件夹下没有 xlsx 文件');
}
})
.catch(function() { showToast('请求失败'); });
.catch(function () { showToast('请求失败'); });
} catch (err) {
showToast('选择失败:' + (err.message || err));
}
@@ -641,10 +916,10 @@
var runProgressWrap = document.getElementById('runProgressWrap');
runProgressWrap.style.display = 'block';
btnCancelRun.style.display = 'inline-block';
btnCancelRun.onclick = function() {
btnCancelRun.onclick = function () {
fetch('/api/brand/tasks/' + taskId + '/cancel', { method: 'POST', credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success) onRunTaskFinished('cancelled');
else showToast(res.error || '取消失败');
});
@@ -653,7 +928,7 @@
// 通过 SSE 订阅任务完成事件,完成后由后端主动推送,前端收到后立即隐藏进度条和取消按钮
var eventsUrl = '/api/brand/tasks/' + taskId + '/events';
runTaskEventSource = new EventSource(eventsUrl);
runTaskEventSource.onmessage = function(e) {
runTaskEventSource.onmessage = function (e) {
try {
var data = JSON.parse(e.data);
if (data && (data.status === 'success' || data.status === 'failed' || data.status === 'cancelled')) {
@@ -662,9 +937,9 @@
// tick();
onRunTaskFinished(data.status);
}
} catch (err) {}
} catch (err) { }
};
runTaskEventSource.onerror = function() {
runTaskEventSource.onerror = function () {
runTaskEventSource.close();
runTaskEventSource = null;
};
@@ -672,8 +947,8 @@
function tick() {
if (!pollTaskId) return;
fetch('/api/brand/tasks/' + taskId, { credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (!res.success || !res.task) return;
var t = res.task;
var total = t.progress_total || 0;
@@ -701,8 +976,8 @@
credentials: 'same-origin',
headers: { 'X-Requested-With': 'XMLHttpRequest' }
})
.then(function(r) { return r.json(); })
.then(function(res2) {
.then(function (r) { return r.json(); })
.then(function (res2) {
if (!res2.success || !res2.has_progress || !res2.info) {
runLineProgressWrap.style.display = 'none';
return;
@@ -714,7 +989,7 @@
runLineProgressFill.style.width = totalLines ? (100 * curLine / totalLines) + '%' : '0%';
runLineProgressText.textContent = totalLines ? (curLine + ' / ' + totalLines) : '当前文件处理中…';
})
.catch(function() {});
.catch(function () { });
} else {
runLineProgressWrap.style.display = 'none';
}
@@ -730,7 +1005,7 @@
pollTimer = setInterval(tick, 5000);
}
document.getElementById('btnRun').onclick = function() {
document.getElementById('btnRun').onclick = function () {
if (selectedPaths.length === 0) {
showToast('请先选择 Excel 文件或文件夹');
return;
@@ -749,8 +1024,8 @@
credentials: 'same-origin',
body: JSON.stringify({ paths: selectedPaths, strategy: strategy, task_type: 1 })
})
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success && res.task_id) {
loadingMsg.style.display = 'none';
pollRunTask(res.task_id);
@@ -759,7 +1034,7 @@
showToast(res.error || '运行失败');
}
})
.catch(function() {
.catch(function () {
stopPollAndResetRunUI();
showToast('请求失败或超时');
});
@@ -770,8 +1045,8 @@
credentials: 'same-origin',
body: JSON.stringify({ paths: selectedPaths, strategy: strategy, task_type: 2 })
})
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success) {
showToast('任务已添加,请在任务队列查看');
loadTasks();
@@ -779,14 +1054,14 @@
showToast(res.error || '添加失败');
}
})
.catch(function() { showToast('请求失败'); });
.catch(function () { showToast('请求失败'); });
}
};
function loadTasks() {
fetch('/api/brand/tasks', { credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
var list = document.getElementById('taskList');
var empty = document.getElementById('emptyTasks');
if (!res.success || !res.items || res.items.length === 0) {
@@ -796,7 +1071,7 @@
}
empty.style.display = 'none';
cachedTasks = res.items;
list.innerHTML = res.items.map(function(t) {
list.innerHTML = res.items.map(function (t) {
var statusClass = (t.status || 'pending').toLowerCase();
var statusText = { pending: '等待中', running: '执行中', success: '已完成', failed: '失败', cancelled: '已取消' }[t.status] || t.status;
var filesDesc = (t.file_paths && t.file_paths.length) ? t.file_paths.length + ' 个文件' : '';
@@ -831,7 +1106,7 @@
'</div></li>';
}).join('');
})
.catch(function() {});
.catch(function () { });
}
// 手动刷新任务状态按钮
@@ -843,7 +1118,7 @@
};
}
document.getElementById('taskList').addEventListener('click', function(e) {
document.getElementById('taskList').addEventListener('click', function (e) {
var target = e.target && e.target.closest && (e.target.closest('a.js-save-zip') || e.target.closest('button.js-cancel-task') || e.target.closest('button.js-delete-task'));
if (!target) return;
e.preventDefault();
@@ -852,8 +1127,8 @@
var btn = target.classList.contains('js-cancel-task') ? target : target.closest('.js-cancel-task');
if (!btn) return;
fetch('/api/brand/tasks/' + taskId + '/cancel', { method: 'POST', credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success) { showToast('已取消'); loadTasks(); } else { showToast(res.error || '取消失败'); }
});
return;
@@ -862,15 +1137,15 @@
var btn = target.classList.contains('js-delete-task') ? target : target.closest('.js-delete-task');
if (!btn) return;
fetch('/api/brand/tasks/' + taskId, { method: 'DELETE', credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success) { showToast('已删除'); loadTasks(); } else { showToast(res.error || '删除失败'); }
});
return;
}
var a = target.closest('a.js-save-zip') || target;
if (!a || !a.classList || !a.classList.contains('js-save-zip')) return;
var task = cachedTasks.filter(function(t) { return String(t.id) === String(taskId); })[0];
var task = cachedTasks.filter(function (t) { return String(t.id) === String(taskId); })[0];
if (!task || !task.result_paths || !task.result_paths.zip_url) {
showToast('无法获取下载地址');
return;
@@ -879,7 +1154,7 @@
var filename = 'brand_task_' + taskId + '.zip';
if (api && api.save_file_from_url) {
a.style.pointerEvents = 'none';
var done = function(ret) {
var done = function (ret) {
if (ret && ret.success) {
showToast('已保存:' + (ret.path || filename));
} else if (ret && ret.error && ret.error !== '用户取消') {
@@ -890,7 +1165,7 @@
try {
var ret = api.save_file_from_url(zipUrl, filename);
if (ret && typeof ret.then === 'function') {
ret.then(done).catch(function(err) { showToast('保存失败:' + (err && err.message || err)); a.style.pointerEvents = ''; });
ret.then(done).catch(function (err) { showToast('保存失败:' + (err && err.message || err)); a.style.pointerEvents = ''; });
} else {
done(ret);
}
@@ -907,12 +1182,13 @@
// setInterval(loadTasks, 10000);
if (window.addEventListener) {
window.addEventListener('pywebviewready', function() {
window.addEventListener('pywebviewready', function () {
api = window.pywebview && window.pywebview.api;
});
}
if (window.pywebview && window.pywebview.api) api = window.pywebview.api;
})();
})();
</script>
</body>
</html>

View File

@@ -1,11 +1,17 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>亚马逊 - 南日AI</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Microsoft YaHei", "Noto Serif SC", "SimSun", "Songti SC", "Times New Roman", serif;
background: rgba(13, 13, 13, 1);
@@ -14,6 +20,7 @@
height: 100vh;
font-weight: bold;
}
.top-bar {
height: 56px;
display: flex;
@@ -22,12 +29,19 @@
padding: 0 16px;
border-bottom: 1px solid #2a2a2a;
}
.logo-area {
display: flex;
align-items: center;
gap: 10px;
}
.top-bar .app-name { font-size: 18px; font-weight: 600; color: #fff; }
.top-bar .app-name {
font-size: 18px;
font-weight: 600;
color: #fff;
}
.btn-home {
font-size: 13px;
color: #999;
@@ -36,7 +50,11 @@
border-radius: 6px;
transition: all 0.2s;
}
.btn-home:hover { color: #fff; background: #2a2a2a; }
.btn-home:hover {
color: #fff;
background: #2a2a2a;
}
/* 顶部栏目导航(容器化,便于后续增加栏目) */
.nav-tabs {
@@ -44,6 +62,7 @@
align-items: center;
gap: 0;
}
.nav-tab-group {
display: flex;
align-items: center;
@@ -51,6 +70,7 @@
background: rgba(77, 72, 72, 0.99);
border-radius: 10px;
}
.nav-tab-sep {
width: 1px;
height: 20px;
@@ -59,6 +79,7 @@
flex-shrink: 0;
opacity: 0.9;
}
.nav-tab {
padding: 8px 14px;
font-size: 13px;
@@ -69,14 +90,17 @@
cursor: pointer;
transition: all 0.2s;
}
.nav-tab:hover {
color: #fff;
background: #2a2a2a;
}
.nav-tab.active {
color: #3498db;
background: rgba(52, 152, 219, 0.2);
}
.top-right {
display: flex;
align-items: center;
@@ -87,6 +111,7 @@
display: flex;
height: calc(100vh - 56px);
}
/* 栏目内容容器:每个栏目一个 .tab-panel通过 data-panel 与导航对应 */
.tab-panel {
display: none;
@@ -94,9 +119,11 @@
min-width: 0;
min-height: 0;
}
.tab-panel.active {
display: flex;
}
.left-panel {
width: 380px;
background: #1e1e1e;
@@ -104,6 +131,7 @@
overflow-y: auto;
border-right: 1px solid #2a2a2a;
}
.right-panel {
flex: 1;
display: flex;
@@ -111,11 +139,13 @@
min-width: 0;
background: #1a1a1a;
}
.section-title {
font-size: 13px;
color: #bbb;
margin-bottom: 10px;
}
.upload-zone {
border: 1px dashed #3a3a3a;
border-radius: 10px;
@@ -125,9 +155,25 @@
margin-bottom: 20px;
transition: all 0.2s;
}
.upload-zone:hover { border-color: #3498db; background: #2a2a2a; }
.upload-zone .hint { color: #888; font-size: 13px; margin-bottom: 12px; }
.upload-zone .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.upload-zone:hover {
border-color: #3498db;
background: #2a2a2a;
}
.upload-zone .hint {
color: #888;
font-size: 13px;
margin-bottom: 12px;
}
.upload-zone .btns {
display: flex;
gap: 10px;
justify-content: center;
flex-wrap: wrap;
}
.opt-btn {
padding: 8px 16px;
font-size: 13px;
@@ -138,7 +184,14 @@
cursor: pointer;
transition: all 0.2s;
}
.opt-btn:hover { color: #fff; background: #333; border-color: #3498db; color: #3498db; }
.opt-btn:hover {
color: #fff;
background: #333;
border-color: #3498db;
color: #3498db;
}
.selected-files {
margin-top: 12px;
font-size: 12px;
@@ -146,8 +199,17 @@
max-height: 72px;
overflow-y: auto;
}
.selected-files span { display: block; margin: 4px 0; word-break: break-all; }
.option-group { margin-bottom: 20px; }
.selected-files span {
display: block;
margin: 4px 0;
word-break: break-all;
}
.option-group {
margin-bottom: 20px;
}
.radio-item {
display: flex;
align-items: flex-start;
@@ -159,16 +221,35 @@
border: 1px solid #2a2a2a;
margin-bottom: 8px;
}
.radio-item:hover { background: #2a2a2a; }
.radio-item input { margin-top: 3px; }
.radio-item .label { font-weight: 500; color: #e0e0e0; font-size: 13px; }
.radio-item .desc { font-size: 12px; color: #888; margin-top: 2px; font-weight: normal; }
.radio-item:hover {
background: #2a2a2a;
}
.radio-item input {
margin-top: 3px;
}
.radio-item .label {
font-weight: 500;
color: #e0e0e0;
font-size: 13px;
}
.radio-item .desc {
font-size: 12px;
color: #888;
margin-top: 2px;
font-weight: normal;
}
.run-row {
display: flex;
align-items: center;
gap: 12px;
margin-top: 16px;
}
.btn-run {
padding: 10px 22px;
background: #3498db;
@@ -179,9 +260,21 @@
cursor: pointer;
transition: all 0.2s;
}
.btn-run:hover { background: #2980b9; }
.btn-run:disabled { background: #555; cursor: not-allowed; color: #999; }
.loading-msg { color: #3498db; font-size: 13px; }
.btn-run:hover {
background: #2980b9;
}
.btn-run:disabled {
background: #555;
cursor: not-allowed;
color: #999;
}
.loading-msg {
color: #3498db;
font-size: 13px;
}
.template-download-row {
margin-top: 16px;
@@ -195,16 +288,22 @@
transition: all 0.25s ease;
cursor: pointer;
}
.template-download-row:hover {
border-color: #2e7d32;
background: linear-gradient(135deg, #2a2a2a 0%, #243324 100%);
box-shadow: 0 4px 12px rgba(46, 125, 50, 0.15);
}
.template-download-row:hover .template-download-text .title { color: #2ecc71; }
.template-download-row:hover .template-download-text .title {
color: #2ecc71;
}
.template-download-row:hover .template-download-icon {
transform: scale(1.05);
box-shadow: 0 6px 16px rgba(46, 125, 50, 0.45), inset 0 1px 0 rgba(255,255,255,0.15);
box-shadow: 0 6px 16px rgba(46, 125, 50, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.template-download-icon {
width: 48px;
height: 48px;
@@ -214,15 +313,28 @@
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 12px rgba(46, 125, 50, 0.35), inset 0 1px 0 rgba(255,255,255,0.1);
box-shadow: 0 4px 12px rgba(46, 125, 50, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
transition: transform 0.2s, box-shadow 0.2s;
}
.template-download-icon svg {
width: 28px;
height: 28px;
}
.template-download-text .title { font-size: 14px; color: #e0e0e0; font-weight: 600; display: block; }
.template-download-text .hint { font-size: 12px; color: #888; margin-top: 2px; font-weight: normal; }
.template-download-text .title {
font-size: 14px;
color: #e0e0e0;
font-weight: 600;
display: block;
}
.template-download-text .hint {
font-size: 12px;
color: #888;
margin-top: 2px;
font-weight: normal;
}
.panel-header {
padding: 16px 20px;
@@ -235,9 +347,11 @@
justify-content: space-between;
gap: 12px;
}
.panel-header-title {
flex: 1;
}
.btn-refresh-tasks {
padding: 6px 14px;
font-size: 12px;
@@ -249,17 +363,23 @@
transition: all 0.2s;
white-space: nowrap;
}
.btn-refresh-tasks:hover {
background: #333;
border-color: #3498db;
color: #3498db;
}
.task-list-wrap {
flex: 1;
overflow-y: auto;
padding: 16px;
}
.task-list { list-style: none; }
.task-list {
list-style: none;
}
.task-item {
display: flex;
align-items: center;
@@ -270,38 +390,155 @@
margin-bottom: 10px;
background: #1e1e1e;
}
.task-item .left { flex: 1; min-width: 0; }
.task-item .id { font-weight: 600; color: #e0e0e0; font-size: 13px; }
.task-item .files { font-size: 12px; color: #888; margin-top: 4px; }
.task-item .time { font-size: 12px; color: #666; margin-top: 2px; }
.task-item .left {
flex: 1;
min-width: 0;
}
.task-item .id {
font-weight: 600;
color: #e0e0e0;
font-size: 13px;
}
.task-item .files {
font-size: 12px;
color: #888;
margin-top: 4px;
}
.task-item .time {
font-size: 12px;
color: #666;
margin-top: 2px;
}
.task-item .status {
padding: 4px 10px;
border-radius: 6px;
font-size: 12px;
margin-right: 12px;
}
.task-item .status.pending { background: rgba(255,193,7,0.2); color: #d4a500; }
.task-item .status.running { background: rgba(52,152,219,0.2); color: #3498db; }
.task-item .status.success { background: rgba(46,204,113,0.2); color: #2ecc71; }
.task-item .status.failed { background: rgba(231,76,60,0.2); color: #e74c3c; }
.task-item .status.cancelled { background: rgba(149,165,166,0.2); color: #95a5a6; }
.task-item .progress-wrap { margin-top: 8px; margin-right: 8px; flex-shrink: 0; width: 120px; }
.task-item .progress-bar-bg { height: 6px; background: #2a2a2a; border-radius: 3px; overflow: hidden; }
.task-item .progress-bar-fill { height: 100%; background: #3498db; border-radius: 3px; transition: width 0.2s; }
.task-item .btn-cancel, .task-item .btn-delete {
padding: 6px 12px; font-size: 12px; border-radius: 6px; cursor: pointer; border: none; margin-left: 6px;
.task-item .status.pending {
background: rgba(255, 193, 7, 0.2);
color: #d4a500;
}
.task-item .status.running {
background: rgba(52, 152, 219, 0.2);
color: #3498db;
}
.task-item .status.success {
background: rgba(46, 204, 113, 0.2);
color: #2ecc71;
}
.task-item .status.failed {
background: rgba(231, 76, 60, 0.2);
color: #e74c3c;
}
.task-item .status.cancelled {
background: rgba(149, 165, 166, 0.2);
color: #95a5a6;
}
.task-item .progress-wrap {
margin-top: 8px;
margin-right: 8px;
flex-shrink: 0;
width: 120px;
}
.task-item .progress-bar-bg {
height: 6px;
background: #2a2a2a;
border-radius: 3px;
overflow: hidden;
}
.task-item .progress-bar-fill {
height: 100%;
background: #3498db;
border-radius: 3px;
transition: width 0.2s;
}
.task-item .btn-cancel,
.task-item .btn-delete {
padding: 6px 12px;
font-size: 12px;
border-radius: 6px;
cursor: pointer;
border: none;
margin-left: 6px;
transition: all 0.2s;
}
.task-item .btn-cancel { background: #e67e22; color: #fff; }
.task-item .btn-cancel:hover { background: #d35400; }
.task-item .btn-delete { background: #444; color: #ccc; }
.task-item .btn-delete:hover { background: #e74c3c; color: #fff; }
.task-item .task-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.run-row .progress-wrap { margin-top: 10px; width: 100%; max-width: 280px; }
.run-row .progress-bar-bg { height: 8px; background: #2a2a2a; border-radius: 4px; overflow: hidden; }
.run-row .progress-bar-fill { height: 100%; background: #3498db; border-radius: 4px; transition: width 0.2s; }
.run-row .btn-cancel-run { margin-left: 12px; padding: 8px 16px; background: #e67e22; color: #fff; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; }
.run-row .btn-cancel-run:hover { background: #d35400; }
.task-item .btn-cancel {
background: #e67e22;
color: #fff;
}
.task-item .btn-cancel:hover {
background: #d35400;
}
.task-item .btn-delete {
background: #444;
color: #ccc;
}
.task-item .btn-delete:hover {
background: #e74c3c;
color: #fff;
}
.task-item .task-right {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.run-row .progress-wrap {
margin-top: 10px;
width: 100%;
max-width: 280px;
}
.run-row .progress-bar-bg {
height: 8px;
background: #2a2a2a;
border-radius: 4px;
overflow: hidden;
}
.run-row .progress-bar-fill {
height: 100%;
background: #3498db;
border-radius: 4px;
transition: width 0.2s;
}
.run-row .btn-cancel-run {
margin-left: 12px;
padding: 8px 16px;
background: #e67e22;
color: #fff;
border: none;
border-radius: 6px;
font-size: 13px;
cursor: pointer;
}
.run-row .btn-cancel-run:hover {
background: #d35400;
}
.task-item .download {
padding: 6px 14px;
background: #3498db;
@@ -314,15 +551,29 @@
white-space: nowrap;
transition: all 0.2s;
}
.task-item .download:hover { background: #2980b9; color: #fff; }
.task-item .download.hide { display: none; }
.empty-tasks { text-align: center; color: #666; padding: 32px; font-size: 13px; }
.task-item .download:hover {
background: #2980b9;
color: #fff;
}
.task-item .download.hide {
display: none;
}
.empty-tasks {
text-align: center;
color: #666;
padding: 32px;
font-size: 13px;
}
.toast {
position: fixed;
bottom: 32px;
left: 50%;
transform: translateX(-50%);
background: rgba(0,0,0,0.85);
background: rgba(0, 0, 0, 0.85);
color: #fff;
padding: 12px 24px;
border-radius: 8px;
@@ -332,9 +583,13 @@
transition: opacity 0.3s;
border: 1px solid #333;
}
.toast.show { opacity: 1; }
.toast.show {
opacity: 1;
}
</style>
</head>
<body>
<header class="top-bar">
<div class="logo-area">
@@ -344,7 +599,12 @@
<nav class="nav-tabs">
<span class="nav-tab-group">
<button type="button" class="nav-tab active" data-panel="brandCheck">品牌检测</button>
<!-- 后续增加栏目时在此添加,例如:<button type="button" class="nav-tab" data-panel="other">其他栏目</button> -->
<button type="button" class="nav-tab"
onclick="window.location='/new_web_source/dedupe.html'">总数据去重</button>
<button type="button" class="nav-tab"
onclick="window.location='/new_web_source/convert.html'">格式转换</button>
<button type="button" class="nav-tab"
onclick="window.location='/new_web_source/split.html'">表格拆分</button>
</span>
<!-- 多组栏目时可用分隔符:<span class="nav-tab-sep" aria-hidden="true"></span> -->
</nav>
@@ -404,23 +664,33 @@
<button type="button" class="btn-run" id="btnRun">立即运行</button>
<span class="loading-msg" id="loadingMsg" style="display:none;">生成中,请稍候…</span>
<div class="progress-wrap" id="runProgressWrap" style="display:none;">
<div class="progress-bar-bg"><div class="progress-bar-fill" id="runProgressFill" style="width:0%;"></div></div>
<div class="progress-bar-bg">
<div class="progress-bar-fill" id="runProgressFill" style="width:0%;"></div>
</div>
<span class="hint" style="font-size:12px;color:#888;" id="runProgressText">0 / 0</span>
</div>
<!-- 当前文件行级进度(不经数据库中转,只读内存接口) -->
<div class="progress-wrap" id="runLineProgressWrap" style="display:none;">
<div class="progress-bar-bg"><div class="progress-bar-fill" id="runLineProgressFill" style="width:0%;"></div></div>
<div class="progress-bar-bg">
<div class="progress-bar-fill" id="runLineProgressFill" style="width:0%;"></div>
</div>
<span class="hint" style="font-size:12px;color:#888;" id="runLineProgressText">0 / 0</span>
</div>
<button type="button" class="btn-cancel-run" id="btnCancelRun" style="display:none;">取消生成</button>
<button type="button" class="btn-cancel-run" id="btnCancelRun"
style="display:none;">取消生成</button>
</div>
</div>
<div class="template-download-row" id="templateDownloadRow" role="button" tabindex="0" title="下载品牌文档格式模板(选择保存位置)">
<div class="template-download-row" id="templateDownloadRow" role="button" tabindex="0"
title="下载品牌文档格式模板(选择保存位置)">
<span class="template-download-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8 13h8M8 17h5" stroke="rgba(255,255,255,0.85)" stroke-width="1.5" stroke-linecap="round"/>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"
stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M8 13h8M8 17h5" stroke="rgba(255,255,255,0.85)" stroke-width="1.5"
stroke-linecap="round" />
</svg>
</span>
<span class="template-download-text">
@@ -428,12 +698,17 @@
<span class="hint">品牌文档格式_模板.xlsx · 点击选择保存位置</span>
</span>
</div>
<div class="template-download-row" id="templateDownloadRow2" role="button" tabindex="0" title="下载模板2以文件夹方式上传">
<div class="template-download-row" id="templateDownloadRow2" role="button" tabindex="0"
title="下载模板2以文件夹方式上传">
<span class="template-download-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3 7v10h4v-4h2v4h8v-4h2v4h2V7H3z" stroke="rgba(255,255,255,0.85)" stroke-width="1.5" stroke-linecap="round"/>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"
stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.9)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M3 7v10h4v-4h2v4h8v-4h2v4h2V7H3z" stroke="rgba(255,255,255,0.85)"
stroke-width="1.5" stroke-linecap="round" />
</svg>
</span>
<span class="template-download-text">
@@ -459,18 +734,18 @@
<div class="toast" id="toast"></div>
<script>
(function() {
(function () {
var selectedPaths = [];
var cachedTasks = [];
var api = window.pywebview && window.pywebview.api;
// 顶部栏目切换:点击 nav-tab 时显示对应 data-panel 的 tab-panel
document.querySelectorAll('.nav-tab').forEach(function(tab) {
tab.addEventListener('click', function() {
document.querySelectorAll('.nav-tab').forEach(function (tab) {
tab.addEventListener('click', function () {
var panelId = this.getAttribute('data-panel');
if (!panelId) return;
document.querySelectorAll('.nav-tab').forEach(function(t) { t.classList.remove('active'); });
document.querySelectorAll('.tab-panel').forEach(function(p) {
document.querySelectorAll('.nav-tab').forEach(function (t) { t.classList.remove('active'); });
document.querySelectorAll('.tab-panel').forEach(function (p) {
p.classList.toggle('active', p.getAttribute('data-panel') === panelId);
});
this.classList.add('active');
@@ -481,7 +756,7 @@
var el = document.getElementById('toast');
el.textContent = msg;
el.classList.add('show');
setTimeout(function() { el.classList.remove('show'); }, 2500);
setTimeout(function () { el.classList.remove('show'); }, 2500);
}
function renderSelected() {
@@ -491,14 +766,14 @@
return;
}
el.innerHTML = '已选 <b>' + selectedPaths.length + '</b> 个文件:<br>' +
selectedPaths.slice(0, 20).map(function(p) {
selectedPaths.slice(0, 20).map(function (p) {
var name = p.split(/[/\\]/).pop();
return '<span title="' + p + '">' + name + '</span>';
}).join('') +
(selectedPaths.length > 20 ? '<span>… 等 ' + selectedPaths.length + ' 个</span>' : '');
}
document.getElementById('btnSelectFiles').onclick = async function(e) {
document.getElementById('btnSelectFiles').onclick = async function (e) {
e.stopPropagation();
if (!api || !api.select_brand_xlsx_files) {
showToast('当前环境不支持文件选择,请在本机客户端中打开');
@@ -516,7 +791,7 @@
}
};
document.getElementById('templateDownloadRow').onclick = async function(e) {
document.getElementById('templateDownloadRow').onclick = async function (e) {
e.preventDefault();
if (api && api.save_template_xlsx) {
try {
@@ -533,11 +808,11 @@
}
window.location.href = '/static/品牌文档格式_模板.xlsx';
};
document.getElementById('templateDownloadRow').onkeydown = function(e) {
document.getElementById('templateDownloadRow').onkeydown = function (e) {
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); this.click(); }
};
document.getElementById('templateDownloadRow2').onclick = async function(e) {
document.getElementById('templateDownloadRow2').onclick = async function (e) {
e.preventDefault();
if (api && api.save_template_zip) {
try {
@@ -554,11 +829,11 @@
}
window.location.href = '/static/模板2-以文件夹方式上传.zip';
};
document.getElementById('templateDownloadRow2').onkeydown = function(e) {
document.getElementById('templateDownloadRow2').onkeydown = function (e) {
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); this.click(); }
};
document.getElementById('btnSelectFolder').onclick =async function(e) {
document.getElementById('btnSelectFolder').onclick = async function (e) {
e.stopPropagation();
if (!api || !api.select_brand_folder) {
showToast('当前环境不支持文件夹选择,请在本机客户端中打开');
@@ -573,8 +848,8 @@
credentials: 'same-origin',
body: JSON.stringify({ folder: folder })
})
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success && res.paths && res.paths.length) {
selectedPaths = res.paths;
renderSelected();
@@ -583,7 +858,7 @@
showToast(res.error || '该文件夹下没有 xlsx 文件');
}
})
.catch(function() { showToast('请求失败'); });
.catch(function () { showToast('请求失败'); });
} catch (err) {
showToast('选择失败:' + (err.message || err));
}
@@ -641,10 +916,10 @@
var runProgressWrap = document.getElementById('runProgressWrap');
runProgressWrap.style.display = 'block';
btnCancelRun.style.display = 'inline-block';
btnCancelRun.onclick = function() {
btnCancelRun.onclick = function () {
fetch('/api/brand/tasks/' + taskId + '/cancel', { method: 'POST', credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success) onRunTaskFinished('cancelled');
else showToast(res.error || '取消失败');
});
@@ -653,7 +928,7 @@
// 通过 SSE 订阅任务完成事件,完成后由后端主动推送,前端收到后立即隐藏进度条和取消按钮
var eventsUrl = '/api/brand/tasks/' + taskId + '/events';
runTaskEventSource = new EventSource(eventsUrl);
runTaskEventSource.onmessage = function(e) {
runTaskEventSource.onmessage = function (e) {
try {
var data = JSON.parse(e.data);
if (data && (data.status === 'success' || data.status === 'failed' || data.status === 'cancelled')) {
@@ -662,9 +937,9 @@
// tick();
onRunTaskFinished(data.status);
}
} catch (err) {}
} catch (err) { }
};
runTaskEventSource.onerror = function() {
runTaskEventSource.onerror = function () {
runTaskEventSource.close();
runTaskEventSource = null;
};
@@ -672,8 +947,8 @@
function tick() {
if (!pollTaskId) return;
fetch('/api/brand/tasks/' + taskId, { credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (!res.success || !res.task) return;
var t = res.task;
var total = t.progress_total || 0;
@@ -701,8 +976,8 @@
credentials: 'same-origin',
headers: { 'X-Requested-With': 'XMLHttpRequest' }
})
.then(function(r) { return r.json(); })
.then(function(res2) {
.then(function (r) { return r.json(); })
.then(function (res2) {
if (!res2.success || !res2.has_progress || !res2.info) {
runLineProgressWrap.style.display = 'none';
return;
@@ -714,7 +989,7 @@
runLineProgressFill.style.width = totalLines ? (100 * curLine / totalLines) + '%' : '0%';
runLineProgressText.textContent = totalLines ? (curLine + ' / ' + totalLines) : '当前文件处理中…';
})
.catch(function() {});
.catch(function () { });
} else {
runLineProgressWrap.style.display = 'none';
}
@@ -730,7 +1005,7 @@
pollTimer = setInterval(tick, 5000);
}
document.getElementById('btnRun').onclick = function() {
document.getElementById('btnRun').onclick = function () {
if (selectedPaths.length === 0) {
showToast('请先选择 Excel 文件或文件夹');
return;
@@ -749,8 +1024,8 @@
credentials: 'same-origin',
body: JSON.stringify({ paths: selectedPaths, strategy: strategy, task_type: 1 })
})
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success && res.task_id) {
loadingMsg.style.display = 'none';
pollRunTask(res.task_id);
@@ -759,7 +1034,7 @@
showToast(res.error || '运行失败');
}
})
.catch(function() {
.catch(function () {
stopPollAndResetRunUI();
showToast('请求失败或超时');
});
@@ -770,8 +1045,8 @@
credentials: 'same-origin',
body: JSON.stringify({ paths: selectedPaths, strategy: strategy, task_type: 2 })
})
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success) {
showToast('任务已添加,请在任务队列查看');
loadTasks();
@@ -779,14 +1054,14 @@
showToast(res.error || '添加失败');
}
})
.catch(function() { showToast('请求失败'); });
.catch(function () { showToast('请求失败'); });
}
};
function loadTasks() {
fetch('/api/brand/tasks', { credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
var list = document.getElementById('taskList');
var empty = document.getElementById('emptyTasks');
if (!res.success || !res.items || res.items.length === 0) {
@@ -796,7 +1071,7 @@
}
empty.style.display = 'none';
cachedTasks = res.items;
list.innerHTML = res.items.map(function(t) {
list.innerHTML = res.items.map(function (t) {
var statusClass = (t.status || 'pending').toLowerCase();
var statusText = { pending: '等待中', running: '执行中', success: '已完成', failed: '失败', cancelled: '已取消' }[t.status] || t.status;
var filesDesc = (t.file_paths && t.file_paths.length) ? t.file_paths.length + ' 个文件' : '';
@@ -831,7 +1106,7 @@
'</div></li>';
}).join('');
})
.catch(function() {});
.catch(function () { });
}
// 手动刷新任务状态按钮
@@ -843,7 +1118,7 @@
};
}
document.getElementById('taskList').addEventListener('click', function(e) {
document.getElementById('taskList').addEventListener('click', function (e) {
var target = e.target && e.target.closest && (e.target.closest('a.js-save-zip') || e.target.closest('button.js-cancel-task') || e.target.closest('button.js-delete-task'));
if (!target) return;
e.preventDefault();
@@ -852,8 +1127,8 @@
var btn = target.classList.contains('js-cancel-task') ? target : target.closest('.js-cancel-task');
if (!btn) return;
fetch('/api/brand/tasks/' + taskId + '/cancel', { method: 'POST', credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success) { showToast('已取消'); loadTasks(); } else { showToast(res.error || '取消失败'); }
});
return;
@@ -862,15 +1137,15 @@
var btn = target.classList.contains('js-delete-task') ? target : target.closest('.js-delete-task');
if (!btn) return;
fetch('/api/brand/tasks/' + taskId, { method: 'DELETE', credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } })
.then(function(r) { return r.json(); })
.then(function(res) {
.then(function (r) { return r.json(); })
.then(function (res) {
if (res.success) { showToast('已删除'); loadTasks(); } else { showToast(res.error || '删除失败'); }
});
return;
}
var a = target.closest('a.js-save-zip') || target;
if (!a || !a.classList || !a.classList.contains('js-save-zip')) return;
var task = cachedTasks.filter(function(t) { return String(t.id) === String(taskId); })[0];
var task = cachedTasks.filter(function (t) { return String(t.id) === String(taskId); })[0];
if (!task || !task.result_paths || !task.result_paths.zip_url) {
showToast('无法获取下载地址');
return;
@@ -879,7 +1154,7 @@
var filename = 'brand_task_' + taskId + '.zip';
if (api && api.save_file_from_url) {
a.style.pointerEvents = 'none';
var done = function(ret) {
var done = function (ret) {
if (ret && ret.success) {
showToast('已保存:' + (ret.path || filename));
} else if (ret && ret.error && ret.error !== '用户取消') {
@@ -890,7 +1165,7 @@
try {
var ret = api.save_file_from_url(zipUrl, filename);
if (ret && typeof ret.then === 'function') {
ret.then(done).catch(function(err) { showToast('保存失败:' + (err && err.message || err)); a.style.pointerEvents = ''; });
ret.then(done).catch(function (err) { showToast('保存失败:' + (err && err.message || err)); a.style.pointerEvents = ''; });
} else {
done(ret);
}
@@ -907,12 +1182,13 @@
// setInterval(loadTasks, 10000);
if (window.addEventListener) {
window.addEventListener('pywebviewready', function() {
window.addEventListener('pywebviewready', function () {
api = window.pywebview && window.pywebview.api;
});
}
if (window.pywebview && window.pywebview.api) api = window.pywebview.api;
})();
})();
</script>
</body>
</html>

View File

@@ -124,9 +124,8 @@ public class BrandTaskController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "任务不存在")
})
public ApiResponse<LegacyBrandTaskDetailVo> getTask(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
return ApiResponse.success(brandTaskService.getTaskDetailLegacy(taskId, userId));
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
return ApiResponse.success(brandTaskService.getTaskDetailLegacy(taskId));
}
@PostMapping("/tasks/{taskId}/result")
@@ -154,9 +153,8 @@ public class BrandTaskController {
})
public ApiResponse<BrandSimpleVo> submitResult(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId,
@Valid @RequestBody BrandCrawlResultRequest request) {
brandTaskService.submitCrawlResult(taskId, userId, request);
brandTaskService.submitCrawlResult(taskId, request);
return ApiResponse.success(new BrandSimpleVo(true));
}
@@ -170,9 +168,8 @@ public class BrandTaskController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "任务不存在或当前状态不可取消")
})
public ApiResponse<BrandSimpleVo> cancelTask(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
brandTaskService.cancelTask(taskId, userId);
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
brandTaskService.cancelTask(taskId);
return ApiResponse.success(new BrandSimpleVo(true));
}
@@ -186,9 +183,8 @@ public class BrandTaskController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "任务不存在或正在执行中不可删除")
})
public ApiResponse<BrandSimpleVo> deleteTask(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
brandTaskService.deleteTask(taskId, userId);
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
brandTaskService.deleteTask(taskId);
return ApiResponse.success(new BrandSimpleVo(true));
}
@@ -202,9 +198,8 @@ public class BrandTaskController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "任务不存在或无结果可下载")
})
public ResponseEntity<Void> download(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
String url = brandTaskService.resolveDownloadUrl(taskId, userId);
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
String url = brandTaskService.resolveDownloadUrl(taskId);
return ResponseEntity.status(302)
.header(HttpHeaders.LOCATION, url)
.build();

View File

@@ -139,8 +139,8 @@ public class BrandTaskService {
return vo;
}
public LegacyBrandTaskDetailVo getTaskDetailLegacy(Long taskId, Long userId) {
BrandCrawlTaskEntity task = requireTask(taskId, userId);
public LegacyBrandTaskDetailVo getTaskDetailLegacy(Long taskId) {
BrandCrawlTaskEntity task = requireTask(taskId);
LegacyBrandTaskDetailVo vo = new LegacyBrandTaskDetailVo();
vo.setTask(toLegacyTaskItem(task));
vo.setLine_progress(buildLineProgress(taskId));
@@ -204,8 +204,8 @@ public class BrandTaskService {
return vo;
}
public void submitCrawlResult(Long taskId, Long userId, BrandCrawlResultRequest request) {
BrandCrawlTaskEntity task = requireTask(taskId, userId);
public void submitCrawlResult(Long taskId, BrandCrawlResultRequest request) {
BrandCrawlTaskEntity task = requireTask(taskId);
if (STATUS_CANCELLED.equalsIgnoreCase(blankToDefault(task.getStatus(), STATUS_PENDING))) {
throw new BusinessException("任务已取消");
}
@@ -310,11 +310,10 @@ public class BrandTaskService {
}
}
public void cancelTask(Long taskId, Long userId) {
requireTask(taskId, userId);
public void cancelTask(Long taskId) {
requireTask(taskId);
int updated = brandCrawlTaskMapper.update(null, new LambdaUpdateWrapper<BrandCrawlTaskEntity>()
.eq(BrandCrawlTaskEntity::getId, taskId)
.eq(BrandCrawlTaskEntity::getUserId, userId)
.in(BrandCrawlTaskEntity::getStatus, STATUS_PENDING, STATUS_RUNNING)
.set(BrandCrawlTaskEntity::getStatus, STATUS_CANCELLED));
if (updated == 0) {
@@ -323,19 +322,18 @@ public class BrandTaskService {
brandTaskProgressCacheService.delete(taskId);
}
public void deleteTask(Long taskId, Long userId) {
requireTask(taskId, userId);
public void deleteTask(Long taskId) {
requireTask(taskId);
int deleted = brandCrawlTaskMapper.delete(new LambdaQueryWrapper<BrandCrawlTaskEntity>()
.eq(BrandCrawlTaskEntity::getId, taskId)
.eq(BrandCrawlTaskEntity::getUserId, userId)
.ne(BrandCrawlTaskEntity::getStatus, STATUS_RUNNING));
if (deleted == 0) {
throw new BusinessException("任务不存在或正在执行中无法删除");
}
}
public String resolveDownloadUrl(Long taskId, Long userId) {
BrandCrawlTaskEntity task = requireTask(taskId, userId);
public String resolveDownloadUrl(Long taskId) {
BrandCrawlTaskEntity task = requireTask(taskId);
Object raw = parseJsonValue(task.getResultPaths());
if (!(raw instanceof Map<?, ?> map)) {
throw new BusinessException("无结果可下载");